linux/tools/testing/selftests/net
Petr Machata 32c8d080a1 selftests: forwarding: lib: Add helpers for checksum handling
commit 952e0ee38c upstream.

In order to generate IGMPv3 and MLDv2 packets on the fly, we will need
helpers to calculate the packet checksum.

The approach presented in this patch revolves around payload templates
for mausezahn. These are mausezahn-like payload strings (01:23:45:...)
with possibly one 2-byte sequence replaced with the word PAYLOAD. The
main function is payload_template_calc_checksum(), which calculates
RFC 1071 checksum of the message. There are further helpers to then
convert the checksum to the payload format, and to expand it.

For IPv6, MLDv2 message checksum is computed using a pseudoheader that
differs from the header used in the payload itself. The fact that the
two messages are different means that the checksum needs to be
returned as a separate quantity, instead of being expanded in-place in
the payload itself. Furthermore, the pseudoheader includes a length of
the message. Much like the checksum, this needs to be expanded in
mausezahn format. And likewise for number of addresses for (S,G)
entries. Thus we have several places where a computed quantity needs
to be presented in the payload format. Add a helper u16_to_bytes(),
which will be used in all these cases.

Signed-off-by: Petr Machata <petrm@nvidia.com>
Acked-by: Nikolay Aleksandrov <razor@blackwall.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
Stable-dep-of: 02cb2e6bac ("selftests: forwarding: vxlan_bridge_1d: fix test failure with br_netfilter enabled")
[bwh: Backported to 5.15: adjust context]
Signed-off-by: Ben Hutchings <benh@debian.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
History 2026-06-19 13:33:24 +02:00
..
af_unix af_unix: selftest: Fix the size of the parameter to connect() 2023-01-18 11:48:54 +01:00
forwarding selftests: forwarding: lib: Add helpers for checksum handling 2026-06-19 13:33:24 +02:00
mptcp selftests: mptcp: more stable simult_flows tests 2026-04-18 10:33:09 +02:00
.gitignore tools/testing: add a selftest for SO_NETNS_COOKIE 2021-06-24 11:13:05 -07:00
altnames.sh selftest: net: fix typo in altname test 2021-09-12 10:48:26 +01:00
bareudp.sh selftests: net: use BASH for bareudp testing 2025-12-07 06:09:31 +09:00
config Revert "selftests: net: Add tls config dependency for tls selftests" 2022-04-13 20:59:25 +02:00
devlink_port_split.py selftests: net: devlink_port_split.py: skip test if no suitable device available 2023-03-22 13:31:28 +01:00
drop_monitor_tests.sh selftests: net: Add drop monitor test 2020-09-30 18:01:26 -07:00
fcnal-test.sh selftests: Replace sleep with slowwait 2025-12-07 06:09:22 +09:00
fib-onlink-tests.sh selftests: fib-onlink: Make quiet by default 2019-05-22 17:50:24 -07:00
fib_nexthop_multiprefix.sh selftests/net: fix grep checking for fib_nexthop_multiprefix 2024-01-25 14:52:38 -08:00
fib_nexthops.sh selftests: fib_nexthops: Fix creation of non-FDB nexthops 2025-10-02 13:39:12 +02:00
fib_rule_tests.sh selftests/net: Use kselftest skip code for skipped tests 2021-08-24 16:49:09 -07:00
fib_tests.sh selftests: fib_tests: mute cleanup error message 2023-05-30 13:55:31 +01:00
fin_ack_lat.c selftests: net: Add FIN_ACK processing order related latency spike test 2020-02-02 13:33:21 -08:00
fin_ack_lat.sh selftests: net: Add FIN_ACK processing order related latency spike test 2020-02-02 13:33:21 -08:00
gre_gso.sh selftests: net: switch to socat in the GSO GRE test 2021-11-25 09:48:33 +01:00
gro.c selftests/net: use destination options instead of hop-by-hop 2025-12-07 06:09:25 +09:00
gro.sh selftests/net: have gro.sh -t return a correct exit code 2025-06-04 14:38:00 +02:00
hwtstamp_config.c selftests: move timestamping selftests to net folder 2020-03-29 21:48:30 -07:00
icmp.sh selftests/net: Add icmp.sh for testing ICMP dummy address responses 2021-06-18 12:13:24 -07:00
icmp_redirect.sh selftests: icmp_redirect: pass xfail=0 to log_test() 2021-12-22 09:32:40 +01:00
in_netns.sh selftests/net: fix in_netns.sh script 2018-03-07 12:26:05 -05:00
ioam6.sh selftests: net: modify IOAM tests for undef bits 2021-10-12 11:49:49 +01:00
ioam6_parser.c selftests: net: modify IOAM tests for undef bits 2021-10-12 11:49:49 +01:00
ip6_gre_headroom.sh selftests: net: Test headroom handling of ip6_gre devices 2018-06-26 23:03:01 +09:00
ip_defrag.c selftests: net: ip_defrag: ignore EPERM 2020-06-02 15:54:20 -07:00
ip_defrag.sh selftests: net: ip_defrag: modprobe missing nf_defrag_ipv6 support 2020-07-17 12:49:18 -07:00
ipsec.c selftests/net/ipsec: Fix Null pointer dereference in rtattr_pack() 2025-03-13 12:50:19 +01:00
ipv6_flowlabel.c selftests/net: ipv6 flowlabel 2019-05-28 17:18:53 -07:00
ipv6_flowlabel.sh selftests/net: ipv6 flowlabel 2019-05-28 17:18:53 -07:00
ipv6_flowlabel_mgr.c selftests/net: ipv6 flowlabel 2019-05-28 17:18:53 -07:00
l2tp.sh selftests: Make l2tp.sh executable 2019-10-22 14:01:35 -07:00
Makefile kselftests/net: add missed toeplitz.sh/toeplitz_client.sh to Makefile 2021-11-18 19:17:05 +01:00
msg_zerocopy.c selftests: make order checking verbose in msg_zerocopy selftest 2024-07-18 13:07:31 +02:00
msg_zerocopy.sh selftests: extend zerocopy tests to udp 2018-12-03 15:58:32 -08:00
net_helper.sh selftests: net: more strict check in net_helper 2024-10-17 15:12:02 +02:00
netdevice.sh selftests: net: return Kselftest Skip code for skipped tests 2018-05-30 15:29:06 -06:00
nettest.c selftests: nettest: Add --{force,no}-bind-key-ifindex 2021-10-15 14:36:57 +01:00
pmtu.sh net: ipv4: Cache pmtu for all packet paths if multipath enabled 2025-03-13 12:50:43 +01:00
psock_fanout.c tools/net: Use bitwise instead of arithmetic operator for flags 2021-08-20 14:55:53 +01:00
psock_lib.h treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 222 2019-05-30 11:29:55 -07:00
psock_snd.c selftests/net: add packet socket packet_snd test 2018-06-04 09:50:01 -04:00
psock_snd.sh selftests/net: remove min gso test in packet_snd 2021-08-02 10:34:04 +01:00
psock_tpacket.c selftests/net: Ensure assert() triggers in psock_tpacket.c 2025-12-07 06:09:18 +09:00
reuseaddr_conflict.c selftests: reuseaddr_conflict: add missing new line at the end of the output 2024-04-10 16:19:39 +02:00
reuseaddr_ports_exhausted.c selftests/net: fix warnings on reuseaddr_ports_exhausted 2021-03-16 15:01:21 -07:00
reuseaddr_ports_exhausted.sh selftests: net: Add SO_REUSEADDR test to check if 4-tuples are fully utilized. 2020-03-12 12:08:09 -07:00
reuseport_addr_any.c selftests/net: add definition for SOL_DCCP to fix compilation errors for old libc 2020-03-21 20:23:10 -07:00
reuseport_addr_any.sh selftests: net: test that listening sockets match on address properly 2018-12-14 15:55:20 -08:00
reuseport_bpf.c selftests: Fix the if conditions of in test_extra_filter() 2022-10-05 10:39:43 +02:00
reuseport_bpf_cpu.c License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
reuseport_bpf_numa.c selftests: net: reuseport_bpf_numa: don't fail if no numa support 2018-05-23 12:21:02 +02:00
reuseport_dualstack.c selftests: net: reuseport_dualstack: fix uninitalized parameter 2019-11-01 15:11:02 -07:00
route_localnet.sh selftests: add route_localnet test script 2019-06-24 09:02:47 -07:00
rtnetlink.sh selftests: rtnetlink.sh: remove esp4_offload after test 2025-08-28 16:24:09 +02:00
run_afpackettests selftests/net: Use kselftest skip code for skipped tests 2021-08-24 16:49:09 -07:00
run_netsocktests selftests/net: correct the return value for run_netsocktests 2019-04-19 14:39:51 -07:00
rxtimestamp.c Merge git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net 2020-08-02 01:02:12 -07:00
rxtimestamp.sh selftests/net: plug rxtimestamp test into kselftest framework 2020-06-23 20:36:46 -07:00
settings selftests/net: bump timeout to 5 minutes 2021-04-23 14:08:58 -07:00
setup_loopback.sh selftests: net: Remove executable bits from library scripts 2024-10-17 15:11:49 +02:00
setup_veth.sh selftests: net: give more time for GRO aggregation 2024-02-23 08:54:53 +01:00
so_netns_cookie.c tools/testing: add a selftest for SO_NETNS_COOKIE 2021-06-24 11:13:05 -07:00
so_txtime.c selftests/net: so_txtime: usage(): fix documentation of default clock 2022-05-12 12:30:17 +02:00
so_txtime.sh selftests/net: so_txtime multi-host support 2021-03-31 17:48:21 -07:00
socket.c License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
srv6_end_dt4_l3vpn_test.sh selftets: seg6: disable rp_filter by default in srv6_end_dt4_l3vpn_test 2023-05-24 17:36:49 +01:00
srv6_end_dt6_l3vpn_test.sh selftests/net: Use kselftest skip code for skipped tests 2021-08-24 16:49:09 -07:00
srv6_end_dt46_l3vpn_test.sh selftests: srv6: make srv6_end_dt46_l3vpn_test more robust 2023-05-17 11:50:16 +02:00
tcp_fastopen_backup_key.c selftests/net: fix warnings in TFO key rotation selftest 2019-06-16 14:27:14 -07:00
tcp_fastopen_backup_key.sh selftests: net: tcp_fastopen_backup_key.sh: fix shellcheck issue 2019-08-15 11:34:32 -07:00
tcp_inq.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 253 2019-06-05 17:30:27 +02:00
tcp_mmap.c selftests: net: tcp_mmap: Use huge pages in receive path 2020-08-20 16:14:53 -07:00
test_blackhole_dev.sh blackhole_dev: add a selftest 2019-07-01 19:34:46 -07:00
test_bpf.sh License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
test_vxlan_fdb_changelink.sh selftests: net: Add test_vxlan_fdb_changelink.sh 2018-12-18 21:18:26 -08:00
test_vxlan_under_vrf.sh selftests: net: test_vxlan_under_vrf: fix HV connectivity test 2026-01-19 13:10:12 +01:00
timestamping.c selftests/net: timestamping: Fix bind_phc check 2022-04-08 14:23:26 +02:00
tls.c selftests: tls: use exact comparison in recv_partial 2024-03-26 18:21:12 -04:00
toeplitz.c selftests: drv-net: fix RPS mask handling for high CPU numbers 2026-02-06 16:41:46 +01:00
toeplitz.sh selftests: net: Use "grep -E" instead of "egrep" 2022-12-21 17:36:38 +01:00
toeplitz_client.sh selftests/net: toeplitz test 2021-08-05 13:14:09 +01:00
traceroute.sh selftests: traceroute: Use require_command() 2025-12-07 06:09:21 +09:00
txring_overwrite.c selftests: txring_overwrite: fix incorrect test of mmap() return value 2019-07-08 15:39:38 -07:00
txtimestamp.c selftests: txtimestamp: fix compilation issue 2021-02-04 20:22:30 -08:00
txtimestamp.sh selftest: txtimestamp: fix net ns entry logic 2020-07-21 16:11:07 -07:00
udpgro.sh selftests: net: increase inter-packet timeout in udpgro.sh 2025-08-28 16:24:01 +02:00
udpgro_bench.sh selftests/net: synchronize udpgro tests' tx and rx connection 2024-10-17 15:11:49 +02:00
udpgro_fwd.sh selftests: net: gro fwd: update vxlan GRO test expectations 2024-04-10 16:19:38 +02:00
udpgso.c udp: gso: do not drop small packets when PMTU reduces 2025-03-13 12:50:22 +01:00
udpgso.sh selftests: udp gso with corking 2018-04-26 15:09:52 -04:00
udpgso_bench.sh selftests: net: udpgso_bench: Fix racing bug between the rx/tx programs 2023-02-09 11:26:38 +01:00
udpgso_bench_rx.c selftests: net: cut more slack for gro fwd tests. 2024-02-23 08:54:57 +01:00
udpgso_bench_tx.c selftests: net: udpgso_bench_tx: Cater for pending datagrams zerocopy benchmarking 2023-02-09 11:26:38 +01:00
unicast_extensions.sh selftests/net: Use kselftest skip code for skipped tests 2021-08-24 16:49:09 -07:00
veth.sh selftests/net: fix section name when using xdp_dummy.o 2022-07-12 16:35:19 +02:00
vrf-xfrm-tests.sh selftests: net: vrf-xfrm-tests: change authentication and encryption algos 2024-03-01 13:21:52 +01:00
vrf_route_leaking.sh selftests: Add VRF route leaking tests 2020-10-14 17:14:28 -07:00
vrf_strict_mode_test.sh selftests/net: Use kselftest skip code for skipped tests 2021-08-24 16:49:09 -07:00
xfrm_policy.sh xfrm: Fix wraparound in xfrm_policy_addr_delta() 2021-01-04 10:35:09 +01:00