diff options
Diffstat (limited to 'freebsd/sys/net/if_loop.c')
-rw-r--r-- | freebsd/sys/net/if_loop.c | 96 |
1 files changed, 27 insertions, 69 deletions
diff --git a/freebsd/sys/net/if_loop.c b/freebsd/sys/net/if_loop.c index b40dec8e..aa5109eb 100644 --- a/freebsd/sys/net/if_loop.c +++ b/freebsd/sys/net/if_loop.c @@ -36,10 +36,8 @@ * Loopback interface driver for protocol testing and timing. */ -#include <rtems/bsd/local/opt_atalk.h> #include <rtems/bsd/local/opt_inet.h> #include <rtems/bsd/local/opt_inet6.h> -#include <rtems/bsd/local/opt_ipx.h> #include <rtems/bsd/sys/param.h> #include <sys/systm.h> @@ -53,6 +51,7 @@ #include <sys/sysctl.h> #include <net/if.h> +#include <net/if_var.h> #include <net/if_clone.h> #include <net/if_types.h> #include <net/netisr.h> @@ -65,11 +64,6 @@ #include <netinet/in_var.h> #endif -#ifdef IPX -#include <netipx/ipx.h> -#include <netipx/ipx_if.h> -#endif - #ifdef INET6 #ifndef INET #include <netinet/in.h> @@ -78,11 +72,6 @@ #include <netinet/ip6.h> #endif -#ifdef NETATALK -#include <netatalk/at.h> -#include <netatalk/at_var.h> -#endif - #include <security/mac/mac_framework.h> #ifdef TINY_LOMTU @@ -101,22 +90,20 @@ CSUM_SCTP_VALID) 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 route *ro); + const struct sockaddr *dst, struct route *ro); static int lo_clone_create(struct if_clone *, int, caddr_t); static void lo_clone_destroy(struct ifnet *); VNET_DEFINE(struct ifnet *, loif); /* Used externally */ #ifdef VIMAGE -static VNET_DEFINE(struct ifc_simple_data, lo_cloner_data); -static VNET_DEFINE(struct if_clone, lo_cloner); -#define V_lo_cloner_data VNET(lo_cloner_data) +static VNET_DEFINE(struct if_clone *, lo_cloner); #define V_lo_cloner VNET(lo_cloner) #endif -IFC_SIMPLE_DECLARE(lo, 1); +static struct if_clone *lo_cloner; +static const char loname[] = "lo"; static void lo_clone_destroy(struct ifnet *ifp) @@ -141,7 +128,7 @@ lo_clone_create(struct if_clone *ifc, int unit, caddr_t params) if (ifp == NULL) return (ENOSPC); - if_initname(ifp, ifc->ifc_name, unit); + if_initname(ifp, loname, unit); ifp->if_mtu = LOMTU; ifp->if_flags = IFF_LOOPBACK | IFF_MULTICAST; ifp->if_ioctl = loioctl; @@ -163,15 +150,15 @@ vnet_loif_init(const void *unused __unused) { #ifdef VIMAGE + lo_cloner = if_clone_simple(loname, lo_clone_create, lo_clone_destroy, + 1); V_lo_cloner = lo_cloner; - V_lo_cloner_data = lo_cloner_data; - V_lo_cloner.ifc_data = &V_lo_cloner_data; - if_clone_attach(&V_lo_cloner); #else - if_clone_attach(&lo_cloner); + lo_cloner = if_clone_simple(loname, lo_clone_create, lo_clone_destroy, + 1); #endif } -VNET_SYSINIT(vnet_loif_init, SI_SUB_PROTO_IFATTACHDOMAIN, SI_ORDER_ANY, +VNET_SYSINIT(vnet_loif_init, SI_SUB_PSEUDO, SI_ORDER_ANY, vnet_loif_init, NULL); #ifdef VIMAGE @@ -179,10 +166,10 @@ static void vnet_loif_uninit(const void *unused __unused) { - if_clone_detach(&V_lo_cloner); + if_clone_detach(V_lo_cloner); V_loif = NULL; } -VNET_SYSUNINIT(vnet_loif_uninit, SI_SUB_PROTO_IFATTACHDOMAIN, SI_ORDER_ANY, +VNET_SYSUNINIT(vnet_loif_uninit, SI_SUB_INIT_IF, SI_ORDER_SECOND, vnet_loif_uninit, NULL); #endif @@ -213,19 +200,16 @@ static moduledata_t loop_mod = { DECLARE_MODULE(if_lo, loop_mod, SI_SUB_PROTO_IFATTACHDOMAIN, SI_ORDER_ANY); int -looutput(struct ifnet *ifp, struct mbuf *m, struct sockaddr *dst, +looutput(struct ifnet *ifp, struct mbuf *m, const struct sockaddr *dst, 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) { @@ -234,23 +218,22 @@ looutput(struct ifnet *ifp, struct mbuf *m, struct sockaddr *dst, } #endif - if (rt && rt->rt_flags & (RTF_REJECT|RTF_BLACKHOLE)) { + if (ro != NULL && ro->ro_flags & (RT_REJECT|RT_BLACKHOLE)) { m_freem(m); - return (rt->rt_flags & RTF_BLACKHOLE ? 0 : - rt->rt_flags & RTF_HOST ? EHOSTUNREACH : ENETUNREACH); + return (ro->ro_flags & RT_BLACKHOLE ? 0 : EHOSTUNREACH); } - ifp->if_opackets++; - ifp->if_obytes += m->m_pkthdr.len; + if_inc_counter(ifp, IFCOUNTER_OPACKETS, 1); + if_inc_counter(ifp, IFCOUNTER_OBYTES, m->m_pkthdr.len); /* BPF writes need to be handled specially. */ - if (dst->sa_family == AF_UNSPEC) { + if (dst->sa_family == AF_UNSPEC || dst->sa_family == pseudo_AF_HDRCMPLT) bcopy(dst->sa_data, &af, sizeof(af)); - dst->sa_family = af; - } + else + af = dst->sa_family; #if 1 /* XXX */ - switch (dst->sa_family) { + switch (af) { case AF_INET: if (ifp->if_capenable & IFCAP_RXCSUM) { m->m_pkthdr.csum_data = 0xffff; @@ -275,16 +258,13 @@ looutput(struct ifnet *ifp, struct mbuf *m, struct sockaddr *dst, #endif m->m_pkthdr.csum_flags &= ~LO_CSUM_FEATURES6; break; - case AF_IPX: - case AF_APPLETALK: - break; default: - printf("looutput: af=%d unexpected\n", dst->sa_family); + printf("looutput: af=%d unexpected\n", af); m_freem(m); return (EAFNOSUPPORT); } #endif - return (if_simloop(ifp, m, dst->sa_family, 0)); + return (if_simloop(ifp, m, af, 0)); } /* @@ -370,36 +350,17 @@ if_simloop(struct ifnet *ifp, struct mbuf *m, int af, int hlen) isr = NETISR_IPV6; break; #endif -#ifdef IPX - case AF_IPX: - isr = NETISR_IPX; - break; -#endif -#ifdef NETATALK - case AF_APPLETALK: - isr = NETISR_ATALK2; - break; -#endif default: printf("if_simloop: can't handle af=%d\n", af); m_freem(m); return (EAFNOSUPPORT); } - ifp->if_ipackets++; - ifp->if_ibytes += m->m_pkthdr.len; + if_inc_counter(ifp, IFCOUNTER_IPACKETS, 1); + if_inc_counter(ifp, IFCOUNTER_IBYTES, m->m_pkthdr.len); netisr_queue(isr, m); /* mbuf is free'd on failure. */ return (0); } -/* ARGSUSED */ -static void -lortrequest(int cmd, struct rtentry *rt, struct rt_addrinfo *info) -{ - - RT_LOCK_ASSERT(rt); - rt->rt_rmx.rmx_mtu = rt->rt_ifp->if_mtu; -} - /* * Process an ioctl request. */ @@ -407,7 +368,6 @@ lortrequest(int cmd, struct rtentry *rt, struct rt_addrinfo *info) int loioctl(struct ifnet *ifp, u_long cmd, caddr_t data) { - struct ifaddr *ifa; struct ifreq *ifr = (struct ifreq *)data; int error = 0, mask; @@ -415,8 +375,6 @@ loioctl(struct ifnet *ifp, u_long cmd, caddr_t data) case SIOCSIFADDR: ifp->if_flags |= IFF_UP; ifp->if_drv_flags |= IFF_DRV_RUNNING; - ifa = (struct ifaddr *)data; - ifa->ifa_rtrequest = lortrequest; /* * Everything else is done at a higher level. */ @@ -424,7 +382,7 @@ loioctl(struct ifnet *ifp, u_long cmd, caddr_t data) case SIOCADDMULTI: case SIOCDELMULTI: - if (ifr == 0) { + if (ifr == NULL) { error = EAFNOSUPPORT; /* XXX */ break; } |