Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
Signed-off-by: Geliang Tang <tanggeliang@kylinos.cn>
  • Loading branch information
Geliang Tang committed Oct 21, 2024
1 parent f5aab59 commit c6eb7c4
Showing 1 changed file with 8 additions and 18 deletions.
26 changes: 8 additions & 18 deletions tools/testing/selftests/bpf/prog_tests/mptcp.c
Original file line number Diff line number Diff line change
Expand Up @@ -675,7 +675,7 @@ static int wait_for_token(int fd)
{
__u32 token;
char *str;
int i, n;
int i;

/* Wait max 2 sec for the connection to be established */
for (i = 0; i < 10; i++) {
Expand All @@ -686,8 +686,7 @@ static int wait_for_token(int fd)
str = get_events_str("type:2");
if (!str)
continue;
n = sscanf(strstr(str, "token"), "token:%u,", &token);
if (n != 1)
if (sscanf(strstr(str, "token"), "token:%u,", &token) != 1)
continue;
return token;
}
Expand All @@ -700,17 +699,14 @@ static int userspace_pm_add_subflow(__u32 token, char *addr, __u8 id)
bool ipv6 = strstr(addr, ":");
__u32 sport, dport;
char *str;
int n;

str = get_events_str("type:2");
if (!str)
return -1;

n = sscanf(strstr(str, "sport"), "sport:%u,", &sport);
if (n != 1)
if (sscanf(strstr(str, "sport"), "sport:%u,", &sport) != 1)
return -1;
n = sscanf(strstr(str, "dport"), "dport:%u,", &dport);
if (n != 1)
if (sscanf(strstr(str, "dport"), "dport:%u,", &dport) != 1)
return -1;
str = ipv6 ? (strstr(addr, ".") ? "::ffff:"ADDR_1 : ADDR6_1) : ADDR_1;
SYS_NOFAIL("ip netns exec %s %s csf lip %s lid %u rip %s rport %u token %u",
Expand Down Expand Up @@ -861,17 +857,14 @@ static int userspace_pm_set_flags(__u32 token, char *addr, char *flags)
bool ipv6 = strstr(addr, ":");
__u32 sport, dport;
char *str;
int n;

str = get_events_str("type:10");
if (!str)
return -1;

n = sscanf(strstr(str, "sport"), "sport:%u,", &sport);
if (n != 1)
if (sscanf(strstr(str, "sport"), "sport:%u,", &sport) != 1)
return -1;
n = sscanf(strstr(str, "dport"), "dport:%u,", &dport);
if (n != 1)
if (sscanf(strstr(str, "dport"), "dport:%u,", &dport) != 1)
return -1;
str = ipv6 ? (strstr(addr, ".") ? "::ffff:"ADDR_1 : ADDR6_1) : ADDR_1;
return SYS_NOFAIL("ip netns exec %s %s set %s port %u rip %s rport %u flags %s token %u",
Expand All @@ -883,17 +876,14 @@ static int userspace_pm_rm_subflow(__u32 token, char *addr, __u8 id)
bool ipv6 = strstr(addr, ":");
__u32 sport, dport;
char *str;
int n;

str = get_events_str("type:10");
if (!str)
return -1;

n = sscanf(strstr(str, "sport"), "sport:%u,", &sport);
if (n != 1)
if (sscanf(strstr(str, "sport"), "sport:%u,", &sport) != 1)
return -1;
n = sscanf(strstr(str, "dport"), "dport:%u,", &dport);
if (n != 1)
if (sscanf(strstr(str, "dport"), "dport:%u,", &dport) != 1)
return -1;
str = ipv6 ? (strstr(addr, ".") ? "::ffff:"ADDR_1 : ADDR6_1) : ADDR_1;
return SYS_NOFAIL("ip netns exec %s %s dsf lip %s lport %u rip %s rport %u token %u",
Expand Down

0 comments on commit c6eb7c4

Please sign in to comment.