Skip to contentSkip to conversation

net/ipv6: add sysctl option accept_ra_min_hop_limit

PATCH Superseded Hangbin Liu 2 participants 5 messages Jul 29, 2015 – Jul 30, 2015

Subsystems (4)

v3 of 5 Superseded Latest is v5 →

lore
Share & tools
lore
#0 lore raw

PATCH v3 1/1 net/ipv6: add sysctl option accept_ra_min_hop_limit

Commit 6fd99094de2b ("ipv6: Don't reduce hop limit for an interface") disabled accept hop limit from RA if it is higher than the current hop limit for security stuff. But this behavior kind of break the RFC definition.

RFC 4861, 6.3.4. Processing Received Router Advertisements
A Router Advertisement field (e.g., Cur Hop Limit, Reachable Time, and Retrans Timer) may contain a value denoting that it is unspecified. In such cases, the parameter should be ignored and the host should continue using whatever value it is already using.

If the received Cur Hop Limit value is non-zero, the host SHOULD set its CurHopLimit variable to the received value.

So add sysctl option accept_ra_min_hop_limit to let user choose the minimum hop limit value they can accept from RA. And set default to 1 to meet RFC standards.

---
 Documentation/networking/ip-sysctl.txt |  8 ++++++++
 include/linux/ipv6.h                   |  1 +
 include/uapi/linux/ipv6.h              |  1 +
 net/ipv6/addrconf.c                    | 10 ++++++++++
 net/ipv6/ndisc.c                       |  8 +++-----
 5 files changed, 23 insertions(+), 5 deletions(-)
Documentation/networking/ip-sysctl.txt +8 -0
index 5fae770..ced0a38 100644
@@ -1346,6 +1346,14 @@ accept_ra_pinfo - BOOLEAN
 	Functional default: enabled if accept_ra is enabled.
 			    disabled if accept_ra is disabled.
 
+accept_ra_min_hop_limit - INTEGER
+	Minimum hop limit Information in Router Advertisement.
+
+	Hop limit Information in Router Advertisement less than this
+	variable shall be ignored.
+
+	Default: 1
+
 accept_ra_rt_info_max_plen - INTEGER
 	Maximum prefix length of Route Information in RA.
 
