svn commit: r321747 - stable/11/sys/net
Sepherosa Ziehau
sephe at FreeBSD.org
Mon Jul 31 02:33:51 UTC 2017
Author: sephe
Date: Mon Jul 31 02:33:49 2017
New Revision: 321747
URL: https://svnweb.freebsd.org/changeset/base/321747
Log:
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
Modified:
stable/11/sys/net/ethernet.h
stable/11/sys/net/if_ethersubr.c
Directory Properties:
stable/11/ (props changed)
Modified: stable/11/sys/net/ethernet.h
==============================================================================
--- stable/11/sys/net/ethernet.h Mon Jul 31 01:36:51 2017 (r321746)
+++ stable/11/sys/net/ethernet.h Mon Jul 31 02:33:49 2017 (r321747)
@@ -403,6 +403,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>
Modified: stable/11/sys/net/if_ethersubr.c
==============================================================================
--- stable/11/sys/net/if_ethersubr.c Mon Jul 31 01:36:51 2017 (r321746)
+++ stable/11/sys/net/if_ethersubr.c Mon Jul 31 02:33:49 2017 (r321747)
@@ -38,6 +38,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);
}
/*
More information about the svn-src-stable
mailing list