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

Function iflib_clone_register

freebsd/net/iflib_clone.c:247–291  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

245}
246
247if_pseudo_t
248iflib_clone_register(if_shared_ctx_t sctx)
249{
250 if_pseudo_t ip;
251
252 if (sctx->isc_name == NULL) {
253 printf("iflib_clone_register failed - shared_ctx needs to have a device name\n");
254 return (NULL);
255 }
256 if (iflib_ip_lookup(sctx->isc_name) != NULL) {
257 printf("iflib_clone_register failed - shared_ctx %s alread registered\n",
258 sctx->isc_name);
259 return (NULL);
260 }
261 ip = malloc(sizeof(*ip), M_IFLIB, M_WAITOK|M_ZERO);
262 ip->ip_sctx = sctx;
263 ip->ip_dc = devclass_create(sctx->isc_name);
264 if (ip->ip_dc == NULL)
265 goto fail_clone;
266 /* XXX --- we can handle clone_advanced later */
267 ip->ip_ifc = if_clone_simple(sctx->isc_name, iflib_clone_create, iflib_clone_destroy, 0);
268 if (ip->ip_ifc == NULL) {
269 printf("clone_simple failed -- cloned %s devices will not be available\n", sctx->isc_name);
270 goto fail_clone;
271 }
272 ip->ip_lladdr_tag = EVENTHANDLER_REGISTER(iflladdr_event,
273 iflib_iflladdr, NULL, EVENTHANDLER_PRI_ANY);
274 if (ip->ip_lladdr_tag == NULL)
275 goto fail_addr;
276 ip->ip_detach_tag = EVENTHANDLER_REGISTER(ifnet_departure_event,
277 iflib_ifdetach, NULL, EVENTHANDLER_PRI_ANY);
278
279 if (ip->ip_detach_tag == NULL)
280 goto fail_depart;
281
282 iflib_ip_insert(ip);
283 return (ip);
284 fail_depart:
285 EVENTHANDLER_DEREGISTER(iflladdr_event, ip->ip_lladdr_tag);
286 fail_addr:
287 if_clone_detach(ip->ip_ifc);
288 fail_clone:
289 free(ip, M_IFLIB);
290 return (NULL);
291}
292
293void
294iflib_clone_deregister(if_pseudo_t ip)

Callers

nothing calls this directly

Calls 8

iflib_ip_lookupFunction · 0.85
mallocFunction · 0.85
devclass_createFunction · 0.85
if_clone_simpleFunction · 0.85
iflib_ip_insertFunction · 0.85
if_clone_detachFunction · 0.85
printfFunction · 0.50
freeFunction · 0.50

Tested by

no test coverage detected