Skip to content

Commit 2bb3dbc

Browse files
committed
packet-solutions: Explain value of eth_type and where eth points
Signed-off-by: Jesper Dangaard Brouer <brouer@redhat.com>
1 parent 61702d6 commit 2bb3dbc

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

packet-solutions/xdp_vlan02_kern.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,10 +79,14 @@ int xdp_vlan_02(struct xdp_md *ctx)
7979
struct collect_vlans vlans;
8080

8181
struct ethhdr *eth;
82-
eth_type = parse_ethhdr_vlan(&nh, data_end, &eth, &vlans);
8382

83+
eth_type = parse_ethhdr_vlan(&nh, data_end, &eth, &vlans);
8484
if (eth_type < 0)
8585
return XDP_ABORTED;
86+
/* The eth_type have skipped VLAN-types, but collected VLAN ids. The
87+
* eth ptr still points to Ethernet header, thus to check if this is a
88+
* VLAN packet do proto_is_vlan(eth->h_proto).
89+
*/
8690

8791
/* The LLVM compiler is very clever, it sees that program only access
8892
* 2nd "inner" vlan (array index 1), and only does loop unroll of 2, and
@@ -117,7 +121,7 @@ int xdp_vlan_02(struct xdp_md *ctx)
117121
}
118122
#endif
119123
/* Hint: to inspect BPF byte-code run:
120-
* llvm-objdump -S xdp_vlan02_kern.o
124+
* llvm-objdump --no-show-raw-insn -S xdp_vlan02_kern.o
121125
*/
122126
return XDP_PASS;
123127
}

0 commit comments

Comments
 (0)