diff options
author | jhb <jhb@FreeBSD.org> | 2009-01-23 20:53:01 +0000 |
---|---|---|
committer | jhb <jhb@FreeBSD.org> | 2009-01-23 20:53:01 +0000 |
commit | a622abe85f60142e95ce8e08a8131e36119e5bfc (patch) | |
tree | 54596b593d9ccd62cda9c7583235f08bb742fef4 | |
parent | 5341e1c54868a02fcc83352d319e64495874e3f3 (diff) | |
download | FreeBSD-src-a622abe85f60142e95ce8e08a8131e36119e5bfc.zip FreeBSD-src-a622abe85f60142e95ce8e08a8131e36119e5bfc.tar.gz |
Only start the if_slowtimo timer (which drives the if_watchdog methods of
network interfaces) if we have at least one interface with an if_watchdog
routine.
MFC after: 2 weeks
-rw-r--r-- | sys/net/if.c | 27 |
1 files changed, 25 insertions, 2 deletions
diff --git a/sys/net/if.c b/sys/net/if.c index 070202c..2fb8e23 100644 --- a/sys/net/if.c +++ b/sys/net/if.c @@ -97,6 +97,8 @@ struct vnet_net vnet_net_0; #endif #endif +static int slowtimo_started; + SYSCTL_NODE(_net, PF_LINK, link, CTLFLAG_RW, 0, "Link layers"); SYSCTL_NODE(_net_link, 0, generic, CTLFLAG_RW, 0, "Generic link-management"); @@ -124,6 +126,7 @@ static int ifconf(u_long, caddr_t); static void if_freemulti(struct ifmultiaddr *); static void if_grow(void); static void if_init(void *); +static void if_check(void *); static void if_qflush(struct ifnet *); static void if_route(struct ifnet *, int flag, int fam); static int if_setflag(struct ifnet *, int, int, int *, int); @@ -185,7 +188,7 @@ VNET_MOD_DECLARE(NET, net, vnet_net_iattach, vnet_net_idetach, * System initialization */ SYSINIT(interfaces, SI_SUB_INIT_IF, SI_ORDER_FIRST, if_init, NULL); -SYSINIT(interface_check, SI_SUB_PROTO_IF, SI_ORDER_FIRST, if_slowtimo, NULL); +SYSINIT(interface_check, SI_SUB_PROTO_IF, SI_ORDER_FIRST, if_check, NULL); MALLOC_DEFINE(M_IFNET, "ifnet", "interface internals"); MALLOC_DEFINE(M_IFADDR, "ifaddr", "interface address"); @@ -425,6 +428,18 @@ if_grow(void) V_ifindex_table = e; } +static void +if_check(void *dummy __unused) +{ + + /* + * If at least one interface added during boot uses + * if_watchdog then start the timer. + */ + if (slowtimo_started) + if_slowtimo(0); +} + /* * Allocate a struct ifnet and an index for an interface. A layer 2 * common structure will also be allocated if an allocation routine is @@ -647,9 +662,17 @@ if_attach(struct ifnet *ifp) /* Announce the interface. */ rt_ifannouncemsg(ifp, IFAN_ARRIVAL); - if (ifp->if_watchdog != NULL) + if (ifp->if_watchdog != NULL) { if_printf(ifp, "WARNING: using obsoleted if_watchdog interface\n"); + + /* + * Note that we need if_slowtimo(). If this happens after + * boot, then call if_slowtimo() directly. + */ + if (atomic_cmpset_int(&slowtimo_started, 0, 1) && !cold) + if_slowtimo(0); + } if (ifp->if_flags & IFF_NEEDSGIANT) if_printf(ifp, "WARNING: using obsoleted IFF_NEEDSGIANT flag\n"); |