kern/109815: wrong interface identifier at pfil_hooks for vlans + if_bridge

Roman Kurakin rik at inse.ru
Sat Mar 3 22:40:10 UTC 2007


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

From: Roman Kurakin <rik at inse.ru>
To: Eygene Ryabinkin <rea-fbsd at codelabs.ru>
Cc: FreeBSD-gnats-submit at FreeBSD.org,  rik at FreeBSD.org, 
 glebius at FreeBSD.org,  andre at FreeBSD.org,  thompsa at FreeBSD.org
Subject: Re: kern/109815: wrong interface identifier at pfil_hooks for vlans
 +	if_bridge
Date: Sun, 04 Mar 2007 01:08:40 +0300

 Just come to my mind.
 
 The idea behind current code could be that in case of bridge the 
 interface for which this
 packet in?nded is much more important than the physical interface it is 
 arrived from.
 If this is the case, than it would be much better do the same logic for 
 ifp and in case
 it is not that interface to check the list. This will fix the problem in 
 case of vlans and
 will leave the old behavior for the other cases.
 
 Any comments?
 
 rik
 
 Eygene Ryabinkin wrote:
 >> Number:         109815
 >> Category:       kern
 >> Synopsis:       wrong interface identifier at pfil_hooks for vlans + if_bridge
 >> Confidential:   no
 >> Severity:       serious
 >> Priority:       medium
 >> Responsible:    freebsd-bugs
 >> State:          open
 >> Quarter:        
 >> Keywords:       
 >> Date-Required:
 >> Class:          sw-bug
 >> Submitter-Id:   current-users
 >> Arrival-Date:   Sat Mar 03 21:20:04 GMT 2007
 >> Closed-Date:
 >> Last-Modified:
 >> Originator:     Eygene Ryabinkin
 >> Release:        FreeBSD 6.2-STABLE i386
 >> Organization:
 >>     
 > Code Labs
 >   
 >> Environment:
 >>     
 > System: FreeBSD XXX 6.2-STABLE FreeBSD 6.2-STABLE #13: Mon Feb 12 15:59:07 MSK 2007 root at XXX:/usr/obj/usr/src/sys/XXX i386
 >   
 >> Description:
 >>     
 > When if_bridge is used to gather multiple vlan interfaces that have
 > the same physical parent (I will call such vlan interfaces the 'vlan
 > group') the interface identifier that will be passed to the
 > pfil_hooks will be sometimes wrong. For all packets coming from the
 > 'vlan group' and destined to some local interface the incoming interface
 > passed to the pfil_hooks will be the last interface in that group
 > regardless of the actual incoming interface. The 'last interface' is
 > the interface that was added to the if_bridge at the very last 'addm'
 > command.
 >
 > The problem is lying in the fact that MAC addresses of the 'vlan group'
 > are just the same and they are equal to the MAC address of the parent
 > interface. And the check for the unicat packet that is destined for
 > 'us' in the if_bridge.c:bridge_input() is walking by the list of the
 > if_bridge-attached interfaces and compares the MAC addresses to the
 > packet's one. Once match is found the interface in the packet header
 > will be rewritten to the found list entry's one. Apparently such
 > code flow will select the last added interface from the 'vlan group'
 > because FreeBSD list macros are adding list members to the beginning
 > of the linked list.
 >
 > BPF will receive the right interface, because it is tapped before
 > bridge_input (in if_ethersubr.c).
 >
 >   
 >> How-To-Repeat:
 >>     
 > Set up three vlan interfaces on the same physical one, and add them
 > to the same if_bridge. Give one VLAN interface IP address and send
 > packets from the other VLAN segment to that IP. See that tcpdump
 > is seeing the correct interface, but ipfw/pf are seeing the same
 > packet having the last added interface as the rcvif, not the right one.
 > For the last added interface the result will be correct, but for
 > others -- not.
 >   
 >> Fix:
 >>     
 > Since bridge_input always knows about the incoming interface as
 > it is passed as the first argument my fix is just to set the
 > right interface using the passed parameter and not the interface
 > found by the list traversal. The patch is below. It should not
 > break the ordinary situation without CARP and I see no troubles
 > even with the CARP code. But I am not expirienced with CARP, so
 > I am CCing Gleb, Andrew and Andre. We'd found this bug with rik@
 > so he gots the CC too.
 >
 > Shutting up ;))
 >
 > --- if_bridge.c.orig	Fri Mar  2 18:23:56 2007
 > +++ if_bridge.c	Sat Mar  3 05:04:38 2007
 > @@ -2122,7 +2122,11 @@
 >  	LIST_FOREACH(bif2, &sc->sc_iflist, bif_next) {
 >  		if (bif2->bif_ifp->if_type == IFT_GIF)
 >  			continue;
 > -		/* It is destined for us. */
 > +		/* It is destined for us. We should not rely on the
 > +		 * found interface's MAC as the interface identifier,
 > +		 * because vlanX interfaces are sharing their MAC
 > +		 * with the parent. Moreover, we do know the interface
 > +		 * the packet is coming from. So we're using it. */
 >  		if (memcmp(IF_LLADDR(bif2->bif_ifp), eh->ether_dhost,
 >  		    ETHER_ADDR_LEN) == 0
 >  #ifdef DEV_CARP
 > @@ -2133,7 +2137,7 @@
 >  			if (bif->bif_flags & IFBIF_LEARNING)
 >  				(void) bridge_rtupdate(sc,
 >  				    eh->ether_shost, bif, 0, IFBAF_DYNAMIC);
 > -			m->m_pkthdr.rcvif = bif2->bif_ifp;
 > +			m->m_pkthdr.rcvif = ifp;
 >  			BRIDGE_UNLOCK(sc);
 >  			return (m);
 >  		}
 >   
 >> Release-Note:
 >> Audit-Trail:
 >> Unformatted:
 >>     
 > _______________________________________________
 > freebsd-bugs at freebsd.org mailing list
 > http://lists.freebsd.org/mailman/listinfo/freebsd-bugs
 > To unsubscribe, send any mail to "freebsd-bugs-unsubscribe at freebsd.org"
 >   
 


More information about the freebsd-bugs mailing list