Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 24 Jul 2017 03:32:10 +0000 (UTC)
From:      Sepherosa Ziehau <sephe@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r321406 - head/sys/net
Message-ID:  <201707240332.v6O3WAbh064357@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
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);
 }
 
 /*



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201707240332.v6O3WAbh064357>