From mboxrd@z Thu Jan 1 00:00:00 1970 Message-ID: <01f701c63728$6203bef0$4a27b3d5@tungemaskin> From: =?iso-8859-1?Q?J=F8rgen_Hovland?= Date: Tue, 21 Feb 2006 21:50:00 +0100 MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_NextPart_000_01F4_01C63730.C3B78520" Subject: [Bridge] physical interface on a bridge List-Id: Linux Ethernet Bridging List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: bridge@lists.osdl.org This is a multi-part message in MIME format... ------=_NextPart_000_01F4_01C63730.C3B78520 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Content-Disposition: inline Hi Is there a way to either: Find the real ifindex/ifname a mac-address is bound to or Find the real ifindex/ifname of an incoming packet ? I am writing a dhcp server and need to know what real interface the dhcp re= quest packet came from. An acceptable solution would be to get the interfac= e by the mac-address, but that can be faked so I would rather get the inter= face by knowing where the data actually came from. Data is IP, UDP broadcas= t. I _could_ use raw sockets. The problem is when I do that, the program is us= ing ~8% cpu on a 3.2ghz xeon64 just reading packets without doing anything = due to the amount of traffic passing through the box (~200mbit and increasi= ng) so that doesn't look like a good idea. brctl showmacs returns a list of port numbers, but they dont make much sens= e to me. They do not seem to be in the same order I added the interfaces? I= s there a mapping here? Example, jorgen@ams41:/$ /tmp/brctl showmacs test0 port no mac addr is local? ageing timer 2 00:04:e2:a8:3b:d7 no 0.24 1 00:08:a1:85:39:fd no 17.31 133 00:0d:88:a3:61:4a no 9.90 1 00:14:22:b0:cd:e0 yes 0.00 133 00:16:c7:f5:8f:e2 no 0.48 Port 133 is the 901'th interface (0x385) I added to bridge test0. What does= 133 point to? The ifindex of this physical interface is 912 (0x390) (retr= ieved with SIOCGIFINDEX). Secondly, I seem to be unable to add more than around 1024 interfaces to a single bri= dge. Is there a way to increase this limit? I am using linux kernel 2.6 Thanks a million, Joergen ------=_NextPart_000_01F4_01C63730.C3B78520 Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Content-Disposition: inline
Hi
 
Is there a way to either:
Find the real ifindex/ifname a mac-address= is bound=20 to
or
Find the real ifindex/ifname of an incomin= g=20 packet
?
 
I am writing a dhcp server and need to kno= w what=20 real interface the dhcp request packet came from. An acceptable solution wo= uld=20 be to get the interface by the mac-address, but that can be faked so I woul= d=20 rather get the interface by knowing where the data actually came from. Data= is=20 IP, UDP broadcast.
I _could_ use raw sockets. The problem is = when I do=20 that, the program is using ~8% cpu on a 3.2ghz xeon64 just reading pac= kets=20 without doing anything due to the amount of traffic passing through the box= =20 (~200mbit and increasing) so that doesn't look like a good=20 idea.
 
brctl showmacs returns a list of port numb= ers, but=20 they dont make much sense to me. They do not seem to be in the same order I= =20 added the interfaces? Is there a mapping here?
 
Example,
jorgen@ams41:/$ /tmp/brctl showmacs=20 test0
port no mac=20 addr            = ;   =20 is local?       ageing timer
 =20 2     00:04:e2:a8:3b:d7     &n= bsp;=20 no            &= nbsp;   =20 0.24
  1    =20 00:08:a1:85:39:fd      =20 no            &= nbsp;  =20 17.31
133    =20 00:0d:88:a3:61:4a      =20 no            &= nbsp;   =20 9.90
  1    =20 00:14:22:b0:cd:e0      =20 yes            =    =20 0.00
133    =20 00:16:c7:f5:8f:e2      =20 no            &= nbsp;   =20 0.48
Port 133 is the 901'th interface (0x385)&n= bsp;I=20 added to bridge test0. What does 133 point to?  The ifindex of this physical interface is 912 (0x390)= =20 (retrieved with SIOCGIFINDEX).
 
Secondly,
I seem to be unable to add more than aroun= d 1024=20 interfaces to a single bridge. Is there a way to increase this=20 limit?
 
