Skip to content

Commit

Permalink
2018-07 - packet dropping - fix ETH_P_8021AD IEEE_802.1ad QinQ or dou…
Browse files Browse the repository at this point in the history
…ble vlan encoding
  • Loading branch information
majek committed Jul 15, 2018
1 parent a0c86a9 commit 765d4b6
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions 2018-07-dropping-packets/xdp-drop-ebpf.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,20 @@ int xdp_drop_benchmark_traffic(struct xdp_md *ctx)
}

uint16_t h_proto = eth->h_proto;
if (h_proto == htons(ETH_P_8021Q) || h_proto == htons(ETH_P_8021AD)) {
struct vlan_hdr *vhdr;
int i;

vhdr = data + nh_off;
nh_off += sizeof(struct vlan_hdr);
if (data + nh_off > data_end) {
return XDP_PASS;
/* Handle double VLAN tagged packet. See https://en.wikipedia.org/wiki/IEEE_802.1ad */
for (i = 0; i < 2; i++) {
if (h_proto == htons(ETH_P_8021Q) || h_proto == htons(ETH_P_8021AD)) {
struct vlan_hdr *vhdr;

vhdr = data + nh_off;
nh_off += sizeof(struct vlan_hdr);
if (data + nh_off > data_end) {
return XDP_PASS;
}
h_proto = vhdr->h_vlan_encapsulated_proto;
}
h_proto = vhdr->h_vlan_encapsulated_proto;
}

if (h_proto == htons(ETH_P_IP)) {
Expand Down

1 comment on commit 765d4b6

@X-Cli
Copy link

@X-Cli X-Cli commented on 765d4b6 Jul 15, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe this patch solves the issue! \o/

Please sign in to comment.