if_loop.c (241394) | if_loop.c (241610) |
---|---|
1/*- 2 * Copyright (c) 1982, 1986, 1993 3 * The Regents of the University of California. All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 13 unchanged lines hidden (view full) --- 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 27 * SUCH DAMAGE. 28 * 29 * @(#)if_loop.c 8.2 (Berkeley) 1/9/95 | 1/*- 2 * Copyright (c) 1982, 1986, 1993 3 * The Regents of the University of California. All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 13 unchanged lines hidden (view full) --- 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 27 * SUCH DAMAGE. 28 * 29 * @(#)if_loop.c 8.2 (Berkeley) 1/9/95 |
30 * $FreeBSD: head/sys/net/if_loop.c 241394 2012-10-10 08:36:38Z kevlo $ | 30 * $FreeBSD: head/sys/net/if_loop.c 241610 2012-10-16 13:37:54Z glebius $ |
31 */ 32 33/* 34 * Loopback interface driver for protocol testing and timing. 35 */ 36 37#include "opt_atalk.h" 38#include "opt_inet.h" --- 64 unchanged lines hidden (view full) --- 103int looutput(struct ifnet *ifp, struct mbuf *m, 104 struct sockaddr *dst, struct route *ro); 105static int lo_clone_create(struct if_clone *, int, caddr_t); 106static void lo_clone_destroy(struct ifnet *); 107 108VNET_DEFINE(struct ifnet *, loif); /* Used externally */ 109 110#ifdef VIMAGE | 31 */ 32 33/* 34 * Loopback interface driver for protocol testing and timing. 35 */ 36 37#include "opt_atalk.h" 38#include "opt_inet.h" --- 64 unchanged lines hidden (view full) --- 103int looutput(struct ifnet *ifp, struct mbuf *m, 104 struct sockaddr *dst, struct route *ro); 105static int lo_clone_create(struct if_clone *, int, caddr_t); 106static void lo_clone_destroy(struct ifnet *); 107 108VNET_DEFINE(struct ifnet *, loif); /* Used externally */ 109 110#ifdef VIMAGE |
111static VNET_DEFINE(struct ifc_simple_data, lo_cloner_data); 112static VNET_DEFINE(struct if_clone, lo_cloner); 113#define V_lo_cloner_data VNET(lo_cloner_data) | 111static VNET_DEFINE(struct if_clone *, lo_cloner); |
114#define V_lo_cloner VNET(lo_cloner) 115#endif 116 | 112#define V_lo_cloner VNET(lo_cloner) 113#endif 114 |
117IFC_SIMPLE_DECLARE(lo, 1); | 115static struct if_clone *lo_cloner; 116static const char loname[] = "lo"; |
118 119static void 120lo_clone_destroy(struct ifnet *ifp) 121{ 122 123#ifndef VIMAGE 124 /* XXX: destroying lo0 will lead to panics. */ 125 KASSERT(V_loif != ifp, ("%s: destroying lo0", __func__)); --- 8 unchanged lines hidden (view full) --- 134lo_clone_create(struct if_clone *ifc, int unit, caddr_t params) 135{ 136 struct ifnet *ifp; 137 138 ifp = if_alloc(IFT_LOOP); 139 if (ifp == NULL) 140 return (ENOSPC); 141 | 117 118static void 119lo_clone_destroy(struct ifnet *ifp) 120{ 121 122#ifndef VIMAGE 123 /* XXX: destroying lo0 will lead to panics. */ 124 KASSERT(V_loif != ifp, ("%s: destroying lo0", __func__)); --- 8 unchanged lines hidden (view full) --- 133lo_clone_create(struct if_clone *ifc, int unit, caddr_t params) 134{ 135 struct ifnet *ifp; 136 137 ifp = if_alloc(IFT_LOOP); 138 if (ifp == NULL) 139 return (ENOSPC); 140 |
142 if_initname(ifp, ifc->ifc_name, unit); | 141 if_initname(ifp, loname, unit); |
143 ifp->if_mtu = LOMTU; 144 ifp->if_flags = IFF_LOOPBACK | IFF_MULTICAST; 145 ifp->if_ioctl = loioctl; 146 ifp->if_output = looutput; 147 ifp->if_snd.ifq_maxlen = ifqmaxlen; 148 ifp->if_capabilities = ifp->if_capenable = 149 IFCAP_HWCSUM | IFCAP_HWCSUM_IPV6; 150 ifp->if_hwassist = LO_CSUM_FEATURES | LO_CSUM_FEATURES6; --- 5 unchanged lines hidden (view full) --- 156 return (0); 157} 158 159static void 160vnet_loif_init(const void *unused __unused) 161{ 162 163#ifdef VIMAGE | 142 ifp->if_mtu = LOMTU; 143 ifp->if_flags = IFF_LOOPBACK | IFF_MULTICAST; 144 ifp->if_ioctl = loioctl; 145 ifp->if_output = looutput; 146 ifp->if_snd.ifq_maxlen = ifqmaxlen; 147 ifp->if_capabilities = ifp->if_capenable = 148 IFCAP_HWCSUM | IFCAP_HWCSUM_IPV6; 149 ifp->if_hwassist = LO_CSUM_FEATURES | LO_CSUM_FEATURES6; --- 5 unchanged lines hidden (view full) --- 155 return (0); 156} 157 158static void 159vnet_loif_init(const void *unused __unused) 160{ 161 162#ifdef VIMAGE |
163 lo_cloner = if_clone_simple(loname, lo_clone_create, lo_clone_destroy, 164 1); |
|
164 V_lo_cloner = lo_cloner; | 165 V_lo_cloner = lo_cloner; |
165 V_lo_cloner_data = lo_cloner_data; 166 V_lo_cloner.ifc_data = &V_lo_cloner_data; 167 if_clone_attach(&V_lo_cloner); | |
168#else | 166#else |
169 if_clone_attach(&lo_cloner); | 167 lo_cloner = if_clone_simple(loname, lo_clone_create, lo_clone_destroy, 168 1); |
170#endif 171} 172VNET_SYSINIT(vnet_loif_init, SI_SUB_PROTO_IFATTACHDOMAIN, SI_ORDER_ANY, 173 vnet_loif_init, NULL); 174 175#ifdef VIMAGE 176static void 177vnet_loif_uninit(const void *unused __unused) 178{ 179 | 169#endif 170} 171VNET_SYSINIT(vnet_loif_init, SI_SUB_PROTO_IFATTACHDOMAIN, SI_ORDER_ANY, 172 vnet_loif_init, NULL); 173 174#ifdef VIMAGE 175static void 176vnet_loif_uninit(const void *unused __unused) 177{ 178 |
180 if_clone_detach(&V_lo_cloner); | 179 if_clone_detach(V_lo_cloner); |
181 V_loif = NULL; 182} 183VNET_SYSUNINIT(vnet_loif_uninit, SI_SUB_PROTO_IFATTACHDOMAIN, SI_ORDER_ANY, 184 vnet_loif_uninit, NULL); 185#endif 186 187static int 188loop_modevent(module_t mod, int type, void *data) --- 300 unchanged lines hidden --- | 180 V_loif = NULL; 181} 182VNET_SYSUNINIT(vnet_loif_uninit, SI_SUB_PROTO_IFATTACHDOMAIN, SI_ORDER_ANY, 183 vnet_loif_uninit, NULL); 184#endif 185 186static int 187loop_modevent(module_t mod, int type, void *data) --- 300 unchanged lines hidden --- |