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

selftests/bpf: Migrate test_xdp_redirect.c to test_xdp_do_redirect.c

prog_tests/xdp_do_redirect.c is the only user of the BPF programs
located in progs/test_xdp_do_redirect.c and progs/test_xdp_redirect.c.
There is no need to keep both files with such close names.

Move test_xdp_redirect.c contents to test_xdp_do_redirect.c and remove
progs/test_xdp_redirect.c

Signed-off-by: Bastien Curutchet (eBPF Foundation) <bastien.curutchet@bootlin.com>
Signed-off-by: Martin KaFai Lau <martin.lau@kernel.org>
Link: https://patch.msgid.link/20250110-xdp_redirect-v2-3-b8f3ae53e894@bootlin.com

authored by

Bastien Curutchet (eBPF Foundation) and committed by
Martin KaFai Lau
3e99fa9f a94df601

+15 -30
+3 -4
tools/testing/selftests/bpf/prog_tests/xdp_do_redirect.c
··· 11 11 #include <bpf/bpf_endian.h> 12 12 #include <uapi/linux/netdev.h> 13 13 #include "test_xdp_do_redirect.skel.h" 14 - #include "test_xdp_redirect.skel.h" 15 14 #include "xdp_dummy.skel.h" 16 15 17 16 struct udp_packet { ··· 323 324 324 325 static void ping_test(struct test_data *data) 325 326 { 326 - struct test_xdp_redirect *skel = NULL; 327 + struct test_xdp_do_redirect *skel = NULL; 327 328 struct xdp_dummy *skel_dummy = NULL; 328 329 struct nstoken *nstoken = NULL; 329 330 int i, ret; ··· 350 351 nstoken = NULL; 351 352 } 352 353 353 - skel = test_xdp_redirect__open_and_load(); 354 + skel = test_xdp_do_redirect__open_and_load(); 354 355 if (!ASSERT_OK_PTR(skel, "open and load skeleton")) 355 356 goto close; 356 357 ··· 382 383 close: 383 384 close_netns(nstoken); 384 385 xdp_dummy__destroy(skel_dummy); 385 - test_xdp_redirect__destroy(skel); 386 + test_xdp_do_redirect__destroy(skel); 386 387 } 387 388 388 389
+12
tools/testing/selftests/bpf/progs/test_xdp_do_redirect.c
··· 98 98 return XDP_DROP; 99 99 } 100 100 101 + SEC("xdp") 102 + int xdp_redirect_to_111(struct xdp_md *xdp) 103 + { 104 + return bpf_redirect(111, 0); 105 + } 106 + 107 + SEC("xdp") 108 + int xdp_redirect_to_222(struct xdp_md *xdp) 109 + { 110 + return bpf_redirect(222, 0); 111 + } 112 + 101 113 SEC("tc") 102 114 int tc_count_pkts(struct __sk_buff *skb) 103 115 {
-26
tools/testing/selftests/bpf/progs/test_xdp_redirect.c
··· 1 - /* Copyright (c) 2017 VMware 2 - * 3 - * This program is free software; you can redistribute it and/or 4 - * modify it under the terms of version 2 of the GNU General Public 5 - * License as published by the Free Software Foundation. 6 - * 7 - * This program is distributed in the hope that it will be useful, but 8 - * WITHOUT ANY WARRANTY; without even the implied warranty of 9 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 10 - * General Public License for more details. 11 - */ 12 - #include <linux/bpf.h> 13 - #include <bpf/bpf_helpers.h> 14 - 15 - SEC("xdp") 16 - int xdp_redirect_to_111(struct xdp_md *xdp) 17 - { 18 - return bpf_redirect(111, 0); 19 - } 20 - SEC("xdp") 21 - int xdp_redirect_to_222(struct xdp_md *xdp) 22 - { 23 - return bpf_redirect(222, 0); 24 - } 25 - 26 - char _license[] SEC("license") = "GPL";