mirror of https://github.com/torvalds/linux.git
mpls: Add mpls_dev_rcu().
mpls_dev_get() uses rcu_dereference_rtnl() to fetch dev->mpls_ptr. We will replace RTNL with a dedicated mutex to protect the field. Then, we will use rcu_dereference_protected() for clarity. Let's add mpls_dev_rcu() for the RCU reader. Signed-off-by: Kuniyuki Iwashima <kuniyu@google.com> Reviewed-by: Guillaume Nault <gnault@redhat.com> Link: https://patch.msgid.link/20251029173344.2934622-7-kuniyu@google.com Signed-off-by: Jakub Kicinski <kuba@kernel.org>
This commit is contained in:
parent
bc7ebc569e
commit
ab061f3347
|
|
@ -136,7 +136,7 @@ void mpls_stats_inc_outucastpkts(struct net *net,
|
|||
struct mpls_dev *mdev;
|
||||
|
||||
if (skb->protocol == htons(ETH_P_MPLS_UC)) {
|
||||
mdev = mpls_dev_get(dev);
|
||||
mdev = mpls_dev_rcu(dev);
|
||||
if (mdev)
|
||||
MPLS_INC_STATS_LEN(mdev, skb->len,
|
||||
tx_packets,
|
||||
|
|
@ -358,7 +358,7 @@ static int mpls_forward(struct sk_buff *skb, struct net_device *dev,
|
|||
|
||||
/* Careful this entire function runs inside of an rcu critical section */
|
||||
|
||||
mdev = mpls_dev_get(dev);
|
||||
mdev = mpls_dev_rcu(dev);
|
||||
if (!mdev)
|
||||
goto drop;
|
||||
|
||||
|
|
@ -467,7 +467,7 @@ static int mpls_forward(struct sk_buff *skb, struct net_device *dev,
|
|||
return 0;
|
||||
|
||||
tx_err:
|
||||
out_mdev = out_dev ? mpls_dev_get(out_dev) : NULL;
|
||||
out_mdev = out_dev ? mpls_dev_rcu(out_dev) : NULL;
|
||||
if (out_mdev)
|
||||
MPLS_INC_STATS(out_mdev, tx_errors);
|
||||
goto drop;
|
||||
|
|
@ -1118,7 +1118,7 @@ static int mpls_fill_stats_af(struct sk_buff *skb,
|
|||
struct mpls_dev *mdev;
|
||||
struct nlattr *nla;
|
||||
|
||||
mdev = mpls_dev_get(dev);
|
||||
mdev = mpls_dev_rcu(dev);
|
||||
if (!mdev)
|
||||
return -ENODATA;
|
||||
|
||||
|
|
@ -1138,7 +1138,7 @@ static size_t mpls_get_stats_af_size(const struct net_device *dev)
|
|||
{
|
||||
struct mpls_dev *mdev;
|
||||
|
||||
mdev = mpls_dev_get(dev);
|
||||
mdev = mpls_dev_rcu(dev);
|
||||
if (!mdev)
|
||||
return 0;
|
||||
|
||||
|
|
@ -1341,7 +1341,7 @@ static int mpls_netconf_dump_devconf(struct sk_buff *skb,
|
|||
|
||||
rcu_read_lock();
|
||||
for_each_netdev_dump(net, dev, ctx->ifindex) {
|
||||
mdev = mpls_dev_get(dev);
|
||||
mdev = mpls_dev_rcu(dev);
|
||||
if (!mdev)
|
||||
continue;
|
||||
err = mpls_netconf_fill_devconf(skb, mdev,
|
||||
|
|
|
|||
|
|
@ -185,6 +185,11 @@ static inline struct mpls_entry_decoded mpls_entry_decode(struct mpls_shim_hdr *
|
|||
return result;
|
||||
}
|
||||
|
||||
static inline struct mpls_dev *mpls_dev_rcu(const struct net_device *dev)
|
||||
{
|
||||
return rcu_dereference(dev->mpls_ptr);
|
||||
}
|
||||
|
||||
static inline struct mpls_dev *mpls_dev_get(const struct net_device *dev)
|
||||
{
|
||||
return rcu_dereference_rtnl(dev->mpls_ptr);
|
||||
|
|
|
|||
|
|
@ -153,7 +153,7 @@ static int mpls_xmit(struct sk_buff *skb)
|
|||
return LWTUNNEL_XMIT_DONE;
|
||||
|
||||
drop:
|
||||
out_mdev = out_dev ? mpls_dev_get(out_dev) : NULL;
|
||||
out_mdev = out_dev ? mpls_dev_rcu(out_dev) : NULL;
|
||||
if (out_mdev)
|
||||
MPLS_INC_STATS(out_mdev, tx_errors);
|
||||
kfree_skb(skb);
|
||||
|
|
|
|||
Loading…
Reference in New Issue