xref: /netbsd-src/sys/netinet/raw_ip.c (revision d48f14661dda8638fee055ba15d35bdfb29b9fa8)
1 /*	$NetBSD: raw_ip.c,v 1.89 2006/05/14 21:19:34 elad Exp $	*/
2 
3 /*
4  * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
5  * All rights reserved.
6  *
7  * Redistribution and use in source and binary forms, with or without
8  * modification, are permitted provided that the following conditions
9  * are met:
10  * 1. Redistributions of source code must retain the above copyright
11  *    notice, this list of conditions and the following disclaimer.
12  * 2. Redistributions in binary form must reproduce the above copyright
13  *    notice, this list of conditions and the following disclaimer in the
14  *    documentation and/or other materials provided with the distribution.
15  * 3. Neither the name of the project nor the names of its contributors
16  *    may be used to endorse or promote products derived from this software
17  *    without specific prior written permission.
18  *
19  * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
20  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22  * ARE DISCLAIMED.  IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
23  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
25  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
26  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
27  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
28  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29  * SUCH DAMAGE.
30  */
31 
32 /*
33  * Copyright (c) 1982, 1986, 1988, 1993
34  *	The Regents of the University of California.  All rights reserved.
35  *
36  * Redistribution and use in source and binary forms, with or without
37  * modification, are permitted provided that the following conditions
38  * are met:
39  * 1. Redistributions of source code must retain the above copyright
40  *    notice, this list of conditions and the following disclaimer.
41  * 2. Redistributions in binary form must reproduce the above copyright
42  *    notice, this list of conditions and the following disclaimer in the
43  *    documentation and/or other materials provided with the distribution.
44  * 3. Neither the name of the University nor the names of its contributors
45  *    may be used to endorse or promote products derived from this software
46  *    without specific prior written permission.
47  *
48  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
49  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
50  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
51  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
52  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
53  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
54  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
55  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
56  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
57  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
58  * SUCH DAMAGE.
59  *
60  *	@(#)raw_ip.c	8.7 (Berkeley) 5/15/95
61  */
62 
63 #include <sys/cdefs.h>
64 __KERNEL_RCSID(0, "$NetBSD: raw_ip.c,v 1.89 2006/05/14 21:19:34 elad Exp $");
65 
66 #include "opt_inet.h"
67 #include "opt_ipsec.h"
68 #include "opt_mrouting.h"
69 
70 #include <sys/param.h>
71 #include <sys/sysctl.h>
72 #include <sys/malloc.h>
73 #include <sys/mbuf.h>
74 #include <sys/socket.h>
75 #include <sys/protosw.h>
76 #include <sys/socketvar.h>
77 #include <sys/errno.h>
78 #include <sys/systm.h>
79 #include <sys/proc.h>
80 #include <sys/kauth.h>
81 
82 #include <net/if.h>
83 #include <net/route.h>
84 
85 #include <netinet/in.h>
86 #include <netinet/in_systm.h>
87 #include <netinet/ip.h>
88 #include <netinet/ip_var.h>
89 #include <netinet/ip_mroute.h>
90 #include <netinet/ip_icmp.h>
91 #include <netinet/in_pcb.h>
92 #include <netinet/in_proto.h>
93 #include <netinet/in_var.h>
94 
95 #include <machine/stdarg.h>
96 
97 #ifdef IPSEC
98 #include <netinet6/ipsec.h>
99 #endif /*IPSEC*/
100 
101 #ifdef FAST_IPSEC
102 #include <netipsec/ipsec.h>
103 #include <netipsec/ipsec_var.h>			/* XXX ipsecstat namespace */
104 #endif	/* FAST_IPSEC*/
105 
106 struct inpcbtable rawcbtable;
107 
108 int	 rip_pcbnotify(struct inpcbtable *, struct in_addr,
109     struct in_addr, int, int, void (*)(struct inpcb *, int));
110 int	 rip_bind(struct inpcb *, struct mbuf *);
111 int	 rip_connect(struct inpcb *, struct mbuf *);
112 void	 rip_disconnect(struct inpcb *);
113 
114 /*
115  * Nominal space allocated to a raw ip socket.
116  */
117 #define	RIPSNDQ		8192
118 #define	RIPRCVQ		8192
119 
120 /*
121  * Raw interface to IP protocol.
122  */
123 
124 /*
125  * Initialize raw connection block q.
126  */
127 void
128 rip_init(void)
129 {
130 
131 	in_pcbinit(&rawcbtable, 1, 1);
132 }
133 
134 /*
135  * Setup generic address and protocol structures
136  * for raw_input routine, then pass them along with
137  * mbuf chain.
138  */
139 void
140 rip_input(struct mbuf *m, ...)
141 {
142 	int proto;
143 	struct ip *ip = mtod(m, struct ip *);
144 	struct inpcb_hdr *inph;
145 	struct inpcb *inp;
146 	struct inpcb *last = 0;
147 	struct mbuf *opts = 0;
148 	struct sockaddr_in ripsrc;
149 	va_list ap;
150 
151 	va_start(ap, m);
152 	(void)va_arg(ap, int);		/* ignore value, advance ap */
153 	proto = va_arg(ap, int);
154 	va_end(ap);
155 
156 	ripsrc.sin_family = AF_INET;
157 	ripsrc.sin_len = sizeof(struct sockaddr_in);
158 	ripsrc.sin_addr = ip->ip_src;
159 	ripsrc.sin_port = 0;
160 	bzero((caddr_t)ripsrc.sin_zero, sizeof(ripsrc.sin_zero));
161 
162 	/*
163 	 * XXX Compatibility: programs using raw IP expect ip_len
164 	 * XXX to have the header length subtracted, and in host order.
165 	 * XXX ip_off is also expected to be host order.
166 	 */
167 	ip->ip_len = ntohs(ip->ip_len) - (ip->ip_hl << 2);
168 	NTOHS(ip->ip_off);
169 
170 	CIRCLEQ_FOREACH(inph, &rawcbtable.inpt_queue, inph_queue) {
171 		inp = (struct inpcb *)inph;
172 		if (inp->inp_af != AF_INET)
173 			continue;
174 		if (inp->inp_ip.ip_p && inp->inp_ip.ip_p != proto)
175 			continue;
176 		if (!in_nullhost(inp->inp_laddr) &&
177 		    !in_hosteq(inp->inp_laddr, ip->ip_dst))
178 			continue;
179 		if (!in_nullhost(inp->inp_faddr) &&
180 		    !in_hosteq(inp->inp_faddr, ip->ip_src))
181 			continue;
182 		if (last) {
183 			struct mbuf *n;
184 
185 #if defined(IPSEC) || defined(FAST_IPSEC)
186 			/* check AH/ESP integrity. */
187 			if (ipsec4_in_reject_so(m, last->inp_socket)) {
188 				ipsecstat.in_polvio++;
189 				/* do not inject data to pcb */
190 			} else
191 #endif /*IPSEC*/
192 			if ((n = m_copy(m, 0, (int)M_COPYALL)) != NULL) {
193 				if (last->inp_flags & INP_CONTROLOPTS ||
194 				    last->inp_socket->so_options & SO_TIMESTAMP)
195 					ip_savecontrol(last, &opts, ip, n);
196 				if (sbappendaddr(&last->inp_socket->so_rcv,
197 				    sintosa(&ripsrc), n, opts) == 0) {
198 					/* should notify about lost packet */
199 					m_freem(n);
200 					if (opts)
201 						m_freem(opts);
202 				} else
203 					sorwakeup(last->inp_socket);
204 				opts = NULL;
205 			}
206 		}
207 		last = inp;
208 	}
209 #if defined(IPSEC) || defined(FAST_IPSEC)
210 	/* check AH/ESP integrity. */
211 	if (last && ipsec4_in_reject_so(m, last->inp_socket)) {
212 		m_freem(m);
213 		ipsecstat.in_polvio++;
214 		ipstat.ips_delivered--;
215 		/* do not inject data to pcb */
216 	} else
217 #endif /*IPSEC*/
218 	if (last) {
219 		if (last->inp_flags & INP_CONTROLOPTS ||
220 		    last->inp_socket->so_options & SO_TIMESTAMP)
221 			ip_savecontrol(last, &opts, ip, m);
222 		if (sbappendaddr(&last->inp_socket->so_rcv,
223 		    sintosa(&ripsrc), m, opts) == 0) {
224 			m_freem(m);
225 			if (opts)
226 				m_freem(opts);
227 		} else
228 			sorwakeup(last->inp_socket);
229 	} else {
230 		if (inetsw[ip_protox[ip->ip_p]].pr_input == rip_input) {
231 			icmp_error(m, ICMP_UNREACH, ICMP_UNREACH_PROTOCOL,
232 			    0, 0);
233 			ipstat.ips_noproto++;
234 			ipstat.ips_delivered--;
235 		} else
236 			m_freem(m);
237 	}
238 	return;
239 }
240 
241 int
242 rip_pcbnotify(struct inpcbtable *table,
243     struct in_addr faddr, struct in_addr laddr, int proto, int errno,
244     void (*notify)(struct inpcb *, int))
245 {
246 	struct inpcb *inp, *ninp;
247 	int nmatch;
248 
249 	nmatch = 0;
250 	for (inp = (struct inpcb *)CIRCLEQ_FIRST(&table->inpt_queue);
251 	    inp != (struct inpcb *)&table->inpt_queue;
252 	    inp = ninp) {
253 		ninp = (struct inpcb *)inp->inp_queue.cqe_next;
254 		if (inp->inp_af != AF_INET)
255 			continue;
256 		if (inp->inp_ip.ip_p && inp->inp_ip.ip_p != proto)
257 			continue;
258 		if (in_hosteq(inp->inp_faddr, faddr) &&
259 		    in_hosteq(inp->inp_laddr, laddr)) {
260 			(*notify)(inp, errno);
261 			nmatch++;
262 		}
263 	}
264 
265 	return nmatch;
266 }
267 
268 void *
269 rip_ctlinput(int cmd, struct sockaddr *sa, void *v)
270 {
271 	struct ip *ip = v;
272 	void (*notify)(struct inpcb *, int) = in_rtchange;
273 	int errno;
274 
275 	if (sa->sa_family != AF_INET ||
276 	    sa->sa_len != sizeof(struct sockaddr_in))
277 		return NULL;
278 	if ((unsigned)cmd >= PRC_NCMDS)
279 		return NULL;
280 	errno = inetctlerrmap[cmd];
281 	if (PRC_IS_REDIRECT(cmd))
282 		notify = in_rtchange, ip = 0;
283 	else if (cmd == PRC_HOSTDEAD)
284 		ip = 0;
285 	else if (errno == 0)
286 		return NULL;
287 	if (ip) {
288 		rip_pcbnotify(&rawcbtable, satosin(sa)->sin_addr,
289 		    ip->ip_src, ip->ip_p, errno, notify);
290 
291 		/* XXX mapped address case */
292 	} else
293 		in_pcbnotifyall(&rawcbtable, satosin(sa)->sin_addr, errno,
294 		    notify);
295 	return NULL;
296 }
297 
298 /*
299  * Generate IP header and pass packet to ip_output.
300  * Tack on options user may have setup with control call.
301  */
302 int
303 rip_output(struct mbuf *m, ...)
304 {
305 	struct inpcb *inp;
306 	struct ip *ip;
307 	struct mbuf *opts;
308 	int flags;
309 	va_list ap;
310 
311 	va_start(ap, m);
312 	inp = va_arg(ap, struct inpcb *);
313 	va_end(ap);
314 
315 	flags =
316 	    (inp->inp_socket->so_options & SO_DONTROUTE) | IP_ALLOWBROADCAST
317 	    | IP_RETURNMTU;
318 
319 	/*
320 	 * If the user handed us a complete IP packet, use it.
321 	 * Otherwise, allocate an mbuf for a header and fill it in.
322 	 */
323 	if ((inp->inp_flags & INP_HDRINCL) == 0) {
324 		if ((m->m_pkthdr.len + sizeof(struct ip)) > IP_MAXPACKET) {
325 			m_freem(m);
326 			return (EMSGSIZE);
327 		}
328 		M_PREPEND(m, sizeof(struct ip), M_DONTWAIT);
329 		if (!m)
330 			return (ENOBUFS);
331 		ip = mtod(m, struct ip *);
332 		ip->ip_tos = 0;
333 		ip->ip_off = htons(0);
334 		ip->ip_p = inp->inp_ip.ip_p;
335 		ip->ip_len = htons(m->m_pkthdr.len);
336 		ip->ip_src = inp->inp_laddr;
337 		ip->ip_dst = inp->inp_faddr;
338 		ip->ip_ttl = MAXTTL;
339 		opts = inp->inp_options;
340 	} else {
341 		if (m->m_pkthdr.len > IP_MAXPACKET) {
342 			m_freem(m);
343 			return (EMSGSIZE);
344 		}
345 		ip = mtod(m, struct ip *);
346 
347 		/*
348 		 * If the mbuf is read-only, we need to allocate
349 		 * a new mbuf for the header, since we need to
350 		 * modify the header.
351 		 */
352 		if (M_READONLY(m)) {
353 			int hlen = ip->ip_hl << 2;
354 
355 			m = m_copyup(m, hlen, (max_linkhdr + 3) & ~3);
356 			if (m == NULL)
357 				return (ENOMEM);	/* XXX */
358 			ip = mtod(m, struct ip *);
359 		}
360 
361 		/* XXX userland passes ip_len and ip_off in host order */
362 		if (m->m_pkthdr.len != ip->ip_len) {
363 			m_freem(m);
364 			return (EINVAL);
365 		}
366 		HTONS(ip->ip_len);
367 		HTONS(ip->ip_off);
368 		if (ip->ip_id == 0)
369 			ip->ip_id = ip_newid();
370 		opts = NULL;
371 		/* XXX prevent ip_output from overwriting header fields */
372 		flags |= IP_RAWOUTPUT;
373 		ipstat.ips_rawout++;
374 	}
375 	return (ip_output(m, opts, &inp->inp_route, flags, inp->inp_moptions,
376 	     inp->inp_socket, &inp->inp_errormtu));
377 }
378 
379 /*
380  * Raw IP socket option processing.
381  */
382 int
383 rip_ctloutput(int op, struct socket *so, int level, int optname,
384     struct mbuf **m)
385 {
386 	struct inpcb *inp = sotoinpcb(so);
387 	int error = 0;
388 
389 	if (level != IPPROTO_IP) {
390 		error = ENOPROTOOPT;
391 		if (op == PRCO_SETOPT && *m != 0)
392 			(void) m_free(*m);
393 	} else switch (op) {
394 
395 	case PRCO_SETOPT:
396 		switch (optname) {
397 		case IP_HDRINCL:
398 			if (*m == 0 || (*m)->m_len < sizeof (int))
399 				error = EINVAL;
400 			else {
401 				if (*mtod(*m, int *))
402 					inp->inp_flags |= INP_HDRINCL;
403 				else
404 					inp->inp_flags &= ~INP_HDRINCL;
405 			}
406 			if (*m != 0)
407 				(void) m_free(*m);
408 			break;
409 
410 #ifdef MROUTING
411 		case MRT_INIT:
412 		case MRT_DONE:
413 		case MRT_ADD_VIF:
414 		case MRT_DEL_VIF:
415 		case MRT_ADD_MFC:
416 		case MRT_DEL_MFC:
417 		case MRT_ASSERT:
418 		case MRT_API_CONFIG:
419 		case MRT_ADD_BW_UPCALL:
420 		case MRT_DEL_BW_UPCALL:
421 			error = ip_mrouter_set(so, optname, m);
422 			break;
423 #endif
424 
425 		default:
426 			error = ip_ctloutput(op, so, level, optname, m);
427 			break;
428 		}
429 		break;
430 
431 	case PRCO_GETOPT:
432 		switch (optname) {
433 		case IP_HDRINCL:
434 			*m = m_get(M_WAIT, MT_SOOPTS);
435 			MCLAIM((*m), so->so_mowner);
436 			(*m)->m_len = sizeof (int);
437 			*mtod(*m, int *) = inp->inp_flags & INP_HDRINCL ? 1 : 0;
438 			break;
439 
440 #ifdef MROUTING
441 		case MRT_VERSION:
442 		case MRT_ASSERT:
443 		case MRT_API_SUPPORT:
444 		case MRT_API_CONFIG:
445 			error = ip_mrouter_get(so, optname, m);
446 			break;
447 #endif
448 
449 		default:
450 			error = ip_ctloutput(op, so, level, optname, m);
451 			break;
452 		}
453 		break;
454 	}
455 	return (error);
456 }
457 
458 int
459 rip_bind(struct inpcb *inp, struct mbuf *nam)
460 {
461 	struct sockaddr_in *addr = mtod(nam, struct sockaddr_in *);
462 
463 	if (nam->m_len != sizeof(*addr))
464 		return (EINVAL);
465 	if (TAILQ_FIRST(&ifnet) == 0)
466 		return (EADDRNOTAVAIL);
467 	if (addr->sin_family != AF_INET &&
468 	    addr->sin_family != AF_IMPLINK)
469 		return (EAFNOSUPPORT);
470 	if (!in_nullhost(addr->sin_addr) &&
471 	    ifa_ifwithaddr(sintosa(addr)) == 0)
472 		return (EADDRNOTAVAIL);
473 	inp->inp_laddr = addr->sin_addr;
474 	return (0);
475 }
476 
477 int
478 rip_connect(struct inpcb *inp, struct mbuf *nam)
479 {
480 	struct sockaddr_in *addr = mtod(nam, struct sockaddr_in *);
481 
482 	if (nam->m_len != sizeof(*addr))
483 		return (EINVAL);
484 	if (TAILQ_FIRST(&ifnet) == 0)
485 		return (EADDRNOTAVAIL);
486 	if (addr->sin_family != AF_INET &&
487 	    addr->sin_family != AF_IMPLINK)
488 		return (EAFNOSUPPORT);
489 	inp->inp_faddr = addr->sin_addr;
490 	return (0);
491 }
492 
493 void
494 rip_disconnect(struct inpcb *inp)
495 {
496 
497 	inp->inp_faddr = zeroin_addr;
498 }
499 
500 u_long	rip_sendspace = RIPSNDQ;
501 u_long	rip_recvspace = RIPRCVQ;
502 
503 /*ARGSUSED*/
504 int
505 rip_usrreq(struct socket *so, int req,
506     struct mbuf *m, struct mbuf *nam, struct mbuf *control, struct lwp *l)
507 {
508 	struct inpcb *inp;
509 	struct proc *p;
510 	int s;
511 	int error = 0;
512 #ifdef MROUTING
513 	extern struct socket *ip_mrouter;
514 #endif
515 
516 	p = l ? l->l_proc : NULL;
517 	if (req == PRU_CONTROL)
518 		return (in_control(so, (long)m, (caddr_t)nam,
519 		    (struct ifnet *)control, p));
520 
521 	if (req == PRU_PURGEIF) {
522 		in_pcbpurgeif0(&rawcbtable, (struct ifnet *)control);
523 		in_purgeif((struct ifnet *)control);
524 		in_pcbpurgeif(&rawcbtable, (struct ifnet *)control);
525 		return (0);
526 	}
527 
528 	s = splsoftnet();
529 	inp = sotoinpcb(so);
530 #ifdef DIAGNOSTIC
531 	if (req != PRU_SEND && req != PRU_SENDOOB && control)
532 		panic("rip_usrreq: unexpected control mbuf");
533 #endif
534 	if (inp == 0 && req != PRU_ATTACH) {
535 		error = EINVAL;
536 		goto release;
537 	}
538 
539 	switch (req) {
540 
541 	case PRU_ATTACH:
542 		if (inp != 0) {
543 			error = EISCONN;
544 			break;
545 		}
546 		if (p == 0 || (error = kauth_authorize_generic(p->p_cred,
547 						KAUTH_GENERIC_ISSUSER, &p->p_acflag))) {
548 			error = EACCES;
549 			break;
550 		}
551 		if (so->so_snd.sb_hiwat == 0 || so->so_rcv.sb_hiwat == 0) {
552 			error = soreserve(so, rip_sendspace, rip_recvspace);
553 			if (error)
554 				break;
555 		}
556 		error = in_pcballoc(so, &rawcbtable);
557 		if (error)
558 			break;
559 		inp = sotoinpcb(so);
560 		inp->inp_ip.ip_p = (long)nam;
561 		break;
562 
563 	case PRU_DETACH:
564 #ifdef MROUTING
565 		if (so == ip_mrouter)
566 			ip_mrouter_done();
567 #endif
568 		in_pcbdetach(inp);
569 		break;
570 
571 	case PRU_BIND:
572 		error = rip_bind(inp, nam);
573 		break;
574 
575 	case PRU_LISTEN:
576 		error = EOPNOTSUPP;
577 		break;
578 
579 	case PRU_CONNECT:
580 		error = rip_connect(inp, nam);
581 		if (error)
582 			break;
583 		soisconnected(so);
584 		break;
585 
586 	case PRU_CONNECT2:
587 		error = EOPNOTSUPP;
588 		break;
589 
590 	case PRU_DISCONNECT:
591 		soisdisconnected(so);
592 		rip_disconnect(inp);
593 		break;
594 
595 	/*
596 	 * Mark the connection as being incapable of further input.
597 	 */
598 	case PRU_SHUTDOWN:
599 		socantsendmore(so);
600 		break;
601 
602 	case PRU_RCVD:
603 		error = EOPNOTSUPP;
604 		break;
605 
606 	/*
607 	 * Ship a packet out.  The appropriate raw output
608 	 * routine handles any massaging necessary.
609 	 */
610 	case PRU_SEND:
611 		if (control && control->m_len) {
612 			m_freem(control);
613 			m_freem(m);
614 			error = EINVAL;
615 			break;
616 		}
617 	{
618 		if (nam) {
619 			if ((so->so_state & SS_ISCONNECTED) != 0) {
620 				error = EISCONN;
621 				goto die;
622 			}
623 			error = rip_connect(inp, nam);
624 			if (error) {
625 			die:
626 				m_freem(m);
627 				break;
628 			}
629 		} else {
630 			if ((so->so_state & SS_ISCONNECTED) == 0) {
631 				error = ENOTCONN;
632 				goto die;
633 			}
634 		}
635 		error = rip_output(m, inp);
636 		if (nam)
637 			rip_disconnect(inp);
638 	}
639 		break;
640 
641 	case PRU_SENSE:
642 		/*
643 		 * stat: don't bother with a blocksize.
644 		 */
645 		splx(s);
646 		return (0);
647 
648 	case PRU_RCVOOB:
649 		error = EOPNOTSUPP;
650 		break;
651 
652 	case PRU_SENDOOB:
653 		m_freem(control);
654 		m_freem(m);
655 		error = EOPNOTSUPP;
656 		break;
657 
658 	case PRU_SOCKADDR:
659 		in_setsockaddr(inp, nam);
660 		break;
661 
662 	case PRU_PEERADDR:
663 		in_setpeeraddr(inp, nam);
664 		break;
665 
666 	default:
667 		panic("rip_usrreq");
668 	}
669 
670 release:
671 	splx(s);
672 	return (error);
673 }
674 
675 SYSCTL_SETUP(sysctl_net_inet_raw_setup, "sysctl net.inet.raw subtree setup")
676 {
677 
678 	sysctl_createv(clog, 0, NULL, NULL,
679 		       CTLFLAG_PERMANENT,
680 		       CTLTYPE_NODE, "net", NULL,
681 		       NULL, 0, NULL, 0,
682 		       CTL_NET, CTL_EOL);
683 	sysctl_createv(clog, 0, NULL, NULL,
684 		       CTLFLAG_PERMANENT,
685 		       CTLTYPE_NODE, "inet", NULL,
686 		       NULL, 0, NULL, 0,
687 		       CTL_NET, PF_INET, CTL_EOL);
688 	sysctl_createv(clog, 0, NULL, NULL,
689 		       CTLFLAG_PERMANENT,
690 		       CTLTYPE_NODE, "raw",
691 		       SYSCTL_DESCR("Raw IPv4 settings"),
692 		       NULL, 0, NULL, 0,
693 		       CTL_NET, PF_INET, IPPROTO_RAW, CTL_EOL);
694 
695 	sysctl_createv(clog, 0, NULL, NULL,
696 		       CTLFLAG_PERMANENT,
697 		       CTLTYPE_STRUCT, "pcblist",
698 		       SYSCTL_DESCR("Raw IPv4 control block list"),
699 		       sysctl_inpcblist, 0, &rawcbtable, 0,
700 		       CTL_NET, PF_INET, IPPROTO_RAW,
701 		       CTL_CREATE, CTL_EOL);
702 }
703