diff options
author | Shmulik Ladkani <shmulik.ladkani@gmail.com> | 2012-11-30 05:25:59 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2012-12-01 11:36:37 -0500 |
commit | aeaf6e9d2f49d793d3eb8c1af4095cf25e061b94 (patch) | |
tree | f668b46359bfa50f83563fb3ee0247f55f451760 /net/ipv6/ndisc.c | |
parent | fd90b29d757827ab12d6669292612308ec249532 (diff) |
ipv6: unify logic evaluating inet6_dev's accept_ra property
As of 026359b [ipv6: Send ICMPv6 RSes only when RAs are accepted], the
logic determining whether to send Router Solicitations is identical
to the logic determining whether kernel accepts Router Advertisements.
However the condition itself is repeated in several code locations.
Unify it by introducing 'ipv6_accept_ra()' accessor.
Also, simplify the condition expression, making it more readable.
No semantic change.
Signed-off-by: Shmulik Ladkani <shmulik.ladkani@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/ipv6/ndisc.c')
-rw-r--r-- | net/ipv6/ndisc.c | 16 |
1 files changed, 2 insertions, 14 deletions
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 |