Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Merge branch 'selftests-tcp-ao'

Dmitry Safonov says:

====================
selftest/net: Some more TCP-AO selftest post-merge fixups

Note that there's another post-merge fix for TCP-AO selftests, but that
doesn't conflict with these, so I don't resend that:

https://lore.kernel.org/all/20231219-b4-tcp-ao-selftests-out-of-tree-v1-1-0fff92d26eac@arista.com/T/#u
====================

Tested-by: Hangbin Liu <liuhangbin@gmail.com>
Reviewed-by: Hangbin Liu <liuhangbin@gmail.com>
Signed-off-by: Dmitry Safonov <dima@arista.com>

+36 -18
+3 -1
tools/testing/selftests/net/tcp_ao/bench-lookups.c
··· 46 46 47 47 for (i = 0; i < ips_nr; i++) { 48 48 union tcp_addr *p = (union tcp_addr *)&ips[i]; 49 + int err; 49 50 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) 51 53 test_error("Failed to add route"); 52 54 } 53 55 }
+1 -3
tools/testing/selftests/net/tcp_ao/lib/netlink.c
··· 261 261 req.nh.nlmsg_seq = seq; 262 262 req.rt.rtm_family = family; 263 263 req.rt.rtm_dst_len = (family == AF_INET) ? 32 : 128; 264 - req.rt.rtm_table = RT_TABLE_MAIN; 264 + req.rt.rtm_table = vrf; 265 265 req.rt.rtm_protocol = RTPROT_BOOT; 266 266 req.rt.rtm_scope = RT_SCOPE_UNIVERSE; 267 267 req.rt.rtm_type = RTN_UNICAST; ··· 294 294 295 295 ret = __ip_route_add(route_sock, route_seq++, intf, 296 296 family, src, dst, vrf); 297 - if (ret == -EEXIST) /* ignoring */ 298 - ret = 0; 299 297 300 298 close(route_sock); 301 299 return ret;
+27 -8
tools/testing/selftests/net/tcp_ao/lib/setup.c
··· 277 277 278 278 /* /proc/sys/net/core/optmem_max artifically limits the amount of memory 279 279 * that can be allocated with sock_kmalloc() on each socket in the system. 280 - * It is not virtualized, so it has to written outside test namespaces. 281 - * To be nice a test will revert optmem back to the old value. 280 + * It is not virtualized in v6.7, so it has to written outside test 281 + * namespaces. To be nice a test will revert optmem back to the old value. 282 282 * Keeping it simple without any file lock, which means the tests that 283 283 * need to set/increase optmem value shouldn't run in parallel. 284 284 * Also, not re-entrant. 285 + * Since commit f5769faeec36 ("net: Namespace-ify sysctl_optmem_max") 286 + * it is per-namespace, keeping logic for non-virtualized optmem_max 287 + * for v6.7, which supports TCP-AO. 285 288 */ 286 289 static const char *optmem_file = "/proc/sys/net/core/optmem_max"; 287 290 static size_t saved_optmem; 291 + static int optmem_ns = -1; 292 + 293 + static bool is_optmem_namespaced(void) 294 + { 295 + if (optmem_ns == -1) { 296 + int old_ns = switch_save_ns(nsfd_child); 297 + 298 + optmem_ns = !access(optmem_file, F_OK); 299 + switch_ns(old_ns); 300 + } 301 + return !!optmem_ns; 302 + } 288 303 289 304 size_t test_get_optmem(void) 290 305 { 306 + int old_ns = 0; 291 307 FILE *foptmem; 292 - int old_ns; 293 308 size_t ret; 294 309 295 - old_ns = switch_save_ns(nsfd_outside); 310 + if (!is_optmem_namespaced()) 311 + old_ns = switch_save_ns(nsfd_outside); 296 312 foptmem = fopen(optmem_file, "r"); 297 313 if (!foptmem) 298 314 test_error("failed to open %s", optmem_file); ··· 316 300 if (fscanf(foptmem, "%zu", &ret) != 1) 317 301 test_error("can't read from %s", optmem_file); 318 302 fclose(foptmem); 319 - switch_ns(old_ns); 303 + if (!is_optmem_namespaced()) 304 + switch_ns(old_ns); 320 305 return ret; 321 306 } 322 307 323 308 static void __test_set_optmem(size_t new, size_t *old) 324 309 { 310 + int old_ns = 0; 325 311 FILE *foptmem; 326 - int old_ns; 327 312 328 313 if (old != NULL) 329 314 *old = test_get_optmem(); 330 315 331 - old_ns = switch_save_ns(nsfd_outside); 316 + if (!is_optmem_namespaced()) 317 + old_ns = switch_save_ns(nsfd_outside); 332 318 foptmem = fopen(optmem_file, "w"); 333 319 if (!foptmem) 334 320 test_error("failed to open %s", optmem_file); ··· 338 320 if (fprintf(foptmem, "%zu", new) <= 0) 339 321 test_error("can't write %zu to %s", new, optmem_file); 340 322 fclose(foptmem); 341 - switch_ns(old_ns); 323 + if (!is_optmem_namespaced()) 324 + switch_ns(old_ns); 342 325 } 343 326 344 327 static void test_revert_optmem(void)
+5 -6
tools/testing/selftests/net/tcp_ao/unsigned-md5.c
··· 30 30 err = ip_route_add_vrf(veth_name, TEST_FAMILY, 31 31 this_ip_addr, this_ip_dest, test_vrf_tabid); 32 32 if (err) 33 - test_error("Failed to add a route to VRF"); 33 + test_error("Failed to add a route to VRF: %d", err); 34 34 } 35 35 36 36 static void try_accept(const char *tst_name, unsigned int port, ··· 494 494 495 495 static void client_add_ip(union tcp_addr *client, const char *ip) 496 496 { 497 - int family = TEST_FAMILY; 497 + int err, family = TEST_FAMILY; 498 498 499 499 if (inet_pton(family, ip, client) != 1) 500 500 test_error("Can't convert ip address %s", ip); 501 501 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); 506 505 } 507 506 508 507 static void client_add_ips(void)