Skip to content

Commit

Permalink
net: reintroduce missing rcu_assign_pointer() calls
Browse files Browse the repository at this point in the history
commit a9b3cd7 (rcu: convert uses of rcu_assign_pointer(x, NULL) to
RCU_INIT_POINTER) did a lot of incorrect changes, since it did a
complete conversion of rcu_assign_pointer(x, y) to RCU_INIT_POINTER(x,
y).

We miss needed barriers, even on x86, when y is not NULL.

Signed-off-by: Eric Dumazet <eric.dumazet@gmail.com>
CC: Stephen Hemminger <shemminger@vyatta.com>
CC: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Eric Dumazet authored and David S. Miller committed Jan 12, 2012
1 parent 9ee6045 commit cf778b0
Show file tree
Hide file tree
Showing 32 changed files with 61 additions and 63 deletions.
6 changes: 3 additions & 3 deletions net/core/net-sysfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -1177,9 +1177,9 @@ static ssize_t store_xps_map(struct netdev_queue *queue,
nonempty = 1;
}

if (nonempty)
RCU_INIT_POINTER(dev->xps_maps, new_dev_maps);
else {
if (nonempty) {
rcu_assign_pointer(dev->xps_maps, new_dev_maps);
} else {
kfree(new_dev_maps);
RCU_INIT_POINTER(dev->xps_maps, NULL);
}
Expand Down
2 changes: 1 addition & 1 deletion net/core/netpoll.c
Original file line number Diff line number Diff line change
Expand Up @@ -765,7 +765,7 @@ int __netpoll_setup(struct netpoll *np)
}

/* last thing to do is link it to the net device structure */
RCU_INIT_POINTER(ndev->npinfo, npinfo);
rcu_assign_pointer(ndev->npinfo, npinfo);

return 0;

Expand Down
4 changes: 2 additions & 2 deletions net/decnet/dn_dev.c
Original file line number Diff line number Diff line change
Expand Up @@ -388,7 +388,7 @@ static int dn_dev_insert_ifa(struct dn_dev *dn_db, struct dn_ifaddr *ifa)
}

ifa->ifa_next = dn_db->ifa_list;
RCU_INIT_POINTER(dn_db->ifa_list, ifa);
rcu_assign_pointer(dn_db->ifa_list, ifa);

dn_ifaddr_notify(RTM_NEWADDR, ifa);
blocking_notifier_call_chain(&dnaddr_chain, NETDEV_UP, ifa);
Expand Down Expand Up @@ -1093,7 +1093,7 @@ static struct dn_dev *dn_dev_create(struct net_device *dev, int *err)

memcpy(&dn_db->parms, p, sizeof(struct dn_dev_parms));

RCU_INIT_POINTER(dev->dn_ptr, dn_db);
rcu_assign_pointer(dev->dn_ptr, dn_db);
dn_db->dev = dev;
init_timer(&dn_db->timer);

Expand Down
2 changes: 1 addition & 1 deletion net/ipv4/devinet.c
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ static struct in_device *inetdev_init(struct net_device *dev)
ip_mc_up(in_dev);

/* we can receive as soon as ip_ptr is set -- do this last */
RCU_INIT_POINTER(dev->ip_ptr, in_dev);
rcu_assign_pointer(dev->ip_ptr, in_dev);
out:
return in_dev;
out_kfree:
Expand Down
10 changes: 5 additions & 5 deletions net/ipv4/fib_trie.c
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ static inline struct tnode *node_parent_rcu(const struct rt_trie_node *node)
return (struct tnode *)(parent & ~NODE_TYPE_MASK);
}

/* Same as RCU_INIT_POINTER
/* Same as rcu_assign_pointer
* but that macro() assumes that value is a pointer.
*/
static inline void node_set_parent(struct rt_trie_node *node, struct tnode *ptr)
Expand Down Expand Up @@ -529,7 +529,7 @@ static void tnode_put_child_reorg(struct tnode *tn, int i, struct rt_trie_node *
if (n)
node_set_parent(n, tn);

RCU_INIT_POINTER(tn->child[i], n);
rcu_assign_pointer(tn->child[i], n);
}

#define MAX_WORK 10
Expand Down Expand Up @@ -1015,7 +1015,7 @@ static void trie_rebalance(struct trie *t, struct tnode *tn)

