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.

selftests/net: gro: add self-test for TCP CWR flag

Currently, GRO does not flush packets when the CWR bit is set.
A corresponding self-test is being added, in which the CWR flag
is set for two consecutive packets, but the first packet with the
CWR flag set will not be flushed immediately.

+===================+==========+===============+===========+
| Packet id | CWR flag | Payload | Flushing? |
+===================+==========+===============+===========+
| 0 | 0 | PAYLOAD_LEN | 0 |
| ... | 0 | PAYLOAD_LEN | 1 |
+-------------------+----------+---------------+-----------+
| NUM_PACKETS/2 - 1 | 1 | payload_len | 0 |
| NUM_PACKETS/2 | 1 | payload_len | 1 |
+-------------------+----------+---------------+-----------+
| ... | 0 | PAYLOAD_LEN | 0 |
| NUM_PACKETS | 0 | PAYLOAD_LEN | 1 |
+===================+==========+===============+===========+

Signed-off-by: Chia-Yu Chang <chia-yu.chang@nokia-bell-labs.com>
Acked-by: Paolo Abeni <pabeni@redhat.com>
Reviewed-by: Eric Dumazet <edumazet@google.com>
Link: https://patch.msgid.link/20260131222515.8485-4-chia-yu.chang@nokia-bell-labs.com
Signed-off-by: Paolo Abeni <pabeni@redhat.com>

authored by

Chia-Yu Chang and committed by
Paolo Abeni
6f74bc8b ab4c8b6f

