@@ -17,6 +17,8 @@
#include "mptcp_bpf_burst.skel.h"
#define NS_TEST "mptcp_ns"
+#define WITH_DATA true
+#define WITHOUT_DATA false
#ifndef IPPROTO_MPTCP
#define IPPROTO_MPTCP 262
@@ -457,23 +459,44 @@ static int has_bytes_sent(char *addr)
return system(cmd);
}
-static void test_default(void)
+static void send_data_and_verify(char *sched, bool addr1, bool addr2)
{
int server_fd, client_fd;
- struct nstoken *nstoken;
- nstoken = sched_init("subflow", "default");
- if (!ASSERT_OK_PTR(nstoken, "sched_init:default"))
- goto fail;
server_fd = start_mptcp_server(AF_INET, ADDR_1, PORT_1, 0);
+ if (CHECK(server_fd < 0, sched, "start_mptcp_server: %d\n", errno))
+ return;
+
client_fd = connect_to_fd(server_fd, 0);
+ if (CHECK(client_fd < 0, sched, "connect_to_fd: %d\n", errno))
+ goto close_server;
- send_data(server_fd, client_fd, "default");
- ASSERT_OK(has_bytes_sent(ADDR_1), "has_bytes_sent addr_1");
- ASSERT_OK(has_bytes_sent(ADDR_2), "has_bytes_sent addr_2");
+ send_data(server_fd, client_fd, sched);
+
+ if (addr1)
+ CHECK(has_bytes_sent(ADDR_1), sched, "should have bytes_sent on addr1\n");
+ else
+ CHECK(!has_bytes_sent(ADDR_1), sched, "shouldn't have bytes_sent on addr1\n");
+ if (addr2)
+ CHECK(has_bytes_sent(ADDR_2), sched, "should have bytes_sent on addr2\n");
+ else
+ CHECK(!has_bytes_sent(ADDR_2), sched, "shouldn't have bytes_sent on addr2\n");
close(client_fd);
+close_server:
close(server_fd);
+}
+
+static void test_default(void)
+{
+ struct nstoken *nstoken;
+
+ nstoken = sched_init("subflow", "default");
+ if (!ASSERT_OK_PTR(nstoken, "sched_init:default"))
+ goto fail;
+
+ send_data_and_verify("default", WITH_DATA, WITH_DATA);
+
fail:
cleanup_netns(nstoken);
}
@@ -663,8 +686,7 @@ void test_mptcp(void)
{
RUN_MPTCP_TEST(base);
RUN_MPTCP_TEST(mptcpify);
- if (test__start_subtest("default"))
- test_default();
+ RUN_MPTCP_TEST(default);
if (test__start_subtest("first"))
test_first();
if (test__start_subtest("bkup"))