Skip to content

Commit

Permalink
bareudp: Handle stats using NETDEV_PCPU_STAT_DSTATS.
Browse files Browse the repository at this point in the history
Bareudp uses the TSTATS infrastructure (dev_sw_netstats_*()) for RX
packet counters. It was also recently converted to use the device core
stats (dev_core_stats_*()) for RX and TX drops (see commit 788d5d6
("bareudp: Use pcpu stats to update rx_dropped counter.")).

Since core stats are to be avoided in drivers, and for consistency with
VXLAN and Geneve, let's convert packet stats handling to DSTATS, which
can handle RX/TX stats and packet drops. Statistics that don't fit
DSTATS are still updated atomically with DEV_STATS_INC().

Signed-off-by: Guillaume Nault <gnault@redhat.com>
Link: https://patch.msgid.link/0f4f8448db3ff449ac6e939872b28cf3f8982da7.1733313925.git.gnault@redhat.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
  • Loading branch information
Guillaume Nault authored and Jakub Kicinski committed Dec 7, 2024
1 parent 6fa6de3 commit c77200c
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions drivers/net/bareudp.c
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ static int bareudp_udp_encap_recv(struct sock *sk, struct sk_buff *skb)

if (skb_copy_bits(skb, BAREUDP_BASE_HLEN, &ipversion,
sizeof(ipversion))) {
dev_core_stats_rx_dropped_inc(bareudp->dev);
dev_dstats_rx_dropped(bareudp->dev);
goto drop;
}
ipversion >>= 4;
Expand All @@ -94,7 +94,7 @@ static int bareudp_udp_encap_recv(struct sock *sk, struct sk_buff *skb)
} else if (ipversion == 6 && bareudp->multi_proto_mode) {
proto = htons(ETH_P_IPV6);
} else {
dev_core_stats_rx_dropped_inc(bareudp->dev);
dev_dstats_rx_dropped(bareudp->dev);
goto drop;
}
} else if (bareudp->ethertype == htons(ETH_P_MPLS_UC)) {
Expand All @@ -108,7 +108,7 @@ static int bareudp_udp_encap_recv(struct sock *sk, struct sk_buff *skb)
ipv4_is_multicast(tunnel_hdr->daddr)) {
proto = htons(ETH_P_MPLS_MC);
} else {
dev_core_stats_rx_dropped_inc(bareudp->dev);
dev_dstats_rx_dropped(bareudp->dev);
goto drop;
}
} else {
Expand All @@ -124,7 +124,7 @@ static int bareudp_udp_encap_recv(struct sock *sk, struct sk_buff *skb)
(addr_type & IPV6_ADDR_MULTICAST)) {
proto = htons(ETH_P_MPLS_MC);
} else {
dev_core_stats_rx_dropped_inc(bareudp->dev);
dev_dstats_rx_dropped(bareudp->dev);
goto drop;
}
}
Expand All @@ -136,15 +136,15 @@ static int bareudp_udp_encap_recv(struct sock *sk, struct sk_buff *skb)
proto,
!net_eq(bareudp->net,
dev_net(bareudp->dev)))) {
dev_core_stats_rx_dropped_inc(bareudp->dev);
dev_dstats_rx_dropped(bareudp->dev);
goto drop;
}

__set_bit(IP_TUNNEL_KEY_BIT, key);

tun_dst = udp_tun_rx_dst(skb, family, key, 0, 0);
if (!tun_dst) {
dev_core_stats_rx_dropped_inc(bareudp->dev);
dev_dstats_rx_dropped(bareudp->dev);
goto drop;
}
skb_dst_set(skb, &tun_dst->dst);
Expand Down Expand Up @@ -194,7 +194,7 @@ static int bareudp_udp_encap_recv(struct sock *sk, struct sk_buff *skb)
len = skb->len;
err = gro_cells_receive(&bareudp->gro_cells, skb);
if (likely(err == NET_RX_SUCCESS))
dev_sw_netstats_rx_add(bareudp->dev, len);
dev_dstats_rx_add(bareudp->dev, len);

return 0;
drop:
Expand Down Expand Up @@ -589,7 +589,7 @@ static void bareudp_setup(struct net_device *dev)
dev->priv_flags |= IFF_NO_QUEUE;
dev->lltx = true;
dev->flags = IFF_POINTOPOINT | IFF_NOARP | IFF_MULTICAST;
dev->pcpu_stat_type = NETDEV_PCPU_STAT_TSTATS;
dev->pcpu_stat_type = NETDEV_PCPU_STAT_DSTATS;
}

static int bareudp_validate(struct nlattr *tb[], struct nlattr *data[],
Expand Down

0 comments on commit c77200c

Please sign in to comment.