Commit f446bd76 authored by Paul Chaignon's avatar Paul Chaignon Committed by yonghong-song

Comment on duplicate code for parsing double vlans (#2107)

Comment on duplicate code for parsing double vlans.
I also changed it into a short loop, which I don't think improves (or degrades) the code, but at least makes it clear that the double parsing is intentional.
Signed-off-by: default avatarPaul Chaignon <paul.chaignon@orange.com>
parent c8e98d1f
...@@ -96,23 +96,18 @@ int xdp_prog1(struct CTXTYPE *ctx) { ...@@ -96,23 +96,18 @@ int xdp_prog1(struct CTXTYPE *ctx) {
h_proto = eth->h_proto; h_proto = eth->h_proto;
if (h_proto == htons(ETH_P_8021Q) || h_proto == htons(ETH_P_8021AD)) { // parse double vlans
struct vlan_hdr *vhdr; #pragma unroll
for (int i=0; i<2; i++) {
vhdr = data + nh_off; if (h_proto == htons(ETH_P_8021Q) || h_proto == htons(ETH_P_8021AD)) {
nh_off += sizeof(struct vlan_hdr); struct vlan_hdr *vhdr;
if (data + nh_off > data_end)
return rc; vhdr = data + nh_off;
h_proto = vhdr->h_vlan_encapsulated_proto; nh_off += sizeof(struct vlan_hdr);
} if (data + nh_off > data_end)
if (h_proto == htons(ETH_P_8021Q) || h_proto == htons(ETH_P_8021AD)) { return rc;
struct vlan_hdr *vhdr; h_proto = vhdr->h_vlan_encapsulated_proto;
}
vhdr = data + nh_off;
nh_off += sizeof(struct vlan_hdr);
if (data + nh_off > data_end)
return rc;
h_proto = vhdr->h_vlan_encapsulated_proto;
} }
if (h_proto == htons(ETH_P_IP)) if (h_proto == htons(ETH_P_IP))
......
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