diff options
-rw-r--r-- | include/net/ipv6.h | 9 | ||||
-rw-r--r-- | net/ipv6/addrconf.c | 3 | ||||
-rw-r--r-- | net/ipv6/ndisc.c | 16 |
3 files changed, 12 insertions, 16 deletions
diff --git a/include/net/ipv6.h b/include/net/ipv6.h index acbd8e034310..5af66b26ebdd 100644 --- a/include/net/ipv6.h +++ b/include/net/ipv6.h | |||
@@ -271,6 +271,15 @@ struct ipv6_txoptions *ipv6_fixup_options(struct ipv6_txoptions *opt_space, | |||
271 | 271 | ||
272 | extern bool ipv6_opt_accepted(const struct sock *sk, const struct sk_buff *skb); | 272 | extern bool ipv6_opt_accepted(const struct sock *sk, const struct sk_buff *skb); |
273 | 273 | ||
274 | static inline bool ipv6_accept_ra(struct inet6_dev *idev) | ||
275 | { | ||
276 | /* If forwarding is enabled, RA are not accepted unless the special | ||
277 | * hybrid mode (accept_ra=2) is enabled. | ||
278 | */ | ||
279 | return idev->cnf.forwarding ? idev->cnf.accept_ra == 2 : | ||
280 | idev->cnf.accept_ra; | ||
281 | } | ||
282 | |||
274 | #if IS_ENABLED(CONFIG_IPV6) | 283 | #if IS_ENABLED(CONFIG_IPV6) |
275 | static inline int ip6_frag_nqueues(struct net *net) | 284 | static inline int ip6_frag_nqueues(struct net *net) |
276 | { | 285 | { |
diff --git a/net/ipv6/addrconf.c b/net/ipv6/addrconf.c index fc0e13ad6337..4b644f656c41 100644 --- a/net/ipv6/addrconf.c +++ b/net/ipv6/addrconf.c | |||
@@ -3150,8 +3150,7 @@ static void addrconf_dad_completed(struct inet6_ifaddr *ifp) | |||
3150 | router advertisements, start sending router solicitations. | 3150 | router advertisements, start sending router solicitations. |
3151 | */ | 3151 | */ |
3152 | 3152 | ||
3153 | if (((ifp->idev->cnf.accept_ra == 1 && !ifp->idev->cnf.forwarding) || | 3153 | if (ipv6_accept_ra(ifp->idev) && |
3154 | ifp->idev->cnf.accept_ra == 2) && | ||
3155 | ifp->idev->cnf.rtr_solicits > 0 && | 3154 | ifp->idev->cnf.rtr_solicits > 0 && |
3156 | (dev->flags&IFF_LOOPBACK) == 0 && | 3155 | (dev->flags&IFF_LOOPBACK) == 0 && |
3157 | (ipv6_addr_type(&ifp->addr) & IPV6_ADDR_LINKLOCAL)) { | 3156 | (ipv6_addr_type(&ifp->addr) & IPV6_ADDR_LINKLOCAL)) { |
diff --git a/net/ipv6/ndisc.c b/net/ipv6/ndisc.c index f41853bca428..cf43b6550f5b 100644 --- a/net/ipv6/ndisc.c +++ b/net/ipv6/ndisc.c | |||
@@ -1032,18 +1032,6 @@ errout: | |||
1032 | rtnl_set_sk_err(net, RTNLGRP_ND_USEROPT, err); | 1032 | rtnl_set_sk_err(net, RTNLGRP_ND_USEROPT, err); |
1033 | } | 1033 | } |
1034 | 1034 | ||
1035 | static inline int accept_ra(struct inet6_dev *in6_dev) | ||
1036 | { | ||
1037 | /* | ||
1038 | * If forwarding is enabled, RA are not accepted unless the special | ||
1039 | * hybrid mode (accept_ra=2) is enabled. | ||
1040 | */ | ||
1041 | if (in6_dev->cnf.forwarding && in6_dev->cnf.accept_ra < 2) | ||
1042 | return 0; | ||
1043 | |||
1044 | return in6_dev->cnf.accept_ra; | ||
1045 | } | ||
1046 | |||
1047 | static void ndisc_router_discovery(struct sk_buff *skb) | 1035 | static void ndisc_router_discovery(struct sk_buff *skb) |
1048 | { | 1036 | { |
1049 | struct ra_msg *ra_msg = (struct ra_msg *)skb_transport_header(skb); | 1037 | struct ra_msg *ra_msg = (struct ra_msg *)skb_transport_header(skb); |
@@ -1091,7 +1079,7 @@ static void ndisc_router_discovery(struct sk_buff *skb) | |||
1091 | return; | 1079 | return; |
1092 | } | 1080 | } |
1093 | 1081 | ||
1094 | if (!accept_ra(in6_dev)) | 1082 | if (!ipv6_accept_ra(in6_dev)) |
1095 | goto skip_linkparms; | 1083 | goto skip_linkparms; |
1096 | 1084 | ||
1097 | #ifdef CONFIG_IPV6_NDISC_NODETYPE | 1085 | #ifdef CONFIG_IPV6_NDISC_NODETYPE |
@@ -1247,7 +1235,7 @@ skip_linkparms: | |||
1247 | NEIGH_UPDATE_F_ISROUTER); | 1235 | NEIGH_UPDATE_F_ISROUTER); |
1248 | } | 1236 | } |
1249 | 1237 | ||
1250 | if (!accept_ra(in6_dev)) | 1238 | if (!ipv6_accept_ra(in6_dev)) |
1251 | goto out; | 1239 | goto out; |
1252 | 1240 | ||
1253 | #ifdef CONFIG_IPV6_ROUTE_INFO | 1241 | #ifdef CONFIG_IPV6_ROUTE_INFO |