Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

selftests/bpf: Add selftests for the invocation of bpf_lwt_xmit_push_encap

Calling bpf_lwt_xmit_push_encap will not cause a crash when dst is missing.

Signed-off-by: Feng Yang <yangfeng@kylinos.cn>
Signed-off-by: Martin KaFai Lau <martin.lau@kernel.org>
Link: https://patch.msgid.link/20260304094429.168521-3-yangfeng59949@163.com

authored by

Feng Yang and committed by
Martin KaFai Lau
e8ae16d6 97278747

+31
+9
tools/testing/selftests/bpf/prog_tests/lwt_misc.c
··· 1 + // SPDX-License-Identifier: GPL-2.0 2 + 3 + #include <test_progs.h> 4 + #include "lwt_misc.skel.h" 5 + 6 + void test_lwt_misc(void) 7 + { 8 + RUN_TESTS(lwt_misc); 9 + }
+22
tools/testing/selftests/bpf/progs/lwt_misc.c
··· 1 + // SPDX-License-Identifier: GPL-2.0 2 + 3 + #include "vmlinux.h" 4 + #include <bpf/bpf_helpers.h> 5 + #include "bpf_misc.h" 6 + 7 + SEC("lwt_xmit") 8 + __success __retval(0) 9 + int test_missing_dst(struct __sk_buff *skb) 10 + { 11 + struct iphdr iph; 12 + 13 + __builtin_memset(&iph, 0, sizeof(struct iphdr)); 14 + iph.ihl = 5; 15 + iph.version = 4; 16 + 17 + bpf_lwt_push_encap(skb, BPF_LWT_ENCAP_IP, &iph, sizeof(struct iphdr)); 18 + 19 + return 0; 20 + } 21 + 22 + char _license[] SEC("license") = "GPL";