Author: sephe
Date: Mon Jul 24 03:32:10 2017
New Revision: 321406
URL: https://svnweb.freebsd.org/changeset/base/321406

Log:
  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.
  
  MFC after:    3 days
  Sponsored by: Microsoft
  Differential Revision:        https://reviews.freebsd.org/D11617

Modified:
  head/sys/net/ethernet.h
  head/sys/net/if_ethersubr.c

Modified: head/sys/net/ethernet.h
==============================================================================
--- head/sys/net/ethernet.h     Mon Jul 24 02:13:46 2017        (r321405)
+++ head/sys/net/ethernet.h     Mon Jul 24 03:32:10 2017        (r321406)
@@ -406,6 +406,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: head/sys/net/if_ethersubr.c
==============================================================================
--- head/sys/net/if_ethersubr.c Mon Jul 24 02:13:46 2017        (r321405)
+++ head/sys/net/if_ethersubr.c Mon Jul 24 03:32:10 2017        (r321406)
@@ -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>
@@ -931,6 +933,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);
 }
 
 /*
_______________________________________________
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"

Reply via email to