OSDN Git Service

samples, bpf: Add an explict comment to handle nested vlan tagging.
authorMuhammad Falak R Wani <falakreyaz@gmail.com>
Mon, 9 Aug 2021 07:00:46 +0000 (12:30 +0530)
committerDaniel Borkmann <daniel@iogearbox.net>
Tue, 10 Aug 2021 09:17:32 +0000 (11:17 +0200)
A codeblock for handling nested vlan trips newbies into thinking it as
duplicate code. Explicitly add a comment to clarify.

Signed-off-by: Muhammad Falak R Wani <falakreyaz@gmail.com>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Link: https://lore.kernel.org/bpf/20210809070046.32142-1-falakreyaz@gmail.com
samples/bpf/xdp1_kern.c
samples/bpf/xdp2_kern.c

index 34b6439..f0c5d95 100644 (file)
@@ -57,6 +57,7 @@ int xdp_prog1(struct xdp_md *ctx)
 
        h_proto = eth->h_proto;
 
+       /* Handle VLAN tagged packet */
        if (h_proto == htons(ETH_P_8021Q) || h_proto == htons(ETH_P_8021AD)) {
                struct vlan_hdr *vhdr;
 
@@ -66,6 +67,7 @@ int xdp_prog1(struct xdp_md *ctx)
                        return rc;
                h_proto = vhdr->h_vlan_encapsulated_proto;
        }
+       /* Handle double VLAN tagged packet */
        if (h_proto == htons(ETH_P_8021Q) || h_proto == htons(ETH_P_8021AD)) {
                struct vlan_hdr *vhdr;
 
index c787f4b..d8a64ab 100644 (file)
@@ -73,6 +73,7 @@ int xdp_prog1(struct xdp_md *ctx)
 
        h_proto = eth->h_proto;
 
+       /* Handle VLAN tagged packet */
        if (h_proto == htons(ETH_P_8021Q) || h_proto == htons(ETH_P_8021AD)) {
                struct vlan_hdr *vhdr;
 
@@ -82,6 +83,7 @@ int xdp_prog1(struct xdp_md *ctx)
                        return rc;
                h_proto = vhdr->h_vlan_encapsulated_proto;
        }
+       /* Handle double VLAN tagged packet */
        if (h_proto == htons(ETH_P_8021Q) || h_proto == htons(ETH_P_8021AD)) {
                struct vlan_hdr *vhdr;