linux/tools/testing/selftests/net
Ido Schimmel c923c14942 selftests: net: Add exception cache tests
Add a test for the IPv4 and IPv6 exception caches, covering the
exceptions that are created in response to ICMP errors quoting a UDP
packet.

The topology consists of a host (h1) that reaches a remote host (h2)
via a router (r1), with a second router (r2) attached to the segment
shared by h1 and r1. UDP packets are injected using a packet socket, so
that an ICMP error quoting them is only matched to a socket when one was
opened separately with the same source port. PMTU errors are provoked by
lowering the MTU of the far end of the path and redirects by pointing
r1's route towards h2 back over the segment it received the packet from.

The following is tested for both address families and for both PMTU and
redirect exceptions:

* An error that is not matched to a socket creates an exception that
  carries the new MTU or gateway.
* An error that is matched to a socket creates the same exception.

The PMTU tests further verify that a lower PMTU replaces the one stored
in the exception whereas a higher one does not, and that a socket which
disabled PMTU discovery using IP{,V6}_PMTUDISC_OMIT gets the same
exception as the other cases.

Without "ipv4: udp: Create exceptions before socket matching" and "ipv6:
udp: Create exceptions before socket matching", the tests that do not
open a socket fail:

 # ./exception_cache.sh
 TEST: IPv4: PMTU: exception without a matching socket               [FAIL]
         No socket: exception does not carry an MTU of 1400
 TEST: IPv6: PMTU: exception without a matching socket               [FAIL]
         No socket: exception does not carry an MTU of 1400
 TEST: IPv4: PMTU: exception with a matching socket                  [ OK ]
 TEST: IPv6: PMTU: exception with a matching socket                  [ OK ]
 TEST: IPv4: PMTU: exception with a socket ignoring it               [FAIL]
         PMTU discovery disabled: exception does not carry an MTU of 1400
 TEST: IPv6: PMTU: exception with a socket ignoring it               [FAIL]
         PMTU discovery disabled: exception does not carry an MTU of 1400
 TEST: IPv4: Redirect: exception without a matching socket           [FAIL]
         No socket: exception does not carry the new gateway
 TEST: IPv6: Redirect: exception without a matching socket           [FAIL]
         No socket: exception does not carry the new gateway
 TEST: IPv4: Redirect: exception with a matching socket              [ OK ]
 TEST: IPv6: Redirect: exception with a matching socket              [ OK ]

