| 1 | --- a/net/ipv6/ndisc.c |
| 2 | +++ b/net/ipv6/ndisc.c |
| 3 | @@ -1105,6 +1105,18 @@ errout: |
| 4 | rtnl_set_sk_err(net, RTNLGRP_ND_USEROPT, err); |
| 5 | } |
| 6 | |
| 7 | +static inline int accept_ra(struct inet6_dev *in6_dev) |
| 8 | +{ |
| 9 | + /* |
| 10 | + * If forwarding is enabled, RA are not accepted unless the special |
| 11 | + * hybrid mode (accept_ra=2) is enabled. |
| 12 | + */ |
| 13 | + if (in6_dev->cnf.forwarding && in6_dev->cnf.accept_ra < 2) |
| 14 | + return 0; |
| 15 | + |
| 16 | + return in6_dev->cnf.accept_ra; |
| 17 | +} |
| 18 | + |
| 19 | static void ndisc_router_discovery(struct sk_buff *skb) |
| 20 | { |
| 21 | struct ra_msg *ra_msg = (struct ra_msg *)skb_transport_header(skb); |
| 22 | @@ -1158,8 +1170,7 @@ static void ndisc_router_discovery(struc |
| 23 | return; |
| 24 | } |
| 25 | |
| 26 | - /* skip route and link configuration on routers */ |
| 27 | - if (in6_dev->cnf.forwarding || !in6_dev->cnf.accept_ra) |
| 28 | + if (!accept_ra(in6_dev)) |
| 29 | goto skip_linkparms; |
| 30 | |
| 31 | #ifdef CONFIG_IPV6_NDISC_NODETYPE |
| 32 | @@ -1309,8 +1320,7 @@ skip_linkparms: |
| 33 | NEIGH_UPDATE_F_ISROUTER); |
| 34 | } |
| 35 | |
| 36 | - /* skip route and link configuration on routers */ |
| 37 | - if (in6_dev->cnf.forwarding || !in6_dev->cnf.accept_ra) |
| 38 | + if (!accept_ra(in6_dev)) |
| 39 | goto out; |
| 40 | |
| 41 | #ifdef CONFIG_IPV6_ROUTE_INFO |
| 42 | |