From 24b38efdce5f73d92ac948039ef4966d9502b484 Mon Sep 17 00:00:00 2001 From: kmacy Date: Thu, 16 Apr 2009 20:30:28 +0000 Subject: [PATCH] Change if_output to take a struct route as its fourth argument in order to allow passing a cached struct llentry * down to L2 Reviewed by: rwatson --- sys/contrib/ipfilter/netinet/ip_fil_freebsd.c | 4 ++-- sys/contrib/pf/net/if_pflog.c | 4 ++-- sys/contrib/pf/net/if_pfsync.c | 4 ++-- sys/contrib/pf/net/pf.c | 2 +- sys/dev/iicbus/if_ic.c | 4 ++-- sys/dev/lmc/if_lmc.c | 3 ++- sys/dev/lmc/if_lmc.h | 2 +- sys/dev/ppbus/if_plip.c | 5 +++-- sys/net/ethernet.h | 4 ++-- sys/net/if_arc.h | 2 +- sys/net/if_arcsubr.c | 5 +++-- sys/net/if_atm.h | 2 +- sys/net/if_atmsubr.c | 8 ++++---- sys/net/if_disc.c | 4 ++-- sys/net/if_enc.c | 4 ++-- sys/net/if_ethersubr.c | 19 +++++++++++++++---- sys/net/if_faith.c | 9 ++++++--- sys/net/if_fddisubr.c | 9 ++++++--- sys/net/if_fwsubr.c | 4 ++-- sys/net/if_gif.c | 4 ++-- sys/net/if_gif.h | 2 +- sys/net/if_gre.c | 4 ++-- sys/net/if_iso88025subr.c | 8 ++++++-- sys/net/if_lagg.c | 6 +++--- sys/net/if_lagg.h | 2 +- sys/net/if_loop.c | 7 +++++-- sys/net/if_spppsubr.c | 4 ++-- sys/net/if_stf.c | 6 +++--- sys/net/if_tun.c | 4 ++-- sys/net/if_var.h | 3 ++- sys/net/iso88025.h | 2 +- sys/net/route.h | 7 ++++--- sys/net80211/ieee80211.c | 2 +- sys/net80211/ieee80211_output.c | 4 ++-- sys/net80211/ieee80211_proto.h | 2 +- sys/net80211/ieee80211_var.h | 2 +- sys/netgraph/ng_fec.c | 9 +++++---- sys/netgraph/ng_iface.c | 5 +++-- sys/netinet/if_ether.c | 4 ++-- sys/netinet/ip_carp.c | 7 +++++-- sys/netinet/ip_fastfwd.c | 6 +++--- sys/netinet/ip_output.c | 4 ++-- sys/netinet6/nd6.c | 4 ++-- sys/netinet6/nd6.h | 2 +- sys/netipx/ipx_outputfl.c | 2 +- 45 files changed, 122 insertions(+), 88 deletions(-) diff --git a/sys/contrib/ipfilter/netinet/ip_fil_freebsd.c b/sys/contrib/ipfilter/netinet/ip_fil_freebsd.c index c053c7087c0e..b2e00e859787 100644 --- a/sys/contrib/ipfilter/netinet/ip_fil_freebsd.c +++ b/sys/contrib/ipfilter/netinet/ip_fil_freebsd.c @@ -1046,7 +1046,7 @@ frdest_t *fdp; if (!ip->ip_sum) ip->ip_sum = in_cksum(m, hlen); error = (*ifp->if_output)(ifp, m, (struct sockaddr *)dst, - ro->ro_rt); + ro); goto done; } /* @@ -1127,7 +1127,7 @@ frdest_t *fdp; m->m_act = 0; if (error == 0) error = (*ifp->if_output)(ifp, m, - (struct sockaddr *)dst, ro->ro_rt); + (struct sockaddr *)dst, ro); else FREE_MB_T(m); } diff --git a/sys/contrib/pf/net/if_pflog.c b/sys/contrib/pf/net/if_pflog.c index 94084d13739c..6f44dcf9352d 100644 --- a/sys/contrib/pf/net/if_pflog.c +++ b/sys/contrib/pf/net/if_pflog.c @@ -113,7 +113,7 @@ __FBSDID("$FreeBSD$"); void pflogattach(int); int pflogoutput(struct ifnet *, struct mbuf *, struct sockaddr *, - struct rtentry *); + struct route *); int pflogioctl(struct ifnet *, u_long, caddr_t); void pflogstart(struct ifnet *); #ifdef __FreeBSD__ @@ -287,7 +287,7 @@ pflogstart(struct ifnet *ifp) int pflogoutput(struct ifnet *ifp, struct mbuf *m, struct sockaddr *dst, - struct rtentry *rt) + struct route *ro) { m_freem(m); return (0); diff --git a/sys/contrib/pf/net/if_pfsync.c b/sys/contrib/pf/net/if_pfsync.c index cd835405e806..0925edb094b9 100644 --- a/sys/contrib/pf/net/if_pfsync.c +++ b/sys/contrib/pf/net/if_pfsync.c @@ -152,7 +152,7 @@ int pfsync_insert_net_state(struct pfsync_state *, u_int8_t); void pfsync_update_net_tdb(struct pfsync_tdb *); #endif int pfsyncoutput(struct ifnet *, struct mbuf *, struct sockaddr *, - struct rtentry *); + struct route *); int pfsyncioctl(struct ifnet *, u_long, caddr_t); void pfsyncstart(struct ifnet *); @@ -1083,7 +1083,7 @@ pfsync_input(struct mbuf *m, ...) int pfsyncoutput(struct ifnet *ifp, struct mbuf *m, struct sockaddr *dst, - struct rtentry *rt) + struct route *ro) { m_freem(m); return (0); diff --git a/sys/contrib/pf/net/pf.c b/sys/contrib/pf/net/pf.c index 71b7bda93948..ca4f79a895e3 100644 --- a/sys/contrib/pf/net/pf.c +++ b/sys/contrib/pf/net/pf.c @@ -6245,7 +6245,7 @@ pf_route(struct mbuf **m, struct pf_rule *r, int dir, struct ifnet *oifp, } } PF_UNLOCK(); - error = (*ifp->if_output)(ifp, m0, sintosa(dst), ro->ro_rt); + error = (*ifp->if_output)(ifp, m0, sintosa(dst), ro); PF_LOCK(); goto done; } diff --git a/sys/dev/iicbus/if_ic.c b/sys/dev/iicbus/if_ic.c index 6d77e2a146fb..bb5186cc401d 100644 --- a/sys/dev/iicbus/if_ic.c +++ b/sys/dev/iicbus/if_ic.c @@ -103,7 +103,7 @@ static int icattach(device_t); static int icioctl(struct ifnet *, u_long, caddr_t); static int icoutput(struct ifnet *, struct mbuf *, struct sockaddr *, - struct rtentry *); + struct route *); static int icintr(device_t, int, char *); @@ -354,7 +354,7 @@ icintr(device_t dev, int event, char *ptr) */ static int icoutput(struct ifnet *ifp, struct mbuf *m, struct sockaddr *dst, - struct rtentry *rt) + struct route *ro) { struct ic_softc *sc = ifp->if_softc; device_t icdev = sc->ic_dev; diff --git a/sys/dev/lmc/if_lmc.c b/sys/dev/lmc/if_lmc.c index c52778c4d4b2..3d1c9d5af616 100644 --- a/sys/dev/lmc/if_lmc.c +++ b/sys/dev/lmc/if_lmc.c @@ -114,6 +114,7 @@ # include # include # include +# include # include # include # include @@ -4583,7 +4584,7 @@ lmc_ifnet_start(struct ifnet *ifp) /* Called from a syscall (user context; no spinlocks). */ static int lmc_raw_output(struct ifnet *ifp, struct mbuf *m, - struct sockaddr *dst, struct rtentry *rt) + struct sockaddr *dst, struct route *ro) { softc_t *sc = IFP2SC(ifp); int error = 0; diff --git a/sys/dev/lmc/if_lmc.h b/sys/dev/lmc/if_lmc.h index a2127d761bea..10308e1ad786 100644 --- a/sys/dev/lmc/if_lmc.h +++ b/sys/dev/lmc/if_lmc.h @@ -1595,7 +1595,7 @@ static int lmc_raw_ioctl(struct ifnet *, u_long, caddr_t); static int lmc_ifnet_ioctl(struct ifnet *, u_long, caddr_t); static void lmc_ifnet_start(struct ifnet *); static int lmc_raw_output(struct ifnet *, struct mbuf *, - struct sockaddr *, struct rtentry *); + struct sockaddr *, struct route *); static void lmc_ifnet_watchdog(struct ifnet *); # ifdef __OpenBSD__ static int ifmedia_change(struct ifnet *); diff --git a/sys/dev/ppbus/if_plip.c b/sys/dev/ppbus/if_plip.c index 3ff11df7218c..3e4c1ca3b2b2 100644 --- a/sys/dev/ppbus/if_plip.c +++ b/sys/dev/ppbus/if_plip.c @@ -99,6 +99,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include @@ -173,7 +174,7 @@ static u_char *ctxmith; static int lpinittables(void); static int lpioctl(struct ifnet *, u_long, caddr_t); static int lpoutput(struct ifnet *, struct mbuf *, struct sockaddr *, - struct rtentry *); + struct route *); static void lpstop(struct lp_data *); static void lp_intr(void *); static int lp_module_handler(module_t, int, void *); @@ -678,7 +679,7 @@ lpoutbyte(u_char byte, int spin, device_t ppbus) static int lpoutput(struct ifnet *ifp, struct mbuf *m, struct sockaddr *dst, - struct rtentry *rt) + struct route *ro) { struct lp_data *sc = ifp->if_softc; device_t dev = sc->sc_dev; diff --git a/sys/net/ethernet.h b/sys/net/ethernet.h index 1cb57addf33d..ae7341ee8191 100644 --- a/sys/net/ethernet.h +++ b/sys/net/ethernet.h @@ -365,7 +365,7 @@ struct ether_addr { struct ifnet; struct mbuf; -struct rtentry; +struct route; struct sockaddr; struct bpf_if; @@ -376,7 +376,7 @@ extern void ether_ifattach(struct ifnet *, const u_int8_t *); extern void ether_ifdetach(struct ifnet *); extern int ether_ioctl(struct ifnet *, u_long, caddr_t); extern int ether_output(struct ifnet *, - struct mbuf *, struct sockaddr *, struct rtentry *); + struct mbuf *, struct sockaddr *, struct route *); extern int ether_output_frame(struct ifnet *, struct mbuf *); extern char *ether_sprintf(const u_int8_t *); void ether_vlan_mtap(struct bpf_if *, struct mbuf *, diff --git a/sys/net/if_arc.h b/sys/net/if_arc.h index f2dc87cf034c..086aeb0f6772 100644 --- a/sys/net/if_arc.h +++ b/sys/net/if_arc.h @@ -133,7 +133,7 @@ void arc_storelladdr(struct ifnet *, u_int8_t); int arc_isphds(u_int8_t); void arc_input(struct ifnet *, struct mbuf *); int arc_output(struct ifnet *, struct mbuf *, - struct sockaddr *, struct rtentry *); + struct sockaddr *, struct route *); int arc_ioctl(struct ifnet *, int, caddr_t); void arc_frag_init(struct ifnet *); diff --git a/sys/net/if_arcsubr.c b/sys/net/if_arcsubr.c index 0089d133fffc..9b834be9a235 100644 --- a/sys/net/if_arcsubr.c +++ b/sys/net/if_arcsubr.c @@ -102,7 +102,7 @@ u_int8_t arcbroadcastaddr = 0; */ int arc_output(struct ifnet *ifp, struct mbuf *m, struct sockaddr *dst, - struct rtentry *rt0) + struct route *ro) { struct arc_header *ah; int error; @@ -129,7 +129,8 @@ arc_output(struct ifnet *ifp, struct mbuf *m, struct sockaddr *dst, else if (ifp->if_flags & IFF_NOARP) adst = ntohl(SIN(dst)->sin_addr.s_addr) & 0xFF; else { - error = arpresolve(ifp, rt0, m, dst, &adst, &lle); + error = arpresolve(ifp, ro ? ro->ro_rt : NULL, + m, dst, &adst, &lle); if (error) return (error == EWOULDBLOCK ? 0 : error); } diff --git a/sys/net/if_atm.h b/sys/net/if_atm.h index 99cc27757148..e8f69da09d02 100644 --- a/sys/net/if_atm.h +++ b/sys/net/if_atm.h @@ -293,7 +293,7 @@ void atm_ifdetach(struct ifnet *); void atm_input(struct ifnet *, struct atm_pseudohdr *, struct mbuf *, void *); int atm_output(struct ifnet *, struct mbuf *, struct sockaddr *, - struct rtentry *); + struct route *); struct atmio_vcctable *atm_getvccs(struct atmio_vcc **, u_int, u_int, struct mtx *, int); diff --git a/sys/net/if_atmsubr.c b/sys/net/if_atmsubr.c index 7e36187c24e3..734acc5fb6e1 100644 --- a/sys/net/if_atmsubr.c +++ b/sys/net/if_atmsubr.c @@ -113,17 +113,17 @@ MALLOC_DEFINE(M_IFATM, "ifatm", "atm interface internals"); * "ifp" = ATM interface to output to * "m0" = the packet to output * "dst" = the sockaddr to send to (either IP addr, or raw VPI/VCI) - * "rt0" = the route to use + * "ro" = the route to use * returns: error code [0 == ok] * * note: special semantic: if (dst == NULL) then we assume "m" already * has an atm_pseudohdr on it and just send it directly. * [for native mode ATM output] if dst is null, then - * rt0 must also be NULL. + * ro->ro_rt must also be NULL. */ int atm_output(struct ifnet *ifp, struct mbuf *m0, struct sockaddr *dst, - struct rtentry *rt0) + struct route *ro) { u_int16_t etype = 0; /* if using LLC/SNAP */ int error = 0, sz; @@ -157,7 +157,7 @@ atm_output(struct ifnet *ifp, struct mbuf *m0, struct sockaddr *dst, etype = ETHERTYPE_IPV6; else etype = ETHERTYPE_IP; - if (!atmresolve(rt0, m, dst, &atmdst)) { + if (!atmresolve(ro->ro_rt, m, dst, &atmdst)) { m = NULL; /* XXX: atmresolve already free'd it */ senderr(EHOSTUNREACH); diff --git a/sys/net/if_disc.c b/sys/net/if_disc.c index 98a06c1093a4..ca7789920876 100644 --- a/sys/net/if_disc.c +++ b/sys/net/if_disc.c @@ -66,7 +66,7 @@ struct disc_softc { }; static int discoutput(struct ifnet *, struct mbuf *, - struct sockaddr *, struct rtentry *); + struct sockaddr *, struct route *); static void discrtrequest(int, struct rtentry *, struct rt_addrinfo *); static int discioctl(struct ifnet *, u_long, caddr_t); static int disc_clone_create(struct if_clone *, int, caddr_t); @@ -156,7 +156,7 @@ DECLARE_MODULE(if_disc, disc_mod, SI_SUB_PSEUDO, SI_ORDER_ANY); static int discoutput(struct ifnet *ifp, struct mbuf *m, struct sockaddr *dst, - struct rtentry *rt) + struct route *ro) { u_int32_t af; diff --git a/sys/net/if_enc.c b/sys/net/if_enc.c index aa008aec12fc..391b798d4e18 100644 --- a/sys/net/if_enc.c +++ b/sys/net/if_enc.c @@ -85,7 +85,7 @@ struct enc_softc { static int enc_ioctl(struct ifnet *, u_long, caddr_t); static int enc_output(struct ifnet *ifp, struct mbuf *m, - struct sockaddr *dst, struct rtentry *rt); + struct sockaddr *dst, struct route *ro); static int enc_clone_create(struct if_clone *, int, caddr_t); static void enc_clone_destroy(struct ifnet *); @@ -185,7 +185,7 @@ DECLARE_MODULE(enc, enc_mod, SI_SUB_PROTO_IFATTACHDOMAIN, SI_ORDER_ANY); static int enc_output(struct ifnet *ifp, struct mbuf *m, struct sockaddr *dst, - struct rtentry *rt) + struct route *ro) { m_freem(m); return (0); diff --git a/sys/net/if_ethersubr.c b/sys/net/if_ethersubr.c index df52f839a5a4..38bf7d47ca4b 100644 --- a/sys/net/if_ethersubr.c +++ b/sys/net/if_ethersubr.c @@ -163,17 +163,22 @@ static int ether_ipfw; */ int ether_output(struct ifnet *ifp, struct mbuf *m, - struct sockaddr *dst, struct rtentry *rt0) + struct sockaddr *dst, struct route *ro) { short type; - int error, hdrcmplt = 0; + int error = 0, hdrcmplt = 0; u_char esrc[ETHER_ADDR_LEN], edst[ETHER_ADDR_LEN]; struct llentry *lle = NULL; + struct rtentry *rt0 = NULL; struct ether_header *eh; struct pf_mtag *t; int loop_copy = 1; int hlen; /* link layer header length */ + if (ro != NULL) { + lle = ro->ro_lle; + rt0 = ro->ro_rt; + } #ifdef MAC error = mac_ifnet_check_transmit(ifp, m); if (error) @@ -191,7 +196,10 @@ ether_output(struct ifnet *ifp, struct mbuf *m, switch (dst->sa_family) { #ifdef INET case AF_INET: - error = arpresolve(ifp, rt0, m, dst, edst, &lle); + if (lle != NULL && (lle->la_flags & LLE_VALID)) + memcpy(edst, &lle->ll_addr.mac16, sizeof(edst)); + else + error = arpresolve(ifp, rt0, m, dst, edst, &lle); if (error) return (error == EWOULDBLOCK ? 0 : error); type = htons(ETHERTYPE_IP); @@ -226,7 +234,10 @@ ether_output(struct ifnet *ifp, struct mbuf *m, #endif #ifdef INET6 case AF_INET6: - error = nd6_storelladdr(ifp, m, dst, (u_char *)edst, &lle); + if (lle != NULL && (lle->la_flags & LLE_VALID)) + memcpy(edst, &lle->ll_addr.mac16, sizeof(edst)); + else + error = nd6_storelladdr(ifp, m, dst, (u_char *)edst, &lle); if (error) return error; type = htons(ETHERTYPE_IPV6); diff --git a/sys/net/if_faith.c b/sys/net/if_faith.c index c83974870e18..3b60d2c3598c 100644 --- a/sys/net/if_faith.c +++ b/sys/net/if_faith.c @@ -88,7 +88,7 @@ struct faith_softc { static int faithioctl(struct ifnet *, u_long, caddr_t); int faithoutput(struct ifnet *, struct mbuf *, struct sockaddr *, - struct rtentry *); + struct route *); static void faithrtrequest(int, struct rtentry *, struct rt_addrinfo *); #ifdef INET6 static int faithprefix(struct in6_addr *); @@ -188,17 +188,20 @@ faith_clone_destroy(ifp) } int -faithoutput(ifp, m, dst, rt) +faithoutput(ifp, m, dst, ro) struct ifnet *ifp; struct mbuf *m; struct sockaddr *dst; - struct rtentry *rt; + struct route *ro; { int isr; u_int32_t af; + struct rtentry *rt = NULL; M_ASSERTPKTHDR(m); + if (ro != NULL) + rt = ro->ro_rt; /* BPF writes need to be handled specially. */ if (dst->sa_family == AF_UNSPEC) { bcopy(dst->sa_data, &af, sizeof(af)); diff --git a/sys/net/if_fddisubr.c b/sys/net/if_fddisubr.c index 438a6e86b67b..28f6e3a5ee3b 100644 --- a/sys/net/if_fddisubr.c +++ b/sys/net/if_fddisubr.c @@ -98,7 +98,7 @@ static const u_char fddibroadcastaddr[FDDI_ADDR_LEN] = static int fddi_resolvemulti(struct ifnet *, struct sockaddr **, struct sockaddr *); static int fddi_output(struct ifnet *, struct mbuf *, struct sockaddr *, - struct rtentry *); + struct route *); static void fddi_input(struct ifnet *ifp, struct mbuf *m); #define senderr(e) do { error = (e); goto bad; } while (0) @@ -111,18 +111,21 @@ static void fddi_input(struct ifnet *ifp, struct mbuf *m); * Assumes that ifp is actually pointer to arpcom structure. */ static int -fddi_output(ifp, m, dst, rt0) +fddi_output(ifp, m, dst, ro) struct ifnet *ifp; struct mbuf *m; struct sockaddr *dst; - struct rtentry *rt0; + struct route *ro; { u_int16_t type; int loop_copy = 0, error = 0, hdrcmplt = 0; u_char esrc[FDDI_ADDR_LEN], edst[FDDI_ADDR_LEN]; struct fddi_header *fh; struct llentry *lle; + struct rtentry *rt0 = NULL; + if (ro != NULL) + rt0 = ro->ro_rt; #ifdef MAC error = mac_ifnet_check_transmit(ifp, m); if (error) diff --git a/sys/net/if_fwsubr.c b/sys/net/if_fwsubr.c index 9d7b95bd5e79..a5e0b19553ee 100644 --- a/sys/net/if_fwsubr.c +++ b/sys/net/if_fwsubr.c @@ -77,7 +77,7 @@ struct fw_hwaddr firewire_broadcastaddr = { static int firewire_output(struct ifnet *ifp, struct mbuf *m, struct sockaddr *dst, - struct rtentry *rt0) + struct route *ro) { struct fw_com *fc = IFP2FWC(ifp); int error, type; @@ -138,7 +138,7 @@ firewire_output(struct ifnet *ifp, struct mbuf *m, struct sockaddr *dst, * doesn't fit into the arp model. */ if (unicast) { - error = arpresolve(ifp, rt0, m, dst, (u_char *) destfw, &lle); + error = arpresolve(ifp, ro ? ro->ro_rt : NULL, m, dst, (u_char *) destfw, &lle); if (error) return (error == EWOULDBLOCK ? 0 : error); } diff --git a/sys/net/if_gif.c b/sys/net/if_gif.c index 1c10f1729bc7..a72d89c617a6 100644 --- a/sys/net/if_gif.c +++ b/sys/net/if_gif.c @@ -409,11 +409,11 @@ gif_start(struct ifnet *ifp) } int -gif_output(ifp, m, dst, rt) +gif_output(ifp, m, dst, ro) struct ifnet *ifp; struct mbuf *m; struct sockaddr *dst; - struct rtentry *rt; /* added in net2 */ + struct route *ro; { INIT_VNET_GIF(ifp->if_vnet); struct gif_softc *sc = ifp->if_softc; diff --git a/sys/net/if_gif.h b/sys/net/if_gif.h index 0fe45b31a88c..779d8be389d9 100644 --- a/sys/net/if_gif.h +++ b/sys/net/if_gif.h @@ -106,7 +106,7 @@ struct etherip_header { /* Prototypes */ void gif_input(struct mbuf *, int, struct ifnet *); int gif_output(struct ifnet *, struct mbuf *, struct sockaddr *, - struct rtentry *); + struct route *); int gif_ioctl(struct ifnet *, u_long, caddr_t); int gif_set_tunnel(struct ifnet *, struct sockaddr *, struct sockaddr *); void gif_delete_tunnel(struct ifnet *); diff --git a/sys/net/if_gre.c b/sys/net/if_gre.c index cfd249f0c34d..5ec12e058b07 100644 --- a/sys/net/if_gre.c +++ b/sys/net/if_gre.c @@ -110,7 +110,7 @@ static int gre_clone_create(struct if_clone *, int, caddr_t); static void gre_clone_destroy(struct ifnet *); static int gre_ioctl(struct ifnet *, u_long, caddr_t); static int gre_output(struct ifnet *, struct mbuf *, struct sockaddr *, - struct rtentry *rt); + struct route *ro); IFC_SIMPLE_DECLARE(gre, 0); @@ -240,7 +240,7 @@ gre_clone_destroy(ifp) */ static int gre_output(struct ifnet *ifp, struct mbuf *m, struct sockaddr *dst, - struct rtentry *rt) + struct route *ro) { #ifdef INET6 INIT_VNET_INET(ifp->if_vnet); diff --git a/sys/net/if_iso88025subr.c b/sys/net/if_iso88025subr.c index ff82e106d81f..99daf6692c1d 100644 --- a/sys/net/if_iso88025subr.c +++ b/sys/net/if_iso88025subr.c @@ -232,11 +232,11 @@ iso88025_ioctl(struct ifnet *ifp, int command, caddr_t data) * ISO88025 encapsulation */ int -iso88025_output(ifp, m, dst, rt0) +iso88025_output(ifp, m, dst, ro) struct ifnet *ifp; struct mbuf *m; struct sockaddr *dst; - struct rtentry *rt0; + struct route *ro; { u_int16_t snap_type = 0; int loop_copy = 0, error = 0, rif_len = 0; @@ -245,6 +245,10 @@ iso88025_output(ifp, m, dst, rt0) struct iso88025_header gen_th; struct sockaddr_dl *sdl = NULL; struct llentry *lle; + struct rtentry *rt0 = NULL; + + if (ro != NULL) + rt0 = ro->ro_rt; #ifdef MAC error = mac_ifnet_check_transmit(ifp, m); diff --git a/sys/net/if_lagg.c b/sys/net/if_lagg.c index 0ab96b370d0a..0479b90fcf96 100644 --- a/sys/net/if_lagg.c +++ b/sys/net/if_lagg.c @@ -93,7 +93,7 @@ static void lagg_linkstate(struct lagg_softc *); static void lagg_port_state(struct ifnet *, int); static int lagg_port_ioctl(struct ifnet *, u_long, caddr_t); static int lagg_port_output(struct ifnet *, struct mbuf *, - struct sockaddr *, struct rtentry *); + struct sockaddr *, struct route *); static void lagg_port_ifdetach(void *arg __unused, struct ifnet *); static int lagg_port_checkstacking(struct lagg_softc *); static void lagg_port2req(struct lagg_port *, struct lagg_reqport *); @@ -676,7 +676,7 @@ lagg_port_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data) static int lagg_port_output(struct ifnet *ifp, struct mbuf *m, - struct sockaddr *dst, struct rtentry *rt0) + struct sockaddr *dst, struct route *ro) { struct lagg_port *lp = ifp->if_lagg; struct ether_header *eh; @@ -696,7 +696,7 @@ lagg_port_output(struct ifnet *ifp, struct mbuf *m, */ switch (ntohs(type)) { case ETHERTYPE_PAE: /* EAPOL PAE/802.1x */ - return ((*lp->lp_output)(ifp, m, dst, rt0)); + return ((*lp->lp_output)(ifp, m, dst, ro)); } /* drop any other frames */ diff --git a/sys/net/if_lagg.h b/sys/net/if_lagg.h index 2b25118bbab1..896f5b310801 100644 --- a/sys/net/if_lagg.h +++ b/sys/net/if_lagg.h @@ -218,7 +218,7 @@ struct lagg_port { /* Redirected callbacks */ int (*lp_ioctl)(struct ifnet *, u_long, caddr_t); int (*lp_output)(struct ifnet *, struct mbuf *, struct sockaddr *, - struct rtentry *); + struct route *); SLIST_ENTRY(lagg_port) lp_entries; }; diff --git a/sys/net/if_loop.c b/sys/net/if_loop.c index c31acefcaf7a..ff57464ad21b 100644 --- a/sys/net/if_loop.c +++ b/sys/net/if_loop.c @@ -102,7 +102,7 @@ int loioctl(struct ifnet *, u_long, caddr_t); static void lortrequest(int, struct rtentry *, struct rt_addrinfo *); int looutput(struct ifnet *ifp, struct mbuf *m, - struct sockaddr *dst, struct rtentry *rt); + struct sockaddr *dst, struct route *ro); static int lo_clone_create(struct if_clone *, int, caddr_t); static void lo_clone_destroy(struct ifnet *); static int vnet_loif_iattach(const void *); @@ -205,15 +205,18 @@ DECLARE_MODULE(loop, loop_mod, SI_SUB_PROTO_IFATTACHDOMAIN, SI_ORDER_ANY); int looutput(struct ifnet *ifp, struct mbuf *m, struct sockaddr *dst, - struct rtentry *rt) + struct route *ro) { u_int32_t af; + struct rtentry *rt = NULL; #ifdef MAC int error; #endif M_ASSERTPKTHDR(m); /* check if we have the packet header */ + if (ro != NULL) + rt = ro->ro_rt; #ifdef MAC error = mac_ifnet_check_transmit(ifp, m); if (error) { diff --git a/sys/net/if_spppsubr.c b/sys/net/if_spppsubr.c index b1c71252d9cc..a84670c00022 100644 --- a/sys/net/if_spppsubr.c +++ b/sys/net/if_spppsubr.c @@ -263,7 +263,7 @@ static const u_short interactive_ports[8] = { int debug = ifp->if_flags & IFF_DEBUG static int sppp_output(struct ifnet *ifp, struct mbuf *m, - struct sockaddr *dst, struct rtentry *rt); + struct sockaddr *dst, struct route *ro); static void sppp_cisco_send(struct sppp *sp, int type, long par1, long par2); static void sppp_cisco_input(struct sppp *sp, struct mbuf *m); @@ -786,7 +786,7 @@ sppp_ifstart(struct ifnet *ifp) */ static int sppp_output(struct ifnet *ifp, struct mbuf *m, - struct sockaddr *dst, struct rtentry *rt) + struct sockaddr *dst, struct route *ro) { struct sppp *sp = IFP2SP(ifp); struct ppp_header *h; diff --git a/sys/net/if_stf.c b/sys/net/if_stf.c index e3db9aed95f7..cc43e5198307 100644 --- a/sys/net/if_stf.c +++ b/sys/net/if_stf.c @@ -178,7 +178,7 @@ static int stfmodevent(module_t, int, void *); static int stf_encapcheck(const struct mbuf *, int, int, void *); static struct in6_ifaddr *stf_getsrcifa6(struct ifnet *); static int stf_output(struct ifnet *, struct mbuf *, struct sockaddr *, - struct rtentry *); + struct route *); static int isrfc1918addr(struct in_addr *); static int stf_checkaddr4(struct stf_softc *, struct in_addr *, struct ifnet *); @@ -403,11 +403,11 @@ stf_getsrcifa6(ifp) } static int -stf_output(ifp, m, dst, rt) +stf_output(ifp, m, dst, ro) struct ifnet *ifp; struct mbuf *m; struct sockaddr *dst; - struct rtentry *rt; + struct route *ro; { struct stf_softc *sc; struct sockaddr_in6 *dst6; diff --git a/sys/net/if_tun.c b/sys/net/if_tun.c index eb65fba30591..0a1d34e733d2 100644 --- a/sys/net/if_tun.c +++ b/sys/net/if_tun.c @@ -129,7 +129,7 @@ static int tunifioctl(struct ifnet *, u_long, caddr_t); static int tuninit(struct ifnet *); static int tunmodevent(module_t, int, void *); static int tunoutput(struct ifnet *, struct mbuf *, struct sockaddr *, - struct rtentry *rt); + struct route *ro); static void tunstart(struct ifnet *); static int tun_clone_create(struct if_clone *, int, caddr_t); @@ -591,7 +591,7 @@ tunoutput( struct ifnet *ifp, struct mbuf *m0, struct sockaddr *dst, - struct rtentry *rt) + struct route *ro) { struct tun_softc *tp = ifp->if_softc; u_short cached_tun_flags; diff --git a/sys/net/if_var.h b/sys/net/if_var.h index 88ec559306e6..50846f8b7e0d 100644 --- a/sys/net/if_var.h +++ b/sys/net/if_var.h @@ -70,6 +70,7 @@ struct socket; struct ether_header; struct carp_if; struct ifvlantrunk; +struct route; #endif #include /* get TAILQ macros */ @@ -149,7 +150,7 @@ struct ifnet { /* procedure handles */ int (*if_output) /* output routine (enqueue) */ (struct ifnet *, struct mbuf *, struct sockaddr *, - struct rtentry *); + struct route *); void (*if_input) /* input routine (from h/w driver) */ (struct ifnet *, struct mbuf *); void (*if_start) /* initiate output routine */ diff --git a/sys/net/iso88025.h b/sys/net/iso88025.h index cb10874ebc11..b42162bb2664 100644 --- a/sys/net/iso88025.h +++ b/sys/net/iso88025.h @@ -166,7 +166,7 @@ void iso88025_ifattach (struct ifnet *, const u_int8_t *, int); void iso88025_ifdetach (struct ifnet *, int); int iso88025_ioctl (struct ifnet *, int , caddr_t ); int iso88025_output (struct ifnet *, struct mbuf *, struct sockaddr *, - struct rtentry *); + struct route *); void iso88025_input (struct ifnet *, struct mbuf *); #endif diff --git a/sys/net/route.h b/sys/net/route.h index 0d35adc9e1db..731db4b2013c 100644 --- a/sys/net/route.h +++ b/sys/net/route.h @@ -41,9 +41,10 @@ */ /* - * A route consists of a destination address and a reference - * to a routing entry. These are often held by protocols - * in their control blocks, e.g. inpcb. + * A route consists of a destination address, a reference + * to a routing entry, and a reference to an llentry. + * These are often held by protocols in their control + * blocks, e.g. inpcb. */ struct route { struct rtentry *ro_rt; diff --git a/sys/net80211/ieee80211.c b/sys/net80211/ieee80211.c index bd3c1ae4fc02..eb40f61d644a 100644 --- a/sys/net80211/ieee80211.c +++ b/sys/net80211/ieee80211.c @@ -221,7 +221,7 @@ null_update_promisc(struct ifnet *ifp) static int null_output(struct ifnet *ifp, struct mbuf *m, - struct sockaddr *dst, struct rtentry *rt0) + struct sockaddr *dst, struct route *ro) { if_printf(ifp, "discard raw packet\n"); m_freem(m); diff --git a/sys/net80211/ieee80211_output.c b/sys/net80211/ieee80211_output.c index 21e0370e7ce4..b109db809b3f 100644 --- a/sys/net80211/ieee80211_output.c +++ b/sys/net80211/ieee80211_output.c @@ -294,7 +294,7 @@ ieee80211_start(struct ifnet *ifp) */ int ieee80211_output(struct ifnet *ifp, struct mbuf *m, - struct sockaddr *dst, struct rtentry *rt0) + struct sockaddr *dst, struct route *ro) { #define senderr(e) do { error = (e); goto bad;} while (0) struct ieee80211_node *ni = NULL; @@ -320,7 +320,7 @@ ieee80211_output(struct ifnet *ifp, struct mbuf *m, * a raw 802.11 frame. */ if (dst->sa_family != AF_IEEE80211) - return vap->iv_output(ifp, m, dst, rt0); + return vap->iv_output(ifp, m, dst, ro); #ifdef MAC error = mac_check_ifnet_transmit(ifp, m); if (error) diff --git a/sys/net80211/ieee80211_proto.h b/sys/net80211/ieee80211_proto.h index 2d32d1e058b3..3712c1eaf808 100644 --- a/sys/net80211/ieee80211_proto.h +++ b/sys/net80211/ieee80211_proto.h @@ -70,7 +70,7 @@ int ieee80211_mgmt_output(struct ieee80211_node *, struct mbuf *, int, int ieee80211_raw_xmit(struct ieee80211_node *, struct mbuf *, const struct ieee80211_bpf_params *); int ieee80211_output(struct ifnet *, struct mbuf *, - struct sockaddr *, struct rtentry *); + struct sockaddr *, struct route *ro); void ieee80211_start(struct ifnet *); int ieee80211_send_nulldata(struct ieee80211_node *); int ieee80211_classify(struct ieee80211_node *, struct mbuf *m); diff --git a/sys/net80211/ieee80211_var.h b/sys/net80211/ieee80211_var.h index 47050475875f..ea72c12b0293 100644 --- a/sys/net80211/ieee80211_var.h +++ b/sys/net80211/ieee80211_var.h @@ -437,7 +437,7 @@ struct ieee80211vap { enum ieee80211_state, int); /* 802.3 output method for raw frame xmit */ int (*iv_output)(struct ifnet *, struct mbuf *, - struct sockaddr *, struct rtentry *); + struct sockaddr *, struct route *); }; MALLOC_DECLARE(M_80211_VAP); diff --git a/sys/netgraph/ng_fec.c b/sys/netgraph/ng_fec.c index dc4ad40d185a..e694dd8de1d9 100644 --- a/sys/netgraph/ng_fec.c +++ b/sys/netgraph/ng_fec.c @@ -107,6 +107,7 @@ #include #include #include +#include #include "opt_inet.h" #include "opt_inet6.h" @@ -165,7 +166,7 @@ struct ng_fec_bundle { int (*fec_if_output) (struct ifnet *, struct mbuf *, struct sockaddr *, - struct rtentry *); + struct route *); }; #define FEC_BTYPE_MAC 0x01 @@ -197,7 +198,7 @@ static int ng_fec_ifmedia_upd(struct ifnet *ifp); static void ng_fec_ifmedia_sts(struct ifnet *ifp, struct ifmediareq *ifmr); static int ng_fec_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data); static int ng_fec_output(struct ifnet *ifp, struct mbuf *m0, - struct sockaddr *dst, struct rtentry *rt0); + struct sockaddr *dst, struct route *ro); static void ng_fec_tick(void *arg); static int ng_fec_addport(struct ng_fec_private *priv, char *iface); static int ng_fec_delport(struct ng_fec_private *priv, char *iface); @@ -923,7 +924,7 @@ ng_fec_input(struct ifnet *ifp, struct mbuf *m0) static int ng_fec_output(struct ifnet *ifp, struct mbuf *m, - struct sockaddr *dst, struct rtentry *rt0) + struct sockaddr *dst, struct route *ro) { const priv_p priv = (priv_p) ifp->if_softc; struct ng_fec_bundle *b; @@ -977,7 +978,7 @@ ng_fec_output(struct ifnet *ifp, struct mbuf *m, * for us. */ priv->if_error = 0; - error = (*b->fec_if_output)(ifp, m, dst, rt0); + error = (*b->fec_if_output)(ifp, m, dst, ro); if (priv->if_error && !error) error = priv->if_error; diff --git a/sys/netgraph/ng_iface.c b/sys/netgraph/ng_iface.c index a22b85a581dd..99fd9717f382 100644 --- a/sys/netgraph/ng_iface.c +++ b/sys/netgraph/ng_iface.c @@ -75,6 +75,7 @@ #include #include #include +#include #include @@ -121,7 +122,7 @@ typedef struct ng_iface_private *priv_p; static void ng_iface_start(struct ifnet *ifp); static int ng_iface_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data); static int ng_iface_output(struct ifnet *ifp, struct mbuf *m0, - struct sockaddr *dst, struct rtentry *rt0); + struct sockaddr *dst, struct route *ro); static void ng_iface_bpftap(struct ifnet *ifp, struct mbuf *m, sa_family_t family); static int ng_iface_send(struct ifnet *ifp, struct mbuf *m, @@ -354,7 +355,7 @@ ng_iface_ioctl(struct ifnet *ifp, u_long command, caddr_t data) static int ng_iface_output(struct ifnet *ifp, struct mbuf *m, - struct sockaddr *dst, struct rtentry *rt0) + struct sockaddr *dst, struct route *ro) { struct m_tag *mtag; uint32_t af; diff --git a/sys/netinet/if_ether.c b/sys/netinet/if_ether.c index 90ef00d8506d..38e420eefc4c 100644 --- a/sys/netinet/if_ether.c +++ b/sys/netinet/if_ether.c @@ -238,7 +238,7 @@ arprequest(struct ifnet *ifp, struct in_addr *sip, struct in_addr *tip, sa.sa_family = AF_ARP; sa.sa_len = 2; m->m_flags |= M_BCAST; - (*ifp->if_output)(ifp, m, &sa, (struct rtentry *)0); + (*ifp->if_output)(ifp, m, &sa, NULL); } /* @@ -753,7 +753,7 @@ in_arpinput(struct mbuf *m) m->m_pkthdr.len = m->m_len; sa.sa_family = AF_ARP; sa.sa_len = 2; - (*ifp->if_output)(ifp, m, &sa, (struct rtentry *)0); + (*ifp->if_output)(ifp, m, &sa, NULL); return; drop: diff --git a/sys/netinet/ip_carp.c b/sys/netinet/ip_carp.c index cc745806e0e1..33b505936c4e 100644 --- a/sys/netinet/ip_carp.c +++ b/sys/netinet/ip_carp.c @@ -207,7 +207,7 @@ static void carp_master_down(void *); static void carp_master_down_locked(struct carp_softc *); static int carp_ioctl(struct ifnet *, u_long, caddr_t); static int carp_looutput(struct ifnet *, struct mbuf *, struct sockaddr *, - struct rtentry *); + struct route *); static void carp_start(struct ifnet *); static void carp_setrun(struct carp_softc *, sa_family_t); static void carp_set_state(struct carp_softc *, int); @@ -2011,12 +2011,15 @@ carp_ioctl(struct ifnet *ifp, u_long cmd, caddr_t addr) */ static int carp_looutput(struct ifnet *ifp, struct mbuf *m, struct sockaddr *dst, - struct rtentry *rt) + struct route *ro) { u_int32_t af; + struct rtentry *rt = NULL; M_ASSERTPKTHDR(m); /* check if we have the packet header */ + if (ro != NULL) + rt = ro->ro_rt; if (rt && rt->rt_flags & (RTF_REJECT|RTF_BLACKHOLE)) { m_freem(m); return (rt->rt_flags & RTF_BLACKHOLE ? 0 : diff --git a/sys/netinet/ip_fastfwd.c b/sys/netinet/ip_fastfwd.c index 0479064ae49c..8752916934f1 100644 --- a/sys/netinet/ip_fastfwd.c +++ b/sys/netinet/ip_fastfwd.c @@ -183,7 +183,7 @@ ip_fastforward(struct mbuf *m) M_ASSERTVALID(m); M_ASSERTPKTHDR(m); - ro.ro_rt = NULL; + bzero(&ro, sizeof(ro)); /* * Step 1: check for packet drop conditions (and sanity checks) @@ -552,7 +552,7 @@ ip_fastforward(struct mbuf *m) * Send off the packet via outgoing interface */ error = (*ifp->if_output)(ifp, m, - (struct sockaddr *)dst, ro.ro_rt); + (struct sockaddr *)dst, &ro); } else { /* * Handle EMSGSIZE with icmp reply needfrag for TCP MTU discovery @@ -585,7 +585,7 @@ ip_fastforward(struct mbuf *m) m->m_nextpkt = NULL; error = (*ifp->if_output)(ifp, m, - (struct sockaddr *)dst, ro.ro_rt); + (struct sockaddr *)dst, &ro); if (error) break; } while ((m = m0) != NULL); diff --git a/sys/netinet/ip_output.c b/sys/netinet/ip_output.c index 16dba61aeeba..76d8f2ad2dc8 100644 --- a/sys/netinet/ip_output.c +++ b/sys/netinet/ip_output.c @@ -595,7 +595,7 @@ ip_output(struct mbuf *m, struct mbuf *opt, struct route *ro, int flags, */ m->m_flags &= ~(M_PROTOFLAGS); error = (*ifp->if_output)(ifp, m, - (struct sockaddr *)dst, ro->ro_rt); + (struct sockaddr *)dst, ro); goto done; } @@ -629,7 +629,7 @@ ip_output(struct mbuf *m, struct mbuf *opt, struct route *ro, int flags, m->m_flags &= ~(M_PROTOFLAGS); error = (*ifp->if_output)(ifp, m, - (struct sockaddr *)dst, ro->ro_rt); + (struct sockaddr *)dst, ro); } else m_freem(m); } diff --git a/sys/netinet6/nd6.c b/sys/netinet6/nd6.c index 857d3fc1c227..ef0c82583885 100644 --- a/sys/netinet6/nd6.c +++ b/sys/netinet6/nd6.c @@ -1939,7 +1939,7 @@ nd6_output_lle(struct ifnet *ifp, struct ifnet *origifp, struct mbuf *m0, int nd6_output_flush(struct ifnet *ifp, struct ifnet *origifp, struct mbuf *chain, - struct sockaddr_in6 *dst, struct rtentry *rt) + struct sockaddr_in6 *dst, struct route *ro) { struct mbuf *m, *m_head; struct ifnet *outifp; @@ -1954,7 +1954,7 @@ nd6_output_flush(struct ifnet *ifp, struct ifnet *origifp, struct mbuf *chain, while (m_head) { m = m_head; m_head = m_head->m_nextpkt; - error = (*ifp->if_output)(ifp, m, (struct sockaddr *)dst, rt); + error = (*ifp->if_output)(ifp, m, (struct sockaddr *)dst, ro); } /* diff --git a/sys/netinet6/nd6.h b/sys/netinet6/nd6.h index e2007f72760e..d4d2fd577782 100644 --- a/sys/netinet6/nd6.h +++ b/sys/netinet6/nd6.h @@ -395,7 +395,7 @@ int nd6_output_lle __P((struct ifnet *, struct ifnet *, struct mbuf *, struct sockaddr_in6 *, struct rtentry *, struct llentry *, struct mbuf **)); int nd6_output_flush __P((struct ifnet *, struct ifnet *, struct mbuf *, - struct sockaddr_in6 *, struct rtentry *)); + struct sockaddr_in6 *, struct route *)); int nd6_need_cache __P((struct ifnet *)); int nd6_storelladdr __P((struct ifnet *, struct mbuf *, struct sockaddr *, u_char *, struct llentry **)); diff --git a/sys/netipx/ipx_outputfl.c b/sys/netipx/ipx_outputfl.c index 61d8759ee55c..9c88f4327ca2 100644 --- a/sys/netipx/ipx_outputfl.c +++ b/sys/netipx/ipx_outputfl.c @@ -154,7 +154,7 @@ ipx_outputfl(struct mbuf *m0, struct route *ro, int flags) ipx_watch_output(m0, ifp); } error = (*ifp->if_output)(ifp, m0, - (struct sockaddr *)dst, ro->ro_rt); + (struct sockaddr *)dst, ro); goto done; } else { ipxstat.ipxs_mtutoosmall++;