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

selftests/net: expand gro with two machine test

The test is currently run on a single host with private addresses,
either over veth or by setting a nic in loopback mode with macvlan.

Support running between two real devices. Allow overriding addresses.

Also cut timeout to fail faster on error and explicitly log success.

Signed-off-by: Willem de Bruijn <willemb@google.com>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

Willem de Bruijn and committed by
David S. Miller
87f7282e ed6fc70e

+24 -14
+24 -14
tools/testing/selftests/net/gro.c
··· 64 64 #define NUM_PACKETS 4 65 65 #define START_SEQ 100 66 66 #define START_ACK 100 67 - #define SIP6 "fdaa::2" 68 - #define DIP6 "fdaa::1" 69 - #define SIP4 "192.168.1.200" 70 - #define DIP4 "192.168.1.100" 71 67 #define ETH_P_NONE 0 72 68 #define TOTAL_HDR_LEN (ETH_HLEN + sizeof(struct ipv6hdr) + sizeof(struct tcphdr)) 73 69 #define MSS (4096 - sizeof(struct tcphdr) - sizeof(struct ipv6hdr)) ··· 71 75 #define NUM_LARGE_PKT (MAX_PAYLOAD / MSS) 72 76 #define MAX_HDR_LEN (ETH_HLEN + sizeof(struct ipv6hdr) + sizeof(struct tcphdr)) 73 77 78 + static const char *addr6_src = "fdaa::2"; 79 + static const char *addr6_dst = "fdaa::1"; 80 + static const char *addr4_src = "192.168.1.200"; 81 + static const char *addr4_dst = "192.168.1.100"; 74 82 static int proto = -1; 75 83 static uint8_t src_mac[ETH_ALEN], dst_mac[ETH_ALEN]; 76 84 static char *testname = "data"; ··· 178 178 uint32_t sum = 0; 179 179 180 180 if (proto == PF_INET6) { 181 - if (inet_pton(AF_INET6, SIP6, &ph6.saddr) != 1) 181 + if (inet_pton(AF_INET6, addr6_src, &ph6.saddr) != 1) 182 182 error(1, errno, "inet_pton6 source ip pseudo"); 183 - if (inet_pton(AF_INET6, DIP6, &ph6.daddr) != 1) 183 + if (inet_pton(AF_INET6, addr6_dst, &ph6.daddr) != 1) 184 184 error(1, errno, "inet_pton6 dest ip pseudo"); 185 185 ph6.protocol = htons(IPPROTO_TCP); 186 186 ph6.payload_len = htons(sizeof(struct tcphdr) + payload_len); 187 187 188 188 sum = checksum_nofold(&ph6, sizeof(ph6), 0); 189 189 } else if (proto == PF_INET) { 190 - if (inet_pton(AF_INET, SIP4, &ph4.saddr) != 1) 190 + if (inet_pton(AF_INET, addr4_src, &ph4.saddr) != 1) 191 191 error(1, errno, "inet_pton source ip pseudo"); 192 - if (inet_pton(AF_INET, DIP4, &ph4.daddr) != 1) 192 + if (inet_pton(AF_INET, addr4_dst, &ph4.daddr) != 1) 193 193 error(1, errno, "inet_pton dest ip pseudo"); 194 194 ph4.protocol = htons(IPPROTO_TCP); 195 195 ph4.payload_len = htons(sizeof(struct tcphdr) + payload_len); ··· 229 229 ip6h->payload_len = htons(sizeof(struct tcphdr) + payload_len); 230 230 ip6h->nexthdr = IPPROTO_TCP; 231 231 ip6h->hop_limit = 8; 232 - if (inet_pton(AF_INET6, SIP6, &ip6h->saddr) != 1) 232 + if (inet_pton(AF_INET6, addr6_src, &ip6h->saddr) != 1) 233 233 error(1, errno, "inet_pton source ip6"); 234 - if (inet_pton(AF_INET6, DIP6, &ip6h->daddr) != 1) 234 + if (inet_pton(AF_INET6, addr6_dst, &ip6h->daddr) != 1) 235 235 error(1, errno, "inet_pton dest ip6"); 236 236 } else if (proto == PF_INET) { 237 237 memset(iph, 0, sizeof(*iph)); ··· 243 243 iph->tot_len = htons(sizeof(struct tcphdr) + 244 244 payload_len + sizeof(struct iphdr)); 245 245 iph->frag_off = htons(0x4000); /* DF = 1, MF = 0 */ 246 - if (inet_pton(AF_INET, SIP4, &iph->saddr) != 1) 246 + if (inet_pton(AF_INET, addr4_src, &iph->saddr) != 1) 247 247 error(1, errno, "inet_pton source ip"); 248 - if (inet_pton(AF_INET, DIP4, &iph->daddr) != 1) 248 + if (inet_pton(AF_INET, addr4_dst, &iph->daddr) != 1) 249 249 error(1, errno, "inet_pton dest ip"); 250 250 iph->check = checksum_fold(buf, sizeof(struct iphdr), 0); 251 251 } ··· 731 731 { 732 732 struct timeval timeout; 733 733 734 - timeout.tv_sec = 120; 734 + timeout.tv_sec = 3; 735 735 timeout.tv_usec = 0; 736 736 if (setsockopt(fd, SOL_SOCKET, SO_RCVTIMEO, (char *)&timeout, 737 737 sizeof(timeout)) < 0) ··· 1023 1023 static void parse_args(int argc, char **argv) 1024 1024 { 1025 1025 static const struct option opts[] = { 1026 + { "daddr", required_argument, NULL, 'd' }, 1026 1027 { "dmac", required_argument, NULL, 'D' }, 1027 1028 { "iface", required_argument, NULL, 'i' }, 1028 1029 { "ipv4", no_argument, NULL, '4' }, 1029 1030 { "ipv6", no_argument, NULL, '6' }, 1030 1031 { "rx", no_argument, NULL, 'r' }, 1032 + { "saddr", required_argument, NULL, 's' }, 1031 1033 { "smac", required_argument, NULL, 'S' }, 1032 1034 { "test", required_argument, NULL, 't' }, 1033 1035 { "verbose", no_argument, NULL, 'v' }, ··· 1037 1035 }; 1038 1036 int c; 1039 1037 1040 - while ((c = getopt_long(argc, argv, "46D:i:rS:t:v", opts, NULL)) != -1) { 1038 + while ((c = getopt_long(argc, argv, "46d:D:i:rs:S:t:v", opts, NULL)) != -1) { 1041 1039 switch (c) { 1042 1040 case '4': 1043 1041 proto = PF_INET; ··· 1047 1045 proto = PF_INET6; 1048 1046 ethhdr_proto = htons(ETH_P_IPV6); 1049 1047 break; 1048 + case 'd': 1049 + addr4_dst = addr6_dst = optarg; 1050 + break; 1050 1051 case 'D': 1051 1052 dmac = optarg; 1052 1053 break; ··· 1058 1053 break; 1059 1054 case 'r': 1060 1055 tx_socket = false; 1056 + break; 1057 + case 's': 1058 + addr4_src = addr6_src = optarg; 1061 1059 break; 1062 1060 case 'S': 1063 1061 smac = optarg; ··· 1099 1091 gro_sender(); 1100 1092 else 1101 1093 gro_receiver(); 1094 + 1095 + fprintf(stderr, "Gro::%s test passed.\n", testname); 1102 1096 return 0; 1103 1097 }