Skip to content

Commit 72cd9f8

Browse files
0x7f454c46davem330
authored andcommitted
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 <[email protected]> Signed-off-by: Dmitry Safonov <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent a27359a commit 72cd9f8

File tree

3 files changed

+9
-10
lines changed

3 files changed

+9
-10
lines changed

tools/testing/selftests/net/tcp_ao/bench-lookups.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,10 @@ static void test_add_routes(union tcp_addr *ips, size_t ips_nr)
4646

4747
for (i = 0; i < ips_nr; i++) {
4848
union tcp_addr *p = (union tcp_addr *)&ips[i];
49+
int err;
4950

50-
if (ip_route_add(veth_name, TEST_FAMILY, this_ip_addr, *p))
51+
err = ip_route_add(veth_name, TEST_FAMILY, this_ip_addr, *p);
52+
if (err && err != -EEXIST)
5153
test_error("Failed to add route");
5254
}
5355
}

tools/testing/selftests/net/tcp_ao/lib/netlink.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,7 @@ static int __ip_route_add(int sock, uint32_t seq, const char *intf, int family,
261261
req.nh.nlmsg_seq = seq;
262262
req.rt.rtm_family = family;
263263
req.rt.rtm_dst_len = (family == AF_INET) ? 32 : 128;
264-
req.rt.rtm_table = RT_TABLE_MAIN;
264+
req.rt.rtm_table = vrf;
265265
req.rt.rtm_protocol = RTPROT_BOOT;
266266
req.rt.rtm_scope = RT_SCOPE_UNIVERSE;
267267
req.rt.rtm_type = RTN_UNICAST;
@@ -294,8 +294,6 @@ int ip_route_add_vrf(const char *intf, int family,
294294

295295
ret = __ip_route_add(route_sock, route_seq++, intf,
296296
family, src, dst, vrf);
297-
if (ret == -EEXIST) /* ignoring */
298-
ret = 0;
299297

300298
close(route_sock);
301299
return ret;

tools/testing/selftests/net/tcp_ao/unsigned-md5.c

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ static void setup_vrfs(void)
3030
err = ip_route_add_vrf(veth_name, TEST_FAMILY,
3131
this_ip_addr, this_ip_dest, test_vrf_tabid);
3232
if (err)
33-
test_error("Failed to add a route to VRF");
33+
test_error("Failed to add a route to VRF: %d", err);
3434
}
3535

3636
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,
494494

495495
static void client_add_ip(union tcp_addr *client, const char *ip)
496496
{
497-
int family = TEST_FAMILY;
497+
int err, family = TEST_FAMILY;
498498

499499
if (inet_pton(family, ip, client) != 1)
500500
test_error("Can't convert ip address %s", ip);
501501

502-
if (ip_addr_add(veth_name, family, *client, TEST_PREFIX))
503-
test_error("Failed to add ip address");
504-
if (ip_route_add(veth_name, family, *client, this_ip_dest))
505-
test_error("Failed to add route");
502+
err = ip_addr_add(veth_name, family, *client, TEST_PREFIX);
503+
if (err)
504+
test_error("Failed to add ip address: %d", err);
506505
}
507506

508507
static void client_add_ips(void)

0 commit comments

Comments
 (0)