From owner-svn-src-stable@freebsd.org Mon Jul 31 02:33:51 2017 Return-Path: Delivered-To: svn-src-stable@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 65530DC786C; Mon, 31 Jul 2017 02:33:51 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 3425263BD4; Mon, 31 Jul 2017 02:33:51 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v6V2Xo5P080718; Mon, 31 Jul 2017 02:33:50 GMT (envelope-from sephe@FreeBSD.org) Received: (from sephe@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v6V2Xoqd080716; Mon, 31 Jul 2017 02:33:50 GMT (envelope-from sephe@FreeBSD.org) Message-Id: <201707310233.v6V2Xoqd080716@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sephe set sender to sephe@FreeBSD.org using -f From: Sepherosa Ziehau Date: Mon, 31 Jul 2017 02:33:50 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r321747 - stable/11/sys/net X-SVN-Group: stable-11 X-SVN-Commit-Author: sephe X-SVN-Commit-Paths: stable/11/sys/net X-SVN-Commit-Revision: 321747 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 31 Jul 2017 02:33:51 -0000 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 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 #include +#include +#include #include #include #include @@ -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); } /*