tp = node_parent((struct rt_trie_node *) tn);
if (!tp)
RCU_INIT_POINTER(t->trie, (struct rt_trie_node *)tn);
rcu_assign_pointer(t->trie, (struct rt_trie_node *)tn);

tnode_free_flush();
if (!tp)
Expand All @@ -1027,7 +1027,7 @@ static void trie_rebalance(struct trie *t, struct tnode *tn)
if (IS_TNODE(tn))
tn = (struct tnode *)resize(t, (struct tnode *)tn);

RCU_INIT_POINTER(t->trie, (struct rt_trie_node *)tn);
rcu_assign_pointer(t->trie, (struct rt_trie_node *)tn);
tnode_free_flush();
}

Expand Down Expand Up @@ -1164,7 +1164,7 @@ static struct list_head *fib_insert_node(struct trie *t, u32 key, int plen)
put_child(t, (struct tnode *)tp, cindex,
(struct rt_trie_node *)tn);
} else {
RCU_INIT_POINTER(t->trie, (struct rt_trie_node *)tn);
rcu_assign_pointer(t->trie, (struct rt_trie_node *)tn);
tp = tn;
}
}
Expand Down
8 changes: 4 additions & 4 deletions net/ipv4/igmp.c
Original file line number Diff line number Diff line change
Expand Up @@ -1249,7 +1249,7 @@ void ip_mc_inc_group(struct in_device *in_dev, __be32 addr)

im->next_rcu = in_dev->mc_list;
in_dev->mc_count++;
RCU_INIT_POINTER(in_dev->mc_list, im);
rcu_assign_pointer(in_dev->mc_list, im);

#ifdef CONFIG_IP_MULTICAST
igmpv3_del_delrec(in_dev, im->multiaddr);
Expand Down Expand Up @@ -1821,7 +1821,7 @@ int ip_mc_join_group(struct sock *sk , struct ip_mreqn *imr)
iml->next_rcu = inet->mc_list;
iml->sflist = NULL;
iml->sfmode = MCAST_EXCLUDE;
RCU_INIT_POINTER(inet->mc_list, iml);
rcu_assign_pointer(inet->mc_list, iml);
ip_mc_inc_group(in_dev, addr);
err = 0;
done:
Expand Down Expand Up @@ -2008,7 +2008,7 @@ int ip_mc_source(int add, int omode, struct sock *sk, struct
atomic_sub(IP_SFLSIZE(psl->sl_max), &sk->sk_omem_alloc);
kfree_rcu(psl, rcu);
}
RCU_INIT_POINTER(pmc->sflist, newpsl);
rcu_assign_pointer(pmc->sflist, newpsl);
psl = newpsl;
}
rv = 1; /* > 0 for insert logic below if sl_count is 0 */
Expand Down Expand Up @@ -2111,7 +2111,7 @@ int ip_mc_msfilter(struct sock *sk, struct ip_msfilter *msf, int ifindex)
} else
(void) ip_mc_del_src(in_dev, &msf->imsf_multiaddr, pmc->sfmode,
0, NULL, 0);
RCU_INIT_POINTER(pmc->sflist, newpsl);
rcu_assign_pointer(pmc->sflist, newpsl);
pmc->sfmode = msf->imsf_fmode;
err = 0;
done:
Expand Down
8 changes: 4 additions & 4 deletions net/ipv4/ipip.c
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ static void ipip_tunnel_unlink(struct ipip_net *ipn, struct ip_tunnel *t)
(iter = rtnl_dereference(*tp)) != NULL;
tp = &iter->next) {
if (t == iter) {
RCU_INIT_POINTER(*tp, t->next);
rcu_assign_pointer(*tp, t->next);
break;
}
}
Expand All @@ -241,8 +241,8 @@ static void ipip_tunnel_link(struct ipip_net *ipn, struct ip_tunnel *t)
{
struct ip_tunnel __rcu **tp = ipip_bucket(ipn, t);

RCU_INIT_POINTER(t->next, rtnl_dereference(*tp));
RCU_INIT_POINTER(*tp, t);
rcu_assign_pointer(t->next, rtnl_dereference(*tp));
rcu_assign_pointer(*tp, t);
}

