aboutsummaryrefslogtreecommitdiffstats
path: root/tools/testing/selftests/bpf/prog_tests/lwt_helpers.h
diff options
context:
space:
mode:
authorMarcus Wichelmann <[email protected]>2025-03-05 21:34:35 +0000
committerMartin KaFai Lau <[email protected]>2025-03-06 20:31:08 +0000
commitd5ca409c86d35ebe60fad08ed554797abd8e53c0 (patch)
treec2f83d852be6ed8d5109515671c97bf744916ca4 /tools/testing/selftests/bpf/prog_tests/lwt_helpers.h
parentnet: tun: Enable transfer of XDP metadata to skb (diff)
downloadkernel-d5ca409c86d35ebe60fad08ed554797abd8e53c0.tar.gz
kernel-d5ca409c86d35ebe60fad08ed554797abd8e53c0.zip
selftests/bpf: Move open_tuntap to network helpers
To test the XDP metadata functionality of the tun driver, it's necessary to create a new tap device first. A helper function for this already exists in lwt_helpers.h. Move it to the common network helpers header, so it can be reused in other tests. Signed-off-by: Marcus Wichelmann <[email protected]> Signed-off-by: Martin KaFai Lau <[email protected]> Link: https://patch.msgid.link/[email protected]
Diffstat (limited to 'tools/testing/selftests/bpf/prog_tests/lwt_helpers.h')
-rw-r--r--tools/testing/selftests/bpf/prog_tests/lwt_helpers.h29
1 files changed, 0 insertions, 29 deletions
diff --git a/tools/testing/selftests/bpf/prog_tests/lwt_helpers.h b/tools/testing/selftests/bpf/prog_tests/lwt_helpers.h
index fb1eb8c67361..ccec0fcdabc1 100644
--- a/tools/testing/selftests/bpf/prog_tests/lwt_helpers.h
+++ b/tools/testing/selftests/bpf/prog_tests/lwt_helpers.h
@@ -5,7 +5,6 @@
#include <time.h>
#include <net/if.h>
-#include <linux/if_tun.h>
#include <linux/icmp.h>
#include "test_progs.h"
@@ -37,34 +36,6 @@ static inline int netns_delete(void)
return system("ip netns del " NETNS ">/dev/null 2>&1");
}
-static int open_tuntap(const char *dev_name, bool need_mac)
-{
- int err = 0;
- struct ifreq ifr;
- int fd = open("/dev/net/tun", O_RDWR);
-
- if (!ASSERT_GT(fd, 0, "open(/dev/net/tun)"))
- return -1;
-
- ifr.ifr_flags = IFF_NO_PI | (need_mac ? IFF_TAP : IFF_TUN);
- strncpy(ifr.ifr_name, dev_name, IFNAMSIZ - 1);
- ifr.ifr_name[IFNAMSIZ - 1] = '\0';
-
- err = ioctl(fd, TUNSETIFF, &ifr);
- if (!ASSERT_OK(err, "ioctl(TUNSETIFF)")) {
- close(fd);
- return -1;
- }
-
- err = fcntl(fd, F_SETFL, O_NONBLOCK);
- if (!ASSERT_OK(err, "fcntl(O_NONBLOCK)")) {
- close(fd);
- return -1;
- }
-
- return fd;
-}
-
#define ICMP_PAYLOAD_SIZE 100
/* Match an ICMP packet with payload len ICMP_PAYLOAD_SIZE */