Received: by 2002:a05:7412:b112:b0:f9:3106:f1c0 with SMTP id az18csp133965rdb; Mon, 18 Dec 2023 01:10:40 -0800 (PST) X-Google-Smtp-Source: AGHT+IHftoE2vkKIWbAnJlk5ynqTGJYeM3VuhfmQTBD5Kcuzqf9Lt9T+5J0PuLR7tce8cr/MX0Ke X-Received: by 2002:a05:6808:bc4:b0:3ba:951:dd45 with SMTP id o4-20020a0568080bc400b003ba0951dd45mr13508751oik.61.1702890640051; Mon, 18 Dec 2023 01:10:40 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702890640; cv=none; d=google.com; s=arc-20160816; b=A7kQ7NU2A5bcuZUil/tbL1oi+NasCjnFzSv7DaRZhQJYDWz7xaQiNrMhOzG6cSiCyk QV6LZRJ53gEm0MhP9tNJx636BmNr+xMK6BSLfW9c1p3rMJbbb4V1dfJhEsueYr6Wnbib 4pgDEmcah5Kuf8d3YJdK+K4uzNXpFAY3R8BByvnHbiL5s5e3fjMbDk0hBUOWw0KRJ9lE CleSoQvEhLGGRUMSZLtBEbPnEuaYO+SL9Tlz4ytUzxro862VQM/4s+dbLqb4v4RUY8gC Fca1xFFo4MwV0Zt0lVC6CdUu5PRXP4W73SO2BR4CqjmFdjhq4qFZ0GxWlRqnMFYd+V/l d/KA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date:dkim-signature; bh=I7CEnotSdqtYO6wFk1Enw7g+LmZWKcHqIYC1OsQUg58=; fh=G9R3k9cEYwB9YaDXokbdT+WuQlJ5FATgGDhomVg9P64=; b=ketQStt11VvDjGhjmlVHvWNY0yV6fxt5NyI0TqwZ86mAuE5pcbNqoxYeIYOsfHl9GL OM/8pBNawUr66i+qkFm/0qvKYTKB22PlwSDzfQRSymXSZHAIW08kNtbLg/Xe14+iZI2+ hUgkcCKsFUzTQ7qGpSPxirVj4WBeFdmymk6iKl7kbljwUnEMxkcTBA3RgljuLoBvWJcA /bqBds+nm8gA/8KRcJLyCK9LS7zl6DNMb9ewdGby1ktV3VfDD87mpDFCaqxi4YtAaOmm 7b95xe9ehEgJ0qGWiT8+kiKQqg6c1hGSBmOcHypf2TMwpD1hg4ENBKFox/NDoALoJSpA AyzA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=hDOIFxWL; spf=pass (google.com: domain of linux-kernel+bounces-3223-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-3223-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id u8-20020a05620a120800b0077faf98e560si6813911qkj.439.2023.12.18.01.10.39 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Dec 2023 01:10:40 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-3223-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=hDOIFxWL; spf=pass (google.com: domain of linux-kernel+bounces-3223-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-3223-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.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 ny.mirrors.kernel.org (Postfix) with ESMTPS id B7AF21C22521 for ; Mon, 18 Dec 2023 09:10:39 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 450FF14ABD; Mon, 18 Dec 2023 09:08:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="hDOIFxWL" X-Original-To: linux-kernel@vger.kernel.org Received: from mail-oo1-f50.google.com (mail-oo1-f50.google.com [209.85.161.50]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E19BF125CC; Mon, 18 Dec 2023 09:08:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-oo1-f50.google.com with SMTP id 006d021491bc7-58d1b767b2bso1953145eaf.2; Mon, 18 Dec 2023 01:08:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1702890498; x=1703495298; darn=vger.kernel.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=I7CEnotSdqtYO6wFk1Enw7g+LmZWKcHqIYC1OsQUg58=; b=hDOIFxWLH4WdimL2Ih3uNyFvxeaBTsCkEIWtvYoDDDZJ/4FUmV9zXZ1SPLhwsCMLEZ Vxhu11ddh9HGqJ313WqXwTFEpZiaRvSB0NUL2Wc3s1D8XcqBoS9OXaT8EWmGb3naXhci VWHRRlmbQ+VplMrTRTLR2JxIHo17Xo/iejANRSM4imhhh9Fx4KM3zhKu0RA1l5rIDog2 Izrd7I5ycqN6GKI3c2vOPbMFV/gfvc5gXfNnwcYRmchw5VZ8ReswSzJjVPB/i9WtDu0B hkSudmE+QvYT4831ywfH16B6M0UXqiyMWynO1Tg7UK91qfWVeC1buLz3DOOtH2rqynQX AHJA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702890498; x=1703495298; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=I7CEnotSdqtYO6wFk1Enw7g+LmZWKcHqIYC1OsQUg58=; b=d9uiMyugneFOWtqdJMFjEc7YVBZQctyKmmagrWaXkne7Rl/VRxtKgiQD5qA7HVZc8s iQqJPW4JbcYITx+jUNchF7S8zZjHUJrjL2nZBMZtP7Z0CJWcNe6+EnSZHDEjj5hRUttj DzL1wDuGYErdFnLcFIeM00I4yGDr/Z8KTeE51plf/0/TXAQx4dPQ65vaiwV7aEtJfsQv AK7BwUSHLGDU7OliVryhG+1x4yHVSlAbQ6K55PP08RC1njHYwsPxygsA3yopka34KyXg 8Hzei2DOkp976prMI/x+/pdRCT9/ASF+qG6qPvnWeKYQUB5LRSLGhKt7f1y55DClngc1 rpxg== X-Gm-Message-State: AOJu0YyQ7J1bFVVnzjUdOHg+AxonkIGZDL9TtTI2pC1p5L9V54vPRi7m 8rZrgTioS1WVFcrchtzg75s= X-Received: by 2002:a05:6358:5912:b0:170:d431:7e3b with SMTP id g18-20020a056358591200b00170d4317e3bmr15469449rwf.8.1702890497581; Mon, 18 Dec 2023 01:08:17 -0800 (PST) Received: from Laptop-X1 ([43.228.180.230]) by smtp.gmail.com with ESMTPSA id f16-20020a056a001ad000b006cedd530420sm17185442pfv.52.2023.12.18.01.08.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Dec 2023 01:08:16 -0800 (PST) Date: Mon, 18 Dec 2023 17:08:11 +0800 From: Hangbin Liu To: Dmitry Safonov Cc: Shuah Khan , David Ahern , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Salam Noureddine , Bob Gilligan , linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, netdev@vger.kernel.org, Dmitry Safonov <0x7f454c46@gmail.com> Subject: Re: [PATCH 06/12] selftests/net: Add TCP-AO + TCP-MD5 + no sign listen socket tests Message-ID: References: <20231215-tcp-ao-selftests-v1-0-f6c08180b985@arista.com> <20231215-tcp-ao-selftests-v1-6-f6c08180b985@arista.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20231215-tcp-ao-selftests-v1-6-f6c08180b985@arista.com> Hi Dmitry, With 6.7.0-rc3 I always got error # selftests: net/tcp_ao: unsigned-md5_ipv6 # 1..72 # # 1577[lib/setup.c:243] rand seed 1702890409 # TAP version 13 # ok 1 AO server (INADDR_ANY): AO client: counter TCPAOGood increased 0 => 2 # ok 2 AO server (INADDR_ANY): AO client: connected # ok 3 AO server (INADDR_ANY): MD5 client ... # ok 52 TCP-MD5 key intersects with existing TCP-AO key: prefailed as expected: Key was rejected by service # ok 53 TCP-MD5 key + TCP-AO required: prefailed as expected: Key was rejected by service # ok 54 TCP-AO required on socket + TCP-MD5 key: prefailed as expected: Key was rejected by service # not ok 55 # error 1578[unsigned-md5.c:33] Failed to add a route to VRF: Key was rejected by service # # Planned tests != run tests (72 != 55) # # Totals: pass:54 fail:0 xfail:0 xpass:0 skip:0 error:1 ok 1 selftests: net/tcp_ao: unsigned-md5_ipv6 Do you have any idea? Thanks Hangbin On Fri, Dec 15, 2023 at 02:36:20AM +0000, Dmitry Safonov wrote: > The test plan was (most of tests have all 3 client types): > 1. TCP-AO listen (INADDR_ANY) > 2. TCP-MD5 listen (INADDR_ANY) > 3. non-signed listen (INADDR_ANY) > 4. TCP-AO + TCP-MD5 listen (prefix) > 5. TCP-AO subprefix add failure [checked in setsockopt-closed.c] > 6. TCP-AO out of prefix connect [checked in connect-deny.c] > 7. TCP-AO + TCP-MD5 on connect() > 8. TCP-AO intersect with TCP-MD5 failure > 9. Established TCP-AO: add TCP-MD5 key > 10. Established TCP-MD5: add TCP-AO key > 11. Established non-signed: add TCP-AO key > > Output produced: > > # ./unsigned-md5_ipv6 > > 1..72 > > # 1592[lib/setup.c:239] rand seed 1697567046 > > TAP version 13 > > ok 1 AO server (INADDR_ANY): AO client: counter TCPAOGood increased 0 => 2 > > ok 2 AO server (INADDR_ANY): AO client: connected > > ok 3 AO server (INADDR_ANY): MD5 client > > ok 4 AO server (INADDR_ANY): MD5 client: counter TCPMD5Unexpected increased 0 => 1 > > ok 5 AO server (INADDR_ANY): no sign client: counter TCPAORequired increased 0 => 1 > > ok 6 AO server (INADDR_ANY): unsigned client > > ok 7 AO server (AO_REQUIRED): AO client: connected > > ok 8 AO server (AO_REQUIRED): AO client: counter TCPAOGood increased 4 => 6 > > ok 9 AO server (AO_REQUIRED): unsigned client > > ok 10 AO server (AO_REQUIRED): unsigned client: counter TCPAORequired increased 1 => 2 > > ok 11 MD5 server (INADDR_ANY): AO client: counter TCPAOKeyNotFound increased 0 => 1 > > ok 12 MD5 server (INADDR_ANY): AO client > > ok 13 MD5 server (INADDR_ANY): MD5 client: connected > > ok 14 MD5 server (INADDR_ANY): MD5 client: no counter checks > > ok 15 MD5 server (INADDR_ANY): no sign client > > ok 16 MD5 server (INADDR_ANY): no sign client: counter TCPMD5NotFound increased 0 => 1 > > ok 17 no sign server: AO client > > ok 18 no sign server: AO client: counter TCPAOKeyNotFound increased 1 => 2 > > ok 19 no sign server: MD5 client > > ok 20 no sign server: MD5 client: counter TCPMD5Unexpected increased 1 => 2 > > ok 21 no sign server: no sign client: connected > > ok 22 no sign server: no sign client: counter CurrEstab increased 0 => 1 > > ok 23 AO+MD5 server: AO client (matching): connected > > ok 24 AO+MD5 server: AO client (matching): counter TCPAOGood increased 8 => 10 > > ok 25 AO+MD5 server: AO client (misconfig, matching MD5) > > ok 26 AO+MD5 server: AO client (misconfig, matching MD5): counter TCPAOKeyNotFound increased 2 => 3 > > ok 27 AO+MD5 server: AO client (misconfig, non-matching): counter TCPAOKeyNotFound increased 3 => 4 > > ok 28 AO+MD5 server: AO client (misconfig, non-matching) > > ok 29 AO+MD5 server: MD5 client (matching): connected > > ok 30 AO+MD5 server: MD5 client (matching): no counter checks > > ok 31 AO+MD5 server: MD5 client (misconfig, matching AO) > > ok 32 AO+MD5 server: MD5 client (misconfig, matching AO): counter TCPMD5Unexpected increased 2 => 3 > > ok 33 AO+MD5 server: MD5 client (misconfig, non-matching) > > ok 34 AO+MD5 server: MD5 client (misconfig, non-matching): counter TCPMD5Unexpected increased 3 => 4 > > ok 35 AO+MD5 server: no sign client (unmatched): connected > > ok 36 AO+MD5 server: no sign client (unmatched): counter CurrEstab increased 0 => 1 > > ok 37 AO+MD5 server: no sign client (misconfig, matching AO) > > ok 38 AO+MD5 server: no sign client (misconfig, matching AO): counter TCPAORequired increased 2 => 3 > > ok 39 AO+MD5 server: no sign client (misconfig, matching MD5) > > ok 40 AO+MD5 server: no sign client (misconfig, matching MD5): counter TCPMD5NotFound increased 1 => 2 > > ok 41 AO+MD5 server: client with both [TCP-MD5] and TCP-AO keys: connect() was prevented > > ok 42 AO+MD5 server: client with both [TCP-MD5] and TCP-AO keys: no counter checks > > ok 43 AO+MD5 server: client with both TCP-MD5 and [TCP-AO] keys: connect() was prevented > > ok 44 AO+MD5 server: client with both TCP-MD5 and [TCP-AO] keys: no counter checks > > ok 45 TCP-AO established: add TCP-MD5 key: postfailed as expected > > ok 46 TCP-AO established: add TCP-MD5 key: counter TCPAOGood increased 12 => 14 > > ok 47 TCP-MD5 established: add TCP-AO key: postfailed as expected > > ok 48 TCP-MD5 established: add TCP-AO key: no counter checks > > ok 49 non-signed established: add TCP-AO key: postfailed as expected > > ok 50 non-signed established: add TCP-AO key: counter CurrEstab increased 0 => 1 > > ok 51 TCP-AO key intersects with existing TCP-MD5 key: prefailed as expected: Key was rejected by service > > ok 52 TCP-MD5 key intersects with existing TCP-AO key: prefailed as expected: Key was rejected by service > > ok 53 TCP-MD5 key + TCP-AO required: prefailed as expected: Key was rejected by service > > ok 54 TCP-AO required on socket + TCP-MD5 key: prefailed as expected: Key was rejected by service > > ok 55 VRF: TCP-AO key (no l3index) + TCP-MD5 key (no l3index): prefailed as expected: Key was rejected by service > > ok 56 VRF: TCP-MD5 key (no l3index) + TCP-AO key (no l3index): prefailed as expected: Key was rejected by service > > ok 57 VRF: TCP-AO key (no l3index) + TCP-MD5 key (l3index=0): prefailed as expected: Key was rejected by service > > ok 58 VRF: TCP-MD5 key (l3index=0) + TCP-AO key (no l3index): prefailed as expected: Key was rejected by service > > ok 59 VRF: TCP-AO key (no l3index) + TCP-MD5 key (l3index=N): prefailed as expected: Key was rejected by service > > ok 60 VRF: TCP-MD5 key (l3index=N) + TCP-AO key (no l3index): prefailed as expected: Key was rejected by service > > ok 61 VRF: TCP-AO key (l3index=0) + TCP-MD5 key (no l3index): prefailed as expected: Key was rejected by service > > ok 62 VRF: TCP-MD5 key (no l3index) + TCP-AO key (l3index=0): prefailed as expected: Key was rejected by service > > ok 63 VRF: TCP-AO key (l3index=0) + TCP-MD5 key (l3index=0): prefailed as expected: Key was rejected by service > > ok 64 VRF: TCP-MD5 key (l3index=0) + TCP-AO key (l3index=0): prefailed as expected: Key was rejected by service > > ok 65 VRF: TCP-AO key (l3index=0) + TCP-MD5 key (l3index=N) > > ok 66 VRF: TCP-MD5 key (l3index=N) + TCP-AO key (l3index=0) > > ok 67 VRF: TCP-AO key (l3index=N) + TCP-MD5 key (no l3index): prefailed as expected: Key was rejected by service > > ok 68 VRF: TCP-MD5 key (no l3index) + TCP-AO key (l3index=N): prefailed as expected: Key was rejected by service > > ok 69 VRF: TCP-AO key (l3index=N) + TCP-MD5 key (l3index=0) > > ok 70 VRF: TCP-MD5 key (l3index=0) + TCP-AO key (l3index=N) > > ok 71 VRF: TCP-AO key (l3index=N) + TCP-MD5 key (l3index=N): prefailed as expected: Key was rejected by service > > ok 72 VRF: TCP-MD5 key (l3index=N) + TCP-AO key (l3index=N): prefailed as expected: Key was rejected by service > > # Totals: pass:72 fail:0 xfail:0 xpass:0 skip:0 error:0 > > Signed-off-by: Dmitry Safonov > --- > tools/testing/selftests/net/tcp_ao/Makefile | 1 + > tools/testing/selftests/net/tcp_ao/unsigned-md5.c | 742 ++++++++++++++++++++++ > 2 files changed, 743 insertions(+) > > diff --git a/tools/testing/selftests/net/tcp_ao/Makefile b/tools/testing/selftests/net/tcp_ao/Makefile > index 1efd98ca12db..ee2f1a17e805 100644 > --- a/tools/testing/selftests/net/tcp_ao/Makefile > +++ b/tools/testing/selftests/net/tcp_ao/Makefile > @@ -3,6 +3,7 @@ TEST_BOTH_AF := connect > TEST_BOTH_AF += connect-deny > TEST_BOTH_AF += icmps-accept icmps-discard > TEST_BOTH_AF += setsockopt-closed > +TEST_BOTH_AF += unsigned-md5 > > TEST_IPV4_PROGS := $(TEST_BOTH_AF:%=%_ipv4) > TEST_IPV6_PROGS := $(TEST_BOTH_AF:%=%_ipv6) > diff --git a/tools/testing/selftests/net/tcp_ao/unsigned-md5.c b/tools/testing/selftests/net/tcp_ao/unsigned-md5.c > new file mode 100644 > index 000000000000..7cffde02d2be > --- /dev/null > +++ b/tools/testing/selftests/net/tcp_ao/unsigned-md5.c > @@ -0,0 +1,742 @@ > +// SPDX-License-Identifier: GPL-2.0 > +/* Author: Dmitry Safonov */ > +#include > +#include "aolib.h" > + > +#define fault(type) (inj == FAULT_ ## type) > +static const char *md5_password = "Some evil genius, enemy to mankind, must have been the first contriver."; > +static const char *ao_password = DEFAULT_TEST_PASSWORD; > + > +static union tcp_addr client2; > +static union tcp_addr client3; > + > +static const int test_vrf_ifindex = 200; > +static const uint8_t test_vrf_tabid = 42; > +static void setup_vrfs(void) > +{ > + int err; > + > + if (!kernel_config_has(KCONFIG_NET_VRF)) > + return; > + > + err = add_vrf("ksft-vrf", test_vrf_tabid, test_vrf_ifindex, -1); > + if (err) > + test_error("Failed to add a VRF: %d", err); > + > + err = link_set_up("ksft-vrf"); > + if (err) > + test_error("Failed to bring up a VRF"); > + > + err = ip_route_add_vrf(veth_name, TEST_FAMILY, > + this_ip_addr, this_ip_dest, test_vrf_tabid); > + if (err) > + test_error("Failed to add a route to VRF"); > +} > + > +static void try_accept(const char *tst_name, unsigned int port, > + union tcp_addr *md5_addr, uint8_t md5_prefix, > + union tcp_addr *ao_addr, uint8_t ao_prefix, > + bool set_ao_required, > + uint8_t sndid, uint8_t rcvid, uint8_t vrf, > + const char *cnt_name, test_cnt cnt_expected, > + int needs_tcp_md5, fault_t inj) > +{ > + struct tcp_ao_counters ao_cnt1, ao_cnt2; > + uint64_t before_cnt = 0, after_cnt = 0; /* silence GCC */ > + int lsk, err, sk = 0; > + time_t timeout; > + > + if (needs_tcp_md5 && should_skip_test(tst_name, KCONFIG_TCP_MD5)) > + return; > + > + lsk = test_listen_socket(this_ip_addr, port, 1); > + > + if (md5_addr && test_set_md5(lsk, *md5_addr, md5_prefix, -1, md5_password)) > + test_error("setsockopt(TCP_MD5SIG_EXT)"); > + > + if (ao_addr && test_add_key(lsk, ao_password, > + *ao_addr, ao_prefix, sndid, rcvid)) > + test_error("setsockopt(TCP_AO_ADD_KEY)"); > + > + if (set_ao_required && test_set_ao_flags(lsk, true, false)) > + test_error("setsockopt(TCP_AO_INFO)"); > + > + if (cnt_name) > + before_cnt = netstat_get_one(cnt_name, NULL); > + if (ao_addr && test_get_tcp_ao_counters(lsk, &ao_cnt1)) > + test_error("test_get_tcp_ao_counters()"); > + > + synchronize_threads(); /* preparations done */ > + > + timeout = fault(TIMEOUT) ? TEST_RETRANSMIT_SEC : TEST_TIMEOUT_SEC; > + err = test_wait_fd(lsk, timeout, 0); > + if (err == -ETIMEDOUT) { > + if (!fault(TIMEOUT)) > + test_fail("timeouted for accept()"); > + } else if (err < 0) { > + test_error("test_wait_fd()"); > + } else { > + if (fault(TIMEOUT)) > + test_fail("ready to accept"); > + > + sk = accept(lsk, NULL, NULL); > + if (sk < 0) { > + test_error("accept()"); > + } else { > + if (fault(TIMEOUT)) > + test_fail("%s: accepted", tst_name); > + } > + } > + > + if (ao_addr && test_get_tcp_ao_counters(lsk, &ao_cnt2)) > + test_error("test_get_tcp_ao_counters()"); > + close(lsk); > + > + if (!cnt_name) { > + test_ok("%s: no counter checks", tst_name); > + goto out; > + } > + > + after_cnt = netstat_get_one(cnt_name, NULL); > + > + if (after_cnt <= before_cnt) { > + test_fail("%s: %s counter did not increase: %zu <= %zu", > + tst_name, cnt_name, after_cnt, before_cnt); > + } else { > + test_ok("%s: counter %s increased %zu => %zu", > + tst_name, cnt_name, before_cnt, after_cnt); > + } > + if (ao_addr) > + test_tcp_ao_counters_cmp(tst_name, &ao_cnt1, &ao_cnt2, cnt_expected); > + > +out: > + synchronize_threads(); /* close() */ > + if (sk > 0) > + close(sk); > +} > + > +static void server_add_routes(void) > +{ > + int family = TEST_FAMILY; > + > + synchronize_threads(); /* client_add_ips() */ > + > + if (ip_route_add(veth_name, family, this_ip_addr, client2)) > + test_error("Failed to add route"); > + if (ip_route_add(veth_name, family, this_ip_addr, client3)) > + test_error("Failed to add route"); > +} > + > +static void server_add_fail_tests(unsigned int *port) > +{ > + union tcp_addr addr_any = {}; > + > + try_accept("TCP-AO established: add TCP-MD5 key", (*port)++, NULL, 0, > + &addr_any, 0, 0, 100, 100, 0, "TCPAOGood", TEST_CNT_GOOD, > + 1, 0); > + try_accept("TCP-MD5 established: add TCP-AO key", (*port)++, &addr_any, > + 0, NULL, 0, 0, 0, 0, 0, NULL, 0, 1, 0); > + try_accept("non-signed established: add TCP-AO key", (*port)++, NULL, 0, > + NULL, 0, 0, 0, 0, 0, "CurrEstab", 0, 0, 0); > +} > + > +static void server_vrf_tests(unsigned int *port) > +{ > + setup_vrfs(); > +} > + > +static void *server_fn(void *arg) > +{ > + unsigned int port = test_server_port; > + union tcp_addr addr_any = {}; > + > + server_add_routes(); > + > + try_accept("AO server (INADDR_ANY): AO client", port++, NULL, 0, > + &addr_any, 0, 0, 100, 100, 0, "TCPAOGood", > + TEST_CNT_GOOD, 0, 0); > + try_accept("AO server (INADDR_ANY): MD5 client", port++, NULL, 0, > + &addr_any, 0, 0, 100, 100, 0, "TCPMD5Unexpected", > + 0, 1, FAULT_TIMEOUT); > + try_accept("AO server (INADDR_ANY): no sign client", port++, NULL, 0, > + &addr_any, 0, 0, 100, 100, 0, "TCPAORequired", > + TEST_CNT_AO_REQUIRED, 0, FAULT_TIMEOUT); > + try_accept("AO server (AO_REQUIRED): AO client", port++, NULL, 0, > + &this_ip_dest, TEST_PREFIX, true, > + 100, 100, 0, "TCPAOGood", TEST_CNT_GOOD, 0, 0); > + try_accept("AO server (AO_REQUIRED): unsigned client", port++, NULL, 0, > + &this_ip_dest, TEST_PREFIX, true, > + 100, 100, 0, "TCPAORequired", > + TEST_CNT_AO_REQUIRED, 0, FAULT_TIMEOUT); > + > + try_accept("MD5 server (INADDR_ANY): AO client", port++, &addr_any, 0, > + NULL, 0, 0, 0, 0, 0, "TCPAOKeyNotFound", > + 0, 1, FAULT_TIMEOUT); > + try_accept("MD5 server (INADDR_ANY): MD5 client", port++, &addr_any, 0, > + NULL, 0, 0, 0, 0, 0, NULL, 0, 1, 0); > + try_accept("MD5 server (INADDR_ANY): no sign client", port++, &addr_any, > + 0, NULL, 0, 0, 0, 0, 0, "TCPMD5NotFound", > + 0, 1, FAULT_TIMEOUT); > + > + try_accept("no sign server: AO client", port++, NULL, 0, > + NULL, 0, 0, 0, 0, 0, "TCPAOKeyNotFound", > + TEST_CNT_AO_KEY_NOT_FOUND, 0, FAULT_TIMEOUT); > + try_accept("no sign server: MD5 client", port++, NULL, 0, > + NULL, 0, 0, 0, 0, 0, "TCPMD5Unexpected", > + 0, 1, FAULT_TIMEOUT); > + try_accept("no sign server: no sign client", port++, NULL, 0, > + NULL, 0, 0, 0, 0, 0, "CurrEstab", 0, 0, 0); > + > + try_accept("AO+MD5 server: AO client (matching)", port++, > + &this_ip_dest, TEST_PREFIX, &client2, TEST_PREFIX, 0, > + 100, 100, 0, "TCPAOGood", TEST_CNT_GOOD, 1, 0); > + try_accept("AO+MD5 server: AO client (misconfig, matching MD5)", port++, > + &this_ip_dest, TEST_PREFIX, &client2, TEST_PREFIX, 0, > + 100, 100, 0, "TCPAOKeyNotFound", TEST_CNT_AO_KEY_NOT_FOUND, > + 1, FAULT_TIMEOUT); > + try_accept("AO+MD5 server: AO client (misconfig, non-matching)", port++, > + &this_ip_dest, TEST_PREFIX, &client2, TEST_PREFIX, 0, > + 100, 100, 0, "TCPAOKeyNotFound", TEST_CNT_AO_KEY_NOT_FOUND, > + 1, FAULT_TIMEOUT); > + try_accept("AO+MD5 server: MD5 client (matching)", port++, > + &this_ip_dest, TEST_PREFIX, &client2, TEST_PREFIX, 0, > + 100, 100, 0, NULL, 0, 1, 0); > + try_accept("AO+MD5 server: MD5 client (misconfig, matching AO)", port++, > + &this_ip_dest, TEST_PREFIX, &client2, TEST_PREFIX, 0, > + 100, 100, 0, "TCPMD5Unexpected", 0, 1, FAULT_TIMEOUT); > + try_accept("AO+MD5 server: MD5 client (misconfig, non-matching)", port++, > + &this_ip_dest, TEST_PREFIX, &client2, TEST_PREFIX, 0, > + 100, 100, 0, "TCPMD5Unexpected", 0, 1, FAULT_TIMEOUT); > + try_accept("AO+MD5 server: no sign client (unmatched)", port++, > + &this_ip_dest, TEST_PREFIX, &client2, TEST_PREFIX, 0, > + 100, 100, 0, "CurrEstab", 0, 1, 0); > + try_accept("AO+MD5 server: no sign client (misconfig, matching AO)", > + port++, &this_ip_dest, TEST_PREFIX, &client2, TEST_PREFIX, 0, > + 100, 100, 0, "TCPAORequired", > + TEST_CNT_AO_REQUIRED, 1, FAULT_TIMEOUT); > + try_accept("AO+MD5 server: no sign client (misconfig, matching MD5)", > + port++, &this_ip_dest, TEST_PREFIX, &client2, TEST_PREFIX, 0, > + 100, 100, 0, "TCPMD5NotFound", 0, 1, FAULT_TIMEOUT); > + > + try_accept("AO+MD5 server: client with both [TCP-MD5] and TCP-AO keys", > + port++, &this_ip_dest, TEST_PREFIX, &client2, TEST_PREFIX, 0, > + 100, 100, 0, NULL, 0, 1, FAULT_TIMEOUT); > + try_accept("AO+MD5 server: client with both TCP-MD5 and [TCP-AO] keys", > + port++, &this_ip_dest, TEST_PREFIX, &client2, TEST_PREFIX, 0, > + 100, 100, 0, NULL, 0, 1, FAULT_TIMEOUT); > + > + server_add_fail_tests(&port); > + > + server_vrf_tests(&port); > + > + /* client exits */ > + synchronize_threads(); > + return NULL; > +} > + > +static int client_bind(int sk, union tcp_addr bind_addr) > +{ > +#ifdef IPV6_TEST > + struct sockaddr_in6 addr = { > + .sin6_family = AF_INET6, > + .sin6_port = 0, > + .sin6_addr = bind_addr.a6, > + }; > +#else > + struct sockaddr_in addr = { > + .sin_family = AF_INET, > + .sin_port = 0, > + .sin_addr = bind_addr.a4, > + }; > +#endif > + return bind(sk, &addr, sizeof(addr)); > +} > + > +static void try_connect(const char *tst_name, unsigned int port, > + union tcp_addr *md5_addr, uint8_t md5_prefix, > + union tcp_addr *ao_addr, uint8_t ao_prefix, > + uint8_t sndid, uint8_t rcvid, uint8_t vrf, > + fault_t inj, int needs_tcp_md5, union tcp_addr *bind_addr) > +{ > + time_t timeout; > + int sk, ret; > + > + if (needs_tcp_md5 && should_skip_test(tst_name, KCONFIG_TCP_MD5)) > + return; > + > + sk = socket(test_family, SOCK_STREAM, IPPROTO_TCP); > + if (sk < 0) > + test_error("socket()"); > + > + if (bind_addr && client_bind(sk, *bind_addr)) > + test_error("bind()"); > + > + if (md5_addr && test_set_md5(sk, *md5_addr, md5_prefix, -1, md5_password)) > + test_error("setsockopt(TCP_MD5SIG_EXT)"); > + > + if (ao_addr && test_add_key(sk, ao_password, *ao_addr, > + ao_prefix, sndid, rcvid)) > + test_error("setsockopt(TCP_AO_ADD_KEY)"); > + > + synchronize_threads(); /* preparations done */ > + > + timeout = fault(TIMEOUT) ? TEST_RETRANSMIT_SEC : TEST_TIMEOUT_SEC; > + ret = _test_connect_socket(sk, this_ip_dest, port, timeout); > + > + if (ret < 0) { > + if (fault(KEYREJECT) && ret == -EKEYREJECTED) > + test_ok("%s: connect() was prevented", tst_name); > + else if (ret == -ETIMEDOUT && fault(TIMEOUT)) > + test_ok("%s", tst_name); > + else if (ret == -ECONNREFUSED && > + (fault(TIMEOUT) || fault(KEYREJECT))) > + test_ok("%s: refused to connect", tst_name); > + else > + test_error("%s: connect() returned %d", tst_name, ret); > + goto out; > + } > + > + if (fault(TIMEOUT) || fault(KEYREJECT)) > + test_fail("%s: connected", tst_name); > + else > + test_ok("%s: connected", tst_name); > + > +out: > + synchronize_threads(); /* close() */ > + /* _test_connect_socket() cleans up on failure */ > + if (ret > 0) > + close(sk); > +} > + > +#define PREINSTALL_MD5_FIRST BIT(0) > +#define PREINSTALL_AO BIT(1) > +#define POSTINSTALL_AO BIT(2) > +#define PREINSTALL_MD5 BIT(3) > +#define POSTINSTALL_MD5 BIT(4) > + > +static int try_add_key_vrf(int sk, union tcp_addr in_addr, uint8_t prefix, > + int vrf, uint8_t sndid, uint8_t rcvid, > + bool set_ao_required) > +{ > + uint8_t keyflags = 0; > + > + if (vrf >= 0) > + keyflags |= TCP_AO_KEYF_IFINDEX; > + else > + vrf = 0; > + if (set_ao_required) { > + int err = test_set_ao_flags(sk, true, 0); > + > + if (err) > + return err; > + } > + return test_add_key_vrf(sk, ao_password, keyflags, in_addr, prefix, > + (uint8_t)vrf, sndid, rcvid); > +} > + > +static bool test_continue(const char *tst_name, int err, > + fault_t inj, bool added_ao) > +{ > + bool expected_to_fail; > + > + expected_to_fail = fault(PREINSTALL_AO) && added_ao; > + expected_to_fail |= fault(PREINSTALL_MD5) && !added_ao; > + > + if (!err) { > + if (!expected_to_fail) > + return true; > + test_fail("%s: setsockopt()s were expected to fail", tst_name); > + return false; > + } > + if (err != -EKEYREJECTED || !expected_to_fail) { > + test_error("%s: setsockopt(%s) = %d", tst_name, > + added_ao ? "TCP_AO_ADD_KEY" : "TCP_MD5SIG_EXT", err); > + return false; > + } > + test_ok("%s: prefailed as expected: %m", tst_name); > + return false; > +} > + > +static int open_add(const char *tst_name, unsigned int port, > + unsigned int strategy, > + union tcp_addr md5_addr, uint8_t md5_prefix, int md5_vrf, > + union tcp_addr ao_addr, uint8_t ao_prefix, > + int ao_vrf, bool set_ao_required, > + uint8_t sndid, uint8_t rcvid, > + fault_t inj) > +{ > + int sk; > + > + sk = socket(test_family, SOCK_STREAM, IPPROTO_TCP); > + if (sk < 0) > + test_error("socket()"); > + > + if (client_bind(sk, this_ip_addr)) > + test_error("bind()"); > + > + if (strategy & PREINSTALL_MD5_FIRST) { > + if (test_set_md5(sk, md5_addr, md5_prefix, md5_vrf, md5_password)) > + test_error("setsockopt(TCP_MD5SIG_EXT)"); > + } > + > + if (strategy & PREINSTALL_AO) { > + int err = try_add_key_vrf(sk, ao_addr, ao_prefix, ao_vrf, > + sndid, rcvid, set_ao_required); > + > + if (!test_continue(tst_name, err, inj, true)) { > + close(sk); > + return -1; > + } > + } > + > + if (strategy & PREINSTALL_MD5) { > + errno = 0; > + test_set_md5(sk, md5_addr, md5_prefix, md5_vrf, md5_password); > + if (!test_continue(tst_name, -errno, inj, false)) { > + close(sk); > + return -1; > + } > + } > + > + return sk; > +} > + > +static void try_to_preadd(const char *tst_name, unsigned int port, > + unsigned int strategy, > + union tcp_addr md5_addr, uint8_t md5_prefix, > + int md5_vrf, > + union tcp_addr ao_addr, uint8_t ao_prefix, > + int ao_vrf, bool set_ao_required, > + uint8_t sndid, uint8_t rcvid, > + int needs_tcp_md5, int needs_vrf, fault_t inj) > +{ > + int sk; > + > + if (needs_tcp_md5 && should_skip_test(tst_name, KCONFIG_TCP_MD5)) > + return; > + if (needs_vrf && should_skip_test(tst_name, KCONFIG_NET_VRF)) > + return; > + > + sk = open_add(tst_name, port, strategy, md5_addr, md5_prefix, md5_vrf, > + ao_addr, ao_prefix, ao_vrf, set_ao_required, > + sndid, rcvid, inj); > + if (sk < 0) > + return; > + > + test_ok("%s", tst_name); > + close(sk); > +} > + > +static void try_to_add(const char *tst_name, unsigned int port, > + unsigned int strategy, > + union tcp_addr md5_addr, uint8_t md5_prefix, > + int md5_vrf, > + union tcp_addr ao_addr, uint8_t ao_prefix, > + int ao_vrf, uint8_t sndid, uint8_t rcvid, > + int needs_tcp_md5, fault_t inj) > +{ > + time_t timeout; > + int sk, ret; > + > + if (needs_tcp_md5 && should_skip_test(tst_name, KCONFIG_TCP_MD5)) > + return; > + > + sk = open_add(tst_name, port, strategy, md5_addr, md5_prefix, md5_vrf, > + ao_addr, ao_prefix, ao_vrf, 0, sndid, rcvid, inj); > + if (sk < 0) > + return; > + > + synchronize_threads(); /* preparations done */ > + > + timeout = fault(TIMEOUT) ? TEST_RETRANSMIT_SEC : TEST_TIMEOUT_SEC; > + ret = _test_connect_socket(sk, this_ip_dest, port, timeout); > + > + if (ret <= 0) { > + test_error("%s: connect() returned %d", tst_name, ret); > + goto out; > + } > + > + if (strategy & POSTINSTALL_MD5) { > + if (test_set_md5(sk, md5_addr, md5_prefix, md5_vrf, md5_password)) { > + if (fault(POSTINSTALL)) { > + test_ok("%s: postfailed as expected", tst_name); > + goto out; > + } else { > + test_error("setsockopt(TCP_MD5SIG_EXT)"); > + } > + } else if (fault(POSTINSTALL)) { > + test_fail("%s: post setsockopt() was expected to fail", tst_name); > + goto out; > + } > + } > + > + if (strategy & POSTINSTALL_AO) { > + if (try_add_key_vrf(sk, ao_addr, ao_prefix, ao_vrf, > + sndid, rcvid, 0)) { > + if (fault(POSTINSTALL)) { > + test_ok("%s: postfailed as expected", tst_name); > + goto out; > + } else { > + test_error("setsockopt(TCP_AO_ADD_KEY)"); > + } > + } else if (fault(POSTINSTALL)) { > + test_fail("%s: post setsockopt() was expected to fail", tst_name); > + goto out; > + } > + } > + > +out: > + synchronize_threads(); /* close() */ > + /* _test_connect_socket() cleans up on failure */ > + if (ret > 0) > + close(sk); > +} > + > +static void client_add_ip(union tcp_addr *client, const char *ip) > +{ > + int family = TEST_FAMILY; > + > + if (inet_pton(family, ip, client) != 1) > + test_error("Can't convert ip address %s", ip); > + > + if (ip_addr_add(veth_name, family, *client, TEST_PREFIX)) > + test_error("Failed to add ip address"); > + if (ip_route_add(veth_name, family, *client, this_ip_dest)) > + test_error("Failed to add route"); > +} > + > +static void client_add_ips(void) > +{ > + client_add_ip(&client2, __TEST_CLIENT_IP(2)); > + client_add_ip(&client3, __TEST_CLIENT_IP(3)); > + synchronize_threads(); /* server_add_routes() */ > +} > + > +static void client_add_fail_tests(unsigned int *port) > +{ > + try_to_add("TCP-AO established: add TCP-MD5 key", > + (*port)++, POSTINSTALL_MD5 | PREINSTALL_AO, > + this_ip_dest, TEST_PREFIX, -1, this_ip_dest, TEST_PREFIX, 0, > + 100, 100, 1, FAULT_POSTINSTALL); > + try_to_add("TCP-MD5 established: add TCP-AO key", > + (*port)++, PREINSTALL_MD5 | POSTINSTALL_AO, > + this_ip_dest, TEST_PREFIX, -1, this_ip_dest, TEST_PREFIX, 0, > + 100, 100, 1, FAULT_POSTINSTALL); > + try_to_add("non-signed established: add TCP-AO key", > + (*port)++, POSTINSTALL_AO, > + this_ip_dest, TEST_PREFIX, -1, this_ip_dest, TEST_PREFIX, 0, > + 100, 100, 0, FAULT_POSTINSTALL); > + > + try_to_add("TCP-AO key intersects with existing TCP-MD5 key", > + (*port)++, PREINSTALL_MD5_FIRST | PREINSTALL_AO, > + this_ip_addr, TEST_PREFIX, -1, this_ip_addr, TEST_PREFIX, -1, > + 100, 100, 1, FAULT_PREINSTALL_AO); > + try_to_add("TCP-MD5 key intersects with existing TCP-AO key", > + (*port)++, PREINSTALL_MD5 | PREINSTALL_AO, > + this_ip_addr, TEST_PREFIX, -1, this_ip_addr, TEST_PREFIX, -1, > + 100, 100, 1, FAULT_PREINSTALL_MD5); > + > + try_to_preadd("TCP-MD5 key + TCP-AO required", > + (*port)++, PREINSTALL_MD5_FIRST | PREINSTALL_AO, > + this_ip_addr, TEST_PREFIX, -1, > + this_ip_addr, TEST_PREFIX, -1, true, > + 100, 100, 1, 0, FAULT_PREINSTALL_AO); > + try_to_preadd("TCP-AO required on socket + TCP-MD5 key", > + (*port)++, PREINSTALL_MD5 | PREINSTALL_AO, > + this_ip_addr, TEST_PREFIX, -1, > + this_ip_addr, TEST_PREFIX, -1, true, > + 100, 100, 1, 0, FAULT_PREINSTALL_MD5); > +} > + > +static void client_vrf_tests(unsigned int *port) > +{ > + setup_vrfs(); > + > + /* The following restrictions for setsockopt()s are expected: > + * > + * |--------------|-----------------|-------------|-------------| > + * | | MD5 key without | MD5 key | MD5 key | > + * | | l3index | l3index=0 | l3index=N | > + * |--------------|-----------------|-------------|-------------| > + * | TCP-AO key | | | | > + * | without | reject | reject | reject | > + * | l3index | | | | > + * |--------------|-----------------|-------------|-------------| > + * | TCP-AO key | | | | > + * | l3index=0 | reject | reject | allow | > + * |--------------|-----------------|-------------|-------------| > + * | TCP-AO key | | | | > + * | l3index=N | reject | allow | reject | > + * |--------------|-----------------|-------------|-------------| > + */ > + try_to_preadd("VRF: TCP-AO key (no l3index) + TCP-MD5 key (no l3index)", > + (*port)++, PREINSTALL_MD5 | PREINSTALL_AO, > + this_ip_addr, TEST_PREFIX, -1, > + this_ip_addr, TEST_PREFIX, -1, 0, 100, 100, > + 1, 1, FAULT_PREINSTALL_MD5); > + try_to_preadd("VRF: TCP-MD5 key (no l3index) + TCP-AO key (no l3index)", > + (*port)++, PREINSTALL_MD5_FIRST | PREINSTALL_AO, > + this_ip_addr, TEST_PREFIX, -1, > + this_ip_addr, TEST_PREFIX, -1, 0, 100, 100, > + 1, 1, FAULT_PREINSTALL_AO); > + try_to_preadd("VRF: TCP-AO key (no l3index) + TCP-MD5 key (l3index=0)", > + (*port)++, PREINSTALL_MD5 | PREINSTALL_AO, > + this_ip_addr, TEST_PREFIX, 0, > + this_ip_addr, TEST_PREFIX, -1, 0, 100, 100, > + 1, 1, FAULT_PREINSTALL_MD5); > + try_to_preadd("VRF: TCP-MD5 key (l3index=0) + TCP-AO key (no l3index)", > + (*port)++, PREINSTALL_MD5_FIRST | PREINSTALL_AO, > + this_ip_addr, TEST_PREFIX, 0, > + this_ip_addr, TEST_PREFIX, -1, 0, 100, 100, > + 1, 1, FAULT_PREINSTALL_AO); > + try_to_preadd("VRF: TCP-AO key (no l3index) + TCP-MD5 key (l3index=N)", > + (*port)++, PREINSTALL_MD5 | PREINSTALL_AO, > + this_ip_addr, TEST_PREFIX, test_vrf_ifindex, > + this_ip_addr, TEST_PREFIX, -1, 0, 100, 100, > + 1, 1, FAULT_PREINSTALL_MD5); > + try_to_preadd("VRF: TCP-MD5 key (l3index=N) + TCP-AO key (no l3index)", > + (*port)++, PREINSTALL_MD5_FIRST | PREINSTALL_AO, > + this_ip_addr, TEST_PREFIX, test_vrf_ifindex, > + this_ip_addr, TEST_PREFIX, -1, 0, 100, 100, > + 1, 1, FAULT_PREINSTALL_AO); > + > + try_to_preadd("VRF: TCP-AO key (l3index=0) + TCP-MD5 key (no l3index)", > + (*port)++, PREINSTALL_MD5 | PREINSTALL_AO, > + this_ip_addr, TEST_PREFIX, -1, > + this_ip_addr, TEST_PREFIX, 0, 0, 100, 100, > + 1, 1, FAULT_PREINSTALL_MD5); > + try_to_preadd("VRF: TCP-MD5 key (no l3index) + TCP-AO key (l3index=0)", > + (*port)++, PREINSTALL_MD5_FIRST | PREINSTALL_AO, > + this_ip_addr, TEST_PREFIX, -1, > + this_ip_addr, TEST_PREFIX, 0, 0, 100, 100, > + 1, 1, FAULT_PREINSTALL_AO); > + try_to_preadd("VRF: TCP-AO key (l3index=0) + TCP-MD5 key (l3index=0)", > + (*port)++, PREINSTALL_MD5 | PREINSTALL_AO, > + this_ip_addr, TEST_PREFIX, 0, > + this_ip_addr, TEST_PREFIX, 0, 0, 100, 100, > + 1, 1, FAULT_PREINSTALL_MD5); > + try_to_preadd("VRF: TCP-MD5 key (l3index=0) + TCP-AO key (l3index=0)", > + (*port)++, PREINSTALL_MD5_FIRST | PREINSTALL_AO, > + this_ip_addr, TEST_PREFIX, 0, > + this_ip_addr, TEST_PREFIX, 0, 0, 100, 100, > + 1, 1, FAULT_PREINSTALL_AO); > + try_to_preadd("VRF: TCP-AO key (l3index=0) + TCP-MD5 key (l3index=N)", > + (*port)++, PREINSTALL_MD5 | PREINSTALL_AO, > + this_ip_addr, TEST_PREFIX, test_vrf_ifindex, > + this_ip_addr, TEST_PREFIX, 0, 0, 100, 100, > + 1, 1, 0); > + try_to_preadd("VRF: TCP-MD5 key (l3index=N) + TCP-AO key (l3index=0)", > + (*port)++, PREINSTALL_MD5_FIRST | PREINSTALL_AO, > + this_ip_addr, TEST_PREFIX, test_vrf_ifindex, > + this_ip_addr, TEST_PREFIX, 0, 0, 100, 100, > + 1, 1, 0); > + > + try_to_preadd("VRF: TCP-AO key (l3index=N) + TCP-MD5 key (no l3index)", > + (*port)++, PREINSTALL_MD5 | PREINSTALL_AO, > + this_ip_addr, TEST_PREFIX, test_vrf_ifindex, > + this_ip_addr, TEST_PREFIX, -1, 0, 100, 100, > + 1, 1, FAULT_PREINSTALL_MD5); > + try_to_preadd("VRF: TCP-MD5 key (no l3index) + TCP-AO key (l3index=N)", > + (*port)++, PREINSTALL_MD5_FIRST | PREINSTALL_AO, > + this_ip_addr, TEST_PREFIX, -1, > + this_ip_addr, TEST_PREFIX, test_vrf_ifindex, 0, 100, 100, > + 1, 1, FAULT_PREINSTALL_AO); > + try_to_preadd("VRF: TCP-AO key (l3index=N) + TCP-MD5 key (l3index=0)", > + (*port)++, PREINSTALL_MD5 | PREINSTALL_AO, > + this_ip_addr, TEST_PREFIX, 0, > + this_ip_addr, TEST_PREFIX, test_vrf_ifindex, 0, 100, 100, > + 1, 1, 0); > + try_to_preadd("VRF: TCP-MD5 key (l3index=0) + TCP-AO key (l3index=N)", > + (*port)++, PREINSTALL_MD5_FIRST | PREINSTALL_AO, > + this_ip_addr, TEST_PREFIX, 0, > + this_ip_addr, TEST_PREFIX, test_vrf_ifindex, 0, 100, 100, > + 1, 1, 0); > + try_to_preadd("VRF: TCP-AO key (l3index=N) + TCP-MD5 key (l3index=N)", > + (*port)++, PREINSTALL_MD5 | PREINSTALL_AO, > + this_ip_addr, TEST_PREFIX, test_vrf_ifindex, > + this_ip_addr, TEST_PREFIX, test_vrf_ifindex, 0, 100, 100, > + 1, 1, FAULT_PREINSTALL_MD5); > + try_to_preadd("VRF: TCP-MD5 key (l3index=N) + TCP-AO key (l3index=N)", > + (*port)++, PREINSTALL_MD5_FIRST | PREINSTALL_AO, > + this_ip_addr, TEST_PREFIX, test_vrf_ifindex, > + this_ip_addr, TEST_PREFIX, test_vrf_ifindex, 0, 100, 100, > + 1, 1, FAULT_PREINSTALL_AO); > +} > + > +static void *client_fn(void *arg) > +{ > + unsigned int port = test_server_port; > + union tcp_addr addr_any = {}; > + > + client_add_ips(); > + > + try_connect("AO server (INADDR_ANY): AO client", port++, NULL, 0, > + &addr_any, 0, 100, 100, 0, 0, 0, &this_ip_addr); > + try_connect("AO server (INADDR_ANY): MD5 client", port++, &addr_any, 0, > + NULL, 0, 100, 100, 0, FAULT_TIMEOUT, 1, &this_ip_addr); > + try_connect("AO server (INADDR_ANY): unsigned client", port++, NULL, 0, > + NULL, 0, 100, 100, 0, FAULT_TIMEOUT, 0, &this_ip_addr); > + try_connect("AO server (AO_REQUIRED): AO client", port++, NULL, 0, > + &addr_any, 0, 100, 100, 0, 0, 0, &this_ip_addr); > + try_connect("AO server (AO_REQUIRED): unsigned client", port++, NULL, 0, > + NULL, 0, 100, 100, 0, FAULT_TIMEOUT, 0, &client2); > + > + try_connect("MD5 server (INADDR_ANY): AO client", port++, NULL, 0, > + &addr_any, 0, 100, 100, 0, FAULT_TIMEOUT, 1, &this_ip_addr); > + try_connect("MD5 server (INADDR_ANY): MD5 client", port++, &addr_any, 0, > + NULL, 0, 100, 100, 0, 0, 1, &this_ip_addr); > + try_connect("MD5 server (INADDR_ANY): no sign client", port++, NULL, 0, > + NULL, 0, 100, 100, 0, FAULT_TIMEOUT, 1, &this_ip_addr); > + > + try_connect("no sign server: AO client", port++, NULL, 0, > + &addr_any, 0, 100, 100, 0, FAULT_TIMEOUT, 0, &this_ip_addr); > + try_connect("no sign server: MD5 client", port++, &addr_any, 0, > + NULL, 0, 100, 100, 0, FAULT_TIMEOUT, 1, &this_ip_addr); > + try_connect("no sign server: no sign client", port++, NULL, 0, > + NULL, 0, 100, 100, 0, 0, 0, &this_ip_addr); > + > + try_connect("AO+MD5 server: AO client (matching)", port++, NULL, 0, > + &addr_any, 0, 100, 100, 0, 0, 1, &client2); > + try_connect("AO+MD5 server: AO client (misconfig, matching MD5)", > + port++, NULL, 0, &addr_any, 0, 100, 100, 0, > + FAULT_TIMEOUT, 1, &this_ip_addr); > + try_connect("AO+MD5 server: AO client (misconfig, non-matching)", > + port++, NULL, 0, &addr_any, 0, 100, 100, 0, > + FAULT_TIMEOUT, 1, &client3); > + try_connect("AO+MD5 server: MD5 client (matching)", port++, &addr_any, 0, > + NULL, 0, 100, 100, 0, 0, 1, &this_ip_addr); > + try_connect("AO+MD5 server: MD5 client (misconfig, matching AO)", > + port++, &addr_any, 0, NULL, 0, 100, 100, 0, FAULT_TIMEOUT, > + 1, &client2); > + try_connect("AO+MD5 server: MD5 client (misconfig, non-matching)", > + port++, &addr_any, 0, NULL, 0, 100, 100, 0, FAULT_TIMEOUT, > + 1, &client3); > + try_connect("AO+MD5 server: no sign client (unmatched)", > + port++, NULL, 0, NULL, 0, 100, 100, 0, 0, 1, &client3); > + try_connect("AO+MD5 server: no sign client (misconfig, matching AO)", > + port++, NULL, 0, NULL, 0, 100, 100, 0, FAULT_TIMEOUT, > + 1, &client2); > + try_connect("AO+MD5 server: no sign client (misconfig, matching MD5)", > + port++, NULL, 0, NULL, 0, 100, 100, 0, FAULT_TIMEOUT, > + 1, &this_ip_addr); > + > + try_connect("AO+MD5 server: client with both [TCP-MD5] and TCP-AO keys", > + port++, &this_ip_addr, TEST_PREFIX, > + &client2, TEST_PREFIX, 100, 100, 0, FAULT_KEYREJECT, > + 1, &this_ip_addr); > + try_connect("AO+MD5 server: client with both TCP-MD5 and [TCP-AO] keys", > + port++, &this_ip_addr, TEST_PREFIX, > + &client2, TEST_PREFIX, 100, 100, 0, FAULT_KEYREJECT, > + 1, &client2); > + > + client_add_fail_tests(&port); > + client_vrf_tests(&port); > + > + return NULL; > +} > + > +int main(int argc, char *argv[]) > +{ > + test_init(72, server_fn, client_fn); > + return 0; > +} > > -- > 2.43.0 >