Commit d692a637 authored by Muhammad Falak R Wani's avatar Muhammad Falak R Wani Committed by Daniel Borkmann

samples, bpf: Add an explict comment to handle nested vlan tagging.

A codeblock for handling nested vlan trips newbies into thinking it as
duplicate code. Explicitly add a comment to clarify.
Signed-off-by: default avatarMuhammad Falak R Wani <falakreyaz@gmail.com>
Signed-off-by: default avatarDaniel Borkmann <daniel@iogearbox.net>
Link: https://lore.kernel.org/bpf/20210809070046.32142-1-falakreyaz@gmail.com
parent 6aab1c81
...@@ -57,6 +57,7 @@ int xdp_prog1(struct xdp_md *ctx) ...@@ -57,6 +57,7 @@ int xdp_prog1(struct xdp_md *ctx)
h_proto = eth->h_proto; h_proto = eth->h_proto;
/* Handle VLAN tagged packet */
if (h_proto == htons(ETH_P_8021Q) || h_proto == htons(ETH_P_8021AD)) { if (h_proto == htons(ETH_P_8021Q) || h_proto == htons(ETH_P_8021AD)) {
struct vlan_hdr *vhdr; struct vlan_hdr *vhdr;
...@@ -66,6 +67,7 @@ int xdp_prog1(struct xdp_md *ctx) ...@@ -66,6 +67,7 @@ int xdp_prog1(struct xdp_md *ctx)
return rc; return rc;
h_proto = vhdr->h_vlan_encapsulated_proto; 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)) { if (h_proto == htons(ETH_P_8021Q) || h_proto == htons(ETH_P_8021AD)) {
struct vlan_hdr *vhdr; struct vlan_hdr *vhdr;
......
...@@ -73,6 +73,7 @@ int xdp_prog1(struct xdp_md *ctx) ...@@ -73,6 +73,7 @@ int xdp_prog1(struct xdp_md *ctx)
h_proto = eth->h_proto; h_proto = eth->h_proto;
/* Handle VLAN tagged packet */
if (h_proto == htons(ETH_P_8021Q) || h_proto == htons(ETH_P_8021AD)) { if (h_proto == htons(ETH_P_8021Q) || h_proto == htons(ETH_P_8021AD)) {
struct vlan_hdr *vhdr; struct vlan_hdr *vhdr;
...@@ -82,6 +83,7 @@ int xdp_prog1(struct xdp_md *ctx) ...@@ -82,6 +83,7 @@ int xdp_prog1(struct xdp_md *ctx)
return rc; return rc;
h_proto = vhdr->h_vlan_encapsulated_proto; 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)) { if (h_proto == htons(ETH_P_8021Q) || h_proto == htons(ETH_P_8021AD)) {
struct vlan_hdr *vhdr; struct vlan_hdr *vhdr;
......
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