@@ -11,6 +11,7 @@
#include "mptcp_sock.skel.h"
#include "mptcpify.skel.h"
#include "mptcp_subflow.skel.h"
+#include "mptcp_bpf_iters.skel.h"
#include "mptcp_bpf_first.skel.h"
#include "mptcp_bpf_bkup.skel.h"
#include "mptcp_bpf_rr.skel.h"
@@ -509,6 +510,73 @@ static void test_subflow(void)
close(cgroup_fd);
}
+static void run_iters_subflow(void)
+{
+ int server_fd, client_fd;
+ char cc[TCP_CA_NAME_MAX];
+ socklen_t len;
+ int err;
+
+ server_fd = start_mptcp_server(AF_INET, ADDR_1, PORT_1, 0);
+ if (!ASSERT_OK_FD(server_fd, "start_mptcp_server"))
+ return;
+
+ client_fd = connect_to_fd(server_fd, 0);
+ if (!ASSERT_OK_FD(client_fd, "connect_to_fd"))
+ goto close_server;
+
+ send_byte(client_fd);
+ wait_for_new_subflows(client_fd);
+
+ len = sizeof(cc);
+ err = getsockopt(client_fd, SOL_TCP, TCP_CONGESTION, cc, &len);
+ if (ASSERT_OK(err, "getsockopt(client_fd, TCP_CONGESTION)"))
+ ASSERT_STREQ(cc, "cubic", "cc");
+
+ close(client_fd);
+close_server:
+ close(server_fd);
+}
+
+static void test_iters_subflow(void)
+{
+ struct mptcp_bpf_iters *skel;
+ struct nstoken *nstoken;
+ int cgroup_fd;
+ int err;
+
+ cgroup_fd = test__join_cgroup("/iters_subflow");
+ if (!ASSERT_OK_FD(cgroup_fd, "join_cgroup: iters_subflow"))
+ return;
+
+ skel = mptcp_bpf_iters__open_and_load();
+ if (!ASSERT_OK_PTR(skel, "skel_open_load: iters_subflow"))
+ goto close_cgroup;
+
+ skel->links.iters_subflow = bpf_program__attach_cgroup(skel->progs.iters_subflow,
+ cgroup_fd);
+ if (!ASSERT_OK_PTR(skel->links.iters_subflow, "attach getsockopt"))
+ goto skel_destroy;
+
+ nstoken = create_netns();
+ if (!ASSERT_OK_PTR(nstoken, "create_netns: iters_subflow"))
+ goto skel_destroy;
+
+ if (endpoint_init("subflow", 4) < 0)
+ goto close_netns;
+
+ run_iters_subflow();
+
+ ASSERT_EQ(skel->bss->ids, 10, "subflow ids");
+
+close_netns:
+ cleanup_netns(nstoken);
+skel_destroy:
+ mptcp_bpf_iters__destroy(skel);
+close_cgroup:
+ close(cgroup_fd);
+}
+
static struct nstoken *sched_init(char *flags, char *sched)
{
struct nstoken *nstoken;
@@ -690,6 +758,8 @@ void test_mptcp(void)
test_mptcpify();
if (test__start_subtest("subflow"))
test_subflow();
+ if (test__start_subtest("iters_subflow"))
+ test_iters_subflow();
if (test__start_subtest("default"))
test_default();
if (test__start_subtest("first"))