Signed-off-by: Ido Schimmel <idosch@nvidia.com>
Link: https://patch.msgid.link/20260828192344.2596928-5-idosch@nvidia.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
2026-08-31 19:56:31 -07:00
..
af_unix selftest: Add tests for useful handling of LSM denials on SCM_RIGHTS 2026-08-17 18:14:52 -07:00
bench selftests: pp-bench: remove page_pool_put_page wrapper 2025-07-01 17:42:11 -07:00
can selftests: complete kselftest include centralization 2025-11-27 14:24:31 -08:00
forwarding selftests: drv-net: let ethtool stats settle before reading 2026-08-10 16:47:49 -07:00
hsr selftests: net: hsr: add PRP RedBox test 2026-07-27 17:46:41 -07:00
lib selftests: net: verify RTA_DEL_REASON on route deletion 2026-08-13 12:30:28 +02:00
mptcp selftests: mptcp: diag: fix stack buffer overflow in get_subflow_info() 2026-08-17 17:25:50 -07:00
netfilter selftests: netfilter: conntrack_dump_flush: remove unused variables and fix typo 2026-08-10 21:20:44 +02:00
openvswitch selftests/net/openvswitch: add SCTP flow key support and test 2026-08-13 18:30:53 -07:00
ovpn Included fixes: 2026-07-23 10:04:17 -07:00
packetdrill Including fixes from Bluetooth, IPSec and Netfilter. 2026-08-27 13:53:43 -07:00
ppp selftests: net: do not detect PPPoX loopback 2026-06-05 17:29:40 -07:00
rds selftests: net: rds: add getsockopt() conversion test 2026-06-11 12:19:05 +02:00
tcp_ao selftests: net: tcp_ao: test VRF-scoped key deletion 2026-08-27 12:07:21 +02:00
.gitignore selftests: net: add getsockopt_iter binary to .gitignore 2026-06-09 18:48:17 -07:00
altnames.sh
amt.sh selftests: net: amt: wait longer for connection before sending packets 2026-01-21 19:20:30 -08:00
arp_ndisc_evict_nocarrier.sh selftests: net: add a hint about MACAddressPolicy=persistent 2025-12-01 12:02:13 -08:00
arp_ndisc_untracked_subnets.sh
bareudp.sh selftests: net: use BASH for bareudp testing 2025-10-29 17:56:03 -07:00
big_tcp_tunnels.sh selftests: net: Fix slow configurations in big_tcp_tunnels.sh 2026-08-27 08:42:28 -07:00
big_tcp.sh
bind_bhash.c selftests/net: bind_bhash: fix memory leak in bind_socket 2026-06-02 19:27:25 -07:00
bind_bhash.sh
bind_timewait.c selftests: complete kselftest include centralization 2025-11-27 14:24:31 -08:00
bind_wildcard.c selftests: complete kselftest include centralization 2025-11-27 14:24:31 -08:00
bpf_offload.py selftests: net: bpf_offload: print loaded programs on mismatch 2025-08-20 19:28:03 -07:00
bpf.mk
bridge_stp_mode.sh selftests: net: add bridge STP mode selection test 2026-04-10 15:52:25 -07:00
bridge_vlan_dump.sh selftests: net: bridge: test ranges with PVID VLAN 2026-07-22 10:23:18 -07:00
broadcast_ether_dst.sh selftests: net: fix file owner for broadcast_ether_dst test 2026-06-18 18:22:30 -07:00
broadcast_pmtu.sh selftests: net: add test for variable PMTU in broadcast routes 2025-07-14 17:29:41 -07:00
busy_poll_test.sh selftests: Add napi threaded busy poll test in busy_poller 2025-11-03 18:11:40 -08:00
busy_poller.c selftests: Add napi threaded busy poll test in busy_poller 2025-11-03 18:11:40 -08:00
cmsg_ip.sh selftests/net: expand cmsg_ip with MSG_MORE 2025-03-10 13:13:04 -07:00
cmsg_sender.c selftests: complete kselftest include centralization 2025-11-27 14:24:31 -08:00
cmsg_so_mark.sh
cmsg_so_priority.sh selftests: net: test SO_PRIORITY ancillary data with cmsg_sender 2024-12-16 18:14:12 -08:00
cmsg_time.sh selftests: net: give up on the cmsg_time accuracy on slow machines 2025-01-17 18:36:14 -08:00
config Summary 2026-08-20 08:46:41 -07:00
double_udp_encap.sh selftests: net: tests for add double tunneling GRO/GSO 2026-01-23 11:31:14 -08:00
drop_monitor_tests.sh selftests: net: lib: Add kill_process 2024-11-15 16:39:19 -08:00
ecmp_rehash.sh selftests: net: add local ECMP rehash test 2026-06-15 15:58:13 -07:00
epoll_busy_poll.c selftests: complete kselftest include centralization 2025-11-27 14:24:31 -08:00
exception_cache.sh selftests: net: Add exception cache tests 2026-08-31 19:56:31 -07:00
fcnal-ipv4.sh selftests: net: run groups from fcnal-test in parallel 2025-09-09 15:34:11 -07:00
fcnal-ipv6.sh selftests: net: run groups from fcnal-test in parallel 2025-09-09 15:34:11 -07:00
fcnal-other.sh selftests: net: run groups from fcnal-test in parallel 2025-09-09 15:34:11 -07:00
fcnal-test.sh selftests: net: add ipv6 ping to local address from localhost 2026-01-25 13:16:47 -08:00
fdb_flush.sh selftests: net: Fix few spelling mistakes 2025-02-18 18:10:31 -08:00
fdb_notify.sh selftests: net: lib: Rename ip_link_set_master() to adf_* 2025-09-26 17:48:37 -07:00
fib_nexthop_multiprefix.sh
fib_nexthop_nongw.sh
fib_nexthops.sh selftests: net: add coverage for fdb nexthop dst_port 2026-07-30 16:09:23 -07:00
fib_rule_tests.sh selftests: net: remove redundant rp_filter configuration 2025-05-12 18:10:55 -07:00
fib_tests.sh selftests: fib_tests: Add test cases for route lookup with oif 2026-06-12 17:53:48 -07:00
fib-onlink-tests.sh Merge git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net 2026-01-22 20:14:36 -08:00
fin_ack_lat.c selftests/net: check fork() return value in fin_ack_lat 2026-08-24 11:40:29 -07:00
fin_ack_lat.sh selftests/net: fix kill() argument order and wrapper cleanup in fin_ack_lat 2026-08-24 11:40:25 -07:00
fou_mcast_encap.sh selftests: net: add FOU multicast encapsulation resubmit test 2026-07-21 11:09:02 +02:00
fq_band_pktlimit.sh selftests: net: Remove unnecessary backslashes in fq_band_pktlimit.sh 2026-03-26 18:48:44 -07:00
getsockopt_iter.c selftests: net: getsockopt_iter: cover rawv6 and tls 2026-08-03 16:55:23 -07:00
gre_gso.sh
gre_ipv6_lladdr.sh selftests: Add IPv6 multicast route generation tests for GRE devices. 2025-07-10 18:11:04 -07:00
hwtstamp_config.c
icmp_redirect.sh selftests: net: remove redundant rp_filter configuration 2025-05-12 18:10:55 -07:00
icmp_rfc4884.c selftests: net: Add kernel selftest for RFC 4884 2026-01-22 18:29:49 -08:00
icmp.sh
in_netns.sh
io_uring_zerocopy_tx.c selftests/net: io_uring: fix unknown errnum values 2025-10-17 16:57:53 -07:00
io_uring_zerocopy_tx.sh selftests: net: io_uring_zerocopy: enable io_uring for the test 2026-03-23 19:58:32 -07:00
ioam6_parser.c selftests: net: add new ioam tests 2024-10-04 15:34:07 -07:00
ioam6.sh Revert "ipv6: preserve insertion order for same-scope addresses" 2026-05-29 13:00:54 -07:00
ip_defrag.c
ip_defrag.sh
ip_local_port_range.c selftests: complete kselftest include centralization 2025-11-27 14:24:31 -08:00
ip_local_port_range.sh selftests/net: ensure mptcp is enabled in netns 2025-02-25 18:13:28 -08:00
ip6_gre_headroom.sh
ip6_tunnel.sh selftests/net: add test for IP-in-IPv6 tunneling 2026-02-23 17:33:29 -08:00
ipsec.c xfrm: Drop support for HMAC-RIPEMD-160 2026-04-07 10:47:58 +02:00
ipv6_flowlabel_mgr.c selftests: net: adopt harness for flow label mgr 2026-08-11 18:24:56 -07:00
ipv6_flowlabel.c
ipv6_flowlabel.sh selftests: net: separate ipv6_flowlabel_mgr test 2026-08-17 10:58:53 -07:00
ipv6_force_forwarding.sh ipv6: add force_forwarding sysctl to enable per-interface forwarding 2025-07-25 13:06:19 -07:00
ipv6_fragmentation.c selftests: complete kselftest include centralization 2025-11-27 14:24:31 -08:00
ipv6_route_update_soft_lockup.sh selftests: net: move wait_local_port_listen to lib.sh 2025-05-27 17:31:42 -07:00
ipvtap_test.sh selftests: net: simple selftest for ipvtap 2026-01-19 10:03:31 -08:00
l2_tos_ttl_inherit.sh
l2tp.sh
lib.sh selftests: net: make busywait timeout clock portable 2026-07-06 12:13:37 +02:00
link_netns.py selftests: net: add a test case for nsid in all nsid notifications 2026-05-22 17:11:09 -07:00
lwt_dst_cache_ref_loop.sh selftests: net: test for lwtunnel dst ref loops 2025-03-20 11:25:52 +01:00
macvlan_mcast_shared_mac.sh selftests: net: add macvlan multicast test for shared source MAC 2026-03-03 18:08:13 -08:00
Makefile selftests: net: Add exception cache tests 2026-08-31 19:56:31 -07:00
msg_zerocopy.c selftest: net: extend msg_zerocopy test with forwarding 2025-07-02 15:07:16 -07:00
msg_zerocopy.sh selftest: net: extend msg_zerocopy test with forwarding 2025-07-02 15:07:16 -07:00
nat6to4.bpf.c
nat6to4.sh selftests: net: add test case for NAT46 looping back dst 2025-06-11 17:02:29 -07:00
ndisc_unsolicited_na_test.sh
netdev-l2addr.sh selftests: net: add netdev-l2addr.sh for testing L2 address functionality 2025-07-11 17:00:18 -07:00
netdevice.sh selftests: net: Use XFAIL for operations not supported by the driver 2024-08-22 16:56:06 -07:00
netlink-dumps.c Significant patch series in this pull request: 2025-12-06 14:01:20 -08:00
netns-name.sh selftests: net: use netdevsim in netns test 2025-04-03 15:32:09 -07:00
netns-sysctl.sh
nettest.c selftests: nettest: Fix typo in log and error messages for clarity 2025-06-17 16:22:59 -07:00
nk_qlease.py selftests/net: Add additional test coverage in nk_qlease 2026-04-14 08:17:02 -07:00
nl_netdev.py selftests: net: add tests for filtered dumps of page pool 2026-05-08 14:54:55 -07:00
nl_nlctrl.py tools: ynl: rework policy access to support recursion 2026-03-18 16:41:42 -07:00
pmtu.sh selftests: net: speed up pmtu.sh by avoiding unnecessary cleanup 2025-09-09 16:26:44 -07:00
proc_net_pktgen.c selftests: complete kselftest include centralization 2025-11-27 14:24:31 -08:00
protodown.sh selftests: net: Add protodown tests 2026-05-08 16:50:27 -07:00
psock_fanout.c selftests: complete kselftest include centralization 2025-11-27 14:24:31 -08:00
psock_lib.h selftests: centralise maybe-unused definition in kselftest.h 2025-09-13 16:55:16 -07:00
psock_snd.c selftests/net: test PACKET_IGNORE_OUTGOING 2026-07-29 16:59:45 -07:00
psock_snd.sh selftests/net: test PACKET_IGNORE_OUTGOING 2026-07-29 16:59:45 -07:00
psock_tpacket.c selftests: complete kselftest include centralization 2025-11-27 14:24:31 -08:00
reuseaddr_conflict.c
reuseaddr_ports_exhausted.c selftests: complete kselftest include centralization 2025-11-27 14:24:31 -08:00
reuseaddr_ports_exhausted.sh
reuseport_addr_any.c selftest: net: Remove DCCP bits. 2025-04-11 18:58:10 -07:00
reuseport_addr_any.sh
reuseport_bpf_cpu.c selftests: net: run reuseport in an isolated netns 2026-03-23 19:58:29 -07:00
reuseport_bpf_numa.c selftests: net: reuseport_bpf_numa: consider cpuless numa node 2026-08-11 10:54:15 +02:00
reuseport_bpf.c selftests: net: run reuseport in an isolated netns 2026-03-23 19:58:29 -07:00
reuseport_dualstack.c selftests: net: run reuseport in an isolated netns 2026-03-23 19:58:29 -07:00
route_hint.sh selftests: net: add test for dst hint mechanism with directed broadcast addresses 2025-08-25 16:07:16 -07:00
route_localnet.sh
rps_default_mask.sh selftests: net: fix spelling and grammar mistakes 2025-09-01 13:08:07 -07:00
rtnetlink_notification.sh selftest: add selftest for anycast notifications 2025-06-22 17:32:04 +01:00
rtnetlink.py selftests: net: verify RTA_DEL_REASON on route deletion 2026-08-13 12:30:28 +02:00
rtnetlink.sh selftests: rtnetlink: Add bridge promiscuity tests 2026-05-27 17:23:05 -07:00
run_afpackettests
run_netsocktests
rxtimestamp.c selftests: complete kselftest include centralization 2025-11-27 14:24:31 -08:00
rxtimestamp.sh
sample_map_ret0.bpf.c
sample_ret0.bpf.c
sctp_hello.c selftests: net: fix server bind failure in sctp_vrf.sh 2025-10-20 16:41:33 -07:00
sctp_vrf.sh selftests: net: fix server bind failure in sctp_vrf.sh 2025-10-20 16:41:33 -07:00
settings
sk_bind_sendto_listen.c
sk_connect_zero_addr.c
sk_so_peek_off.c selftests: complete kselftest include centralization 2025-11-27 14:24:31 -08:00
skf_net_off.c selftests/net: test sk_filter support for SKF_NET_OFF on frags 2025-04-09 20:02:51 -07:00
skf_net_off.sh selftests/net: test sk_filter support for SKF_NET_OFF on frags 2025-04-09 20:02:51 -07:00
so_incoming_cpu.c selftests: complete kselftest include centralization 2025-11-27 14:24:31 -08:00
so_netns_cookie.c
so_rcv_listener.c selftests: net: add support for testing SO_RCVMARK and SO_RCVPRIORITY 2025-02-17 16:45:19 -08:00
socket.c selftests: complete kselftest include centralization 2025-11-27 14:24:31 -08:00
srv6_encap_lookup_l3vpn_test.sh selftests: seg6: add test for post-encap SID route lookup 2026-07-22 08:01:02 -07:00
srv6_end_dt4_l3vpn_test.sh selftests: net: use setup_ns for SRv6 tests and remove rp_filter configuration 2025-05-12 18:10:55 -07:00
srv6_end_dt6_l3vpn_test.sh
srv6_end_dt46_l3vpn_test.sh selftests/net: Skip srv6_end_dt46_l3vpn_test if iproute2 too old 2026-07-23 15:10:09 +02:00
srv6_end_dx4_netfilter_test.sh selftests: add selftest for the SRv6 End.DX4 behavior with netfilter 2024-06-19 18:42:10 +02:00
srv6_end_dx6_netfilter_test.sh selftests: add selftest for the SRv6 End.DX6 behavior with netfilter 2024-06-19 18:42:10 +02:00
srv6_end_flavors_test.sh selftests: net: Fix spellings 2025-05-20 18:14:08 -07:00
srv6_end_next_csid_l3vpn_test.sh selftests: seg6: fix instaces typo in comments 2025-07-01 19:32:45 -07:00
srv6_end_x_next_csid_l3vpn_test.sh selftests: seg6: fix instaces typo in comments 2025-07-01 19:32:45 -07:00
srv6_hencap_red_l3vpn_test.sh selftests: add check for seg6 tunsrc 2026-03-26 18:45:29 -07:00
srv6_hl2encap_red_l2vpn_test.sh selftests: seg6: fix instaces typo in comments 2025-07-01 19:32:45 -07:00
srv6_iptunnel_cache.sh selftests: seg6: add test for dst_cache isolation in seg6 lwtunnel 2026-04-07 20:20:56 -07:00
stress_reuseport_listen.c
stress_reuseport_listen.sh
tap.c selftests: net: fix "buffer overflow detected" for tap.c 2025-12-23 12:30:23 +01:00
tcp_ecmp_failover.sh selftest: net: Add test for TCP flow failover with ECMP routes. 2026-05-01 17:58:44 -07:00
tcp_fastopen_backup_key.c selftests: complete kselftest include centralization 2025-11-27 14:24:31 -08:00
tcp_fastopen_backup_key.sh
tcp_inq.c
tcp_mmap.c selftests/net: use MAP_FAILED instead of (void *)-1 in tcp_mmap 2026-07-23 07:18:53 -07:00
tcp_port_share.c selftests: complete kselftest include centralization 2025-11-27 14:24:31 -08:00
test_bpf.sh
test_bridge_backup_port.sh selftests: net: Test bridge backup port when port is administratively down 2025-08-14 17:45:36 -07:00
test_bridge_neigh_suppress.sh selftests: net: Add tests for neigh_forward_grat option 2026-05-14 12:42:12 +02:00
test_ingress_egress_chaining.sh
test_neigh.sh selftests: net: Fix flaky neighbor garbage collection test 2025-08-01 13:51:41 -07:00
test_so_rcv.sh selftests: net: add support for testing SO_RCVMARK and SO_RCVPRIORITY 2025-02-17 16:45:19 -08:00
test_vxlan_fdb_changelink.sh selftests: net: lib: Rename ip_link_set_up() to adf_* 2025-09-26 17:48:37 -07:00
test_vxlan_mdb.sh vxlan: mdb: Fix use-after-free in vxlan_mdb_remote_src_del() 2026-08-30 14:19:59 -07:00
test_vxlan_nh.sh selftests: net: add coverage for fdb nexthop dst_port 2026-07-30 16:09:23 -07:00
test_vxlan_nolocalbypass.sh
test_vxlan_under_vrf.sh
test_vxlan_vnifilter_notify.sh selftests: net: add vxlan vnifilter notification test 2026-06-04 08:47:45 -07:00
test_vxlan_vnifiltering.sh selftests: net: use slowwait to make sure IPv6 setup finished 2025-06-19 15:24:09 +02:00
tfo_passive.sh selftests: net: fix passive TFO test to fail if child processes failed 2026-01-17 18:01:26 -08:00
tfo.c selftests: net: improve error handling in passive TFO test 2026-01-17 18:01:26 -08:00
timestamping.c
tls.c selftests: tls: cover splice after a failed decrypt 2026-08-11 15:39:00 +02:00
traceroute.sh selftests: traceroute: Add ICMP extensions tests 2025-10-29 18:28:30 -07:00
tun.c selftests/net: Fix tun IPv6 test addresses to avoid 6to4 range 2026-07-20 17:59:25 -07:00
tuntap_helpers.h selftest: tun: Introduce tuntap_helpers.h header for TUN/TAP testing 2026-01-23 11:43:28 -08:00
txring_overwrite.c
txtimestamp.c selftests: net: reduce txtimestamp deschedule flakes 2026-01-13 11:46:39 -08:00
txtimestamp.sh selftests: txtimestamp: add SCM_TS_OPT_ID test 2024-10-04 11:52:20 -07:00
udpgro_bench.sh selftests: net: move wait_local_port_listen to lib.sh 2025-05-27 17:31:42 -07:00
udpgro_frglist.sh selftests: net: move wait_local_port_listen to lib.sh 2025-05-27 17:31:42 -07:00
udpgro_fwd.sh selftest: net: add a test-case for encap segmentation after GRO 2026-02-03 19:23:41 -08:00
udpgro.sh selftests: net: increase inter-packet timeout in udpgro.sh 2025-07-15 15:26:47 +02:00
udpgso_bench_rx.c
udpgso_bench_tx.c selftests: complete kselftest include centralization 2025-11-27 14:24:31 -08:00
udpgso_bench.sh selftests/net: call sendmmsg via udpgso_bench.sh 2024-12-04 19:22:20 -08:00
udpgso.c udp: gso: do not drop small packets when PMTU reduces 2025-02-03 10:13:27 +00:00
udpgso.sh selftests/net: Add test coverage for UDP GSO software fallback 2024-06-28 18:13:00 -07:00
unicast_extensions.sh selftests: net: add helper for checking if nettest is available 2024-08-22 12:55:47 +02:00
veth.sh selftests: net: use the dummy bpf from net/lib 2025-03-31 16:44:25 -07:00
vlan_bridge_binding.sh selftests: vlan_bridge_binding: Fix flaky operational state check 2026-06-18 18:15:34 -07:00
vlan_hw_filter.sh selftests: avoid using ifconfig 2025-08-01 14:40:19 -07:00
vrf_route_leaking.sh selftests: net: use slowwait to stabilize vrf_route_leaking test 2025-06-19 15:24:08 +02:00
vrf_strict_mode_test.sh
vrf-xfrm-tests.sh
xfrm_policy_add_speed.sh selftests: add xfrm policy insertion speed test script 2024-08-24 09:55:01 +02:00
xfrm_policy.sh
xfrm_state.sh selftests: net: add ICMP error source address test over xfrm tunnel 2026-02-28 15:08:15 -08:00
ynl.mk selftests: net: move netlink-dumps back to progs 2025-09-08 12:57:05 -07:00