static struct ip_tunnel * ipip_tunnel_locate(struct net *net,
Expand Down Expand Up @@ -792,7 +792,7 @@ static int __net_init ipip_fb_tunnel_init(struct net_device *dev)
return -ENOMEM;

dev_hold(dev);
RCU_INIT_POINTER(ipn->tunnels_wc[0], tunnel);
rcu_assign_pointer(ipn->tunnels_wc[0], tunnel);
return 0;
}

Expand Down
2 changes: 1 addition & 1 deletion net/ipv4/ipmr.c
Original file line number Diff line number Diff line change
Expand Up @@ -1225,7 +1225,7 @@ int ip_mroute_setsockopt(struct sock *sk, int optname, char __user *optval, unsi

ret = ip_ra_control(sk, 1, mrtsock_destruct);
if (ret == 0) {
RCU_INIT_POINTER(mrt->mroute_sk, sk);
rcu_assign_pointer(mrt->mroute_sk, sk);
IPV4_DEVCONF_ALL(net, MC_FORWARDING)++;
}
rtnl_unlock();
Expand Down
2 changes: 1 addition & 1 deletion net/ipv6/addrconf.c
Original file line number Diff line number Diff line change
Expand Up @@ -429,7 +429,7 @@ static struct inet6_dev * ipv6_add_dev(struct net_device *dev)
ndev->tstamp = jiffies;
addrconf_sysctl_register(ndev);
/* protected by rtnl_lock */
RCU_INIT_POINTER(dev->ip6_ptr, ndev);
rcu_assign_pointer(dev->ip6_ptr, ndev);

/* Join all-node multicast group */
ipv6_dev_mc_inc(dev, &in6addr_linklocal_allnodes);
Expand Down
8 changes: 4 additions & 4 deletions net/ipv6/ip6_tunnel.c
Original file line number Diff line number Diff line change
Expand Up @@ -218,8 +218,8 @@ ip6_tnl_link(struct ip6_tnl_net *ip6n, struct ip6_tnl *t)
{
struct ip6_tnl __rcu **tp = ip6_tnl_bucket(ip6n, &t->parms);

RCU_INIT_POINTER(t->next , rtnl_dereference(*tp));
RCU_INIT_POINTER(*tp, t);
rcu_assign_pointer(t->next , rtnl_dereference(*tp));
rcu_assign_pointer(*tp, t);
}

/**
Expand All @@ -237,7 +237,7 @@ ip6_tnl_unlink(struct ip6_tnl_net *ip6n, struct ip6_tnl *t)
(iter = rtnl_dereference(*tp)) != NULL;
tp = &iter->next) {
if (t == iter) {
RCU_INIT_POINTER(*tp, t->next);
rcu_assign_pointer(*tp, t->next);
break;
}
}
Expand Down Expand Up @@ -1450,7 +1450,7 @@ static int __net_init ip6_fb_tnl_dev_init(struct net_device *dev)

t->parms.proto = IPPROTO_IPV6;
dev_hold(dev);
RCU_INIT_POINTER(ip6n->tnls_wc[0], t);
rcu_assign_pointer(ip6n->tnls_wc[0], t);
return 0;
}

Expand Down
2 changes: 1 addition & 1 deletion net/ipv6/raw.c
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ static mh_filter_t __rcu *mh_filter __read_mostly;

int rawv6_mh_filter_register(mh_filter_t filter)
{
RCU_INIT_POINTER(mh_filter, filter);
rcu_assign_pointer(mh_filter, filter);
return 0;
}
EXPORT_SYMBOL(rawv6_mh_filter_register);
Expand Down
10 changes: 5 additions & 5 deletions net/ipv6/sit.c
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ static void ipip6_tunnel_unlink(struct sit_net *sitn, struct ip_tunnel *t)
(iter = rtnl_dereference(*tp)) != NULL;
tp = &iter->next) {
if (t == iter) {
RCU_INIT_POINTER(*tp, t->next);
rcu_assign_pointer(*tp, t->next);
break;
}
}
Expand All @@ -192,8 +192,8 @@ static void ipip6_tunnel_link(struct sit_net *sitn, struct ip_tunnel *t)
{
struct ip_tunnel __rcu **tp = ipip6_bucket(sitn, t);

RCU_INIT_POINTER(t->next, rtnl_dereference(*tp));
RCU_INIT_POINTER(*tp, t);
rcu_assign_pointer(t->next, rtnl_dereference(*tp));
rcu_assign_pointer(*tp, t);
}

static void ipip6_tunnel_clone_6rd(struct net_device *dev, struct sit_net *sitn)
Expand Down Expand Up @@ -393,7 +393,7 @@ ipip6_tunnel_add_prl(struct ip_tunnel *t, struct ip_tunnel_prl *a, int chg)
p->addr = a->addr;
p->flags = a->flags;
t->prl_count++;
RCU_INIT_POINTER(t->prl, p);
rcu_assign_pointer(t->prl, p);
out:
return err;
}
Expand Down Expand Up @@ -1177,7 +1177,7 @@ static int __net_init ipip6_fb_tunnel_init(struct net_device *dev)
if (!dev->tstats)
return -ENOMEM;
dev_hold(dev);
RCU_INIT_POINTER(sitn->tunnels_wc[0], tunnel);
rcu_assign_pointer(sitn->tunnels_wc[0], tunnel);
return 0;
}

Expand Down
2 changes: 1 addition & 1 deletion net/mac80211/agg-rx.c
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,7 @@ void ieee80211_process_addba_request(struct ieee80211_local *local,
status = WLAN_STATUS_SUCCESS;

/* activate it for RX */
RCU_INIT_POINTER(sta->ampdu_mlme.tid_rx[tid], tid_agg_rx);
rcu_assign_pointer(sta->ampdu_mlme.tid_rx[tid], tid_agg_rx);

if (timeout)
mod_timer(&tid_agg_rx->session_timer, TU_TO_EXP_TIME(timeout));
Expand Down
4 changes: 2 additions & 2 deletions net/mac80211/cfg.c
Original file line number Diff line number Diff line change
Expand Up @@ -616,7 +616,7 @@ static int ieee80211_config_beacon(struct ieee80211_sub_if_data *sdata,

sdata->vif.bss_conf.dtim_period = new->dtim_period;

RCU_INIT_POINTER(sdata->u.ap.beacon, new);
rcu_assign_pointer(sdata->u.ap.beacon, new);

synchronize_rcu();

Expand Down Expand Up @@ -1033,7 +1033,7 @@ static int ieee80211_change_station(struct wiphy *wiphy,
return -EBUSY;
}

RCU_INIT_POINTER(vlansdata->u.vlan.sta, sta);
rcu_assign_pointer(vlansdata->u.vlan.sta, sta);
}

sta->sdata = vlansdata;
Expand Down
2 changes: 1 addition & 1 deletion net/mac80211/ibss.c
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ static void __ieee80211_sta_join_ibss(struct ieee80211_sub_if_data *sdata,
*pos++ = 0; /* U-APSD no in use */
}

RCU_INIT_POINTER(ifibss->presp, skb);
rcu_assign_pointer(ifibss->presp, skb);

sdata->vif.bss_conf.beacon_int = beacon_int;
sdata->vif.bss_conf.basic_rates = basic_rates;
Expand Down
6 changes: 3 additions & 3 deletions net/mac80211/sta_info.c
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ static int sta_info_hash_del(struct ieee80211_local *local,
if (!s)
return -ENOENT;
if (s == sta) {
RCU_INIT_POINTER(local->sta_hash[STA_HASH(sta->sta.addr)],
rcu_assign_pointer(local->sta_hash[STA_HASH(sta->sta.addr)],
s->hnext);
return 0;
}
Expand All @@ -83,7 +83,7 @@ static int sta_info_hash_del(struct ieee80211_local *local,
s = rcu_dereference_protected(s->hnext,
lockdep_is_held(&local->sta_mtx));
if (rcu_access_pointer(s->hnext)) {
RCU_INIT_POINTER(s->hnext, sta->hnext);
rcu_assign_pointer(s->hnext, sta->hnext);
return 0;
}

Expand Down Expand Up @@ -226,7 +226,7 @@ static void sta_info_hash_add(struct ieee80211_local *local,
{
lockdep_assert_held(&local->sta_mtx);
sta->hnext = local->sta_hash[STA_HASH(sta->sta.addr)];
RCU_INIT_POINTER(local->sta_hash[STA_HASH(sta->sta.addr)], sta);
rcu_assign_pointer(local->sta_hash[STA_HASH(sta->sta.addr)], sta);
}

static void sta_unblock(struct work_struct *wk)
Expand Down
2 changes: 1 addition & 1 deletion net/netfilter/nf_conntrack_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -777,7 +777,7 @@ init_conntrack(struct net *net, struct nf_conn *tmpl,
if (exp->helper) {
help = nf_ct_helper_ext_add(ct, GFP_ATOMIC);
if (help)
RCU_INIT_POINTER(help->helper, exp->helper);
rcu_assign_pointer(help->helper, exp->helper);
}

#ifdef CONFIG_NF_CONNTRACK_MARK
Expand Down
4 changes: 2 additions & 2 deletions net/netfilter/nf_conntrack_ecache.c
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ int nf_conntrack_register_notifier(struct net *net,
ret = -EBUSY;
goto out_unlock;
}
RCU_INIT_POINTER(net->ct.nf_conntrack_event_cb, new);
rcu_assign_pointer(net->ct.nf_conntrack_event_cb, new);
mutex_unlock(&nf_ct_ecache_mutex);
return ret;

Expand Down Expand Up @@ -128,7 +128,7 @@ int nf_ct_expect_register_notifier(struct net *net,
ret = -EBUSY;
goto out_unlock;
}
RCU_INIT_POINTER(net->ct.nf_expect_event_cb, new);
rcu_assign_pointer(net->ct.nf_expect_event_cb, new);
mutex_unlock(&nf_ct_ecache_mutex);
return ret;

Expand Down
2 changes: 1 addition & 1 deletion net/netfilter/nf_conntrack_extend.c
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ int nf_ct_extend_register(struct nf_ct_ext_type *type)
before updating alloc_size */
type->alloc_size = ALIGN(sizeof(struct nf_ct_ext), type->align)
+ type->len;
RCU_INIT_POINTER(nf_ct_ext_types[type->id], type);
rcu_assign_pointer(nf_ct_ext_types[type->id], type);
update_alloc_size(type);
out:
mutex_unlock(&nf_ct_ext_type_mutex);
Expand Down
2 changes: 1 addition & 1 deletion net/netfilter/nf_conntrack_helper.c
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ int __nf_ct_try_assign_helper(struct nf_conn *ct, struct nf_conn *tmpl,
memset(&help->help, 0, sizeof(help->help));
}

RCU_INIT_POINTER(help->helper, helper);
rcu_assign_pointer(help->helper, helper);
out:
return ret;
}
Expand Down
2 changes: 1 addition & 1 deletion net/netfilter/nf_conntrack_netlink.c
Original file line number Diff line number Diff line change
Expand Up @@ -1172,7 +1172,7 @@ ctnetlink_change_helper(struct nf_conn *ct, const struct nlattr * const cda[])
return -EOPNOTSUPP;
}

RCU_INIT_POINTER(help->helper, helper);
rcu_assign_pointer(help->helper, helper);

return 0;
}
Expand Down
6 changes: 3 additions & 3 deletions net/netfilter/nf_log.c
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ int nf_log_register(u_int8_t pf, struct nf_logger *logger)
llog = rcu_dereference_protected(nf_loggers[pf],
lockdep_is_held(&nf_log_mutex));
if (llog == NULL)
RCU_INIT_POINTER(nf_loggers[pf], logger);
rcu_assign_pointer(nf_loggers[pf], logger);
}

mutex_unlock(&nf_log_mutex);
Expand Down Expand Up @@ -92,7 +92,7 @@ int nf_log_bind_pf(u_int8_t pf, const struct nf_logger *logger)
mutex_unlock(&nf_log_mutex);
return -ENOENT;
}
RCU_INIT_POINTER(nf_loggers[pf], logger);
rcu_assign_pointer(nf_loggers[pf], logger);
mutex_unlock(&nf_log_mutex);
return 0;
}
Expand Down Expand Up @@ -250,7 +250,7 @@ static int nf_log_proc_dostring(ctl_table *table, int write,
mutex_unlock(&nf_log_mutex);
return -ENOENT;
}
RCU_INIT_POINTER(nf_loggers[tindex], logger);
rcu_assign_pointer(nf_loggers[tindex], logger);
mutex_unlock(&nf_log_mutex);
} else {
mutex_lock(&nf_log_mutex);
Expand Down
Loading

0 comments on commit cf778b0

Please sign in to comment.