MCPcopy Create free account
hub / github.com/F-Stack/f-stack / iflib_clone_create

Function iflib_clone_create

freebsd/net/iflib_clone.c:169–219  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

167}
168
169static int
170iflib_clone_create(struct if_clone *ifc, int unit, caddr_t params)
171{
172 const char *name = ifc_name(ifc);
173 struct iflib_cloneattach_ctx clctx;
174 if_ctx_t ctx;
175 if_pseudo_t ip;
176 device_t dev;
177 int rc;
178
179 clctx.cc_ifc = ifc;
180 clctx.cc_len = 0;
181 clctx.cc_params = params;
182 clctx.cc_name = name;
183
184 if (__predict_false(iflib_pseudodev == NULL)) {
185 /* SYSINIT initialization would panic !?! */
186 mtx_lock(&Giant);
187 iflib_pseudodev = device_add_child(root_bus, "ifpseudo", 0);
188 mtx_unlock(&Giant);
189 MPASS(iflib_pseudodev != NULL);
190 }
191 ip = iflib_ip_lookup(name);
192 if (ip == NULL) {
193 printf("no ip found for %s\n", name);
194 return (ENOENT);
195 }
196 if ((dev = devclass_get_device(ip->ip_dc, unit)) != NULL) {
197 printf("unit %d allocated\n", unit);
198 bus_generic_print_child(iflib_pseudodev, dev);
199 return (EBUSY);
200 }
201 PSEUDO_LOCK();
202 dev = device_add_child(iflib_pseudodev, name, unit);
203 device_set_driver(dev, &iflib_pseudodriver);
204 PSEUDO_UNLOCK();
205 device_quiet(dev);
206 rc = device_attach(dev);
207 MPASS(rc == 0);
208 MPASS(dev != NULL);
209 MPASS(devclass_get_device(ip->ip_dc, unit) == dev);
210 rc = iflib_pseudo_register(dev, ip->ip_sctx, &ctx, &clctx);
211 if (rc) {
212 mtx_lock(&Giant);
213 device_delete_child(iflib_pseudodev, dev);
214 mtx_unlock(&Giant);
215 } else
216 device_set_softc(dev, ctx);
217
218 return (rc);
219}
220
221static void
222iflib_clone_destroy(if_t ifp)

Callers

nothing calls this directly

Calls 14

ifc_nameFunction · 0.85
device_add_childFunction · 0.85
iflib_ip_lookupFunction · 0.85
devclass_get_deviceFunction · 0.85
bus_generic_print_childFunction · 0.85
device_set_driverFunction · 0.85
device_quietFunction · 0.85
iflib_pseudo_registerFunction · 0.85
device_delete_childFunction · 0.85
device_set_softcFunction · 0.85
mtx_lockFunction · 0.50
mtx_unlockFunction · 0.50

Tested by

no test coverage detected