net/ipv6: add sysctl option accept_ra_min_hop_limit
Subsystems (4)
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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
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_limitto let user choose the minimum hop limit value they can accept from RA. And set default to 1 to meet RFC standards.Signed-off-by Hangbin Liu <[email protected]>--- 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@@ -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
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_defrtraccept_ra_min_hop_limitaccept_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
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@@ -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@@ -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
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_limitto let user choose the minimum hop limit value they can accept from RA. And set default to 1 to meet RFC standards.Signed-off-by Hangbin Liu <[email protected]>--- 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@@ -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@@ -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_defrtraccept_ra_min_hop_limitaccept_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@@ -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
-0DEVCONF_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@@ -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_LIMITthen 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@@ -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
Hi,
Quoted 33 lines · Hangbin Liu
Quoted 16 lines
Quoted 16 lines
net/ipv6/ndisc.c +2
-4@@ -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_limitgreat than 255 is meaningless, there is also no need to check it sinceicmp6_hop_limitwill 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
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_limitgreat than 255 is meaningless, there is also no need to check it sinceicmp6_hop_limitwill 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_limitby 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