diff options
| author | Linus Torvalds <torvalds@linux-foundation.org> | 2026-10-29 08:17:05 -1000 |
|---|---|---|
| committer | Linus Torvalds <torvalds@linux-foundation.org> | 2026-10-29 08:17:05 -1000 |
| commit | 4dd16e31135ea8437a720222df34e8745f385d6d (patch) | |
| tree | 004c93006bf6fdd3618249deedab3fbbdc8bee30 /tools/testing | |
| parent | 46806af187f448b0d5481f284e7c900a57ee6a6d (diff) | |
| parent | 8f44631ba02afe9fff2f0a0fb66560ab19df87fd (diff) | |
Merge tag 'net-7.4-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net
Pull networking fixes from Jakub Kicinski:
"Current release - new code bugs:
- mctp: usblib: fix assertion breaking esoteric builds
Previous releases - regressions:
- Revert advertising the TCP MSS from the configured MTU
- netlink: check sk_rcvbuf before charging the dump skb
- eth:
- ti: am65-cpts: fix support for PTP_EXTTS_REQUEST2 ioctl
- mlx4: always create the eth and ib auxiliary devices
- tg3: invert restart quirk logic to restrict SNP power-down bypass
- bnxt: recycle agg buffers when Rx head buffer allocation fails
Previous releases - always broken:
- net: fix frag_list leak in skb_segment_list() error path
- sctp: reject forged cookie peer_addr with unknown address family
- vxlan: keep reserved_bits across changelink
- net: limit priority VLAN untag depth
- inet: frags: prevent acceptance of partially authenticated reassembly
- gro: do not GRO GSO packets with inconsistent payload
- tcp: avoid double destroy in tcp_abort() of an unaccepted child"
* tag 'net-7.4-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net: (137 commits)
tun: drop batched packets while the device is down
selftests: net: netlink-dumps: start a dump with a notification queued
netlink: check sk_rcvbuf before charging the dump skb
net/sched: act_ife: do not consume the inner header on egress
openvswitch: use eth_type_trans_careful() in internal_dev_recv()
net: use eth_type_trans_careful() in __dev_forward_skb2()
loopback: use eth_type_trans_careful()
net: add eth_type_trans_careful()
tcp: initialize mapped children before route lookup
tcp: fix reordering addition overflow in MTU probing
tcp: avoid double destroy in tcp_abort() of an unaccepted child
net: bgmac: fix TX DMA unmapping and slot cleanup
gro: do not GRO GSO packets with inconsistent payload
net/packet: check TX_RING fragments before memory accounting
eth: bnxt: hand XDP frags over to the copybreak skb
eth: bnxt: free XDP frags when xdp_do_redirect() fails
eth: bnxt: don't leak buffers when XDP agg buffer allocation fails
eth: bnxt: resize Rx head buffers when rx-copybreak changes
eth: bnxt: recycle agg buffers when Rx head buffer allocation fails
netdev-genl: ignore NETDEV_UNREGISTER rebroadcasts
...
Diffstat (limited to 'tools/testing')
| -rw-r--r-- | tools/testing/selftests/bpf/prog_tests/empty_skb.c | 19 | ||||
| -rwxr-xr-x | tools/testing/selftests/net/forwarding/bridge_vlan_mcast.sh | 3 | ||||
| -rwxr-xr-x | tools/testing/selftests/net/forwarding/vxlan_reserved.sh | 15 | ||||
| -rw-r--r-- | tools/testing/selftests/net/lib/gro.c | 2 | ||||
| -rw-r--r-- | tools/testing/selftests/net/netlink-dumps.c | 102 | ||||
| -rw-r--r-- | tools/testing/selftests/net/packetdrill/tcp_advmss_pmtu_ipv4.pkt | 67 | ||||
| -rw-r--r-- | tools/testing/selftests/net/packetdrill/tcp_advmss_pmtu_ipv6.pkt | 67 | ||||
| -rw-r--r-- | tools/testing/selftests/net/tcp_mmap.c | 6 | ||||
| -rw-r--r-- | tools/testing/selftests/net/tls.c | 31 | ||||
| -rw-r--r-- | tools/testing/selftests/net/txtimestamp.c | 23 | ||||
| -rw-r--r-- | tools/testing/selftests/tc-testing/tc-tests/filters/matchall.json | 71 |
11 files changed, 248 insertions, 158 deletions
diff --git a/tools/testing/selftests/bpf/prog_tests/empty_skb.c b/tools/testing/selftests/bpf/prog_tests/empty_skb.c index c9fcb70cbafb..a3938c16557b 100644 --- a/tools/testing/selftests/bpf/prog_tests/empty_skb.c +++ b/tools/testing/selftests/bpf/prog_tests/empty_skb.c @@ -24,7 +24,7 @@ void test_empty_skb(void) int *ifindex; int err; int ret; - int lwt_egress_ret; /* expected retval at lwt/egress */ + int lwt_ret; /* expected retval at lwt */ __be16 h_proto; bool success_on_tc; bool adjust_room; @@ -82,7 +82,7 @@ void test_empty_skb(void) .data_size_in = sizeof(eth_hlen), .ifindex = &veth_ifindex, .ret = -ERANGE, - .lwt_egress_ret = -ERANGE, + .lwt_ret = -ERANGE, .success_on_tc = true, }, { @@ -96,17 +96,23 @@ void test_empty_skb(void) .data_size_in = sizeof(eth_hlen), .ifindex = &ipip_ifindex, .ret = -ERANGE, - .lwt_egress_ret = -ERANGE, + .lwt_ret = -ERANGE, }, - /* ETH_HLEN+1-sized packet should be redirected. */ + /* ETH_HLEN+1-sized packet should be redirected at TC. + * At LWT, the Ethernet header is not part of the skb, and + * a 1-byte packet is too short for an Ethernet device. + */ { .msg = "veth ETH_HLEN+1 packet ingress", .data_in = eth_hlen_pp, .data_size_in = sizeof(eth_hlen_pp), .ifindex = &veth_ifindex, - .lwt_egress_ret = 1, /* veth_xmit NET_XMIT_DROP */ + /* lwt: skb->len=1, dropped by veth_xmit() at egress + * and by __dev_forward_skb2() at ingress. + */ + .lwt_ret = 1, /* NET_XMIT_DROP / NET_RX_DROP */ }, { .msg = "ipip ETH_HLEN+1 packet ingress", @@ -144,7 +150,6 @@ void test_empty_skb(void) eth_hlen.h_proto = tests[i].h_proto; bpf_object__for_each_program(prog, bpf_obj->obj) { - bool at_egress = strstr(bpf_program__name(prog), "egress") != NULL; bool at_tc = !strncmp(bpf_program__section_name(prog), "tc", 2); bool is_adjust_room = !strcmp(bpf_program__name(prog), "tc_adjust_room"); int expected_ret; @@ -153,7 +158,7 @@ void test_empty_skb(void) if (tests[i].adjust_room != is_adjust_room) continue; - expected_ret = at_egress && !at_tc ? tests[i].lwt_egress_ret : tests[i].ret; + expected_ret = at_tc ? tests[i].ret : tests[i].lwt_ret; tattr.data_in = tests[i].data_in; tattr.data_size_in = tests[i].data_size_in; diff --git a/tools/testing/selftests/net/forwarding/bridge_vlan_mcast.sh b/tools/testing/selftests/net/forwarding/bridge_vlan_mcast.sh index c4cd2078a8db..c07c2af5df94 100755 --- a/tools/testing/selftests/net/forwarding/bridge_vlan_mcast.sh +++ b/tools/testing/selftests/net/forwarding/bridge_vlan_mcast.sh @@ -383,7 +383,8 @@ vlmc_startup_query_test() echo -n $goutput | jq -e ".[].vlans[] | select(.vlan == 10 and \ - .mcast_startup_query_interval == 3125) " &>/dev/null + .mcast_startup_query_interval >= 3124 and \ + .mcast_startup_query_interval <= 3126) " &>/dev/null check_err $? "Wrong default mcast_startup_query_interval global vlan option value" log_test "Vlan mcast_startup_query_interval global option default value" diff --git a/tools/testing/selftests/net/forwarding/vxlan_reserved.sh b/tools/testing/selftests/net/forwarding/vxlan_reserved.sh index 709845123727..0ce264cc57f8 100755 --- a/tools/testing/selftests/net/forwarding/vxlan_reserved.sh +++ b/tools/testing/selftests/net/forwarding/vxlan_reserved.sh @@ -40,6 +40,7 @@ reserved_31_test reserved_56_test reserved_63_test + gbp_changelink_test "} NUM_NETIFS=4 @@ -338,6 +339,20 @@ reserved_63_test() reserved_test 63 } +gbp_changelink_test_do() +{ + vxlan_device_add gbp + __default_test_do 25 "gbp" + ip link set dev vx1 type vxlan ageing 300 + __default_test_do 25 "gbp after changelink" +} + +gbp_changelink_test() +{ + in_defer_scope \ + gbp_changelink_test_do +} + trap cleanup EXIT setup_prepare diff --git a/tools/testing/selftests/net/lib/gro.c b/tools/testing/selftests/net/lib/gro.c index fb6a72275636..5aaf7a897b0b 100644 --- a/tools/testing/selftests/net/lib/gro.c +++ b/tools/testing/selftests/net/lib/gro.c @@ -1339,7 +1339,6 @@ static void check_capacity_pkts(int fd) int coalesced[num_flows]; struct tcphdr *tcph; int ip_ext_len = 0; - int total_data = 0; int pkt_size = -1; int data_len = 0; int flow_id; @@ -1402,7 +1401,6 @@ static void check_capacity_pkts(int fd) } num_pkt++; - total_data += data_len; } /* Check flow ordering. We expect to see all non-coalesced first segs diff --git a/tools/testing/selftests/net/netlink-dumps.c b/tools/testing/selftests/net/netlink-dumps.c index 51129c564d0a..4a94a25167e2 100644 --- a/tools/testing/selftests/net/netlink-dumps.c +++ b/tools/testing/selftests/net/netlink-dumps.c @@ -2,9 +2,12 @@ #define _GNU_SOURCE +#include <errno.h> #include <fcntl.h> +#include <sched.h> #include <stdio.h> #include <string.h> +#include <sys/ioctl.h> #include <sys/socket.h> #include <sys/stat.h> #include <sys/syscall.h> @@ -260,4 +263,103 @@ TEST(close_with_ref) usleep(100 * 1000); } +static int lo_set_up(int sock, bool up) +{ + struct ifreq ifr = {}; + + strcpy(ifr.ifr_name, "lo"); + if (ioctl(sock, SIOCGIFFLAGS, &ifr)) + return -1; + if (up) + ifr.ifr_flags |= IFF_UP; + else + ifr.ifr_flags &= ~IFF_UP; + return ioctl(sock, SIOCSIFFLAGS, &ifr); +} + +static const struct { + struct nlmsghdr nlhdr; + struct ifinfomsg ifm; +} dump_links = { + .nlhdr = { + .nlmsg_len = sizeof(dump_links), + .nlmsg_type = RTM_GETLINK, + .nlmsg_flags = NLM_F_REQUEST | NLM_F_ACK | NLM_F_DUMP, + .nlmsg_seq = 1, + }, + .ifm = { + .ifi_family = AF_UNSPEC, + }, +}; + +// A dump started while a notification is still queued must make progress +// for a reader which peeks before reading, like libnl does +TEST(dump_with_queued_ntf) +{ + struct sockaddr_nl addr = { + .nl_family = AF_NETLINK, + .nl_groups = RTMGRP_LINK, + }; + int netlink_sock, inet_sock, i, ret, links = 0; + int rcvbuf = 2048; + bool done = false; + char buf[32768]; + ssize_t n; + + ret = unshare(CLONE_NEWNET); + if (ret && errno == EPERM) + SKIP(return, "Needs CAP_SYS_ADMIN for a netns"); + ASSERT_EQ(ret, 0); + + inet_sock = socket(AF_INET, SOCK_DGRAM, 0); + ASSERT_GE(inet_sock, 0); + netlink_sock = socket(AF_NETLINK, SOCK_RAW, NETLINK_ROUTE); + ASSERT_GE(netlink_sock, 0); + ASSERT_EQ(setsockopt(netlink_sock, SOL_SOCKET, SO_RCVBUF, + &rcvbuf, sizeof(rcvbuf)), 0); + ASSERT_EQ(bind(netlink_sock, (struct sockaddr *)&addr, + sizeof(addr)), 0); + + // A large read makes the kernel attempt large dump skbs + ASSERT_EQ(lo_set_up(inet_sock, true), 0); + n = recv(netlink_sock, buf, sizeof(buf), 0); + ASSERT_GE(n, (ssize_t)sizeof(struct nlmsghdr)); + + // Leave one notification queued, then start the dump + ASSERT_EQ(lo_set_up(inet_sock, false), 0); + n = send(netlink_sock, &dump_links, sizeof(dump_links), 0); + ASSERT_EQ(n, sizeof(dump_links)); + + for (i = 0; i < 100 && !done; i++) { + struct nlmsghdr *nlh; + + n = recv(netlink_sock, buf, sizeof(buf), + MSG_PEEK | MSG_TRUNC | MSG_DONTWAIT); + if (n < 0) + continue; + n = recv(netlink_sock, buf, sizeof(buf), MSG_DONTWAIT); + if (n < 0) + continue; + + for (nlh = (struct nlmsghdr *)buf; NLMSG_OK(nlh, n); + nlh = NLMSG_NEXT(nlh, n)) { + if (nlh->nlmsg_seq != dump_links.nlhdr.nlmsg_seq) + continue; + if (nlh->nlmsg_type == NLMSG_ERROR) + EXPECT_EQ(*(int *)NLMSG_DATA(nlh), 0); + if (nlh->nlmsg_type == RTM_NEWLINK) + links++; + if (nlh->nlmsg_type == NLMSG_DONE) { + EXPECT_EQ(*(int *)NLMSG_DATA(nlh), 0); + done = true; + } + } + } + EXPECT_TRUE(done); + EXPECT_GE(links, 1); + + close(netlink_sock); + close(inet_sock); +} + TEST_HARNESS_MAIN diff --git a/tools/testing/selftests/net/packetdrill/tcp_advmss_pmtu_ipv4.pkt b/tools/testing/selftests/net/packetdrill/tcp_advmss_pmtu_ipv4.pkt deleted file mode 100644 index f2ef931b77a1..000000000000 --- a/tools/testing/selftests/net/packetdrill/tcp_advmss_pmtu_ipv4.pkt +++ /dev/null @@ -1,67 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0 -// -// Test that IPv4 advertised MSS in SYN-ACK is derived from the configured -// interface MTU (1500 -> MSS 1460), not the ICMP-learned Path MTU. - ---ip_version=ipv4 - -`./defaults.sh -ethtool -K tun0 tso off -` - -// -// Connection 1: Learn PMTU exception (MTU 1200 -> MSS 1160) -// - 0 socket(..., SOCK_STREAM, IPPROTO_TCP) = 3 - +0 setsockopt(3, SOL_SOCKET, SO_REUSEADDR, [1], 4) = 0 - +0 bind(3, ..., ...) = 0 - +0 listen(3, 1) = 0 - - +0 < S 0:0(0) win 65535 <mss 1460,sackOK,nop,nop,nop,wscale 8> - +0 > S. 0:0(0) ack 1 <mss 1460,nop,nop,sackOK,nop,wscale 8> - +.1 < . 1:1(0) ack 1 win 257 - +0 accept(3, ..., ...) = 4 - -// Send a full 1460-byte segment - +0 write(4, ..., 1460) = 1460 - +0 > P. 1:1461(1460) ack 1 - -// ICMP Fragmentation Needed arrives indicating next-hop MTU 1200 - +0 < icmp unreachable frag_needed mtu 1200 [1:1461(1460)] - -// Local host retransmits using the learned MTU 1200 (MSS = 1200 - 40 = 1160) - +0 > . 1:1161(1160) ack 1 - +0 > P. 1161:1461(300) ack 1 - +0 < R 1:1(0) ack 1461 win 0 - -// Close connection 1 and listener - +0 close(4) = 0 - +0 close(3) = 0 - -// -// Connection 2: New connection from the same peer -// - +0 socket(..., SOCK_STREAM, IPPROTO_TCP) = 3 - +0 setsockopt(3, SOL_SOCKET, SO_REUSEADDR, [1], 4) = 0 - +0 bind(3, ..., ...) = 0 - +0 listen(3, 1) = 0 - - +0 < S 0:0(0) win 65535 <mss 1460,sackOK,nop,nop,nop,wscale 8> - -// Verify: SYN-ACK MUST advertise configured MSS 1460, NOT the learned PMTU MSS 1160 - +0 > S. 0:0(0) ack 1 <mss 1460,nop,nop,sackOK,nop,wscale 8> - +0 < . 1:1(0) ack 1 win 257 - +0 accept(3, ..., ...) = 4 - -// Verify: Outgoing transmit MSS is still constrained by the learned PMTU 1200 - +0 write(4, ..., 1460) = 1460 - +0 > . 1:1161(1160) ack 1 - +0 > P. 1161:1461(300) ack 1 - +0 < . 1:1(0) ack 1461 win 257 - -// Clean up - +0 close(4) = 0 - +0 > F. 1461:1461(0) ack 1 - +0 < F. 1:1(0) ack 1462 win 257 - +0 > . 1462:1462(0) ack 2 - +0 close(3) = 0 diff --git a/tools/testing/selftests/net/packetdrill/tcp_advmss_pmtu_ipv6.pkt b/tools/testing/selftests/net/packetdrill/tcp_advmss_pmtu_ipv6.pkt deleted file mode 100644 index c7638b11a815..000000000000 --- a/tools/testing/selftests/net/packetdrill/tcp_advmss_pmtu_ipv6.pkt +++ /dev/null @@ -1,67 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0 -// -// Test that IPv6 advertised MSS in SYN-ACK is derived from the configured -// interface MTU (1520 -> MSS 1460), not the ICMPv6-learned Path MTU. - ---ip_version=ipv6 - -`./defaults.sh -ethtool -K tun0 tso off -` - -// -// Connection 1: Learn PMTU exception (MTU 1280 -> MSS 1220) -// - 0 socket(..., SOCK_STREAM, IPPROTO_TCP) = 3 - +0 setsockopt(3, SOL_SOCKET, SO_REUSEADDR, [1], 4) = 0 - +0 bind(3, ..., ...) = 0 - +0 listen(3, 1) = 0 - - +0 < S 0:0(0) win 65535 <mss 1460,sackOK,nop,nop,nop,wscale 8> - +0 > S. 0:0(0) ack 1 <mss 1460,nop,nop,sackOK,nop,wscale 8> - +.1 < . 1:1(0) ack 1 win 257 - +0 accept(3, ..., ...) = 4 - -// Send a full 1460-byte segment - +0 write(4, ..., 1460) = 1460 - +0 > P. 1:1461(1460) ack 1 - -// ICMPv6 Packet Too Big arrives indicating next-hop MTU 1280 - +0 < icmp packet_too_big mtu 1280 [1:1461(1460)] - -// Local host retransmits using the learned MTU 1280 (MSS = 1280 - 40 - 20 = 1220) - +0 > . 1:1221(1220) ack 1 - +0 > P. 1221:1461(240) ack 1 - +0 < R 1:1(0) ack 1461 win 0 - -// Close connection 1 and listener - +0 close(4) = 0 - +0 close(3) = 0 - -// -// Connection 2: New connection from the same peer -// - +0 socket(..., SOCK_STREAM, IPPROTO_TCP) = 3 - +0 setsockopt(3, SOL_SOCKET, SO_REUSEADDR, [1], 4) = 0 - +0 bind(3, ..., ...) = 0 - +0 listen(3, 1) = 0 - - +0 < S 0:0(0) win 65535 <mss 1460,sackOK,nop,nop,nop,wscale 8> - -// Verify: SYN-ACK MUST advertise configured MSS 1460, NOT the learned PMTU MSS 1220 - +0 > S. 0:0(0) ack 1 <mss 1460,nop,nop,sackOK,nop,wscale 8> - +0 < . 1:1(0) ack 1 win 257 - +0 accept(3, ..., ...) = 4 - -// Verify: Outgoing transmit MSS is still constrained by the learned PMTU 1280 - +0 write(4, ..., 1460) = 1460 - +0 > . 1:1221(1220) ack 1 - +0 > P. 1221:1461(240) ack 1 - +0 < . 1:1(0) ack 1461 win 257 - -// Clean up - +0 close(4) = 0 - +0 > F. 1461:1461(0) ack 1 - +0 < F. 1:1(0) ack 1462 win 257 - +0 > . 1462:1462(0) ack 2 - +0 close(3) = 0 diff --git a/tools/testing/selftests/net/tcp_mmap.c b/tools/testing/selftests/net/tcp_mmap.c index 487ae659a1f1..86241bed7f08 100644 --- a/tools/testing/selftests/net/tcp_mmap.c +++ b/tools/testing/selftests/net/tcp_mmap.c @@ -85,7 +85,6 @@ static int rcvbuf; /* Default: autotuning. Can be set with -r <integer> option static int sndbuf; /* Default: autotuning. Can be set with -w <integer> option */ static int zflg; /* zero copy option. (MSG_ZEROCOPY for sender, mmap() for receiver */ static int xflg; /* hash received data (simple xor) (-h option) */ -static int keepflag; /* -k option: receiver shall keep all received file in memory (no munmap() calls) */ static int integrity; /* -i option: sender and receiver compute sha256 over the data.*/ static size_t chunk_size = 512*1024; @@ -456,7 +455,7 @@ int main(int argc, char *argv[]) int sflg = 0; int mss = 0; - while ((c = getopt(argc, argv, "46p:svr:w:H:zxkP:M:C:a:i")) != -1) { + while ((c = getopt(argc, argv, "46p:svr:w:H:zxP:M:C:a:i")) != -1) { switch (c) { case '4': cfg_family = PF_INET; @@ -490,9 +489,6 @@ int main(int argc, char *argv[]) case 'x': xflg = 1; break; - case 'k': - keepflag = 1; - break; case 'P': max_pacing_rate = atoi(optarg) ; break; diff --git a/tools/testing/selftests/net/tls.c b/tools/testing/selftests/net/tls.c index 9d3cd4fff062..c4203401c4bf 100644 --- a/tools/testing/selftests/net/tls.c +++ b/tools/testing/selftests/net/tls.c @@ -889,6 +889,37 @@ TEST_F(tls, splice_to_pipe) EXPECT_EQ(memcmp(mem_send, mem_recv, send_len), 0); } +/* The socket's O_NONBLOCK governs the record wait, as on a plain TCP + * socket, even without SPLICE_F_NONBLOCK. + */ +TEST_F(tls, splice_nonblock_socket) +{ + struct pollfd pfd = { .fd = self->cfd, .events = POLLIN }; + int send_len = TLS_PAYLOAD_MAX_LEN; + char mem_send[TLS_PAYLOAD_MAX_LEN]; + char mem_recv[TLS_PAYLOAD_MAX_LEN]; + int flags, p[2]; + + flags = fcntl(self->cfd, F_GETFL, 0); + ASSERT_GE(flags, 0); + ASSERT_EQ(fcntl(self->cfd, F_SETFL, flags | O_NONBLOCK), 0); + + memrnd(mem_send, sizeof(mem_send)); + + ASSERT_GE(pipe(p), 0); + EXPECT_EQ(splice(self->cfd, NULL, p[1], NULL, send_len, 0), -1); + EXPECT_EQ(errno, EAGAIN); + + /* The record may still be in flight, wait for it. A failed splice() + * would leave the read() below blocking until the harness timeout. + */ + EXPECT_EQ(send(self->fd, mem_send, send_len, 0), send_len); + ASSERT_EQ(poll(&pfd, 1, 5000), 1); + ASSERT_EQ(splice(self->cfd, NULL, p[1], NULL, send_len, 0), send_len); + EXPECT_EQ(read(p[0], mem_recv, send_len), send_len); + EXPECT_EQ(memcmp(mem_send, mem_recv, send_len), 0); +} + TEST_F(tls, splice_cmsg_to_pipe) { char *test_str = "test_read"; diff --git a/tools/testing/selftests/net/txtimestamp.c b/tools/testing/selftests/net/txtimestamp.c index 170be192f5c7..f7bdf30b78d9 100644 --- a/tools/testing/selftests/net/txtimestamp.c +++ b/tools/testing/selftests/net/txtimestamp.c @@ -418,19 +418,25 @@ static uint16_t get_ip_csum(const uint16_t *start, int num_words, return ~sum; } -static uint16_t get_udp_csum(const struct udphdr *udph, int alen) +static uint16_t get_udp_csum(const struct udphdr *udph, bool is_ipv4) { - unsigned long pseudo_sum, csum_len; - const void *csum_start = udph; + const void *addr = is_ipv4 ? (void *)&daddr.sin_addr : &daddr6.sin6_addr; + int alen = is_ipv4 ? sizeof(struct in_addr) : sizeof(struct in6_addr); + uint16_t addr16[sizeof(struct in6_addr) / sizeof(uint16_t)]; + unsigned long pseudo_sum; + int i; pseudo_sum = htons(IPPROTO_UDP); pseudo_sum += udph->len; - /* checksum ip(v6) addresses + udp header + payload */ - csum_start -= alen * 2; - csum_len = ntohs(udph->len) + alen * 2; + /* pseudo-header source and destination: both are daddr */ + memcpy(addr16, addr, alen); + for (i = 0; i < alen / 2; i++) + pseudo_sum += 2 * addr16[i]; - return get_ip_csum(csum_start, csum_len >> 1, pseudo_sum); + /* checksum udp header + payload */ + return get_ip_csum((const uint16_t *)udph, ntohs(udph->len) >> 1, + pseudo_sum); } static int fill_header_ipv4(void *p) @@ -479,8 +485,7 @@ static void fill_header_udp(void *p, bool is_ipv4) udph->len = ntohs(sizeof(*udph) + cfg_payload_len); udph->check = 0; - udph->check = get_udp_csum(udph, is_ipv4 ? sizeof(struct in_addr) : - sizeof(struct in6_addr)); + udph->check = get_udp_csum(udph, is_ipv4); } static void do_test(int family, unsigned int report_opt) diff --git a/tools/testing/selftests/tc-testing/tc-tests/filters/matchall.json b/tools/testing/selftests/tc-testing/tc-tests/filters/matchall.json index f8d28c415bc3..6b3eea401fc8 100644 --- a/tools/testing/selftests/tc-testing/tc-tests/filters/matchall.json +++ b/tools/testing/selftests/tc-testing/tc-tests/filters/matchall.json @@ -482,6 +482,77 @@ ] }, { + "id": "230c", + "name": "Keep the flags of a gact action reused by a matchall filter with skip_hw", + "category": [ + "filter", + "matchall" + ], + "plugins": { + "requires": "nsPlugin" + }, + "setup": [ + "$TC qdisc add dev $DUMMY ingress", + "$TC filter add dev $DUMMY parent ffff: handle 0x1 prio 1 protocol ipv4 matchall action gact pass index 199" + ], + "cmdUnderTest": "$TC filter add dev $DUMMY parent ffff: handle 0x2 prio 2 protocol ipv4 matchall skip_hw action gact pass index 199", + "expExitCode": "0", + "verifyCmd": "$TC actions get action gact index 199", + "matchPattern": "skip_hw", + "matchCount": "0", + "teardown": [ + "$TC qdisc del dev $DUMMY ingress" + ] + }, + { + "id": "1f7a", + "name": "Keep the flags of a gact action reused by a rejected matchall filter with skip_hw", + "category": [ + "filter", + "matchall" + ], + "plugins": { + "requires": "nsPlugin" + }, + "setup": [ + "$TC qdisc add dev $DUMMY ingress", + "$TC actions add action gact pass index 200", + "$TC filter add dev $DUMMY parent ffff: handle 0x1 prio 1 protocol ipv4 matchall action gact pass index 199" + ], + "cmdUnderTest": "$TC filter add dev $DUMMY parent ffff: handle 0x2 prio 2 protocol ipv4 matchall skip_hw action gact pass index 199 action gact pass index 200", + "expExitCode": "2", + "verifyCmd": "$TC actions get action gact index 199", + "matchPattern": "skip_hw", + "matchCount": "0", + "teardown": [ + "$TC qdisc del dev $DUMMY ingress", + "$TC actions del action gact index 200" + ] + }, + { + "id": "9117", + "name": "Reject the reuse of a skip_hw gact action by a matchall filter without skip_hw", + "category": [ + "filter", + "matchall" + ], + "plugins": { + "requires": "nsPlugin" + }, + "setup": [ + "$TC qdisc add dev $DUMMY ingress", + "$TC filter add dev $DUMMY parent ffff: handle 0x1 prio 1 protocol ipv4 matchall skip_hw action gact pass index 199" + ], + "cmdUnderTest": "$TC filter add dev $DUMMY parent ffff: handle 0x2 prio 2 protocol ipv4 matchall action gact pass index 199", + "expExitCode": "2", + "verifyCmd": "$TC filter get dev $DUMMY parent ffff: handle 2 prio 2 protocol ipv4 matchall", + "matchPattern": "^filter parent ffff: protocol ip pref 2 matchall.*handle 0x2.*", + "matchCount": "0", + "teardown": [ + "$TC qdisc del dev $DUMMY ingress" + ] + }, + { "id": "2638", "name": "Add matchall and try to get it", "category": [ |
