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; > +} > +