From d3ecf7ceb7b44cd1ba8e11d21f6d33f9b96c31ca Mon Sep 17 00:00:00 2001 From: krw Date: Thu, 18 Dec 2014 15:29:30 +0000 Subject: [PATCH] Change the link state change routing message generation to a taskq. One less workq to worry about. Tweaks from many. ok mpi@ mikeb@ --- sys/net/if.c | 29 +++++++++++++++++------------ sys/net/if_var.h | 4 +++- 2 files changed, 20 insertions(+), 13 deletions(-) diff --git a/sys/net/if.c b/sys/net/if.c index 5008933b403..50e87b33d9d 100644 --- a/sys/net/if.c +++ b/sys/net/if.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if.c,v 1.307 2014/12/17 09:45:59 mpi Exp $ */ +/* $OpenBSD: if.c,v 1.308 2014/12/18 15:29:30 krw Exp $ */ /* $NetBSD: if.c,v 1.35 1996/05/07 05:26:04 thorpej Exp $ */ /* @@ -79,7 +79,7 @@ #include #include #include -#include +#include #include #include @@ -270,6 +270,9 @@ if_attachsetup(struct ifnet *ifp) timeout_set(ifp->if_slowtimo, if_slowtimo, ifp); if_slowtimo(ifp); + task_set(ifp->if_linkstatetask, if_link_state_change_task, + ifp, NULL); + /* Announce the interface. */ rt_ifannouncemsg(ifp, IFAN_ARRIVAL); } @@ -410,6 +413,8 @@ if_attach_common(struct ifnet *ifp) ifp->if_slowtimo = malloc(sizeof(*ifp->if_slowtimo), M_TEMP, M_WAITOK|M_ZERO); + ifp->if_linkstatetask = malloc(sizeof(*ifp->if_linkstatetask), + M_TEMP, M_WAITOK|M_ZERO); } void @@ -477,6 +482,9 @@ if_detach(struct ifnet *ifp) /* Remove the watchdog timeout */ timeout_del(ifp->if_slowtimo); + /* Remove the link state task */ + task_del(systq, ifp->if_linkstatetask); + #if NBRIDGE > 0 /* Remove the interface from any bridge it is part of. */ if (ifp->if_bridgeport) @@ -560,6 +568,7 @@ do { \ free(ifp->if_detachhooks, M_TEMP, 0); free(ifp->if_slowtimo, M_TEMP, sizeof(*ifp->if_slowtimo)); + free(ifp->if_linkstatetask, M_TEMP, sizeof(*ifp->if_linkstatetask)); for (dp = domains; dp; dp = dp->dom_next) { if (dp->dom_ifdetach && ifp->if_afdata[dp->dom_family]) @@ -1117,9 +1126,8 @@ if_up(struct ifnet *ifp) void if_link_state_change(struct ifnet *ifp) { - /* try to put the routing table update task on syswq */ - workq_add_task(NULL, 0, if_link_state_change_task, - (void *)((unsigned long)ifp->if_index), NULL); + /* put the routing table update task on systq */ + task_add(systq, ifp->if_linkstatetask); } /* @@ -1128,18 +1136,15 @@ if_link_state_change(struct ifnet *ifp) void if_link_state_change_task(void *arg, void *unused) { - unsigned int index = (unsigned long)arg; - struct ifnet *ifp; + struct ifnet *ifp = arg; int s; s = splsoftnet(); - if ((ifp = if_get(index)) != NULL) { - rt_ifmsg(ifp); + rt_ifmsg(ifp); #ifndef SMALL_KERNEL - rt_if_track(ifp); + rt_if_track(ifp); #endif - dohooks(ifp->if_linkstatehooks, 0); - } + dohooks(ifp->if_linkstatehooks, 0); splx(s); } diff --git a/sys/net/if_var.h b/sys/net/if_var.h index faeb3596f13..264ab3be26c 100644 --- a/sys/net/if_var.h +++ b/sys/net/if_var.h @@ -1,4 +1,4 @@ -/* $OpenBSD: if_var.h,v 1.15 2014/12/08 10:46:14 mpi Exp $ */ +/* $OpenBSD: if_var.h,v 1.16 2014/12/18 15:29:30 krw Exp $ */ /* $NetBSD: if.h,v 1.23 1996/05/07 02:40:27 thorpej Exp $ */ /* @@ -78,6 +78,7 @@ struct arpcom; struct rt_addrinfo; struct ifnet; struct hfsc_if; +struct task; /* * Structure describing a `cloning' interface. @@ -149,6 +150,7 @@ struct ifnet { /* and the entries */ u_short if_rtlabelid; /* next route label */ u_int8_t if_priority; struct timeout *if_slowtimo; /* watchdog timeout */ + struct task *if_linkstatetask; /* task to do route updates */ /* procedure handles */ /* output routine (enqueue) */ -- 2.20.1