| 245 | } |
| 246 | |
| 247 | if_pseudo_t |
| 248 | iflib_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 | |
| 293 | void |
| 294 | iflib_clone_deregister(if_pseudo_t ip) |
nothing calls this directly
no test coverage detected