2 * Copyright (c) 1988, 1991, 1993
3 * The Regents of the University of California. All rights reserved.
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 * 4. Neither the name of the University nor the names of its contributors
14 * may be used to endorse or promote products derived from this software
15 * without specific prior written permission.
17 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
18 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
21 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29 * @(#)rtsock.c 8.7 (Berkeley) 10/12/95
32 #include "opt_compat.h"
34 #include "opt_mpath.h"
36 #include "opt_inet6.h"
38 #include <sys/param.h>
40 #include <sys/kernel.h>
41 #include <sys/domain.h>
43 #include <sys/malloc.h>
47 #include <sys/protosw.h>
48 #include <sys/rwlock.h>
49 #include <sys/signalvar.h>
50 #include <sys/socket.h>
51 #include <sys/socketvar.h>
52 #include <sys/sysctl.h>
53 #include <sys/systm.h>
56 #include <net/if_dl.h>
57 #include <net/if_llatbl.h>
58 #include <net/if_types.h>
59 #include <net/netisr.h>
60 #include <net/raw_cb.h>
61 #include <net/route.h>
64 #include <netinet/in.h>
65 #include <netinet/if_ether.h>
67 #include <netinet6/scope6_var.h>
70 #if defined(INET) || defined(INET6)
72 extern void sctp_addr_change(struct ifaddr *ifa, int cmd);
76 #ifdef COMPAT_FREEBSD32
77 #include <sys/mount.h>
78 #include <compat/freebsd32/freebsd32.h>
85 uint8_t ifi_link_state;
86 uint8_t ifi_spare_char1;
87 uint8_t ifi_spare_char2;
91 uint32_t ifi_baudrate;
92 uint32_t ifi_ipackets;
94 uint32_t ifi_opackets;
96 uint32_t ifi_collisions;
100 uint32_t ifi_omcasts;
101 uint32_t ifi_iqdrops;
102 uint32_t ifi_noproto;
103 uint32_t ifi_hwassist;
105 struct timeval32 ifi_lastchange;
115 struct if_data32 ifm_data;
119 MALLOC_DEFINE(M_RTABLE, "routetbl", "routing tables");
121 /* NB: these are not modified */
122 static struct sockaddr route_src = { 2, PF_ROUTE, };
123 static struct sockaddr sa_zero = { sizeof(sa_zero), AF_INET, };
126 int ip_count; /* attached w/ AF_INET */
127 int ip6_count; /* attached w/ AF_INET6 */
128 int ipx_count; /* attached w/ AF_IPX */
129 int any_count; /* total attached */
132 struct mtx rtsock_mtx;
133 MTX_SYSINIT(rtsock, &rtsock_mtx, "rtsock route_cb lock", MTX_DEF);
135 #define RTSOCK_LOCK() mtx_lock(&rtsock_mtx)
136 #define RTSOCK_UNLOCK() mtx_unlock(&rtsock_mtx)
137 #define RTSOCK_LOCK_ASSERT() mtx_assert(&rtsock_mtx, MA_OWNED)
139 SYSCTL_NODE(_net, OID_AUTO, route, CTLFLAG_RD, 0, "");
145 struct sysctl_req *w_req;
148 static void rts_input(struct mbuf *m);
149 static struct mbuf *rt_msg1(int type, struct rt_addrinfo *rtinfo);
150 static int rt_msg2(int type, struct rt_addrinfo *rtinfo,
151 caddr_t cp, struct walkarg *w);
152 static int rt_xaddrs(caddr_t cp, caddr_t cplim,
153 struct rt_addrinfo *rtinfo);
154 static int sysctl_dumpentry(struct radix_node *rn, void *vw);
155 static int sysctl_iflist(int af, struct walkarg *w);
156 static int sysctl_ifmalist(int af, struct walkarg *w);
157 static int route_output(struct mbuf *m, struct socket *so);
158 static void rt_setmetrics(u_long which, const struct rt_metrics *in,
159 struct rt_metrics_lite *out);
160 static void rt_getmetrics(const struct rt_metrics_lite *in,
161 struct rt_metrics *out);
162 static void rt_dispatch(struct mbuf *, const struct sockaddr *);
164 static struct netisr_handler rtsock_nh = {
166 .nh_handler = rts_input,
167 .nh_proto = NETISR_ROUTE,
168 .nh_policy = NETISR_POLICY_SOURCE,
172 sysctl_route_netisr_maxqlen(SYSCTL_HANDLER_ARGS)
176 netisr_getqlimit(&rtsock_nh, &qlimit);
177 error = sysctl_handle_int(oidp, &qlimit, 0, req);
178 if (error || !req->newptr)
182 return (netisr_setqlimit(&rtsock_nh, qlimit));
184 SYSCTL_PROC(_net_route, OID_AUTO, netisr_maxqlen, CTLTYPE_INT|CTLFLAG_RW,
185 0, 0, sysctl_route_netisr_maxqlen, "I",
186 "maximum routing socket dispatch queue length");
193 if (TUNABLE_INT_FETCH("net.route.netisr_maxqlen", &tmp))
194 rtsock_nh.nh_qlimit = tmp;
195 netisr_register(&rtsock_nh);
197 SYSINIT(rtsock, SI_SUB_PROTO_DOMAIN, SI_ORDER_THIRD, rts_init, 0);
200 rts_input(struct mbuf *m)
202 struct sockproto route_proto;
203 unsigned short *family;
206 route_proto.sp_family = PF_ROUTE;
207 tag = m_tag_find(m, PACKET_TAG_RTSOCKFAM, NULL);
209 family = (unsigned short *)(tag + 1);
210 route_proto.sp_protocol = *family;
211 m_tag_delete(m, tag);
213 route_proto.sp_protocol = 0;
215 raw_input(m, &route_proto, &route_src);
219 * It really doesn't make any sense at all for this code to share much
220 * with raw_usrreq.c, since its functionality is so restricted. XXX
223 rts_abort(struct socket *so)
226 raw_usrreqs.pru_abort(so);
230 rts_close(struct socket *so)
233 raw_usrreqs.pru_close(so);
236 /* pru_accept is EOPNOTSUPP */
239 rts_attach(struct socket *so, int proto, struct thread *td)
244 KASSERT(so->so_pcb == NULL, ("rts_attach: so_pcb != NULL"));
247 rp = malloc(sizeof *rp, M_PCB, M_WAITOK | M_ZERO);
252 * The splnet() is necessary to block protocols from sending
253 * error notifications (like RTM_REDIRECT or RTM_LOSING) while
254 * this PCB is extant but incompletely initialized.
255 * Probably we should try to do more of this work beforehand and
259 so->so_pcb = (caddr_t)rp;
260 so->so_fibnum = td->td_proc->p_fibnum;
261 error = raw_attach(so, proto);
270 switch(rp->rcb_proto.sp_protocol) {
275 route_cb.ip6_count++;
278 route_cb.ipx_count++;
281 route_cb.any_count++;
284 so->so_options |= SO_USELOOPBACK;
290 rts_bind(struct socket *so, struct sockaddr *nam, struct thread *td)
293 return (raw_usrreqs.pru_bind(so, nam, td)); /* xxx just EINVAL */
297 rts_connect(struct socket *so, struct sockaddr *nam, struct thread *td)
300 return (raw_usrreqs.pru_connect(so, nam, td)); /* XXX just EINVAL */
303 /* pru_connect2 is EOPNOTSUPP */
304 /* pru_control is EOPNOTSUPP */
307 rts_detach(struct socket *so)
309 struct rawcb *rp = sotorawcb(so);
311 KASSERT(rp != NULL, ("rts_detach: rp == NULL"));
314 switch(rp->rcb_proto.sp_protocol) {
319 route_cb.ip6_count--;
322 route_cb.ipx_count--;
325 route_cb.any_count--;
327 raw_usrreqs.pru_detach(so);
331 rts_disconnect(struct socket *so)
334 return (raw_usrreqs.pru_disconnect(so));
337 /* pru_listen is EOPNOTSUPP */
340 rts_peeraddr(struct socket *so, struct sockaddr **nam)
343 return (raw_usrreqs.pru_peeraddr(so, nam));
346 /* pru_rcvd is EOPNOTSUPP */
347 /* pru_rcvoob is EOPNOTSUPP */
350 rts_send(struct socket *so, int flags, struct mbuf *m, struct sockaddr *nam,
351 struct mbuf *control, struct thread *td)
354 return (raw_usrreqs.pru_send(so, flags, m, nam, control, td));
357 /* pru_sense is null */
360 rts_shutdown(struct socket *so)
363 return (raw_usrreqs.pru_shutdown(so));
367 rts_sockaddr(struct socket *so, struct sockaddr **nam)
370 return (raw_usrreqs.pru_sockaddr(so, nam));
373 static struct pr_usrreqs route_usrreqs = {
374 .pru_abort = rts_abort,
375 .pru_attach = rts_attach,
376 .pru_bind = rts_bind,
377 .pru_connect = rts_connect,
378 .pru_detach = rts_detach,
379 .pru_disconnect = rts_disconnect,
380 .pru_peeraddr = rts_peeraddr,
381 .pru_send = rts_send,
382 .pru_shutdown = rts_shutdown,
383 .pru_sockaddr = rts_sockaddr,
384 .pru_close = rts_close,
387 #ifndef _SOCKADDR_UNION_DEFINED
388 #define _SOCKADDR_UNION_DEFINED
390 * The union of all possible address formats we handle.
392 union sockaddr_union {
394 struct sockaddr_in sin;
395 struct sockaddr_in6 sin6;
397 #endif /* _SOCKADDR_UNION_DEFINED */
400 rtm_get_jailed(struct rt_addrinfo *info, struct ifnet *ifp,
401 struct rtentry *rt, union sockaddr_union *saun, struct ucred *cred)
404 /* First, see if the returned address is part of the jail. */
405 if (prison_if(cred, rt->rt_ifa->ifa_addr) == 0) {
406 info->rti_info[RTAX_IFA] = rt->rt_ifa->ifa_addr;
410 switch (info->rti_info[RTAX_DST]->sa_family) {
420 * Try to find an address on the given outgoing interface
421 * that belongs to the jail.
424 TAILQ_FOREACH(ifa, &ifp->if_addrhead, ifa_link) {
427 if (sa->sa_family != AF_INET)
429 ia = ((struct sockaddr_in *)sa)->sin_addr;
430 if (prison_check_ip4(cred, &ia) == 0) {
438 * As a last resort return the 'default' jail address.
440 ia = ((struct sockaddr_in *)rt->rt_ifa->ifa_addr)->
442 if (prison_get_ip4(cred, &ia) != 0)
445 bzero(&saun->sin, sizeof(struct sockaddr_in));
446 saun->sin.sin_len = sizeof(struct sockaddr_in);
447 saun->sin.sin_family = AF_INET;
448 saun->sin.sin_addr.s_addr = ia.s_addr;
449 info->rti_info[RTAX_IFA] = (struct sockaddr *)&saun->sin;
462 * Try to find an address on the given outgoing interface
463 * that belongs to the jail.
466 TAILQ_FOREACH(ifa, &ifp->if_addrhead, ifa_link) {
469 if (sa->sa_family != AF_INET6)
471 bcopy(&((struct sockaddr_in6 *)sa)->sin6_addr,
472 &ia6, sizeof(struct in6_addr));
473 if (prison_check_ip6(cred, &ia6) == 0) {
481 * As a last resort return the 'default' jail address.
483 ia6 = ((struct sockaddr_in6 *)rt->rt_ifa->ifa_addr)->
485 if (prison_get_ip6(cred, &ia6) != 0)
488 bzero(&saun->sin6, sizeof(struct sockaddr_in6));
489 saun->sin6.sin6_len = sizeof(struct sockaddr_in6);
490 saun->sin6.sin6_family = AF_INET6;
491 bcopy(&ia6, &saun->sin6.sin6_addr, sizeof(struct in6_addr));
492 if (sa6_recoverscope(&saun->sin6) != 0)
494 info->rti_info[RTAX_IFA] = (struct sockaddr *)&saun->sin6;
506 route_output(struct mbuf *m, struct socket *so)
508 #define sa_equal(a1, a2) (bcmp((a1), (a2), (a1)->sa_len) == 0)
509 struct rt_msghdr *rtm = NULL;
510 struct rtentry *rt = NULL;
511 struct radix_node_head *rnh;
512 struct rt_addrinfo info;
514 struct ifnet *ifp = NULL;
515 union sockaddr_union saun;
517 #define senderr(e) { error = e; goto flush;}
518 if (m == NULL || ((m->m_len < sizeof(long)) &&
519 (m = m_pullup(m, sizeof(long))) == NULL))
521 if ((m->m_flags & M_PKTHDR) == 0)
522 panic("route_output");
523 len = m->m_pkthdr.len;
524 if (len < sizeof(*rtm) ||
525 len != mtod(m, struct rt_msghdr *)->rtm_msglen) {
526 info.rti_info[RTAX_DST] = NULL;
529 R_Malloc(rtm, struct rt_msghdr *, len);
531 info.rti_info[RTAX_DST] = NULL;
534 m_copydata(m, 0, len, (caddr_t)rtm);
535 if (rtm->rtm_version != RTM_VERSION) {
536 info.rti_info[RTAX_DST] = NULL;
537 senderr(EPROTONOSUPPORT);
539 rtm->rtm_pid = curproc->p_pid;
540 bzero(&info, sizeof(info));
541 info.rti_addrs = rtm->rtm_addrs;
542 if (rt_xaddrs((caddr_t)(rtm + 1), len + (caddr_t)rtm, &info)) {
543 info.rti_info[RTAX_DST] = NULL;
546 info.rti_flags = rtm->rtm_flags;
547 if (info.rti_info[RTAX_DST] == NULL ||
548 info.rti_info[RTAX_DST]->sa_family >= AF_MAX ||
549 (info.rti_info[RTAX_GATEWAY] != NULL &&
550 info.rti_info[RTAX_GATEWAY]->sa_family >= AF_MAX))
553 * Verify that the caller has the appropriate privilege; RTM_GET
554 * is the only operation the non-superuser is allowed.
556 if (rtm->rtm_type != RTM_GET) {
557 error = priv_check(curthread, PRIV_NET_ROUTE);
563 * The given gateway address may be an interface address.
564 * For example, issuing a "route change" command on a route
565 * entry that was created from a tunnel, and the gateway
566 * address given is the local end point. In this case the
567 * RTF_GATEWAY flag must be cleared or the destination will
568 * not be reachable even though there is no error message.
570 if (info.rti_info[RTAX_GATEWAY] != NULL &&
571 info.rti_info[RTAX_GATEWAY]->sa_family != AF_LINK) {
574 bzero(&gw_ro, sizeof(gw_ro));
575 gw_ro.ro_dst = *info.rti_info[RTAX_GATEWAY];
576 rtalloc_ign_fib(&gw_ro, 0, so->so_fibnum);
578 * A host route through the loopback interface is
579 * installed for each interface adddress. In pre 8.0
580 * releases the interface address of a PPP link type
581 * is not reachable locally. This behavior is fixed as
582 * part of the new L2/L3 redesign and rewrite work. The
583 * signature of this interface address route is the
584 * AF_LINK sa_family type of the rt_gateway, and the
585 * rt_ifp has the IFF_LOOPBACK flag set.
587 if (gw_ro.ro_rt != NULL &&
588 gw_ro.ro_rt->rt_gateway->sa_family == AF_LINK &&
589 gw_ro.ro_rt->rt_ifp->if_flags & IFF_LOOPBACK)
590 info.rti_flags &= ~RTF_GATEWAY;
591 if (gw_ro.ro_rt != NULL)
595 switch (rtm->rtm_type) {
596 struct rtentry *saved_nrt;
599 if (info.rti_info[RTAX_GATEWAY] == NULL)
603 /* support for new ARP code */
604 if (info.rti_info[RTAX_GATEWAY]->sa_family == AF_LINK &&
605 (rtm->rtm_flags & RTF_LLDATA) != 0) {
606 error = lla_rt_output(rtm, &info);
609 error = rtrequest1_fib(RTM_ADD, &info, &saved_nrt,
611 if (error == 0 && saved_nrt) {
613 rt_setmetrics(rtm->rtm_inits,
614 &rtm->rtm_rmx, &saved_nrt->rt_rmx);
615 rtm->rtm_index = saved_nrt->rt_ifp->if_index;
616 RT_REMREF(saved_nrt);
617 RT_UNLOCK(saved_nrt);
623 /* support for new ARP code */
624 if (info.rti_info[RTAX_GATEWAY] &&
625 (info.rti_info[RTAX_GATEWAY]->sa_family == AF_LINK) &&
626 (rtm->rtm_flags & RTF_LLDATA) != 0) {
627 error = lla_rt_output(rtm, &info);
630 error = rtrequest1_fib(RTM_DELETE, &info, &saved_nrt,
642 rnh = rt_tables_get_rnh(so->so_fibnum,
643 info.rti_info[RTAX_DST]->sa_family);
645 senderr(EAFNOSUPPORT);
646 RADIX_NODE_HEAD_RLOCK(rnh);
647 rt = (struct rtentry *) rnh->rnh_lookup(info.rti_info[RTAX_DST],
648 info.rti_info[RTAX_NETMASK], rnh);
649 if (rt == NULL) { /* XXX looks bogus */
650 RADIX_NODE_HEAD_RUNLOCK(rnh);
655 * for RTM_CHANGE/LOCK, if we got multipath routes,
656 * we require users to specify a matching RTAX_GATEWAY.
658 * for RTM_GET, gate is optional even with multipath.
659 * if gate == NULL the first match is returned.
660 * (no need to call rt_mpath_matchgate if gate == NULL)
662 if (rn_mpath_capable(rnh) &&
663 (rtm->rtm_type != RTM_GET || info.rti_info[RTAX_GATEWAY])) {
664 rt = rt_mpath_matchgate(rt, info.rti_info[RTAX_GATEWAY]);
666 RADIX_NODE_HEAD_RUNLOCK(rnh);
672 * If performing proxied L2 entry insertion, and
673 * the actual PPP host entry is found, perform
674 * another search to retrieve the prefix route of
675 * the local end point of the PPP link.
677 if (rtm->rtm_flags & RTF_ANNOUNCE) {
678 struct sockaddr laddr;
680 if (rt->rt_ifp != NULL &&
681 rt->rt_ifp->if_type == IFT_PROPVIRTUAL) {
684 ifa = ifa_ifwithnet(info.rti_info[RTAX_DST], 1);
686 rt_maskedcopy(ifa->ifa_addr,
690 rt_maskedcopy(rt->rt_ifa->ifa_addr,
692 rt->rt_ifa->ifa_netmask);
694 * refactor rt and no lock operation necessary
696 rt = (struct rtentry *)rnh->rnh_matchaddr(&laddr, rnh);
698 RADIX_NODE_HEAD_RUNLOCK(rnh);
704 RADIX_NODE_HEAD_RUNLOCK(rnh);
709 * RTM_CHANGE/LOCK need a perfect match, rn_lookup()
710 * returns a perfect match in case a netmask is
711 * specified. For host routes only a longest prefix
712 * match is returned so it is necessary to compare the
713 * existence of the netmask. If both have a netmask
714 * rnh_lookup() did a perfect match and if none of them
715 * have a netmask both are host routes which is also a
719 if (rtm->rtm_type != RTM_GET &&
720 (!rt_mask(rt) != !info.rti_info[RTAX_NETMASK])) {
725 switch(rtm->rtm_type) {
730 if ((rt->rt_flags & RTF_HOST) == 0
731 ? jailed_without_vnet(curthread->td_ucred)
732 : prison_if(curthread->td_ucred,
737 info.rti_info[RTAX_DST] = rt_key(rt);
738 info.rti_info[RTAX_GATEWAY] = rt->rt_gateway;
739 info.rti_info[RTAX_NETMASK] = rt_mask(rt);
740 info.rti_info[RTAX_GENMASK] = 0;
741 if (rtm->rtm_addrs & (RTA_IFP | RTA_IFA)) {
744 info.rti_info[RTAX_IFP] =
745 ifp->if_addr->ifa_addr;
746 error = rtm_get_jailed(&info, ifp, rt,
747 &saun, curthread->td_ucred);
752 if (ifp->if_flags & IFF_POINTOPOINT)
753 info.rti_info[RTAX_BRD] =
754 rt->rt_ifa->ifa_dstaddr;
755 rtm->rtm_index = ifp->if_index;
757 info.rti_info[RTAX_IFP] = NULL;
758 info.rti_info[RTAX_IFA] = NULL;
760 } else if ((ifp = rt->rt_ifp) != NULL) {
761 rtm->rtm_index = ifp->if_index;
763 len = rt_msg2(rtm->rtm_type, &info, NULL, NULL);
764 if (len > rtm->rtm_msglen) {
765 struct rt_msghdr *new_rtm;
766 R_Malloc(new_rtm, struct rt_msghdr *, len);
767 if (new_rtm == NULL) {
771 bcopy(rtm, new_rtm, rtm->rtm_msglen);
772 Free(rtm); rtm = new_rtm;
774 (void)rt_msg2(rtm->rtm_type, &info, (caddr_t)rtm, NULL);
775 rtm->rtm_flags = rt->rt_flags;
776 rt_getmetrics(&rt->rt_rmx, &rtm->rtm_rmx);
777 rtm->rtm_addrs = info.rti_addrs;
782 * New gateway could require new ifaddr, ifp;
783 * flags may also be different; ifp may be specified
784 * by ll sockaddr when protocol address is ambiguous
786 if (((rt->rt_flags & RTF_GATEWAY) &&
787 info.rti_info[RTAX_GATEWAY] != NULL) ||
788 info.rti_info[RTAX_IFP] != NULL ||
789 (info.rti_info[RTAX_IFA] != NULL &&
790 !sa_equal(info.rti_info[RTAX_IFA],
791 rt->rt_ifa->ifa_addr))) {
793 RADIX_NODE_HEAD_LOCK(rnh);
794 error = rt_getifa_fib(&info, rt->rt_fibnum);
796 * XXXRW: Really we should release this
797 * reference later, but this maintains
798 * historical behavior.
800 if (info.rti_ifa != NULL)
801 ifa_free(info.rti_ifa);
802 RADIX_NODE_HEAD_UNLOCK(rnh);
807 if (info.rti_ifa != NULL &&
808 info.rti_ifa != rt->rt_ifa &&
809 rt->rt_ifa != NULL &&
810 rt->rt_ifa->ifa_rtrequest != NULL) {
811 rt->rt_ifa->ifa_rtrequest(RTM_DELETE, rt,
813 ifa_free(rt->rt_ifa);
815 if (info.rti_info[RTAX_GATEWAY] != NULL) {
817 RADIX_NODE_HEAD_LOCK(rnh);
820 error = rt_setgate(rt, rt_key(rt),
821 info.rti_info[RTAX_GATEWAY]);
822 RADIX_NODE_HEAD_UNLOCK(rnh);
827 rt->rt_flags |= (RTF_GATEWAY & info.rti_flags);
829 if (info.rti_ifa != NULL &&
830 info.rti_ifa != rt->rt_ifa) {
831 ifa_ref(info.rti_ifa);
832 rt->rt_ifa = info.rti_ifa;
833 rt->rt_ifp = info.rti_ifp;
835 /* Allow some flags to be toggled on change. */
836 rt->rt_flags = (rt->rt_flags & ~RTF_FMASK) |
837 (rtm->rtm_flags & RTF_FMASK);
838 rt_setmetrics(rtm->rtm_inits, &rtm->rtm_rmx,
840 rtm->rtm_index = rt->rt_ifp->if_index;
841 if (rt->rt_ifa && rt->rt_ifa->ifa_rtrequest)
842 rt->rt_ifa->ifa_rtrequest(RTM_ADD, rt, &info);
845 /* We don't support locks anymore */
858 rtm->rtm_errno = error;
860 rtm->rtm_flags |= RTF_DONE;
862 if (rt) /* XXX can this be true? */
865 struct rawcb *rp = NULL;
867 * Check to see if we don't want our own messages.
869 if ((so->so_options & SO_USELOOPBACK) == 0) {
870 if (route_cb.any_count <= 1) {
876 /* There is another listener, so construct message */
880 m_copyback(m, 0, rtm->rtm_msglen, (caddr_t)rtm);
881 if (m->m_pkthdr.len < rtm->rtm_msglen) {
884 } else if (m->m_pkthdr.len > rtm->rtm_msglen)
885 m_adj(m, rtm->rtm_msglen - m->m_pkthdr.len);
891 * XXX insure we don't get a copy by
892 * invalidating our protocol
894 unsigned short family = rp->rcb_proto.sp_family;
895 rp->rcb_proto.sp_family = 0;
896 rt_dispatch(m, info.rti_info[RTAX_DST]);
897 rp->rcb_proto.sp_family = family;
899 rt_dispatch(m, info.rti_info[RTAX_DST]);
907 rt_setmetrics(u_long which, const struct rt_metrics *in,
908 struct rt_metrics_lite *out)
910 #define metric(f, e) if (which & (f)) out->e = in->e;
912 * Only these are stored in the routing entry since introduction
913 * of tcp hostcache. The rest is ignored.
915 metric(RTV_MTU, rmx_mtu);
916 metric(RTV_WEIGHT, rmx_weight);
917 /* Userland -> kernel timebase conversion. */
918 if (which & RTV_EXPIRE)
919 out->rmx_expire = in->rmx_expire ?
920 in->rmx_expire - time_second + time_uptime : 0;
925 rt_getmetrics(const struct rt_metrics_lite *in, struct rt_metrics *out)
927 #define metric(e) out->e = in->e;
928 bzero(out, sizeof(*out));
931 /* Kernel -> userland timebase conversion. */
932 out->rmx_expire = in->rmx_expire ?
933 in->rmx_expire - time_uptime + time_second : 0;
938 * Extract the addresses of the passed sockaddrs.
939 * Do a little sanity checking so as to avoid bad memory references.
940 * This data is derived straight from userland.
943 rt_xaddrs(caddr_t cp, caddr_t cplim, struct rt_addrinfo *rtinfo)
948 for (i = 0; i < RTAX_MAX && cp < cplim; i++) {
949 if ((rtinfo->rti_addrs & (1 << i)) == 0)
951 sa = (struct sockaddr *)cp;
955 if (cp + sa->sa_len > cplim)
958 * there are no more.. quit now
959 * If there are more bits, they are in error.
960 * I've seen this. route(1) can evidently generate these.
961 * This causes kernel to core dump.
962 * for compatibility, If we see this, point to a safe address.
964 if (sa->sa_len == 0) {
965 rtinfo->rti_info[i] = &sa_zero;
966 return (0); /* should be EINVAL but for compat */
969 rtinfo->rti_info[i] = sa;
976 rt_msg1(int type, struct rt_addrinfo *rtinfo)
978 struct rt_msghdr *rtm;
988 len = sizeof(struct ifa_msghdr);
993 len = sizeof(struct ifma_msghdr);
997 len = sizeof(struct if_msghdr);
1000 case RTM_IFANNOUNCE:
1002 len = sizeof(struct if_announcemsghdr);
1006 len = sizeof(struct rt_msghdr);
1010 m = m_gethdr(M_DONTWAIT, MT_DATA);
1011 if (m && len > MHLEN) {
1012 MCLGET(m, M_DONTWAIT);
1013 if ((m->m_flags & M_EXT) == 0) {
1020 m->m_pkthdr.len = m->m_len = len;
1021 m->m_pkthdr.rcvif = NULL;
1022 rtm = mtod(m, struct rt_msghdr *);
1023 bzero((caddr_t)rtm, len);
1024 for (i = 0; i < RTAX_MAX; i++) {
1025 if ((sa = rtinfo->rti_info[i]) == NULL)
1027 rtinfo->rti_addrs |= (1 << i);
1029 m_copyback(m, len, dlen, (caddr_t)sa);
1032 if (m->m_pkthdr.len != len) {
1036 rtm->rtm_msglen = len;
1037 rtm->rtm_version = RTM_VERSION;
1038 rtm->rtm_type = type;
1043 rt_msg2(int type, struct rt_addrinfo *rtinfo, caddr_t cp, struct walkarg *w)
1046 int len, dlen, second_time = 0;
1049 rtinfo->rti_addrs = 0;
1055 len = sizeof(struct ifa_msghdr);
1059 #ifdef COMPAT_FREEBSD32
1060 if (w != NULL && w->w_req->flags & SCTL_MASK32) {
1061 len = sizeof(struct if_msghdr32);
1065 len = sizeof(struct if_msghdr);
1069 len = sizeof(struct ifma_msghdr);
1073 len = sizeof(struct rt_msghdr);
1078 for (i = 0; i < RTAX_MAX; i++) {
1079 struct sockaddr *sa;
1081 if ((sa = rtinfo->rti_info[i]) == NULL)
1083 rtinfo->rti_addrs |= (1 << i);
1086 bcopy((caddr_t)sa, cp, (unsigned)dlen);
1092 if (cp == NULL && w != NULL && !second_time) {
1093 struct walkarg *rw = w;
1096 if (rw->w_tmemsize < len) {
1098 free(rw->w_tmem, M_RTABLE);
1099 rw->w_tmem = (caddr_t)
1100 malloc(len, M_RTABLE, M_NOWAIT);
1102 rw->w_tmemsize = len;
1112 struct rt_msghdr *rtm = (struct rt_msghdr *)cp0;
1114 rtm->rtm_version = RTM_VERSION;
1115 rtm->rtm_type = type;
1116 rtm->rtm_msglen = len;
1122 * This routine is called to generate a message from the routing
1123 * socket indicating that a redirect has occured, a routing lookup
1124 * has failed, or that a protocol has detected timeouts to a particular
1128 rt_missmsg(int type, struct rt_addrinfo *rtinfo, int flags, int error)
1130 struct rt_msghdr *rtm;
1132 struct sockaddr *sa = rtinfo->rti_info[RTAX_DST];
1134 if (route_cb.any_count == 0)
1136 m = rt_msg1(type, rtinfo);
1139 rtm = mtod(m, struct rt_msghdr *);
1140 rtm->rtm_flags = RTF_DONE | flags;
1141 rtm->rtm_errno = error;
1142 rtm->rtm_addrs = rtinfo->rti_addrs;
1147 * This routine is called to generate a message from the routing
1148 * socket indicating that the status of a network interface has changed.
1151 rt_ifmsg(struct ifnet *ifp)
1153 struct if_msghdr *ifm;
1155 struct rt_addrinfo info;
1157 if (route_cb.any_count == 0)
1159 bzero((caddr_t)&info, sizeof(info));
1160 m = rt_msg1(RTM_IFINFO, &info);
1163 ifm = mtod(m, struct if_msghdr *);
1164 ifm->ifm_index = ifp->if_index;
1165 ifm->ifm_flags = ifp->if_flags | ifp->if_drv_flags;
1166 ifm->ifm_data = ifp->if_data;
1168 rt_dispatch(m, NULL);
1172 * This is called to generate messages from the routing socket
1173 * indicating a network interface has had addresses associated with it.
1174 * if we ever reverse the logic and replace messages TO the routing
1175 * socket indicate a request to configure interfaces, then it will
1176 * be unnecessary as the routing socket will automatically generate
1180 rt_newaddrmsg(int cmd, struct ifaddr *ifa, int error, struct rtentry *rt)
1182 struct rt_addrinfo info;
1183 struct sockaddr *sa = NULL;
1185 struct mbuf *m = NULL;
1186 struct ifnet *ifp = ifa->ifa_ifp;
1188 KASSERT(cmd == RTM_ADD || cmd == RTM_DELETE,
1189 ("unexpected cmd %u", cmd));
1190 #if defined(INET) || defined(INET6)
1193 * notify the SCTP stack
1194 * this will only get called when an address is added/deleted
1195 * XXX pass the ifaddr struct instead if ifa->ifa_addr...
1197 sctp_addr_change(ifa, cmd);
1200 if (route_cb.any_count == 0)
1202 for (pass = 1; pass < 3; pass++) {
1203 bzero((caddr_t)&info, sizeof(info));
1204 if ((cmd == RTM_ADD && pass == 1) ||
1205 (cmd == RTM_DELETE && pass == 2)) {
1206 struct ifa_msghdr *ifam;
1207 int ncmd = cmd == RTM_ADD ? RTM_NEWADDR : RTM_DELADDR;
1209 info.rti_info[RTAX_IFA] = sa = ifa->ifa_addr;
1210 info.rti_info[RTAX_IFP] = ifp->if_addr->ifa_addr;
1211 info.rti_info[RTAX_NETMASK] = ifa->ifa_netmask;
1212 info.rti_info[RTAX_BRD] = ifa->ifa_dstaddr;
1213 if ((m = rt_msg1(ncmd, &info)) == NULL)
1215 ifam = mtod(m, struct ifa_msghdr *);
1216 ifam->ifam_index = ifp->if_index;
1217 ifam->ifam_metric = ifa->ifa_metric;
1218 ifam->ifam_flags = ifa->ifa_flags;
1219 ifam->ifam_addrs = info.rti_addrs;
1221 if ((cmd == RTM_ADD && pass == 2) ||
1222 (cmd == RTM_DELETE && pass == 1)) {
1223 struct rt_msghdr *rtm;
1227 info.rti_info[RTAX_NETMASK] = rt_mask(rt);
1228 info.rti_info[RTAX_DST] = sa = rt_key(rt);
1229 info.rti_info[RTAX_GATEWAY] = rt->rt_gateway;
1230 if ((m = rt_msg1(cmd, &info)) == NULL)
1232 rtm = mtod(m, struct rt_msghdr *);
1233 rtm->rtm_index = ifp->if_index;
1234 rtm->rtm_flags |= rt->rt_flags;
1235 rtm->rtm_errno = error;
1236 rtm->rtm_addrs = info.rti_addrs;
1243 * This is the analogue to the rt_newaddrmsg which performs the same
1244 * function but for multicast group memberhips. This is easier since
1245 * there is no route state to worry about.
1248 rt_newmaddrmsg(int cmd, struct ifmultiaddr *ifma)
1250 struct rt_addrinfo info;
1251 struct mbuf *m = NULL;
1252 struct ifnet *ifp = ifma->ifma_ifp;
1253 struct ifma_msghdr *ifmam;
1255 if (route_cb.any_count == 0)
1258 bzero((caddr_t)&info, sizeof(info));
1259 info.rti_info[RTAX_IFA] = ifma->ifma_addr;
1260 info.rti_info[RTAX_IFP] = ifp ? ifp->if_addr->ifa_addr : NULL;
1262 * If a link-layer address is present, present it as a ``gateway''
1263 * (similarly to how ARP entries, e.g., are presented).
1265 info.rti_info[RTAX_GATEWAY] = ifma->ifma_lladdr;
1266 m = rt_msg1(cmd, &info);
1269 ifmam = mtod(m, struct ifma_msghdr *);
1270 KASSERT(ifp != NULL, ("%s: link-layer multicast address w/o ifp\n",
1272 ifmam->ifmam_index = ifp->if_index;
1273 ifmam->ifmam_addrs = info.rti_addrs;
1274 rt_dispatch(m, ifma->ifma_addr);
1277 static struct mbuf *
1278 rt_makeifannouncemsg(struct ifnet *ifp, int type, int what,
1279 struct rt_addrinfo *info)
1281 struct if_announcemsghdr *ifan;
1284 if (route_cb.any_count == 0)
1286 bzero((caddr_t)info, sizeof(*info));
1287 m = rt_msg1(type, info);
1289 ifan = mtod(m, struct if_announcemsghdr *);
1290 ifan->ifan_index = ifp->if_index;
1291 strlcpy(ifan->ifan_name, ifp->if_xname,
1292 sizeof(ifan->ifan_name));
1293 ifan->ifan_what = what;
1299 * This is called to generate routing socket messages indicating
1300 * IEEE80211 wireless events.
1301 * XXX we piggyback on the RTM_IFANNOUNCE msg format in a clumsy way.
1304 rt_ieee80211msg(struct ifnet *ifp, int what, void *data, size_t data_len)
1307 struct rt_addrinfo info;
1309 m = rt_makeifannouncemsg(ifp, RTM_IEEE80211, what, &info);
1312 * Append the ieee80211 data. Try to stick it in the
1313 * mbuf containing the ifannounce msg; otherwise allocate
1314 * a new mbuf and append.
1316 * NB: we assume m is a single mbuf.
1318 if (data_len > M_TRAILINGSPACE(m)) {
1319 struct mbuf *n = m_get(M_NOWAIT, MT_DATA);
1324 bcopy(data, mtod(n, void *), data_len);
1325 n->m_len = data_len;
1327 } else if (data_len > 0) {
1328 bcopy(data, mtod(m, u_int8_t *) + m->m_len, data_len);
1329 m->m_len += data_len;
1331 if (m->m_flags & M_PKTHDR)
1332 m->m_pkthdr.len += data_len;
1333 mtod(m, struct if_announcemsghdr *)->ifan_msglen += data_len;
1334 rt_dispatch(m, NULL);
1339 * This is called to generate routing socket messages indicating
1340 * network interface arrival and departure.
1343 rt_ifannouncemsg(struct ifnet *ifp, int what)
1346 struct rt_addrinfo info;
1348 m = rt_makeifannouncemsg(ifp, RTM_IFANNOUNCE, what, &info);
1350 rt_dispatch(m, NULL);
1354 rt_dispatch(struct mbuf *m, const struct sockaddr *sa)
1359 * Preserve the family from the sockaddr, if any, in an m_tag for
1360 * use when injecting the mbuf into the routing socket buffer from
1364 tag = m_tag_get(PACKET_TAG_RTSOCKFAM, sizeof(unsigned short),
1370 *(unsigned short *)(tag + 1) = sa->sa_family;
1371 m_tag_prepend(m, tag);
1375 m->m_pkthdr.rcvif = V_loif;
1381 netisr_queue(NETISR_ROUTE, m); /* mbuf is free'd on failure. */
1385 * This is used in dumping the kernel table via sysctl().
1388 sysctl_dumpentry(struct radix_node *rn, void *vw)
1390 struct walkarg *w = vw;
1391 struct rtentry *rt = (struct rtentry *)rn;
1392 int error = 0, size;
1393 struct rt_addrinfo info;
1395 if (w->w_op == NET_RT_FLAGS && !(rt->rt_flags & w->w_arg))
1397 if ((rt->rt_flags & RTF_HOST) == 0
1398 ? jailed_without_vnet(w->w_req->td->td_ucred)
1399 : prison_if(w->w_req->td->td_ucred, rt_key(rt)) != 0)
1401 bzero((caddr_t)&info, sizeof(info));
1402 info.rti_info[RTAX_DST] = rt_key(rt);
1403 info.rti_info[RTAX_GATEWAY] = rt->rt_gateway;
1404 info.rti_info[RTAX_NETMASK] = rt_mask(rt);
1405 info.rti_info[RTAX_GENMASK] = 0;
1407 info.rti_info[RTAX_IFP] = rt->rt_ifp->if_addr->ifa_addr;
1408 info.rti_info[RTAX_IFA] = rt->rt_ifa->ifa_addr;
1409 if (rt->rt_ifp->if_flags & IFF_POINTOPOINT)
1410 info.rti_info[RTAX_BRD] = rt->rt_ifa->ifa_dstaddr;
1412 size = rt_msg2(RTM_GET, &info, NULL, w);
1413 if (w->w_req && w->w_tmem) {
1414 struct rt_msghdr *rtm = (struct rt_msghdr *)w->w_tmem;
1416 rtm->rtm_flags = rt->rt_flags;
1418 * let's be honest about this being a retarded hack
1420 rtm->rtm_fmask = rt->rt_rmx.rmx_pksent;
1421 rt_getmetrics(&rt->rt_rmx, &rtm->rtm_rmx);
1422 rtm->rtm_index = rt->rt_ifp->if_index;
1423 rtm->rtm_errno = rtm->rtm_pid = rtm->rtm_seq = 0;
1424 rtm->rtm_addrs = info.rti_addrs;
1425 error = SYSCTL_OUT(w->w_req, (caddr_t)rtm, size);
1431 #ifdef COMPAT_FREEBSD32
1433 copy_ifdata32(struct if_data *src, struct if_data32 *dst)
1436 bzero(dst, sizeof(*dst));
1437 CP(*src, *dst, ifi_type);
1438 CP(*src, *dst, ifi_physical);
1439 CP(*src, *dst, ifi_addrlen);
1440 CP(*src, *dst, ifi_hdrlen);
1441 CP(*src, *dst, ifi_link_state);
1442 CP(*src, *dst, ifi_datalen);
1443 CP(*src, *dst, ifi_mtu);
1444 CP(*src, *dst, ifi_metric);
1445 CP(*src, *dst, ifi_baudrate);
1446 CP(*src, *dst, ifi_ipackets);
1447 CP(*src, *dst, ifi_ierrors);
1448 CP(*src, *dst, ifi_opackets);
1449 CP(*src, *dst, ifi_oerrors);
1450 CP(*src, *dst, ifi_collisions);
1451 CP(*src, *dst, ifi_ibytes);
1452 CP(*src, *dst, ifi_obytes);
1453 CP(*src, *dst, ifi_imcasts);
1454 CP(*src, *dst, ifi_omcasts);
1455 CP(*src, *dst, ifi_iqdrops);
1456 CP(*src, *dst, ifi_noproto);
1457 CP(*src, *dst, ifi_hwassist);
1458 CP(*src, *dst, ifi_epoch);
1459 TV_CP(*src, *dst, ifi_lastchange);
1464 sysctl_iflist(int af, struct walkarg *w)
1468 struct rt_addrinfo info;
1471 bzero((caddr_t)&info, sizeof(info));
1473 TAILQ_FOREACH(ifp, &V_ifnet, if_link) {
1474 if (w->w_arg && w->w_arg != ifp->if_index)
1477 info.rti_info[RTAX_IFP] = ifa->ifa_addr;
1478 len = rt_msg2(RTM_IFINFO, &info, NULL, w);
1479 info.rti_info[RTAX_IFP] = NULL;
1480 if (w->w_req && w->w_tmem) {
1481 struct if_msghdr *ifm;
1483 #ifdef COMPAT_FREEBSD32
1484 if (w->w_req->flags & SCTL_MASK32) {
1485 struct if_msghdr32 *ifm32;
1487 ifm32 = (struct if_msghdr32 *)w->w_tmem;
1488 ifm32->ifm_index = ifp->if_index;
1489 ifm32->ifm_flags = ifp->if_flags |
1491 copy_ifdata32(&ifp->if_data, &ifm32->ifm_data);
1492 ifm32->ifm_addrs = info.rti_addrs;
1493 error = SYSCTL_OUT(w->w_req, (caddr_t)ifm32,
1498 ifm = (struct if_msghdr *)w->w_tmem;
1499 ifm->ifm_index = ifp->if_index;
1500 ifm->ifm_flags = ifp->if_flags | ifp->if_drv_flags;
1501 ifm->ifm_data = ifp->if_data;
1502 ifm->ifm_addrs = info.rti_addrs;
1503 error = SYSCTL_OUT(w->w_req, (caddr_t)ifm, len);
1504 #ifdef COMPAT_FREEBSD32
1510 while ((ifa = TAILQ_NEXT(ifa, ifa_link)) != NULL) {
1511 if (af && af != ifa->ifa_addr->sa_family)
1513 if (prison_if(w->w_req->td->td_ucred,
1514 ifa->ifa_addr) != 0)
1516 info.rti_info[RTAX_IFA] = ifa->ifa_addr;
1517 info.rti_info[RTAX_NETMASK] = ifa->ifa_netmask;
1518 info.rti_info[RTAX_BRD] = ifa->ifa_dstaddr;
1519 len = rt_msg2(RTM_NEWADDR, &info, NULL, w);
1520 if (w->w_req && w->w_tmem) {
1521 struct ifa_msghdr *ifam;
1523 ifam = (struct ifa_msghdr *)w->w_tmem;
1524 ifam->ifam_index = ifa->ifa_ifp->if_index;
1525 ifam->ifam_flags = ifa->ifa_flags;
1526 ifam->ifam_metric = ifa->ifa_metric;
1527 ifam->ifam_addrs = info.rti_addrs;
1528 error = SYSCTL_OUT(w->w_req, w->w_tmem, len);
1533 info.rti_info[RTAX_IFA] = info.rti_info[RTAX_NETMASK] =
1534 info.rti_info[RTAX_BRD] = NULL;
1542 sysctl_ifmalist(int af, struct walkarg *w)
1545 struct ifmultiaddr *ifma;
1546 struct rt_addrinfo info;
1550 bzero((caddr_t)&info, sizeof(info));
1552 TAILQ_FOREACH(ifp, &V_ifnet, if_link) {
1553 if (w->w_arg && w->w_arg != ifp->if_index)
1556 info.rti_info[RTAX_IFP] = ifa ? ifa->ifa_addr : NULL;
1558 TAILQ_FOREACH(ifma, &ifp->if_multiaddrs, ifma_link) {
1559 if (af && af != ifma->ifma_addr->sa_family)
1561 if (prison_if(w->w_req->td->td_ucred,
1562 ifma->ifma_addr) != 0)
1564 info.rti_info[RTAX_IFA] = ifma->ifma_addr;
1565 info.rti_info[RTAX_GATEWAY] =
1566 (ifma->ifma_addr->sa_family != AF_LINK) ?
1567 ifma->ifma_lladdr : NULL;
1568 len = rt_msg2(RTM_NEWMADDR, &info, NULL, w);
1569 if (w->w_req && w->w_tmem) {
1570 struct ifma_msghdr *ifmam;
1572 ifmam = (struct ifma_msghdr *)w->w_tmem;
1573 ifmam->ifmam_index = ifma->ifma_ifp->if_index;
1574 ifmam->ifmam_flags = 0;
1575 ifmam->ifmam_addrs = info.rti_addrs;
1576 error = SYSCTL_OUT(w->w_req, w->w_tmem, len);
1578 IF_ADDR_UNLOCK(ifp);
1583 IF_ADDR_UNLOCK(ifp);
1591 sysctl_rtsock(SYSCTL_HANDLER_ARGS)
1593 int *name = (int *)arg1;
1594 u_int namelen = arg2;
1595 struct radix_node_head *rnh = NULL; /* silence compiler. */
1596 int i, lim, error = EINVAL;
1605 return ((namelen < 3) ? EISDIR : ENOTDIR);
1609 bzero(&w, sizeof(w));
1614 error = sysctl_wire_old_buffer(req, 0);
1621 if (af == 0) { /* dump all tables */
1624 } else /* dump only one table */
1628 * take care of llinfo entries, the caller must
1631 if (w.w_op == NET_RT_FLAGS &&
1632 (w.w_arg == 0 || w.w_arg & RTF_LLINFO)) {
1634 error = lltable_sysctl_dumparp(af, w.w_req);
1640 * take care of routing entries
1642 for (error = 0; error == 0 && i <= lim; i++) {
1643 rnh = rt_tables_get_rnh(req->td->td_proc->p_fibnum, i);
1645 RADIX_NODE_HEAD_LOCK(rnh);
1646 error = rnh->rnh_walktree(rnh,
1647 sysctl_dumpentry, &w);
1648 RADIX_NODE_HEAD_UNLOCK(rnh);
1650 error = EAFNOSUPPORT;
1655 error = sysctl_iflist(af, &w);
1658 case NET_RT_IFMALIST:
1659 error = sysctl_ifmalist(af, &w);
1663 free(w.w_tmem, M_RTABLE);
1667 SYSCTL_NODE(_net, PF_ROUTE, routetable, CTLFLAG_RD, sysctl_rtsock, "");
1670 * Definitions of protocols supported in the ROUTE domain.
1673 static struct domain routedomain; /* or at least forward */
1675 static struct protosw routesw[] = {
1677 .pr_type = SOCK_RAW,
1678 .pr_domain = &routedomain,
1679 .pr_flags = PR_ATOMIC|PR_ADDR,
1680 .pr_output = route_output,
1681 .pr_ctlinput = raw_ctlinput,
1682 .pr_init = raw_init,
1683 .pr_usrreqs = &route_usrreqs
1687 static struct domain routedomain = {
1688 .dom_family = PF_ROUTE,
1689 .dom_name = "route",
1690 .dom_protosw = routesw,
1691 .dom_protoswNPROTOSW = &routesw[sizeof(routesw)/sizeof(routesw[0])]
1694 VNET_DOMAIN_SET(route);