On Mon, Jun 22, 2015 at 05:31:29PM +0200, Martin Pieuchot wrote:
> On 22/06/15(Mon) 17:12, Alexander Bluhm wrote:
> > On Wed, Jun 17, 2015 at 02:08:14PM +0200, Martin Pieuchot wrote:
> > > diff -u -p -r1.340 if.c
> > > --- net/if.c      16 Jun 2015 11:09:39 -0000      1.340
> > > +++ net/if.c      17 Jun 2015 12:03:36 -0000
> > > @@ -530,6 +530,15 @@ if_input_process(void *xmq)
> > >                   continue;
> > >           }
> > >  
> > > +#if NBRIDGE > 0
> > > +         if (ifp->if_bridgeport && (m->m_flags & M_PROTO1) == 0) {
> > > +                 m = bridge_input(m);
> > > +                 if (m == NULL)
> > > +                         continue;
> > > +         }
> > > +         m->m_flags &= ~M_PROTO1;        /* Loop prevention */
> > > +#endif
> > 
> > Should we reset the loop prevention only if our call to bridge_input()
> > did set M_PROTO1?  Something like this
> > 
> >             if (ifp->if_bridgeport && (m->m_flags & M_PROTO1) == 0) {
> >                     m = bridge_input(m);
> >                     if (m == NULL)
> >                             continue;
> >                     m->m_flags &= ~M_PROTO1;        /* Loop prevention */
> >             }
> 
> Yes and no :)
> 
> bridge_input() will set M_PROTO1 on the mbuf copies that it enqueues on
> its ports.
> 
> If you receive a packet on em0 in bridge0 with tun0, you want to call
> bridge_input() only once, but you'll call if_input() in em0 and tun0.
> 
> So the first packet will enter if_input() without M_PROTO1, go through
> bridge_input() then be processed by the stack.  Then the copy of this
> packet created in bridge_input() will have the M_PROTO1 flag set and
> when it will be dequeued by if_input() it won't be passed to 
> bridge_input() again.
> 
> Does that make sense?

I have tested bridge loops with vlans.  The packets run in a circle
with both implementations.  Softnet task goes to 100% but no crashes
or stack overflow.

So with your explanation and my test I am fine with your loop
prevention.

OK bluhm@

Reply via email to