ipv6 addrconf: implement RFC7559 router solicitation backoff
Subsystems (3)
PATCH 1/1 ipv6 addrconf: implement RFC7559 router solicitation backoff
From: Maciej Żenczykowski <[email protected]>
This implements:
https://tools.ietf.org/html/rfc7559
Backoff is performed according to RFC3315 section 14:
https://tools.ietf.org/html/rfc3315#section-14
We allow setting /proc/sys/net/ipv6/conf/*/router_solicitations to a negative value meaning an unlimited number of retransmits, and we make this the new default (inline with the RFC).
We also add a new setting:
/proc/sys/net/ipv6/conf/*/router_solicitation_max_interval
defaulting to 1 hour (per RFC recommendation).
--- include/linux/ipv6.h | 1 + include/net/addrconf.h | 3 ++- include/net/if_inet6.h | 1 + include/uapi/linux/ipv6.h | 1 + net/ipv6/addrconf.c | 51 ++++++++++++++++++++++++++++++++++++++++------- 5 files changed, 49 insertions(+), 8 deletions(-)
include/linux/ipv6.h +1 -0
@@ -18,6 +18,7 @@ struct ipv6_devconf {__s32 dad_transmits;__s32 rtr_solicits;__s32 rtr_solicit_interval; +__s32 rtr_solicit_max_interval;__s32 rtr_solicit_delay;__s32 force_mld_version;__s32 mldv1_unsolicited_report_interval;
include/net/addrconf.h +2 -1
@@ -1,8 +1,9 @@#ifndef _ADDRCONF_H#define _ADDRCONF_H -#define MAX_RTR_SOLICITATIONS 3 +#define MAX_RTR_SOLICITATIONS -1/* unlimited */ #define RTR_SOLICITATION_INTERVAL (4*HZ) +#define RTR_SOLICITATION_MAX_INTERVAL (3600*HZ)/* 1 hour */ #define MIN_VALID_LIFETIME (2*3600)/* 2 hours */
include/net/if_inet6.h +1 -0
@@ -201,6 +201,7 @@ struct inet6_dev {struct ipv6_devstat stats;struct timer_list rs_timer; +__s32 rs_interval;/* in jiffies */ __u8 rs_probes;__u8 addr_gen_mode;
include/uapi/linux/ipv6.h +1 -0
@@ -177,6 +177,7 @@ enum {DEVCONF_DROP_UNICAST_IN_L2_MULTICAST ,DEVCONF_DROP_UNSOLICITED_NA ,DEVCONF_KEEP_ADDR_ON_DOWN , +DEVCONF_RTR_SOLICIT_MAX_INTERVAL , DEVCONF_MAX };
net/ipv6/addrconf.c +44 -7
124 lines not on this page · raw message
Signature · 1 line
2.8.0.rc3.226.g39d4020
Hello,
Quoted 93 lines · Maciej Żenczykowski
From: Maciej Żenczykowski <[email protected]>
This implements:
https://tools.ietf.org/html/rfc7559Backoff is performed according to RFC3315 section 14:
https://tools.ietf.org/html/rfc3315#section-14We allow setting
/proc/sys/net/ipv6/conf/*/router_solicitationsto a negative value meaning an unlimited number of retransmits, and we make this the new default (inline with the RFC).We also add a new setting:
/proc/sys/net/ipv6/conf/*/router_solicitation_max_interval
defaulting to 1 hour (per RFC recommendation).Signed-off-by Maciej Żenczykowski <[email protected]>--- include/linux/ipv6.h | 1 + include/net/addrconf.h | 3 ++- include/net/if_inet6.h | 1 + include/uapi/linux/ipv6.h | 1 + net/ipv6/addrconf.c | 51 ++++++++++++++++++++++++++++++++++++++++------- 5 files changed, 49 insertions(+), 8 deletions(-)include/linux/ipv6.h +1
-0@@ -18,6 +18,7 @@ struct ipv6_devconf {__s32 dad_transmits;__s32 rtr_solicits;__s32 rtr_solicit_interval; +__s32 rtr_solicit_max_interval;__s32 rtr_solicit_delay;__s32 force_mld_version;__s32 mldv1_unsolicited_report_interval;include/net/addrconf.h +2
-1@@ -1,8 +1,9 @@#ifndef _ADDRCONF_H#define _ADDRCONF_H -#define MAX_RTR_SOLICITATIONS 3 +#define MAX_RTR_SOLICITATIONS -1/* unlimited */ #define RTR_SOLICITATION_INTERVAL (4*HZ) +#define RTR_SOLICITATION_MAX_INTERVAL (3600*HZ)/* 1 hour */ #define MIN_VALID_LIFETIME (2*3600)/* 2 hours */ include/net/if_inet6.h +1
-0@@ -201,6 +201,7 @@ struct inet6_dev {struct ipv6_devstat stats;struct timer_list rs_timer; +__s32 rs_interval;/* in jiffies */ __u8 rs_probes;__u8 addr_gen_mode;include/uapi/linux/ipv6.h +1
-0@@ -177,6 +177,7 @@ enum {DEVCONF_DROP_UNICAST_IN_L2_MULTICAST ,DEVCONF_DROP_UNSOLICITED_NA ,DEVCONF_KEEP_ADDR_ON_DOWN , +DEVCONF_RTR_SOLICIT_MAX_INTERVAL , DEVCONF_MAX };net/ipv6/addrconf.c +8
-0@@ -112,6 +112,27 @@ static inline u32 cstamp_delta(unsigned long cstamp)return (cstamp -INITIAL_JIFFIES ) *100UL /HZ ; } +static inline s32 rfc3315_s14_backoff_init (s32 irt) +{ +/* multiply 'initial retransmission time' by 0.9 .. 1.1 */ +u64 tmp = (900000 +prandom_u32 () %200001 ) * (u64 )irt; +do_div (tmp,1000000 ); +return (s32 )tmp; +} +
net/ipv6/addrconf.c static inline u32 cstamp_delta(unsigned long cstamp) · line 132
Quoted 10 lines
net/ipv6/addrconf.c +9
-0+static inline s32 rfc3315_s14_backoff_update (s32 rt,s32 mrt) +{ +/* multiply 'retransmission timeout' by 1.9 .. 2.1 */ +u64 tmp = (1900000 +prandom_u32 () %200001 ) * (u64 )rt; +do_div (tmp,1000000 ); +if ((s32 )tmp > mrt) { +/* multiply 'maximum retransmission time' by 0.9 .. 1.1 */ + tmp = (900000 +prandom_u32 () %200001 ) * (u64 )mrt; +do_div (tmp,1000000 );
Could you use msecs_to_jiffies here to make the units more clear like I proposed in the last mail? Or is there a reason not to?
Bye,
Hannes
I'm not sure what line you're referring to.
There are *no* outright jiffies or msecs in this patch, with the exception of the (3600*HZ) line which is already obvious enough.
The 900000 200001 1900000 1000000 constants are not jiffies nor miliseconds, they're simply numbers, such that 900000/1000000 = 0.9 and 200001/1000000 =~ 0.2 (the +1 is to deal with 0) and 1900000/1000000 = 1.9
Erik Kline
Acked-byPasses my local unittest for this behaviour.
From: Maciej Żenczykowski <[email protected]>
Date: Tue, 27 Sep 2016 23:57:58 -0700
Quoted 12 lines
From: Maciej Żenczykowski <[email protected]>
This implements:
https://tools.ietf.org/html/rfc7559Backoff is performed according to RFC3315 section 14:
https://tools.ietf.org/html/rfc3315#section-14We allow setting
/proc/sys/net/ipv6/conf/*/router_solicitationsto a negative value meaning an unlimited number of retransmits, and we make this the new default (inline with the RFC).
Quoted 5 lines
We also add a new setting:
/proc/sys/net/ipv6/conf/*/router_solicitation_max_interval
defaulting to 1 hour (per RFC recommendation).Signed-off-by Maciej Żenczykowski <[email protected]>
Applied to net-next, thanks.