Skip to content

Commit

Permalink
packet-solutions: Explain value of eth_type and where eth points
Browse files Browse the repository at this point in the history
Signed-off-by: Jesper Dangaard Brouer <[email protected]>
  • Loading branch information
netoptimizer committed Nov 15, 2020
1 parent 61702d6 commit 2bb3dbc
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions packet-solutions/xdp_vlan02_kern.c
Original file line number Diff line number Diff line change
Expand Up @@ -79,10 +79,14 @@ int xdp_vlan_02(struct xdp_md *ctx)
struct collect_vlans vlans;

struct ethhdr *eth;
eth_type = parse_ethhdr_vlan(&nh, data_end, &eth, &vlans);

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

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

0 comments on commit 2bb3dbc

Please sign in to comment.