diff options
author | Michael Tuexen <tuexen@FreeBSD.org> | 2010-11-07 18:50:35 +0000 |
---|---|---|
committer | Michael Tuexen <tuexen@FreeBSD.org> | 2010-11-07 18:50:35 +0000 |
commit | 437fc91ae619a45e61d08b9207c88599dc5583f0 (patch) | |
tree | 77af1ab00266f89fccd57bd3c5fad0987393dd07 /sys/netinet/sctputil.c | |
parent | 228a253795f21dbc5c184c3eec5497a8c9b03f41 (diff) | |
download | src-437fc91ae619a45e61d08b9207c88599dc5583f0.tar.gz src-437fc91ae619a45e61d08b9207c88599dc5583f0.zip |
Do not have the MTU table twice in the code. Therefore move the
function from the timer code to util, rename it appropriately and
also fix a bug in sctp_get_prev_mtu(), where calling it with a
value existing in the MTU table did not return a smaller one.
MFC after: 3 days.
Notes
Notes:
svn path=/head/; revision=214939
Diffstat (limited to 'sys/netinet/sctputil.c')
-rw-r--r-- | sys/netinet/sctputil.c | 49 |
1 files changed, 32 insertions, 17 deletions
diff --git a/sys/netinet/sctputil.c b/sys/netinet/sctputil.c index cdd986c52969..13d7eaee3b6f 100644 --- a/sys/netinet/sctputil.c +++ b/sys/netinet/sctputil.c @@ -50,8 +50,6 @@ __FBSDID("$FreeBSD$"); #include <netinet/sctp_cc_functions.h> #include <netinet/sctp_bsd_addr.h> -#define NUMBER_OF_MTU_SIZES 18 - #ifndef KTR_SCTP #define KTR_SCTP KTR_SUBSYS @@ -753,7 +751,7 @@ sctp_stop_timers_for_shutdown(struct sctp_tcb *stcb) * a list of sizes based on typical mtu's, used only if next hop size not * returned. */ -static int sctp_mtu_sizes[] = { +static uint32_t sctp_mtu_sizes[] = { 68, 296, 508, @@ -774,25 +772,42 @@ static int sctp_mtu_sizes[] = { 65535 }; -int -find_next_best_mtu(int totsz) +/* + * Return the largest MTU smaller than val. If there is no + * entry, just return val. + */ +uint32_t +sctp_get_prev_mtu(uint32_t val) { - int i, perfer; + uint32_t i; - /* - * if we are in here we must find the next best fit based on the - * size of the dg that failed to be sent. - */ - perfer = 0; - for (i = 0; i < NUMBER_OF_MTU_SIZES; i++) { - if (totsz < sctp_mtu_sizes[i]) { - perfer = i - 1; - if (perfer < 0) - perfer = 0; + if (val <= sctp_mtu_sizes[0]) { + return (val); + } + for (i = 1; i < (sizeof(sctp_mtu_sizes) / sizeof(uint32_t)); i++) { + if (val <= sctp_mtu_sizes[i]) { break; } } - return (sctp_mtu_sizes[perfer]); + return (sctp_mtu_sizes[i - 1]); +} + +/* + * Return the smallest MTU larger than val. If there is no + * entry, just return val. + */ +uint32_t +sctp_get_next_mtu(struct sctp_inpcb *inp, uint32_t val) +{ + /* select another MTU that is just bigger than this one */ + uint32_t i; + + for (i = 0; i < (sizeof(sctp_mtu_sizes) / sizeof(uint32_t)); i++) { + if (val < sctp_mtu_sizes[i]) { + return (sctp_mtu_sizes[i]); + } + } + return (val); } void |