summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorsephe <sephe@FreeBSD.org>2017-07-31 03:49:08 +0000
committersephe <sephe@FreeBSD.org>2017-07-31 03:49:08 +0000
commit5e267e2325b21e08308ddcb74fb913c34155112f (patch)
tree8e674f29a5b36a8e0628f3a4fe0b1782db769af4
parent8f3740e05ff1c43850591e44dbd7b848d79e4926 (diff)
downloadFreeBSD-src-5e267e2325b21e08308ddcb74fb913c34155112f.zip
FreeBSD-src-5e267e2325b21e08308ddcb74fb913c34155112f.tar.gz
MFC 321406
ethernet: Add ethernet interface attached event and devctl notification. ifnet_arrival_event may not be adequate under certain situation; e.g. when the LLADDR is needed. So the ethernet ifattach event is announced after all necessary bits are setup. Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D11617
-rw-r--r--sys/net/ethernet.h6
-rw-r--r--sys/net/if_ethersubr.c7
2 files changed, 13 insertions, 0 deletions
diff --git a/sys/net/ethernet.h b/sys/net/ethernet.h
index ce22139..1c17cdf 100644
--- a/sys/net/ethernet.h
+++ b/sys/net/ethernet.h
@@ -384,6 +384,12 @@ void ether_vlan_mtap(struct bpf_if *, struct mbuf *,
void *, u_int);
struct mbuf *ether_vlanencap(struct mbuf *, uint16_t);
+#ifdef SYS_EVENTHANDLER_H
+/* new ethernet interface attached event */
+typedef void (*ether_ifattach_event_handler_t)(void *, struct ifnet *);
+EVENTHANDLER_DECLARE(ether_ifattach_event, ether_ifattach_event_handler_t);
+#endif
+
#else /* _KERNEL */
#include <sys/cdefs.h>
diff --git a/sys/net/if_ethersubr.c b/sys/net/if_ethersubr.c
index 9e843f1..558c8bb 100644
--- a/sys/net/if_ethersubr.c
+++ b/sys/net/if_ethersubr.c
@@ -39,6 +39,8 @@
#include <sys/param.h>
#include <sys/systm.h>
+#include <sys/bus.h>
+#include <sys/eventhandler.h>
#include <sys/kernel.h>
#include <sys/lock.h>
#include <sys/malloc.h>
@@ -933,6 +935,11 @@ ether_ifattach(struct ifnet *ifp, const u_int8_t *lla)
if_printf(ifp, "Ethernet address: %6D\n", lla, ":");
uuid_ether_add(LLADDR(sdl));
+
+ /* Add necessary bits are setup; announce it now. */
+ EVENTHANDLER_INVOKE(ether_ifattach_event, ifp);
+ if (IS_DEFAULT_VNET(curvnet))
+ devctl_notify("ETHERNET", ifp->if_xname, "IFATTACH", NULL);
}
/*
OpenPOWER on IntegriCloud