Skip to content

Commit d1e462a

Browse files
lxindavem330
authored andcommitted
sctp: add probe_interval in sysctl and sock/asoc/transport
PLPMTUD can be enabled by doing 'sysctl -w net.sctp.probe_interval=n'. 'n' is the interval for PLPMTUD probe timer in milliseconds, and it can't be less than 5000 if it's not 0. All asoc/transport's PLPMTUD in a new socket will be enabled by default. Signed-off-by: Xin Long <lucien.xin@gmail.com> Acked-by: Marcelo Ricardo Leitner <marcelo.leitner@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 745a321 commit d1e462a

File tree

7 files changed

+54
-0
lines changed

7 files changed

+54
-0
lines changed

Documentation/networking/ip-sysctl.rst

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2834,6 +2834,14 @@ encap_port - INTEGER
28342834

28352835
Default: 0
28362836

2837+
plpmtud_probe_interval - INTEGER
2838+
The time interval (in milliseconds) for sending PLPMTUD probe chunks.
2839+
These chunks are sent at the specified interval with a variable size
2840+
to probe the mtu of a given path between 2 endpoints. PLPMTUD will
2841+
be disabled when 0 is set, and other values for it must be >= 5000.
2842+
2843+
Default: 0
2844+
28372845

28382846
``/proc/sys/net/core/*``
28392847
========================

include/net/netns/sctp.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,9 @@ struct netns_sctp {
8484
/* HB.interval - 30 seconds */
8585
unsigned int hb_interval;
8686

87+
/* The interval for PLPMTUD probe timer */
88+
unsigned int probe_interval;
89+
8790
/* Association.Max.Retrans - 10 attempts
8891
* Path.Max.Retrans - 5 attempts (per destination address)
8992
* Max.Init.Retransmits - 8 attempts

include/net/sctp/constants.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -424,4 +424,6 @@ enum {
424424
*/
425425
#define SCTP_AUTH_RANDOM_LENGTH 32
426426

427+
#define SCTP_PROBE_TIMER_MIN 5000
428+
427429
#endif /* __sctp_constants_h__ */

include/net/sctp/structs.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,7 @@ struct sctp_sock {
177177
* will be inherited by all new associations.
178178
*/
179179
__u32 hbinterval;
180+
__u32 probe_interval;
180181

181182
__be16 udp_port;
182183
__be16 encap_port;
@@ -858,6 +859,7 @@ struct sctp_transport {
858859
* the destination address every heartbeat interval.
859860
*/
860861
unsigned long hbinterval;
862+
unsigned long probe_interval;
861863

862864
/* SACK delay timeout */
863865
unsigned long sackdelay;
@@ -1795,6 +1797,7 @@ struct sctp_association {
17951797
* will be inherited by all new transports.
17961798
*/
17971799
unsigned long hbinterval;
1800+
unsigned long probe_interval;
17981801

17991802
__be16 encap_port;
18001803

net/sctp/associola.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@ static struct sctp_association *sctp_association_init(
9898
* sock configured value.
9999
*/
100100
asoc->hbinterval = msecs_to_jiffies(sp->hbinterval);
101+
asoc->probe_interval = msecs_to_jiffies(sp->probe_interval);
101102

102103
asoc->encap_port = sp->encap_port;
103104

@@ -625,6 +626,7 @@ struct sctp_transport *sctp_assoc_add_peer(struct sctp_association *asoc,
625626
* association configured value.
626627
*/
627628
peer->hbinterval = asoc->hbinterval;
629+
peer->probe_interval = asoc->probe_interval;
628630

629631
peer->encap_port = asoc->encap_port;
630632

net/sctp/socket.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4989,6 +4989,7 @@ static int sctp_init_sock(struct sock *sk)
49894989
atomic_set(&sp->pd_mode, 0);
49904990
skb_queue_head_init(&sp->pd_lobby);
49914991
sp->frag_interleave = 0;
4992+
sp->probe_interval = net->sctp.probe_interval;
49924993

49934994
/* Create a per socket endpoint structure. Even if we
49944995
* change the data structure relationships, this may still

net/sctp/sysctl.c

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,8 @@ static int proc_sctp_do_alpha_beta(struct ctl_table *ctl, int write,
5555
void *buffer, size_t *lenp, loff_t *ppos);
5656
static int proc_sctp_do_auth(struct ctl_table *ctl, int write,
5757
void *buffer, size_t *lenp, loff_t *ppos);
58+
static int proc_sctp_do_probe_interval(struct ctl_table *ctl, int write,
59+
void *buffer, size_t *lenp, loff_t *ppos);
5860

5961
static struct ctl_table sctp_table[] = {
6062
{
@@ -293,6 +295,13 @@ static struct ctl_table sctp_net_table[] = {
293295
.mode = 0644,
294296
.proc_handler = proc_dointvec,
295297
},
298+
{
299+
.procname = "plpmtud_probe_interval",
300+
.data = &init_net.sctp.probe_interval,
301+
.maxlen = sizeof(int),
302+
.mode = 0644,
303+
.proc_handler = proc_sctp_do_probe_interval,
304+
},
296305
{
297306
.procname = "udp_port",
298307
.data = &init_net.sctp.udp_port,
@@ -539,6 +548,32 @@ static int proc_sctp_do_udp_port(struct ctl_table *ctl, int write,
539548
return ret;
540549
}
541550

551+
static int proc_sctp_do_probe_interval(struct ctl_table *ctl, int write,
552+
void *buffer, size_t *lenp, loff_t *ppos)
553+
{
554+
struct net *net = current->nsproxy->net_ns;
555+
struct ctl_table tbl;
556+
int ret, new_value;
557+
558+
memset(&tbl, 0, sizeof(struct ctl_table));
559+
tbl.maxlen = sizeof(unsigned int);
560+
561+
if (write)
562+
tbl.data = &new_value;
563+
else
564+
tbl.data = &net->sctp.probe_interval;
565+
566+
ret = proc_dointvec(&tbl, write, buffer, lenp, ppos);
567+
if (write && ret == 0) {
568+
if (new_value && new_value < SCTP_PROBE_TIMER_MIN)
569+
return -EINVAL;
570+
571+
net->sctp.probe_interval = new_value;
572+
}
573+
574+
return ret;
575+
}
576+
542577
int sctp_sysctl_net_register(struct net *net)
543578
{
544579
struct ctl_table *table;

0 commit comments

Comments
 (0)