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
This commit is contained in:
Rozhuk Ivan 2021-06-23 10:15:11 -06:00 committed by Warner Losh
parent 4420bb6a86
commit 4fb3e0bb94
2 changed files with 8 additions and 1 deletions

View File

@ -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

View File

@ -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