Skip to content

Commit 795540b

Browse files
Guillaume NaultNipaLocal
Guillaume Nault
authored and
NipaLocal
committed
bareudp: Handle stats using NETDEV_PCPU_STAT_DSTATS.
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 <[email protected]> Signed-off-by: NipaLocal <nipa@local>
1 parent e9e11cb commit 795540b

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

drivers/net/bareudp.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ static int bareudp_udp_encap_recv(struct sock *sk, struct sk_buff *skb)
8484

8585
if (skb_copy_bits(skb, BAREUDP_BASE_HLEN, &ipversion,
8686
sizeof(ipversion))) {
87-
dev_core_stats_rx_dropped_inc(bareudp->dev);
87+
dev_dstats_rx_dropped(bareudp->dev);
8888
goto drop;
8989
}
9090
ipversion >>= 4;
@@ -94,7 +94,7 @@ static int bareudp_udp_encap_recv(struct sock *sk, struct sk_buff *skb)
9494
} else if (ipversion == 6 && bareudp->multi_proto_mode) {
9595
proto = htons(ETH_P_IPV6);
9696
} else {
97-
dev_core_stats_rx_dropped_inc(bareudp->dev);
97+
dev_dstats_rx_dropped(bareudp->dev);
9898
goto drop;
9999
}
100100
} else if (bareudp->ethertype == htons(ETH_P_MPLS_UC)) {
@@ -108,7 +108,7 @@ static int bareudp_udp_encap_recv(struct sock *sk, struct sk_buff *skb)
108108
ipv4_is_multicast(tunnel_hdr->daddr)) {
109109
proto = htons(ETH_P_MPLS_MC);
110110
} else {
111-
dev_core_stats_rx_dropped_inc(bareudp->dev);
111+
dev_dstats_rx_dropped(bareudp->dev);
112112
goto drop;
113113
}
114114
} else {
@@ -124,7 +124,7 @@ static int bareudp_udp_encap_recv(struct sock *sk, struct sk_buff *skb)
124124
(addr_type & IPV6_ADDR_MULTICAST)) {
125125
proto = htons(ETH_P_MPLS_MC);
126126
} else {
127-
dev_core_stats_rx_dropped_inc(bareudp->dev);
127+
dev_dstats_rx_dropped(bareudp->dev);
128128
goto drop;
129129
}
130130
}
@@ -136,15 +136,15 @@ static int bareudp_udp_encap_recv(struct sock *sk, struct sk_buff *skb)
136136
proto,
137137
!net_eq(bareudp->net,
138138
dev_net(bareudp->dev)))) {
139-
dev_core_stats_rx_dropped_inc(bareudp->dev);
139+
dev_dstats_rx_dropped(bareudp->dev);
140140
goto drop;
141141
}
142142

143143
__set_bit(IP_TUNNEL_KEY_BIT, key);
144144

145145
tun_dst = udp_tun_rx_dst(skb, family, key, 0, 0);
146146
if (!tun_dst) {
147-
dev_core_stats_rx_dropped_inc(bareudp->dev);
147+
dev_dstats_rx_dropped(bareudp->dev);
148148
goto drop;
149149
}
150150
skb_dst_set(skb, &tun_dst->dst);
@@ -194,7 +194,7 @@ static int bareudp_udp_encap_recv(struct sock *sk, struct sk_buff *skb)
194194
len = skb->len;
195195
err = gro_cells_receive(&bareudp->gro_cells, skb);
196196
if (likely(err == NET_RX_SUCCESS))
197-
dev_sw_netstats_rx_add(bareudp->dev, len);
197+
dev_dstats_rx_add(bareudp->dev, len);
198198

199199
return 0;
200200
drop:
@@ -589,7 +589,7 @@ static void bareudp_setup(struct net_device *dev)
589589
dev->priv_flags |= IFF_NO_QUEUE;
590590
dev->lltx = true;
591591
dev->flags = IFF_POINTOPOINT | IFF_NOARP | IFF_MULTICAST;
592-
dev->pcpu_stat_type = NETDEV_PCPU_STAT_TSTATS;
592+
dev->pcpu_stat_type = NETDEV_PCPU_STAT_DSTATS;
593593
}
594594

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

0 commit comments

Comments
 (0)