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
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=214939
@ -1670,46 +1670,6 @@ sctp_heartbeat_timer(struct sctp_inpcb *inp, struct sctp_tcb *stcb,
|
||||
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 *inp,
|
||||
{
|
||||
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) ||
|
||||
|
@ -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)) {
|
||||
|
@ -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
|
||||
|
@ -124,7 +124,8 @@ sctp_append_to_readq(struct sctp_inpcb *inp,
|
||||
|
||||
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 *);
|
||||
|
Loading…
Reference in New Issue
Block a user