[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CA+WQbwuenfY9Pxet6g0Tvo++JOAmU98+QymuWVsi-2iRpPq3oQ@mail.gmail.com>
Date: Tue, 17 May 2022 13:19:38 +0800
From: Geliang Tang <geliangtang@...il.com>
To: Martin KaFai Lau <kafai@...com>
Cc: Mat Martineau <mathew.j.martineau@...ux.intel.com>,
Geliang Tang <geliang.tang@...e.com>,
Networking <netdev@...r.kernel.org>, bpf <bpf@...r.kernel.org>,
Alexei Starovoitov <ast@...nel.org>,
Daniel Borkmann <daniel@...earbox.net>,
Andrii Nakryiko <andrii@...nel.org>,
MPTCP Upstream <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
Martin KaFai Lau <kafai@...com> 于2022年5月17日周二 09:32写道:
>
> 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 ?
Hi Martin,
Yes, it will break in that case. How can I fix this? Should I run the
test in a special net namespace?
'ip mptcp monitor' can easily run in a special net namespace:
ip -net ns1 mptcp monitor
But I don't know how to run start_server() and connect_to_fd() in a
special namespace. Could you please give me some suggestions about
this?
Thanks,
-Geliang
>
> > + */
> > +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