include/linux/ipv6.h +1 -0
index 82806c6..ac01ab4 100644
@@ -30,6 +30,7 @@ struct ipv6_devconf {
 	__s32		max_addresses;
 	__s32		accept_ra_defrtr;
 	__s32		accept_ra_pinfo;
+	__s32		accept_ra_min_hop_limit;
 #ifdef CONFIG_IPV6_ROUTER_PREF
 	__s32		accept_ra_rtr_pref;
 	__s32		rtr_probe_interval;
include/uapi/linux/ipv6.h +1 -0
index 5efa54a..68094e33 100644
@@ -171,6 +171,7 @@ enum {
 	DEVCONF_USE_OPTIMISTIC,
 	DEVCONF_ACCEPT_RA_MTU,
 	DEVCONF_STABLE_SECRET,
+	DEVCONF_ACCEPT_RA_MIN_HOP_LIMIT,
 	DEVCONF_MAX
 };
 
net/ipv6/addrconf.c +10 -0
index 21c2c81..77df8f2 100644
@@ -196,6 +196,7 @@ static struct ipv6_devconf ipv6_devconf __read_mostly = {
 	.accept_ra_defrtr	= 1,
 	.accept_ra_from_local	= 0,
 	.accept_ra_pinfo	= 1,
+	.accept_ra_min_hop_limit= 1,
 #ifdef CONFIG_IPV6_ROUTER_PREF
 	.accept_ra_rtr_pref	= 1,
 	.rtr_probe_interval	= 60 * HZ,
@@ -237,6 +238,7 @@ static struct ipv6_devconf ipv6_devconf_dflt __read_mostly = {
 	.accept_ra_defrtr	= 1,
 	.accept_ra_from_local	= 0,
 	.accept_ra_pinfo	= 1,
+	.accept_ra_min_hop_limit= 1,
 #ifdef CONFIG_IPV6_ROUTER_PREF
 	.accept_ra_rtr_pref	= 1,
 	.rtr_probe_interval	= 60 * HZ,
@@ -4561,6 +4563,7 @@ static inline void ipv6_store_devconf(struct ipv6_devconf *cnf,
 	array[DEVCONF_MAX_ADDRESSES] = cnf->max_addresses;
 	array[DEVCONF_ACCEPT_RA_DEFRTR] = cnf->accept_ra_defrtr;
 	array[DEVCONF_ACCEPT_RA_PINFO] = cnf->accept_ra_pinfo;
+	array[DEVCONF_ACCEPT_RA_MIN_HOP_LIMIT] = cnf->accept_ra_min_hop_limit;
 #ifdef CONFIG_IPV6_ROUTER_PREF
 	array[DEVCONF_ACCEPT_RA_RTR_PREF] = cnf->accept_ra_rtr_pref;
 	array[DEVCONF_RTR_PROBE_INTERVAL] =
@@ -5462,6 +5465,13 @@ static struct addrconf_sysctl_table
 			.mode		= 0644,
 			.proc_handler	= proc_dointvec,
 		},
+		{
+			.procname	= "accept_ra_min_hop_limit",
+			.data		= &ipv6_devconf.accept_ra_min_hop_limit,
+			.maxlen		= sizeof(int),
+			.mode		= 0644,
+			.proc_handler	= proc_dointvec,
+		},
 #ifdef CONFIG_IPV6_ROUTER_PREF
 		{
 			.procname	= "accept_ra_rtr_pref",
net/ipv6/ndisc.c +3 -5
index 0a05b35..acda056 100644
@@ -1226,13 +1226,11 @@ static void ndisc_router_discovery(struct sk_buff *skb)
 	if (rt)
 		rt6_set_expires(rt, jiffies + (HZ * lifetime));
 	if (ra_msg->icmph.icmp6_hop_limit) {
-		/* Only set hop_limit on the interface if it is higher than
-		 * the current hop_limit.
-		 */
-		if (in6_dev->cnf.hop_limit < ra_msg->icmph.icmp6_hop_limit) {
+		if (in6_dev->cnf.accept_ra_min_hop_limit <= ra_msg->icmph.icmp6_hop_limit &&
+		    ra_msg->icmph.icmp6_hop_limit != 0) {
 			in6_dev->cnf.hop_limit = ra_msg->icmph.icmp6_hop_limit;
 		} else {
-			ND_PRINTK(2, warn, "RA: Got route advertisement with lower hop_limit than current\n");
+			ND_PRINTK(2, warn, "RA: Got route advertisement with lower hop_limit than minimum\n");
 		}
 		if (rt)
 			dst_metric_set(&rt->dst, RTAX_HOPLIMIT,
Signature · 1 line
1.9.3
#1 lore raw

Hi,

Thank you for you updated patch.

Quoted 50 lines · Hangbin Liu

Commit 6fd99094de2b ("ipv6: Don't reduce hop limit for an interface") disabled accept hop limit from RA if it is higher than the current hop limit for security stuff. But this behavior kind of break the RFC definition.

RFC 4861, 6.3.4. Processing Received Router Advertisements
A Router Advertisement field (e.g., Cur Hop Limit, Reachable Time, and Retrans Timer) may contain a value denoting that it is unspecified. In such cases, the parameter should be ignored and the host should continue using whatever value it is already using.

If the received Cur Hop Limit value is non-zero, the host SHOULD set its CurHopLimit variable to the received value.

So add sysctl option accept_ra_min_hop_limit to let user choose the minimum hop limit value they can accept from RA. And set default to 1 to meet RFC standards.

---
 Documentation/networking/ip-sysctl.txt |  8 ++++++++
 include/linux/ipv6.h                   |  1 +
 include/uapi/linux/ipv6.h              |  1 +
 net/ipv6/addrconf.c                    | 10 ++++++++++
 net/ipv6/ndisc.c                       |  8 +++-----
 5 files changed, 23 insertions(+), 5 deletions(-)
Documentation/networking/ip-sysctl.txt +8 -0
index 5fae770..ced0a38 100644
@@ -1346,6 +1346,14 @@ accept_ra_pinfo - BOOLEAN
 	Functional default: enabled if accept_ra is enabled.
 			    disabled if accept_ra is disabled.
 
+accept_ra_min_hop_limit - INTEGER
+	Minimum hop limit Information in Router Advertisement.
+
+	Hop limit Information in Router Advertisement less than this
+	variable shall be ignored.
+
+	Default: 1
+
 accept_ra_rt_info_max_plen - INTEGER
 	Maximum prefix length of Route Information in RA.
 
include/linux/ipv6.h +0 -0
index 82806c6..ac01ab4 100644

include/linux/ipv6.h struct ipv6_devconf { · line 33

Quoted 4 lines
include/linux/ipv6.h +1 -0
@@ -30,6 +30,7 @@ struct ipv6_devconf {
 	__s32		max_addresses;
 	__s32		accept_ra_defrtr;
 	__s32		accept_ra_pinfo;
+	__s32		accept_ra_min_hop_limit;

accept_ra_defrtr
accept_ra_min_hop_limit
accept_ra_pinfo
(matter of taste)

Quoted 8 lines
include/linux/ipv6.h +0 -0
 #ifdef CONFIG_IPV6_ROUTER_PREF
 	__s32		accept_ra_rtr_pref;
 	__s32		rtr_probe_interval;
include/uapi/linux/ipv6.h +0 -0
index 5efa54a..68094e33 100644

include/uapi/linux/ipv6.h enum { · line 177

Quoted 7 lines
include/uapi/linux/ipv6.h +1 -0
@@ -171,6 +171,7 @@ enum {
 	DEVCONF_USE_OPTIMISTIC,
 	DEVCONF_ACCEPT_RA_MTU,
 	DEVCONF_STABLE_SECRET,
+	DEVCONF_ACCEPT_RA_MIN_HOP_LIMIT,
 	DEVCONF_MAX
 };
 

This patch cannot apply to current net-next. Please rebase your patch.

Quoted 21 lines
net/ipv6/addrconf.c +2 -0
index 21c2c81..77df8f2 100644
@@ -196,6 +196,7 @@ static struct ipv6_devconf ipv6_devconf __read_mostly = {
 	.accept_ra_defrtr	= 1,
 	.accept_ra_from_local	= 0,
 	.accept_ra_pinfo	= 1,
+	.accept_ra_min_hop_limit= 1,
 #ifdef CONFIG_IPV6_ROUTER_PREF
 	.accept_ra_rtr_pref	= 1,
 	.rtr_probe_interval	= 60 * HZ,
@@ -237,6 +238,7 @@ static struct ipv6_devconf ipv6_devconf_dflt __read_mostly = {
 	.accept_ra_defrtr	= 1,
 	.accept_ra_from_local	= 0,
 	.accept_ra_pinfo	= 1,
+	.accept_ra_min_hop_limit= 1,
 #ifdef CONFIG_IPV6_ROUTER_PREF
 	.accept_ra_rtr_pref	= 1,
 	.rtr_probe_interval	= 60 * HZ,

net/ipv6/addrconf.c static inline void ipv6_store_devconf(struct ipv6_devconf *cnf, · line 4566

Quoted 4 lines
net/ipv6/addrconf.c +1 -0
@@ -4561,6 +4563,7 @@ static inline void ipv6_store_devconf(struct ipv6_devconf *cnf,
 	array[DEVCONF_MAX_ADDRESSES] = cnf->max_addresses;
 	array[DEVCONF_ACCEPT_RA_DEFRTR] = cnf->accept_ra_defrtr;
 	array[DEVCONF_ACCEPT_RA_PINFO] = cnf->accept_ra_pinfo;
+	array[DEVCONF_ACCEPT_RA_MIN_HOP_LIMIT] = cnf->accept_ra_min_hop_limit;

DEFRTR, MIN_HOP_LIMIT then PINFO
(matter of taste)

Quoted 29 lines
net/ipv6/addrconf.c +7 -0
 #ifdef CONFIG_IPV6_ROUTER_PREF
 	array[DEVCONF_ACCEPT_RA_RTR_PREF] = cnf->accept_ra_rtr_pref;
 	array[DEVCONF_RTR_PROBE_INTERVAL] =
@@ -5462,6 +5465,13 @@ static struct addrconf_sysctl_table
 			.mode		= 0644,
 			.proc_handler	= proc_dointvec,
 		},
+		{
+			.procname	= "accept_ra_min_hop_limit",
+			.data		= &ipv6_devconf.accept_ra_min_hop_limit,
+			.maxlen		= sizeof(int),
+			.mode		= 0644,
+			.proc_handler	= proc_dointvec,
+		},
 #ifdef CONFIG_IPV6_ROUTER_PREF
 		{
 			.procname	= "accept_ra_rtr_pref",
net/ipv6/ndisc.c +0 -3
index 0a05b35..acda056 100644
@@ -1226,13 +1226,11 @@ static void ndisc_router_discovery(struct sk_buff *skb)
 	if (rt)
 		rt6_set_expires(rt, jiffies + (HZ * lifetime));
 	if (ra_msg->icmph.icmp6_hop_limit) {
-		/* Only set hop_limit on the interface if it is higher than
-		 * the current hop_limit.
-		 */

net/ipv6/ndisc.c static void ndisc_router_discovery(struct sk_buff *skb) · line 1236

Quoted 10 lines
net/ipv6/ndisc.c +3 -2
-		if (in6_dev->cnf.hop_limit < ra_msg->icmph.icmp6_hop_limit) {
+		if (in6_dev->cnf.accept_ra_min_hop_limit <= ra_msg->icmph.icmp6_hop_limit &&
+		    ra_msg->icmph.icmp6_hop_limit != 0) {
 			in6_dev->cnf.hop_limit = ra_msg->icmph.icmp6_hop_limit;
 		} else {
-			ND_PRINTK(2, warn, "RA: Got route advertisement with lower hop_limit than current\n");
+			ND_PRINTK(2, warn, "RA: Got route advertisement with lower hop_limit than minimum\n");
 		}
 		if (rt)
 			dst_metric_set(&rt->dst, RTAX_HOPLIMIT,

Please see my comments against your previous patch.

Signature · 2 lines
Hideaki Yoshifuji <[email protected]>
Technical Division, MIRACLE LINUX CORPORATION
#2 lore raw

Hi Yoshifuji-san,

Please see comments in the mail.

2015-07-29 18:39 GMT+08:00 YOSHIFUJI Hideaki
<[email protected]>:

Quoted 50 lines

Hi,

Thank you for you updated patch.

Quoted 45 lines · Hangbin Liu

Commit 6fd99094de2b ("ipv6: Don't reduce hop limit for an interface") disabled accept hop limit from RA if it is higher than the current hop limit for security stuff. But this behavior kind of break the RFC definition.

RFC 4861, 6.3.4. Processing Received Router Advertisements
A Router Advertisement field (e.g., Cur Hop Limit, Reachable Time, and Retrans Timer) may contain a value denoting that it is unspecified. In such cases, the parameter should be ignored and the host should continue using whatever value it is already using.

If the received Cur Hop Limit value is non-zero, the host SHOULD set its CurHopLimit variable to the received value.

So add sysctl option accept_ra_min_hop_limit to let user choose the minimum hop limit value they can accept from RA. And set default to 1 to meet RFC standards.

---
 Documentation/networking/ip-sysctl.txt |  8 ++++++++
 include/linux/ipv6.h                   |  1 +
 include/uapi/linux/ipv6.h              |  1 +
 net/ipv6/addrconf.c                    | 10 ++++++++++
 net/ipv6/ndisc.c                       |  8 +++-----
 5 files changed, 23 insertions(+), 5 deletions(-)
Documentation/networking/ip-sysctl.txt +8 -0
index 5fae770..ced0a38 100644
@@ -1346,6 +1346,14 @@ accept_ra_pinfo - BOOLEAN
      Functional default: enabled if accept_ra is enabled.
                          disabled if accept_ra is disabled.
 
+accept_ra_min_hop_limit - INTEGER
+     Minimum hop limit Information in Router Advertisement.
+
+     Hop limit Information in Router Advertisement less than this
+     variable shall be ignored.
+
+     Default: 1
+
 accept_ra_rt_info_max_plen - INTEGER
      Maximum prefix length of Route Information in RA.
 
Quoted 14 lines

include/linux/ipv6.h struct ipv6_devconf { · line 33

Quoted 9 lines
include/linux/ipv6.h +1 -0
index 82806c6..ac01ab4 100644
@@ -30,6 +30,7 @@ struct ipv6_devconf {
      __s32           max_addresses;
      __s32           accept_ra_defrtr;
      __s32           accept_ra_pinfo;
+     __s32           accept_ra_min_hop_limit;

accept_ra_defrtr
accept_ra_min_hop_limit
accept_ra_pinfo
(matter of taste)

Ah yes, alphabet order, that make sense.

Quoted 10 lines
Quoted 10 lines
include/linux/ipv6.h +0 -0
 #ifdef CONFIG_IPV6_ROUTER_PREF
      __s32           accept_ra_rtr_pref;
      __s32           rtr_probe_interval;
include/uapi/linux/ipv6.h +0 -0
index 5efa54a..68094e33 100644
@@ -171,6 +171,7 @@ enum {
      DEVCONF_USE_OPTIMISTIC,
Quoted 8 lines

include/uapi/linux/ipv6.h enum { · line 177

Quoted 6 lines
include/uapi/linux/ipv6.h +1 -0
      DEVCONF_ACCEPT_RA_MTU,
      DEVCONF_STABLE_SECRET,
+     DEVCONF_ACCEPT_RA_MIN_HOP_LIMIT,
      DEVCONF_MAX
 };
 

This patch cannot apply to current net-next. Please rebase your patch.

Got it, I will fix the patch based on latest net-next.

Quoted 21 lines
Quoted 21 lines
net/ipv6/addrconf.c +2 -0
index 21c2c81..77df8f2 100644
@@ -196,6 +196,7 @@ static struct ipv6_devconf ipv6_devconf __read_mostly = {
      .accept_ra_defrtr       = 1,
      .accept_ra_from_local   = 0,
      .accept_ra_pinfo        = 1,
+     .accept_ra_min_hop_limit= 1,
 #ifdef CONFIG_IPV6_ROUTER_PREF
      .accept_ra_rtr_pref     = 1,
      .rtr_probe_interval     = 60 * HZ,
@@ -237,6 +238,7 @@ static struct ipv6_devconf ipv6_devconf_dflt __read_mostly = {
      .accept_ra_defrtr       = 1,
      .accept_ra_from_local   = 0,
      .accept_ra_pinfo        = 1,
+     .accept_ra_min_hop_limit= 1,
 #ifdef CONFIG_IPV6_ROUTER_PREF
      .accept_ra_rtr_pref     = 1,
      .rtr_probe_interval     = 60 * HZ,
Quoted 8 lines

net/ipv6/addrconf.c static inline void ipv6_store_devconf(struct ipv6_devconf *cnf, · line 4566

Quoted 5 lines
net/ipv6/addrconf.c +1 -0
@@ -4561,6 +4563,7 @@ static inline void ipv6_store_devconf(struct ipv6_devconf *cnf,
      array[DEVCONF_MAX_ADDRESSES] = cnf->max_addresses;
      array[DEVCONF_ACCEPT_RA_DEFRTR] = cnf->accept_ra_defrtr;
      array[DEVCONF_ACCEPT_RA_PINFO] = cnf->accept_ra_pinfo;
+     array[DEVCONF_ACCEPT_RA_MIN_HOP_LIMIT] = cnf->accept_ra_min_hop_limit;

DEFRTR, MIN_HOP_LIMIT then PINFO
(matter of taste)

OK, will fix it.

Quoted 34 lines
Quoted 34 lines
net/ipv6/addrconf.c +7 -0
 #ifdef CONFIG_IPV6_ROUTER_PREF
      array[DEVCONF_ACCEPT_RA_RTR_PREF] = cnf->accept_ra_rtr_pref;
      array[DEVCONF_RTR_PROBE_INTERVAL] =
@@ -5462,6 +5465,13 @@ static struct addrconf_sysctl_table
                      .mode           = 0644,
                      .proc_handler   = proc_dointvec,
              },
+             {
+                     .procname       = "accept_ra_min_hop_limit",
+                     .data           = &ipv6_devconf.accept_ra_min_hop_limit,
+                     .maxlen         = sizeof(int),
+                     .mode           = 0644,
+                     .proc_handler   = proc_dointvec,
+             },
 #ifdef CONFIG_IPV6_ROUTER_PREF
              {
                      .procname       = "accept_ra_rtr_pref",
net/ipv6/ndisc.c +2 -4
index 0a05b35..acda056 100644
@@ -1226,13 +1226,11 @@ static void ndisc_router_discovery(struct sk_buff *skb)
      if (rt)
              rt6_set_expires(rt, jiffies + (HZ * lifetime));
      if (ra_msg->icmph.icmp6_hop_limit) {
-             /* Only set hop_limit on the interface if it is higher than
-              * the current hop_limit.
-              */
-             if (in6_dev->cnf.hop_limit < ra_msg->icmph.icmp6_hop_limit) {
+             if (in6_dev->cnf.accept_ra_min_hop_limit <= ra_msg->icmph.icmp6_hop_limit &&
+                 ra_msg->icmph.icmp6_hop_limit != 0) {
                      in6_dev->cnf.hop_limit = ra_msg->icmph.icmp6_hop_limit;
              } else {
Quoted 8 lines

net/ipv6/ndisc.c static void ndisc_router_discovery(struct sk_buff *skb) · line 1236

Quoted 6 lines
net/ipv6/ndisc.c +1 -1
-                     ND_PRINTK(2, warn, "RA: Got route advertisement with lower hop_limit than current\n");
+                     ND_PRINTK(2, warn, "RA: Got route advertisement with lower hop_limit than minimum\n");
              }
              if (rt)
                      dst_metric_set(&rt->dst, RTAX_HOPLIMIT,

Please see my comments against your previous patch.

I pasted you comments here so we don't need to discuss in two mails :)

Quoted 2 lines

ra_msg->icmph.icmp6_hop_limit != 0 is checkd by outer "if".

Yes, thanks for your reminding :)

Quoted 3 lines

You do not need to update cnf.hop_limit if it is already equal to hop limit received.

We need to update cnf.hop_limit if min_hop_limit <= icmp6_hop_limit. e.g. current hop limit is 64, min hop limit is 1 and ra hop limit is 32, then we need update current hop limit to 32.

Quoted 3 lines

How about ignoring hop limit without message is configured value is larger than 255, BTW?

Although set accept_ra_min_hop_limit great than 255 is meaningless, there is also no need to check it since icmp6_hop_limit will not larger than 255. so

+ if (in6_dev->cnf.accept_ra_min_hop_limit <= 255 &&
+ in6_dev->cnf.accept_ra_min_hop_limit <=
ra_msg->icmph.icmp6_hop_limit )

                        in6_dev->cnf.hop_limit = ra_msg->icmph.icmp6_hop_limit;

is duplicated check. How do you think?

Quoted 6 lines
Quoted 4 lines
              if (rt)
                      dst_metric_set(&rt->dst, RTAX_HOPLIMIT,

This can be inside the inner "if".

OK, will move it.

Best Regards
Hangbin

#3 lore raw

Hi,

Quoted 33 lines · Hangbin Liu
Quoted 16 lines
Quoted 16 lines
net/ipv6/ndisc.c +2 -4
index 0a05b35..acda056 100644
@@ -1226,13 +1226,11 @@ static void ndisc_router_discovery(struct sk_buff *skb)
      if (rt)
              rt6_set_expires(rt, jiffies + (HZ * lifetime));
      if (ra_msg->icmph.icmp6_hop_limit) {
-             /* Only set hop_limit on the interface if it is higher than
-              * the current hop_limit.
-              */
-             if (in6_dev->cnf.hop_limit < ra_msg->icmph.icmp6_hop_limit) {
+             if (in6_dev->cnf.accept_ra_min_hop_limit <= ra_msg->icmph.icmp6_hop_limit &&
+                 ra_msg->icmph.icmp6_hop_limit != 0) {
                      in6_dev->cnf.hop_limit = ra_msg->icmph.icmp6_hop_limit;
              } else {
Quoted 8 lines

net/ipv6/ndisc.c static void ndisc_router_discovery(struct sk_buff *skb) · line 1236

Quoted 6 lines
net/ipv6/ndisc.c +1 -1
-                     ND_PRINTK(2, warn, "RA: Got route advertisement with lower hop_limit than current\n");
+                     ND_PRINTK(2, warn, "RA: Got route advertisement with lower hop_limit than minimum\n");
              }
              if (rt)
                      dst_metric_set(&rt->dst, RTAX_HOPLIMIT,

Please see my comments against your previous patch.

I pasted you comments here so we don't need to discuss in two mails :)

Quoted 2 lines

ra_msg->icmph.icmp6_hop_limit != 0 is checkd by outer "if".

Yes, thanks for your reminding :)

Quoted 1 line
Quoted 6 lines
Quoted 2 lines

You do not need to update cnf.hop_limit if it is already equal to hop limit received.

We need to update cnf.hop_limit if min_hop_limit <= icmp6_hop_limit. e.g. current hop limit is 64, min hop limit is 1 and ra hop limit is 32, then we need update current hop limit to 32.

OK

Quoted 11 lines
Quoted 4 lines

How about ignoring hop limit without message is configured value is larger than 255, BTW?

Although set accept_ra_min_hop_limit great than 255 is meaningless, there is also no need to check it since icmp6_hop_limit will not larger than 255. so

(quoted diff) +2 -0
+               if (in6_dev->cnf.accept_ra_min_hop_limit <= 255 &&
+                   in6_dev->cnf.accept_ra_min_hop_limit <=

ra_msg->icmph.icmp6_hop_limit )

Quoted 3 lines
                        in6_dev->cnf.hop_limit = ra_msg->icmph.icmp6_hop_limit;

is duplicated check. How do you think?

How about checking in6_dev->cnf.accept_ra_min_hop_limit by outer if, then?

if (in6_dev->cnf.accept_ra_min_hop_limit < 256 &&

    ra_msg->icmph.icmp6_hop_limit) {

...
}

Quoted 6 lines
Quoted 6 lines
Quoted 5 lines

              if (rt)
                      dst_metric_set(&rt->dst, RTAX_HOPLIMIT,
Quoted 8 lines
Quoted 1 line

This can be inside the inner "if".

OK, will move it.

Best Regards
Hangbin

Regards,

Signature · 2 lines
Hideaki Yoshifuji <[email protected]>
Technical Division, MIRACLE LINUX CORPORATION
#4 lore raw

2015-07-30 8:45 GMT+08:00 YOSHIFUJI Hideaki
<[email protected]>:

Quoted 13 lines
Quoted 9 lines
Quoted 2 lines

How about ignoring hop limit without message is configured value is larger than 255, BTW?

Although set accept_ra_min_hop_limit great than 255 is meaningless, there is also no need to check it since icmp6_hop_limit will not larger than 255. so

(quoted diff) +2 -0
+               if (in6_dev->cnf.accept_ra_min_hop_limit <= 255 &&
+                   in6_dev->cnf.accept_ra_min_hop_limit <=

ra_msg->icmph.icmp6_hop_limit )

Quoted 3 lines
                        in6_dev->cnf.hop_limit = ra_msg->icmph.icmp6_hop_limit;

is duplicated check. How do you think?

Quoted 7 lines

How about checking in6_dev->cnf.accept_ra_min_hop_limit by outer if, then?

if (in6_dev->cnf.accept_ra_min_hop_limit < 256 &&

    ra_msg->icmph.icmp6_hop_limit) {

...
}

Then let's move all the if check outside, I will send a v4 patch for you review.

Thanks
Hangbin