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/netisr.h>
59 #include <net/raw_cb.h>
60 #include <net/route.h>
63 #include <netinet/in.h>
64 #include <netinet/if_ether.h>
66 #include <netinet6/scope6_var.h>
69 #if defined(INET) || defined(INET6)
71 extern void sctp_addr_change(struct ifaddr *ifa, int cmd);
75 #ifdef COMPAT_FREEBSD32
76 #include <sys/mount.h>
77 #include <compat/freebsd32/freebsd32.h>
84 uint8_t ifi_link_state;
85 uint8_t ifi_spare_char1;
86 uint8_t ifi_spare_char2;
90 uint32_t ifi_baudrate;
91 uint32_t ifi_ipackets;
93 uint32_t ifi_opackets;
95 uint32_t ifi_collisions;
100 uint32_t ifi_iqdrops;
101 uint32_t ifi_noproto;
102 uint32_t ifi_hwassist;
104 struct timeval32 ifi_lastchange;
114 struct if_data32 ifm_data;
118 MALLOC_DEFINE(M_RTABLE, "routetbl", "routing tables");
120 /* NB: these are not modified */
121 static struct sockaddr route_src = { 2, PF_ROUTE, };
122 static struct sockaddr sa_zero = { sizeof(sa_zero), AF_INET, };
125 int ip_count; /* attached w/ AF_INET */
126 int ip6_count; /* attached w/ AF_INET6 */
127 int ipx_count; /* attached w/ AF_IPX */
128 int any_count; /* total attached */
131 struct mtx rtsock_mtx;
132 MTX_SYSINIT(rtsock, &rtsock_mtx, "rtsock route_cb lock", MTX_DEF);
134 #define RTSOCK_LOCK() mtx_lock(&rtsock_mtx)
135 #define RTSOCK_UNLOCK() mtx_unlock(&rtsock_mtx)
136 #define RTSOCK_LOCK_ASSERT() mtx_assert(&rtsock_mtx, MA_OWNED)
138 SYSCTL_NODE(_net, OID_AUTO, route, CTLFLAG_RD, 0, "");
144 struct sysctl_req *w_req;
147 static void rts_input(struct mbuf *m);
148 static struct mbuf *rt_msg1(int type, struct rt_addrinfo *rtinfo);
149 static int rt_msg2(int type, struct rt_addrinfo *rtinfo,
150 caddr_t cp, struct walkarg *w);
151 static int rt_xaddrs(caddr_t cp, caddr_t cplim,
152 struct rt_addrinfo *rtinfo);
153 static int sysctl_dumpentry(struct radix_node *rn, void *vw);
154 static int sysctl_iflist(int af, struct walkarg *w);
155 static int sysctl_ifmalist(int af, struct walkarg *w);
156 static int route_output(struct mbuf *m, struct socket *so);
157 static void rt_setmetrics(u_long which, const struct rt_metrics *in,
158 struct rt_metrics_lite *out);
159 static void rt_getmetrics(const struct rt_metrics_lite *in,
160 struct rt_metrics *out);
161 static void rt_dispatch(struct mbuf *, const struct sockaddr *);
163 static struct netisr_handler rtsock_nh = {
165 .nh_handler = rts_input,
166 .nh_proto = NETISR_ROUTE,
167 .nh_policy = NETISR_POLICY_SOURCE,
171 sysctl_route_netisr_maxqlen(SYSCTL_HANDLER_ARGS)
175 netisr_getqlimit(&rtsock_nh, &qlimit);
176 error = sysctl_handle_int(oidp, &qlimit, 0, req);
177 if (error || !req->newptr)
181 return (netisr_setqlimit(&rtsock_nh, qlimit));
183 SYSCTL_PROC(_net_route, OID_AUTO, netisr_maxqlen, CTLTYPE_INT|CTLFLAG_RW,
184 0, 0, sysctl_route_netisr_maxqlen, "I",
185 "maximum routing socket dispatch queue length");
192 if (TUNABLE_INT_FETCH("net.route.netisr_maxqlen", &tmp))
193 rtsock_nh.nh_qlimit = tmp;
194 netisr_register(&rtsock_nh);
196 SYSINIT(rtsock, SI_SUB_PROTO_DOMAIN, SI_ORDER_THIRD, rts_init, 0);
199 rts_input(struct mbuf *m)
201 struct sockproto route_proto;
202 unsigned short *family;
205 route_proto.sp_family = PF_ROUTE;
206 tag = m_tag_find(m, PACKET_TAG_RTSOCKFAM, NULL);
208 family = (unsigned short *)(tag + 1);
209 route_proto.sp_protocol = *family;
210 m_tag_delete(m, tag);
212 route_proto.sp_protocol = 0;
214 raw_input(m, &route_proto, &route_src);
218 * It really doesn't make any sense at all for this code to share much
219 * with raw_usrreq.c, since its functionality is so restricted. XXX
222 rts_abort(struct socket *so)
225 raw_usrreqs.pru_abort(so);
229 rts_close(struct socket *so)
232 raw_usrreqs.pru_close(so);
235 /* pru_accept is EOPNOTSUPP */
238 rts_attach(struct socket *so, int proto, struct thread *td)
243 KASSERT(so->so_pcb == NULL, ("rts_attach: so_pcb != NULL"));
246 rp = malloc(sizeof *rp, M_PCB, M_WAITOK | M_ZERO);
251 * The splnet() is necessary to block protocols from sending
252 * error notifications (like RTM_REDIRECT or RTM_LOSING) while
253 * this PCB is extant but incompletely initialized.
254 * Probably we should try to do more of this work beforehand and
258 so->so_pcb = (caddr_t)rp;
259 so->so_fibnum = td->td_proc->p_fibnum;
260 error = raw_attach(so, proto);
269 switch(rp->rcb_proto.sp_protocol) {
274 route_cb.ip6_count++;
277 route_cb.ipx_count++;
280 route_cb.any_count++;
283 so->so_options |= SO_USELOOPBACK;
289 rts_bind(struct socket *so, struct sockaddr *nam, struct thread *td)
292 return (raw_usrreqs.pru_bind(so, nam, td)); /* xxx just EINVAL */
296 rts_connect(struct socket *so, struct sockaddr *nam, struct thread *td)
299 return (raw_usrreqs.pru_connect(so, nam, td)); /* XXX just EINVAL */
302 /* pru_connect2 is EOPNOTSUPP */
303 /* pru_control is EOPNOTSUPP */
306 rts_detach(struct socket *so)
308 struct rawcb *rp = sotorawcb(so);
310 KASSERT(rp != NULL, ("rts_detach: rp == NULL"));
313 switch(rp->rcb_proto.sp_protocol) {
318 route_cb.ip6_count--;
321 route_cb.ipx_count--;
324 route_cb.any_count--;
326 raw_usrreqs.pru_detach(so);
330 rts_disconnect(struct socket *so)
333 return (raw_usrreqs.pru_disconnect(so));
336 /* pru_listen is EOPNOTSUPP */
339 rts_peeraddr(struct socket *so, struct sockaddr **nam)
342 return (raw_usrreqs.pru_peeraddr(so, nam));
345 /* pru_rcvd is EOPNOTSUPP */
346 /* pru_rcvoob is EOPNOTSUPP */
349 rts_send(struct socket *so, int flags, struct mbuf *m, struct sockaddr *nam,
350 struct mbuf *control, struct thread *td)
353 return (raw_usrreqs.pru_send(so, flags, m, nam, control, td));
356 /* pru_sense is null */
359 rts_shutdown(struct socket *so)
362 return (raw_usrreqs.pru_shutdown(so));
366 rts_sockaddr(struct socket *so, struct sockaddr **nam)
369 return (raw_usrreqs.pru_sockaddr(so, nam));
372 static struct pr_usrreqs route_usrreqs = {
373 .pru_abort = rts_abort,
374 .pru_attach = rts_attach,
375 .pru_bind = rts_bind,
376 .pru_connect = rts_connect,
377 .pru_detach = rts_detach,
378 .pru_disconnect = rts_disconnect,
379 .pru_peeraddr = rts_peeraddr,
380 .pru_send = rts_send,
381 .pru_shutdown = rts_shutdown,
382 .pru_sockaddr = rts_sockaddr,
383 .pru_close = rts_close,
386 #ifndef _SOCKADDR_UNION_DEFINED
387 #define _SOCKADDR_UNION_DEFINED
389 * The union of all possible address formats we handle.
391 union sockaddr_union {
393 struct sockaddr_in sin;
394 struct sockaddr_in6 sin6;
396 #endif /* _SOCKADDR_UNION_DEFINED */
399 rtm_get_jailed(struct rt_addrinfo *info, struct ifnet *ifp,
400 struct rtentry *rt, union sockaddr_union *saun, struct ucred *cred)
403 /* First, see if the returned address is part of the jail. */
404 if (prison_if(cred, rt->rt_ifa->ifa_addr) == 0) {
405 info->rti_info[RTAX_IFA] = rt->rt_ifa->ifa_addr;
409 switch (info->rti_info[RTAX_DST]->sa_family) {
419 * Try to find an address on the given outgoing interface
420 * that belongs to the jail.
423 TAILQ_FOREACH(ifa, &ifp->if_addrhead, ifa_link) {
426 if (sa->sa_family != AF_INET)
428 ia = ((struct sockaddr_in *)sa)->sin_addr;
429 if (prison_check_ip4(cred, &ia) == 0) {
437 * As a last resort return the 'default' jail address.
439 ia = ((struct sockaddr_in *)rt->rt_ifa->ifa_addr)->
441 if (prison_get_ip4(cred, &ia) != 0)
444 bzero(&saun->sin, sizeof(struct sockaddr_in));
445 saun->sin.sin_len = sizeof(struct sockaddr_in);
446 saun->sin.sin_family = AF_INET;
447 saun->sin.sin_addr.s_addr = ia.s_addr;
448 info->rti_info[RTAX_IFA] = (struct sockaddr *)&saun->sin;
461 * Try to find an address on the given outgoing interface
462 * that belongs to the jail.
465 TAILQ_FOREACH(ifa, &ifp->if_addrhead, ifa_link) {
468 if (sa->sa_family != AF_INET6)
470 bcopy(&((struct sockaddr_in6 *)sa)->sin6_addr,
471 &ia6, sizeof(struct in6_addr));
472 if (prison_check_ip6(cred, &ia6) == 0) {
480 * As a last resort return the 'default' jail address.
482 ia6 = ((struct sockaddr_in6 *)rt->rt_ifa->ifa_addr)->
484 if (prison_get_ip6(cred, &ia6) != 0)
487 bzero(&saun->sin6, sizeof(struct sockaddr_in6));
488 saun->sin6.sin6_len = sizeof(struct sockaddr_in6);
489 saun->sin6.sin6_family = AF_INET6;
490 bcopy(&ia6, &saun->sin6.sin6_addr, sizeof(struct in6_addr));
491 if (sa6_recoverscope(&saun->sin6) != 0)
493 info->rti_info[RTAX_IFA] = (struct sockaddr *)&saun->sin6;
505 route_output(struct mbuf *m, struct socket *so)
507 #define sa_equal(a1, a2) (bcmp((a1), (a2), (a1)->sa_len) == 0)
508 struct rt_msghdr *rtm = NULL;
509 struct rtentry *rt = NULL;
510 struct radix_node_head *rnh;
511 struct rt_addrinfo info;
513 struct ifnet *ifp = NULL;
514 union sockaddr_union saun;
516 #define senderr(e) { error = e; goto flush;}
517 if (m == NULL || ((m->m_len < sizeof(long)) &&
518 (m = m_pullup(m, sizeof(long))) == NULL))
520 if ((m->m_flags & M_PKTHDR) == 0)
521 panic("route_output");
522 len = m->m_pkthdr.len;
523 if (len < sizeof(*rtm) ||
524 len != mtod(m, struct rt_msghdr *)->rtm_msglen) {
525 info.rti_info[RTAX_DST] = NULL;
528 R_Malloc(rtm, struct rt_msghdr *, len);
530 info.rti_info[RTAX_DST] = NULL;
533 m_copydata(m, 0, len, (caddr_t)rtm);
534 if (rtm->rtm_version != RTM_VERSION) {
535 info.rti_info[RTAX_DST] = NULL;
536 senderr(EPROTONOSUPPORT);
538 rtm->rtm_pid = curproc->p_pid;
539 bzero(&info, sizeof(info));
540 info.rti_addrs = rtm->rtm_addrs;
541 if (rt_xaddrs((caddr_t)(rtm + 1), len + (caddr_t)rtm, &info)) {
542 info.rti_info[RTAX_DST] = NULL;
545 info.rti_flags = rtm->rtm_flags;
546 if (info.rti_info[RTAX_DST] == NULL ||
547 info.rti_info[RTAX_DST]->sa_family >= AF_MAX ||
548 (info.rti_info[RTAX_GATEWAY] != NULL &&
549 info.rti_info[RTAX_GATEWAY]->sa_family >= AF_MAX))
552 * Verify that the caller has the appropriate privilege; RTM_GET
553 * is the only operation the non-superuser is allowed.
555 if (rtm->rtm_type != RTM_GET) {
556 error = priv_check(curthread, PRIV_NET_ROUTE);
562 * The given gateway address may be an interface address.
563 * For example, issuing a "route change" command on a route
564 * entry that was created from a tunnel, and the gateway
565 * address given is the local end point. In this case the
566 * RTF_GATEWAY flag must be cleared or the destination will
567 * not be reachable even though there is no error message.
569 if (info.rti_info[RTAX_GATEWAY] != NULL &&
570 info.rti_info[RTAX_GATEWAY]->sa_family != AF_LINK) {
573 bzero(&gw_ro, sizeof(gw_ro));
574 gw_ro.ro_dst = *info.rti_info[RTAX_GATEWAY];
575 rtalloc_ign_fib(&gw_ro, 0, so->so_fibnum);
577 * A host route through the loopback interface is
578 * installed for each interface adddress. In pre 8.0
579 * releases the interface address of a PPP link type
580 * is not reachable locally. This behavior is fixed as
581 * part of the new L2/L3 redesign and rewrite work. The
582 * signature of this interface address route is the
583 * AF_LINK sa_family type of the rt_gateway, and the
584 * rt_ifp has the IFF_LOOPBACK flag set.
586 if (gw_ro.ro_rt != NULL &&
587 gw_ro.ro_rt->rt_gateway->sa_family == AF_LINK &&
588 gw_ro.ro_rt->rt_ifp->if_flags & IFF_LOOPBACK)
589 info.rti_flags &= ~RTF_GATEWAY;
590 if (gw_ro.ro_rt != NULL)
594 switch (rtm->rtm_type) {
595 struct rtentry *saved_nrt;
598 if (info.rti_info[RTAX_GATEWAY] == NULL)
602 /* support for new ARP code */
603 if (info.rti_info[RTAX_GATEWAY]->sa_family == AF_LINK &&
604 (rtm->rtm_flags & RTF_LLDATA) != 0) {
605 error = lla_rt_output(rtm, &info);
608 error = rtrequest1_fib(RTM_ADD, &info, &saved_nrt,
610 if (error == 0 && saved_nrt) {
612 rt_setmetrics(rtm->rtm_inits,
613 &rtm->rtm_rmx, &saved_nrt->rt_rmx);
614 rtm->rtm_index = saved_nrt->rt_ifp->if_index;
615 RT_REMREF(saved_nrt);
616 RT_UNLOCK(saved_nrt);
622 /* support for new ARP code */
623 if (info.rti_info[RTAX_GATEWAY] &&
624 (info.rti_info[RTAX_GATEWAY]->sa_family == AF_LINK) &&
625 (rtm->rtm_flags & RTF_LLDATA) != 0) {
626 error = lla_rt_output(rtm, &info);
629 error = rtrequest1_fib(RTM_DELETE, &info, &saved_nrt,
641 rnh = rt_tables_get_rnh(so->so_fibnum,
642 info.rti_info[RTAX_DST]->sa_family);
644 senderr(EAFNOSUPPORT);
645 RADIX_NODE_HEAD_RLOCK(rnh);
646 rt = (struct rtentry *) rnh->rnh_lookup(info.rti_info[RTAX_DST],
647 info.rti_info[RTAX_NETMASK], rnh);
648 if (rt == NULL) { /* XXX looks bogus */
649 RADIX_NODE_HEAD_RUNLOCK(rnh);
654 * for RTM_CHANGE/LOCK, if we got multipath routes,
655 * we require users to specify a matching RTAX_GATEWAY.
657 * for RTM_GET, gate is optional even with multipath.
658 * if gate == NULL the first match is returned.
659 * (no need to call rt_mpath_matchgate if gate == NULL)
661 if (rn_mpath_capable(rnh) &&
662 (rtm->rtm_type != RTM_GET || info.rti_info[RTAX_GATEWAY])) {
663 rt = rt_mpath_matchgate(rt, info.rti_info[RTAX_GATEWAY]);
665 RADIX_NODE_HEAD_RUNLOCK(rnh);
671 * If performing proxied L2 entry insertion, and
672 * the actual PPP host entry is found, perform
673 * another search to retrieve the prefix route of
674 * the local end point of the PPP link.
676 if ((rtm->rtm_flags & RTF_ANNOUNCE) &&
677 (rt->rt_ifp->if_flags & IFF_POINTOPOINT)) {
678 struct sockaddr laddr;
679 rt_maskedcopy(rt->rt_ifa->ifa_addr,
681 rt->rt_ifa->ifa_netmask);
683 * refactor rt and no lock operation necessary
685 rt = (struct rtentry *)rnh->rnh_matchaddr(&laddr, rnh);
687 RADIX_NODE_HEAD_RUNLOCK(rnh);
693 RADIX_NODE_HEAD_RUNLOCK(rnh);
698 * RTM_CHANGE/LOCK need a perfect match, rn_lookup()
699 * returns a perfect match in case a netmask is
700 * specified. For host routes only a longest prefix
701 * match is returned so it is necessary to compare the
702 * existence of the netmask. If both have a netmask
703 * rnh_lookup() did a perfect match and if none of them
704 * have a netmask both are host routes which is also a
708 if (rtm->rtm_type != RTM_GET &&
709 (!rt_mask(rt) != !info.rti_info[RTAX_NETMASK])) {
714 switch(rtm->rtm_type) {
719 if ((rt->rt_flags & RTF_HOST) == 0
720 ? jailed_without_vnet(curthread->td_ucred)
721 : prison_if(curthread->td_ucred,
726 info.rti_info[RTAX_DST] = rt_key(rt);
727 info.rti_info[RTAX_GATEWAY] = rt->rt_gateway;
728 info.rti_info[RTAX_NETMASK] = rt_mask(rt);
729 info.rti_info[RTAX_GENMASK] = 0;
730 if (rtm->rtm_addrs & (RTA_IFP | RTA_IFA)) {
733 info.rti_info[RTAX_IFP] =
734 ifp->if_addr->ifa_addr;
735 error = rtm_get_jailed(&info, ifp, rt,
736 &saun, curthread->td_ucred);
741 if (ifp->if_flags & IFF_POINTOPOINT)
742 info.rti_info[RTAX_BRD] =
743 rt->rt_ifa->ifa_dstaddr;
744 rtm->rtm_index = ifp->if_index;
746 info.rti_info[RTAX_IFP] = NULL;
747 info.rti_info[RTAX_IFA] = NULL;
749 } else if ((ifp = rt->rt_ifp) != NULL) {
750 rtm->rtm_index = ifp->if_index;
752 len = rt_msg2(rtm->rtm_type, &info, NULL, NULL);
753 if (len > rtm->rtm_msglen) {
754 struct rt_msghdr *new_rtm;
755 R_Malloc(new_rtm, struct rt_msghdr *, len);
756 if (new_rtm == NULL) {
760 bcopy(rtm, new_rtm, rtm->rtm_msglen);
761 Free(rtm); rtm = new_rtm;
763 (void)rt_msg2(rtm->rtm_type, &info, (caddr_t)rtm, NULL);
764 rtm->rtm_flags = rt->rt_flags;
765 rt_getmetrics(&rt->rt_rmx, &rtm->rtm_rmx);
766 rtm->rtm_addrs = info.rti_addrs;
771 * New gateway could require new ifaddr, ifp;
772 * flags may also be different; ifp may be specified
773 * by ll sockaddr when protocol address is ambiguous
775 if (((rt->rt_flags & RTF_GATEWAY) &&
776 info.rti_info[RTAX_GATEWAY] != NULL) ||
777 info.rti_info[RTAX_IFP] != NULL ||
778 (info.rti_info[RTAX_IFA] != NULL &&
779 !sa_equal(info.rti_info[RTAX_IFA],
780 rt->rt_ifa->ifa_addr))) {
782 RADIX_NODE_HEAD_LOCK(rnh);
783 error = rt_getifa_fib(&info, rt->rt_fibnum);
785 * XXXRW: Really we should release this
786 * reference later, but this maintains
787 * historical behavior.
789 if (info.rti_ifa != NULL)
790 ifa_free(info.rti_ifa);
791 RADIX_NODE_HEAD_UNLOCK(rnh);
796 if (info.rti_ifa != NULL &&
797 info.rti_ifa != rt->rt_ifa &&
798 rt->rt_ifa != NULL &&
799 rt->rt_ifa->ifa_rtrequest != NULL) {
800 rt->rt_ifa->ifa_rtrequest(RTM_DELETE, rt,
802 ifa_free(rt->rt_ifa);
804 if (info.rti_info[RTAX_GATEWAY] != NULL) {
806 RADIX_NODE_HEAD_LOCK(rnh);
809 error = rt_setgate(rt, rt_key(rt),
810 info.rti_info[RTAX_GATEWAY]);
811 RADIX_NODE_HEAD_UNLOCK(rnh);
816 rt->rt_flags |= (RTF_GATEWAY & info.rti_flags);
818 if (info.rti_ifa != NULL &&
819 info.rti_ifa != rt->rt_ifa) {
820 ifa_ref(info.rti_ifa);
821 rt->rt_ifa = info.rti_ifa;
822 rt->rt_ifp = info.rti_ifp;
824 /* Allow some flags to be toggled on change. */
825 rt->rt_flags = (rt->rt_flags & ~RTF_FMASK) |
826 (rtm->rtm_flags & RTF_FMASK);
827 rt_setmetrics(rtm->rtm_inits, &rtm->rtm_rmx,
829 rtm->rtm_index = rt->rt_ifp->if_index;
830 if (rt->rt_ifa && rt->rt_ifa->ifa_rtrequest)
831 rt->rt_ifa->ifa_rtrequest(RTM_ADD, rt, &info);
834 /* We don't support locks anymore */
847 rtm->rtm_errno = error;
849 rtm->rtm_flags |= RTF_DONE;
851 if (rt) /* XXX can this be true? */
854 struct rawcb *rp = NULL;
856 * Check to see if we don't want our own messages.
858 if ((so->so_options & SO_USELOOPBACK) == 0) {
859 if (route_cb.any_count <= 1) {
865 /* There is another listener, so construct message */
869 m_copyback(m, 0, rtm->rtm_msglen, (caddr_t)rtm);
870 if (m->m_pkthdr.len < rtm->rtm_msglen) {
873 } else if (m->m_pkthdr.len > rtm->rtm_msglen)
874 m_adj(m, rtm->rtm_msglen - m->m_pkthdr.len);
880 * XXX insure we don't get a copy by
881 * invalidating our protocol
883 unsigned short family = rp->rcb_proto.sp_family;
884 rp->rcb_proto.sp_family = 0;
885 rt_dispatch(m, info.rti_info[RTAX_DST]);
886 rp->rcb_proto.sp_family = family;
888 rt_dispatch(m, info.rti_info[RTAX_DST]);
896 rt_setmetrics(u_long which, const struct rt_metrics *in,
897 struct rt_metrics_lite *out)
899 #define metric(f, e) if (which & (f)) out->e = in->e;
901 * Only these are stored in the routing entry since introduction
902 * of tcp hostcache. The rest is ignored.
904 metric(RTV_MTU, rmx_mtu);
905 metric(RTV_WEIGHT, rmx_weight);
906 /* Userland -> kernel timebase conversion. */
907 if (which & RTV_EXPIRE)
908 out->rmx_expire = in->rmx_expire ?
909 in->rmx_expire - time_second + time_uptime : 0;
914 rt_getmetrics(const struct rt_metrics_lite *in, struct rt_metrics *out)
916 #define metric(e) out->e = in->e;
917 bzero(out, sizeof(*out));
920 /* Kernel -> userland timebase conversion. */
921 out->rmx_expire = in->rmx_expire ?
922 in->rmx_expire - time_uptime + time_second : 0;
927 * Extract the addresses of the passed sockaddrs.
928 * Do a little sanity checking so as to avoid bad memory references.
929 * This data is derived straight from userland.
932 rt_xaddrs(caddr_t cp, caddr_t cplim, struct rt_addrinfo *rtinfo)
937 for (i = 0; i < RTAX_MAX && cp < cplim; i++) {
938 if ((rtinfo->rti_addrs & (1 << i)) == 0)
940 sa = (struct sockaddr *)cp;
944 if (cp + sa->sa_len > cplim)
947 * there are no more.. quit now
948 * If there are more bits, they are in error.
949 * I've seen this. route(1) can evidently generate these.
950 * This causes kernel to core dump.
951 * for compatibility, If we see this, point to a safe address.
953 if (sa->sa_len == 0) {
954 rtinfo->rti_info[i] = &sa_zero;
955 return (0); /* should be EINVAL but for compat */
958 rtinfo->rti_info[i] = sa;
965 rt_msg1(int type, struct rt_addrinfo *rtinfo)
967 struct rt_msghdr *rtm;
977 len = sizeof(struct ifa_msghdr);
982 len = sizeof(struct ifma_msghdr);
986 len = sizeof(struct if_msghdr);
991 len = sizeof(struct if_announcemsghdr);
995 len = sizeof(struct rt_msghdr);
999 m = m_gethdr(M_DONTWAIT, MT_DATA);
1000 if (m && len > MHLEN) {
1001 MCLGET(m, M_DONTWAIT);
1002 if ((m->m_flags & M_EXT) == 0) {
1009 m->m_pkthdr.len = m->m_len = len;
1010 m->m_pkthdr.rcvif = NULL;
1011 rtm = mtod(m, struct rt_msghdr *);
1012 bzero((caddr_t)rtm, len);
1013 for (i = 0; i < RTAX_MAX; i++) {
1014 if ((sa = rtinfo->rti_info[i]) == NULL)
1016 rtinfo->rti_addrs |= (1 << i);
1018 m_copyback(m, len, dlen, (caddr_t)sa);
1021 if (m->m_pkthdr.len != len) {
1025 rtm->rtm_msglen = len;
1026 rtm->rtm_version = RTM_VERSION;
1027 rtm->rtm_type = type;
1032 rt_msg2(int type, struct rt_addrinfo *rtinfo, caddr_t cp, struct walkarg *w)
1035 int len, dlen, second_time = 0;
1038 rtinfo->rti_addrs = 0;
1044 len = sizeof(struct ifa_msghdr);
1048 #ifdef COMPAT_FREEBSD32
1049 if (w != NULL && w->w_req->flags & SCTL_MASK32) {
1050 len = sizeof(struct if_msghdr32);
1054 len = sizeof(struct if_msghdr);
1058 len = sizeof(struct ifma_msghdr);
1062 len = sizeof(struct rt_msghdr);
1067 for (i = 0; i < RTAX_MAX; i++) {
1068 struct sockaddr *sa;
1070 if ((sa = rtinfo->rti_info[i]) == NULL)
1072 rtinfo->rti_addrs |= (1 << i);
1075 bcopy((caddr_t)sa, cp, (unsigned)dlen);
1081 if (cp == NULL && w != NULL && !second_time) {
1082 struct walkarg *rw = w;
1085 if (rw->w_tmemsize < len) {
1087 free(rw->w_tmem, M_RTABLE);
1088 rw->w_tmem = (caddr_t)
1089 malloc(len, M_RTABLE, M_NOWAIT);
1091 rw->w_tmemsize = len;
1101 struct rt_msghdr *rtm = (struct rt_msghdr *)cp0;
1103 rtm->rtm_version = RTM_VERSION;
1104 rtm->rtm_type = type;
1105 rtm->rtm_msglen = len;
1111 * This routine is called to generate a message from the routing
1112 * socket indicating that a redirect has occured, a routing lookup
1113 * has failed, or that a protocol has detected timeouts to a particular
1117 rt_missmsg(int type, struct rt_addrinfo *rtinfo, int flags, int error)
1119 struct rt_msghdr *rtm;
1121 struct sockaddr *sa = rtinfo->rti_info[RTAX_DST];
1123 if (route_cb.any_count == 0)
1125 m = rt_msg1(type, rtinfo);
1128 rtm = mtod(m, struct rt_msghdr *);
1129 rtm->rtm_flags = RTF_DONE | flags;
1130 rtm->rtm_errno = error;
1131 rtm->rtm_addrs = rtinfo->rti_addrs;
1136 * This routine is called to generate a message from the routing
1137 * socket indicating that the status of a network interface has changed.
1140 rt_ifmsg(struct ifnet *ifp)
1142 struct if_msghdr *ifm;
1144 struct rt_addrinfo info;
1146 if (route_cb.any_count == 0)
1148 bzero((caddr_t)&info, sizeof(info));
1149 m = rt_msg1(RTM_IFINFO, &info);
1152 ifm = mtod(m, struct if_msghdr *);
1153 ifm->ifm_index = ifp->if_index;
1154 ifm->ifm_flags = ifp->if_flags | ifp->if_drv_flags;
1155 ifm->ifm_data = ifp->if_data;
1157 rt_dispatch(m, NULL);
1161 * This is called to generate messages from the routing socket
1162 * indicating a network interface has had addresses associated with it.
1163 * if we ever reverse the logic and replace messages TO the routing
1164 * socket indicate a request to configure interfaces, then it will
1165 * be unnecessary as the routing socket will automatically generate
1169 rt_newaddrmsg(int cmd, struct ifaddr *ifa, int error, struct rtentry *rt)
1171 struct rt_addrinfo info;
1172 struct sockaddr *sa = NULL;
1174 struct mbuf *m = NULL;
1175 struct ifnet *ifp = ifa->ifa_ifp;
1177 KASSERT(cmd == RTM_ADD || cmd == RTM_DELETE,
1178 ("unexpected cmd %u", cmd));
1179 #if defined(INET) || defined(INET6)
1182 * notify the SCTP stack
1183 * this will only get called when an address is added/deleted
1184 * XXX pass the ifaddr struct instead if ifa->ifa_addr...
1186 sctp_addr_change(ifa, cmd);
1189 if (route_cb.any_count == 0)
1191 for (pass = 1; pass < 3; pass++) {
1192 bzero((caddr_t)&info, sizeof(info));
1193 if ((cmd == RTM_ADD && pass == 1) ||
1194 (cmd == RTM_DELETE && pass == 2)) {
1195 struct ifa_msghdr *ifam;
1196 int ncmd = cmd == RTM_ADD ? RTM_NEWADDR : RTM_DELADDR;
1198 info.rti_info[RTAX_IFA] = sa = ifa->ifa_addr;
1199 info.rti_info[RTAX_IFP] = ifp->if_addr->ifa_addr;
1200 info.rti_info[RTAX_NETMASK] = ifa->ifa_netmask;
1201 info.rti_info[RTAX_BRD] = ifa->ifa_dstaddr;
1202 if ((m = rt_msg1(ncmd, &info)) == NULL)
1204 ifam = mtod(m, struct ifa_msghdr *);
1205 ifam->ifam_index = ifp->if_index;
1206 ifam->ifam_metric = ifa->ifa_metric;
1207 ifam->ifam_flags = ifa->ifa_flags;
1208 ifam->ifam_addrs = info.rti_addrs;
1210 if ((cmd == RTM_ADD && pass == 2) ||
1211 (cmd == RTM_DELETE && pass == 1)) {
1212 struct rt_msghdr *rtm;
1216 info.rti_info[RTAX_NETMASK] = rt_mask(rt);
1217 info.rti_info[RTAX_DST] = sa = rt_key(rt);
1218 info.rti_info[RTAX_GATEWAY] = rt->rt_gateway;
1219 if ((m = rt_msg1(cmd, &info)) == NULL)
1221 rtm = mtod(m, struct rt_msghdr *);
1222 rtm->rtm_index = ifp->if_index;
1223 rtm->rtm_flags |= rt->rt_flags;
1224 rtm->rtm_errno = error;
1225 rtm->rtm_addrs = info.rti_addrs;
1232 * This is the analogue to the rt_newaddrmsg which performs the same
1233 * function but for multicast group memberhips. This is easier since
1234 * there is no route state to worry about.
1237 rt_newmaddrmsg(int cmd, struct ifmultiaddr *ifma)
1239 struct rt_addrinfo info;
1240 struct mbuf *m = NULL;
1241 struct ifnet *ifp = ifma->ifma_ifp;
1242 struct ifma_msghdr *ifmam;
1244 if (route_cb.any_count == 0)
1247 bzero((caddr_t)&info, sizeof(info));
1248 info.rti_info[RTAX_IFA] = ifma->ifma_addr;
1249 info.rti_info[RTAX_IFP] = ifp ? ifp->if_addr->ifa_addr : NULL;
1251 * If a link-layer address is present, present it as a ``gateway''
1252 * (similarly to how ARP entries, e.g., are presented).
1254 info.rti_info[RTAX_GATEWAY] = ifma->ifma_lladdr;
1255 m = rt_msg1(cmd, &info);
1258 ifmam = mtod(m, struct ifma_msghdr *);
1259 KASSERT(ifp != NULL, ("%s: link-layer multicast address w/o ifp\n",
1261 ifmam->ifmam_index = ifp->if_index;
1262 ifmam->ifmam_addrs = info.rti_addrs;
1263 rt_dispatch(m, ifma->ifma_addr);
1266 static struct mbuf *
1267 rt_makeifannouncemsg(struct ifnet *ifp, int type, int what,
1268 struct rt_addrinfo *info)
1270 struct if_announcemsghdr *ifan;
1273 if (route_cb.any_count == 0)
1275 bzero((caddr_t)info, sizeof(*info));
1276 m = rt_msg1(type, info);
1278 ifan = mtod(m, struct if_announcemsghdr *);
1279 ifan->ifan_index = ifp->if_index;
1280 strlcpy(ifan->ifan_name, ifp->if_xname,
1281 sizeof(ifan->ifan_name));
1282 ifan->ifan_what = what;
1288 * This is called to generate routing socket messages indicating
1289 * IEEE80211 wireless events.
1290 * XXX we piggyback on the RTM_IFANNOUNCE msg format in a clumsy way.
1293 rt_ieee80211msg(struct ifnet *ifp, int what, void *data, size_t data_len)
1296 struct rt_addrinfo info;
1298 m = rt_makeifannouncemsg(ifp, RTM_IEEE80211, what, &info);
1301 * Append the ieee80211 data. Try to stick it in the
1302 * mbuf containing the ifannounce msg; otherwise allocate
1303 * a new mbuf and append.
1305 * NB: we assume m is a single mbuf.
1307 if (data_len > M_TRAILINGSPACE(m)) {
1308 struct mbuf *n = m_get(M_NOWAIT, MT_DATA);
1313 bcopy(data, mtod(n, void *), data_len);
1314 n->m_len = data_len;
1316 } else if (data_len > 0) {
1317 bcopy(data, mtod(m, u_int8_t *) + m->m_len, data_len);
1318 m->m_len += data_len;
1320 if (m->m_flags & M_PKTHDR)
1321 m->m_pkthdr.len += data_len;
1322 mtod(m, struct if_announcemsghdr *)->ifan_msglen += data_len;
1323 rt_dispatch(m, NULL);
1328 * This is called to generate routing socket messages indicating
1329 * network interface arrival and departure.
1332 rt_ifannouncemsg(struct ifnet *ifp, int what)
1335 struct rt_addrinfo info;
1337 m = rt_makeifannouncemsg(ifp, RTM_IFANNOUNCE, what, &info);
1339 rt_dispatch(m, NULL);
1343 rt_dispatch(struct mbuf *m, const struct sockaddr *sa)
1348 * Preserve the family from the sockaddr, if any, in an m_tag for
1349 * use when injecting the mbuf into the routing socket buffer from
1353 tag = m_tag_get(PACKET_TAG_RTSOCKFAM, sizeof(unsigned short),
1359 *(unsigned short *)(tag + 1) = sa->sa_family;
1360 m_tag_prepend(m, tag);
1364 m->m_pkthdr.rcvif = V_loif;
1370 netisr_queue(NETISR_ROUTE, m); /* mbuf is free'd on failure. */
1374 * This is used in dumping the kernel table via sysctl().
1377 sysctl_dumpentry(struct radix_node *rn, void *vw)
1379 struct walkarg *w = vw;
1380 struct rtentry *rt = (struct rtentry *)rn;
1381 int error = 0, size;
1382 struct rt_addrinfo info;
1384 if (w->w_op == NET_RT_FLAGS && !(rt->rt_flags & w->w_arg))
1386 if ((rt->rt_flags & RTF_HOST) == 0
1387 ? jailed_without_vnet(w->w_req->td->td_ucred)
1388 : prison_if(w->w_req->td->td_ucred, rt_key(rt)) != 0)
1390 bzero((caddr_t)&info, sizeof(info));
1391 info.rti_info[RTAX_DST] = rt_key(rt);
1392 info.rti_info[RTAX_GATEWAY] = rt->rt_gateway;
1393 info.rti_info[RTAX_NETMASK] = rt_mask(rt);
1394 info.rti_info[RTAX_GENMASK] = 0;
1396 info.rti_info[RTAX_IFP] = rt->rt_ifp->if_addr->ifa_addr;
1397 info.rti_info[RTAX_IFA] = rt->rt_ifa->ifa_addr;
1398 if (rt->rt_ifp->if_flags & IFF_POINTOPOINT)
1399 info.rti_info[RTAX_BRD] = rt->rt_ifa->ifa_dstaddr;
1401 size = rt_msg2(RTM_GET, &info, NULL, w);
1402 if (w->w_req && w->w_tmem) {
1403 struct rt_msghdr *rtm = (struct rt_msghdr *)w->w_tmem;
1405 rtm->rtm_flags = rt->rt_flags;
1407 * let's be honest about this being a retarded hack
1409 rtm->rtm_fmask = rt->rt_rmx.rmx_pksent;
1410 rt_getmetrics(&rt->rt_rmx, &rtm->rtm_rmx);
1411 rtm->rtm_index = rt->rt_ifp->if_index;
1412 rtm->rtm_errno = rtm->rtm_pid = rtm->rtm_seq = 0;
1413 rtm->rtm_addrs = info.rti_addrs;
1414 error = SYSCTL_OUT(w->w_req, (caddr_t)rtm, size);
1420 #ifdef COMPAT_FREEBSD32
1422 copy_ifdata32(struct if_data *src, struct if_data32 *dst)
1425 bzero(dst, sizeof(*dst));
1426 CP(*src, *dst, ifi_type);
1427 CP(*src, *dst, ifi_physical);
1428 CP(*src, *dst, ifi_addrlen);
1429 CP(*src, *dst, ifi_hdrlen);
1430 CP(*src, *dst, ifi_link_state);
1431 CP(*src, *dst, ifi_datalen);
1432 CP(*src, *dst, ifi_mtu);
1433 CP(*src, *dst, ifi_metric);
1434 CP(*src, *dst, ifi_baudrate);
1435 CP(*src, *dst, ifi_ipackets);
1436 CP(*src, *dst, ifi_ierrors);
1437 CP(*src, *dst, ifi_opackets);
1438 CP(*src, *dst, ifi_oerrors);
1439 CP(*src, *dst, ifi_collisions);
1440 CP(*src, *dst, ifi_ibytes);
1441 CP(*src, *dst, ifi_obytes);
1442 CP(*src, *dst, ifi_imcasts);
1443 CP(*src, *dst, ifi_omcasts);
1444 CP(*src, *dst, ifi_iqdrops);
1445 CP(*src, *dst, ifi_noproto);
1446 CP(*src, *dst, ifi_hwassist);
1447 CP(*src, *dst, ifi_epoch);
1448 TV_CP(*src, *dst, ifi_lastchange);
1453 sysctl_iflist(int af, struct walkarg *w)
1457 struct rt_addrinfo info;
1460 bzero((caddr_t)&info, sizeof(info));
1462 TAILQ_FOREACH(ifp, &V_ifnet, if_link) {
1463 if (w->w_arg && w->w_arg != ifp->if_index)
1466 info.rti_info[RTAX_IFP] = ifa->ifa_addr;
1467 len = rt_msg2(RTM_IFINFO, &info, NULL, w);
1468 info.rti_info[RTAX_IFP] = NULL;
1469 if (w->w_req && w->w_tmem) {
1470 struct if_msghdr *ifm;
1472 #ifdef COMPAT_FREEBSD32
1473 if (w->w_req->flags & SCTL_MASK32) {
1474 struct if_msghdr32 *ifm32;
1476 ifm32 = (struct if_msghdr32 *)w->w_tmem;
1477 ifm32->ifm_index = ifp->if_index;
1478 ifm32->ifm_flags = ifp->if_flags |
1480 copy_ifdata32(&ifp->if_data, &ifm32->ifm_data);
1481 ifm32->ifm_addrs = info.rti_addrs;
1482 error = SYSCTL_OUT(w->w_req, (caddr_t)ifm32,
1487 ifm = (struct if_msghdr *)w->w_tmem;
1488 ifm->ifm_index = ifp->if_index;
1489 ifm->ifm_flags = ifp->if_flags | ifp->if_drv_flags;
1490 ifm->ifm_data = ifp->if_data;
1491 ifm->ifm_addrs = info.rti_addrs;
1492 error = SYSCTL_OUT(w->w_req, (caddr_t)ifm, len);
1493 #ifdef COMPAT_FREEBSD32
1499 while ((ifa = TAILQ_NEXT(ifa, ifa_link)) != NULL) {
1500 if (af && af != ifa->ifa_addr->sa_family)
1502 if (prison_if(w->w_req->td->td_ucred,
1503 ifa->ifa_addr) != 0)
1505 info.rti_info[RTAX_IFA] = ifa->ifa_addr;
1506 info.rti_info[RTAX_NETMASK] = ifa->ifa_netmask;
1507 info.rti_info[RTAX_BRD] = ifa->ifa_dstaddr;
1508 len = rt_msg2(RTM_NEWADDR, &info, NULL, w);
1509 if (w->w_req && w->w_tmem) {
1510 struct ifa_msghdr *ifam;
1512 ifam = (struct ifa_msghdr *)w->w_tmem;
1513 ifam->ifam_index = ifa->ifa_ifp->if_index;
1514 ifam->ifam_flags = ifa->ifa_flags;
1515 ifam->ifam_metric = ifa->ifa_metric;
1516 ifam->ifam_addrs = info.rti_addrs;
1517 error = SYSCTL_OUT(w->w_req, w->w_tmem, len);
1522 info.rti_info[RTAX_IFA] = info.rti_info[RTAX_NETMASK] =
1523 info.rti_info[RTAX_BRD] = NULL;
1531 sysctl_ifmalist(int af, struct walkarg *w)
1534 struct ifmultiaddr *ifma;
1535 struct rt_addrinfo info;
1539 bzero((caddr_t)&info, sizeof(info));
1541 TAILQ_FOREACH(ifp, &V_ifnet, if_link) {
1542 if (w->w_arg && w->w_arg != ifp->if_index)
1545 info.rti_info[RTAX_IFP] = ifa ? ifa->ifa_addr : NULL;
1547 TAILQ_FOREACH(ifma, &ifp->if_multiaddrs, ifma_link) {
1548 if (af && af != ifma->ifma_addr->sa_family)
1550 if (prison_if(w->w_req->td->td_ucred,
1551 ifma->ifma_addr) != 0)
1553 info.rti_info[RTAX_IFA] = ifma->ifma_addr;
1554 info.rti_info[RTAX_GATEWAY] =
1555 (ifma->ifma_addr->sa_family != AF_LINK) ?
1556 ifma->ifma_lladdr : NULL;
1557 len = rt_msg2(RTM_NEWMADDR, &info, NULL, w);
1558 if (w->w_req && w->w_tmem) {
1559 struct ifma_msghdr *ifmam;
1561 ifmam = (struct ifma_msghdr *)w->w_tmem;
1562 ifmam->ifmam_index = ifma->ifma_ifp->if_index;
1563 ifmam->ifmam_flags = 0;
1564 ifmam->ifmam_addrs = info.rti_addrs;
1565 error = SYSCTL_OUT(w->w_req, w->w_tmem, len);
1567 IF_ADDR_UNLOCK(ifp);
1572 IF_ADDR_UNLOCK(ifp);
1580 sysctl_rtsock(SYSCTL_HANDLER_ARGS)
1582 int *name = (int *)arg1;
1583 u_int namelen = arg2;
1584 struct radix_node_head *rnh = NULL; /* silence compiler. */
1585 int i, lim, error = EINVAL;
1594 return ((namelen < 3) ? EISDIR : ENOTDIR);
1598 bzero(&w, sizeof(w));
1603 error = sysctl_wire_old_buffer(req, 0);
1610 if (af == 0) { /* dump all tables */
1613 } else /* dump only one table */
1617 * take care of llinfo entries, the caller must
1620 if (w.w_op == NET_RT_FLAGS &&
1621 (w.w_arg == 0 || w.w_arg & RTF_LLINFO)) {
1623 error = lltable_sysctl_dumparp(af, w.w_req);
1629 * take care of routing entries
1631 for (error = 0; error == 0 && i <= lim; i++) {
1632 rnh = rt_tables_get_rnh(req->td->td_proc->p_fibnum, i);
1634 RADIX_NODE_HEAD_LOCK(rnh);
1635 error = rnh->rnh_walktree(rnh,
1636 sysctl_dumpentry, &w);
1637 RADIX_NODE_HEAD_UNLOCK(rnh);
1639 error = EAFNOSUPPORT;
1644 error = sysctl_iflist(af, &w);
1647 case NET_RT_IFMALIST:
1648 error = sysctl_ifmalist(af, &w);
1652 free(w.w_tmem, M_RTABLE);
1656 SYSCTL_NODE(_net, PF_ROUTE, routetable, CTLFLAG_RD, sysctl_rtsock, "");
1659 * Definitions of protocols supported in the ROUTE domain.
1662 static struct domain routedomain; /* or at least forward */
1664 static struct protosw routesw[] = {
1666 .pr_type = SOCK_RAW,
1667 .pr_domain = &routedomain,
1668 .pr_flags = PR_ATOMIC|PR_ADDR,
1669 .pr_output = route_output,
1670 .pr_ctlinput = raw_ctlinput,
1671 .pr_init = raw_init,
1672 .pr_usrreqs = &route_usrreqs
1676 static struct domain routedomain = {
1677 .dom_family = PF_ROUTE,
1678 .dom_name = "route",
1679 .dom_protosw = routesw,
1680 .dom_protoswNPROTOSW = &routesw[sizeof(routesw)/sizeof(routesw[0])]
1683 VNET_DOMAIN_SET(route);