Commit cc306350 authored by David S. Miller's avatar David S. Miller

Merge branch 'ipv6-mc_forwarding-changes'

Eric Dumazet says:

====================
ipv6: mc_forwarding changes

First patch removes minor data-races, as mc_forwarding can
be locklessly read in fast path.

Second patch adds a short cut in ip6mr_sk_done()
====================
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parents 3115ff3c f2f2325e
...@@ -51,7 +51,7 @@ struct ipv6_devconf { ...@@ -51,7 +51,7 @@ struct ipv6_devconf {
__s32 use_optimistic; __s32 use_optimistic;
#endif #endif
#ifdef CONFIG_IPV6_MROUTE #ifdef CONFIG_IPV6_MROUTE
__s32 mc_forwarding; atomic_t mc_forwarding;
#endif #endif
__s32 disable_ipv6; __s32 disable_ipv6;
__s32 drop_unicast_in_l2_multicast; __s32 drop_unicast_in_l2_multicast;
......
...@@ -134,7 +134,7 @@ static u8 batadv_mcast_mla_rtr_flags_softif_get_ipv6(struct net_device *dev) ...@@ -134,7 +134,7 @@ static u8 batadv_mcast_mla_rtr_flags_softif_get_ipv6(struct net_device *dev)
{ {
struct inet6_dev *in6_dev = __in6_dev_get(dev); struct inet6_dev *in6_dev = __in6_dev_get(dev);
if (in6_dev && in6_dev->cnf.mc_forwarding) if (in6_dev && atomic_read(&in6_dev->cnf.mc_forwarding))
return BATADV_NO_FLAGS; return BATADV_NO_FLAGS;
else else
return BATADV_MCAST_WANT_NO_RTR6; return BATADV_MCAST_WANT_NO_RTR6;
......
...@@ -554,7 +554,7 @@ static int inet6_netconf_fill_devconf(struct sk_buff *skb, int ifindex, ...@@ -554,7 +554,7 @@ static int inet6_netconf_fill_devconf(struct sk_buff *skb, int ifindex,
#ifdef CONFIG_IPV6_MROUTE #ifdef CONFIG_IPV6_MROUTE
if ((all || type == NETCONFA_MC_FORWARDING) && if ((all || type == NETCONFA_MC_FORWARDING) &&
nla_put_s32(skb, NETCONFA_MC_FORWARDING, nla_put_s32(skb, NETCONFA_MC_FORWARDING,
devconf->mc_forwarding) < 0) atomic_read(&devconf->mc_forwarding)) < 0)
goto nla_put_failure; goto nla_put_failure;
#endif #endif
if ((all || type == NETCONFA_PROXY_NEIGH) && if ((all || type == NETCONFA_PROXY_NEIGH) &&
...@@ -5533,7 +5533,7 @@ static inline void ipv6_store_devconf(struct ipv6_devconf *cnf, ...@@ -5533,7 +5533,7 @@ static inline void ipv6_store_devconf(struct ipv6_devconf *cnf,
array[DEVCONF_USE_OPTIMISTIC] = cnf->use_optimistic; array[DEVCONF_USE_OPTIMISTIC] = cnf->use_optimistic;
#endif #endif
#ifdef CONFIG_IPV6_MROUTE #ifdef CONFIG_IPV6_MROUTE
array[DEVCONF_MC_FORWARDING] = cnf->mc_forwarding; array[DEVCONF_MC_FORWARDING] = atomic_read(&cnf->mc_forwarding);
#endif #endif
array[DEVCONF_DISABLE_IPV6] = cnf->disable_ipv6; array[DEVCONF_DISABLE_IPV6] = cnf->disable_ipv6;
array[DEVCONF_ACCEPT_DAD] = cnf->accept_dad; array[DEVCONF_ACCEPT_DAD] = cnf->accept_dad;
......
...@@ -508,7 +508,7 @@ int ip6_mc_input(struct sk_buff *skb) ...@@ -508,7 +508,7 @@ int ip6_mc_input(struct sk_buff *skb)
/* /*
* IPv6 multicast router mode is now supported ;) * IPv6 multicast router mode is now supported ;)
*/ */
if (dev_net(skb->dev)->ipv6.devconf_all->mc_forwarding && if (atomic_read(&dev_net(skb->dev)->ipv6.devconf_all->mc_forwarding) &&
!(ipv6_addr_type(&hdr->daddr) & !(ipv6_addr_type(&hdr->daddr) &
(IPV6_ADDR_LOOPBACK|IPV6_ADDR_LINKLOCAL)) && (IPV6_ADDR_LOOPBACK|IPV6_ADDR_LINKLOCAL)) &&
likely(!(IP6CB(skb)->flags & IP6SKB_FORWARDED))) { likely(!(IP6CB(skb)->flags & IP6SKB_FORWARDED))) {
......
...@@ -732,7 +732,7 @@ static int mif6_delete(struct mr_table *mrt, int vifi, int notify, ...@@ -732,7 +732,7 @@ static int mif6_delete(struct mr_table *mrt, int vifi, int notify,
in6_dev = __in6_dev_get(dev); in6_dev = __in6_dev_get(dev);
if (in6_dev) { if (in6_dev) {
in6_dev->cnf.mc_forwarding--; atomic_dec(&in6_dev->cnf.mc_forwarding);
inet6_netconf_notify_devconf(dev_net(dev), RTM_NEWNETCONF, inet6_netconf_notify_devconf(dev_net(dev), RTM_NEWNETCONF,
NETCONFA_MC_FORWARDING, NETCONFA_MC_FORWARDING,
dev->ifindex, &in6_dev->cnf); dev->ifindex, &in6_dev->cnf);
...@@ -900,7 +900,7 @@ static int mif6_add(struct net *net, struct mr_table *mrt, ...@@ -900,7 +900,7 @@ static int mif6_add(struct net *net, struct mr_table *mrt,
in6_dev = __in6_dev_get(dev); in6_dev = __in6_dev_get(dev);
if (in6_dev) { if (in6_dev) {
in6_dev->cnf.mc_forwarding++; atomic_inc(&in6_dev->cnf.mc_forwarding);
inet6_netconf_notify_devconf(dev_net(dev), RTM_NEWNETCONF, inet6_netconf_notify_devconf(dev_net(dev), RTM_NEWNETCONF,
NETCONFA_MC_FORWARDING, NETCONFA_MC_FORWARDING,
dev->ifindex, &in6_dev->cnf); dev->ifindex, &in6_dev->cnf);
...@@ -1551,7 +1551,7 @@ static int ip6mr_sk_init(struct mr_table *mrt, struct sock *sk) ...@@ -1551,7 +1551,7 @@ static int ip6mr_sk_init(struct mr_table *mrt, struct sock *sk)
} else { } else {
rcu_assign_pointer(mrt->mroute_sk, sk); rcu_assign_pointer(mrt->mroute_sk, sk);
sock_set_flag(sk, SOCK_RCU_FREE); sock_set_flag(sk, SOCK_RCU_FREE);
net->ipv6.devconf_all->mc_forwarding++; atomic_inc(&net->ipv6.devconf_all->mc_forwarding);
} }
write_unlock_bh(&mrt_lock); write_unlock_bh(&mrt_lock);
...@@ -1575,6 +1575,9 @@ int ip6mr_sk_done(struct sock *sk) ...@@ -1575,6 +1575,9 @@ int ip6mr_sk_done(struct sock *sk)
inet_sk(sk)->inet_num != IPPROTO_ICMPV6) inet_sk(sk)->inet_num != IPPROTO_ICMPV6)
return err; return err;
if (!atomic_read(&net->ipv6.devconf_all->mc_forwarding))
return err;
rtnl_lock(); rtnl_lock();
ip6mr_for_each_table(mrt, net) { ip6mr_for_each_table(mrt, net) {
if (sk == rtnl_dereference(mrt->mroute_sk)) { if (sk == rtnl_dereference(mrt->mroute_sk)) {
...@@ -1584,7 +1587,7 @@ int ip6mr_sk_done(struct sock *sk) ...@@ -1584,7 +1587,7 @@ int ip6mr_sk_done(struct sock *sk)
* so the RCU grace period before sk freeing * so the RCU grace period before sk freeing
* is guaranteed by sk_destruct() * is guaranteed by sk_destruct()
*/ */
net->ipv6.devconf_all->mc_forwarding--; atomic_dec(&net->ipv6.devconf_all->mc_forwarding);
write_unlock_bh(&mrt_lock); write_unlock_bh(&mrt_lock);
inet6_netconf_notify_devconf(net, RTM_NEWNETCONF, inet6_netconf_notify_devconf(net, RTM_NEWNETCONF,
NETCONFA_MC_FORWARDING, NETCONFA_MC_FORWARDING,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment