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.
This commit is contained in:
parent
228a253795
commit
437fc91ae6
@ -1670,46 +1670,6 @@ sctp_heartbeat_timer(struct sctp_inpcb *inp, struct sctp_tcb *stcb,
|
|||||||
return (0);
|
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
|
void
|
||||||
sctp_pathmtu_timer(struct sctp_inpcb *inp,
|
sctp_pathmtu_timer(struct sctp_inpcb *inp,
|
||||||
struct sctp_tcb *stcb,
|
struct sctp_tcb *stcb,
|
||||||
@ -1717,7 +1677,7 @@ sctp_pathmtu_timer(struct sctp_inpcb *inp,
|
|||||||
{
|
{
|
||||||
uint32_t next_mtu, mtu;
|
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 ((next_mtu > net->mtu) && (net->port == 0)) {
|
||||||
if ((net->src_addr_selected == 0) ||
|
if ((net->src_addr_selected == 0) ||
|
||||||
|
@ -194,7 +194,7 @@ sctp_notify_mbuf(struct sctp_inpcb *inp,
|
|||||||
* mtu is. Rats we will have to guess (in a educated fashion
|
* mtu is. Rats we will have to guess (in a educated fashion
|
||||||
* of course)
|
* of course)
|
||||||
*/
|
*/
|
||||||
nxtsz = find_next_best_mtu(totsz);
|
nxtsz = sctp_get_prev_mtu(totsz);
|
||||||
}
|
}
|
||||||
/* Stop any PMTU timer */
|
/* Stop any PMTU timer */
|
||||||
if (SCTP_OS_TIMER_PENDING(&net->pmtu_timer.timer)) {
|
if (SCTP_OS_TIMER_PENDING(&net->pmtu_timer.timer)) {
|
||||||
|
@ -50,8 +50,6 @@ __FBSDID("$FreeBSD$");
|
|||||||
#include <netinet/sctp_cc_functions.h>
|
#include <netinet/sctp_cc_functions.h>
|
||||||
#include <netinet/sctp_bsd_addr.h>
|
#include <netinet/sctp_bsd_addr.h>
|
||||||
|
|
||||||
#define NUMBER_OF_MTU_SIZES 18
|
|
||||||
|
|
||||||
|
|
||||||
#ifndef KTR_SCTP
|
#ifndef KTR_SCTP
|
||||||
#define KTR_SCTP KTR_SUBSYS
|
#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
|
* a list of sizes based on typical mtu's, used only if next hop size not
|
||||||
* returned.
|
* returned.
|
||||||
*/
|
*/
|
||||||
static int sctp_mtu_sizes[] = {
|
static uint32_t sctp_mtu_sizes[] = {
|
||||||
68,
|
68,
|
||||||
296,
|
296,
|
||||||
508,
|
508,
|
||||||
@ -774,25 +772,42 @@ static int sctp_mtu_sizes[] = {
|
|||||||
65535
|
65535
|
||||||
};
|
};
|
||||||
|
|
||||||
int
|
|
||||||
find_next_best_mtu(int totsz)
|
|
||||||
{
|
|
||||||
int i, perfer;
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* if we are in here we must find the next best fit based on the
|
* Return the largest MTU smaller than val. If there is no
|
||||||
* size of the dg that failed to be sent.
|
* entry, just return val.
|
||||||
*/
|
*/
|
||||||
perfer = 0;
|
uint32_t
|
||||||
for (i = 0; i < NUMBER_OF_MTU_SIZES; i++) {
|
sctp_get_prev_mtu(uint32_t val)
|
||||||
if (totsz < sctp_mtu_sizes[i]) {
|
{
|
||||||
perfer = i - 1;
|
uint32_t i;
|
||||||
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;
|
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
|
void
|
||||||
|
@ -124,7 +124,8 @@ sctp_append_to_readq(struct sctp_inpcb *inp,
|
|||||||
|
|
||||||
void sctp_iterator_worker(void);
|
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
|
void
|
||||||
sctp_timeout_handler(void *);
|
sctp_timeout_handler(void *);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user