Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

mpls: Use in6_dev_rcu() and dev_net_rcu() in mpls_forward() and mpls_xmit().

mpls_forward() and mpls_xmit() are called under RCU.

Let's use in6_dev_rcu() and dev_net_rcu() there to annotate
as such.

Now we pass net to mpls_stats_inc_outucastpkts() not to read
dev_net_rcu() twice.

Signed-off-by: Kuniyuki Iwashima <kuniyu@google.com>
Reviewed-by: Guillaume Nault <gnault@redhat.com>
Link: https://patch.msgid.link/20251029173344.2934622-6-kuniyu@google.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>

authored by

Kuniyuki Iwashima and committed by
Jakub Kicinski
bc7ebc56 d8f9581e

+12 -10
+8 -7
net/mpls/af_mpls.c
··· 129 129 } 130 130 EXPORT_SYMBOL_GPL(mpls_pkt_too_big); 131 131 132 - void mpls_stats_inc_outucastpkts(struct net_device *dev, 132 + void mpls_stats_inc_outucastpkts(struct net *net, 133 + struct net_device *dev, 133 134 const struct sk_buff *skb) 134 135 { 135 136 struct mpls_dev *mdev; ··· 142 141 tx_packets, 143 142 tx_bytes); 144 143 } else if (skb->protocol == htons(ETH_P_IP)) { 145 - IP_UPD_PO_STATS(dev_net(dev), IPSTATS_MIB_OUT, skb->len); 144 + IP_UPD_PO_STATS(net, IPSTATS_MIB_OUT, skb->len); 146 145 #if IS_ENABLED(CONFIG_IPV6) 147 146 } else if (skb->protocol == htons(ETH_P_IPV6)) { 148 - struct inet6_dev *in6dev = __in6_dev_get(dev); 147 + struct inet6_dev *in6dev = in6_dev_rcu(dev); 149 148 150 149 if (in6dev) 151 - IP6_UPD_PO_STATS(dev_net(dev), in6dev, 150 + IP6_UPD_PO_STATS(net, in6dev, 152 151 IPSTATS_MIB_OUT, skb->len); 153 152 #endif 154 153 } ··· 343 342 static int mpls_forward(struct sk_buff *skb, struct net_device *dev, 344 343 struct packet_type *pt, struct net_device *orig_dev) 345 344 { 346 - struct net *net = dev_net(dev); 345 + struct net *net = dev_net_rcu(dev); 347 346 struct mpls_shim_hdr *hdr; 348 347 const struct mpls_nh *nh; 349 348 struct mpls_route *rt; ··· 435 434 dec.ttl -= 1; 436 435 if (unlikely(!new_header_size && dec.bos)) { 437 436 /* Penultimate hop popping */ 438 - if (!mpls_egress(dev_net(out_dev), rt, skb, dec)) 437 + if (!mpls_egress(net, rt, skb, dec)) 439 438 goto err; 440 439 } else { 441 440 bool bos; ··· 452 451 } 453 452 } 454 453 455 - mpls_stats_inc_outucastpkts(out_dev, skb); 454 + mpls_stats_inc_outucastpkts(net, out_dev, skb); 456 455 457 456 /* If via wasn't specified then send out using device address */ 458 457 if (nh->nh_via_table == MPLS_NEIGH_TABLE_UNSPEC)
+2 -1
net/mpls/internal.h
··· 197 197 bool mpls_output_possible(const struct net_device *dev); 198 198 unsigned int mpls_dev_mtu(const struct net_device *dev); 199 199 bool mpls_pkt_too_big(const struct sk_buff *skb, unsigned int mtu); 200 - void mpls_stats_inc_outucastpkts(struct net_device *dev, 200 + void mpls_stats_inc_outucastpkts(struct net *net, 201 + struct net_device *dev, 201 202 const struct sk_buff *skb); 202 203 203 204 #endif /* MPLS_INTERNAL_H */
+2 -2
net/mpls/mpls_iptunnel.c
··· 53 53 54 54 /* Find the output device */ 55 55 out_dev = dst->dev; 56 - net = dev_net(out_dev); 56 + net = dev_net_rcu(out_dev); 57 57 58 58 if (!mpls_output_possible(out_dev) || 59 59 !dst->lwtstate || skb_warn_if_lro(skb)) ··· 128 128 bos = false; 129 129 } 130 130 131 - mpls_stats_inc_outucastpkts(out_dev, skb); 131 + mpls_stats_inc_outucastpkts(net, out_dev, skb); 132 132 133 133 if (rt) { 134 134 if (rt->rt_gw_family == AF_INET6)