* Interface arrival notification handler. * The notification is produced in two cases: * o a new interface arrives * o an existing interface got renamed * Currently the first case is handled by ng_ether_attach via special * hook ng_ether_attach_p. */
| 408 | * hook ng_ether_attach_p. |
| 409 | */ |
| 410 | static void |
| 411 | ng_ether_ifnet_arrival_event(void *arg __unused, struct ifnet *ifp) |
| 412 | { |
| 413 | char name[IFNAMSIZ]; |
| 414 | node_p node; |
| 415 | |
| 416 | /* Only ethernet interfaces are of interest. */ |
| 417 | if (ifp->if_type != IFT_ETHER && ifp->if_type != IFT_L2VLAN) |
| 418 | return; |
| 419 | |
| 420 | /* |
| 421 | * Just return if it's a new interface without an ng_ether companion. |
| 422 | */ |
| 423 | node = IFP2NG(ifp); |
| 424 | if (node == NULL) |
| 425 | return; |
| 426 | |
| 427 | /* Try to give the node the same name as the new interface name */ |
| 428 | ng_ether_sanitize_ifname(ifp->if_xname, name); |
| 429 | if (ng_name_node(node, name) != 0) |
| 430 | log(LOG_WARNING, "%s: can't re-name node %s\n", __func__, name); |
| 431 | } |
| 432 | |
| 433 | /****************************************************************** |
| 434 | NETGRAPH NODE METHODS |
nothing calls this directly
no test coverage detected