From owner-freebsd-pf@FreeBSD.ORG Sun Oct 24 22:10:30 2004 Return-Path: Delivered-To: freebsd-pf@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 5424316A4CE for ; Sun, 24 Oct 2004 22:10:30 +0000 (GMT) Received: from freefall.freebsd.org (freefall.freebsd.org [216.136.204.21]) by mx1.FreeBSD.org (Postfix) with ESMTP id 271AE43D1F for ; Sun, 24 Oct 2004 22:10:30 +0000 (GMT) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (gnats@localhost [127.0.0.1]) by freefall.freebsd.org (8.12.11/8.12.11) with ESMTP id i9OMAUkx070318 for ; Sun, 24 Oct 2004 22:10:30 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.12.11/8.12.11/Submit) id i9OMATO7070316; Sun, 24 Oct 2004 22:10:29 GMT (envelope-from gnats) Date: Sun, 24 Oct 2004 22:10:29 GMT Message-Id: <200410242210.i9OMATO7070316@freefall.freebsd.org> To: pf@FreeBSD.org From: Max Laier Subject: Re: kern/72444: PF can't properly detect interface after 'ifconfig XXX name YYY' X-BeenThere: freebsd-pf@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list Reply-To: Max Laier List-Id: Technical discussion and general questions about packet filter (pf) List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 24 Oct 2004 22:10:30 -0000 The following reply was made to PR kern/72444; it has been noted by GNATS. From: Max Laier To: freebsd-gnats-submit@freebsd.org, ed@il.fontys.nl Cc: Subject: Re: kern/72444: PF can't properly detect interface after 'ifconfig XXX name YYY' Date: Mon, 25 Oct 2004 00:00:17 +0200 --Boundary-00=_zXCfBCdi0Ycu4DN Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Content-Disposition: inline I have uploaded an updated diff. This version should do better with module load/unload and allow the use of "6to4" interfaces. Please test and tell me if it introduces other problems. Diff attached or at: http://people.freebsd.org/~mlaier/pf_if.c.diff -- Max --Boundary-00=_zXCfBCdi0Ycu4DN Content-Type: text/x-diff; charset="us-ascii"; name="pf_if.c.diff" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="pf_if.c.diff" Index: pf_if.c =================================================================== RCS file: /usr/store/mlaier/fcvs/src/sys/contrib/pf/net/pf_if.c,v retrieving revision 1.6 diff -u -r1.6 pf_if.c --- pf_if.c 14 Sep 2004 15:20:24 -0000 1.6 +++ pf_if.c 24 Oct 2004 21:52:45 -0000 @@ -157,12 +157,11 @@ #ifdef __FreeBSD__ PF_LOCK(); IFNET_RLOCK(); - TAILQ_FOREACH(ifp, &ifnet, if_link) - if (ifp->if_dunit != IF_DUNIT_NONE) { - IFNET_RUNLOCK(); - pfi_attach_ifnet(ifp); - IFNET_RLOCK(); - } + TAILQ_FOREACH(ifp, &ifnet, if_link) { + IFNET_RUNLOCK(); + pfi_attach_ifnet(ifp); + IFNET_RLOCK(); + } IFNET_RUNLOCK(); PF_UNLOCK(); pfi_dummy = pfi_if_create("notyet", pfi_self, @@ -248,8 +247,7 @@ pfi_attach_ifnet_event(void *arg __unused, struct ifnet *ifp) { PF_LOCK(); - if (ifp->if_dunit != IF_DUNIT_NONE) - pfi_attach_ifnet(ifp); + pfi_attach_ifnet(ifp); PF_UNLOCK(); } @@ -341,8 +339,8 @@ /* add/modify interface */ if (p == NULL) - p = pfi_if_create(ifp->if_xname, q, - realname?PFI_IFLAG_INSTANCE:PFI_IFLAG_PLACEHOLDER); + p = pfi_if_create(ifp->if_xname, q, PFI_IFLAG_INSTANCE | + (realname?0:PFI_IFLAG_PLACEHOLDER)); else { /* remove from the dummy group */ /* XXX: copy stats? We should not have any!!! */ @@ -354,10 +352,9 @@ q->pfik_addcnt++; TAILQ_INSERT_TAIL(&q->pfik_grouphead, p, pfik_instances); - if (realname) { + if (realname) p->pfik_flags &= ~PFI_IFLAG_PLACEHOLDER; - p->pfik_flags |= PFI_IFLAG_INSTANCE; - } + p->pfik_flags |= PFI_IFLAG_INSTANCE; } if (p == NULL) panic("pfi_attach_ifnet: " @@ -874,6 +871,7 @@ if (p->pfik_rules > 0 || p->pfik_states > 0) { /* move back to the dummy group */ p->pfik_parent = pfi_dummy; + p->pfik_flags &= ~PFI_IFLAG_INSTANCE; pfi_dummy->pfik_addcnt++; TAILQ_INSERT_TAIL(&pfi_dummy->pfik_grouphead, p, pfik_instances); @@ -912,11 +910,8 @@ */ IFNET_RLOCK(); - TAILQ_FOREACH(ifp, &ifnet, if_link) { - if (ifp->if_dunit == IF_DUNIT_NONE) - continue; + TAILQ_FOREACH(ifp, &ifnet, if_link) pfi_newgroup(ifp->if_dname, PFI_IFLAG_DYNAMIC); - } IFNET_RUNLOCK(); #else char *buses[] = PFI_DYNAMIC_BUSES; --Boundary-00=_zXCfBCdi0Ycu4DN--