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

Function ng_ether_ifnet_arrival_event

freebsd/netgraph/ng_ether.c:410–431  ·  view source on GitHub ↗

* 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. */

Source from the content-addressed store, hash-verified

408 * hook ng_ether_attach_p.
409 */
410static void
411ng_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

Callers

nothing calls this directly

Calls 3

ng_ether_sanitize_ifnameFunction · 0.85
ng_name_nodeFunction · 0.70
logFunction · 0.50

Tested by

no test coverage detected