svn commit: r215583 - stable/8/sys/netinet
Michael Tuexen
tuexen at FreeBSD.org
Sat Nov 20 19:37:00 UTC 2010
Author: tuexen
Date: Sat Nov 20 19:37:00 2010
New Revision: 215583
URL: http://svn.freebsd.org/changeset/base/215583
Log:
MFC r214939:
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.
Modified:
stable/8/sys/netinet/sctp_timer.c
stable/8/sys/netinet/sctp_usrreq.c
stable/8/sys/netinet/sctputil.c
stable/8/sys/netinet/sctputil.h
Directory Properties:
stable/8/sys/ (props changed)
stable/8/sys/amd64/include/xen/ (props changed)
stable/8/sys/cddl/contrib/opensolaris/ (props changed)
stable/8/sys/contrib/dev/acpica/ (props changed)
stable/8/sys/contrib/pf/ (props changed)
stable/8/sys/dev/xen/xenpci/ (props changed)
Modified: stable/8/sys/netinet/sctp_timer.c
==============================================================================
--- stable/8/sys/netinet/sctp_timer.c Sat Nov 20 19:35:13 2010 (r215582)
+++ stable/8/sys/netinet/sctp_timer.c Sat Nov 20 19:37:00 2010 (r215583)
@@ -1670,46 +1670,6 @@ sctp_heartbeat_timer(struct sctp_inpcb *
return (0);
}
-#define SCTP_NUMBER_OF_MTU_SIZES 18
-static uint32_t mtu_sizes[] = {
- 68,
- 296,
- 508,
- 512,
- 544,
- 576,
- 1006,
- 1492,
- 1500,
- 1536,
- 2002,
- 2048,
- 4352,
- 4464,
- 8166,
- 17914,
- 32000,
- 65535
-};
-
-
-static uint32_t
-sctp_getnext_mtu(struct sctp_inpcb *inp, uint32_t cur_mtu)
-{
- /* select another MTU that is just bigger than this one */
- int i;
-
- for (i = 0; i < SCTP_NUMBER_OF_MTU_SIZES; i++) {
- if (cur_mtu < mtu_sizes[i]) {
- /* no max_mtu is bigger than this one */
- return (mtu_sizes[i]);
- }
- }
- /* here return the highest allowable */
- return (cur_mtu);
-}
-
-
void
sctp_pathmtu_timer(struct sctp_inpcb *inp,
struct sctp_tcb *stcb,
@@ -1717,7 +1677,7 @@ sctp_pathmtu_timer(struct sctp_inpcb *in
{
uint32_t next_mtu, mtu;
- next_mtu = sctp_getnext_mtu(inp, net->mtu);
+ next_mtu = sctp_get_next_mtu(inp, net->mtu);
if ((next_mtu > net->mtu) && (net->port == 0)) {
if ((net->src_addr_selected == 0) ||
Modified: stable/8/sys/netinet/sctp_usrreq.c
==============================================================================
--- stable/8/sys/netinet/sctp_usrreq.c Sat Nov 20 19:35:13 2010 (r215582)
+++ stable/8/sys/netinet/sctp_usrreq.c Sat Nov 20 19:37:00 2010 (r215583)
@@ -194,7 +194,7 @@ sctp_notify_mbuf(struct sctp_inpcb *inp,
* mtu is. Rats we will have to guess (in a educated fashion
* of course)
*/
- nxtsz = find_next_best_mtu(totsz);
+ nxtsz = sctp_get_prev_mtu(totsz);
}
/* Stop any PMTU timer */
if (SCTP_OS_TIMER_PENDING(&net->pmtu_timer.timer)) {
Modified: stable/8/sys/netinet/sctputil.c
==============================================================================
--- stable/8/sys/netinet/sctputil.c Sat Nov 20 19:35:13 2010 (r215582)
+++ stable/8/sys/netinet/sctputil.c Sat Nov 20 19:37:00 2010 (r215583)
@@ -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 sct
* 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
Modified: stable/8/sys/netinet/sctputil.h
==============================================================================
--- stable/8/sys/netinet/sctputil.h Sat Nov 20 19:35:13 2010 (r215582)
+++ stable/8/sys/netinet/sctputil.h Sat Nov 20 19:37:00 2010 (r215583)
@@ -124,7 +124,8 @@ sctp_append_to_readq(struct sctp_inpcb *
void sctp_iterator_worker(void);
-int find_next_best_mtu(int);
+uint32_t sctp_get_prev_mtu(uint32_t);
+uint32_t sctp_get_next_mtu(struct sctp_inpcb *, uint32_t);
void
sctp_timeout_handler(void *);
More information about the svn-src-stable-8
mailing list