diff options
author | Thomas Graf <tgraf@infradead.org> | 2010-09-02 22:59:14 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2010-09-03 12:43:13 -0400 |
commit | 65e9b62d4503849b10bedfc29bff0473760cc597 (patch) | |
tree | 74fb61b4a345ed9ce022d21c4973c056c5516f08 | |
parent | bc8acf2c8c3e43fcc192762a9f964b3e9a17748b (diff) |
ipv6: add special mode accept_ra=2 to accept RA while configured as router
The current IPv6 behavior is to not accept router advertisements while
forwarding, i.e. configured as router.
This does make sense, a router is typically not supposed to be auto
configured. However there are exceptions and we should allow the
current behavior to be overwritten.
Therefore this patch enables the user to overrule the "if forwarding
enabled then don't listen to RAs" rule by setting accept_ra to the
special value of 2.
An alternative would be to ignore the forwarding switch alltogether
and solely accept RAs based on the value of accept_ra. However, I
found that if not intended, accepting RAs as a router can lead to
strange unwanted behavior therefore we it seems wise to only do so
if the user explicitely asks for this behavior.
Signed-off-by: Thomas Graf <tgraf@infradead.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r-- | net/ipv6/ndisc.c | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/net/ipv6/ndisc.c b/net/ipv6/ndisc.c index 58841c4ae947..69a0051cea67 100644 --- a/net/ipv6/ndisc.c +++ b/net/ipv6/ndisc.c | |||
@@ -1105,6 +1105,18 @@ errout: | |||
1105 | rtnl_set_sk_err(net, RTNLGRP_ND_USEROPT, err); | 1105 | rtnl_set_sk_err(net, RTNLGRP_ND_USEROPT, err); |
1106 | } | 1106 | } |
1107 | 1107 | ||
1108 | static inline int accept_ra(struct inet6_dev *in6_dev) | ||
1109 | { | ||
1110 | /* | ||
1111 | * If forwarding is enabled, RA are not accepted unless the special | ||
1112 | * hybrid mode (accept_ra=2) is enabled. | ||
1113 | */ | ||
1114 | if (in6_dev->cnf.forwarding && in6_dev->cnf.accept_ra < 2) | ||
1115 | return 0; | ||
1116 | |||
1117 | return in6_dev->cnf.accept_ra; | ||
1118 | } | ||
1119 | |||
1108 | static void ndisc_router_discovery(struct sk_buff *skb) | 1120 | static void ndisc_router_discovery(struct sk_buff *skb) |
1109 | { | 1121 | { |
1110 | struct ra_msg *ra_msg = (struct ra_msg *)skb_transport_header(skb); | 1122 | struct ra_msg *ra_msg = (struct ra_msg *)skb_transport_header(skb); |
@@ -1158,8 +1170,7 @@ static void ndisc_router_discovery(struct sk_buff *skb) | |||
1158 | return; | 1170 | return; |
1159 | } | 1171 | } |
1160 | 1172 | ||
1161 | /* skip route and link configuration on routers */ | 1173 | if (!accept_ra(in6_dev)) |
1162 | if (in6_dev->cnf.forwarding || !in6_dev->cnf.accept_ra) | ||
1163 | goto skip_linkparms; | 1174 | goto skip_linkparms; |
1164 | 1175 | ||
1165 | #ifdef CONFIG_IPV6_NDISC_NODETYPE | 1176 | #ifdef CONFIG_IPV6_NDISC_NODETYPE |
@@ -1309,8 +1320,7 @@ skip_linkparms: | |||
1309 | NEIGH_UPDATE_F_ISROUTER); | 1320 | NEIGH_UPDATE_F_ISROUTER); |
1310 | } | 1321 | } |
1311 | 1322 | ||
1312 | /* skip route and link configuration on routers */ | 1323 | if (!accept_ra(in6_dev)) |
1313 | if (in6_dev->cnf.forwarding || !in6_dev->cnf.accept_ra) | ||
1314 | goto out; | 1324 | goto out; |
1315 | 1325 | ||
1316 | #ifdef CONFIG_IPV6_ROUTE_INFO | 1326 | #ifdef CONFIG_IPV6_ROUTE_INFO |