I am using linux kernel 2.6
 
 
Thanks a million,
Joergen
------=_NextPart_000_01F4_01C63730.C3B78520-- From mboxrd@z Thu Jan 1 00:00:00 1970 Date: Tue, 21 Feb 2006 14:17:43 -0800 From: Stephen Hemminger Subject: Re: [Bridge] physical interface on a bridge Message-ID: <20060221141743.32d66879@localhost.localdomain> In-Reply-To: <01f701c63728$6203bef0$4a27b3d5@tungemaskin> References: <01f701c63728$6203bef0$4a27b3d5@tungemaskin> Mime-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit List-Id: Linux Ethernet Bridging List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: =?UTF-8?B?SsO4cmdlbg==?= Hovland Cc: bridge@lists.osdl.org On Tue, 21 Feb 2006 21:50:00 +0100 Jørgen Hovland wrote: > Hi > > Is there a way to either: > Find the real ifindex/ifname a mac-address is bound to > or > Find the real ifindex/ifname of an incoming packet > ? > > I am writing a dhcp server and need to know what real interface the dhcp request packet came from. An acceptable solution would be to get the interface by the mac-address, but that can be faked so I would rather get the interface by knowing where the data actually came from. Data is IP, UDP broadcast. > I _could_ use raw sockets. The problem is when I do that, the program is using ~8% cpu on a 3.2ghz xeon64 just reading packets without doing anything due to the amount of traffic passing through the box (~200mbit and increasing) so that doesn't look like a good idea. Why should the app care. If forwarding database is working correctly, the source mac of the incoming packet will be in the list and any response to it will go out that interface. > brctl showmacs returns a list of port numbers, but they dont make much sense to me. They do not seem to be in the same order I added the interfaces? Is there a mapping here? > > Example, > jorgen@ams41:/$ /tmp/brctl showmacs test0 > port no mac addr is local? ageing timer > 2 00:04:e2:a8:3b:d7 no 0.24 > 1 00:08:a1:85:39:fd no 17.31 > 133 00:0d:88:a3:61:4a no 9.90 > 1 00:14:22:b0:cd:e0 yes 0.00 > 133 00:16:c7:f5:8f:e2 no 0.48 > > Port 133 is the 901'th interface (0x385) I added to bridge test0. What does 133 point to? The ifindex of this physical interface is 912 (0x390) (retrieved with SIOCGIFINDEX). Arbitrary index assigned by bridge for STP usage. Slots get reused as ports are deleted and added. > > Secondly, > I seem to be unable to add more than around 1024 interfaces to a single bridge. Is there a way to increase this limit? Increase BR_PORT_BITS (you can go up to 15) but you will lose priority bits on the spanning tree. Also, why? You performance is going to start to fall off with so many interfaces. Can't you partition to multiple machines? From mboxrd@z Thu Jan 1 00:00:00 1970 Message-ID: <003101c6378b$f5f65060$4a27b3d5@tungemaskin> From: =?UTF-8?Q?J=C3=B8rgen_Hovland?= References: <01f701c63728$6203bef0$4a27b3d5@tungemaskin> <20060221141743.32d66879@localhost.localdomain> Subject: Re: [Bridge] physical interface on a bridge Date: Wed, 22 Feb 2006 09:42:49 +0100 MIME-Version: 1.0 Content-Type: text/plain; format="flowed"; charset="utf-8"; reply-type="original" Content-Transfer-Encoding: 8bit List-Id: Linux Ethernet Bridging List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Stephen Hemminger Cc: bridge@lists.osdl.org ----- Original Message ----- From: "Stephen Hemminger" > On Tue, 21 Feb 2006 21:50:00 +0100 > Jørgen Hovland wrote: > >> Hi >> >> Is there a way to either: >> Find the real ifindex/ifname a mac-address is bound to >> or >> Find the real ifindex/ifname of an incoming packet >> ? >> >> I am writing a dhcp server and need to know what real interface the dhcp >> request packet came from. An acceptable solution would be to get the >> interface by the mac-address, but that can be faked so I would rather get >> the interface by knowing where the data actually came from. Data is IP, >> UDP broadcast. >> I _could_ use raw sockets. The problem is when I do that, the program is >> using ~8% cpu on a 3.2ghz xeon64 just reading packets without doing >> anything due to the amount of traffic passing through the box (~200mbit >> and increasing) so that doesn't look like a good idea. > > Why should the app care. If forwarding database is working correctly, the > source mac > of the incoming packet will be in the list and any response to it will go > out that interface. > Well there is no guarantee that the source mac isn't faked. Additionally, the hardware address of the dhcp client is put inside a dhcp-packet, which also can be faked. So I am stuck with two hardware addresses that I am suppposed to believe are correct but have no information about where I originally received them from. I can live with this (I guess all the other dhcp servers do that too), but I can't find a way to map a hardware address to a physical interface when using bridgemode. I need to know this because the dhcp server will be limiting the amount of leases you can get per interface (eg max 5 ips per interface). It will also be assigning static IP-addresses based on what interface the dhcp packet came from. I will also be using iptables to only permit the IP+MAC traffic to/from the real physical interface so if you don't use dhcp at all times, the traffic won't be permitted. > >> brctl showmacs returns a list of port numbers, but they dont make much >> sense to me. They do not seem to be in the same order I added the >> interfaces? Is there a mapping here? >> >> Example, >> jorgen@ams41:/$ /tmp/brctl showmacs test0 >> port no mac addr is local? ageing timer >> 2 00:04:e2:a8:3b:d7 no 0.24 >> 1 00:08:a1:85:39:fd no 17.31 >> 133 00:0d:88:a3:61:4a no 9.90 >> 1 00:14:22:b0:cd:e0 yes 0.00 >> 133 00:16:c7:f5:8f:e2 no 0.48 >> >> Port 133 is the 901'th interface (0x385) I added to bridge test0. What >> does 133 point to? The ifindex of this physical interface is 912 (0x390) >> (retrieved with SIOCGIFINDEX). > > Arbitrary index assigned by bridge for STP usage. Slots get reused as > ports are deleted and added. So there is no way to get the physical interface from a mac address? Is there any way at all? Do you plan to add this functionality? Would you accept a patch if I were to submit any (I can't guarantee anything atm) ? As an example, Cisco IOS support mac lookup just fine. > >> >> Secondly, >> I seem to be unable to add more than around 1024 interfaces to a single >> bridge. Is there a way to increase this limit? > > Increase BR_PORT_BITS (you can go up to 15) but you will lose priority > bits on the spanning tree. > Also, why? You performance is going to start to fall off with so many > interfaces. Can't you > partition to multiple machines? Perhaps it would be better to split it into multiple bridges. I was planning on having 1 bridge per router, and one router will have ~3000 interfaces. I will reconsider this. Thank you. Joergen From mboxrd@z Thu Jan 1 00:00:00 1970 Date: Wed, 22 Feb 2006 08:02:50 -0800 From: Stephen Hemminger Subject: Re: [Bridge] physical interface on a bridge Message-ID: <20060222080250.363d5e30@localhost.localdomain> In-Reply-To: <003101c6378b$f5f65060$4a27b3d5@tungemaskin> References: <01f701c63728$6203bef0$4a27b3d5@tungemaskin> <20060221141743.32d66879@localhost.localdomain> <003101c6378b$f5f65060$4a27b3d5@tungemaskin> Mime-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit List-Id: Linux Ethernet Bridging List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: =?UTF-8?B?SsO4cmdlbg==?= Hovland Cc: bridge@lists.osdl.org On Wed, 22 Feb 2006 09:42:49 +0100 Jørgen Hovland wrote: > > ----- Original Message ----- > From: "Stephen Hemminger" > > > > On Tue, 21 Feb 2006 21:50:00 +0100 > > Jørgen Hovland wrote: > > > >> Hi > >> > >> Is there a way to either: > >> Find the real ifindex/ifname a mac-address is bound to > >> or > >> Find the real ifindex/ifname of an incoming packet > >> ? > >> > >> I am writing a dhcp server and need to know what real interface the dhcp > >> request packet came from. An acceptable solution would be to get the > >> interface by the mac-address, but that can be faked so I would rather get > >> the interface by knowing where the data actually came from. Data is IP, > >> UDP broadcast. > >> I _could_ use raw sockets. The problem is when I do that, the program is > >> using ~8% cpu on a 3.2ghz xeon64 just reading packets without doing > >> anything due to the amount of traffic passing through the box (~200mbit > >> and increasing) so that doesn't look like a good idea. > > > > Why should the app care. If forwarding database is working correctly, the > > source mac > > of the incoming packet will be in the list and any response to it will go > > out that interface. > > > > Well there is no guarantee that the source mac isn't faked. Additionally, > the hardware address of the dhcp client is put inside a dhcp-packet, which > also can be faked. So I am stuck with two hardware addresses that I am > suppposed to believe are correct but have no information about where I > originally received them from. > I can live with this (I guess all the other dhcp servers do that too), but I > can't find a way to map a hardware address to a physical interface when > using bridgemode. I need to know this because the dhcp server will be > limiting the amount of leases you can get per interface (eg max 5 ips per > interface). It will also be assigning static IP-addresses based on what > interface the dhcp packet came from. I will also be using iptables to only > permit the IP+MAC traffic to/from the real physical interface so if you > don't use dhcp at all times, the traffic won't be permitted. > > > > > >> brctl showmacs returns a list of port numbers, but they dont make much > >> sense to me. They do not seem to be in the same order I added the > >> interfaces? Is there a mapping here? > >> > >> Example, > >> jorgen@ams41:/$ /tmp/brctl showmacs test0 > >> port no mac addr is local? ageing timer > >> 2 00:04:e2:a8:3b:d7 no 0.24 > >> 1 00:08:a1:85:39:fd no 17.31 > >> 133 00:0d:88:a3:61:4a no 9.90 > >> 1 00:14:22:b0:cd:e0 yes 0.00 > >> 133 00:16:c7:f5:8f:e2 no 0.48 > >> > >> Port 133 is the 901'th interface (0x385) I added to bridge test0. What > >> does 133 point to? The ifindex of this physical interface is 912 (0x390) > >> (retrieved with SIOCGIFINDEX). > > > > Arbitrary index assigned by bridge for STP usage. Slots get reused as > > ports are deleted and added. > > So there is no way to get the physical interface from a mac address? You can read the forwarding database (see brctl sources for how). But the value can change as result of traffic. From mboxrd@z Thu Jan 1 00:00:00 1970 Message-ID: <004701c63853$74520090$0f01a8c0@tungemaskin> From: =?UTF-8?Q?J=C3=B8rgen_Hovland?= References: <01f701c63728$6203bef0$4a27b3d5@tungemaskin><20060221141743.32d66879@localhost.localdomain><003101c6378b$f5f65060$4a27b3d5@tungemaskin> <20060222080250.363d5e30@localhost.localdomain> Subject: Re: [Bridge] physical interface on a bridge Date: Thu, 23 Feb 2006 09:30:51 +0100 MIME-Version: 1.0 Content-Type: text/plain; format="flowed"; charset="utf-8"; reply-type="original" Content-Transfer-Encoding: 8bit List-Id: Linux Ethernet Bridging List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Stephen Hemminger Cc: bridge@lists.osdl.org ----- Original Message ----- From: "Stephen Hemminger" > On Wed, 22 Feb 2006 09:42:49 +0100 > Jørgen Hovland wrote: > >> So there is no way to get the physical interface from a mac address? > > You can read the forwarding database (see brctl sources for how). > But the value can change as result of traffic. > From mboxrd@z Thu Jan 1 00:00:00 1970 Message-ID: <005601c63854$a2fdace0$0f01a8c0@tungemaskin> From: =?UTF-8?Q?J=C3=B8rgen_Hovland?= References: <01f701c63728$6203bef0$4a27b3d5@tungemaskin><20060221141743.32d66879@localhost.localdomain><003101c6378b$f5f65060$4a27b3d5@tungemaskin> <20060222080250.363d5e30@localhost.localdomain> Subject: Re: [Bridge] physical interface on a bridge Date: Thu, 23 Feb 2006 09:39:18 +0100 MIME-Version: 1.0 Content-Type: text/plain; format="flowed"; charset="utf-8"; reply-type="original" Content-Transfer-Encoding: 8bit List-Id: Linux Ethernet Bridging List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Stephen Hemminger Cc: bridge@lists.osdl.org (sorry about the empty last email) ----- Original Message ----- From: "Stephen Hemminger" > On Wed, 22 Feb 2006 09:42:49 +0100 > Jørgen Hovland wrote: > >> So there is no way to get the physical interface from a mac address? > > You can read the forwarding database (see brctl sources for how). > But the value can change as result of traffic. > I did actually look at the code before I emailed the list. Sorry if I am missing something, but a fdb_entry maps a hardware address to a port number. This arbitary port number points to the port_info structure which seems to only hold information about what bridge it belongs to. And the bridge_info structure doesn't contain any information either. The only place I can find something that might be useful is in linux/netdevice.h and the "struct net_bridge_port *br_port" under the net_device structure. This is inside the kernel as it needs __KERNEL__ defined in order to use it, or is this what I am looking for? Thank you once again Joergen From mboxrd@z Thu Jan 1 00:00:00 1970 Date: Thu, 23 Feb 2006 10:27:31 -0800 From: Stephen Hemminger Subject: Re: [Bridge] physical interface on a bridge Message-ID: <20060223102731.5756f778@localhost.localdomain> In-Reply-To: <005601c63854$a2fdace0$0f01a8c0@tungemaskin> References: <01f701c63728$6203bef0$4a27b3d5@tungemaskin> <20060221141743.32d66879@localhost.localdomain> <003101c6378b$f5f65060$4a27b3d5@tungemaskin> <20060222080250.363d5e30@localhost.localdomain> <005601c63854$a2fdace0$0f01a8c0@tungemaskin> Mime-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit List-Id: Linux Ethernet Bridging List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: =?UTF-8?B?SsO4cmdlbg==?= Hovland Cc: bridge@lists.osdl.org On Thu, 23 Feb 2006 09:39:18 +0100 Jørgen Hovland wrote: > (sorry about the empty last email) > > ----- Original Message ----- > From: "Stephen Hemminger" > > > On Wed, 22 Feb 2006 09:42:49 +0100 > > Jørgen Hovland wrote: > > > >> So there is no way to get the physical interface from a mac address? > > > > You can read the forwarding database (see brctl sources for how). > > But the value can change as result of traffic. > > > > > I did actually look at the code before I emailed the list. Sorry if I am > missing something, but a fdb_entry maps a hardware address to a port number. > This arbitary port number points to the port_info structure which seems to > only hold information about what bridge it belongs to. And the bridge_info > structure doesn't contain any information either. > The only place I can find something that might be useful is in > linux/netdevice.h and the "struct net_bridge_port *br_port" under the > net_device structure. This is inside the kernel as it needs __KERNEL__ > defined in order to use it, or is this what I am looking for? > > Thank you once again > > Joergen The old way is to do ioctl() SIOCDEV_PRIVATE with BRCTL_GET_BRIDGES and that gives a table of ifindices, you can use that to map port -> ifindex -> etherdevice Newer way is to look in directory: /sys/class/net/brX/brif It has symlinks to the devices that are being bridged. /sys/class/net/eth0/brport/port_id contains the portid of eth0 in what ever bridge it is in. From mboxrd@z Thu Jan 1 00:00:00 1970 Message-ID: <00f701c63945$10dc7d90$4a27b3d5@tungemaskin> From: =?utf-8?Q?J=C3=B8rgen_Hovland?= References: <01f701c63728$6203bef0$4a27b3d5@tungemaskin><20060221141743.32d66879@localhost.localdomain><003101c6378b$f5f65060$4a27b3d5@tungemaskin><20060222080250.363d5e30@localhost.localdomain><005601c63854$a2fdace0$0f01a8c0@tungemaskin> <20060223102731.5756f778@localhost.localdomain> Subject: Re: [Bridge] physical interface on a bridge Date: Fri, 24 Feb 2006 14:20:22 +0100 MIME-Version: 1.0 Content-Type: text/plain; format=flowed; charset="utf-8"; reply-type=original Content-Transfer-Encoding: 7bit List-Id: Linux Ethernet Bridging List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Stephen Hemminger Cc: bridge@lists.osdl.org ----- Original Message ----- From: "Stephen Hemminger" > > The old way is to do ioctl() SIOCDEV_PRIVATE with BRCTL_GET_BRIDGES > and that gives a table of ifindices, you can use that to map port -> > ifindex -> etherdevice > > Newer way is to look in directory: > /sys/class/net/brX/brif > It has symlinks to the devices that are being bridged. > /sys/class/net/eth0/brport/port_id > contains the portid of eth0 in what ever bridge it is in. > Works perfectly. Thanks Joergen