Commit fe741e23 authored by Girish Moodalbail's avatar Girish Moodalbail Committed by David S. Miller

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: default avatarGirish Moodalbail <girish.moodalbail@oracle.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 3ad7d246
...@@ -212,6 +212,7 @@ static void geneve_rx(struct geneve_dev *geneve, struct geneve_sock *gs, ...@@ -212,6 +212,7 @@ static void geneve_rx(struct geneve_dev *geneve, struct geneve_sock *gs,
struct genevehdr *gnvh = geneve_hdr(skb); struct genevehdr *gnvh = geneve_hdr(skb);
struct metadata_dst *tun_dst = NULL; struct metadata_dst *tun_dst = NULL;
struct pcpu_sw_netstats *stats; struct pcpu_sw_netstats *stats;
unsigned int len;
int err = 0; int err = 0;
void *oiph; void *oiph;
...@@ -225,8 +226,10 @@ static void geneve_rx(struct geneve_dev *geneve, struct geneve_sock *gs, ...@@ -225,8 +226,10 @@ static void geneve_rx(struct geneve_dev *geneve, struct geneve_sock *gs,
tun_dst = udp_tun_rx_dst(skb, geneve_get_sk_family(gs), flags, tun_dst = udp_tun_rx_dst(skb, geneve_get_sk_family(gs), flags,
vni_to_tunnel_id(gnvh->vni), vni_to_tunnel_id(gnvh->vni),
gnvh->opt_len * 4); gnvh->opt_len * 4);
if (!tun_dst) if (!tun_dst) {
geneve->dev->stats.rx_dropped++;
goto drop; goto drop;
}
/* Update tunnel dst according to Geneve options. */ /* Update tunnel dst according to Geneve options. */
ip_tunnel_info_opts_set(&tun_dst->u.tun_info, ip_tunnel_info_opts_set(&tun_dst->u.tun_info,
gnvh->options, gnvh->opt_len * 4); gnvh->options, gnvh->opt_len * 4);
...@@ -234,8 +237,11 @@ static void geneve_rx(struct geneve_dev *geneve, struct geneve_sock *gs, ...@@ -234,8 +237,11 @@ static void geneve_rx(struct geneve_dev *geneve, struct geneve_sock *gs,
/* Drop packets w/ critical options, /* Drop packets w/ critical options,
* since we don't support any... * since we don't support any...
*/ */
if (gnvh->critical) if (gnvh->critical) {
geneve->dev->stats.rx_frame_errors++;
geneve->dev->stats.rx_errors++;
goto drop; goto drop;
}
} }
skb_reset_mac_header(skb); skb_reset_mac_header(skb);
...@@ -246,8 +252,10 @@ static void geneve_rx(struct geneve_dev *geneve, struct geneve_sock *gs, ...@@ -246,8 +252,10 @@ static void geneve_rx(struct geneve_dev *geneve, struct geneve_sock *gs,
skb_dst_set(skb, &tun_dst->dst); skb_dst_set(skb, &tun_dst->dst);
/* Ignore packet loops (and multicast echo) */ /* Ignore packet loops (and multicast echo) */
if (ether_addr_equal(eth_hdr(skb)->h_source, geneve->dev->dev_addr)) if (ether_addr_equal(eth_hdr(skb)->h_source, geneve->dev->dev_addr)) {
geneve->dev->stats.rx_errors++;
goto drop; goto drop;
}
oiph = skb_network_header(skb); oiph = skb_network_header(skb);
skb_reset_network_header(skb); skb_reset_network_header(skb);
...@@ -279,13 +287,15 @@ static void geneve_rx(struct geneve_dev *geneve, struct geneve_sock *gs, ...@@ -279,13 +287,15 @@ static void geneve_rx(struct geneve_dev *geneve, struct geneve_sock *gs,
} }
} }
stats = this_cpu_ptr(geneve->dev->tstats); len = skb->len;
u64_stats_update_begin(&stats->syncp); err = gro_cells_receive(&geneve->gro_cells, skb);
stats->rx_packets++; if (likely(err == NET_RX_SUCCESS)) {
stats->rx_bytes += skb->len; stats = this_cpu_ptr(geneve->dev->tstats);
u64_stats_update_end(&stats->syncp); u64_stats_update_begin(&stats->syncp);
stats->rx_packets++;
gro_cells_receive(&geneve->gro_cells, skb); stats->rx_bytes += len;
u64_stats_update_end(&stats->syncp);
}
return; return;
drop: drop:
/* Consume bad packet */ /* Consume bad packet */
...@@ -334,7 +344,7 @@ static int geneve_udp_encap_recv(struct sock *sk, struct sk_buff *skb) ...@@ -334,7 +344,7 @@ static int geneve_udp_encap_recv(struct sock *sk, struct sk_buff *skb)
struct geneve_sock *gs; struct geneve_sock *gs;
int opts_len; int opts_len;
/* Need Geneve and inner Ethernet header to be present */ /* Need UDP and Geneve header to be present */
if (unlikely(!pskb_may_pull(skb, GENEVE_BASE_HLEN))) if (unlikely(!pskb_may_pull(skb, GENEVE_BASE_HLEN)))
goto drop; goto drop;
...@@ -357,8 +367,10 @@ static int geneve_udp_encap_recv(struct sock *sk, struct sk_buff *skb) ...@@ -357,8 +367,10 @@ static int geneve_udp_encap_recv(struct sock *sk, struct sk_buff *skb)
opts_len = geneveh->opt_len * 4; opts_len = geneveh->opt_len * 4;
if (iptunnel_pull_header(skb, GENEVE_BASE_HLEN + opts_len, if (iptunnel_pull_header(skb, GENEVE_BASE_HLEN + opts_len,
htons(ETH_P_TEB), htons(ETH_P_TEB),
!net_eq(geneve->net, dev_net(geneve->dev)))) !net_eq(geneve->net, dev_net(geneve->dev)))) {
geneve->dev->stats.rx_dropped++;
goto drop; goto drop;
}
geneve_rx(geneve, gs, skb); geneve_rx(geneve, gs, skb);
return 0; return 0;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment