From nobody Sun Feb 8 07:22:19 2026 Delivered-To: wpasupplicant.patchew@gmail.com Received: by 2002:a05:6a06:869:b0:4b8:7781:bd2f with SMTP id d41csp4040501pis; Mon, 2 May 2022 09:36:52 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwDNQY4vhXn8x4aKshJeRv4nwY+MVywG3LoLL0g/dV9WJTZymOOVragKeGH3G5lxTBgybfo X-Received: by 2002:a05:6a00:1903:b0:4fa:fa9e:42e6 with SMTP id y3-20020a056a00190300b004fafa9e42e6mr12001231pfi.1.1651509411950; Mon, 02 May 2022 09:36:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1651509411; cv=none; d=google.com; s=arc-20160816; b=PTPT/TVTH95Rt1Jp6HnV1xqQa693RbU642rPqJBsJP30LQVkFpVIo9Zi63hpMA4lOm oQpqSBBBeMydqEU2bsrihdUMIH8kYeFOb/Dj0akA91LMiYadEaVgun/6AbW+sfsb2xza asjFPQosztAwwRY+Wpc2EllmUGZP1BwCwxqKnypLp2WG6uYtiaUpU61X/R31IoTGDwuI k3DaBek0b6ogq/bmF2MyfvmBFejMZBI4kqJURzzjs63I76Zlx9mabpJaJqx0cMALkVnz uIECLIEcxhWdhmnbtUgUywNKoeGl14lm84gLUwe7euu6d5+/RVLYgXGK54P8rmkhECsq Yauw== 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:message-id:date:subject:cc:to :from; bh=3hQR9GaPzDedjfJa0EqyX6d1NrzuleD8IuouJ82lWWM=; b=uw4dg+gXMu5fuB9yR+2jaBx8YJXr96UA5rXIEd8cAJpMh7qY4e8uOxWAc9SKx3XZXl uYJPUsp2SsQy0P6jyKdsfqf7CDo3cZ/hkKDpw0gDZXgsO1NWXLcX5y2T53ntIy3fl5+p mj51xlj3TLwMzTgj64vuOBouyYwWFZ30y2jtuPTtZ0qGG5sXQ6paLEd7vAEneI8c9dEP lKX8QRlPKSEoh4uipTApeq30URwAHbQcPGa0bamdrwMVSN3cW2oc7AxdkSZ9jOceblCM uRQLsIL7uyvwRq3VsGK+Rnp0qYm43lfSnG61knLR+DVAIjc8hDRATd2ccbZAbEEdH+LL VItw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of mptcp+bounces-5016-wpasupplicant.patchew=gmail.com@lists.linux.dev designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="mptcp+bounces-5016-wpasupplicant.patchew=gmail.com@lists.linux.dev" Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id z17-20020a170902d55100b0015eb08a719asi1056002plf.127.2022.05.02.09.36.51 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 02 May 2022 09:36:51 -0700 (PDT) Received-SPF: pass (google.com: domain of mptcp+bounces-5016-wpasupplicant.patchew=gmail.com@lists.linux.dev designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; spf=pass (google.com: domain of mptcp+bounces-5016-wpasupplicant.patchew=gmail.com@lists.linux.dev designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="mptcp+bounces-5016-wpasupplicant.patchew=gmail.com@lists.linux.dev" 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 sv.mirrors.kernel.org (Postfix) with ESMTPS id E2DF6280A81 for ; Mon, 2 May 2022 16:36:50 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id C3B772CA6; Mon, 2 May 2022 16:36:49 +0000 (UTC) X-Original-To: mptcp@lists.linux.dev Received: from Chamillionaire.breakpoint.cc (Chamillionaire.breakpoint.cc [193.142.43.52]) (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 D25E915D0 for ; Mon, 2 May 2022 16:36:47 +0000 (UTC) Received: from fw by Chamillionaire.breakpoint.cc with local (Exim 4.92) (envelope-from ) id 1nlZ2T-0000lY-SW; Mon, 02 May 2022 18:36:45 +0200 From: Florian Westphal To: mptcp@lists.linux.dev Cc: Florian Westphal Subject: [PATCH mptcp-next] selftests: mptcp: add TCP_DEFER test case Date: Mon, 2 May 2022 18:36:41 +0200 Message-Id: <20220502163641.6146-1-fw@strlen.de> X-Mailer: git-send-email 2.35.1 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" Check that value x can be set and retrieved. Signed-off-by: Florian Westphal --- .../selftests/net/mptcp/mptcp_sockopt.c | 41 ++++++++++++++++++- 1 file changed, 39 insertions(+), 2 deletions(-) diff --git a/tools/testing/selftests/net/mptcp/mptcp_sockopt.c b/tools/test= ing/selftests/net/mptcp/mptcp_sockopt.c index ac9a4d9c1764..12aa2d921fd5 100644 --- a/tools/testing/selftests/net/mptcp/mptcp_sockopt.c +++ b/tools/testing/selftests/net/mptcp/mptcp_sockopt.c @@ -133,10 +133,43 @@ static void xgetaddrinfo(const char *node, const char= *service, } } =20 +static void check_tcp_defer(int sock, unsigned int value) +{ + unsigned int rv; + socklen_t rvl; + int err; + + rvl =3D sizeof(rv); + err =3D getsockopt(sock, IPPROTO_TCP, TCP_DEFER_ACCEPT, &rv, &rvl); + if (err) { + perror("getsockopt TCP_DEFER_ACCEPT"); + exit(1); + } + + assert(rvl =3D=3D (int)sizeof(rv)); + assert(rv =3D=3D value); +} + +static unsigned int set_tcp_defer(int sock) +{ + unsigned int v =3D rand(); + int err; + + v &=3D 0x1f; + + err =3D setsockopt(sock, IPPROTO_TCP, TCP_DEFER_ACCEPT, &v, sizeof(v)); + if (err) { + perror("setsockopt TCP_DEFER_ACCEPT"); + exit(1); + } + + return v; +} + static int sock_listen_mptcp(const char * const listenaddr, const char * const port) { - int sock; + int sock, value; struct addrinfo hints =3D { .ai_protocol =3D IPPROTO_TCP, .ai_socktype =3D SOCK_STREAM, @@ -173,9 +206,13 @@ static int sock_listen_mptcp(const char * const listen= addr, if (sock < 0) xerror("could not create listen socket"); =20 + value =3D set_tcp_defer(sock); + if (listen(sock, 20)) die_perror("listen"); =20 + check_tcp_defer(sock, value); + return sock; } =20 @@ -630,7 +667,7 @@ static void test_ip_tos_sockopt(int fd) r =3D getsockopt(fd, SOL_IP, IP_TOS, &tos_out, &s); if (r !=3D -1 && errno !=3D EINVAL) die_perror("getsockopt IP_TOS did not indicate -EINVAL"); - if (s !=3D -1) + if ((int)s !=3D -1) xerror("expect socklen_t =3D=3D -1"); } =20 --=20 2.35.1