From nobody Mon Feb 9 21:19:49 2026 Delivered-To: wpasupplicant.patchew@gmail.com Received: by 2002:a02:cbb9:0:0:0:0:0 with SMTP id v25csp1110653jap; Fri, 3 Dec 2021 14:35:57 -0800 (PST) X-Google-Smtp-Source: ABdhPJwedcUzIkHKNT7YnS/4XbKF2aaHbij143jqBFMtMBtd9S0cf+H845XLo2InXAxuCUyVnUd2 X-Received: by 2002:a17:902:b588:b0:143:b732:834 with SMTP id a8-20020a170902b58800b00143b7320834mr26253141pls.22.1638570956879; Fri, 03 Dec 2021 14:35:56 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1638570956; cv=none; d=google.com; s=arc-20160816; b=0uUJdZnNm5t+zPDya8wJCq4bpN6YibLH42n9GejFN6g/bA/0zbzwvRPJ66dfWC+f8E GNy9j5j4i2ilxptt6TbPfHojlCjtIdWQSw6fv2qKZDDKqA5dimx7TlB9pQsmmN1/TFxt MWXo2ILsgDoWBRGSooF/2HJ0ApP228e5bT621Ip8Wd3bEkD/U4PX5r31errsWB66G2Ah st5z+vTea9lFPkJZKXNJs5l05Su3icJwEWNMZ538/4ekmaRJI0720kAaO70RasD9SCPj X0tuQmnxe1VHXSqTJ3/6t1pW1z7mCQuKZCn311/NsMpgMPM/KONhaWMfau7Ciu0zDsLE Nd5Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from; bh=LGlfZAHbN8q+seL/szCkwRYZzUan4yFJkb99ueAuMYE=; b=wLZHig02k9MU42/LJOdjikNiy+RtAtFQlv8A17zFXcrUrvNxJK12jUyYy3AWDo33HK xbwF26Jz5uiSv6v+gepfep4j1Tq0DbaEHjfdjkpYQI4KDHMypQyh7Z2CrdWCO9Hz+RoY viyVpUC/PKSOcD46msxjlT0sB2XBsWTr8GG+ScJt/d5h6Ujakl6CrpAiJAF/0ZeBIEiA kJzz8yOfNpt/AuY/MO+v0wwmm8SCSlSR9mg6ZpaewX0j5X3xnDGDeOvZ0cZy0oJaVpxw bK0DtvgbhcyRFE6S6OBtzqgvtIYeQvYKl+WddfyYGYCJ/hZ3jGEXWkxrd+o2TT1Ubl9t PWiQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of mptcp+bounces-2629-wpasupplicant.patchew=gmail.com@lists.linux.dev designates 147.75.69.165 as permitted sender) smtp.mailfrom="mptcp+bounces-2629-wpasupplicant.patchew=gmail.com@lists.linux.dev"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from sjc.edge.kernel.org (sjc.edge.kernel.org. [147.75.69.165]) by mx.google.com with ESMTPS id v20si2772256plg.312.2021.12.03.14.35.56 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Fri, 03 Dec 2021 14:35:56 -0800 (PST) Received-SPF: pass (google.com: domain of mptcp+bounces-2629-wpasupplicant.patchew=gmail.com@lists.linux.dev designates 147.75.69.165 as permitted sender) client-ip=147.75.69.165; Authentication-Results: mx.google.com; spf=pass (google.com: domain of mptcp+bounces-2629-wpasupplicant.patchew=gmail.com@lists.linux.dev designates 147.75.69.165 as permitted sender) smtp.mailfrom="mptcp+bounces-2629-wpasupplicant.patchew=gmail.com@lists.linux.dev"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sjc.edge.kernel.org (Postfix) with ESMTPS id 627DE3E0F83 for ; Fri, 3 Dec 2021 22:35:56 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 0FF652CAF; Fri, 3 Dec 2021 22:35:52 +0000 (UTC) X-Original-To: mptcp@lists.linux.dev Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 923242CAC for ; Fri, 3 Dec 2021 22:35:50 +0000 (UTC) X-IronPort-AV: E=McAfee;i="6200,9189,10187"; a="235802943" X-IronPort-AV: E=Sophos;i="5.87,284,1631602800"; d="scan'208";a="235802943" Received: from orsmga003.jf.intel.com ([10.7.209.27]) by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Dec 2021 14:35:47 -0800 X-IronPort-AV: E=Sophos;i="5.87,284,1631602800"; d="scan'208";a="460185308" Received: from mjmartin-desk2.amr.corp.intel.com (HELO mjmartin-desk2.intel.com) ([10.251.18.88]) by orsmga003-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Dec 2021 14:35:47 -0800 From: Mat Martineau To: netdev@vger.kernel.org Cc: Florian Westphal , davem@davemloft.net, kuba@kernel.org, matthieu.baerts@tessares.net, mptcp@lists.linux.dev, Mat Martineau Subject: [PATCH net-next 04/10] selftests: mptcp: add inq test case Date: Fri, 3 Dec 2021 14:35:35 -0800 Message-Id: <20211203223541.69364-5-mathew.j.martineau@linux.intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20211203223541.69364-1-mathew.j.martineau@linux.intel.com> References: <20211203223541.69364-1-mathew.j.martineau@linux.intel.com> Precedence: bulk X-Mailing-List: mptcp@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Florian Westphal client & server use a unix socket connection to communicate outside of the mptcp connection. This allows the consumer to know in advance how many bytes have been (or will be) sent by the peer. This allows stricter checks on the bytecounts reported by TCP_INQ cmsg. Suggested-by: Mat Martineau Signed-off-by: Florian Westphal Signed-off-by: Mat Martineau --- tools/testing/selftests/net/mptcp/.gitignore | 1 + tools/testing/selftests/net/mptcp/Makefile | 2 +- tools/testing/selftests/net/mptcp/mptcp_inq.c | 603 ++++++++++++++++++ .../selftests/net/mptcp/mptcp_sockopt.sh | 40 ++ 4 files changed, 645 insertions(+), 1 deletion(-) create mode 100644 tools/testing/selftests/net/mptcp/mptcp_inq.c diff --git a/tools/testing/selftests/net/mptcp/.gitignore b/tools/testing/s= elftests/net/mptcp/.gitignore index 7569d892967a..49daae73c41e 100644 --- a/tools/testing/selftests/net/mptcp/.gitignore +++ b/tools/testing/selftests/net/mptcp/.gitignore @@ -1,5 +1,6 @@ # SPDX-License-Identifier: GPL-2.0-only mptcp_connect +mptcp_inq mptcp_sockopt pm_nl_ctl *.pcap diff --git a/tools/testing/selftests/net/mptcp/Makefile b/tools/testing/sel= ftests/net/mptcp/Makefile index bbf4e448bad9..0356c4501c99 100644 --- a/tools/testing/selftests/net/mptcp/Makefile +++ b/tools/testing/selftests/net/mptcp/Makefile @@ -8,7 +8,7 @@ CFLAGS =3D -Wall -Wl,--no-as-needed -O2 -g -I$(top_srcdir= )/usr/include TEST_PROGS :=3D mptcp_connect.sh pm_netlink.sh mptcp_join.sh diag.sh \ simult_flows.sh mptcp_sockopt.sh =20 -TEST_GEN_FILES =3D mptcp_connect pm_nl_ctl mptcp_sockopt +TEST_GEN_FILES =3D mptcp_connect pm_nl_ctl mptcp_sockopt mptcp_inq =20 TEST_FILES :=3D settings =20 diff --git a/tools/testing/selftests/net/mptcp/mptcp_inq.c b/tools/testing/= selftests/net/mptcp/mptcp_inq.c new file mode 100644 index 000000000000..b8debd4fb5ed --- /dev/null +++ b/tools/testing/selftests/net/mptcp/mptcp_inq.c @@ -0,0 +1,603 @@ +// SPDX-License-Identifier: GPL-2.0 + +#define _GNU_SOURCE + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include + +#include +#include + +#include +#include + +#ifndef IPPROTO_MPTCP +#define IPPROTO_MPTCP 262 +#endif +#ifndef SOL_MPTCP +#define SOL_MPTCP 284 +#endif + +static int pf =3D AF_INET; +static int proto_tx =3D IPPROTO_MPTCP; +static int proto_rx =3D IPPROTO_MPTCP; + +static void die_perror(const char *msg) +{ + perror(msg); + exit(1); +} + +static void die_usage(int r) +{ + fprintf(stderr, "Usage: mptcp_inq [-6] [ -t tcp|mptcp ] [ -r tcp|mptcp]\n= "); + exit(r); +} + +static void xerror(const char *fmt, ...) +{ + va_list ap; + + va_start(ap, fmt); + vfprintf(stderr, fmt, ap); + va_end(ap); + fputc('\n', stderr); + exit(1); +} + +static const char *getxinfo_strerr(int err) +{ + if (err =3D=3D EAI_SYSTEM) + return strerror(errno); + + return gai_strerror(err); +} + +static void xgetaddrinfo(const char *node, const char *service, + const struct addrinfo *hints, + struct addrinfo **res) +{ + int err =3D getaddrinfo(node, service, hints, res); + + if (err) { + const char *errstr =3D getxinfo_strerr(err); + + fprintf(stderr, "Fatal: getaddrinfo(%s:%s): %s\n", + node ? node : "", service ? service : "", errstr); + exit(1); + } +} + +static int sock_listen_mptcp(const char * const listenaddr, + const char * const port) +{ + int sock; + struct addrinfo hints =3D { + .ai_protocol =3D IPPROTO_TCP, + .ai_socktype =3D SOCK_STREAM, + .ai_flags =3D AI_PASSIVE | AI_NUMERICHOST + }; + + hints.ai_family =3D pf; + + struct addrinfo *a, *addr; + int one =3D 1; + + xgetaddrinfo(listenaddr, port, &hints, &addr); + hints.ai_family =3D pf; + + for (a =3D addr; a; a =3D a->ai_next) { + sock =3D socket(a->ai_family, a->ai_socktype, proto_rx); + if (sock < 0) + continue; + + if (-1 =3D=3D setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, &one, + sizeof(one))) + perror("setsockopt"); + + if (bind(sock, a->ai_addr, a->ai_addrlen) =3D=3D 0) + break; /* success */ + + perror("bind"); + close(sock); + sock =3D -1; + } + + freeaddrinfo(addr); + + if (sock < 0) + xerror("could not create listen socket"); + + if (listen(sock, 20)) + die_perror("listen"); + + return sock; +} + +static int sock_connect_mptcp(const char * const remoteaddr, + const char * const port, int proto) +{ + struct addrinfo hints =3D { + .ai_protocol =3D IPPROTO_TCP, + .ai_socktype =3D SOCK_STREAM, + }; + struct addrinfo *a, *addr; + int sock =3D -1; + + hints.ai_family =3D pf; + + xgetaddrinfo(remoteaddr, port, &hints, &addr); + for (a =3D addr; a; a =3D a->ai_next) { + sock =3D socket(a->ai_family, a->ai_socktype, proto); + if (sock < 0) + continue; + + if (connect(sock, a->ai_addr, a->ai_addrlen) =3D=3D 0) + break; /* success */ + + die_perror("connect"); + } + + if (sock < 0) + xerror("could not create connect socket"); + + freeaddrinfo(addr); + return sock; +} + +static int protostr_to_num(const char *s) +{ + if (strcasecmp(s, "tcp") =3D=3D 0) + return IPPROTO_TCP; + if (strcasecmp(s, "mptcp") =3D=3D 0) + return IPPROTO_MPTCP; + + die_usage(1); + return 0; +} + +static void parse_opts(int argc, char **argv) +{ + int c; + + while ((c =3D getopt(argc, argv, "h6t:r:")) !=3D -1) { + switch (c) { + case 'h': + die_usage(0); + break; + case '6': + pf =3D AF_INET6; + break; + case 't': + proto_tx =3D protostr_to_num(optarg); + break; + case 'r': + proto_rx =3D protostr_to_num(optarg); + break; + default: + die_usage(1); + break; + } + } +} + +/* wait up to timeout milliseconds */ +static void wait_for_ack(int fd, int timeout, size_t total) +{ + int i; + + for (i =3D 0; i < timeout; i++) { + int nsd, ret, queued =3D -1; + struct timespec req; + + ret =3D ioctl(fd, TIOCOUTQ, &queued); + if (ret < 0) + die_perror("TIOCOUTQ"); + + ret =3D ioctl(fd, SIOCOUTQNSD, &nsd); + if (ret < 0) + die_perror("SIOCOUTQNSD"); + + if ((size_t)queued > total) + xerror("TIOCOUTQ %u, but only %zu expected\n", queued, total); + assert(nsd <=3D queued); + + if (queued =3D=3D 0) + return; + + /* wait for peer to ack rx of all data */ + req.tv_sec =3D 0; + req.tv_nsec =3D 1 * 1000 * 1000ul; /* 1ms */ + nanosleep(&req, NULL); + } + + xerror("still tx data queued after %u ms\n", timeout); +} + +static void connect_one_server(int fd, int unixfd) +{ + size_t len, i, total, sent; + char buf[4096], buf2[4096]; + ssize_t ret; + + len =3D rand() % (sizeof(buf) - 1); + + if (len < 128) + len =3D 128; + + for (i =3D 0; i < len ; i++) { + buf[i] =3D rand() % 26; + buf[i] +=3D 'A'; + } + + buf[i] =3D '\n'; + + /* un-block server */ + ret =3D read(unixfd, buf2, 4); + assert(ret =3D=3D 4); + + assert(strncmp(buf2, "xmit", 4) =3D=3D 0); + + ret =3D write(unixfd, &len, sizeof(len)); + assert(ret =3D=3D (ssize_t)sizeof(len)); + + ret =3D write(fd, buf, len); + if (ret < 0) + die_perror("write"); + + if (ret !=3D (ssize_t)len) + xerror("short write"); + + ret =3D read(unixfd, buf2, 4); + assert(strncmp(buf2, "huge", 4) =3D=3D 0); + + total =3D rand() % (16 * 1024 * 1024); + total +=3D (1 * 1024 * 1024); + sent =3D total; + + ret =3D write(unixfd, &total, sizeof(total)); + assert(ret =3D=3D (ssize_t)sizeof(total)); + + wait_for_ack(fd, 5000, len); + + while (total > 0) { + if (total > sizeof(buf)) + len =3D sizeof(buf); + else + len =3D total; + + ret =3D write(fd, buf, len); + if (ret < 0) + die_perror("write"); + total -=3D ret; + + /* we don't have to care about buf content, only + * number of total bytes sent + */ + } + + ret =3D read(unixfd, buf2, 4); + assert(ret =3D=3D 4); + assert(strncmp(buf2, "shut", 4) =3D=3D 0); + + wait_for_ack(fd, 5000, sent); + + ret =3D write(fd, buf, 1); + assert(ret =3D=3D 1); + close(fd); + ret =3D write(unixfd, "closed", 6); + assert(ret =3D=3D 6); + + close(unixfd); +} + +static void get_tcp_inq(struct msghdr *msgh, unsigned int *inqv) +{ + struct cmsghdr *cmsg; + + for (cmsg =3D CMSG_FIRSTHDR(msgh); cmsg ; cmsg =3D CMSG_NXTHDR(msgh, cmsg= )) { + if (cmsg->cmsg_level =3D=3D IPPROTO_TCP && cmsg->cmsg_type =3D=3D TCP_CM= _INQ) { + memcpy(inqv, CMSG_DATA(cmsg), sizeof(*inqv)); + return; + } + } + + xerror("could not find TCP_CM_INQ cmsg type"); +} + +static void process_one_client(int fd, int unixfd) +{ + unsigned int tcp_inq; + size_t expect_len; + char msg_buf[4096]; + char buf[4096]; + char tmp[16]; + struct iovec iov =3D { + .iov_base =3D buf, + .iov_len =3D 1, + }; + struct msghdr msg =3D { + .msg_iov =3D &iov, + .msg_iovlen =3D 1, + .msg_control =3D msg_buf, + .msg_controllen =3D sizeof(msg_buf), + }; + ssize_t ret, tot; + + ret =3D write(unixfd, "xmit", 4); + assert(ret =3D=3D 4); + + ret =3D read(unixfd, &expect_len, sizeof(expect_len)); + assert(ret =3D=3D (ssize_t)sizeof(expect_len)); + + if (expect_len > sizeof(buf)) + xerror("expect len %zu exceeds buffer size", expect_len); + + for (;;) { + struct timespec req; + unsigned int queued; + + ret =3D ioctl(fd, FIONREAD, &queued); + if (ret < 0) + die_perror("FIONREAD"); + if (queued > expect_len) + xerror("FIONREAD returned %u, but only %zu expected\n", + queued, expect_len); + if (queued =3D=3D expect_len) + break; + + req.tv_sec =3D 0; + req.tv_nsec =3D 1000 * 1000ul; + nanosleep(&req, NULL); + } + + /* read one byte, expect cmsg to return expected - 1 */ + ret =3D recvmsg(fd, &msg, 0); + if (ret < 0) + die_perror("recvmsg"); + + if (msg.msg_controllen =3D=3D 0) + xerror("msg_controllen is 0"); + + get_tcp_inq(&msg, &tcp_inq); + + assert((size_t)tcp_inq =3D=3D (expect_len - 1)); + + iov.iov_len =3D sizeof(buf); + ret =3D recvmsg(fd, &msg, 0); + if (ret < 0) + die_perror("recvmsg"); + + /* should have gotten exact remainder of all pending data */ + assert(ret =3D=3D (ssize_t)tcp_inq); + + /* should be 0, all drained */ + get_tcp_inq(&msg, &tcp_inq); + assert(tcp_inq =3D=3D 0); + + /* request a large swath of data. */ + ret =3D write(unixfd, "huge", 4); + assert(ret =3D=3D 4); + + ret =3D read(unixfd, &expect_len, sizeof(expect_len)); + assert(ret =3D=3D (ssize_t)sizeof(expect_len)); + + /* peer should send us a few mb of data */ + if (expect_len <=3D sizeof(buf)) + xerror("expect len %zu too small\n", expect_len); + + tot =3D 0; + do { + iov.iov_len =3D sizeof(buf); + ret =3D recvmsg(fd, &msg, 0); + if (ret < 0) + die_perror("recvmsg"); + + tot +=3D ret; + + get_tcp_inq(&msg, &tcp_inq); + + if (tcp_inq > expect_len - tot) + xerror("inq %d, remaining %d total_len %d\n", + tcp_inq, expect_len - tot, (int)expect_len); + + assert(tcp_inq <=3D expect_len - tot); + } while ((size_t)tot < expect_len); + + ret =3D write(unixfd, "shut", 4); + assert(ret =3D=3D 4); + + /* wait for hangup. Should have received one more byte of data. */ + ret =3D read(unixfd, tmp, sizeof(tmp)); + assert(ret =3D=3D 6); + assert(strncmp(tmp, "closed", 6) =3D=3D 0); + + sleep(1); + + iov.iov_len =3D 1; + ret =3D recvmsg(fd, &msg, 0); + if (ret < 0) + die_perror("recvmsg"); + assert(ret =3D=3D 1); + + get_tcp_inq(&msg, &tcp_inq); + + /* tcp_inq should be 1 due to received fin. */ + assert(tcp_inq =3D=3D 1); + + iov.iov_len =3D 1; + ret =3D recvmsg(fd, &msg, 0); + if (ret < 0) + die_perror("recvmsg"); + + /* expect EOF */ + assert(ret =3D=3D 0); + get_tcp_inq(&msg, &tcp_inq); + assert(tcp_inq =3D=3D 1); + + close(fd); +} + +static int xaccept(int s) +{ + int fd =3D accept(s, NULL, 0); + + if (fd < 0) + die_perror("accept"); + + return fd; +} + +static int server(int unixfd) +{ + int fd =3D -1, r, on =3D 1; + + switch (pf) { + case AF_INET: + fd =3D sock_listen_mptcp("127.0.0.1", "15432"); + break; + case AF_INET6: + fd =3D sock_listen_mptcp("::1", "15432"); + break; + default: + xerror("Unknown pf %d\n", pf); + break; + } + + r =3D write(unixfd, "conn", 4); + assert(r =3D=3D 4); + + alarm(15); + r =3D xaccept(fd); + + if (-1 =3D=3D setsockopt(r, IPPROTO_TCP, TCP_INQ, &on, sizeof(on))) + die_perror("setsockopt"); + + process_one_client(r, unixfd); + + return 0; +} + +static int client(int unixfd) +{ + int fd =3D -1; + + alarm(15); + + switch (pf) { + case AF_INET: + fd =3D sock_connect_mptcp("127.0.0.1", "15432", proto_tx); + break; + case AF_INET6: + fd =3D sock_connect_mptcp("::1", "15432", proto_tx); + break; + default: + xerror("Unknown pf %d\n", pf); + } + + connect_one_server(fd, unixfd); + + return 0; +} + +static void init_rng(void) +{ + int fd =3D open("/dev/urandom", O_RDONLY); + unsigned int foo; + + if (fd > 0) { + int ret =3D read(fd, &foo, sizeof(foo)); + + if (ret < 0) + srand(fd + foo); + close(fd); + } + + srand(foo); +} + +static pid_t xfork(void) +{ + pid_t p =3D fork(); + + if (p < 0) + die_perror("fork"); + else if (p =3D=3D 0) + init_rng(); + + return p; +} + +static int rcheck(int wstatus, const char *what) +{ + if (WIFEXITED(wstatus)) { + if (WEXITSTATUS(wstatus) =3D=3D 0) + return 0; + fprintf(stderr, "%s exited, status=3D%d\n", what, WEXITSTATUS(wstatus)); + return WEXITSTATUS(wstatus); + } else if (WIFSIGNALED(wstatus)) { + xerror("%s killed by signal %d\n", what, WTERMSIG(wstatus)); + } else if (WIFSTOPPED(wstatus)) { + xerror("%s stopped by signal %d\n", what, WSTOPSIG(wstatus)); + } + + return 111; +} + +int main(int argc, char *argv[]) +{ + int e1, e2, wstatus; + pid_t s, c, ret; + int unixfds[2]; + + parse_opts(argc, argv); + + e1 =3D socketpair(AF_UNIX, SOCK_DGRAM, 0, unixfds); + if (e1 < 0) + die_perror("pipe"); + + s =3D xfork(); + if (s =3D=3D 0) + return server(unixfds[1]); + + close(unixfds[1]); + + /* wait until server bound a socket */ + e1 =3D read(unixfds[0], &e1, 4); + assert(e1 =3D=3D 4); + + c =3D xfork(); + if (c =3D=3D 0) + return client(unixfds[0]); + + close(unixfds[0]); + + ret =3D waitpid(s, &wstatus, 0); + if (ret =3D=3D -1) + die_perror("waitpid"); + e1 =3D rcheck(wstatus, "server"); + ret =3D waitpid(c, &wstatus, 0); + if (ret =3D=3D -1) + die_perror("waitpid"); + e2 =3D rcheck(wstatus, "client"); + + return e1 ? e1 : e2; +} diff --git a/tools/testing/selftests/net/mptcp/mptcp_sockopt.sh b/tools/tes= ting/selftests/net/mptcp/mptcp_sockopt.sh index c8c364369599..0879da915014 100755 --- a/tools/testing/selftests/net/mptcp/mptcp_sockopt.sh +++ b/tools/testing/selftests/net/mptcp/mptcp_sockopt.sh @@ -279,6 +279,45 @@ run_tests() fi } =20 +do_tcpinq_test() +{ + ip netns exec "$ns1" ./mptcp_inq "$@" + lret=3D$? + if [ $lret -ne 0 ];then + ret=3D$lret + echo "FAIL: mptcp_inq $@" 1>&2 + return $lret + fi + + echo "PASS: TCP_INQ cmsg/ioctl $@" + return $lret +} + +do_tcpinq_tests() +{ + local lret=3D0 + + ip netns exec "$ns1" iptables -F + ip netns exec "$ns1" ip6tables -F + + for args in "-t tcp" "-r tcp"; do + do_tcpinq_test $args + lret=3D$? + if [ $lret -ne 0 ] ; then + return $lret + fi + do_tcpinq_test -6 $args + lret=3D$? + if [ $lret -ne 0 ] ; then + return $lret + fi + done + + do_tcpinq_test -r tcp -t tcp + + return $? +} + sin=3D$(mktemp) sout=3D$(mktemp) cin=3D$(mktemp) @@ -300,4 +339,5 @@ if [ $ret -eq 0 ];then echo "PASS: SOL_MPTCP getsockopt has expected information" fi =20 +do_tcpinq_tests exit $ret --=20 2.34.1