* [Bridge] About local delivery of bridged packets
@ 2010-10-11 13:29 Aijaz Baig
2010-10-12 13:01 ` Aijaz Baig
0 siblings, 1 reply; 3+ messages in thread
From: Aijaz Baig @ 2010-10-11 13:29 UTC (permalink / raw)
To: bridge
Hello,
I am trying to understand how does the bridging code determine if the packet is
to be delivered locally or is it to be forwarded. Before being delivered
locally, I mean the packet is to be delivered either to br0 or to a non enslaved
interface. If I am wrong here, please do correct me.
The decision whether to pass the frame up or to forward the frame (or flood it
if the bridge doesnt know where a given dest address resides) seems to be
dependent on whether the entry corresponding to the frame is a local entry or if
the destination address is a multicast address. fdb insert, if it finds an
existing entry, which is not local, deletes it and creates an entry such that
the 'is_local' flag is set. I do not understand this logic.
But on investigating it looks like the 'is_local' flag in the
net_bridge_fdb_entry is set by fdb_insert() indirectly via fdb_create().
fdb_insert() is called from br_fdb_insert() which is inturn called from
br_add_if when an interface is being added to the bridge. br_add_if() is called
from add_del_if() which is in turn called from br_dev_ioctl() in case of the new
brctl interface. Now the signature of this function is like so:
int br_dev_ioctl(struct net_device *dev, struct ifreq *rq, int cmd);
It looks like the 'dev' above is the net_device structure corresponding to the
bridge br0, the cmd in case of adding or removing an interface is SIOCBRADDIF or
SIOCBRDELIF and when add_del_if is called from br_dev_ioctl() , it is done like
so:
add_del_if(br, rq->ifr_ifindex, cmd == SIOCBRADDIF);
Thus the second argument I suppose is the interface index for the bridge. Now
from within add_del_if(), we obtain the dev, of type net_device again, using:
dev = dev_get_by_index(&init_net, ifindex);
br_add_if is finally called as in:
br_add_if(br,dev);
we are passing the net_bridge structure along with the net_device structure
corresponding to the interface which we want to be enslaved. Now br_fdb_insert()
is called from within like so:
err = br_fdb_insert(br, p, dev->dev_addr); where p is the newly allocated net
bridge port. Thus it looks like the address that we are adding here, i.e. the
third argument of this function is the address of the interface being enslaved.
However, we usually do not assign any address to the enslaved interface as a
standard practice isnt it? We usually assign br0 an address which is usually
used for administrative purposes. So If I assign an address to br0, how does
that get added to the fdb? And secondly how does it know that its a local
address?
Im a little confused by the code here. Please enlighten me about it
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [Bridge] About local delivery of bridged packets
2010-10-11 13:29 [Bridge] About local delivery of bridged packets Aijaz Baig
@ 2010-10-12 13:01 ` Aijaz Baig
2010-10-12 16:37 ` Stephen Hemminger
0 siblings, 1 reply; 3+ messages in thread
From: Aijaz Baig @ 2010-10-12 13:01 UTC (permalink / raw)
To: bridge
Aijaz Baig <aijazbaig1 <at> gmail.com> writes:
>
> Hello,
>
> I am trying to understand how does the bridging code determine if the packet
is
> to be delivered locally or is it to be forwarded. Before being delivered
> locally, I mean the packet is to be delivered either to br0 or to a non
enslaved
> interface. If I am wrong here, please do correct me..................
Hello,
Heres answering my own question partially. Since the bridge which is after all a
virtual interface takes one of the L2 addresses of its interfaces (is it the
first real interface which is enslaved?), any packet which is destined with this
L2 dest address in its eth header, will be considered locally destined.
This simple fact solves my issue.
Regards,
Aijaz
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [Bridge] About local delivery of bridged packets
2010-10-12 13:01 ` Aijaz Baig
@ 2010-10-12 16:37 ` Stephen Hemminger
0 siblings, 0 replies; 3+ messages in thread
From: Stephen Hemminger @ 2010-10-12 16:37 UTC (permalink / raw)
To: Aijaz Baig; +Cc: bridge
On Tue, 12 Oct 2010 13:01:08 +0000 (UTC)
Aijaz Baig <aijazbaig1@gmail.com> wrote:
> Aijaz Baig <aijazbaig1 <at> gmail.com> writes:
>
> >
> > Hello,
> >
> > I am trying to understand how does the bridging code determine if the packet
> is
> > to be delivered locally or is it to be forwarded. Before being delivered
> > locally, I mean the packet is to be delivered either to br0 or to a non
> enslaved
> > interface. If I am wrong here, please do correct me..................
>
> Hello,
>
> Heres answering my own question partially. Since the bridge which is after all a
> virtual interface takes one of the L2 addresses of its interfaces (is it the
> first real interface which is enslaved?), any packet which is destined with this
> L2 dest address in its eth header, will be considered locally destined.
>
> This simple fact solves my issue.
>
> Regards,
> Aijaz
You have it almost right!
The bridge keeps a forwarding database that contains:
Ethernet-address Port-device flags
11:22:33:44:55 eth0 local
01:20:30:40:50 eth0
When eth0 is added to bridge, the address for eth0 is added
to forwarding table with local flag set. The local flag indicates
during receive that the packet should be received locally.
If multiple devices are in bridge, then the bridge will locally
receive all those addresses.
The logic for this is in br_input.c:br_handle_frame_finish function.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2010-10-12 16:37 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-10-11 13:29 [Bridge] About local delivery of bridged packets Aijaz Baig
2010-10-12 13:01 ` Aijaz Baig
2010-10-12 16:37 ` Stephen Hemminger
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox