@@ -27,15 +27,11 @@ static int prepare_netns(void)
LIBBPF_OPTS(bpf_tc_opts, tc_attach,
.prog_fd = bpf_program__fd(skel->progs.cls_ingress));
- if (CHECK(unshare(CLONE_NEWNET), "create netns",
+ if (CHECK(unshare_netns(), "create netns",
"unshare(CLONE_NEWNET): %s (%d)",
strerror(errno), errno))
return -1;
- if (CHECK(system("ip link set dev lo up"),
- "ip link set dev lo up", "failed\n"))
- return -1;
-
qdisc_lo.ifindex = if_nametoindex("lo");
if (!ASSERT_OK(bpf_tc_hook_create(&qdisc_lo), "qdisc add dev lo clsact"))
return -1;
@@ -47,12 +47,10 @@ configure_stack(void)
return false;
/* Move to a new networking namespace */
- if (CHECK_FAIL(unshare(CLONE_NEWNET)))
+ if (CHECK_FAIL(unshare_netns()))
return false;
/* Configure necessary links, routes */
- if (CHECK_FAIL(system("ip link set dev lo up")))
- return false;
if (CHECK_FAIL(system("ip route add local default dev lo")))
return false;
if (CHECK_FAIL(system("ip -6 route add local default dev lo")))
@@ -32,12 +32,9 @@ static struct test_tcp_custom_syncookie_case {
static int setup_netns(void)
{
- if (!ASSERT_OK(unshare(CLONE_NEWNET), "create netns"))
+ if (!ASSERT_OK(unshare_netns(), "create netns"))
return -1;
- if (!ASSERT_OK(system("ip link set dev lo up"), "ip"))
- goto err;
-
if (!ASSERT_OK(write_sysctl("/proc/sys/net/ipv4/tcp_ecn", "1"),
"write_sysctl"))
goto err;