From owner-dev-commits-src-all@freebsd.org Wed Jun 23 16:31:57 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id B0096653255; Wed, 23 Jun 2021 16:31:57 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4G98194Rsfz3Gqn; Wed, 23 Jun 2021 16:31:57 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 7FF6D27833; Wed, 23 Jun 2021 16:31:57 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 15NGVvpd071688; Wed, 23 Jun 2021 16:31:57 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 15NGVv4G071671; Wed, 23 Jun 2021 16:31:57 GMT (envelope-from git) Date: Wed, 23 Jun 2021 16:31:57 GMT Message-Id: <202106231631.15NGVv4G071671@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Warner Losh Subject: git: 4fb3e0bb94ab - main - devctl: add RENAME devctl event for IFNET MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: imp X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 4fb3e0bb94abdd2d44b23937670a83876d11b97f Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 23 Jun 2021 16:31:57 -0000 The branch main has been updated by imp: URL: https://cgit.FreeBSD.org/src/commit/?id=4fb3e0bb94abdd2d44b23937670a83876d11b97f commit 4fb3e0bb94abdd2d44b23937670a83876d11b97f Author: Rozhuk Ivan AuthorDate: 2021-06-23 16:15:11 +0000 Commit: Warner Losh CommitDate: 2021-06-23 16:20:58 +0000 devctl: add RENAME devctl event for IFNET Add devd event on network iface rename. Reviewed by: imp@,asomers@ Sponsored by: Netflix Differential Revision: https://reviews.freebsd.org/D30839 --- sbin/devd/devd.conf.5 | 4 +++- sys/net/if.c | 5 +++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/sbin/devd/devd.conf.5 b/sbin/devd/devd.conf.5 index 1a1071584f70..56e2df684f32 100644 --- a/sbin/devd/devd.conf.5 +++ b/sbin/devd/devd.conf.5 @@ -40,7 +40,7 @@ .\" ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS .\" SOFTWARE. .\" -.Dd October 12, 2020 +.Dd June 23, 2021 .Dt DEVD.CONF 5 .Os .Sh NAME @@ -467,6 +467,8 @@ Carrier status changed to DOWN. The network interface is attached to the system. .It Li IFNET Ta Em inet Ta Li DETACH Ta The network interface is detached from the system. +.It Li IFNET Ta Em inet Ta Li RENAME Ta +The network interface is renamed. .El .Pp .Bl -column "System" "Subsystem" "1234567" -compact diff --git a/sys/net/if.c b/sys/net/if.c index f615d82636be..cfa795904bc9 100644 --- a/sys/net/if.c +++ b/sys/net/if.c @@ -2468,6 +2468,7 @@ ifhwioctl(u_long cmd, struct ifnet *ifp, caddr_t data, struct thread *td) size_t descrlen; char *descrbuf, *odescrbuf; char new_name[IFNAMSIZ]; + char old_name[IFNAMSIZ], strbuf[IFNAMSIZ + 8]; struct ifaddr *ifa; struct sockaddr_dl *sdl; @@ -2673,6 +2674,7 @@ ifhwioctl(u_long cmd, struct ifnet *ifp, caddr_t data, struct thread *td) if_printf(ifp, "changing name to '%s'\n", new_name); IF_ADDR_WLOCK(ifp); + strlcpy(old_name, ifp->if_xname, sizeof(old_name)); strlcpy(ifp->if_xname, new_name, sizeof(ifp->if_xname)); ifa = ifp->if_addr; sdl = (struct sockaddr_dl *)ifa->ifa_addr; @@ -2700,6 +2702,9 @@ ifhwioctl(u_long cmd, struct ifnet *ifp, caddr_t data, struct thread *td) rt_ifannouncemsg(ifp, IFAN_ARRIVAL); ifp->if_flags &= ~IFF_RENAMING; + + snprintf(strbuf, sizeof(strbuf), "name=%s", new_name); + devctl_notify("IFNET", old_name, "RENAME", strbuf); break; #ifdef VIMAGE