| 1 | --- a/net/ipv6/ndisc.c |
| 2 | +++ b/net/ipv6/ndisc.c |
| 3 | @@ -1106,6 +1106,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 | @@ -1151,7 +1163,7 @@ static void ndisc_router_discovery(struc |
| 23 | skb->dev->name); |
| 24 | return; |
| 25 | } |
| 26 | - if (in6_dev->cnf.forwarding || !in6_dev->cnf.accept_ra) { |
| 27 | + if (!accept_ra(in6_dev)) { |
| 28 | in6_dev_put(in6_dev); |
| 29 | return; |
| 30 | } |
| 31 | |