lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20231222-selftests-tcp-ao-fixups-v1-1-39c73817c372@arista.com>
Date: Fri, 22 Dec 2023 01:59:06 +0000
From: Dmitry Safonov <dima@...sta.com>
To: "David S. Miller" <davem@...emloft.net>,
	Eric Dumazet <edumazet@...gle.com>,
	Jakub Kicinski <kuba@...nel.org>,
	Paolo Abeni <pabeni@...hat.com>,
	Shuah Khan <shuah@...nel.org>
Cc: Dmitry Safonov <dima@...sta.com>,
	netdev@...r.kernel.org,
	linux-kselftest@...r.kernel.org,
	linux-kernel@...r.kernel.org,
	Dmitry Safonov <0x7f454c46@...il.com>,
	Hangbin Liu <liuhangbin@...il.com>
Subject: [PATCH net-next 1/2] selftest/tcp-ao: Set routes in a proper VRF table id

In unsigned-md5 selftests ip_route_add() is not needed in
client_add_ip(): the route was pre-setup in __test_init() => link_init()
for subnet, rather than a specific ip-address.

Currently, __ip_route_add() mistakenly always sets VRF table
to RT_TABLE_MAIN - this seems to have sneaked in during unsigned-md5
tests debugging. That also explains, why ip_route_add_vrf() ignored
EEXIST, returned by fib6.

Yet, keep EEXIST ignoring in bench-lookups selftests as it's expected
that those selftests may add the same (duplicate) routes.

Reported-by: Hangbin Liu <liuhangbin@...il.com>
Signed-off-by: Dmitry Safonov <dima@...sta.com>
---
 tools/testing/selftests/net/tcp_ao/bench-lookups.c |  4 +++-
 tools/testing/selftests/net/tcp_ao/lib/netlink.c   |  4 +---
 tools/testing/selftests/net/tcp_ao/unsigned-md5.c  | 11 +++++------
 3 files changed, 9 insertions(+), 10 deletions(-)

diff --git a/tools/testing/selftests/net/tcp_ao/bench-lookups.c b/tools/testing/selftests/net/tcp_ao/bench-lookups.c
index 7be8a7d9308c..a1e6e007c291 100644
--- a/tools/testing/selftests/net/tcp_ao/bench-lookups.c
+++ b/tools/testing/selftests/net/tcp_ao/bench-lookups.c
@@ -46,8 +46,10 @@ static void test_add_routes(union tcp_addr *ips, size_t ips_nr)
 
 	for (i = 0; i < ips_nr; i++) {
 		union tcp_addr *p = (union tcp_addr *)&ips[i];
+		int err;
 
-		if (ip_route_add(veth_name, TEST_FAMILY, this_ip_addr, *p))
+		err = ip_route_add(veth_name, TEST_FAMILY, this_ip_addr, *p);
+		if (err && err != -EEXIST)
 			test_error("Failed to add route");
 	}
 }
diff --git a/tools/testing/selftests/net/tcp_ao/lib/netlink.c b/tools/testing/selftests/net/tcp_ao/lib/netlink.c
index b731f2c84083..7f108493a29a 100644
--- a/tools/testing/selftests/net/tcp_ao/lib/netlink.c
+++ b/tools/testing/selftests/net/tcp_ao/lib/netlink.c
@@ -261,7 +261,7 @@ static int __ip_route_add(int sock, uint32_t seq, const char *intf, int family,
 	req.nh.nlmsg_seq	= seq;
 	req.rt.rtm_family	= family;
 	req.rt.rtm_dst_len	= (family == AF_INET) ? 32 : 128;
-	req.rt.rtm_table	= RT_TABLE_MAIN;
+	req.rt.rtm_table	= vrf;
 	req.rt.rtm_protocol	= RTPROT_BOOT;
 	req.rt.rtm_scope	= RT_SCOPE_UNIVERSE;
 	req.rt.rtm_type		= RTN_UNICAST;
@@ -294,8 +294,6 @@ int ip_route_add_vrf(const char *intf, int family,
 
 	ret = __ip_route_add(route_sock, route_seq++, intf,
 			     family, src, dst, vrf);
-	if (ret == -EEXIST) /* ignoring */
-		ret = 0;
 
 	close(route_sock);
 	return ret;
diff --git a/tools/testing/selftests/net/tcp_ao/unsigned-md5.c b/tools/testing/selftests/net/tcp_ao/unsigned-md5.c
index 7cffde02d2be..f5b6d488d501 100644
--- a/tools/testing/selftests/net/tcp_ao/unsigned-md5.c
+++ b/tools/testing/selftests/net/tcp_ao/unsigned-md5.c
@@ -30,7 +30,7 @@ static void setup_vrfs(void)
 	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");
+		test_error("Failed to add a route to VRF: %d", err);
 }
 
 static void try_accept(const char *tst_name, unsigned int port,
@@ -494,15 +494,14 @@ static void try_to_add(const char *tst_name, unsigned int port,
 
 static void client_add_ip(union tcp_addr *client, const char *ip)
 {
-	int family = TEST_FAMILY;
+	int err, 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");
+	err = ip_addr_add(veth_name, family, *client, TEST_PREFIX);
+	if (err)
+		test_error("Failed to add ip address: %d", err);
 }
 
 static void client_add_ips(void)

-- 
2.43.0


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