From owner-svn-src-projects@freebsd.org Fri Dec 4 20:12:51 2015 Return-Path: Delivered-To: svn-src-projects@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 507DBA41AD1 for ; Fri, 4 Dec 2015 20:12:51 +0000 (UTC) (envelope-from hselasky@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 260B61D39; Fri, 4 Dec 2015 20:12:51 +0000 (UTC) (envelope-from hselasky@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id tB4KCoKo055304; Fri, 4 Dec 2015 20:12:50 GMT (envelope-from hselasky@FreeBSD.org) Received: (from hselasky@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id tB4KCnlH055294; Fri, 4 Dec 2015 20:12:49 GMT (envelope-from hselasky@FreeBSD.org) Message-Id: <201512042012.tB4KCnlH055294@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: hselasky set sender to hselasky@FreeBSD.org using -f From: Hans Petter Selasky Date: Fri, 4 Dec 2015 20:12:49 +0000 (UTC) To: src-committers@freebsd.org, svn-src-projects@freebsd.org Subject: svn commit: r291822 - in projects/hps_head/sys: dev/oce kern net netgraph netinet netinet6 netpfil/pf X-SVN-Group: projects MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-projects@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: "SVN commit messages for the src " projects" tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 04 Dec 2015 20:12:51 -0000 Author: hselasky Date: Fri Dec 4 20:12:49 2015 New Revision: 291822 URL: https://svnweb.freebsd.org/changeset/base/291822 Log: Check the return values from callout_reset() and callout_stop() in a more proper and readable way. This also fixes a bug in the ARP timer code and in the OCE driver. Modified: projects/hps_head/sys/dev/oce/oce_if.c projects/hps_head/sys/kern/subr_taskqueue.c projects/hps_head/sys/net/if_llatbl.c projects/hps_head/sys/netgraph/ng_base.c projects/hps_head/sys/netinet/if_ether.c projects/hps_head/sys/netinet/in.c projects/hps_head/sys/netinet6/in6.c projects/hps_head/sys/netinet6/nd6.c projects/hps_head/sys/netpfil/pf/if_pfsync.c Modified: projects/hps_head/sys/dev/oce/oce_if.c ============================================================================== --- projects/hps_head/sys/dev/oce/oce_if.c Fri Dec 4 19:46:49 2015 (r291821) +++ projects/hps_head/sys/dev/oce/oce_if.c Fri Dec 4 20:12:49 2015 (r291822) @@ -343,7 +343,7 @@ oce_attach(device_t dev) callout_init(&sc->timer, 1); rc = callout_reset(&sc->timer, 2 * hz, oce_local_timer, sc); - if (rc) + if (rc == CALLOUT_RET_CANCELLED) goto stats_free; return 0; Modified: projects/hps_head/sys/kern/subr_taskqueue.c ============================================================================== --- projects/hps_head/sys/kern/subr_taskqueue.c Fri Dec 4 19:46:49 2015 (r291821) +++ projects/hps_head/sys/kern/subr_taskqueue.c Fri Dec 4 20:12:49 2015 (r291822) @@ -496,7 +496,7 @@ taskqueue_cancel_timeout(struct taskqueu int error; TQ_LOCK(queue); - pending = !!(callout_stop(&timeout_task->c) > 0); + pending = (callout_stop(&timeout_task->c) == CALLOUT_RET_CANCELLED) ? 1 : 0; error = taskqueue_cancel_locked(queue, &timeout_task->t, &pending1); if ((timeout_task->f & DT_CALLOUT_ARMED) != 0) { timeout_task->f &= ~DT_CALLOUT_ARMED; Modified: projects/hps_head/sys/net/if_llatbl.c ============================================================================== --- projects/hps_head/sys/net/if_llatbl.c Fri Dec 4 19:46:49 2015 (r291821) +++ projects/hps_head/sys/net/if_llatbl.c Fri Dec 4 20:12:49 2015 (r291822) @@ -394,7 +394,7 @@ lltable_free(struct lltable *llt) IF_AFDATA_WUNLOCK(llt->llt_ifp); LIST_FOREACH_SAFE(lle, &dchain, lle_chain, next) { - if (callout_stop(&lle->lle_timer) > 0) + if (callout_stop(&lle->lle_timer) == CALLOUT_RET_CANCELLED) LLE_REMREF(lle); llentry_free(lle); } Modified: projects/hps_head/sys/netgraph/ng_base.c ============================================================================== --- projects/hps_head/sys/netgraph/ng_base.c Fri Dec 4 19:46:49 2015 (r291821) +++ projects/hps_head/sys/netgraph/ng_base.c Fri Dec 4 20:12:49 2015 (r291822) @@ -3813,7 +3813,8 @@ ng_uncallout(struct callout *c, node_p n rval = callout_stop(c); item = c->c_arg; /* Do an extra check */ - if ((rval > 0) && (c->c_func == &ng_callout_trampoline) && + if ((rval == CALLOUT_RET_CANCELLED) && + (c->c_func == &ng_callout_trampoline) && (NGI_NODE(item) == node)) { /* * We successfully removed it from the queue before it ran Modified: projects/hps_head/sys/netinet/if_ether.c ============================================================================== --- projects/hps_head/sys/netinet/if_ether.c Fri Dec 4 19:46:49 2015 (r291821) +++ projects/hps_head/sys/netinet/if_ether.c Fri Dec 4 20:12:49 2015 (r291822) @@ -420,7 +420,7 @@ arpresolve_full(struct ifnet *ifp, int i la->la_expire = time_uptime; canceled = callout_reset(&la->lle_timer, hz * V_arpt_down, arptimer, la); - if (canceled) + if (canceled == CALLOUT_RET_CANCELLED) LLE_REMREF(la); la->la_asked++; LLE_WUNLOCK(la); @@ -1084,7 +1084,7 @@ arp_mark_lle_reachable(struct llentry *l la->la_expire = time_uptime + V_arpt_keep; canceled = callout_reset(&la->lle_timer, hz * V_arpt_keep, arptimer, la); - if (canceled) + if (canceled == CALLOUT_RET_CANCELLED) LLE_REMREF(la); } la->la_asked = 0; Modified: projects/hps_head/sys/netinet/in.c ============================================================================== --- projects/hps_head/sys/netinet/in.c Fri Dec 4 19:46:49 2015 (r291821) +++ projects/hps_head/sys/netinet/in.c Fri Dec 4 20:12:49 2015 (r291822) @@ -1093,7 +1093,7 @@ in_lltable_free_entry(struct lltable *ll } /* cancel timer */ - if (callout_stop(&lle->lle_timer) > 0) + if (callout_stop(&lle->lle_timer) == CALLOUT_RET_CANCELLED) LLE_REMREF(lle); /* Drop hold queue */ Modified: projects/hps_head/sys/netinet6/in6.c ============================================================================== --- projects/hps_head/sys/netinet6/in6.c Fri Dec 4 19:46:49 2015 (r291821) +++ projects/hps_head/sys/netinet6/in6.c Fri Dec 4 20:12:49 2015 (r291822) @@ -2133,7 +2133,7 @@ in6_lltable_free_entry(struct lltable *l lltable_unlink_entry(llt, lle); } - if (callout_stop(&lle->lle_timer) > 0) + if (callout_stop(&lle->lle_timer) == CALLOUT_RET_CANCELLED) LLE_REMREF(lle); llentry_free(lle); Modified: projects/hps_head/sys/netinet6/nd6.c ============================================================================== --- projects/hps_head/sys/netinet6/nd6.c Fri Dec 4 19:46:49 2015 (r291821) +++ projects/hps_head/sys/netinet6/nd6.c Fri Dec 4 20:12:49 2015 (r291822) @@ -508,7 +508,7 @@ nd6_llinfo_settimer_locked(struct llentr nd6_llinfo_timer, ln); } } - if (canceled > 0) + if (canceled == CALLOUT_RET_CANCELLED) LLE_REMREF(ln); } Modified: projects/hps_head/sys/netpfil/pf/if_pfsync.c ============================================================================== --- projects/hps_head/sys/netpfil/pf/if_pfsync.c Fri Dec 4 19:46:49 2015 (r291821) +++ projects/hps_head/sys/netpfil/pf/if_pfsync.c Fri Dec 4 20:12:49 2015 (r291822) @@ -352,7 +352,7 @@ pfsync_clone_destroy(struct ifnet *ifp) TAILQ_REMOVE(&sc->sc_deferrals, pd, pd_entry); sc->sc_deferred--; - if (callout_stop(&pd->pd_tmo) > 0) { + if (callout_stop(&pd->pd_tmo) == CALLOUT_RET_CANCELLED) { pf_release_state(pd->pd_st); m_freem(pd->pd_m); free(pd, M_PFSYNC); @@ -1775,7 +1775,7 @@ pfsync_undefer_state(struct pf_state *st TAILQ_FOREACH(pd, &sc->sc_deferrals, pd_entry) { if (pd->pd_st == st) { - if (callout_stop(&pd->pd_tmo) > 0) + if (callout_stop(&pd->pd_tmo) == CALLOUT_RET_CANCELLED) pfsync_undefer(pd, drop); return; }