Skip to content

Commit

Permalink
sctp: add probe_interval in sysctl and sock/asoc/transport
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Xin Long authored and David S. Miller committed Jun 22, 2021
1 parent 745a321 commit d1e462a
Show file tree
Hide file tree
Showing 7 changed files with 54 additions and 0 deletions.
8 changes: 8 additions & 0 deletions Documentation/networking/ip-sysctl.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2834,6 +2834,14 @@ encap_port - INTEGER

Default: 0

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

Default: 0


``/proc/sys/net/core/*``
========================
Expand Down
3 changes: 3 additions & 0 deletions include/net/netns/sctp.h
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,9 @@ struct netns_sctp {
/* HB.interval - 30 seconds */
unsigned int hb_interval;

/* The interval for PLPMTUD probe timer */
unsigned int probe_interval;

/* Association.Max.Retrans - 10 attempts
* Path.Max.Retrans - 5 attempts (per destination address)
* Max.Init.Retransmits - 8 attempts
Expand Down
2 changes: 2 additions & 0 deletions include/net/sctp/constants.h
Original file line number Diff line number Diff line change
Expand Up @@ -424,4 +424,6 @@ enum {
*/
#define SCTP_AUTH_RANDOM_LENGTH 32

#define SCTP_PROBE_TIMER_MIN 5000

#endif /* __sctp_constants_h__ */
3 changes: 3 additions & 0 deletions include/net/sctp/structs.h
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,7 @@ struct sctp_sock {
* will be inherited by all new associations.
*/
__u32 hbinterval;
__u32 probe_interval;

__be16 udp_port;
__be16 encap_port;
Expand Down Expand Up @@ -858,6 +859,7 @@ struct sctp_transport {
* the destination address every heartbeat interval.
*/
unsigned long hbinterval;
unsigned long probe_interval;

/* SACK delay timeout */
unsigned long sackdelay;
Expand Down Expand Up @@ -1795,6 +1797,7 @@ struct sctp_association {
* will be inherited by all new transports.
*/
unsigned long hbinterval;
unsigned long probe_interval;

__be16 encap_port;

Expand Down
2 changes: 2 additions & 0 deletions net/sctp/associola.c
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ static struct sctp_association *sctp_association_init(
* sock configured value.
*/
asoc->hbinterval = msecs_to_jiffies(sp->hbinterval);
asoc->probe_interval = msecs_to_jiffies(sp->probe_interval);

asoc->encap_port = sp->encap_port;

Expand Down Expand Up @@ -625,6 +626,7 @@ struct sctp_transport *sctp_assoc_add_peer(struct sctp_association *asoc,
* association configured value.
*/
peer->hbinterval = asoc->hbinterval;
peer->probe_interval = asoc->probe_interval;

peer->encap_port = asoc->encap_port;

Expand Down
1 change: 1 addition & 0 deletions net/sctp/socket.c
Original file line number Diff line number Diff line change
Expand Up @@ -4989,6 +4989,7 @@ static int sctp_init_sock(struct sock *sk)
atomic_set(&sp->pd_mode, 0);
skb_queue_head_init(&sp->pd_lobby);
sp->frag_interleave = 0;
sp->probe_interval = net->sctp.probe_interval;

/* Create a per socket endpoint structure. Even if we
* change the data structure relationships, this may still
Expand Down
35 changes: 35 additions & 0 deletions net/sctp/sysctl.c
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ static int proc_sctp_do_alpha_beta(struct ctl_table *ctl, int write,
void *buffer, size_t *lenp, loff_t *ppos);
static int proc_sctp_do_auth(struct ctl_table *ctl, int write,
void *buffer, size_t *lenp, loff_t *ppos);
static int proc_sctp_do_probe_interval(struct ctl_table *ctl, int write,
void *buffer, size_t *lenp, loff_t *ppos);

static struct ctl_table sctp_table[] = {
{
Expand Down Expand Up @@ -293,6 +295,13 @@ static struct ctl_table sctp_net_table[] = {
.mode = 0644,
.proc_handler = proc_dointvec,
},
{
.procname = "plpmtud_probe_interval",
.data = &init_net.sctp.probe_interval,
.maxlen = sizeof(int),
.mode = 0644,
.proc_handler = proc_sctp_do_probe_interval,
},
{
.procname = "udp_port",
.data = &init_net.sctp.udp_port,
Expand Down Expand Up @@ -539,6 +548,32 @@ static int proc_sctp_do_udp_port(struct ctl_table *ctl, int write,
return ret;
}

static int proc_sctp_do_probe_interval(struct ctl_table *ctl, int write,
void *buffer, size_t *lenp, loff_t *ppos)
{
struct net *net = current->nsproxy->net_ns;
struct ctl_table tbl;
int ret, new_value;

memset(&tbl, 0, sizeof(struct ctl_table));
tbl.maxlen = sizeof(unsigned int);

if (write)
tbl.data = &new_value;
else
tbl.data = &net->sctp.probe_interval;

ret = proc_dointvec(&tbl, write, buffer, lenp, ppos);
if (write && ret == 0) {
if (new_value && new_value < SCTP_PROBE_TIMER_MIN)
return -EINVAL;

net->sctp.probe_interval = new_value;
}

return ret;
}

int sctp_sysctl_net_register(struct net *net)
{
struct ctl_table *table;
Expand Down

0 comments on commit d1e462a

Please sign in to comment.