@@ -9,6 +9,7 @@
#include <linux/icmp.h>
#include "test_progs.h"
+#include "network_helpers.h"
#define log_err(MSG, ...) \
fprintf(stderr, "(%s:%d: errno: %s) " MSG "\n", \
@@ -16,27 +17,14 @@
#define RUN_TEST(name) \
({ \
- if (test__start_subtest(#name)) \
- if (ASSERT_OK(netns_create(), "netns_create")) { \
- struct nstoken *token = open_netns(NETNS); \
- if (ASSERT_OK_PTR(token, "setns")) { \
- test_ ## name(); \
- close_netns(token); \
- } \
- netns_delete(); \
- } \
+ if (test__start_subtest(#name)) { \
+ struct nstoken *token = create_netns(NETNS); \
+ if (ASSERT_OK_PTR(token, "setns")) \
+ test_ ## name(); \
+ cleanup_netns(token); \
+ } \
})
-static inline int netns_create(void)
-{
- return system("ip netns add " NETNS);
-}
-
-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;
@@ -57,7 +57,6 @@
#define NETNS "ns_lwt_redirect"
#include "lwt_helpers.h"
#include "test_progs.h"
-#include "network_helpers.h"
#define BPF_OBJECT "test_lwt_redirect.bpf.o"
#define INGRESS_SEC(need_mac) ((need_mac) ? "redir_ingress" : "redir_ingress_nomac")
@@ -308,7 +307,6 @@ static void test_lwt_redirect_dev_carrier_down(void)
static void *test_lwt_redirect_run(void *arg)
{
- netns_delete();
RUN_TEST(lwt_redirect_normal);
RUN_TEST(lwt_redirect_normal_nomac);
RUN_TEST(lwt_redirect_dev_down);
@@ -50,7 +50,6 @@
*/
#define NETNS "ns_lwt_reroute"
#include "lwt_helpers.h"
-#include "network_helpers.h"
#include <linux/net_tstamp.h>
#define BPF_OBJECT "test_lwt_reroute.bpf.o"
@@ -242,7 +241,6 @@ static void test_lwt_reroute_qdisc_dropped(void)
static void *test_lwt_reroute_run(void *arg)
{
- netns_delete();
RUN_TEST(lwt_reroute_normal_xmit);
RUN_TEST(lwt_reroute_qdisc_dropped);
return NULL;