Skip to content

Commit f48d431

Browse files
committed
selftests/bpf: tc_tunnel - pass decap flags for tunnel type
commit-author Nick Hudson <nhudson@akamai.com> commit - commit-source https://lore.kernel.org/netdev/20260504101759.3319427-7-nhudson@akamai.com/ upstream-diff | The upstream patch targets a newer selftest framework with CO-RE support (bpf_cast_to_kern_ctx, bpf_core_cast, bpf_core_enum_value_exists). This tree has an older version of test_tc_tunnel.c without those features, so the following upstream changes were dropped: - CO-RE enum existence checks for flag availability - Post-decap GSO gso_type and skb->encapsulation validation - TSO disable removal from prog_tests/test_tc_tunnel.c (file absent) The functional flag-passing changes (DECAP_L4_GRE, DECAP_L4_UDP, DECAP_IPXIP4, DECAP_IPXIP6) to decap_internal/decap_ipv4/decap_ipv6 are applied as in upstream. Pass the new BPF_F_ADJ_ROOM_DECAP_* flags through the decap path so the kernel clears the correct GSO and encapsulation state when removing tunnel headers. Signed-off-by: Nick Hudson <nhudson@akamai.com> Signed-off-by: Brett Mastbergen <bmastbergen@ciq.com>
1 parent d84d5ac commit f48d431

1 file changed

Lines changed: 16 additions & 7 deletions

File tree

tools/testing/selftests/bpf/progs/test_tc_tunnel.c

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -597,7 +597,8 @@ int __encap_ip6vxlan_eth(struct __sk_buff *skb)
597597
return TC_ACT_OK;
598598
}
599599

600-
static int decap_internal(struct __sk_buff *skb, int off, int len, char proto)
600+
static int decap_internal(struct __sk_buff *skb, int off, int len, char proto,
601+
__u64 ipxip_flag)
601602
{
602603
__u64 flags = BPF_F_ADJ_ROOM_FIXED_GSO;
603604
struct ipv6_opt_hdr ip6_opt_hdr;
@@ -607,28 +608,33 @@ static int decap_internal(struct __sk_buff *skb, int off, int len, char proto)
607608

608609
switch (proto) {
609610
case IPPROTO_IPIP:
610-
flags |= BPF_F_ADJ_ROOM_DECAP_L3_IPV4;
611+
flags |= BPF_F_ADJ_ROOM_DECAP_L3_IPV4 |
612+
ipxip_flag;
611613
break;
612614
case IPPROTO_IPV6:
613-
flags |= BPF_F_ADJ_ROOM_DECAP_L3_IPV6;
615+
flags |= BPF_F_ADJ_ROOM_DECAP_L3_IPV6 |
616+
ipxip_flag;
614617
break;
615618
case NEXTHDR_DEST:
616619
if (bpf_skb_load_bytes(skb, off + len, &ip6_opt_hdr,
617620
sizeof(ip6_opt_hdr)) < 0)
618621
return TC_ACT_OK;
619622
switch (ip6_opt_hdr.nexthdr) {
620623
case IPPROTO_IPIP:
621-
flags |= BPF_F_ADJ_ROOM_DECAP_L3_IPV4;
624+
flags |= BPF_F_ADJ_ROOM_DECAP_L3_IPV4 |
625+
ipxip_flag;
622626
break;
623627
case IPPROTO_IPV6:
624-
flags |= BPF_F_ADJ_ROOM_DECAP_L3_IPV6;
628+
flags |= BPF_F_ADJ_ROOM_DECAP_L3_IPV6 |
629+
ipxip_flag;
625630
break;
626631
default:
627632
return TC_ACT_OK;
628633
}
629634
break;
630635
case IPPROTO_GRE:
631636
olen += sizeof(struct gre_hdr);
637+
flags |= BPF_F_ADJ_ROOM_DECAP_L4_GRE;
632638
if (bpf_skb_load_bytes(skb, off + len, &greh, sizeof(greh)) < 0)
633639
return TC_ACT_OK;
634640
switch (bpf_ntohs(greh.protocol)) {
@@ -642,6 +648,7 @@ static int decap_internal(struct __sk_buff *skb, int off, int len, char proto)
642648
break;
643649
case IPPROTO_UDP:
644650
olen += sizeof(struct udphdr);
651+
flags |= BPF_F_ADJ_ROOM_DECAP_L4_UDP;
645652
if (bpf_skb_load_bytes(skb, off + len, &udph, sizeof(udph)) < 0)
646653
return TC_ACT_OK;
647654
switch (bpf_ntohs(udph.dest)) {
@@ -678,7 +685,8 @@ static int decap_ipv4(struct __sk_buff *skb)
678685
return TC_ACT_OK;
679686

680687
return decap_internal(skb, ETH_HLEN, sizeof(iph_outer),
681-
iph_outer.protocol);
688+
iph_outer.protocol,
689+
BPF_F_ADJ_ROOM_DECAP_IPXIP4);
682690
}
683691

684692
static int decap_ipv6(struct __sk_buff *skb)
@@ -690,7 +698,8 @@ static int decap_ipv6(struct __sk_buff *skb)
690698
return TC_ACT_OK;
691699

692700
return decap_internal(skb, ETH_HLEN, sizeof(iph_outer),
693-
iph_outer.nexthdr);
701+
iph_outer.nexthdr,
702+
BPF_F_ADJ_ROOM_DECAP_IPXIP6);
694703
}
695704

696705
SEC("decap")

0 commit comments

Comments
 (0)