History

bpf: Add bpf_skb_adjust_room flag BPF_F_ADJ_ROOM_ENCAP_L2_ETH

bpf_skb_adjust_room sets the inner_protocol as skb->protocol for packets encapsulation. But that is not appropriate when pushing Ethernet header. Add an option to further specify encap L2 type and set the inner_protocol as ETH_P_TEB.

Xuesen Huang committed 5 years ago

Commit d01b59c1 parent bce86233 files · +20 −1Browse files

Showing the changes to include/uapi (1 of 3 files). Show all

Unified · Split

include/uapi/linux/bpf.h+5−0
@@ -2484,6 +2484,10 @@ union bpf_attr { · 2483 unmodified lines
24842484 * Use with ENCAP_L3/L4 flags to further specify the tunnel
24852485 * type; *len* is the length of the inner MAC header.
24862486 *
2487+ * * **BPF_F_ADJ_ROOM_ENCAP_L2_ETH**:
2488+ * Use with BPF_F_ADJ_ROOM_ENCAP_L2 flag to further specify the
2489+ * L2 type as Ethernet.
2490+ *
24872491 * A call to this helper is susceptible to change the underlying
24882492 * packet buffer. Therefore, at load time, all checks on pointers
24892493 * previously done by the verifier are invalidated and must be
@@ -4916,6 +4920,7 @@ enum { · 2426 unmodified lines
49164920 BPF_F_ADJ_ROOM_ENCAP_L4_GRE = (1ULL << 3),
49174921 BPF_F_ADJ_ROOM_ENCAP_L4_UDP = (1ULL << 4),
49184922 BPF_F_ADJ_ROOM_NO_CSUM_RESET = (1ULL << 5),
4923+ BPF_F_ADJ_ROOM_ENCAP_L2_ETH = (1ULL << 6),
49194924 };
49204925
49214926 enum {