git: 0693c3f7cb3d - main - ifnet: Integrate if_unroute() into if_down()

From: Zhenlei Huang <zlei_at_FreeBSD.org>
Date: Tue, 20 May 2025 15:47:00 UTC
The branch main has been updated by zlei:

URL: https://cgit.FreeBSD.org/src/commit/?id=0693c3f7cb3d9e5389863a0c131ddef799c77091

commit 0693c3f7cb3d9e5389863a0c131ddef799c77091
Author:     Zhenlei Huang <zlei@FreeBSD.org>
AuthorDate: 2025-05-20 15:45:20 +0000
Commit:     Zhenlei Huang <zlei@FreeBSD.org>
CommitDate: 2025-05-20 15:45:20 +0000

    ifnet: Integrate if_unroute() into if_down()
    
    if_unroute() is static since 2004 and is not used anywhere except for
    if_down().
    
    This also makes it easier to grep by the pattern `if_flags &= ~IFF_UP`.
    
    No functional change intended.
    
    Reviewed by:    glebius
    MFC after:      1 week
    Differential Revision:  https://reviews.freebsd.org/D49356
---
 sys/net/if.c | 29 ++++++++---------------------
 1 file changed, 8 insertions(+), 21 deletions(-)

diff --git a/sys/net/if.c b/sys/net/if.c
index 974ff3af4f61..853fc3c78fce 100644
--- a/sys/net/if.c
+++ b/sys/net/if.c
@@ -278,7 +278,6 @@ static void	if_input_default(struct ifnet *, struct mbuf *);
 static int	if_requestencap_default(struct ifnet *, struct if_encap_req *);
 static int	if_setflag(struct ifnet *, int, int, int *, int);
 static int	if_transmit_default(struct ifnet *ifp, struct mbuf *m);
-static void	if_unroute(struct ifnet *, int flag, int fam);
 static int	if_delmulti_locked(struct ifnet *, struct ifmultiaddr *, int);
 static void	do_link_state_change(void *, int);
 static int	if_getgroup(struct ifgroupreq *, struct ifnet *);
@@ -2097,25 +2096,6 @@ link_init_sdl(struct ifnet *ifp, struct sockaddr *paddr, u_char iftype)
 	return (sdl);
 }
 
-/*
- * Mark an interface down and notify protocols of
- * the transition.
- */
-static void
-if_unroute(struct ifnet *ifp, int flag, int fam)
-{
-
-	KASSERT(flag == IFF_UP, ("if_unroute: flag != IFF_UP"));
-
-	ifp->if_flags &= ~flag;
-	getmicrotime(&ifp->if_lastchange);
-	ifp->if_qflush(ifp);
-
-	if (ifp->if_carp)
-		(*carp_linkstate_p)(ifp);
-	rt_ifmsg(ifp, IFF_UP);
-}
-
 void	(*vlan_link_state_p)(struct ifnet *);	/* XXX: private from if_vlan */
 void	(*vlan_trunk_cap_p)(struct ifnet *);		/* XXX: private from if_vlan */
 struct ifnet *(*vlan_trunkdev_p)(struct ifnet *);
@@ -2190,7 +2170,14 @@ if_down(struct ifnet *ifp)
 {
 
 	EVENTHANDLER_INVOKE(ifnet_event, ifp, IFNET_EVENT_DOWN);
-	if_unroute(ifp, IFF_UP, AF_UNSPEC);
+
+	ifp->if_flags &= ~IFF_UP;
+	getmicrotime(&ifp->if_lastchange);
+	ifp->if_qflush(ifp);
+
+	if (ifp->if_carp)
+		(*carp_linkstate_p)(ifp);
+	rt_ifmsg(ifp, IFF_UP);
 }
 
 /*