[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20220517013217.oxbpwjilwr4fzvuv@kafai-mbp.dhcp.thefacebook.com>
Date: Mon, 16 May 2022 18:32:17 -0700
From: Martin KaFai Lau <kafai@...com>
To: Mat Martineau <mathew.j.martineau@...ux.intel.com>,
Geliang Tang <geliang.tang@...e.com>
Cc: netdev@...r.kernel.org, bpf@...r.kernel.org, ast@...nel.org,
daniel@...earbox.net, andrii@...nel.org, mptcp@...ts.linux.dev,
Matthieu Baerts <matthieu.baerts@...sares.net>
Subject: Re: [PATCH bpf-next v4 5/7] selftests/bpf: verify token of struct
mptcp_sock
On Fri, May 13, 2022 at 03:48:25PM -0700, Mat Martineau wrote:
[ ... ]
> +/*
> + * Parse the token from the output of 'ip mptcp monitor':
> + *
> + * [ CREATED] token=3ca933d3 remid=0 locid=0 saddr4=127.0.0.1 ...
> + * [ CREATED] token=2ab57040 remid=0 locid=0 saddr4=127.0.0.1 ...
How stable is the string format ?
If it happens to have some unrelated mptcp connection going on, will the test
break ?
> + */
> +static __u32 get_msk_token(void)
> +{
> + char *prefix = "[ CREATED] token=";
> + char buf[BUFSIZ] = {};
> + __u32 token = 0;
> + ssize_t len;
> + int fd;
> +
> + sync();
> +
> + fd = open(monitor_log_path, O_RDONLY);
> + if (!ASSERT_GE(fd, 0, "Failed to open monitor_log_path"))
> + return token;
> +
> + len = read(fd, buf, sizeof(buf));
> + if (!ASSERT_GT(len, 0, "Failed to read monitor_log_path"))
> + goto err;
> +
> + if (strncmp(buf, prefix, strlen(prefix))) {
> + log_err("Invalid prefix %s", buf);
> + goto err;
> + }
> +
> + token = strtol(buf + strlen(prefix), NULL, 16);
> +
> +err:
> + close(fd);
> + return token;
> +}
> +
Powered by blists - more mailing lists