kern/72444: PF can't properly detect interface after 'ifconfig XXX name YYY'

Max Laier max at love2party.net
Sun Oct 24 15:10:30 PDT 2004


The following reply was made to PR kern/72444; it has been noted by GNATS.

From: Max Laier <max at love2party.net>
To: freebsd-gnats-submit at freebsd.org, ed at 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--


More information about the freebsd-pf mailing list