From 4d2ff05c2312656571e4796caa0e464221e25f35 Mon Sep 17 00:00:00 2001 From: Roy Marples Date: Fri, 6 Sep 2019 17:36:13 +0100 Subject: [PATCH] route: ensure RTM_IFINFO is sent first when bring interface down/up Taking an interface down can generate a lot of route messages. This can overflow the route socket, so ensure that the most important message is sent first - that of the interface state. While here, these functions can be made static. --- sys/net/if.c | 12 +++++++----- sys/net/if_var.h | 2 -- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/sys/net/if.c b/sys/net/if.c index d82d23f620..b3d8cfb302 100644 --- a/sys/net/if.c +++ b/sys/net/if.c @@ -1667,6 +1667,8 @@ if_unroute_dispatch(netmsg_t nmsg) ifp->if_flags &= ~flag; getmicrotime(&ifp->if_lastchange); + rt_ifmsg(ifp); + /* * The ifaddr processing in the following loop will block, * however, this function is called in netisr0, in which @@ -1683,13 +1685,12 @@ if_unroute_dispatch(netmsg_t nmsg) if (fam == PF_UNSPEC || (fam == ifa->ifa_addr->sa_family)) kpfctlinput(PRC_IFDOWN, ifa->ifa_addr); } - ifq_purge_all(&ifp->if_snd); - rt_ifmsg(ifp); + ifq_purge_all(&ifp->if_snd); netisr_replymsg(&nmsg->base, 0); } -void +static void if_unroute(struct ifnet *ifp, int flag, int fam) { struct netmsg_ifroute msg; @@ -1718,6 +1719,8 @@ if_route_dispatch(netmsg_t nmsg) ifq_purge_all(&ifp->if_snd); ifp->if_flags |= flag; getmicrotime(&ifp->if_lastchange); + rt_ifmsg(ifp); + /* * The ifaddr processing in the following loop will block, * however, this function is called in netisr0, in which @@ -1734,7 +1737,6 @@ if_route_dispatch(netmsg_t nmsg) if (fam == PF_UNSPEC || (fam == ifa->ifa_addr->sa_family)) kpfctlinput(PRC_IFUP, ifa->ifa_addr); } - rt_ifmsg(ifp); #ifdef INET6 in6_if_up(ifp); #endif @@ -1742,7 +1744,7 @@ if_route_dispatch(netmsg_t nmsg) netisr_replymsg(&nmsg->base, 0); } -void +static void if_route(struct ifnet *ifp, int flag, int fam) { struct netmsg_ifroute msg; diff --git a/sys/net/if_var.h b/sys/net/if_var.h index 1f26883568..3f6fe12173 100644 --- a/sys/net/if_var.h +++ b/sys/net/if_var.h @@ -943,10 +943,8 @@ int if_getanyethermac(uint16_t *, int); int if_printf(struct ifnet *, const char *, ...) __printflike(2, 3); struct ifnet *if_alloc(uint8_t); void if_free(struct ifnet *); -void if_route(struct ifnet *, int flag, int fam); int if_setlladdr(struct ifnet *, const u_char *, int); struct ifnet *if_bylla(const void *, unsigned char); -void if_unroute(struct ifnet *, int flag, int fam); void if_up(struct ifnet *); /*void ifinit(void);*/ /* declared in systm.h for main() */ int ifioctl(struct socket *, u_long, caddr_t, struct ucred *); -- 2.41.0