From owner-svn-src-head@freebsd.org Mon Jul 24 03:32:12 2017 Return-Path: Delivered-To: svn-src-head@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 0A39EDB582F; Mon, 24 Jul 2017 03:32:12 +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 BF9F77E125; Mon, 24 Jul 2017 03:32:11 +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 v6O3WAxo064359; Mon, 24 Jul 2017 03:32:10 GMT (envelope-from sephe@FreeBSD.org) Received: (from sephe@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v6O3WAbh064357; Mon, 24 Jul 2017 03:32:10 GMT (envelope-from sephe@FreeBSD.org) Message-Id: <201707240332.v6O3WAbh064357@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sephe set sender to sephe@FreeBSD.org using -f From: Sepherosa Ziehau Date: Mon, 24 Jul 2017 03:32:10 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r321406 - head/sys/net X-SVN-Group: head X-SVN-Commit-Author: sephe X-SVN-Commit-Paths: head/sys/net X-SVN-Commit-Revision: 321406 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 24 Jul 2017 03:32:12 -0000 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 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 #include +#include +#include #include #include #include @@ -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); } /*