History

bpf: Add BPF_F_ADJ_ROOM_DECAP_* flags for tunnel decapsulation

Add new bpf_skb_adjust_room() decapsulation flags: - BPF_F_ADJ_ROOM_DECAP_L4_GRE - BPF_F_ADJ_ROOM_DECAP_L4_UDP - BPF_F_ADJ_ROOM_DECAP_IPXIP4 - BPF_F_ADJ_ROOM_DECAP_IPXIP6 These flags let BPF programs describe which tunnel layer is being removed, so later changes can update tunnel-related GSO state accordingly during decapsulation. This patch only introduces the UAPI flag definitions and helper documentation.

Nick Hudson committed 3 months ago

Commit da199071 parent 7b2ea112 files · +64 −4Browse files

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

Unified · Split

tools/include/uapi/linux/bpf.h+32−2
@@ -3038,8 +3038,34 @@ union bpf_attr { · 3037 unmodified lines
30383038 *
30393039 * * **BPF_F_ADJ_ROOM_DECAP_L3_IPV4**,
30403040 * **BPF_F_ADJ_ROOM_DECAP_L3_IPV6**:
3041− * Indicate the new IP header version after decapsulating the outer
3042− * IP header. Used when the inner and outer IP versions are different.
3041+ * Indicate the new IP header version after decapsulating the
3042+ * outer IP header. Used when the inner and outer IP versions
3043+ * are different. These flags only trigger a protocol change
3044+ * without clearing any tunnel-specific GSO flags.
3045+ *
3046+ * * **BPF_F_ADJ_ROOM_DECAP_L4_GRE**:
3047+ * Clear GRE tunnel GSO flags (SKB_GSO_GRE and SKB_GSO_GRE_CSUM)
3048+ * when decapsulating a GRE tunnel.
3049+ *
3050+ * * **BPF_F_ADJ_ROOM_DECAP_L4_UDP**:
3051+ * Clear UDP tunnel GSO flags (SKB_GSO_UDP_TUNNEL and
3052+ * SKB_GSO_UDP_TUNNEL_CSUM) when decapsulating a UDP tunnel.
3053+ *
3054+ * * **BPF_F_ADJ_ROOM_DECAP_IPXIP4**:
3055+ * Clear IPIP/SIT tunnel GSO flag (SKB_GSO_IPXIP4) when decapsulating
3056+ * a tunnel with an outer IPv4 header (IPv4-in-IPv4 or IPv6-in-IPv4).
3057+ *
3058+ * * **BPF_F_ADJ_ROOM_DECAP_IPXIP6**:
3059+ * Clear IPv6 encapsulation tunnel GSO flag (SKB_GSO_IPXIP6) when
3060+ * decapsulating a tunnel with an outer IPv6 header (IPv6-in-IPv6
3061+ * or IPv4-in-IPv6).
3062+ *
3063+ * When using the decapsulation flags above, the skb->encapsulation
3064+ * flag is automatically cleared if all tunnel-specific GSO flags
3065+ * (SKB_GSO_UDP_TUNNEL, SKB_GSO_UDP_TUNNEL_CSUM, SKB_GSO_GRE,
3066+ * SKB_GSO_GRE_CSUM, SKB_GSO_IPXIP4, SKB_GSO_IPXIP6) have been
3067+ * removed from the packet. This handles cases where all tunnel
3068+ * layers have been decapsulated.
30433069 *
30443070 * A call to this helper is susceptible to change the underlying
30453071 * packet buffer. Therefore, at load time, all checks on pointers
@@ -6293,6 +6319,10 @@ enum bpf_adj_room_flags { · 3247 unmodified lines
62936319 BPF_F_ADJ_ROOM_ENCAP_L2_ETH = (1ULL << 6),
62946320 BPF_F_ADJ_ROOM_DECAP_L3_IPV4 = (1ULL << 7),
62956321 BPF_F_ADJ_ROOM_DECAP_L3_IPV6 = (1ULL << 8),
6322+ BPF_F_ADJ_ROOM_DECAP_L4_GRE = (1ULL << 9),
6323+ BPF_F_ADJ_ROOM_DECAP_L4_UDP = (1ULL << 10),
6324+ BPF_F_ADJ_ROOM_DECAP_IPXIP4 = (1ULL << 11),
6325+ BPF_F_ADJ_ROOM_DECAP_IPXIP6 = (1ULL << 12),
62966326 };
62976327
62986328 enum {