+60 -24
+58 -23
tools/testing/selftests/drivers/net/gro.c
··· 17 17 * Pure ACK does not coalesce. 18 18 * 19 19 * flags_*: 20 - * No packets with PSH, SYN, URG, RST set will be coalesced. 21 - * - flags_psh, flags_syn, flags_rst, flags_urg 20 + * No packets with PSH, SYN, URG, RST, CWR set will be coalesced. 21 + * - flags_psh, flags_syn, flags_rst, flags_urg, flags_cwr 22 22 * 23 23 * tcp_*: 24 24 * Packets with incorrect checksum, non-consecutive seqno and ··· 360 360 fill_datalinklayer(buf); 361 361 } 362 362 363 - /* send one extra flag, not first and not last pkt */ 364 - static void send_flags(int fd, struct sockaddr_ll *daddr, int psh, int syn, 365 - int rst, int urg) 363 + #ifndef TH_CWR 364 + #define TH_CWR 0x80 365 + #endif 366 + static void set_flags(struct tcphdr *tcph, int payload_len, int psh, int syn, 367 + int rst, int urg, int cwr) 366 368 { 367 - static char flag_buf[MAX_HDR_LEN + PAYLOAD_LEN]; 368 - static char buf[MAX_HDR_LEN + PAYLOAD_LEN]; 369 - int payload_len, pkt_size, flag, i; 370 - struct tcphdr *tcph; 371 - 372 - payload_len = PAYLOAD_LEN * psh; 373 - pkt_size = total_hdr_len + payload_len; 374 - flag = NUM_PACKETS / 2; 375 - 376 - create_packet(flag_buf, flag * payload_len, 0, payload_len, 0); 377 - 378 - tcph = (struct tcphdr *)(flag_buf + tcp_offset); 379 369 tcph->psh = psh; 380 370 tcph->syn = syn; 381 371 tcph->rst = rst; 382 372 tcph->urg = urg; 373 + if (cwr) 374 + tcph->th_flags |= TH_CWR; 375 + else 376 + tcph->th_flags &= ~TH_CWR; 383 377 tcph->check = 0; 384 378 tcph->check = tcp_checksum(tcph, payload_len); 379 + } 380 + 381 + /* send extra flags of the (NUM_PACKETS / 2) and (NUM_PACKETS / 2 - 1) 382 + * pkts, not first and not last pkt 383 + */ 384 + static void send_flags(int fd, struct sockaddr_ll *daddr, int psh, int syn, 385 + int rst, int urg, int cwr) 386 + { 387 + static char flag_buf[2][MAX_HDR_LEN + PAYLOAD_LEN]; 388 + static char buf[MAX_HDR_LEN + PAYLOAD_LEN]; 389 + int payload_len, pkt_size, i; 390 + struct tcphdr *tcph; 391 + int flag[2]; 392 + 393 + payload_len = PAYLOAD_LEN * (psh || cwr); 394 + pkt_size = total_hdr_len + payload_len; 395 + flag[0] = NUM_PACKETS / 2; 396 + flag[1] = NUM_PACKETS / 2 - 1; 397 + 398 + /* Create and configure packets with flags 399 + */ 400 + for (i = 0; i < 2; i++) { 401 + if (flag[i] > 0) { 402 + create_packet(flag_buf[i], flag[i] * payload_len, 0, 403 + payload_len, 0); 404 + tcph = (struct tcphdr *)(flag_buf[i] + tcp_offset); 405 + set_flags(tcph, payload_len, psh, syn, rst, urg, cwr); 406 + } 407 + } 385 408 386 409 for (i = 0; i < NUM_PACKETS + 1; i++) { 387 - if (i == flag) { 388 - write_packet(fd, flag_buf, pkt_size, daddr); 410 + if (i == flag[0]) { 411 + write_packet(fd, flag_buf[0], pkt_size, daddr); 412 + continue; 413 + } else if (i == flag[1] && cwr) { 414 + write_packet(fd, flag_buf[1], pkt_size, daddr); 389 415 continue; 390 416 } 391 417 create_packet(buf, i * PAYLOAD_LEN, 0, PAYLOAD_LEN, 0); ··· 1094 1068 1095 1069 /* flags sub-tests */ 1096 1070 } else if (strcmp(testname, "flags_psh") == 0) { 1097 - send_flags(txfd, &daddr, 1, 0, 0, 0); 1071 + send_flags(txfd, &daddr, 1, 0, 0, 0, 0); 1098 1072 write_packet(txfd, fin_pkt, total_hdr_len, &daddr); 1099 1073 } else if (strcmp(testname, "flags_syn") == 0) { 1100 - send_flags(txfd, &daddr, 0, 1, 0, 0); 1074 + send_flags(txfd, &daddr, 0, 1, 0, 0, 0); 1101 1075 write_packet(txfd, fin_pkt, total_hdr_len, &daddr); 1102 1076 } else if (strcmp(testname, "flags_rst") == 0) { 1103 - send_flags(txfd, &daddr, 0, 0, 1, 0); 1077 + send_flags(txfd, &daddr, 0, 0, 1, 0, 0); 1104 1078 write_packet(txfd, fin_pkt, total_hdr_len, &daddr); 1105 1079 } else if (strcmp(testname, "flags_urg") == 0) { 1106 - send_flags(txfd, &daddr, 0, 0, 0, 1); 1080 + send_flags(txfd, &daddr, 0, 0, 0, 1, 0); 1081 + write_packet(txfd, fin_pkt, total_hdr_len, &daddr); 1082 + } else if (strcmp(testname, "flags_cwr") == 0) { 1083 + send_flags(txfd, &daddr, 0, 0, 0, 0, 1); 1107 1084 write_packet(txfd, fin_pkt, total_hdr_len, &daddr); 1108 1085 1109 1086 /* tcp sub-tests */ ··· 1267 1238 correct_payload[1] = 0; 1268 1239 correct_payload[2] = PAYLOAD_LEN * 2; 1269 1240 printf("urg flag ends coalescing: "); 1241 + check_recv_pkts(rxfd, correct_payload, 3); 1242 + } else if (strcmp(testname, "flags_cwr") == 0) { 1243 + correct_payload[0] = PAYLOAD_LEN; 1244 + correct_payload[1] = PAYLOAD_LEN * 2; 1245 + correct_payload[2] = PAYLOAD_LEN * 2; 1246 + printf("cwr flag ends coalescing: "); 1270 1247 check_recv_pkts(rxfd, correct_payload, 3); 1271 1248 1272 1249 /* tcp sub-tests */
+2 -1
tools/testing/selftests/drivers/net/gro.py
··· 17 17 - flags_syn: Packets with SYN flag don't coalesce 18 18 - flags_rst: Packets with RST flag don't coalesce 19 19 - flags_urg: Packets with URG flag don't coalesce 20 + - flags_cwr: Packets with CWR flag don't coalesce 20 21 - tcp_csum: Packets with incorrect checksum don't coalesce 21 22 - tcp_seq: Packets with non-consecutive seqno don't coalesce 22 23 - tcp_ts: Packets with different timestamp options don't coalesce ··· 192 191 common_tests = [ 193 192 "data_same", "data_lrg_sml", "data_sml_lrg", 194 193 "ack", 195 - "flags_psh", "flags_syn", "flags_rst", "flags_urg", 194 + "flags_psh", "flags_syn", "flags_rst", "flags_urg", "flags_cwr", 196 195 "tcp_csum", "tcp_seq", "tcp_ts", "tcp_opt", 197 196 "ip_ecn", "ip_tos", 198 197 "large_max", "large_rem",