Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 31 Jul 2017 03:49:08 +0000 (UTC)
From:      Sepherosa Ziehau <sephe@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org
Subject:   svn commit: r321752 - stable/10/sys/net
Message-ID:  <201707310349.v6V3n82L010306@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: sephe
Date: Mon Jul 31 03:49:08 2017
New Revision: 321752
URL: https://svnweb.freebsd.org/changeset/base/321752

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/10/sys/net/ethernet.h
  stable/10/sys/net/if_ethersubr.c
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/sys/net/ethernet.h
==============================================================================
--- stable/10/sys/net/ethernet.h	Mon Jul 31 03:19:16 2017	(r321751)
+++ stable/10/sys/net/ethernet.h	Mon Jul 31 03:49:08 2017	(r321752)
@@ -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>

Modified: stable/10/sys/net/if_ethersubr.c
==============================================================================
--- stable/10/sys/net/if_ethersubr.c	Mon Jul 31 03:19:16 2017	(r321751)
+++ stable/10/sys/net/if_ethersubr.c	Mon Jul 31 03:49:08 2017	(r321752)
@@ -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);
 }
 
 /*



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