So I'd appreciates some eyes on the diff below that touches all the existing rtalloc1() queries.
The main change is indeed a rename to finally come back to a function with a sexy name introduced in 4.2BSD but with more goodies: rtalloc(9). But this diff also changes the meaning of the flags passed to this function, in order to simplify the various call afterward. See the manpage below. Here's the conversion observed: rtalloc1() rtalloc(9) What for? ---------------------- -------------------- ----------------------- 0 0 no effect RT_NOCLONING 0 no effect RT_REPORT|RT_NOCLONING RT_REPORT notify sockets RT_REPORT RT_REPORT|RT_RESOLVE notify sockets + clone The rational for such change is to have only one flag to *enable* a functionality in order to remove non wanted flags where applicable. Index: share/man/man9/Makefile =================================================================== RCS file: /home/ncvs/src/share/man/man9/Makefile,v retrieving revision 1.220 diff -u -p -r1.220 Makefile --- share/man/man9/Makefile 8 Oct 2014 07:39:46 -0000 1.220 +++ share/man/man9/Makefile 15 Oct 2014 12:18:38 -0000 @@ -26,8 +26,8 @@ MAN= aml_evalnode.9 atomic_add_int.9 ato panic.9 pci_conf_read.9 pci_intr_map.9 pfind.9 physio.9 pmap.9 \ pool.9 powerhook_establish.9 ppsratecheck.9 printf.9 psignal.9 \ radio.9 arc4random.9 rasops.9 ratecheck.9 resettodr.9 rssadapt.9 \ - rt_ifa_add.9 rt_timer_add.9 route.9 rtable_add.9 rtlabel_id2name.9 \ - rtrequest1.9 rwlock.9 sensor_attach.9 \ + route.9 rt_ifa_add.9 rt_timer_add.9 rtalloc.9 rtable_add.9 \ + rtlabel_id2name.9 rtrequest1.9 rwlock.9 sensor_attach.9 \ shutdownhook_establish.9 tsleep.9 spl.9 startuphook_establish.9 \ socreate.9 sosplice.9 style.9 syscall.9 systrace.9 sysctl_int.9 \ task_add.9 tc_init.9 time.9 timeout.9 tvtohz.9 uiomove.9 uvm.9 \ @@ -323,7 +323,7 @@ MLINKS+=rssadapt.9 ieee80211_rssadapt_ch rssadapt.9 ieee80211_rssadapt_lower_rate.9 \ rssadapt.9 ieee80211_rssadapt_raise_rate.9 \ rssadapt.9 ieee80211_rssadapt_updatestats.9 -MLINKS+=route.9 rt_lookup.9 route.9 rtalloc1.9 route.9 rtfree.9 \ +MLINKS+=route.9 rt_lookup.9 \ route.9 rt_setgate.9 route.9 rtredirect.9 route.9 rtdeletemsg.9 MLINKS+=rt_ifa_add.9 rt_ifa_del.9 rt_ifa_add.9 rt_ifa_addloop.9 \ rt_ifa_add.9 rt_ifa_delloop.9 @@ -332,6 +332,7 @@ MLINKS+=rt_timer_add.9 rt_timer_queue_cr rt_timer_add.9 rt_timer_queue_change.9 \ rt_timer_add.9 rt_timer_queue_destroy.9 \ rt_timer_add.9 rt_timer_remove_all.9 +MLINKS+=rtalloc.9 rtalloc_mpath.9 rtalloc.9 rtfree.9 MLINKS+=rtable_add.9 rtable_exists.9 rtable_add.9 rtable_get.9 \ rtable_add.9 rtable_l2.9 rtable_add.9 rtable_l2set.9 MLINKS+=rtlabel_id2name.9 rtlabel_name2id.9 \ Index: share/man/man9/route.9 =================================================================== RCS file: /home/ncvs/src/share/man/man9/route.9,v retrieving revision 1.12 diff -u -p -r1.12 route.9 --- share/man/man9/route.9 14 Oct 2014 10:56:10 -0000 1.12 +++ share/man/man9/route.9 15 Oct 2014 12:18:38 -0000 @@ -25,10 +25,6 @@ .In net/route.h .Ft struct rtentry * .Fn rt_lookup "struct sockaddr *dst" "struct sockaddr *mask" "u_int tableid" -.Ft struct rtentry * -.Fn rtalloc1 "struct sockaddr *dst" "int flags" "u_int tableid" -.Ft void -.Fn rtfree "struct rtentry *rt" .Ft int .Fn rt_setgate "struct rtentry *rt0" "struct sockaddr *dst" \ "struct sockaddr *gate" "u_int tableid" @@ -82,10 +78,6 @@ from table and forward a notification message to all .Fa AF_ROUTE sockets. -.It Fn rtfree "struct rtentry *rt" -Release a reference to -.Fa rt , -freeing it if the reference count drops to 0. .El .Sh RETURN VALUES .Fn rt_setgate @@ -106,7 +98,7 @@ No routing entry for could be found. .It Bq Er ESRCH .Fa rt -is a multipath route that conflicts with existing multipath route. +is a multipath routing entry that conflicts with an existing one. .El .Sh SEE ALSO .Xr route 4 , Index: share/man/man9/rtalloc.9 =================================================================== RCS file: share/man/man9/rtalloc.9 diff -N share/man/man9/rtalloc.9 --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ share/man/man9/rtalloc.9 15 Oct 2014 12:18:38 -0000 @@ -0,0 +1,78 @@ +.\" $OpenBSD$ +.\" +.\" Copyright (c) 2014 Martin Pieuchot +.\" +.\" Permission to use, copy, modify, and distribute this software for any +.\" purpose with or without fee is hereby granted, provided that the above +.\" copyright notice and this permission notice appear in all copies. +.\" +.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR +.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN +.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF +.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. +.\" +.Dd $Mdocdate$ +.Dt RTALLOC 9 +.Os +.Sh NAME +.Nm rtalloc, rtalloc_mpath, rtfree +.Nd routing entries interface +.Sh SYNOPSIS +.In sys/types.h +.In sys/socket.h +.In net/route.h +.Ft struct rtentry * +.Fn rtalloc "struct sockaddr *dst" "int flags" "unsigned int rtableid" +.Ft struct rtentry * +.Fn rtalloc_mpath "struct sockaddr *dst" "uint32_t *src" "unsigned int rtableid" +.Ft void +.Fn rtfree "struct rtentry *rt" +.Sh DESCRIPTION +The +.Fn rtalloc +function looks up in the routing table specified by +.Fa rtableid +for an entry matching +.Fa dst . +The following +.Fa flags +can be specified: +.Bl -tag -width RT_RESOLVE -offset indent +.It Dv RT_REPORT +Notify the routing sockets if the lookup fails. +.It Dv RT_RESOLVE +Allocate and return a cloned entry for +.Fa dst +if it does not exist and the lookup returned a cloning entry. +.El +.Pp +The +.Fn rtalloc_mpath +function does the same as +.Fn rtalloc +with the +.Dv RT_REPORT +and +.Dv RT_RESOLVE +.Fa flags , +but selects a multipath routing entry corresponding to +.Fa src +when possible. +.Pp +The +.Fn rtfree +function releases a reference to the routing entry +.Fa rt , +freeing it if the reference count drops to 0. +.Sh CONTEXT +.Fn rtalloc , +.Fn rtalloc_mpath , +and +.Fn rtfree +can be called during autoconf, from process context, or from interrupt context. +.Sh SEE ALSO +.Xr route 4 , +.Xr rtrequest1 9 Index: sys/net/if_ethersubr.c =================================================================== RCS file: /home/ncvs/src/sys/net/if_ethersubr.c,v retrieving revision 1.175 diff -u -p -r1.175 if_ethersubr.c --- sys/net/if_ethersubr.c 7 Oct 2014 20:23:32 -0000 1.175 +++ sys/net/if_ethersubr.c 15 Oct 2014 12:18:38 -0000 @@ -285,7 +285,7 @@ ether_output(struct ifnet *ifp0, struct senderr(ENETDOWN); if ((rt = rt0) != NULL) { if ((rt->rt_flags & RTF_UP) == 0) { - if ((rt0 = rt = rtalloc1(dst, RT_REPORT, + if ((rt0 = rt = rtalloc(dst, RT_REPORT|RT_RESOLVE, m->m_pkthdr.ph_rtableid)) != NULL) rt->rt_refcnt--; else @@ -299,8 +299,8 @@ ether_output(struct ifnet *ifp0, struct rtfree(rt); rt = rt0; lookup: - rt->rt_gwroute = rtalloc1(rt->rt_gateway, - RT_REPORT, ifp->if_rdomain); + rt->rt_gwroute = rtalloc(rt->rt_gateway, + RT_REPORT|RT_RESOLVE, ifp->if_rdomain); if ((rt = rt->rt_gwroute) == NULL) senderr(EHOSTUNREACH); } Index: sys/net/if_mpe.c =================================================================== RCS file: /home/ncvs/src/sys/net/if_mpe.c,v retrieving revision 1.37 diff -u -p -r1.37 if_mpe.c --- sys/net/if_mpe.c 14 Oct 2014 09:52:25 -0000 1.37 +++ sys/net/if_mpe.c 15 Oct 2014 12:18:38 -0000 @@ -163,7 +163,7 @@ mpestart(struct ifnet *ifp) continue; } - rt = rtalloc1(sa, RT_REPORT, 0); + rt = rtalloc(sa, RT_REPORT|RT_RESOLVE, 0); if (rt == NULL) { /* no route give up */ m_freem(m); Index: sys/net/pf.c =================================================================== RCS file: /home/ncvs/src/sys/net/pf.c,v retrieving revision 1.889 diff -u -p -r1.889 pf.c --- sys/net/pf.c 14 Oct 2014 09:52:25 -0000 1.889 +++ sys/net/pf.c 15 Oct 2014 12:18:38 -0000 @@ -2968,8 +2968,7 @@ pf_calc_mss(struct pf_addr *addr, sa_fam dst->sin_len = sizeof(*dst); dst->sin_addr = addr->v4; ro.ro_tableid = rtableid; - ro.ro_rt = rtalloc1(&ro.ro_dst, RT_REPORT | RT_NOCLONING, - ro.ro_tableid); + ro.ro_rt = rtalloc(&ro.ro_dst, RT_REPORT, ro.ro_tableid); rt = ro.ro_rt; break; #endif /* INET */ @@ -2982,8 +2981,8 @@ pf_calc_mss(struct pf_addr *addr, sa_fam dst6->sin6_len = sizeof(*dst6); dst6->sin6_addr = addr->v6; ro6.ro_tableid = rtableid; - ro6.ro_rt = rtalloc1(sin6tosa(&ro6.ro_dst), - RT_REPORT | RT_NOCLONING, ro6.ro_tableid); + ro6.ro_rt = rtalloc(sin6tosa(&ro6.ro_dst), RT_REPORT, + ro6.ro_tableid); rt = ro6.ro_rt; break; #endif /* INET6 */ @@ -5437,8 +5436,8 @@ pf_routable(struct pf_addr *addr, sa_fam if (kif != NULL && kif->pfik_ifp->if_type == IFT_ENC) goto out; - ro.ro_rt = rtalloc1((struct sockaddr *)&ro.ro_dst, - RT_REPORT | RT_NOCLONING, ro.ro_tableid); + ro.ro_rt = rtalloc((struct sockaddr *)&ro.ro_dst, RT_REPORT, + ro.ro_tableid); if (ro.ro_rt != NULL) { /* No interface given, this is a no-route check */ @@ -5505,8 +5504,8 @@ pf_rtlabel_match(struct pf_addr *addr, s #endif /* INET6 */ } - ro.ro_rt = rtalloc1((struct sockaddr *)&ro.ro_dst, - RT_REPORT | RT_NOCLONING, ro.ro_tableid); + ro.ro_rt = rtalloc((struct sockaddr *)&ro.ro_dst, RT_REPORT, + ro.ro_tableid); if (ro.ro_rt != NULL) { if (ro.ro_rt->rt_labelid == aw->v.rtlabel) @@ -5571,7 +5570,8 @@ pf_route(struct mbuf **m, struct pf_rule ro->ro_tableid = m0->m_pkthdr.ph_rtableid; if (!r->rt) { - ro->ro_rt = rtalloc1(&ro->ro_dst, RT_REPORT, ro->ro_tableid); + ro->ro_rt = rtalloc(&ro->ro_dst, RT_REPORT|RT_RESOLVE, + ro->ro_tableid); if (ro->ro_rt == 0) { ipstat.ips_noroute++; goto bad; Index: sys/net/pfkeyv2.c =================================================================== RCS file: /home/ncvs/src/sys/net/pfkeyv2.c,v retrieving revision 1.135 diff -u -p -r1.135 pfkeyv2.c --- sys/net/pfkeyv2.c 14 Oct 2014 09:52:26 -0000 1.135 +++ sys/net/pfkeyv2.c 15 Oct 2014 12:18:38 -0000 @@ -1569,8 +1569,8 @@ pfkeyv2_send(struct socket *socket, void /* Set the rdomain that was obtained from the socket */ re.re_tableid = rdomain; - re.re_rt = rtalloc1((struct sockaddr *)&re.re_dst, RT_REPORT, - re.re_tableid); + re.re_rt = rtalloc((struct sockaddr *)&re.re_dst, + RT_REPORT|RT_RESOLVE, re.re_tableid); if (re.re_rt != NULL) { ipo = ((struct sockaddr_encap *) re.re_rt->rt_gateway)->sen_ipsp; rtfree(re.re_rt); Index: sys/net/radix_mpath.c =================================================================== RCS file: /home/ncvs/src/sys/net/radix_mpath.c,v retrieving revision 1.24 diff -u -p -r1.24 radix_mpath.c --- sys/net/radix_mpath.c 27 Sep 2014 12:26:16 -0000 1.24 +++ sys/net/radix_mpath.c 15 Oct 2014 12:18:38 -0000 @@ -392,7 +392,7 @@ rtalloc_mpath(struct sockaddr *dst, u_in int hash, npaths, threshold; #endif - rt = rtalloc1(dst, RT_REPORT, rtableid); + rt = rtalloc(dst, RT_REPORT|RT_RESOLVE, rtableid); /* if the route does not exist or it is not multipath, don't care */ if (rt == NULL || !ISSET(rt->rt_flags, RTF_MPATH)) Index: sys/net/route.c =================================================================== RCS file: /home/ncvs/src/sys/net/route.c,v retrieving revision 1.187 diff -u -p -r1.187 route.c --- sys/net/route.c 14 Oct 2014 09:52:26 -0000 1.187 +++ sys/net/route.c 15 Oct 2014 12:18:38 -0000 @@ -311,7 +311,7 @@ rtable_exists(u_int id) /* verify table } struct rtentry * -rtalloc1(struct sockaddr *dst, int flags, u_int tableid) +rtalloc(struct sockaddr *dst, int flags, unsigned int tableid) { struct radix_node_head *rnh; struct rtentry *rt; @@ -327,8 +327,7 @@ rtalloc1(struct sockaddr *dst, int flags if (rnh && (rn = rnh->rnh_matchaddr((caddr_t)dst, rnh)) && ((rn->rn_flags & RNF_ROOT) == 0)) { newrt = rt = (struct rtentry *)rn; - if ((rt->rt_flags & RTF_CLONING) && - ISSET(flags, RT_REPORT | RT_NOCLONING) == RT_REPORT) { + if ((rt->rt_flags & RTF_CLONING) && ISSET(flags, RT_RESOLVE)) { err = rtrequest1(RTM_RESOLVE, &info, RTP_DEFAULT, &newrt, tableid); if (err) { @@ -452,7 +451,7 @@ rtredirect(struct sockaddr *dst, struct goto out; } ifp = ifa->ifa_ifp; - rt = rtalloc1(dst, 0, rdomain); + rt = rtalloc(dst, 0, rdomain); /* * If the redirect isn't from our current router for this dst, * it's either old or wrong. If it redirects us to ourselves, @@ -651,7 +650,7 @@ ifa_ifwithroute(int flags, struct sockad } } if (ifa == NULL) { - struct rtentry *rt = rtalloc1(gateway, 0, rtable_l2(rtableid)); + struct rtentry *rt = rtalloc(gateway, 0, rtableid); if (rt == NULL) return (NULL); rt->rt_refcnt--; @@ -962,7 +961,7 @@ rtrequest1(int req, struct rt_addrinfo * rn = rnh->rnh_addaddr((caddr_t)ndst, (caddr_t)info->rti_info[RTAX_NETMASK], rnh, rt->rt_nodes, rt->rt_priority); - if (rn == NULL && (crt = rtalloc1(ndst, 0, tableid)) != NULL) { + if (rn == NULL && (crt = rtalloc(ndst, 0, tableid)) != NULL) { /* overwrite cloned route */ if ((crt->rt_flags & RTF_CLONED) != 0) { rtdeletemsg(crt, tableid); @@ -1032,7 +1031,7 @@ rt_setgate(struct rtentry *rt, struct so } if (rt->rt_flags & RTF_GATEWAY) { /* XXX is this actually valid to cross tables here? */ - rt->rt_gwroute = rtalloc1(gate, RT_REPORT, rtable_l2(tableid)); + rt->rt_gwroute = rtalloc(gate, RT_REPORT|RT_RESOLVE, tableid); /* * If we switched gateways, grab the MTU from the new * gateway route if the current MTU is 0 or greater @@ -1140,7 +1139,7 @@ rt_ifa_del(struct ifaddr *ifa, int flags rt_maskedcopy(dst, deldst, ifa->ifa_netmask); dst = deldst; } - if ((rt = rtalloc1(dst, 0, rtableid)) != NULL) { + if ((rt = rtalloc(dst, 0, rtableid)) != NULL) { rt->rt_refcnt--; /* try to find the right route */ while (rt && rt->rt_ifa != ifa) @@ -1217,7 +1216,7 @@ rt_ifa_addloop(struct ifaddr *ifa) flags |= RTF_LLINFO; /* If there is no loopback entry, allocate one. */ - rt = rtalloc1(ifa->ifa_addr, 0, ifa->ifa_ifp->if_rdomain); + rt = rtalloc(ifa->ifa_addr, 0, ifa->ifa_ifp->if_rdomain); if (rt == NULL || !ISSET(rt->rt_flags, flags)); rt_ifa_add(ifa, RTF_UP | flags, ifa->ifa_addr); if (rt) @@ -1264,7 +1263,7 @@ rt_ifa_delloop(struct ifaddr *ifa) * a subnet-router anycast address on an interface attached * to a shared medium. */ - rt = rtalloc1(ifa->ifa_addr, 0, ifa->ifa_ifp->if_rdomain); + rt = rtalloc(ifa->ifa_addr, 0, ifa->ifa_ifp->if_rdomain); if (rt != NULL && ISSET(rt->rt_flags, flags)) rt_ifa_del(ifa, flags, ifa->ifa_addr); if (rt) Index: sys/net/route.h =================================================================== RCS file: /home/ncvs/src/sys/net/route.h,v retrieving revision 1.99 diff -u -p -r1.99 route.h --- sys/net/route.h 14 Oct 2014 09:52:26 -0000 1.99 +++ sys/net/route.h 15 Oct 2014 12:18:38 -0000 @@ -331,10 +331,10 @@ struct sockaddr *rtlabel_id2sa(u_int16_t void rtlabel_unref(u_int16_t); /* - * Values for additional argument to rtalloc1() + * Values for additional argument to rtalloc() */ #define RT_REPORT 0x1 -#define RT_NOCLONING 0x2 +#define RT_RESOLVE 0x2 extern struct rtstat rtstat; extern const struct sockaddr_rtin rt_defmask4; @@ -374,11 +374,11 @@ unsigned long rt_timer_queue_count(str void rt_timer_timer(void *); #ifdef SMALL_KERNEL -#define rtalloc_mpath(dst, s, rtableid) rtalloc1((dst), RT_REPORT, (rtableid)) +#define rtalloc_mpath(dst, s, rid) rtalloc((dst), RT_REPORT|RT_RESOLVE, (rid)) #endif -struct rtentry * - rtalloc1(struct sockaddr *, int, u_int); +struct rtentry *rtalloc(struct sockaddr *, int, unsigned int); void rtfree(struct rtentry *); + int rt_getifa(struct rt_addrinfo *, u_int); int rt_ifa_add(struct ifaddr *, int, struct sockaddr *); int rt_ifa_del(struct ifaddr *, int, struct sockaddr *); Index: sys/netinet/if_ether.c =================================================================== RCS file: /home/ncvs/src/sys/netinet/if_ether.c,v retrieving revision 1.136 diff -u -p -r1.136 if_ether.c --- sys/netinet/if_ether.c 3 Sep 2014 08:53:54 -0000 1.136 +++ sys/netinet/if_ether.c 15 Oct 2014 12:18:38 -0000 @@ -366,7 +366,7 @@ arpresolve(struct arpcom *ac, struct rte "local address\n", inet_ntop(AF_INET, &satosin(dst)->sin_addr, addr, sizeof(addr))); } else { - if ((la = arplookup(satosin(dst)->sin_addr.s_addr, RT_REPORT, 0, + if ((la = arplookup(satosin(dst)->sin_addr.s_addr, 1, 0, ac->ac_if.if_rdomain)) != NULL) rt = la->la_rt; else @@ -801,13 +801,16 @@ arplookup(u_int32_t addr, int create, in { struct rtentry *rt; struct sockaddr_inarp sin; + int flags; memset(&sin, 0, sizeof(sin)); sin.sin_len = sizeof(sin); sin.sin_family = AF_INET; sin.sin_addr.s_addr = addr; sin.sin_other = proxy ? SIN_PROXY : 0; - rt = rtalloc1((struct sockaddr *)&sin, create, tableid); + flags = (create) ? (RT_REPORT|RT_RESOLVE) : 0; + + rt = rtalloc((struct sockaddr *)&sin, flags, tableid); if (rt == 0) return (0); rt->rt_refcnt--; Index: sys/netinet/ip_icmp.c =================================================================== RCS file: /home/ncvs/src/sys/netinet/ip_icmp.c,v retrieving revision 1.125 diff -u -p -r1.125 ip_icmp.c --- sys/netinet/ip_icmp.c 30 Sep 2014 08:26:15 -0000 1.125 +++ sys/netinet/ip_icmp.c 15 Oct 2014 12:18:38 -0000 @@ -715,7 +715,7 @@ icmp_reflect(struct mbuf *m, struct mbuf sin.sin_family = AF_INET; sin.sin_addr = ip->ip_dst; - rt = rtalloc1(sintosa(&sin), 0, rtableid); + rt = rtalloc(sintosa(&sin), 0, rtableid); if (rt != NULL) { if (rt->rt_flags & (RTF_LOCAL|RTF_BROADCAST)) ia = ifatoia(rt->rt_ifa); @@ -735,7 +735,7 @@ icmp_reflect(struct mbuf *m, struct mbuf sin.sin_addr = ip->ip_src; /* keep packet in the original virtual instance */ - rt = rtalloc1(sintosa(&sin), RT_REPORT, rtableid); + rt = rtalloc(sintosa(&sin), RT_REPORT|RT_RESOLVE, rtableid); if (rt == NULL) { ipstat.ips_noroute++; m_freem(m); @@ -924,7 +924,7 @@ icmp_mtudisc_clone(struct in_addr dst, u sin->sin_len = sizeof(*sin); sin->sin_addr = dst; - rt = rtalloc1(&ro.ro_dst, RT_REPORT, rtableid); + rt = rtalloc(&ro.ro_dst, RT_REPORT|RT_RESOLVE, rtableid); if (rt == NULL) return (NULL); Index: sys/netinet/ip_input.c =================================================================== RCS file: /home/ncvs/src/sys/netinet/ip_input.c,v retrieving revision 1.238 diff -u -p -r1.238 ip_input.c --- sys/netinet/ip_input.c 14 Oct 2014 09:52:26 -0000 1.238 +++ sys/netinet/ip_input.c 15 Oct 2014 12:18:38 -0000 @@ -667,7 +667,7 @@ in_ouraddr(struct mbuf *m, struct ifnet sin.sin_len = sizeof(sin); sin.sin_family = AF_INET; sin.sin_addr = ina; - rt = rtalloc1(sintosa(&sin), 0, m->m_pkthdr.ph_rtableid); + rt = rtalloc(sintosa(&sin), 0, m->m_pkthdr.ph_rtableid); if (rt != NULL) { if (rt->rt_flags & (RTF_LOCAL|RTF_BROADCAST)) ia = ifatoia(rt->rt_ifa); @@ -1251,8 +1251,8 @@ ip_rtaddr(struct in_addr dst, u_int rtab sin->sin_len = sizeof(*sin); sin->sin_addr = dst; - ipforward_rt.ro_rt = rtalloc1(&ipforward_rt.ro_dst, RT_REPORT, - rtableid); + ipforward_rt.ro_rt = rtalloc(&ipforward_rt.ro_dst, + RT_REPORT|RT_RESOLVE, rtableid); } if (ipforward_rt.ro_rt == 0) return (NULL); Index: sys/netinet/ip_output.c =================================================================== RCS file: /home/ncvs/src/sys/netinet/ip_output.c,v retrieving revision 1.269 diff -u -p -r1.269 ip_output.c --- sys/netinet/ip_output.c 14 Oct 2014 09:52:26 -0000 1.269 +++ sys/netinet/ip_output.c 15 Oct 2014 12:18:38 -0000 @@ -583,7 +583,8 @@ sendit: rt->rt_rmx.rmx_mtu = icmp_mtu; if (ro && ro->ro_rt != NULL) { rtfree(ro->ro_rt); - ro->ro_rt = rtalloc1(&ro->ro_dst, RT_REPORT, + ro->ro_rt = rtalloc(&ro->ro_dst, + RT_REPORT|RT_RESOLVE, m->m_pkthdr.ph_rtableid); } if (rt_mtucloned) @@ -1771,8 +1772,8 @@ ip_setmoptions(int optname, struct ip_mo dst->sin_addr = mreq->imr_multiaddr; if (!(ro.ro_rt && ro.ro_rt->rt_ifp && (ro.ro_rt->rt_flags & RTF_UP))) - ro.ro_rt = rtalloc1(&ro.ro_dst, RT_REPORT, - rtableid); + ro.ro_rt = rtalloc(&ro.ro_dst, + RT_REPORT|RT_RESOLVE, rtableid); if (ro.ro_rt == NULL) { error = EADDRNOTAVAIL; break; Index: sys/netinet/ip_spd.c =================================================================== RCS file: /home/ncvs/src/sys/netinet/ip_spd.c,v retrieving revision 1.74 diff -u -p -r1.74 ip_spd.c --- sys/netinet/ip_spd.c 14 Oct 2014 09:52:26 -0000 1.74 +++ sys/netinet/ip_spd.c 15 Oct 2014 12:18:38 -0000 @@ -244,8 +244,8 @@ ipsp_spd_lookup(struct mbuf *m, int af, re->re_tableid = rdomain; /* Actual SPD lookup. */ - re->re_rt = rtalloc1((struct sockaddr *)&re->re_dst, RT_REPORT, - re->re_tableid); + re->re_rt = rtalloc((struct sockaddr *)&re->re_dst, + RT_REPORT|RT_RESOLVE, re->re_tableid); if (re->re_rt == NULL) { /* * Return whatever the socket requirements are, there are no Index: sys/netinet6/icmp6.c =================================================================== RCS file: /home/ncvs/src/sys/netinet6/icmp6.c,v retrieving revision 1.149 diff -u -p -r1.149 icmp6.c --- sys/netinet6/icmp6.c 14 Oct 2014 09:52:26 -0000 1.149 +++ sys/netinet6/icmp6.c 15 Oct 2014 12:18:38 -0000 @@ -1432,7 +1432,7 @@ icmp6_redirect_input(struct mbuf *m, int sin6.sin6_family = AF_INET6; sin6.sin6_len = sizeof(struct sockaddr_in6); bcopy(&reddst6, &sin6.sin6_addr, sizeof(reddst6)); - rt = rtalloc1(sin6tosa(&sin6), 0, m->m_pkthdr.ph_rtableid); + rt = rtalloc(sin6tosa(&sin6), 0, m->m_pkthdr.ph_rtableid); if (rt) { if (rt->rt_gateway == NULL || rt->rt_gateway->sa_family != AF_INET6) { @@ -1939,7 +1939,7 @@ icmp6_mtudisc_clone(struct sockaddr *dst struct rtentry *rt; int error; - rt = rtalloc1(dst, RT_REPORT, rdomain); + rt = rtalloc(dst, RT_REPORT|RT_RESOLVE, rdomain); if (rt == 0) return NULL; Index: sys/netinet6/in6.c =================================================================== RCS file: /home/ncvs/src/sys/netinet6/in6.c,v retrieving revision 1.142 diff -u -p -r1.142 in6.c --- sys/netinet6/in6.c 14 Oct 2014 09:52:26 -0000 1.142 +++ sys/netinet6/in6.c 15 Oct 2014 12:18:38 -0000 @@ -870,7 +870,7 @@ in6_update_ifa(struct ifnet *ifp, struct * actually do not need the routes, since they usually specify * the outgoing interface. */ - rt = rtalloc1(sin6tosa(&mltaddr), 0, ifp->if_rdomain); + rt = rtalloc(sin6tosa(&mltaddr), 0, ifp->if_rdomain); if (rt) { /* * 32bit came from "mltmask" @@ -941,7 +941,7 @@ in6_update_ifa(struct ifnet *ifp, struct mltaddr.sin6_scope_id = 0; /* XXX: again, do we really need the route? */ - rt = rtalloc1(sin6tosa(&mltaddr), 0, ifp->if_rdomain); + rt = rtalloc(sin6tosa(&mltaddr), 0, ifp->if_rdomain); if (rt) { /* 32bit came from "mltmask" */ if (memcmp(&mltaddr.sin6_addr, @@ -1604,7 +1604,7 @@ in6_ifpprefix(const struct ifnet *ifp, c dst.sin6_len = sizeof(struct sockaddr_in6); dst.sin6_family = AF_INET6; dst.sin6_addr = *addr; - rt = rtalloc1(sin6tosa(&dst), RT_NOCLONING, tableid); + rt = rtalloc(sin6tosa(&dst), 0, tableid); if (rt == NULL) return (0); Index: sys/netinet6/in6_ifattach.c =================================================================== RCS file: /home/ncvs/src/sys/netinet6/in6_ifattach.c,v retrieving revision 1.73 diff -u -p -r1.73 in6_ifattach.c --- sys/netinet6/in6_ifattach.c 25 Aug 2014 14:00:34 -0000 1.73 +++ sys/netinet6/in6_ifattach.c 15 Oct 2014 12:18:38 -0000 @@ -656,7 +656,7 @@ in6_ifdetach(struct ifnet *ifp) sin6.sin6_family = AF_INET6; sin6.sin6_addr = in6addr_intfacelocal_allnodes; sin6.sin6_addr.s6_addr16[1] = htons(ifp->if_index); - rt = rtalloc1(sin6tosa(&sin6), 0, ifp->if_rdomain); + rt = rtalloc(sin6tosa(&sin6), 0, ifp->if_rdomain); if (rt && rt->rt_ifp == ifp) { struct rt_addrinfo info; @@ -676,7 +676,7 @@ in6_ifdetach(struct ifnet *ifp) sin6.sin6_family = AF_INET6; sin6.sin6_addr = in6addr_linklocal_allnodes; sin6.sin6_addr.s6_addr16[1] = htons(ifp->if_index); - rt = rtalloc1(sin6tosa(&sin6), 0, ifp->if_rdomain); + rt = rtalloc(sin6tosa(&sin6), 0, ifp->if_rdomain); if (rt && rt->rt_ifp == ifp) { struct rt_addrinfo info; Index: sys/netinet6/in6_src.c =================================================================== RCS file: /home/ncvs/src/sys/netinet6/in6_src.c,v retrieving revision 1.47 diff -u -p -r1.47 in6_src.c --- sys/netinet6/in6_src.c 14 Oct 2014 09:52:26 -0000 1.47 +++ sys/netinet6/in6_src.c 15 Oct 2014 12:18:38 -0000 @@ -264,8 +264,8 @@ in6_selectsrc(struct in6_addr **in6src, sa6->sin6_addr = *dst; sa6->sin6_scope_id = dstsock->sin6_scope_id; if (IN6_IS_ADDR_MULTICAST(dst)) { - ro->ro_rt = rtalloc1(sin6tosa(&ro->ro_dst), - RT_REPORT, ro->ro_tableid); + ro->ro_rt = rtalloc(sin6tosa(&ro->ro_dst), + RT_REPORT|RT_RESOLVE, ro->ro_tableid); } else { ro->ro_rt = rtalloc_mpath(sin6tosa(&ro->ro_dst), NULL, ro->ro_tableid); @@ -382,8 +382,9 @@ selectroute(struct sockaddr_in6 *dstsock ron->ro_tableid = rtableid; } if (ron->ro_rt == NULL) { - ron->ro_rt = rtalloc1(sin6tosa(&ron->ro_dst), - RT_REPORT, ron->ro_tableid); /* multi path case? */ + /* multi path case? */ + ron->ro_rt = rtalloc(sin6tosa(&ron->ro_dst), + RT_REPORT|RT_RESOLVE, ron->ro_tableid); if (ron->ro_rt == NULL || (ron->ro_rt->rt_flags & RTF_GATEWAY)) { if (ron->ro_rt) { Index: sys/netinet6/ip6_output.c =================================================================== RCS file: /home/ncvs/src/sys/netinet6/ip6_output.c,v retrieving revision 1.160 diff -u -p -r1.160 ip6_output.c --- sys/netinet6/ip6_output.c 14 Oct 2014 09:52:26 -0000 1.160 +++ sys/netinet6/ip6_output.c 15 Oct 2014 12:18:38 -0000 @@ -1229,8 +1229,8 @@ ip6_getpmtu(struct route_in6 *ro_pmtu, s sa6_dst->sin6_len = sizeof(struct sockaddr_in6); sa6_dst->sin6_addr = *dst; - ro_pmtu->ro_rt = rtalloc1(sin6tosa(&ro_pmtu->ro_dst), - RT_REPORT, ro_pmtu->ro_tableid); + ro_pmtu->ro_rt = rtalloc(sin6tosa(&ro_pmtu->ro_dst), + RT_REPORT|RT_RESOLVE, ro_pmtu->ro_tableid); } } if (ro_pmtu->ro_rt) { @@ -2483,8 +2483,8 @@ ip6_setmoptions(int optname, struct ip6_ dst->sin6_len = sizeof(struct sockaddr_in6); dst->sin6_family = AF_INET6; dst->sin6_addr = mreq->ipv6mr_multiaddr; - ro.ro_rt = rtalloc1(sin6tosa(&ro.ro_dst), - RT_REPORT, ro.ro_tableid); + ro.ro_rt = rtalloc(sin6tosa(&ro.ro_dst), + RT_REPORT|RT_RESOLVE, ro.ro_tableid); if (ro.ro_rt == NULL) { error = EADDRNOTAVAIL; break; Index: sys/netinet6/nd6.c =================================================================== RCS file: /home/ncvs/src/sys/netinet6/nd6.c,v retrieving revision 1.123 diff -u -p -r1.123 nd6.c --- sys/netinet6/nd6.c 14 Oct 2014 09:52:26 -0000 1.123 +++ sys/netinet6/nd6.c 15 Oct 2014 12:18:38 -0000 @@ -649,13 +649,15 @@ nd6_lookup(struct in6_addr *addr6, int c { struct rtentry *rt; struct sockaddr_in6 sin6; + int flags; bzero(&sin6, sizeof(sin6)); sin6.sin6_len = sizeof(struct sockaddr_in6); sin6.sin6_family = AF_INET6; sin6.sin6_addr = *addr6; + flags = (create) ? (RT_REPORT|RT_RESOLVE) : 0; - rt = rtalloc1(sin6tosa(&sin6), create, rtableid); + rt = rtalloc(sin6tosa(&sin6), flags, rtableid); if (rt && (rt->rt_flags & RTF_LLINFO) == 0) { /* * This is the case for the default route. @@ -1390,7 +1392,7 @@ nd6_cache_lladdr(struct ifnet *ifp, stru return NULL; #endif - rt = nd6_lookup(from, RT_REPORT, ifp, ifp->if_rdomain); + rt = nd6_lookup(from, 1, ifp, ifp->if_rdomain); is_newentry = 1; } else { /* do nothing if static ndp is set */ @@ -1672,8 +1674,9 @@ nd6_output(struct ifnet *ifp, struct ifn */ if (rt) { if ((rt->rt_flags & RTF_UP) == 0) { - if ((rt0 = rt = rtalloc1(sin6tosa(dst), - RT_REPORT, m->m_pkthdr.ph_rtableid)) != NULL) + if ((rt0 = rt = rtalloc(sin6tosa(dst), + RT_REPORT|RT_RESOLVE, + m->m_pkthdr.ph_rtableid)) != NULL) { rt->rt_refcnt--; if (rt->rt_ifp != ifp) @@ -1711,8 +1714,9 @@ nd6_output(struct ifnet *ifp, struct ifn if (((rt = rt->rt_gwroute)->rt_flags & RTF_UP) == 0) { rtfree(rt); rt = rt0; lookup: - rt->rt_gwroute = rtalloc1(rt->rt_gateway, - RT_REPORT, m->m_pkthdr.ph_rtableid); + rt->rt_gwroute = rtalloc(rt->rt_gateway, + RT_REPORT|RT_RESOLVE, + m->m_pkthdr.ph_rtableid); if ((rt = rt->rt_gwroute) == 0) senderr(EHOSTUNREACH); } @@ -1736,7 +1740,7 @@ nd6_output(struct ifnet *ifp, struct ifn * it is tolerable, because this should be a rare case. */ if (nd6_is_addr_neighbor(dst, ifp) && - (rt = nd6_lookup(&dst->sin6_addr, RT_REPORT, ifp, + (rt = nd6_lookup(&dst->sin6_addr, 1, ifp, ifp->if_rdomain)) != NULL) ln = (struct llinfo_nd6 *)rt->rt_llinfo; } Index: sys/netinet6/nd6_nbr.c =================================================================== RCS file: /home/ncvs/src/sys/netinet6/nd6_nbr.c,v retrieving revision 1.81 diff -u -p -r1.81 nd6_nbr.c --- sys/netinet6/nd6_nbr.c 14 Oct 2014 09:52:26 -0000 1.81 +++ sys/netinet6/nd6_nbr.c 15 Oct 2014 12:18:38 -0000 @@ -219,7 +219,7 @@ nd6_ns_input(struct mbuf *m, int off, in tsin6.sin6_family = AF_INET6; tsin6.sin6_addr = taddr6; - rt = rtalloc1(sin6tosa(&tsin6), 0, m->m_pkthdr.ph_rtableid); + rt = rtalloc(sin6tosa(&tsin6), 0, m->m_pkthdr.ph_rtableid); if (rt && (rt->rt_flags & RTF_ANNOUNCE) != 0 && rt->rt_gateway->sa_family == AF_LINK) { /* Index: sys/netinet6/nd6_rtr.c =================================================================== RCS file: /home/ncvs/src/sys/netinet6/nd6_rtr.c,v retrieving revision 1.88 diff -u -p -r1.88 nd6_rtr.c --- sys/netinet6/nd6_rtr.c 7 Oct 2014 08:47:28 -0000 1.88 +++ sys/netinet6/nd6_rtr.c 15 Oct 2014 12:18:38 -0000 @@ -685,7 +685,7 @@ defrouter_reset(void) /* * XXX should we also nuke any default routers in the kernel, by - * going through them by rtalloc1()? + * going through them by rtalloc()? */ } Index: sys/netmpls/mpls_input.c =================================================================== RCS file: /home/ncvs/src/sys/netmpls/mpls_input.c,v retrieving revision 1.39 diff -u -p -r1.39 mpls_input.c --- sys/netmpls/mpls_input.c 14 Oct 2014 09:52:26 -0000 1.39 +++ sys/netmpls/mpls_input.c 15 Oct 2014 12:18:38 -0000 @@ -205,7 +205,7 @@ do_v6: } } - rt = rtalloc1(smplstosa(smpls), RT_REPORT, 0); + rt = rtalloc(smplstosa(smpls), RT_REPORT|RT_RESOLVE, 0); if (rt == NULL) { /* no entry for this label */ #ifdef MPLS_DEBUG @@ -455,7 +455,7 @@ mpls_do_error(struct mbuf *m, int type, smpls->smpls_len = sizeof(*smpls); smpls->smpls_label = shim->shim_label & MPLS_LABEL_MASK; - rt = rtalloc1(smplstosa(smpls), RT_REPORT, 0); + rt = rtalloc(smplstosa(smpls), RT_REPORT|RT_RESOLVE, 0); if (rt == NULL) { /* no entry for this label */ m_freem(m); Index: sys/netmpls/mpls_output.c =================================================================== RCS file: /home/ncvs/src/sys/netmpls/mpls_output.c,v retrieving revision 1.17 diff -u -p -r1.17 mpls_output.c --- sys/netmpls/mpls_output.c 22 Jul 2014 11:06:10 -0000 1.17 +++ sys/netmpls/mpls_output.c 15 Oct 2014 12:18:38 -0000 @@ -121,7 +121,7 @@ mpls_output(struct ifnet *ifp0, struct m break; smpls->smpls_label = shim->shim_label & MPLS_LABEL_MASK; - rt = rtalloc1(smplstosa(smpls), RT_REPORT, 0); + rt = rtalloc(smplstosa(smpls), RT_REPORT|RT_RESOLVE, 0); if (rt == NULL) { /* no entry for this label */ #ifdef MPLS_DEBUG