From owner-freebsd-bugs@FreeBSD.ORG Sat Jul 2 23:20:20 2005 Return-Path: X-Original-To: freebsd-bugs@hub.freebsd.org Delivered-To: freebsd-bugs@hub.freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id EA41916A427 for ; Sat, 2 Jul 2005 23:20:19 +0000 (GMT) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [216.136.204.21]) by mx1.FreeBSD.org (Postfix) with ESMTP id A5C3943D5E for ; Sat, 2 Jul 2005 23:20:18 +0000 (GMT) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (gnats@localhost [127.0.0.1]) by freefall.freebsd.org (8.13.3/8.13.3) with ESMTP id j62NKI8S007521 for ; Sat, 2 Jul 2005 23:20:18 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.13.3/8.13.1/Submit) id j62NKIiP007516; Sat, 2 Jul 2005 23:20:18 GMT (envelope-from gnats) Resent-Date: Sat, 2 Jul 2005 23:20:18 GMT Resent-Message-Id: <200507022320.j62NKIiP007516@freefall.freebsd.org> Resent-From: FreeBSD-gnats-submit@FreeBSD.org (GNATS Filer) Resent-To: freebsd-bugs@FreeBSD.org Resent-Reply-To: FreeBSD-gnats-submit@FreeBSD.org, Dan Lukes Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 254CF16A41C for ; Sat, 2 Jul 2005 23:11:00 +0000 (GMT) (envelope-from dan@kulesh.obluda.cz) Received: from kulesh.obluda.cz (kulesh.obluda.cz [193.179.22.243]) by mx1.FreeBSD.org (Postfix) with ESMTP id E0B6843D1D for ; Sat, 2 Jul 2005 23:10:58 +0000 (GMT) (envelope-from dan@kulesh.obluda.cz) Received: from kulesh.obluda.cz (localhost.eunet.cz [127.0.0.1]) by kulesh.obluda.cz (8.13.3/8.13.3) with ESMTP id j62NAuCh009821 for ; Sun, 3 Jul 2005 01:10:56 +0200 (CEST) (envelope-from dan@kulesh.obluda.cz) Received: (from root@localhost) by kulesh.obluda.cz (8.13.3/8.13.1/Submit) id j62NAuWX009820; Sun, 3 Jul 2005 01:10:56 +0200 (CEST) (envelope-from dan) Message-Id: <200507022310.j62NAuWX009820@kulesh.obluda.cz> Date: Sun, 3 Jul 2005 01:10:56 +0200 (CEST) From: Dan Lukes To: FreeBSD-gnats-submit@FreeBSD.org X-Send-Pr-Version: 3.113 Cc: Subject: kern/82908: [ PATCH ] ip_carp should use ifnet_departure_event event X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: Dan Lukes List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 02 Jul 2005 23:20:20 -0000 >Number: 82908 >Category: kern >Synopsis: [ PATCH ] ip_carp should use ifnet_departure_event event >Confidential: no >Severity: non-critical >Priority: low >Responsible: freebsd-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: change-request >Submitter-Id: current-users >Arrival-Date: Sat Jul 02 23:20:18 GMT 2005 >Closed-Date: >Last-Modified: >Originator: Dan Lukes >Release: FreeBSD 5.4-STABLE i386 >Organization: Obludarium >Environment: System: FreeBSD 5.4-STABLE i386 src/sys/net/if.c,v 1.199.2.15 2005/04/15 01:51:44 cperciva src/sys/netinet/ip_carp.h,v 1.1.2.1 2005/03/21 16:05:35 glebius src/sys/netinet/ip_carp.c,v 1.21.2.3 2005/05/19 10:55:14 glebius >Description: modify ip_carp to use ifnet_departure_event event handler instead of exporting of carp_ifdetach() to public >How-To-Repeat: N/A >Fix: --- sys/net/if.c.ORIG Sat Jul 2 01:36:12 2005 +++ sys/net/if.c Sun Jul 3 00:45:46 2005 @@ -532,11 +532,6 @@ int found; EVENTHANDLER_INVOKE(ifnet_departure_event, ifp); -#ifdef DEV_CARP - /* Maybe hook to the generalized departure handler above?!? */ - if (ifp->if_carp) - carp_ifdetach(ifp); -#endif /* * Remove routes and flush queues. --- sys/netinet/ip_carp.c.ORIG Tue May 31 23:39:41 2005 +++ sys/netinet/ip_carp.c Sun Jul 3 00:42:34 2005 @@ -182,6 +182,8 @@ log(LOG_DEBUG, __VA_ARGS__); \ } while (0) +static eventhandler_tag if_detach_event_tag = NULL; + static void carp_hmac_prepare(struct carp_softc *); static void carp_hmac_generate(struct carp_softc *, u_int32_t *, unsigned char *); @@ -772,12 +774,14 @@ } /* Detach an interface from the carp. */ -void -carp_ifdetach(struct ifnet *ifp) +static void +carp_ifdetach(void *arg __unused, struct ifnet *ifp) { struct carp_softc *sc; struct carp_if *cif = (struct carp_if *)ifp->if_carp; + if ( ! ifp->if_carp) + return; CARP_LOCK(cif); TAILQ_FOREACH(sc, &cif->vhif_vrs, sc_list) carpdetach(sc); @@ -2138,11 +2142,19 @@ switch (type) { case MOD_LOAD: mtx_init(&carp_mtx, "carp_mtx", NULL, MTX_DEF); + if_detach_event_tag = EVENTHANDLER_REGISTER(ifnet_departure_event, + carp_ifdetach, NULL, EVENTHANDLER_PRI_ANY); + if (if_detach_event_tag == NULL) { + mtx_destroy(&carp_mtx); + error = ENOMEM; + break; + } LIST_INIT(&carpif_list); if_clone_attach(&carp_cloner); break; case MOD_UNLOAD: + EVENTHANDLER_DEREGISTER(ifnet_departure_event, if_detach_event_tag); if_clone_detach(&carp_cloner); while (!LIST_EMPTY(&carpif_list)) carp_clone_destroy(&LIST_FIRST(&carpif_list)->sc_if); --- sys/netinet/ip_carp.h.ORIG Mon Mar 21 17:05:35 2005 +++ sys/netinet/ip_carp.h Sun Jul 3 00:43:47 2005 @@ -148,7 +148,6 @@ } #ifdef _KERNEL -void carp_ifdetach (struct ifnet *); void carp_carpdev_state(void *); void carp_input (struct mbuf *, int); int carp6_input (struct mbuf **, int *, int); --- patch ends here --- >Release-Note: >Audit-Trail: >Unformatted: