Deleted Added
full compact
if_loop.c (193511) if_loop.c (193731)
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 193511 2009-06-05 14:55:22Z rwatson $
30 * $FreeBSD: head/sys/net/if_loop.c 193731 2009-06-08 17:15:40Z zec $
31 */
32
33/*
34 * Loopback interface driver for protocol testing and timing.
35 */
36
37#include "opt_atalk.h"
38#include "opt_inet.h"

--- 61 unchanged lines hidden (view full) ---

100
101int loioctl(struct ifnet *, u_long, caddr_t);
102static void lortrequest(int, struct rtentry *, struct rt_addrinfo *);
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 *);
107static int vnet_loif_iattach(const void *);
31 */
32
33/*
34 * Loopback interface driver for protocol testing and timing.
35 */
36
37#include "opt_atalk.h"
38#include "opt_inet.h"

--- 61 unchanged lines hidden (view full) ---

100
101int loioctl(struct ifnet *, u_long, caddr_t);
102static void lortrequest(int, struct rtentry *, struct rt_addrinfo *);
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 *);
107static int vnet_loif_iattach(const void *);
108#ifdef VIMAGE
109static int vnet_loif_idetach(const void *);
110#endif
108
109#ifdef VIMAGE_GLOBALS
110struct ifnet *loif; /* Used externally */
111#endif
112
113#ifdef VIMAGE
114MALLOC_DEFINE(M_LO_CLONER, "lo_cloner", "lo_cloner");
115#endif
116
117#ifndef VIMAGE_GLOBALS
118static const vnet_modinfo_t vnet_loif_modinfo = {
119 .vmi_id = VNET_MOD_LOIF,
120 .vmi_dependson = VNET_MOD_IF_CLONE,
121 .vmi_name = "loif",
111
112#ifdef VIMAGE_GLOBALS
113struct ifnet *loif; /* Used externally */
114#endif
115
116#ifdef VIMAGE
117MALLOC_DEFINE(M_LO_CLONER, "lo_cloner", "lo_cloner");
118#endif
119
120#ifndef VIMAGE_GLOBALS
121static const vnet_modinfo_t vnet_loif_modinfo = {
122 .vmi_id = VNET_MOD_LOIF,
123 .vmi_dependson = VNET_MOD_IF_CLONE,
124 .vmi_name = "loif",
122 .vmi_iattach = vnet_loif_iattach
125 .vmi_iattach = vnet_loif_iattach,
126#ifdef VIMAGE
127 .vmi_idetach = vnet_loif_idetach
128#endif
123};
124#endif /* !VIMAGE_GLOBALS */
125
126IFC_SIMPLE_DECLARE(lo, 1);
127
128static void
129lo_clone_destroy(struct ifnet *ifp)
130{
129};
130#endif /* !VIMAGE_GLOBALS */
131
132IFC_SIMPLE_DECLARE(lo, 1);
133
134static void
135lo_clone_destroy(struct ifnet *ifp)
136{
131#ifdef INVARIANTS
132 INIT_VNET_NET(ifp->if_vnet);
133#endif
134
137
138#ifndef VIMAGE
135 /* XXX: destroying lo0 will lead to panics. */
136 KASSERT(V_loif != ifp, ("%s: destroying lo0", __func__));
139 /* XXX: destroying lo0 will lead to panics. */
140 KASSERT(V_loif != ifp, ("%s: destroying lo0", __func__));
141#endif
137
138 bpfdetach(ifp);
139 if_detach(ifp);
140 if_free(ifp);
141}
142
143static int
144lo_clone_create(struct if_clone *ifc, int unit, caddr_t params)

--- 16 unchanged lines hidden (view full) ---

161 if_attach(ifp);
162 bpfattach(ifp, DLT_NULL, sizeof(u_int32_t));
163 if (V_loif == NULL)
164 V_loif = ifp;
165
166 return (0);
167}
168
142
143 bpfdetach(ifp);
144 if_detach(ifp);
145 if_free(ifp);
146}
147
148static int
149lo_clone_create(struct if_clone *ifc, int unit, caddr_t params)

--- 16 unchanged lines hidden (view full) ---

166 if_attach(ifp);
167 bpfattach(ifp, DLT_NULL, sizeof(u_int32_t));
168 if (V_loif == NULL)
169 V_loif = ifp;
170
171 return (0);
172}
173
169static int vnet_loif_iattach(const void *unused __unused)
174static int
175vnet_loif_iattach(const void *unused __unused)
170{
171 INIT_VNET_NET(curvnet);
172
173 V_loif = NULL;
174
175#ifdef VIMAGE
176 V_lo_cloner = malloc(sizeof(*V_lo_cloner), M_LO_CLONER,
177 M_WAITOK | M_ZERO);
176{
177 INIT_VNET_NET(curvnet);
178
179 V_loif = NULL;
180
181#ifdef VIMAGE
182 V_lo_cloner = malloc(sizeof(*V_lo_cloner), M_LO_CLONER,
183 M_WAITOK | M_ZERO);
184 V_lo_cloner_data = malloc(sizeof(*V_lo_cloner_data), M_LO_CLONER,
185 M_WAITOK | M_ZERO);
178 bcopy(&lo_cloner, V_lo_cloner, sizeof(*V_lo_cloner));
186 bcopy(&lo_cloner, V_lo_cloner, sizeof(*V_lo_cloner));
187 bcopy(lo_cloner.ifc_data, V_lo_cloner_data, sizeof(*V_lo_cloner_data));
188 V_lo_cloner->ifc_data = V_lo_cloner_data;
179 if_clone_attach(V_lo_cloner);
180#else
181 if_clone_attach(&lo_cloner);
182#endif
183 return (0);
184}
185
189 if_clone_attach(V_lo_cloner);
190#else
191 if_clone_attach(&lo_cloner);
192#endif
193 return (0);
194}
195
196#ifdef VIMAGE
186static int
197static int
198vnet_loif_idetach(const void *unused __unused)
199{
200 INIT_VNET_NET(curvnet);
201
202 if_clone_detach(V_lo_cloner);
203 free(V_lo_cloner, M_LO_CLONER);
204 free(V_lo_cloner_data, M_LO_CLONER);
205 V_loif = NULL;
206
207 return (0);
208}
209#endif
210
211static int
187loop_modevent(module_t mod, int type, void *data)
188{
189
190 switch (type) {
191 case MOD_LOAD:
192#ifndef VIMAGE_GLOBALS
193 vnet_mod_register(&vnet_loif_modinfo);
194#else

--- 263 unchanged lines hidden ---
212loop_modevent(module_t mod, int type, void *data)
213{
214
215 switch (type) {
216 case MOD_LOAD:
217#ifndef VIMAGE_GLOBALS
218 vnet_mod_register(&vnet_loif_modinfo);
219#else

--- 263 unchanged lines hidden ---