Home | History | Annotate | Line # | Download | only in netinet6
udp6_usrreq.c revision 1.57
      1  1.57   itojun /*	$NetBSD: udp6_usrreq.c,v 1.57 2003/08/22 22:05:11 itojun Exp $	*/
      2  1.43   itojun /*	$KAME: udp6_usrreq.c,v 1.86 2001/05/27 17:33:00 itojun Exp $	*/
      3   1.3  thorpej 
      4   1.2   itojun /*
      5   1.2   itojun  * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
      6   1.2   itojun  * All rights reserved.
      7  1.27   itojun  *
      8   1.2   itojun  * Redistribution and use in source and binary forms, with or without
      9   1.2   itojun  * modification, are permitted provided that the following conditions
     10   1.2   itojun  * are met:
     11   1.2   itojun  * 1. Redistributions of source code must retain the above copyright
     12   1.2   itojun  *    notice, this list of conditions and the following disclaimer.
     13   1.2   itojun  * 2. Redistributions in binary form must reproduce the above copyright
     14   1.2   itojun  *    notice, this list of conditions and the following disclaimer in the
     15   1.2   itojun  *    documentation and/or other materials provided with the distribution.
     16   1.2   itojun  * 3. Neither the name of the project nor the names of its contributors
     17   1.2   itojun  *    may be used to endorse or promote products derived from this software
     18   1.2   itojun  *    without specific prior written permission.
     19  1.27   itojun  *
     20   1.2   itojun  * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
     21   1.2   itojun  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
     22   1.2   itojun  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
     23   1.2   itojun  * ARE DISCLAIMED.  IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
     24   1.2   itojun  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     25   1.2   itojun  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
     26   1.2   itojun  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     27   1.2   itojun  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
     28   1.2   itojun  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     29   1.2   itojun  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     30   1.2   itojun  * SUCH DAMAGE.
     31   1.2   itojun  */
     32   1.2   itojun 
     33   1.2   itojun /*
     34   1.2   itojun  * Copyright (c) 1982, 1986, 1989, 1993
     35   1.2   itojun  *	The Regents of the University of California.  All rights reserved.
     36   1.2   itojun  *
     37   1.2   itojun  * Redistribution and use in source and binary forms, with or without
     38   1.2   itojun  * modification, are permitted provided that the following conditions
     39   1.2   itojun  * are met:
     40   1.2   itojun  * 1. Redistributions of source code must retain the above copyright
     41   1.2   itojun  *    notice, this list of conditions and the following disclaimer.
     42   1.2   itojun  * 2. Redistributions in binary form must reproduce the above copyright
     43   1.2   itojun  *    notice, this list of conditions and the following disclaimer in the
     44   1.2   itojun  *    documentation and/or other materials provided with the distribution.
     45  1.56      agc  * 3. Neither the name of the University nor the names of its contributors
     46   1.2   itojun  *    may be used to endorse or promote products derived from this software
     47   1.2   itojun  *    without specific prior written permission.
     48   1.2   itojun  *
     49   1.2   itojun  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
     50   1.2   itojun  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
     51   1.2   itojun  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
     52   1.2   itojun  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
     53   1.2   itojun  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     54   1.2   itojun  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
     55   1.2   itojun  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     56   1.2   itojun  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
     57   1.2   itojun  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     58   1.2   itojun  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     59   1.2   itojun  * SUCH DAMAGE.
     60   1.2   itojun  *
     61   1.2   itojun  *	@(#)udp_var.h	8.1 (Berkeley) 6/10/93
     62   1.2   itojun  */
     63  1.51    lukem 
     64  1.51    lukem #include <sys/cdefs.h>
     65  1.57   itojun __KERNEL_RCSID(0, "$NetBSD: udp6_usrreq.c,v 1.57 2003/08/22 22:05:11 itojun Exp $");
     66   1.2   itojun 
     67   1.2   itojun #include <sys/param.h>
     68   1.2   itojun #include <sys/malloc.h>
     69   1.2   itojun #include <sys/mbuf.h>
     70   1.2   itojun #include <sys/protosw.h>
     71   1.2   itojun #include <sys/socket.h>
     72   1.2   itojun #include <sys/socketvar.h>
     73   1.2   itojun #include <sys/errno.h>
     74   1.2   itojun #include <sys/stat.h>
     75   1.2   itojun #include <sys/systm.h>
     76   1.2   itojun #include <sys/proc.h>
     77   1.8   itojun #include <sys/syslog.h>
     78  1.50   simonb #include <sys/sysctl.h>
     79   1.2   itojun 
     80   1.2   itojun #include <net/if.h>
     81   1.2   itojun #include <net/route.h>
     82   1.2   itojun #include <net/if_types.h>
     83   1.2   itojun 
     84   1.2   itojun #include <netinet/in.h>
     85   1.2   itojun #include <netinet/in_var.h>
     86  1.14   itojun #include <netinet/in_systm.h>
     87  1.14   itojun #include <netinet/ip.h>
     88  1.14   itojun #include <netinet/ip_var.h>
     89  1.14   itojun #include <netinet/in_pcb.h>
     90  1.14   itojun #include <netinet/udp.h>
     91  1.14   itojun #include <netinet/udp_var.h>
     92  1.23   itojun #include <netinet/ip6.h>
     93  1.27   itojun #include <netinet6/ip6_var.h>
     94   1.2   itojun #include <netinet6/in6_pcb.h>
     95  1.23   itojun #include <netinet/icmp6.h>
     96   1.2   itojun #include <netinet6/udp6_var.h>
     97  1.14   itojun #include <netinet6/ip6protosw.h>
     98   1.2   itojun 
     99   1.2   itojun #include "faith.h"
    100  1.41   itojun #if defined(NFAITH) && NFAITH > 0
    101  1.41   itojun #include <net/if_faith.h>
    102  1.41   itojun #endif
    103   1.2   itojun 
    104   1.2   itojun /*
    105   1.2   itojun  * UDP protocol inplementation.
    106   1.2   itojun  * Per RFC 768, August, 1980.
    107   1.2   itojun  */
    108   1.2   itojun 
    109  1.52     matt struct	in6pcb udb6;
    110   1.2   itojun struct	in6pcb *udp6_last_in6pcb = &udb6;
    111  1.52     matt struct	udp6stat udp6stat;
    112   1.2   itojun 
    113   1.2   itojun static	void udp6_detach __P((struct in6pcb *));
    114   1.2   itojun static	void udp6_notify __P((struct in6pcb *, int));
    115   1.2   itojun 
    116   1.2   itojun void
    117   1.2   itojun udp6_init()
    118   1.2   itojun {
    119   1.2   itojun 	udb6.in6p_next = udb6.in6p_prev = &udb6;
    120   1.2   itojun }
    121   1.2   itojun 
    122   1.2   itojun /*
    123   1.2   itojun  * Notify a udp user of an asynchronous error;
    124  1.27   itojun  * just wake up so that he can collect error status.
    125   1.2   itojun  */
    126   1.2   itojun static	void
    127   1.2   itojun udp6_notify(in6p, errno)
    128  1.39   itojun 	struct in6pcb *in6p;
    129   1.2   itojun 	int errno;
    130   1.2   itojun {
    131   1.2   itojun 	in6p->in6p_socket->so_error = errno;
    132   1.2   itojun 	sorwakeup(in6p->in6p_socket);
    133   1.2   itojun 	sowwakeup(in6p->in6p_socket);
    134   1.2   itojun }
    135   1.2   itojun 
    136   1.2   itojun void
    137  1.14   itojun udp6_ctlinput(cmd, sa, d)
    138   1.2   itojun 	int cmd;
    139   1.2   itojun 	struct sockaddr *sa;
    140  1.14   itojun 	void *d;
    141   1.2   itojun {
    142   1.2   itojun 	struct udphdr uh;
    143  1.39   itojun 	struct ip6_hdr *ip6;
    144  1.40   itojun 	struct sockaddr_in6 *sa6 = (struct sockaddr_in6 *)sa;
    145  1.14   itojun 	struct mbuf *m;
    146  1.14   itojun 	int off;
    147  1.40   itojun 	void *cmdarg;
    148  1.40   itojun 	struct ip6ctlparam *ip6cp = NULL;
    149  1.40   itojun 	const struct sockaddr_in6 *sa6_src = NULL;
    150  1.25   itojun 	void (*notify) __P((struct in6pcb *, int)) = udp6_notify;
    151  1.40   itojun 	struct udp_portonly {
    152  1.40   itojun 		u_int16_t uh_sport;
    153  1.40   itojun 		u_int16_t uh_dport;
    154  1.40   itojun 	} *uhp;
    155   1.2   itojun 
    156  1.10   itojun 	if (sa->sa_family != AF_INET6 ||
    157  1.10   itojun 	    sa->sa_len != sizeof(struct sockaddr_in6))
    158  1.10   itojun 		return;
    159  1.14   itojun 
    160  1.25   itojun 	if ((unsigned)cmd >= PRC_NCMDS)
    161  1.25   itojun 		return;
    162  1.25   itojun 	if (PRC_IS_REDIRECT(cmd))
    163  1.25   itojun 		notify = in6_rtchange, d = NULL;
    164  1.25   itojun 	else if (cmd == PRC_HOSTDEAD)
    165  1.25   itojun 		d = NULL;
    166  1.47   itojun 	else if (cmd == PRC_MSGSIZE) {
    167  1.47   itojun 		/* special code is present, see below */
    168  1.47   itojun 		notify = in6_rtchange;
    169  1.47   itojun 	}
    170  1.25   itojun 	else if (inet6ctlerrmap[cmd] == 0)
    171   1.2   itojun 		return;
    172   1.7   itojun 
    173  1.14   itojun 	/* if the parameter is from icmp6, decode it. */
    174  1.14   itojun 	if (d != NULL) {
    175  1.40   itojun 		ip6cp = (struct ip6ctlparam *)d;
    176  1.14   itojun 		m = ip6cp->ip6c_m;
    177  1.14   itojun 		ip6 = ip6cp->ip6c_ip6;
    178  1.14   itojun 		off = ip6cp->ip6c_off;
    179  1.40   itojun 		cmdarg = ip6cp->ip6c_cmdarg;
    180  1.40   itojun 		sa6_src = ip6cp->ip6c_src;
    181  1.14   itojun 	} else {
    182  1.14   itojun 		m = NULL;
    183  1.14   itojun 		ip6 = NULL;
    184  1.40   itojun 		cmdarg = NULL;
    185  1.40   itojun 		sa6_src = &sa6_any;
    186  1.14   itojun 	}
    187  1.14   itojun 
    188   1.2   itojun 	if (ip6) {
    189   1.2   itojun 		/*
    190   1.2   itojun 		 * XXX: We assume that when IPV6 is non NULL,
    191   1.2   itojun 		 * M and OFF are valid.
    192   1.2   itojun 		 */
    193  1.33   itojun 
    194  1.33   itojun 		/* check if we can safely examine src and dst ports */
    195  1.42   itojun 		if (m->m_pkthdr.len < off + sizeof(*uhp)) {
    196  1.42   itojun 			if (cmd == PRC_MSGSIZE)
    197  1.42   itojun 				icmp6_mtudisc_update((struct ip6ctlparam *)d, 0);
    198  1.33   itojun 			return;
    199  1.42   itojun 		}
    200   1.7   itojun 
    201  1.40   itojun 		bzero(&uh, sizeof(uh));
    202  1.40   itojun 		m_copydata(m, off, sizeof(*uhp), (caddr_t)&uh);
    203  1.34   itojun 
    204  1.34   itojun 		if (cmd == PRC_MSGSIZE) {
    205  1.36   itojun 			int valid = 0;
    206  1.40   itojun 
    207  1.34   itojun 			/*
    208  1.34   itojun 			 * Check to see if we have a valid UDP socket
    209  1.34   itojun 			 * corresponding to the address in the ICMPv6 message
    210  1.34   itojun 			 * payload.
    211  1.34   itojun 			 */
    212  1.40   itojun 			if (in6_pcblookup_connect(&udb6, &sa6->sin6_addr,
    213  1.40   itojun 			    uh.uh_dport, (struct in6_addr *)&sa6_src->sin6_addr,
    214  1.40   itojun 			    uh.uh_sport, 0))
    215  1.36   itojun 				valid++;
    216  1.34   itojun #if 0
    217  1.34   itojun 			/*
    218  1.34   itojun 			 * As the use of sendto(2) is fairly popular,
    219  1.34   itojun 			 * we may want to allow non-connected pcb too.
    220  1.34   itojun 			 * But it could be too weak against attacks...
    221  1.34   itojun 			 * We should at least check if the local address (= s)
    222  1.34   itojun 			 * is really ours.
    223  1.34   itojun 			 */
    224  1.40   itojun 			else if (in6_pcblookup_bind(&udb6, &sa6->sin6_addr,
    225  1.40   itojun 						    uh.uh_dport, 0))
    226  1.36   itojun 				valid++;
    227  1.34   itojun #endif
    228  1.34   itojun 
    229  1.34   itojun 			/*
    230  1.40   itojun 			 * Depending on the value of "valid" and routing table
    231  1.40   itojun 			 * size (mtudisc_{hi,lo}wat), we will:
    232  1.46   itojun 			 * - recalculate the new MTU and create the
    233  1.40   itojun 			 *   corresponding routing entry, or
    234  1.40   itojun 			 * - ignore the MTU change notification.
    235  1.34   itojun 			 */
    236  1.36   itojun 			icmp6_mtudisc_update((struct ip6ctlparam *)d, valid);
    237  1.34   itojun 
    238  1.40   itojun 			/*
    239  1.40   itojun 			 * regardless of if we called icmp6_mtudisc_update(),
    240  1.40   itojun 			 * we need to call in6_pcbnotify(), to notify path
    241  1.40   itojun 			 * MTU change to the userland (2292bis-02), because
    242  1.40   itojun 			 * some unconnected sockets may share the same
    243  1.40   itojun 			 * destination and want to know the path MTU.
    244  1.40   itojun 			 */
    245  1.34   itojun 		}
    246  1.34   itojun 
    247  1.40   itojun 		(void) in6_pcbnotify(&udb6, sa, uh.uh_dport,
    248  1.40   itojun 		    (struct sockaddr *)sa6_src, uh.uh_sport, cmd, cmdarg,
    249  1.40   itojun 		    notify);
    250   1.2   itojun 	} else {
    251  1.40   itojun 		(void) in6_pcbnotify(&udb6, sa, 0, (struct sockaddr *)sa6_src,
    252  1.40   itojun 		    0, cmd, cmdarg, notify);
    253   1.2   itojun 	}
    254   1.2   itojun }
    255   1.2   itojun 
    256   1.2   itojun extern	int udp6_sendspace;
    257   1.2   itojun extern	int udp6_recvspace;
    258   1.2   itojun 
    259   1.2   itojun int
    260  1.55     fvdl udp6_usrreq(so, req, m, addr6, control, p)
    261   1.2   itojun 	struct socket *so;
    262   1.2   itojun 	int req;
    263   1.2   itojun 	struct mbuf *m, *addr6, *control;
    264  1.55     fvdl 	struct proc *p;
    265   1.2   itojun {
    266   1.2   itojun 	struct	in6pcb *in6p = sotoin6pcb(so);
    267   1.2   itojun 	int	error = 0;
    268   1.2   itojun 	int	s;
    269   1.2   itojun 
    270  1.27   itojun 	/*
    271   1.2   itojun 	 * MAPPED_ADDR implementation info:
    272   1.2   itojun 	 *  Mapped addr support for PRU_CONTROL is not necessary.
    273   1.2   itojun 	 *  Because typical user of PRU_CONTROL is such as ifconfig,
    274   1.2   itojun 	 *  and they don't associate any addr to their socket.  Then
    275   1.2   itojun 	 *  socket family is only hint about the PRU_CONTROL'ed address
    276   1.2   itojun 	 *  family, especially when getting addrs from kernel.
    277   1.2   itojun 	 *  So AF_INET socket need to be used to control AF_INET addrs,
    278   1.2   itojun 	 *  and AF_INET6 socket for AF_INET6 addrs.
    279   1.2   itojun 	 */
    280   1.2   itojun 	if (req == PRU_CONTROL)
    281  1.53   itojun 		return (in6_control(so, (u_long)m, (caddr_t)addr6,
    282   1.2   itojun 				   (struct ifnet *)control, p));
    283  1.20  thorpej 
    284  1.21  thorpej 	if (req == PRU_PURGEIF) {
    285  1.44   itojun 		in6_pcbpurgeif0(&udb6, (struct ifnet *)control);
    286  1.21  thorpej 		in6_purgeif((struct ifnet *)control);
    287  1.21  thorpej 		in6_pcbpurgeif(&udb6, (struct ifnet *)control);
    288  1.20  thorpej 		return (0);
    289  1.20  thorpej 	}
    290   1.2   itojun 
    291   1.2   itojun 	if (in6p == NULL && req != PRU_ATTACH) {
    292   1.2   itojun 		error = EINVAL;
    293   1.2   itojun 		goto release;
    294   1.2   itojun 	}
    295   1.2   itojun 
    296   1.2   itojun 	switch (req) {
    297   1.2   itojun 	case PRU_ATTACH:
    298   1.2   itojun 		/*
    299   1.2   itojun 		 * MAPPED_ADDR implementation spec:
    300  1.27   itojun 		 *  Always attach for IPv6,
    301   1.2   itojun 		 *  and only when necessary for IPv4.
    302   1.2   itojun 		 */
    303   1.2   itojun 		if (in6p != NULL) {
    304   1.2   itojun 			error = EINVAL;
    305   1.2   itojun 			break;
    306   1.2   itojun 		}
    307   1.4   itojun 		s = splsoftnet();
    308   1.2   itojun 		error = in6_pcballoc(so, &udb6);
    309   1.2   itojun 		splx(s);
    310   1.2   itojun 		if (error)
    311   1.2   itojun 			break;
    312   1.2   itojun 		error = soreserve(so, udp6_sendspace, udp6_recvspace);
    313   1.2   itojun 		if (error)
    314   1.2   itojun 			break;
    315   1.2   itojun 		in6p = sotoin6pcb(so);
    316   1.2   itojun 		in6p->in6p_cksum = -1;	/* just to be sure */
    317   1.2   itojun 		break;
    318   1.2   itojun 
    319   1.2   itojun 	case PRU_DETACH:
    320   1.2   itojun 		udp6_detach(in6p);
    321   1.2   itojun 		break;
    322   1.2   itojun 
    323   1.2   itojun 	case PRU_BIND:
    324   1.4   itojun 		s = splsoftnet();
    325  1.29   itojun 		error = in6_pcbbind(in6p, addr6, p);
    326   1.2   itojun 		splx(s);
    327   1.2   itojun 		break;
    328   1.2   itojun 
    329   1.2   itojun 	case PRU_LISTEN:
    330   1.2   itojun 		error = EOPNOTSUPP;
    331   1.2   itojun 		break;
    332   1.2   itojun 
    333   1.2   itojun 	case PRU_CONNECT:
    334  1.14   itojun 		if (!IN6_IS_ADDR_UNSPECIFIED(&in6p->in6p_faddr)) {
    335   1.2   itojun 			error = EISCONN;
    336   1.2   itojun 			break;
    337   1.2   itojun 		}
    338   1.4   itojun 		s = splsoftnet();
    339   1.2   itojun 		error = in6_pcbconnect(in6p, addr6);
    340   1.2   itojun 		if (ip6_auto_flowlabel) {
    341   1.2   itojun 			in6p->in6p_flowinfo &= ~IPV6_FLOWLABEL_MASK;
    342  1.27   itojun 			in6p->in6p_flowinfo |=
    343   1.2   itojun 				(htonl(ip6_flow_seq++) & IPV6_FLOWLABEL_MASK);
    344   1.2   itojun 		}
    345   1.2   itojun 		splx(s);
    346   1.2   itojun 		if (error == 0)
    347   1.2   itojun 			soisconnected(so);
    348   1.2   itojun 		break;
    349   1.2   itojun 
    350   1.2   itojun 	case PRU_CONNECT2:
    351   1.2   itojun 		error = EOPNOTSUPP;
    352   1.2   itojun 		break;
    353   1.2   itojun 
    354   1.2   itojun 	case PRU_ACCEPT:
    355   1.2   itojun 		error = EOPNOTSUPP;
    356   1.2   itojun 		break;
    357   1.2   itojun 
    358   1.2   itojun 	case PRU_DISCONNECT:
    359   1.2   itojun 		if (IN6_IS_ADDR_UNSPECIFIED(&in6p->in6p_faddr)) {
    360   1.2   itojun 			error = ENOTCONN;
    361   1.2   itojun 			break;
    362   1.2   itojun 		}
    363   1.4   itojun 		s = splsoftnet();
    364   1.2   itojun 		in6_pcbdisconnect(in6p);
    365   1.2   itojun 		bzero((caddr_t)&in6p->in6p_laddr, sizeof(in6p->in6p_laddr));
    366   1.2   itojun 		splx(s);
    367   1.2   itojun 		so->so_state &= ~SS_ISCONNECTED;		/* XXX */
    368   1.2   itojun 		break;
    369   1.2   itojun 
    370   1.2   itojun 	case PRU_SHUTDOWN:
    371   1.2   itojun 		socantsendmore(so);
    372   1.2   itojun 		break;
    373   1.2   itojun 
    374   1.2   itojun 	case PRU_SEND:
    375  1.53   itojun 		return (udp6_output(in6p, m, addr6, control, p));
    376   1.2   itojun 
    377   1.2   itojun 	case PRU_ABORT:
    378   1.2   itojun 		soisdisconnected(so);
    379   1.2   itojun 		udp6_detach(in6p);
    380   1.2   itojun 		break;
    381   1.2   itojun 
    382   1.2   itojun 	case PRU_SOCKADDR:
    383   1.2   itojun 		in6_setsockaddr(in6p, addr6);
    384   1.2   itojun 		break;
    385   1.2   itojun 
    386   1.2   itojun 	case PRU_PEERADDR:
    387   1.2   itojun 		in6_setpeeraddr(in6p, addr6);
    388   1.2   itojun 		break;
    389   1.2   itojun 
    390   1.2   itojun 	case PRU_SENSE:
    391   1.2   itojun 		/*
    392   1.2   itojun 		 * stat: don't bother with a blocksize
    393   1.2   itojun 		 */
    394  1.53   itojun 		return (0);
    395   1.2   itojun 
    396   1.2   itojun 	case PRU_SENDOOB:
    397   1.2   itojun 	case PRU_FASTTIMO:
    398   1.2   itojun 	case PRU_SLOWTIMO:
    399   1.2   itojun 	case PRU_PROTORCV:
    400   1.2   itojun 	case PRU_PROTOSEND:
    401   1.2   itojun 		error = EOPNOTSUPP;
    402   1.2   itojun 		break;
    403   1.2   itojun 
    404   1.2   itojun 	case PRU_RCVD:
    405   1.2   itojun 	case PRU_RCVOOB:
    406  1.53   itojun 		return (EOPNOTSUPP);	/* do not free mbuf's */
    407   1.2   itojun 
    408   1.2   itojun 	default:
    409   1.2   itojun 		panic("udp6_usrreq");
    410   1.2   itojun 	}
    411   1.2   itojun 
    412   1.2   itojun release:
    413  1.43   itojun 	if (control)
    414   1.2   itojun 		m_freem(control);
    415   1.2   itojun 	if (m)
    416   1.2   itojun 		m_freem(m);
    417  1.53   itojun 	return (error);
    418   1.2   itojun }
    419   1.2   itojun 
    420   1.2   itojun static void
    421   1.2   itojun udp6_detach(in6p)
    422   1.2   itojun 	struct in6pcb *in6p;
    423   1.2   itojun {
    424  1.27   itojun 	int s = splsoftnet();
    425   1.2   itojun 
    426   1.2   itojun 	if (in6p == udp6_last_in6pcb)
    427   1.2   itojun 		udp6_last_in6pcb = &udb6;
    428   1.2   itojun 	in6_pcbdetach(in6p);
    429   1.2   itojun 	splx(s);
    430   1.2   itojun }
    431   1.2   itojun 
    432   1.2   itojun int
    433   1.2   itojun udp6_sysctl(name, namelen, oldp, oldlenp, newp, newlen)
    434   1.2   itojun 	int *name;
    435   1.2   itojun 	u_int namelen;
    436   1.2   itojun 	void *oldp;
    437   1.2   itojun 	size_t *oldlenp;
    438   1.2   itojun 	void *newp;
    439   1.2   itojun 	size_t newlen;
    440   1.2   itojun {
    441   1.2   itojun 	/* All sysctl names at this level are terminal. */
    442   1.2   itojun 	if (namelen != 1)
    443   1.2   itojun 		return ENOTDIR;
    444   1.2   itojun 
    445   1.2   itojun 	switch (name[0]) {
    446   1.2   itojun 
    447  1.28   itojun 	case UDP6CTL_SENDSPACE:
    448   1.2   itojun 		return sysctl_int(oldp, oldlenp, newp, newlen,
    449   1.2   itojun 		    &udp6_sendspace);
    450   1.2   itojun 	case UDP6CTL_RECVSPACE:
    451  1.27   itojun 		return sysctl_int(oldp, oldlenp, newp, newlen,
    452   1.2   itojun 		    &udp6_recvspace);
    453   1.2   itojun 	default:
    454   1.2   itojun 		return ENOPROTOOPT;
    455   1.2   itojun 	}
    456   1.2   itojun 	/* NOTREACHED */
    457   1.2   itojun }
    458