udp6_usrreq.c revision 1.139 1 /* $NetBSD: udp6_usrreq.c,v 1.139 2018/04/12 06:49:39 maxv Exp $ */
2 /* $KAME: udp6_usrreq.c,v 1.86 2001/05/27 17:33:00 itojun Exp $ */
3 /* $KAME: udp6_output.c,v 1.43 2001/10/15 09:19:52 itojun Exp $ */
4
5 /*
6 * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
7 * All rights reserved.
8 *
9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions
11 * are met:
12 * 1. Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer.
14 * 2. Redistributions in binary form must reproduce the above copyright
15 * notice, this list of conditions and the following disclaimer in the
16 * documentation and/or other materials provided with the distribution.
17 * 3. Neither the name of the project nor the names of its contributors
18 * may be used to endorse or promote products derived from this software
19 * without specific prior written permission.
20 *
21 * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
22 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24 * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
25 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
27 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31 * SUCH DAMAGE.
32 */
33
34 /*
35 * Copyright (c) 1982, 1986, 1989, 1993
36 * The Regents of the University of California. All rights reserved.
37 *
38 * Redistribution and use in source and binary forms, with or without
39 * modification, are permitted provided that the following conditions
40 * are met:
41 * 1. Redistributions of source code must retain the above copyright
42 * notice, this list of conditions and the following disclaimer.
43 * 2. Redistributions in binary form must reproduce the above copyright
44 * notice, this list of conditions and the following disclaimer in the
45 * documentation and/or other materials provided with the distribution.
46 * 3. Neither the name of the University nor the names of its contributors
47 * may be used to endorse or promote products derived from this software
48 * without specific prior written permission.
49 *
50 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
51 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
52 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
53 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
54 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
55 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
56 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
57 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
58 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
59 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
60 * SUCH DAMAGE.
61 *
62 * @(#)udp_var.h 8.1 (Berkeley) 6/10/93
63 */
64
65 #include <sys/cdefs.h>
66 __KERNEL_RCSID(0, "$NetBSD: udp6_usrreq.c,v 1.139 2018/04/12 06:49:39 maxv Exp $");
67
68 #ifdef _KERNEL_OPT
69 #include "opt_inet.h"
70 #include "opt_inet_csum.h"
71 #include "opt_ipsec.h"
72 #include "opt_net_mpsafe.h"
73 #endif
74
75 #include <sys/param.h>
76 #include <sys/mbuf.h>
77 #include <sys/protosw.h>
78 #include <sys/socket.h>
79 #include <sys/socketvar.h>
80 #include <sys/systm.h>
81 #include <sys/proc.h>
82 #include <sys/syslog.h>
83 #include <sys/domain.h>
84 #include <sys/sysctl.h>
85
86 #include <net/if.h>
87 #include <net/if_types.h>
88
89 #include <netinet/in.h>
90 #include <netinet/in_var.h>
91 #include <netinet/in_systm.h>
92 #include <netinet/in_offload.h>
93 #include <netinet/ip.h>
94 #include <netinet/ip_var.h>
95 #include <netinet/in_pcb.h>
96 #include <netinet/udp.h>
97 #include <netinet/udp_var.h>
98 #include <netinet/udp_private.h>
99
100 #include <netinet/ip6.h>
101 #include <netinet/icmp6.h>
102 #include <netinet6/ip6_var.h>
103 #include <netinet6/ip6_private.h>
104 #include <netinet6/in6_pcb.h>
105 #include <netinet6/udp6_var.h>
106 #include <netinet6/udp6_private.h>
107 #include <netinet6/ip6protosw.h>
108 #include <netinet6/scope6_var.h>
109
110 #ifdef IPSEC
111 #include <netipsec/ipsec.h>
112 #include <netipsec/ipsec_var.h>
113 #ifdef INET6
114 #include <netipsec/ipsec6.h>
115 #endif
116 #endif
117
118 #include "faith.h"
119 #if defined(NFAITH) && NFAITH > 0
120 #include <net/if_faith.h>
121 #endif
122
123 /*
124 * UDP protocol implementation.
125 * Per RFC 768, August, 1980.
126 */
127
128 extern struct inpcbtable udbtable;
129
130 percpu_t *udp6stat_percpu;
131
132 /* UDP on IP6 parameters */
133 static int udp6_sendspace = 9216; /* really max datagram size */
134 static int udp6_recvspace = 40 * (1024 + sizeof(struct sockaddr_in6));
135 /* 40 1K datagrams */
136
137 static void udp6_notify(struct in6pcb *, int);
138 static void sysctl_net_inet6_udp6_setup(struct sysctllog **);
139
140 #ifdef UDP_CSUM_COUNTERS
141 #include <sys/device.h>
142 struct evcnt udp6_hwcsum_bad = EVCNT_INITIALIZER(EVCNT_TYPE_MISC,
143 NULL, "udp6", "hwcsum bad");
144 struct evcnt udp6_hwcsum_ok = EVCNT_INITIALIZER(EVCNT_TYPE_MISC,
145 NULL, "udp6", "hwcsum ok");
146 struct evcnt udp6_hwcsum_data = EVCNT_INITIALIZER(EVCNT_TYPE_MISC,
147 NULL, "udp6", "hwcsum data");
148 struct evcnt udp6_swcsum = EVCNT_INITIALIZER(EVCNT_TYPE_MISC,
149 NULL, "udp6", "swcsum");
150
151 EVCNT_ATTACH_STATIC(udp6_hwcsum_bad);
152 EVCNT_ATTACH_STATIC(udp6_hwcsum_ok);
153 EVCNT_ATTACH_STATIC(udp6_hwcsum_data);
154 EVCNT_ATTACH_STATIC(udp6_swcsum);
155
156 #define UDP_CSUM_COUNTER_INCR(ev) (ev)->ev_count++
157 #else
158 #define UDP_CSUM_COUNTER_INCR(ev) /* nothing */
159 #endif
160
161 void
162 udp6_init(void)
163 {
164 sysctl_net_inet6_udp6_setup(NULL);
165 udp6stat_percpu = percpu_alloc(sizeof(uint64_t) * UDP6_NSTATS);
166
167 udp_init_common();
168 }
169
170 /*
171 * Notify a udp user of an asynchronous error;
172 * just wake up so that he can collect error status.
173 */
174 static void
175 udp6_notify(struct in6pcb *in6p, int errno)
176 {
177 in6p->in6p_socket->so_error = errno;
178 sorwakeup(in6p->in6p_socket);
179 sowwakeup(in6p->in6p_socket);
180 }
181
182 void *
183 udp6_ctlinput(int cmd, const struct sockaddr *sa, void *d)
184 {
185 struct udphdr uh;
186 struct ip6_hdr *ip6;
187 const struct sockaddr_in6 *sa6 = (const struct sockaddr_in6 *)sa;
188 struct mbuf *m;
189 int off;
190 void *cmdarg;
191 struct ip6ctlparam *ip6cp = NULL;
192 const struct sockaddr_in6 *sa6_src = NULL;
193 void (*notify)(struct in6pcb *, int) = udp6_notify;
194 struct udp_portonly {
195 u_int16_t uh_sport;
196 u_int16_t uh_dport;
197 } *uhp;
198
199 if (sa->sa_family != AF_INET6 ||
200 sa->sa_len != sizeof(struct sockaddr_in6))
201 return NULL;
202
203 if ((unsigned)cmd >= PRC_NCMDS)
204 return NULL;
205 if (PRC_IS_REDIRECT(cmd))
206 notify = in6_rtchange, d = NULL;
207 else if (cmd == PRC_HOSTDEAD)
208 d = NULL;
209 else if (cmd == PRC_MSGSIZE) {
210 /* special code is present, see below */
211 notify = in6_rtchange;
212 }
213 else if (inet6ctlerrmap[cmd] == 0)
214 return NULL;
215
216 /* if the parameter is from icmp6, decode it. */
217 if (d != NULL) {
218 ip6cp = (struct ip6ctlparam *)d;
219 m = ip6cp->ip6c_m;
220 ip6 = ip6cp->ip6c_ip6;
221 off = ip6cp->ip6c_off;
222 cmdarg = ip6cp->ip6c_cmdarg;
223 sa6_src = ip6cp->ip6c_src;
224 } else {
225 m = NULL;
226 ip6 = NULL;
227 cmdarg = NULL;
228 sa6_src = &sa6_any;
229 off = 0;
230 }
231
232 if (ip6) {
233 /*
234 * XXX: We assume that when IPV6 is non NULL,
235 * M and OFF are valid.
236 */
237
238 /* check if we can safely examine src and dst ports */
239 if (m->m_pkthdr.len < off + sizeof(*uhp)) {
240 if (cmd == PRC_MSGSIZE)
241 icmp6_mtudisc_update((struct ip6ctlparam *)d, 0);
242 return NULL;
243 }
244
245 memset(&uh, 0, sizeof(uh));
246 m_copydata(m, off, sizeof(*uhp), (void *)&uh);
247
248 if (cmd == PRC_MSGSIZE) {
249 int valid = 0;
250
251 /*
252 * Check to see if we have a valid UDP socket
253 * corresponding to the address in the ICMPv6 message
254 * payload.
255 */
256 if (in6_pcblookup_connect(&udbtable, &sa6->sin6_addr,
257 uh.uh_dport, (const struct in6_addr *)&sa6_src->sin6_addr,
258 uh.uh_sport, 0, 0))
259 valid++;
260 #if 0
261 /*
262 * As the use of sendto(2) is fairly popular,
263 * we may want to allow non-connected pcb too.
264 * But it could be too weak against attacks...
265 * We should at least check if the local address (= s)
266 * is really ours.
267 */
268 else if (in6_pcblookup_bind(&udbtable, &sa6->sin6_addr,
269 uh.uh_dport, 0))
270 valid++;
271 #endif
272
273 /*
274 * Depending on the value of "valid" and routing table
275 * size (mtudisc_{hi,lo}wat), we will:
276 * - recalculate the new MTU and create the
277 * corresponding routing entry, or
278 * - ignore the MTU change notification.
279 */
280 icmp6_mtudisc_update((struct ip6ctlparam *)d, valid);
281
282 /*
283 * regardless of if we called
284 * icmp6_mtudisc_update(), we need to call
285 * in6_pcbnotify(), to notify path MTU change
286 * to the userland (RFC3542), because some
287 * unconnected sockets may share the same
288 * destination and want to know the path MTU.
289 */
290 }
291
292 (void)in6_pcbnotify(&udbtable, sa, uh.uh_dport,
293 sin6tocsa(sa6_src), uh.uh_sport, cmd, cmdarg,
294 notify);
295 } else {
296 (void)in6_pcbnotify(&udbtable, sa, 0,
297 sin6tocsa(sa6_src), 0, cmd, cmdarg, notify);
298 }
299 return NULL;
300 }
301
302 int
303 udp6_ctloutput(int op, struct socket *so, struct sockopt *sopt)
304 {
305 int s;
306 int error = 0;
307 int family;
308
309 family = so->so_proto->pr_domain->dom_family;
310
311 s = splsoftnet();
312 switch (family) {
313 #ifdef INET
314 case PF_INET:
315 if (sopt->sopt_level != IPPROTO_UDP) {
316 error = ip_ctloutput(op, so, sopt);
317 goto end;
318 }
319 break;
320 #endif
321 #ifdef INET6
322 case PF_INET6:
323 if (sopt->sopt_level != IPPROTO_UDP) {
324 error = ip6_ctloutput(op, so, sopt);
325 goto end;
326 }
327 break;
328 #endif
329 default:
330 error = EAFNOSUPPORT;
331 goto end;
332 }
333 error = EINVAL;
334
335 end:
336 splx(s);
337 return error;
338 }
339
340 static void
341 udp6_sendup(struct mbuf *m, int off /* offset of data portion */,
342 struct sockaddr *src, struct socket *so)
343 {
344 struct mbuf *opts = NULL;
345 struct mbuf *n;
346 struct in6pcb *in6p;
347
348 KASSERT(so != NULL);
349 KASSERT(so->so_proto->pr_domain->dom_family == AF_INET6);
350 in6p = sotoin6pcb(so);
351 KASSERT(in6p != NULL);
352
353 #if defined(IPSEC)
354 if (ipsec_used && ipsec_in_reject(m, in6p)) {
355 if ((n = m_copypacket(m, M_DONTWAIT)) != NULL)
356 icmp6_error(n, ICMP6_DST_UNREACH,
357 ICMP6_DST_UNREACH_ADMIN, 0);
358 return;
359 }
360 #endif
361
362 if ((n = m_copypacket(m, M_DONTWAIT)) != NULL) {
363 if (in6p->in6p_flags & IN6P_CONTROLOPTS ||
364 SOOPT_TIMESTAMP(in6p->in6p_socket->so_options)) {
365 struct ip6_hdr *ip6 = mtod(n, struct ip6_hdr *);
366 ip6_savecontrol(in6p, &opts, ip6, n);
367 }
368
369 m_adj(n, off);
370 if (sbappendaddr(&so->so_rcv, src, n, opts) == 0) {
371 m_freem(n);
372 if (opts)
373 m_freem(opts);
374 UDP6_STATINC(UDP6_STAT_FULLSOCK);
375 soroverflow(so);
376 } else
377 sorwakeup(so);
378 }
379 }
380
381 int
382 udp6_realinput(int af, struct sockaddr_in6 *src, struct sockaddr_in6 *dst,
383 struct mbuf *m, int off)
384 {
385 u_int16_t sport, dport;
386 int rcvcnt;
387 struct in6_addr src6, *dst6;
388 const struct in_addr *dst4;
389 struct inpcb_hdr *inph;
390 struct in6pcb *in6p;
391
392 rcvcnt = 0;
393 off += sizeof(struct udphdr); /* now, offset of payload */
394
395 if (af != AF_INET && af != AF_INET6)
396 goto bad;
397 if (src->sin6_family != AF_INET6 || dst->sin6_family != AF_INET6)
398 goto bad;
399
400 src6 = src->sin6_addr;
401 if (sa6_recoverscope(src) != 0) {
402 /* XXX: should be impossible. */
403 goto bad;
404 }
405 sport = src->sin6_port;
406
407 dport = dst->sin6_port;
408 dst4 = (struct in_addr *)&dst->sin6_addr.s6_addr[12];
409 dst6 = &dst->sin6_addr;
410
411 if (IN6_IS_ADDR_MULTICAST(dst6) ||
412 (af == AF_INET && IN_MULTICAST(dst4->s_addr))) {
413 /*
414 * Deliver a multicast or broadcast datagram to *all* sockets
415 * for which the local and remote addresses and ports match
416 * those of the incoming datagram. This allows more than
417 * one process to receive multi/broadcasts on the same port.
418 * (This really ought to be done for unicast datagrams as
419 * well, but that would cause problems with existing
420 * applications that open both address-specific sockets and
421 * a wildcard socket listening to the same port -- they would
422 * end up receiving duplicates of every unicast datagram.
423 * Those applications open the multiple sockets to overcome an
424 * inadequacy of the UDP socket interface, but for backwards
425 * compatibility we avoid the problem here rather than
426 * fixing the interface. Maybe 4.5BSD will remedy this?)
427 */
428
429 /*
430 * KAME note: traditionally we dropped udpiphdr from mbuf here.
431 * we need udpiphdr for IPsec processing so we do that later.
432 */
433 /*
434 * Locate pcb(s) for datagram.
435 */
436 TAILQ_FOREACH(inph, &udbtable.inpt_queue, inph_queue) {
437 in6p = (struct in6pcb *)inph;
438 if (in6p->in6p_af != AF_INET6)
439 continue;
440
441 if (in6p->in6p_lport != dport)
442 continue;
443 if (!IN6_IS_ADDR_UNSPECIFIED(&in6p->in6p_laddr)) {
444 if (!IN6_ARE_ADDR_EQUAL(&in6p->in6p_laddr,
445 dst6))
446 continue;
447 } else {
448 if (IN6_IS_ADDR_V4MAPPED(dst6) &&
449 (in6p->in6p_flags & IN6P_IPV6_V6ONLY))
450 continue;
451 }
452 if (!IN6_IS_ADDR_UNSPECIFIED(&in6p->in6p_faddr)) {
453 if (!IN6_ARE_ADDR_EQUAL(&in6p->in6p_faddr,
454 &src6) || in6p->in6p_fport != sport)
455 continue;
456 } else {
457 if (IN6_IS_ADDR_V4MAPPED(&src6) &&
458 (in6p->in6p_flags & IN6P_IPV6_V6ONLY))
459 continue;
460 }
461
462 udp6_sendup(m, off, sin6tosa(src), in6p->in6p_socket);
463 rcvcnt++;
464
465 /*
466 * Don't look for additional matches if this one does
467 * not have either the SO_REUSEPORT or SO_REUSEADDR
468 * socket options set. This heuristic avoids searching
469 * through all pcbs in the common case of a non-shared
470 * port. It assumes that an application will never
471 * clear these options after setting them.
472 */
473 if ((in6p->in6p_socket->so_options &
474 (SO_REUSEPORT|SO_REUSEADDR)) == 0)
475 break;
476 }
477 } else {
478 /*
479 * Locate pcb for datagram.
480 */
481 in6p = in6_pcblookup_connect(&udbtable, &src6, sport, dst6,
482 dport, 0, 0);
483 if (in6p == 0) {
484 UDP_STATINC(UDP_STAT_PCBHASHMISS);
485 in6p = in6_pcblookup_bind(&udbtable, dst6, dport, 0);
486 if (in6p == 0)
487 return rcvcnt;
488 }
489
490 udp6_sendup(m, off, sin6tosa(src), in6p->in6p_socket);
491 rcvcnt++;
492 }
493
494 bad:
495 return rcvcnt;
496 }
497
498 int
499 udp6_input_checksum(struct mbuf *m, const struct udphdr *uh, int off, int len)
500 {
501
502 /*
503 * XXX it's better to record and check if this mbuf is
504 * already checked.
505 */
506
507 if (__predict_false((m->m_flags & M_LOOP) && !udp_do_loopback_cksum)) {
508 goto good;
509 }
510 if (uh->uh_sum == 0) {
511 UDP6_STATINC(UDP6_STAT_NOSUM);
512 goto bad;
513 }
514
515 switch (m->m_pkthdr.csum_flags &
516 ((m_get_rcvif_NOMPSAFE(m)->if_csum_flags_rx & M_CSUM_UDPv6) |
517 M_CSUM_TCP_UDP_BAD | M_CSUM_DATA)) {
518 case M_CSUM_UDPv6|M_CSUM_TCP_UDP_BAD:
519 UDP_CSUM_COUNTER_INCR(&udp6_hwcsum_bad);
520 UDP6_STATINC(UDP6_STAT_BADSUM);
521 goto bad;
522
523 #if 0 /* notyet */
524 case M_CSUM_UDPv6|M_CSUM_DATA:
525 #endif
526
527 case M_CSUM_UDPv6:
528 /* Checksum was okay. */
529 UDP_CSUM_COUNTER_INCR(&udp6_hwcsum_ok);
530 break;
531
532 default:
533 /*
534 * Need to compute it ourselves. Maybe skip checksum
535 * on loopback interfaces.
536 */
537 UDP_CSUM_COUNTER_INCR(&udp6_swcsum);
538 if (in6_cksum(m, IPPROTO_UDP, off, len) != 0) {
539 UDP6_STATINC(UDP6_STAT_BADSUM);
540 goto bad;
541 }
542 }
543
544 good:
545 return 0;
546 bad:
547 return -1;
548 }
549
550 int
551 udp6_input(struct mbuf **mp, int *offp, int proto)
552 {
553 struct mbuf *m = *mp;
554 int off = *offp;
555 struct sockaddr_in6 src, dst;
556 struct ip6_hdr *ip6;
557 struct udphdr *uh;
558 u_int32_t plen, ulen;
559
560 ip6 = mtod(m, struct ip6_hdr *);
561
562 #if defined(NFAITH) && 0 < NFAITH
563 if (faithprefix(&ip6->ip6_dst)) {
564 /* send icmp6 host unreach? */
565 m_freem(m);
566 return IPPROTO_DONE;
567 }
568 #endif
569
570 UDP6_STATINC(UDP6_STAT_IPACKETS);
571
572 /* Check for jumbogram is done in ip6_input. We can trust pkthdr.len. */
573 plen = m->m_pkthdr.len - off;
574 IP6_EXTHDR_GET(uh, struct udphdr *, m, off, sizeof(struct udphdr));
575 if (uh == NULL) {
576 IP6_STATINC(IP6_STAT_TOOSHORT);
577 return IPPROTO_DONE;
578 }
579
580 /*
581 * Enforce alignment requirements that are violated in
582 * some cases, see kern/50766 for details.
583 */
584 if (UDP_HDR_ALIGNED_P(uh) == 0) {
585 m = m_copyup(m, off + sizeof(struct udphdr), 0);
586 if (m == NULL) {
587 IP6_STATINC(IP6_STAT_TOOSHORT);
588 return IPPROTO_DONE;
589 }
590 ip6 = mtod(m, struct ip6_hdr *);
591 uh = (struct udphdr *)(mtod(m, char *) + off);
592 }
593 KASSERT(UDP_HDR_ALIGNED_P(uh));
594 ulen = ntohs((u_short)uh->uh_ulen);
595
596 /*
597 * RFC2675 section 4: jumbograms will have 0 in the UDP header field,
598 * iff payload length > 0xffff.
599 */
600 if (ulen == 0 && plen > 0xffff)
601 ulen = plen;
602
603 if (plen != ulen) {
604 UDP6_STATINC(UDP6_STAT_BADLEN);
605 goto bad;
606 }
607
608 /* destination port of 0 is illegal, based on RFC768. */
609 if (uh->uh_dport == 0)
610 goto bad;
611
612 /*
613 * Checksum extended UDP header and data. Maybe skip checksum
614 * on loopback interfaces.
615 */
616 if (udp6_input_checksum(m, uh, off, ulen))
617 goto bad;
618
619 /*
620 * Construct source and dst sockaddrs.
621 */
622 memset(&src, 0, sizeof(src));
623 src.sin6_family = AF_INET6;
624 src.sin6_len = sizeof(struct sockaddr_in6);
625 src.sin6_addr = ip6->ip6_src;
626 src.sin6_port = uh->uh_sport;
627 memset(&dst, 0, sizeof(dst));
628 dst.sin6_family = AF_INET6;
629 dst.sin6_len = sizeof(struct sockaddr_in6);
630 dst.sin6_addr = ip6->ip6_dst;
631 dst.sin6_port = uh->uh_dport;
632
633 if (udp6_realinput(AF_INET6, &src, &dst, m, off) == 0) {
634 if (m->m_flags & M_MCAST) {
635 UDP6_STATINC(UDP6_STAT_NOPORTMCAST);
636 goto bad;
637 }
638 UDP6_STATINC(UDP6_STAT_NOPORT);
639 icmp6_error(m, ICMP6_DST_UNREACH, ICMP6_DST_UNREACH_NOPORT, 0);
640 m = NULL;
641 }
642
643 bad:
644 if (m)
645 m_freem(m);
646 return IPPROTO_DONE;
647 }
648
649 int
650 udp6_output(struct in6pcb * const in6p, struct mbuf *m,
651 struct sockaddr_in6 * const addr6, struct mbuf * const control,
652 struct lwp * const l)
653 {
654 u_int32_t ulen = m->m_pkthdr.len;
655 u_int32_t plen = sizeof(struct udphdr) + ulen;
656 struct ip6_hdr *ip6;
657 struct udphdr *udp6;
658 struct in6_addr _laddr, *laddr, *faddr;
659 struct in6_addr laddr_mapped; /* XXX ugly */
660 struct sockaddr_in6 *sin6 = NULL;
661 struct ifnet *oifp = NULL;
662 int scope_ambiguous = 0;
663 u_int16_t fport;
664 int error = 0;
665 struct ip6_pktopts *optp = NULL;
666 struct ip6_pktopts opt;
667 int af = AF_INET6, hlen = sizeof(struct ip6_hdr);
668 #ifdef INET
669 struct ip *ip;
670 struct udpiphdr *ui;
671 int flags = 0;
672 #endif
673 struct sockaddr_in6 tmp;
674
675 if (addr6) {
676 sin6 = addr6;
677 if (sin6->sin6_family != AF_INET6) {
678 error = EAFNOSUPPORT;
679 goto release;
680 }
681
682 /* protect *sin6 from overwrites */
683 tmp = *sin6;
684 sin6 = &tmp;
685
686 /*
687 * Application should provide a proper zone ID or the use of
688 * default zone IDs should be enabled. Unfortunately, some
689 * applications do not behave as it should, so we need a
690 * workaround. Even if an appropriate ID is not determined,
691 * we'll see if we can determine the outgoing interface. If we
692 * can, determine the zone ID based on the interface below.
693 */
694 if (sin6->sin6_scope_id == 0 && !ip6_use_defzone)
695 scope_ambiguous = 1;
696 if ((error = sa6_embedscope(sin6, ip6_use_defzone)) != 0)
697 goto release;
698 }
699
700 if (control) {
701 if (__predict_false(l == NULL)) {
702 panic("%s: control but no lwp", __func__);
703 }
704 if ((error = ip6_setpktopts(control, &opt,
705 in6p->in6p_outputopts, l->l_cred, IPPROTO_UDP)) != 0)
706 goto release;
707 optp = &opt;
708 } else
709 optp = in6p->in6p_outputopts;
710
711
712 if (sin6) {
713 /*
714 * Slightly different than v4 version in that we call
715 * in6_selectsrc and in6_pcbsetport to fill in the local
716 * address and port rather than in_pcbconnect. in_pcbconnect
717 * sets in6p_faddr which causes EISCONN below to be hit on
718 * subsequent sendto.
719 */
720 if (sin6->sin6_port == 0) {
721 error = EADDRNOTAVAIL;
722 goto release;
723 }
724
725 if (!IN6_IS_ADDR_UNSPECIFIED(&in6p->in6p_faddr)) {
726 /* how about ::ffff:0.0.0.0 case? */
727 error = EISCONN;
728 goto release;
729 }
730
731 faddr = &sin6->sin6_addr;
732 fport = sin6->sin6_port; /* allow 0 port */
733
734 if (IN6_IS_ADDR_V4MAPPED(faddr)) {
735 if ((in6p->in6p_flags & IN6P_IPV6_V6ONLY)) {
736 /*
737 * I believe we should explicitly discard the
738 * packet when mapped addresses are disabled,
739 * rather than send the packet as an IPv6 one.
740 * If we chose the latter approach, the packet
741 * might be sent out on the wire based on the
742 * default route, the situation which we'd
743 * probably want to avoid.
744 * (20010421 jinmei (at) kame.net)
745 */
746 error = EINVAL;
747 goto release;
748 }
749 if (!IN6_IS_ADDR_UNSPECIFIED(&in6p->in6p_laddr) &&
750 !IN6_IS_ADDR_V4MAPPED(&in6p->in6p_laddr)) {
751 /*
752 * when remote addr is an IPv4-mapped address,
753 * local addr should not be an IPv6 address,
754 * since you cannot determine how to map IPv6
755 * source address to IPv4.
756 */
757 error = EINVAL;
758 goto release;
759 }
760
761 af = AF_INET;
762 }
763
764 if (!IN6_IS_ADDR_V4MAPPED(faddr)) {
765 struct psref psref;
766 int bound = curlwp_bind();
767
768 error = in6_selectsrc(sin6, optp,
769 in6p->in6p_moptions,
770 &in6p->in6p_route,
771 &in6p->in6p_laddr, &oifp, &psref, &_laddr);
772 /* XXX need error check? */
773 if (oifp && scope_ambiguous &&
774 (error = in6_setscope(&sin6->sin6_addr,
775 oifp, NULL))) {
776 if_put(oifp, &psref);
777 curlwp_bindx(bound);
778 goto release;
779 }
780 if_put(oifp, &psref);
781 curlwp_bindx(bound);
782 laddr = &_laddr;
783 } else {
784 /*
785 * XXX: freebsd[34] does not have in_selectsrc, but
786 * we can omit the whole part because freebsd4 calls
787 * udp_output() directly in this case, and thus we'll
788 * never see this path.
789 */
790 if (IN6_IS_ADDR_UNSPECIFIED(&in6p->in6p_laddr)) {
791 struct sockaddr_in sin_dst;
792 struct in_addr ina;
793 struct in_ifaddr *ia4;
794 struct psref _psref;
795 int bound;
796
797 memcpy(&ina, &faddr->s6_addr[12], sizeof(ina));
798 sockaddr_in_init(&sin_dst, &ina, 0);
799 bound = curlwp_bind();
800 ia4 = in_selectsrc(&sin_dst, &in6p->in6p_route,
801 in6p->in6p_socket->so_options, NULL,
802 &error, &_psref);
803 if (ia4 == NULL) {
804 curlwp_bindx(bound);
805 if (error == 0)
806 error = EADDRNOTAVAIL;
807 goto release;
808 }
809 memset(&laddr_mapped, 0, sizeof(laddr_mapped));
810 laddr_mapped.s6_addr16[5] = 0xffff; /* ugly */
811 memcpy(&laddr_mapped.s6_addr[12],
812 &IA_SIN(ia4)->sin_addr,
813 sizeof(IA_SIN(ia4)->sin_addr));
814 ia4_release(ia4, &_psref);
815 curlwp_bindx(bound);
816 laddr = &laddr_mapped;
817 } else
818 {
819 laddr = &in6p->in6p_laddr; /* XXX */
820 }
821 }
822 if (laddr == NULL) {
823 if (error == 0)
824 error = EADDRNOTAVAIL;
825 goto release;
826 }
827 if (in6p->in6p_lport == 0) {
828 /*
829 * Craft a sockaddr_in6 for the local endpoint. Use the
830 * "any" as a base, set the address, and recover the
831 * scope.
832 */
833 struct sockaddr_in6 lsin6 =
834 *((const struct sockaddr_in6 *)in6p->in6p_socket->so_proto->pr_domain->dom_sa_any);
835 lsin6.sin6_addr = *laddr;
836 error = sa6_recoverscope(&lsin6);
837 if (error)
838 goto release;
839
840 error = in6_pcbsetport(&lsin6, in6p, l);
841
842 if (error) {
843 in6p->in6p_laddr = in6addr_any;
844 goto release;
845 }
846 }
847 } else {
848 if (IN6_IS_ADDR_UNSPECIFIED(&in6p->in6p_faddr)) {
849 error = ENOTCONN;
850 goto release;
851 }
852 if (IN6_IS_ADDR_V4MAPPED(&in6p->in6p_faddr)) {
853 if ((in6p->in6p_flags & IN6P_IPV6_V6ONLY))
854 {
855 /*
856 * XXX: this case would happen when the
857 * application sets the V6ONLY flag after
858 * connecting the foreign address.
859 * Such applications should be fixed,
860 * so we bark here.
861 */
862 log(LOG_INFO, "udp6_output: IPV6_V6ONLY "
863 "option was set for a connected socket\n");
864 error = EINVAL;
865 goto release;
866 } else
867 af = AF_INET;
868 }
869 laddr = &in6p->in6p_laddr;
870 faddr = &in6p->in6p_faddr;
871 fport = in6p->in6p_fport;
872 }
873
874 if (af == AF_INET)
875 hlen = sizeof(struct ip);
876
877 /*
878 * Calculate data length and get a mbuf
879 * for UDP and IP6 headers.
880 */
881 M_PREPEND(m, hlen + sizeof(struct udphdr), M_DONTWAIT);
882 if (m == NULL) {
883 error = ENOBUFS;
884 goto release;
885 }
886
887 /*
888 * Stuff checksum and output datagram.
889 */
890 udp6 = (struct udphdr *)(mtod(m, char *) + hlen);
891 udp6->uh_sport = in6p->in6p_lport; /* lport is always set in the PCB */
892 udp6->uh_dport = fport;
893 if (plen <= 0xffff)
894 udp6->uh_ulen = htons((u_int16_t)plen);
895 else
896 udp6->uh_ulen = 0;
897 udp6->uh_sum = 0;
898
899 switch (af) {
900 case AF_INET6:
901 ip6 = mtod(m, struct ip6_hdr *);
902 ip6->ip6_flow = in6p->in6p_flowinfo & IPV6_FLOWINFO_MASK;
903 ip6->ip6_vfc &= ~IPV6_VERSION_MASK;
904 ip6->ip6_vfc |= IPV6_VERSION;
905 #if 0 /* ip6_plen will be filled in ip6_output. */
906 ip6->ip6_plen = htons((u_int16_t)plen);
907 #endif
908 ip6->ip6_nxt = IPPROTO_UDP;
909 ip6->ip6_hlim = in6_selecthlim_rt(in6p);
910 ip6->ip6_src = *laddr;
911 ip6->ip6_dst = *faddr;
912
913 udp6->uh_sum = in6_cksum_phdr(laddr, faddr,
914 htonl(plen), htonl(IPPROTO_UDP));
915 m->m_pkthdr.csum_flags = M_CSUM_UDPv6;
916 m->m_pkthdr.csum_data = offsetof(struct udphdr, uh_sum);
917
918 UDP6_STATINC(UDP6_STAT_OPACKETS);
919 error = ip6_output(m, optp, &in6p->in6p_route, 0,
920 in6p->in6p_moptions, in6p, NULL);
921 break;
922 case AF_INET:
923 #ifdef INET
924 /* can't transmit jumbogram over IPv4 */
925 if (plen > 0xffff) {
926 error = EMSGSIZE;
927 goto release;
928 }
929
930 ip = mtod(m, struct ip *);
931 ui = (struct udpiphdr *)ip;
932 memset(ui->ui_x1, 0, sizeof(ui->ui_x1));
933 ui->ui_pr = IPPROTO_UDP;
934 ui->ui_len = htons(plen);
935 memcpy(&ui->ui_src, &laddr->s6_addr[12], sizeof(ui->ui_src));
936 ui->ui_ulen = ui->ui_len;
937
938 flags = (in6p->in6p_socket->so_options &
939 (SO_DONTROUTE | SO_BROADCAST));
940 memcpy(&ui->ui_dst, &faddr->s6_addr[12], sizeof(ui->ui_dst));
941
942 udp6->uh_sum = in_cksum(m, hlen + plen);
943 if (udp6->uh_sum == 0)
944 udp6->uh_sum = 0xffff;
945
946 ip->ip_len = htons(hlen + plen);
947 ip->ip_ttl = in6_selecthlim(in6p, NULL); /* XXX */
948 ip->ip_tos = 0; /* XXX */
949
950 UDP_STATINC(UDP_STAT_OPACKETS);
951 error = ip_output(m, NULL, &in6p->in6p_route, flags /* XXX */,
952 in6p->in6p_v4moptions, NULL);
953 break;
954 #else
955 error = EAFNOSUPPORT;
956 goto release;
957 #endif
958 }
959 goto releaseopt;
960
961 release:
962 m_freem(m);
963
964 releaseopt:
965 if (control) {
966 if (optp == &opt)
967 ip6_clearpktopts(&opt, -1);
968 m_freem(control);
969 }
970 return (error);
971 }
972
973 static int
974 udp6_attach(struct socket *so, int proto)
975 {
976 struct in6pcb *in6p;
977 int s, error;
978
979 KASSERT(sotoin6pcb(so) == NULL);
980 sosetlock(so);
981
982 /*
983 * MAPPED_ADDR implementation spec:
984 * Always attach for IPv6, and only when necessary for IPv4.
985 */
986 s = splsoftnet();
987 error = in6_pcballoc(so, &udbtable);
988 splx(s);
989 if (error) {
990 return error;
991 }
992 error = soreserve(so, udp6_sendspace, udp6_recvspace);
993 if (error) {
994 return error;
995 }
996 in6p = sotoin6pcb(so);
997 in6p->in6p_cksum = -1; /* just to be sure */
998
999 KASSERT(solocked(so));
1000 return 0;
1001 }
1002
1003 static void
1004 udp6_detach(struct socket *so)
1005 {
1006 struct in6pcb *in6p = sotoin6pcb(so);
1007 int s;
1008
1009 KASSERT(solocked(so));
1010 KASSERT(in6p != NULL);
1011
1012 s = splsoftnet();
1013 in6_pcbdetach(in6p);
1014 splx(s);
1015 }
1016
1017 static int
1018 udp6_accept(struct socket *so, struct sockaddr *nam)
1019 {
1020 KASSERT(solocked(so));
1021
1022 return EOPNOTSUPP;
1023 }
1024
1025 static int
1026 udp6_bind(struct socket *so, struct sockaddr *nam, struct lwp *l)
1027 {
1028 struct in6pcb *in6p = sotoin6pcb(so);
1029 struct sockaddr_in6 *sin6 = (struct sockaddr_in6 *)nam;
1030 int error = 0;
1031 int s;
1032
1033 KASSERT(solocked(so));
1034 KASSERT(in6p != NULL);
1035
1036 s = splsoftnet();
1037 error = in6_pcbbind(in6p, sin6, l);
1038 splx(s);
1039 return error;
1040 }
1041
1042 static int
1043 udp6_listen(struct socket *so, struct lwp *l)
1044 {
1045 KASSERT(solocked(so));
1046
1047 return EOPNOTSUPP;
1048 }
1049
1050 static int
1051 udp6_connect(struct socket *so, struct sockaddr *nam, struct lwp *l)
1052 {
1053 struct in6pcb *in6p = sotoin6pcb(so);
1054 int error = 0;
1055 int s;
1056
1057 KASSERT(solocked(so));
1058 KASSERT(in6p != NULL);
1059
1060 if (!IN6_IS_ADDR_UNSPECIFIED(&in6p->in6p_faddr))
1061 return EISCONN;
1062 s = splsoftnet();
1063 error = in6_pcbconnect(in6p, (struct sockaddr_in6 *)nam, l);
1064 splx(s);
1065 if (error == 0)
1066 soisconnected(so);
1067
1068 return error;
1069 }
1070
1071 static int
1072 udp6_connect2(struct socket *so, struct socket *so2)
1073 {
1074 KASSERT(solocked(so));
1075
1076 return EOPNOTSUPP;
1077 }
1078
1079 static int
1080 udp6_disconnect(struct socket *so)
1081 {
1082 struct in6pcb *in6p = sotoin6pcb(so);
1083 int s;
1084
1085 KASSERT(solocked(so));
1086 KASSERT(in6p != NULL);
1087
1088 if (IN6_IS_ADDR_UNSPECIFIED(&in6p->in6p_faddr))
1089 return ENOTCONN;
1090
1091 s = splsoftnet();
1092 in6_pcbdisconnect(in6p);
1093 memset((void *)&in6p->in6p_laddr, 0, sizeof(in6p->in6p_laddr));
1094 splx(s);
1095
1096 so->so_state &= ~SS_ISCONNECTED; /* XXX */
1097 in6_pcbstate(in6p, IN6P_BOUND); /* XXX */
1098 return 0;
1099 }
1100
1101 static int
1102 udp6_shutdown(struct socket *so)
1103 {
1104 int s;
1105
1106 s = splsoftnet();
1107 socantsendmore(so);
1108 splx(s);
1109
1110 return 0;
1111 }
1112
1113 static int
1114 udp6_abort(struct socket *so)
1115 {
1116 int s;
1117
1118 KASSERT(solocked(so));
1119 KASSERT(sotoin6pcb(so) != NULL);
1120
1121 s = splsoftnet();
1122 soisdisconnected(so);
1123 in6_pcbdetach(sotoin6pcb(so));
1124 splx(s);
1125
1126 return 0;
1127 }
1128
1129 static int
1130 udp6_ioctl(struct socket *so, u_long cmd, void *addr6, struct ifnet *ifp)
1131 {
1132 /*
1133 * MAPPED_ADDR implementation info:
1134 * Mapped addr support for PRU_CONTROL is not necessary.
1135 * Because typical user of PRU_CONTROL is such as ifconfig,
1136 * and they don't associate any addr to their socket. Then
1137 * socket family is only hint about the PRU_CONTROL'ed address
1138 * family, especially when getting addrs from kernel.
1139 * So AF_INET socket need to be used to control AF_INET addrs,
1140 * and AF_INET6 socket for AF_INET6 addrs.
1141 */
1142 return in6_control(so, cmd, addr6, ifp);
1143 }
1144
1145 static int
1146 udp6_stat(struct socket *so, struct stat *ub)
1147 {
1148 KASSERT(solocked(so));
1149
1150 /* stat: don't bother with a blocksize */
1151 return 0;
1152 }
1153
1154 static int
1155 udp6_peeraddr(struct socket *so, struct sockaddr *nam)
1156 {
1157 KASSERT(solocked(so));
1158 KASSERT(sotoin6pcb(so) != NULL);
1159 KASSERT(nam != NULL);
1160
1161 in6_setpeeraddr(sotoin6pcb(so), (struct sockaddr_in6 *)nam);
1162 return 0;
1163 }
1164
1165 static int
1166 udp6_sockaddr(struct socket *so, struct sockaddr *nam)
1167 {
1168 KASSERT(solocked(so));
1169 KASSERT(sotoin6pcb(so) != NULL);
1170 KASSERT(nam != NULL);
1171
1172 in6_setsockaddr(sotoin6pcb(so), (struct sockaddr_in6 *)nam);
1173 return 0;
1174 }
1175
1176 static int
1177 udp6_rcvd(struct socket *so, int flags, struct lwp *l)
1178 {
1179 KASSERT(solocked(so));
1180
1181 return EOPNOTSUPP;
1182 }
1183
1184 static int
1185 udp6_recvoob(struct socket *so, struct mbuf *m, int flags)
1186 {
1187 KASSERT(solocked(so));
1188
1189 return EOPNOTSUPP;
1190 }
1191
1192 static int
1193 udp6_send(struct socket *so, struct mbuf *m, struct sockaddr *nam,
1194 struct mbuf *control, struct lwp *l)
1195 {
1196 struct in6pcb *in6p = sotoin6pcb(so);
1197 int error = 0;
1198 int s;
1199
1200 KASSERT(solocked(so));
1201 KASSERT(in6p != NULL);
1202 KASSERT(m != NULL);
1203
1204 s = splsoftnet();
1205 error = udp6_output(in6p, m, (struct sockaddr_in6 *)nam, control, l);
1206 splx(s);
1207
1208 return error;
1209 }
1210
1211 static int
1212 udp6_sendoob(struct socket *so, struct mbuf *m, struct mbuf *control)
1213 {
1214 KASSERT(solocked(so));
1215
1216 if (m)
1217 m_freem(m);
1218 if (control)
1219 m_freem(control);
1220
1221 return EOPNOTSUPP;
1222 }
1223
1224 static int
1225 udp6_purgeif(struct socket *so, struct ifnet *ifp)
1226 {
1227
1228 mutex_enter(softnet_lock);
1229 in6_pcbpurgeif0(&udbtable, ifp);
1230 #ifdef NET_MPSAFE
1231 mutex_exit(softnet_lock);
1232 #endif
1233 in6_purgeif(ifp);
1234 #ifdef NET_MPSAFE
1235 mutex_enter(softnet_lock);
1236 #endif
1237 in6_pcbpurgeif(&udbtable, ifp);
1238 mutex_exit(softnet_lock);
1239
1240 return 0;
1241 }
1242
1243 static int
1244 sysctl_net_inet6_udp6_stats(SYSCTLFN_ARGS)
1245 {
1246
1247 return (NETSTAT_SYSCTL(udp6stat_percpu, UDP6_NSTATS));
1248 }
1249
1250 static void
1251 sysctl_net_inet6_udp6_setup(struct sysctllog **clog)
1252 {
1253
1254 sysctl_createv(clog, 0, NULL, NULL,
1255 CTLFLAG_PERMANENT,
1256 CTLTYPE_NODE, "inet6", NULL,
1257 NULL, 0, NULL, 0,
1258 CTL_NET, PF_INET6, CTL_EOL);
1259 sysctl_createv(clog, 0, NULL, NULL,
1260 CTLFLAG_PERMANENT,
1261 CTLTYPE_NODE, "udp6",
1262 SYSCTL_DESCR("UDPv6 related settings"),
1263 NULL, 0, NULL, 0,
1264 CTL_NET, PF_INET6, IPPROTO_UDP, CTL_EOL);
1265
1266 sysctl_createv(clog, 0, NULL, NULL,
1267 CTLFLAG_PERMANENT|CTLFLAG_READWRITE,
1268 CTLTYPE_INT, "sendspace",
1269 SYSCTL_DESCR("Default UDP send buffer size"),
1270 NULL, 0, &udp6_sendspace, 0,
1271 CTL_NET, PF_INET6, IPPROTO_UDP, UDP6CTL_SENDSPACE,
1272 CTL_EOL);
1273 sysctl_createv(clog, 0, NULL, NULL,
1274 CTLFLAG_PERMANENT|CTLFLAG_READWRITE,
1275 CTLTYPE_INT, "recvspace",
1276 SYSCTL_DESCR("Default UDP receive buffer size"),
1277 NULL, 0, &udp6_recvspace, 0,
1278 CTL_NET, PF_INET6, IPPROTO_UDP, UDP6CTL_RECVSPACE,
1279 CTL_EOL);
1280 sysctl_createv(clog, 0, NULL, NULL,
1281 CTLFLAG_PERMANENT|CTLFLAG_READWRITE,
1282 CTLTYPE_INT, "do_loopback_cksum",
1283 SYSCTL_DESCR("Perform UDP checksum on loopback"),
1284 NULL, 0, &udp_do_loopback_cksum, 0,
1285 CTL_NET, PF_INET6, IPPROTO_UDP, UDP6CTL_LOOPBACKCKSUM,
1286 CTL_EOL);
1287 sysctl_createv(clog, 0, NULL, NULL,
1288 CTLFLAG_PERMANENT,
1289 CTLTYPE_STRUCT, "pcblist",
1290 SYSCTL_DESCR("UDP protocol control block list"),
1291 sysctl_inpcblist, 0, &udbtable, 0,
1292 CTL_NET, PF_INET6, IPPROTO_UDP, CTL_CREATE,
1293 CTL_EOL);
1294 sysctl_createv(clog, 0, NULL, NULL,
1295 CTLFLAG_PERMANENT,
1296 CTLTYPE_STRUCT, "stats",
1297 SYSCTL_DESCR("UDPv6 statistics"),
1298 sysctl_net_inet6_udp6_stats, 0, NULL, 0,
1299 CTL_NET, PF_INET6, IPPROTO_UDP, UDP6CTL_STATS,
1300 CTL_EOL);
1301 }
1302
1303 void
1304 udp6_statinc(u_int stat)
1305 {
1306
1307 KASSERT(stat < UDP6_NSTATS);
1308 UDP6_STATINC(stat);
1309 }
1310
1311 PR_WRAP_USRREQS(udp6)
1312 #define udp6_attach udp6_attach_wrapper
1313 #define udp6_detach udp6_detach_wrapper
1314 #define udp6_accept udp6_accept_wrapper
1315 #define udp6_bind udp6_bind_wrapper
1316 #define udp6_listen udp6_listen_wrapper
1317 #define udp6_connect udp6_connect_wrapper
1318 #define udp6_connect2 udp6_connect2_wrapper
1319 #define udp6_disconnect udp6_disconnect_wrapper
1320 #define udp6_shutdown udp6_shutdown_wrapper
1321 #define udp6_abort udp6_abort_wrapper
1322 #define udp6_ioctl udp6_ioctl_wrapper
1323 #define udp6_stat udp6_stat_wrapper
1324 #define udp6_peeraddr udp6_peeraddr_wrapper
1325 #define udp6_sockaddr udp6_sockaddr_wrapper
1326 #define udp6_rcvd udp6_rcvd_wrapper
1327 #define udp6_recvoob udp6_recvoob_wrapper
1328 #define udp6_send udp6_send_wrapper
1329 #define udp6_sendoob udp6_sendoob_wrapper
1330 #define udp6_purgeif udp6_purgeif_wrapper
1331
1332 const struct pr_usrreqs udp6_usrreqs = {
1333 .pr_attach = udp6_attach,
1334 .pr_detach = udp6_detach,
1335 .pr_accept = udp6_accept,
1336 .pr_bind = udp6_bind,
1337 .pr_listen = udp6_listen,
1338 .pr_connect = udp6_connect,
1339 .pr_connect2 = udp6_connect2,
1340 .pr_disconnect = udp6_disconnect,
1341 .pr_shutdown = udp6_shutdown,
1342 .pr_abort = udp6_abort,
1343 .pr_ioctl = udp6_ioctl,
1344 .pr_stat = udp6_stat,
1345 .pr_peeraddr = udp6_peeraddr,
1346 .pr_sockaddr = udp6_sockaddr,
1347 .pr_rcvd = udp6_rcvd,
1348 .pr_recvoob = udp6_recvoob,
1349 .pr_send = udp6_send,
1350 .pr_sendoob = udp6_sendoob,
1351 .pr_purgeif = udp6_purgeif,
1352 };
1353