GNU Linux-libre 4.14.251-gnu1
[releases.git] / tools / testing / selftests / net / msg_zerocopy.c
1 /* Evaluate MSG_ZEROCOPY
2  *
3  * Send traffic between two processes over one of the supported
4  * protocols and modes:
5  *
6  * PF_INET/PF_INET6
7  * - SOCK_STREAM
8  * - SOCK_DGRAM
9  * - SOCK_DGRAM with UDP_CORK
10  * - SOCK_RAW
11  * - SOCK_RAW with IP_HDRINCL
12  *
13  * PF_PACKET
14  * - SOCK_DGRAM
15  * - SOCK_RAW
16  *
17  * Start this program on two connected hosts, one in send mode and
18  * the other with option '-r' to put it in receiver mode.
19  *
20  * If zerocopy mode ('-z') is enabled, the sender will verify that
21  * the kernel queues completions on the error queue for all zerocopy
22  * transfers.
23  */
24
25 #define _GNU_SOURCE
26
27 #include <arpa/inet.h>
28 #include <error.h>
29 #include <errno.h>
30 #include <limits.h>
31 #include <linux/errqueue.h>
32 #include <linux/if_packet.h>
33 #include <linux/ipv6.h>
34 #include <linux/socket.h>
35 #include <linux/sockios.h>
36 #include <net/ethernet.h>
37 #include <net/if.h>
38 #include <netinet/ip.h>
39 #include <netinet/ip6.h>
40 #include <netinet/tcp.h>
41 #include <netinet/udp.h>
42 #include <poll.h>
43 #include <sched.h>
44 #include <stdbool.h>
45 #include <stdio.h>
46 #include <stdint.h>
47 #include <stdlib.h>
48 #include <string.h>
49 #include <sys/ioctl.h>
50 #include <sys/socket.h>
51 #include <sys/stat.h>
52 #include <sys/time.h>
53 #include <sys/types.h>
54 #include <sys/wait.h>
55 #include <unistd.h>
56
57 #ifndef SO_EE_ORIGIN_ZEROCOPY
58 #define SO_EE_ORIGIN_ZEROCOPY           5
59 #endif
60
61 #ifndef SO_ZEROCOPY
62 #define SO_ZEROCOPY     60
63 #endif
64
65 #ifndef SO_EE_CODE_ZEROCOPY_COPIED
66 #define SO_EE_CODE_ZEROCOPY_COPIED      1
67 #endif
68
69 #ifndef MSG_ZEROCOPY
70 #define MSG_ZEROCOPY    0x4000000
71 #endif
72
73 static int  cfg_cork;
74 static bool cfg_cork_mixed;
75 static int  cfg_cpu             = -1;           /* default: pin to last cpu */
76 static int  cfg_family          = PF_UNSPEC;
77 static int  cfg_ifindex         = 1;
78 static int  cfg_payload_len;
79 static int  cfg_port            = 8000;
80 static bool cfg_rx;
81 static int  cfg_runtime_ms      = 4200;
82 static int  cfg_verbose;
83 static int  cfg_waittime_ms     = 500;
84 static bool cfg_zerocopy;
85
86 static socklen_t cfg_alen;
87 static struct sockaddr_storage cfg_dst_addr;
88 static struct sockaddr_storage cfg_src_addr;
89
90 static char payload[IP_MAXPACKET];
91 static long packets, bytes, completions, expected_completions;
92 static int  zerocopied = -1;
93 static uint32_t next_completion;
94
95 static unsigned long gettimeofday_ms(void)
96 {
97         struct timeval tv;
98
99         gettimeofday(&tv, NULL);
100         return (tv.tv_sec * 1000) + (tv.tv_usec / 1000);
101 }
102
103 static uint16_t get_ip_csum(const uint16_t *start, int num_words)
104 {
105         unsigned long sum = 0;
106         int i;
107
108         for (i = 0; i < num_words; i++)
109                 sum += start[i];
110
111         while (sum >> 16)
112                 sum = (sum & 0xFFFF) + (sum >> 16);
113
114         return ~sum;
115 }
116
117 static int do_setcpu(int cpu)
118 {
119         cpu_set_t mask;
120
121         CPU_ZERO(&mask);
122         CPU_SET(cpu, &mask);
123         if (sched_setaffinity(0, sizeof(mask), &mask))
124                 fprintf(stderr, "cpu: unable to pin, may increase variance.\n");
125         else if (cfg_verbose)
126                 fprintf(stderr, "cpu: %u\n", cpu);
127
128         return 0;
129 }
130
131 static void do_setsockopt(int fd, int level, int optname, int val)
132 {
133         if (setsockopt(fd, level, optname, &val, sizeof(val)))
134                 error(1, errno, "setsockopt %d.%d: %d", level, optname, val);
135 }
136
137 static int do_poll(int fd, int events)
138 {
139         struct pollfd pfd;
140         int ret;
141
142         pfd.events = events;
143         pfd.revents = 0;
144         pfd.fd = fd;
145
146         ret = poll(&pfd, 1, cfg_waittime_ms);
147         if (ret == -1)
148                 error(1, errno, "poll");
149
150         return ret && (pfd.revents & events);
151 }
152
153 static int do_accept(int fd)
154 {
155         int fda = fd;
156
157         fd = accept(fda, NULL, NULL);
158         if (fd == -1)
159                 error(1, errno, "accept");
160         if (close(fda))
161                 error(1, errno, "close listen sock");
162
163         return fd;
164 }
165
166 static bool do_sendmsg(int fd, struct msghdr *msg, bool do_zerocopy)
167 {
168         int ret, len, i, flags;
169
170         len = 0;
171         for (i = 0; i < msg->msg_iovlen; i++)
172                 len += msg->msg_iov[i].iov_len;
173
174         flags = MSG_DONTWAIT;
175         if (do_zerocopy)
176                 flags |= MSG_ZEROCOPY;
177
178         ret = sendmsg(fd, msg, flags);
179         if (ret == -1 && errno == EAGAIN)
180                 return false;
181         if (ret == -1)
182                 error(1, errno, "send");
183         if (cfg_verbose && ret != len)
184                 fprintf(stderr, "send: ret=%u != %u\n", ret, len);
185
186         if (len) {
187                 packets++;
188                 bytes += ret;
189                 if (do_zerocopy && ret)
190                         expected_completions++;
191         }
192
193         return true;
194 }
195
196 static void do_sendmsg_corked(int fd, struct msghdr *msg)
197 {
198         bool do_zerocopy = cfg_zerocopy;
199         int i, payload_len, extra_len;
200
201         /* split up the packet. for non-multiple, make first buffer longer */
202         payload_len = cfg_payload_len / cfg_cork;
203         extra_len = cfg_payload_len - (cfg_cork * payload_len);
204
205         do_setsockopt(fd, IPPROTO_UDP, UDP_CORK, 1);
206
207         for (i = 0; i < cfg_cork; i++) {
208
209                 /* in mixed-frags mode, alternate zerocopy and copy frags
210                  * start with non-zerocopy, to ensure attach later works
211                  */
212                 if (cfg_cork_mixed)
213                         do_zerocopy = (i & 1);
214
215                 msg->msg_iov[0].iov_len = payload_len + extra_len;
216                 extra_len = 0;
217
218                 do_sendmsg(fd, msg, do_zerocopy);
219         }
220
221         do_setsockopt(fd, IPPROTO_UDP, UDP_CORK, 0);
222 }
223
224 static int setup_iph(struct iphdr *iph, uint16_t payload_len)
225 {
226         struct sockaddr_in *daddr = (void *) &cfg_dst_addr;
227         struct sockaddr_in *saddr = (void *) &cfg_src_addr;
228
229         memset(iph, 0, sizeof(*iph));
230
231         iph->version    = 4;
232         iph->tos        = 0;
233         iph->ihl        = 5;
234         iph->ttl        = 2;
235         iph->saddr      = saddr->sin_addr.s_addr;
236         iph->daddr      = daddr->sin_addr.s_addr;
237         iph->protocol   = IPPROTO_EGP;
238         iph->tot_len    = htons(sizeof(*iph) + payload_len);
239         iph->check      = get_ip_csum((void *) iph, iph->ihl << 1);
240
241         return sizeof(*iph);
242 }
243
244 static int setup_ip6h(struct ipv6hdr *ip6h, uint16_t payload_len)
245 {
246         struct sockaddr_in6 *daddr = (void *) &cfg_dst_addr;
247         struct sockaddr_in6 *saddr = (void *) &cfg_src_addr;
248
249         memset(ip6h, 0, sizeof(*ip6h));
250
251         ip6h->version           = 6;
252         ip6h->payload_len       = htons(payload_len);
253         ip6h->nexthdr           = IPPROTO_EGP;
254         ip6h->hop_limit         = 2;
255         ip6h->saddr             = saddr->sin6_addr;
256         ip6h->daddr             = daddr->sin6_addr;
257
258         return sizeof(*ip6h);
259 }
260
261
262 static void setup_sockaddr(int domain, const char *str_addr,
263                            struct sockaddr_storage *sockaddr)
264 {
265         struct sockaddr_in6 *addr6 = (void *) sockaddr;
266         struct sockaddr_in *addr4 = (void *) sockaddr;
267
268         switch (domain) {
269         case PF_INET:
270                 memset(addr4, 0, sizeof(*addr4));
271                 addr4->sin_family = AF_INET;
272                 addr4->sin_port = htons(cfg_port);
273                 if (str_addr &&
274                     inet_pton(AF_INET, str_addr, &(addr4->sin_addr)) != 1)
275                         error(1, 0, "ipv4 parse error: %s", str_addr);
276                 break;
277         case PF_INET6:
278                 memset(addr6, 0, sizeof(*addr6));
279                 addr6->sin6_family = AF_INET6;
280                 addr6->sin6_port = htons(cfg_port);
281                 if (str_addr &&
282                     inet_pton(AF_INET6, str_addr, &(addr6->sin6_addr)) != 1)
283                         error(1, 0, "ipv6 parse error: %s", str_addr);
284                 break;
285         default:
286                 error(1, 0, "illegal domain");
287         }
288 }
289
290 static int do_setup_tx(int domain, int type, int protocol)
291 {
292         int fd;
293
294         fd = socket(domain, type, protocol);
295         if (fd == -1)
296                 error(1, errno, "socket t");
297
298         do_setsockopt(fd, SOL_SOCKET, SO_SNDBUF, 1 << 21);
299         if (cfg_zerocopy)
300                 do_setsockopt(fd, SOL_SOCKET, SO_ZEROCOPY, 1);
301
302         if (domain != PF_PACKET)
303                 if (connect(fd, (void *) &cfg_dst_addr, cfg_alen))
304                         error(1, errno, "connect");
305
306         return fd;
307 }
308
309 static bool do_recv_completion(int fd)
310 {
311         struct sock_extended_err *serr;
312         struct msghdr msg = {};
313         struct cmsghdr *cm;
314         uint32_t hi, lo, range;
315         int ret, zerocopy;
316         char control[100];
317
318         msg.msg_control = control;
319         msg.msg_controllen = sizeof(control);
320
321         ret = recvmsg(fd, &msg, MSG_ERRQUEUE);
322         if (ret == -1 && errno == EAGAIN)
323                 return false;
324         if (ret == -1)
325                 error(1, errno, "recvmsg notification");
326         if (msg.msg_flags & MSG_CTRUNC)
327                 error(1, errno, "recvmsg notification: truncated");
328
329         cm = CMSG_FIRSTHDR(&msg);
330         if (!cm)
331                 error(1, 0, "cmsg: no cmsg");
332         if (!((cm->cmsg_level == SOL_IP && cm->cmsg_type == IP_RECVERR) ||
333               (cm->cmsg_level == SOL_IPV6 && cm->cmsg_type == IPV6_RECVERR) ||
334               (cm->cmsg_level == SOL_PACKET && cm->cmsg_type == PACKET_TX_TIMESTAMP)))
335                 error(1, 0, "serr: wrong type: %d.%d",
336                       cm->cmsg_level, cm->cmsg_type);
337
338         serr = (void *) CMSG_DATA(cm);
339         if (serr->ee_origin != SO_EE_ORIGIN_ZEROCOPY)
340                 error(1, 0, "serr: wrong origin: %u", serr->ee_origin);
341         if (serr->ee_errno != 0)
342                 error(1, 0, "serr: wrong error code: %u", serr->ee_errno);
343
344         hi = serr->ee_data;
345         lo = serr->ee_info;
346         range = hi - lo + 1;
347
348         /* Detect notification gaps. These should not happen often, if at all.
349          * Gaps can occur due to drops, reordering and retransmissions.
350          */
351         if (lo != next_completion)
352                 fprintf(stderr, "gap: %u..%u does not append to %u\n",
353                         lo, hi, next_completion);
354         next_completion = hi + 1;
355
356         zerocopy = !(serr->ee_code & SO_EE_CODE_ZEROCOPY_COPIED);
357         if (zerocopied == -1)
358                 zerocopied = zerocopy;
359         else if (zerocopied != zerocopy) {
360                 fprintf(stderr, "serr: inconsistent\n");
361                 zerocopied = zerocopy;
362         }
363
364         if (cfg_verbose >= 2)
365                 fprintf(stderr, "completed: %u (h=%u l=%u)\n",
366                         range, hi, lo);
367
368         completions += range;
369         return true;
370 }
371
372 /* Read all outstanding messages on the errqueue */
373 static void do_recv_completions(int fd)
374 {
375         while (do_recv_completion(fd)) {}
376 }
377
378 /* Wait for all remaining completions on the errqueue */
379 static void do_recv_remaining_completions(int fd)
380 {
381         int64_t tstop = gettimeofday_ms() + cfg_waittime_ms;
382
383         while (completions < expected_completions &&
384                gettimeofday_ms() < tstop) {
385                 if (do_poll(fd, POLLERR))
386                         do_recv_completions(fd);
387         }
388
389         if (completions < expected_completions)
390                 fprintf(stderr, "missing notifications: %lu < %lu\n",
391                         completions, expected_completions);
392 }
393
394 static void do_tx(int domain, int type, int protocol)
395 {
396         struct iovec iov[3] = { {0} };
397         struct sockaddr_ll laddr;
398         struct msghdr msg = {0};
399         struct ethhdr eth;
400         union {
401                 struct ipv6hdr ip6h;
402                 struct iphdr iph;
403         } nh;
404         uint64_t tstop;
405         int fd;
406
407         fd = do_setup_tx(domain, type, protocol);
408
409         if (domain == PF_PACKET) {
410                 uint16_t proto = cfg_family == PF_INET ? ETH_P_IP : ETH_P_IPV6;
411
412                 /* sock_raw passes ll header as data */
413                 if (type == SOCK_RAW) {
414                         memset(eth.h_dest, 0x06, ETH_ALEN);
415                         memset(eth.h_source, 0x02, ETH_ALEN);
416                         eth.h_proto = htons(proto);
417                         iov[0].iov_base = &eth;
418                         iov[0].iov_len = sizeof(eth);
419                         msg.msg_iovlen++;
420                 }
421
422                 /* both sock_raw and sock_dgram expect name */
423                 memset(&laddr, 0, sizeof(laddr));
424                 laddr.sll_family        = AF_PACKET;
425                 laddr.sll_ifindex       = cfg_ifindex;
426                 laddr.sll_protocol      = htons(proto);
427                 laddr.sll_halen         = ETH_ALEN;
428
429                 memset(laddr.sll_addr, 0x06, ETH_ALEN);
430
431                 msg.msg_name            = &laddr;
432                 msg.msg_namelen         = sizeof(laddr);
433         }
434
435         /* packet and raw sockets with hdrincl must pass network header */
436         if (domain == PF_PACKET || protocol == IPPROTO_RAW) {
437                 if (cfg_family == PF_INET)
438                         iov[1].iov_len = setup_iph(&nh.iph, cfg_payload_len);
439                 else
440                         iov[1].iov_len = setup_ip6h(&nh.ip6h, cfg_payload_len);
441
442                 iov[1].iov_base = (void *) &nh;
443                 msg.msg_iovlen++;
444         }
445
446         iov[2].iov_base = payload;
447         iov[2].iov_len = cfg_payload_len;
448         msg.msg_iovlen++;
449         msg.msg_iov = &iov[3 - msg.msg_iovlen];
450
451         tstop = gettimeofday_ms() + cfg_runtime_ms;
452         do {
453                 if (cfg_cork)
454                         do_sendmsg_corked(fd, &msg);
455                 else
456                         do_sendmsg(fd, &msg, cfg_zerocopy);
457
458                 while (!do_poll(fd, POLLOUT)) {
459                         if (cfg_zerocopy)
460                                 do_recv_completions(fd);
461                 }
462
463         } while (gettimeofday_ms() < tstop);
464
465         if (cfg_zerocopy)
466                 do_recv_remaining_completions(fd);
467
468         if (close(fd))
469                 error(1, errno, "close");
470
471         fprintf(stderr, "tx=%lu (%lu MB) txc=%lu zc=%c\n",
472                 packets, bytes >> 20, completions,
473                 zerocopied == 1 ? 'y' : 'n');
474 }
475
476 static int do_setup_rx(int domain, int type, int protocol)
477 {
478         int fd;
479
480         /* If tx over PF_PACKET, rx over PF_INET(6)/SOCK_RAW,
481          * to recv the only copy of the packet, not a clone
482          */
483         if (domain == PF_PACKET)
484                 error(1, 0, "Use PF_INET/SOCK_RAW to read");
485
486         if (type == SOCK_RAW && protocol == IPPROTO_RAW)
487                 error(1, 0, "IPPROTO_RAW: not supported on Rx");
488
489         fd = socket(domain, type, protocol);
490         if (fd == -1)
491                 error(1, errno, "socket r");
492
493         do_setsockopt(fd, SOL_SOCKET, SO_RCVBUF, 1 << 21);
494         do_setsockopt(fd, SOL_SOCKET, SO_RCVLOWAT, 1 << 16);
495         do_setsockopt(fd, SOL_SOCKET, SO_REUSEPORT, 1);
496
497         if (bind(fd, (void *) &cfg_dst_addr, cfg_alen))
498                 error(1, errno, "bind");
499
500         if (type == SOCK_STREAM) {
501                 if (listen(fd, 1))
502                         error(1, errno, "listen");
503                 fd = do_accept(fd);
504         }
505
506         return fd;
507 }
508
509 /* Flush all outstanding bytes for the tcp receive queue */
510 static void do_flush_tcp(int fd)
511 {
512         int ret;
513
514         /* MSG_TRUNC flushes up to len bytes */
515         ret = recv(fd, NULL, 1 << 21, MSG_TRUNC | MSG_DONTWAIT);
516         if (ret == -1 && errno == EAGAIN)
517                 return;
518         if (ret == -1)
519                 error(1, errno, "flush");
520         if (!ret)
521                 return;
522
523         packets++;
524         bytes += ret;
525 }
526
527 /* Flush all outstanding datagrams. Verify first few bytes of each. */
528 static void do_flush_datagram(int fd, int type)
529 {
530         int ret, off = 0;
531         char buf[64];
532
533         /* MSG_TRUNC will return full datagram length */
534         ret = recv(fd, buf, sizeof(buf), MSG_DONTWAIT | MSG_TRUNC);
535         if (ret == -1 && errno == EAGAIN)
536                 return;
537
538         /* raw ipv4 return with header, raw ipv6 without */
539         if (cfg_family == PF_INET && type == SOCK_RAW) {
540                 off += sizeof(struct iphdr);
541                 ret -= sizeof(struct iphdr);
542         }
543
544         if (ret == -1)
545                 error(1, errno, "recv");
546         if (ret != cfg_payload_len)
547                 error(1, 0, "recv: ret=%u != %u", ret, cfg_payload_len);
548         if (ret > sizeof(buf) - off)
549                 ret = sizeof(buf) - off;
550         if (memcmp(buf + off, payload, ret))
551                 error(1, 0, "recv: data mismatch");
552
553         packets++;
554         bytes += cfg_payload_len;
555 }
556
557 static void do_rx(int domain, int type, int protocol)
558 {
559         uint64_t tstop;
560         int fd;
561
562         fd = do_setup_rx(domain, type, protocol);
563
564         tstop = gettimeofday_ms() + cfg_runtime_ms;
565         do {
566                 if (type == SOCK_STREAM)
567                         do_flush_tcp(fd);
568                 else
569                         do_flush_datagram(fd, type);
570
571                 do_poll(fd, POLLIN);
572
573         } while (gettimeofday_ms() < tstop);
574
575         if (close(fd))
576                 error(1, errno, "close");
577
578         fprintf(stderr, "rx=%lu (%lu MB)\n", packets, bytes >> 20);
579 }
580
581 static void do_test(int domain, int type, int protocol)
582 {
583         int i;
584
585         if (cfg_cork && (domain == PF_PACKET || type != SOCK_DGRAM))
586                 error(1, 0, "can only cork udp sockets");
587
588         do_setcpu(cfg_cpu);
589
590         for (i = 0; i < IP_MAXPACKET; i++)
591                 payload[i] = 'a' + (i % 26);
592
593         if (cfg_rx)
594                 do_rx(domain, type, protocol);
595         else
596                 do_tx(domain, type, protocol);
597 }
598
599 static void usage(const char *filepath)
600 {
601         error(1, 0, "Usage: %s [options] <test>", filepath);
602 }
603
604 static void parse_opts(int argc, char **argv)
605 {
606         const int max_payload_len = sizeof(payload) -
607                                     sizeof(struct ipv6hdr) -
608                                     sizeof(struct tcphdr) -
609                                     40 /* max tcp options */;
610         int c;
611         char *daddr = NULL, *saddr = NULL;
612
613         cfg_payload_len = max_payload_len;
614
615         while ((c = getopt(argc, argv, "46c:C:D:i:mp:rs:S:t:vz")) != -1) {
616                 switch (c) {
617                 case '4':
618                         if (cfg_family != PF_UNSPEC)
619                                 error(1, 0, "Pass one of -4 or -6");
620                         cfg_family = PF_INET;
621                         cfg_alen = sizeof(struct sockaddr_in);
622                         break;
623                 case '6':
624                         if (cfg_family != PF_UNSPEC)
625                                 error(1, 0, "Pass one of -4 or -6");
626                         cfg_family = PF_INET6;
627                         cfg_alen = sizeof(struct sockaddr_in6);
628                         break;
629                 case 'c':
630                         cfg_cork = strtol(optarg, NULL, 0);
631                         break;
632                 case 'C':
633                         cfg_cpu = strtol(optarg, NULL, 0);
634                         break;
635                 case 'D':
636                         daddr = optarg;
637                         break;
638                 case 'i':
639                         cfg_ifindex = if_nametoindex(optarg);
640                         if (cfg_ifindex == 0)
641                                 error(1, errno, "invalid iface: %s", optarg);
642                         break;
643                 case 'm':
644                         cfg_cork_mixed = true;
645                         break;
646                 case 'p':
647                         cfg_port = strtoul(optarg, NULL, 0);
648                         break;
649                 case 'r':
650                         cfg_rx = true;
651                         break;
652                 case 's':
653                         cfg_payload_len = strtoul(optarg, NULL, 0);
654                         break;
655                 case 'S':
656                         saddr = optarg;
657                         break;
658                 case 't':
659                         cfg_runtime_ms = 200 + strtoul(optarg, NULL, 10) * 1000;
660                         break;
661                 case 'v':
662                         cfg_verbose++;
663                         break;
664                 case 'z':
665                         cfg_zerocopy = true;
666                         break;
667                 }
668         }
669         setup_sockaddr(cfg_family, daddr, &cfg_dst_addr);
670         setup_sockaddr(cfg_family, saddr, &cfg_src_addr);
671
672         if (cfg_payload_len > max_payload_len)
673                 error(1, 0, "-s: payload exceeds max (%d)", max_payload_len);
674         if (cfg_cork_mixed && (!cfg_zerocopy || !cfg_cork))
675                 error(1, 0, "-m: cork_mixed requires corking and zerocopy");
676
677         if (optind != argc - 1)
678                 usage(argv[0]);
679 }
680
681 int main(int argc, char **argv)
682 {
683         const char *cfg_test;
684
685         parse_opts(argc, argv);
686
687         cfg_test = argv[argc - 1];
688
689         if (!strcmp(cfg_test, "packet"))
690                 do_test(PF_PACKET, SOCK_RAW, 0);
691         else if (!strcmp(cfg_test, "packet_dgram"))
692                 do_test(PF_PACKET, SOCK_DGRAM, 0);
693         else if (!strcmp(cfg_test, "raw"))
694                 do_test(cfg_family, SOCK_RAW, IPPROTO_EGP);
695         else if (!strcmp(cfg_test, "raw_hdrincl"))
696                 do_test(cfg_family, SOCK_RAW, IPPROTO_RAW);
697         else if (!strcmp(cfg_test, "tcp"))
698                 do_test(cfg_family, SOCK_STREAM, 0);
699         else if (!strcmp(cfg_test, "udp"))
700                 do_test(cfg_family, SOCK_DGRAM, 0);
701         else
702                 error(1, 0, "unknown cfg_test %s", cfg_test);
703
704         return 0;
705 }