From 25875c173c795ccba0a02b4b7668efbf6df46fb9 Mon Sep 17 00:00:00 2001 From: Geliang Tang Date: Wed, 15 May 2024 14:18:38 +0800 Subject: [PATCH] Squash to "selftests/bpf: Add mptcp subflow subtest" Use pm_nl_ctl instead of 'ip mptcp'. Use SYS_NOFAIL in _ss_search() and drop 'ss -M'. Signed-off-by: Geliang Tang --- tools/testing/selftests/bpf/prog_tests/mptcp.c | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/tools/testing/selftests/bpf/prog_tests/mptcp.c b/tools/testing/selftests/bpf/prog_tests/mptcp.c index 8b0671bcce2955..adc76601367958 100644 --- a/tools/testing/selftests/bpf/prog_tests/mptcp.c +++ b/tools/testing/selftests/bpf/prog_tests/mptcp.c @@ -346,7 +346,10 @@ static int endpoint_init(char *flags) SYS(fail, "ip -net %s link set dev veth1 up", NS_TEST); SYS(fail, "ip -net %s addr add %s/24 dev veth2", NS_TEST, ADDR_2); SYS(fail, "ip -net %s link set dev veth2 up", NS_TEST); - SYS(fail, "ip -net %s mptcp endpoint add %s %s", NS_TEST, ADDR_2, flags); + /* It would be better to use "ip -net %s mptcp endpoint add %s %s", + * but the BPF CI is using an old version of IPRoute (5.5.0). + */ + SYS(fail, "ip netns exec %s ./mptcp_pm_nl_ctl add %s flags %s", NS_TEST, ADDR_2, flags); return 0; fail: @@ -355,16 +358,8 @@ static int endpoint_init(char *flags) static int _ss_search(char *src, char *dst, char *port, char *keyword) { - char cmd[128]; - int n; - - n = snprintf(cmd, sizeof(cmd), - "ip netns exec %s ss -Menita src %s dst %s %s %d | grep -q '%s'", - NS_TEST, src, dst, port, PORT_1, keyword); - if (n < 0 || n >= sizeof(cmd)) - return -1; - - return system(cmd); + return SYS_NOFAIL("ip netns exec %s ss -enita src %s dst %s %s %d | grep -q '%s'", + NS_TEST, src, dst, port, PORT_1, keyword); } static int ss_search(char *src, char *keyword)