Skip to content

Commit fe741e2

Browse files
Girish Moodalbaildavem330
authored andcommitted
geneve: add missing rx stats accounting
There are few places on the receive path where packet drops and packet errors were not accounted for. This patch fixes that issue. Signed-off-by: Girish Moodalbail <girish.moodalbail@oracle.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 3ad7d24 commit fe741e2

File tree

1 file changed

+24
-12
lines changed

1 file changed

+24
-12
lines changed

drivers/net/geneve.c

Lines changed: 24 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,7 @@ static void geneve_rx(struct geneve_dev *geneve, struct geneve_sock *gs,
212212
struct genevehdr *gnvh = geneve_hdr(skb);
213213
struct metadata_dst *tun_dst = NULL;
214214
struct pcpu_sw_netstats *stats;
215+
unsigned int len;
215216
int err = 0;
216217
void *oiph;
217218

@@ -225,17 +226,22 @@ static void geneve_rx(struct geneve_dev *geneve, struct geneve_sock *gs,
225226
tun_dst = udp_tun_rx_dst(skb, geneve_get_sk_family(gs), flags,
226227
vni_to_tunnel_id(gnvh->vni),
227228
gnvh->opt_len * 4);
228-
if (!tun_dst)
229+
if (!tun_dst) {
230+
geneve->dev->stats.rx_dropped++;
229231
goto drop;
232+
}
230233
/* Update tunnel dst according to Geneve options. */
231234
ip_tunnel_info_opts_set(&tun_dst->u.tun_info,
232235
gnvh->options, gnvh->opt_len * 4);
233236
} else {
234237
/* Drop packets w/ critical options,
235238
* since we don't support any...
236239
*/
237-
if (gnvh->critical)
240+
if (gnvh->critical) {
241+
geneve->dev->stats.rx_frame_errors++;
242+
geneve->dev->stats.rx_errors++;
238243
goto drop;
244+
}
239245
}
240246

241247
skb_reset_mac_header(skb);
@@ -246,8 +252,10 @@ static void geneve_rx(struct geneve_dev *geneve, struct geneve_sock *gs,
246252
skb_dst_set(skb, &tun_dst->dst);
247253

248254
/* Ignore packet loops (and multicast echo) */
249-
if (ether_addr_equal(eth_hdr(skb)->h_source, geneve->dev->dev_addr))
255+
if (ether_addr_equal(eth_hdr(skb)->h_source, geneve->dev->dev_addr)) {
256+
geneve->dev->stats.rx_errors++;
250257
goto drop;
258+
}
251259

252260
oiph = skb_network_header(skb);
253261
skb_reset_network_header(skb);
@@ -279,13 +287,15 @@ static void geneve_rx(struct geneve_dev *geneve, struct geneve_sock *gs,
279287
}
280288
}
281289

282-
stats = this_cpu_ptr(geneve->dev->tstats);
283-
u64_stats_update_begin(&stats->syncp);
284-
stats->rx_packets++;
285-
stats->rx_bytes += skb->len;
286-
u64_stats_update_end(&stats->syncp);
287-
288-
gro_cells_receive(&geneve->gro_cells, skb);
290+
len = skb->len;
291+
err = gro_cells_receive(&geneve->gro_cells, skb);
292+
if (likely(err == NET_RX_SUCCESS)) {
293+
stats = this_cpu_ptr(geneve->dev->tstats);
294+
u64_stats_update_begin(&stats->syncp);
295+
stats->rx_packets++;
296+
stats->rx_bytes += len;
297+
u64_stats_update_end(&stats->syncp);
298+
}
289299
return;
290300
drop:
291301
/* Consume bad packet */
@@ -334,7 +344,7 @@ static int geneve_udp_encap_recv(struct sock *sk, struct sk_buff *skb)
334344
struct geneve_sock *gs;
335345
int opts_len;
336346

337-
/* Need Geneve and inner Ethernet header to be present */
347+
/* Need UDP and Geneve header to be present */
338348
if (unlikely(!pskb_may_pull(skb, GENEVE_BASE_HLEN)))
339349
goto drop;
340350

@@ -357,8 +367,10 @@ static int geneve_udp_encap_recv(struct sock *sk, struct sk_buff *skb)
357367
opts_len = geneveh->opt_len * 4;
358368
if (iptunnel_pull_header(skb, GENEVE_BASE_HLEN + opts_len,
359369
htons(ETH_P_TEB),
360-
!net_eq(geneve->net, dev_net(geneve->dev))))
370+
!net_eq(geneve->net, dev_net(geneve->dev)))) {
371+
geneve->dev->stats.rx_dropped++;
361372
goto drop;
373+
}
362374

363375
geneve_rx(geneve, gs, skb);
364376
return 0;

0 commit comments

Comments
 (0)