Question about using brctl and changing MAC addresses
Subsystems (2)
I'm using Linux 2.6.20 (yes, I'll be upgrading to 2.6.24 as soon as it's stable).
I have 4 VIA rhine ethernet controllers on my Soekris net5501, plus an ADSL PCI card (a Sangoma S-518) that runs in AAL5-SNAP mode, so it looks like an Ethernet controller.
I'm trying to bridge eth0 and w1ad (the ADSL interface) into "br0". And I'm trying to force the traffic on br0 to have the MAC address that my ISP insists I use (i.e. that of the crappy little Westell 6100 modem they sent me).
The issue is the following. If I do:
ifconfig w1ad down hw ether x:x:x:x:x:x up
followed by either:
brctl addbr br0
brctl addif br0 eth0
brctl addif br0 w1ad
or:
brctl addbr br0
brctl addif br0 w1ad
brctl addif br0 eth0
the bridge ends up taking the MAC address of eth0 either way, which I don't get (how does it decide which to use?).
I can clone the same MAC address to both eth0 and w1ad, but I don't know if that would cause me any problems or not (I haven't read the STP spec in about 15 years).
What's the solution?
Is there a way to explicitly set the MAC address of the bridge interface?
I tried:
ifconfig br0 down hw ether x:x:x:x:x:x up
but that just results in:
ifconfig: SIOCSIFHWADDR: Cannot assign requested address
So, I'm not clear what the best solution is.
Any guidance is appreciated.
Thanks,
-Philip
Quoted 28 lines · On Mon, 10 Mar 2008 11:05:53 -0700 Philip Prindeville…
I'm using Linux 2.6.20 (yes, I'll be upgrading to 2.6.24 as soon as it's stable).
I have 4 VIA rhine ethernet controllers on my Soekris net5501, plus an ADSL PCI card (a Sangoma S-518) that runs in AAL5-SNAP mode, so it looks like an Ethernet controller.
I'm trying to bridge eth0 and w1ad (the ADSL interface) into "br0". And I'm trying to force the traffic on br0 to have the MAC address that my ISP insists I use (i.e. that of the crappy little Westell 6100 modem they sent me).
The issue is the following. If I do:
ifconfig w1ad down hw ether x:x:x:x:x:x up
followed by either:
brctl addbr br0
brctl addif br0 eth0
brctl addif br0 w1ador:
brctl addbr br0
brctl addif br0 w1ad
brctl addif br0 eth0
Quoted 7 lines
the bridge ends up taking the MAC address of eth0 either way, which I don't get (how does it decide which to use?).
I can clone the same MAC address to both eth0 and w1ad, but I don't know if that would cause me any problems or not (I haven't read the STP spec in about 15 years).
Having the same mac address on both just is going to be problematic (impossible to do STP), so don't if you don't have to.
But you can set address of bridge and eth0 to any address you want. So set these to the ISP assigned address. You probably will have to do it after bridge is created.
brctl addbr br0
brctl addif br0 w1ad br0
ifconfig eth0 hw ether x:x:x:x:x:x up
ifconfig w1ad up
ifconfig br0 hw ether x:x:x:x:x:x up
ifconfig br0 A.B.C.D netmask 255.255.255.0
Quoted 47 lines · Stephen Hemminger
Quoted 28 lines · On Mon, 10 Mar 2008 11:05:53 -0700 Philip Prindeville…
I'm using Linux 2.6.20 (yes, I'll be upgrading to 2.6.24 as soon as it's stable).
I have 4 VIA rhine ethernet controllers on my Soekris net5501, plus an ADSL PCI card (a Sangoma S-518) that runs in AAL5-SNAP mode, so it looks like an Ethernet controller.
I'm trying to bridge eth0 and w1ad (the ADSL interface) into "br0". And I'm trying to force the traffic on br0 to have the MAC address that my ISP insists I use (i.e. that of the crappy little Westell 6100 modem they sent me).
The issue is the following. If I do:
ifconfig w1ad down hw ether x:x:x:x:x:x up
followed by either:
brctl addbr br0
brctl addif br0 eth0
brctl addif br0 w1ador:
brctl addbr br0
brctl addif br0 w1ad
brctl addif br0 eth0Quoted 8 lines
the bridge ends up taking the MAC address of eth0 either way, which I don't get (how does it decide which to use?).
I can clone the same MAC address to both eth0 and w1ad, but I don't know if that would cause me any problems or not (I haven't read the STP spec in about 15 years).
Having the same mac address on both just is going to be problematic (impossible to do STP), so don't if you don't have to.
But you can set address of bridge and eth0 to any address you want. So set these to the ISP assigned address. You probably will have to do it after bridge is created.
Quoted 8 lines
brctl addbr br0
brctl addif br0 w1ad br0
ifconfig eth0 hw ether x:x:x:x:x:x up
ifconfig w1ad up
ifconfig br0 hw ether x:x:x:x:x:x upifconfig br0 A.B.C.D netmask 255.255.255.0
That seems to not work. I get:
# ifconfig br0 hw ether "00:18:3A:55:15:35" ifconfig: SIOCSIFHWADDR: Cannot assign requested address #
Any ideas why? I'm doing this before an IP address has even been assigned...
-Philip
Quoted 62 lines · Philip Prindeville
Quoted 47 lines · Stephen Hemminger
Quoted 28 lines · On Mon, 10 Mar 2008 11:05:53 -0700 Philip Prindeville…
I'm using Linux 2.6.20 (yes, I'll be upgrading to 2.6.24 as soon as it's stable).
I have 4 VIA rhine ethernet controllers on my Soekris net5501, plus an ADSL PCI card (a Sangoma S-518) that runs in AAL5-SNAP mode, so it looks like an Ethernet controller.
I'm trying to bridge eth0 and w1ad (the ADSL interface) into "br0". And I'm trying to force the traffic on br0 to have the MAC address that my ISP insists I use (i.e. that of the crappy little Westell 6100 modem they sent me).
The issue is the following. If I do:
ifconfig w1ad down hw ether x:x:x:x:x:x up
followed by either:
brctl addbr br0
brctl addif br0 eth0
brctl addif br0 w1ador:
brctl addbr br0
brctl addif br0 w1ad
brctl addif br0 eth0Quoted 8 lines
the bridge ends up taking the MAC address of eth0 either way, which I don't get (how does it decide which to use?).
I can clone the same MAC address to both eth0 and w1ad, but I don't know if that would cause me any problems or not (I haven't read the STP spec in about 15 years).
Having the same mac address on both just is going to be problematic (impossible to do STP), so don't if you don't have to.
But you can set address of bridge and eth0 to any address you want. So set these to the ISP assigned address. You probably will have to do it after bridge is created.Quoted 8 lines
brctl addbr br0
brctl addif br0 w1ad br0
ifconfig eth0 hw ether x:x:x:x:x:x up
ifconfig w1ad up
ifconfig br0 hw ether x:x:x:x:x:x upifconfig br0 A.B.C.D netmask 255.255.255.0
That seems to not work. I get:
# ifconfig br0 hw ether "00:18:3A:55:15:35"
Quoted 10 lines
ifconfig: SIOCSIFHWADDR: Cannot assign requested address
#Any ideas why? I'm doing this before an IP address has even been assigned...
-Philip
Was the interface reported as 'UP' by ifconfig?
Quoted 62 lines · On Wed, 12 Mar 2008 10:46:48 -0400 "Andy Gospodarek" <[email protected]> wrote:
Quoted 60 lines · Philip Prindeville
Quoted 47 lines · Stephen Hemminger
Quoted 28 lines · On Mon, 10 Mar 2008 11:05:53 -0700 Philip Prindeville…
I'm using Linux 2.6.20 (yes, I'll be upgrading to 2.6.24 as soon as it's stable).
I have 4 VIA rhine ethernet controllers on my Soekris net5501, plus an ADSL PCI card (a Sangoma S-518) that runs in AAL5-SNAP mode, so it looks like an Ethernet controller.
I'm trying to bridge eth0 and w1ad (the ADSL interface) into "br0". And I'm trying to force the traffic on br0 to have the MAC address that my ISP insists I use (i.e. that of the crappy little Westell 6100 modem they sent me).
The issue is the following. If I do:
ifconfig w1ad down hw ether x:x:x:x:x:x up
followed by either:
brctl addbr br0
brctl addif br0 eth0
brctl addif br0 w1ador:
brctl addbr br0
brctl addif br0 w1ad
brctl addif br0 eth0Quoted 8 lines
the bridge ends up taking the MAC address of eth0 either way, which I don't get (how does it decide which to use?).
I can clone the same MAC address to both eth0 and w1ad, but I don't know if that would cause me any problems or not (I haven't read the STP spec in about 15 years).
Having the same mac address on both just is going to be problematic (impossible to do STP), so don't if you don't have to.
But you can set address of bridge and eth0 to any address you want. So set these to the ISP assigned address. You probably will have to do it after bridge is created.Quoted 8 lines
brctl addbr br0
brctl addif br0 w1ad br0
ifconfig eth0 hw ether x:x:x:x:x:x up
ifconfig w1ad up
ifconfig br0 hw ether x:x:x:x:x:x upifconfig br0 A.B.C.D netmask 255.255.255.0
That seems to not work. I get:
Quoted 7 lines
Quoted 7 lines
# ifconfig br0 hw ether "00:18:3A:55:15:35"ifconfig: SIOCSIFHWADDR: Cannot assign requested address
#Any ideas why? I'm doing this before an IP address has even been assigned...
Assign the hardware address of the bridge was only added in later kernels.
Quoted 68 lines · Stephen Hemminger
Quoted 64 lines · On Wed, 12 Mar 2008 10:46:48 -0400 "Andy Gospodarek" <[email protected]> wrote:
Quoted 61 lines · Philip Prindeville
Quoted 47 lines · Stephen Hemminger
Quoted 28 lines · On Mon, 10 Mar 2008 11:05:53 -0700 Philip Prindeville…
I'm using Linux 2.6.20 (yes, I'll be upgrading to 2.6.24 as soon as it's stable).
I have 4 VIA rhine ethernet controllers on my Soekris net5501, plus an ADSL PCI card (a Sangoma S-518) that runs in AAL5-SNAP mode, so it looks like an Ethernet controller.
I'm trying to bridge eth0 and w1ad (the ADSL interface) into "br0". And I'm trying to force the traffic on br0 to have the MAC address that my ISP insists I use (i.e. that of the crappy little Westell 6100 modem they sent me).
The issue is the following. If I do:
ifconfig w1ad down hw ether x:x:x:x:x:x up
followed by either:
brctl addbr br0
brctl addif br0 eth0
brctl addif br0 w1ador:
brctl addbr br0
brctl addif br0 w1ad
brctl addif br0 eth0Quoted 8 lines
the bridge ends up taking the MAC address of eth0 either way, which I don't get (how does it decide which to use?).
I can clone the same MAC address to both eth0 and w1ad, but I don't know if that would cause me any problems or not (I haven't read the STP spec in about 15 years).
Having the same mac address on both just is going to be problematic (impossible to do STP), so don't if you don't have to.
But you can set address of bridge and eth0 to any address you want. So set these to the ISP assigned address. You probably will have to do it after bridge is created.Quoted 8 lines
brctl addbr br0
brctl addif br0 w1ad br0
ifconfig eth0 hw ether x:x:x:x:x:x up
ifconfig w1ad up
ifconfig br0 hw ether x:x:x:x:x:x upifconfig br0 A.B.C.D netmask 255.255.255.0
That seems to not work. I get:
# ifconfig br0 hw ether "00:18:3A:55:15:35"
Quoted 9 lines
Quoted 6 lines
Quoted 6 lines
ifconfig: SIOCSIFHWADDR: Cannot assign requested address
#Any ideas why? I'm doing this before an IP address has even been assigned...
Assign the hardware address of the bridge was only added in later kernels.
Later being which kernel?
And to answer the earlier question, I was doing:
ifconfig brX down hw ether x:x:x:x:x:x up
so yes, the interface was down when I tried to change its address.
-Philip
Quoted 73 lines · Philip Prindeville
Quoted 71 lines · Stephen Hemminger
Quoted 67 lines · On Wed, 12 Mar 2008 10:46:48 -0400 "Andy Gospodarek" <[email protected]> wrote:
Quoted 64 lines · Philip Prindeville
Quoted 47 lines · Stephen Hemminger
Quoted 28 lines · On Mon, 10 Mar 2008 11:05:53 -0700 Philip Prindeville…
I'm using Linux 2.6.20 (yes, I'll be upgrading to 2.6.24 as soon as it's stable).
I have 4 VIA rhine ethernet controllers on my Soekris net5501, plus an ADSL PCI card (a Sangoma S-518) that runs in AAL5-SNAP mode, so it looks like an Ethernet controller.
I'm trying to bridge eth0 and w1ad (the ADSL interface) into "br0". And I'm trying to force the traffic on br0 to have the MAC address that my ISP insists I use (i.e. that of the crappy little Westell 6100 modem they sent me).
The issue is the following. If I do:
ifconfig w1ad down hw ether x:x:x:x:x:x up
followed by either:
brctl addbr br0
brctl addif br0 eth0
brctl addif br0 w1ador:
brctl addbr br0
brctl addif br0 w1ad
brctl addif br0 eth0Quoted 8 lines
the bridge ends up taking the MAC address of eth0 either way, which I don't get (how does it decide which to use?).
I can clone the same MAC address to both eth0 and w1ad, but I don't know if that would cause me any problems or not (I haven't read the STP spec in about 15 years).
Having the same mac address on both just is going to be problematic (impossible to do STP), so don't if you don't have to.
But you can set address of bridge and eth0 to any address you want. So set these to the ISP assigned address. You probably will have to do it after bridge is created.Quoted 8 lines
brctl addbr br0
brctl addif br0 w1ad br0
ifconfig eth0 hw ether x:x:x:x:x:x up
ifconfig w1ad up
ifconfig br0 hw ether x:x:x:x:x:x upifconfig br0 A.B.C.D netmask 255.255.255.0
That seems to not work. I get:
# ifconfig br0 hw ether "00:18:3A:55:15:35"ifconfig: SIOCSIFHWADDR: Cannot assign requested address
#
Quoted 8 lines
Quoted 6 lines
Quoted 3 lines
Quoted 3 lines
Any ideas why? I'm doing this before an IP address has even been assigned...
Assign the hardware address of the bridge was only added in later kernels.
Later being which kernel?
It looks like this commit did it:
commit 4505a3ef720845b5db3ddb440de13cd4800fd508
Author: Stephen Hemminger <[email protected]> Date: Wed Dec 21 18:51:49 2005 -0800
[BRIDGE]: allow setting hardware address of bridge pseudo-dev
Some people are using bridging to hide multiple machines from an ISP that restricts by MAC address. So in that case allow the bridge mac address to be set to any of the existing interfaces. I don't want to allow any arbitrary value and confuse STP.
So that should mean it is in 2.6.15 and later (presuming this patch added all the needed functionality).
Quoted 10 lines
And to answer the earlier question, I was doing:
ifconfig brX down hw ether x:x:x:x:x:x up
so yes, the interface was down when I tried to change its address.
-Philip
Quoted 98 lines · Andy Gospodarek
Quoted 72 lines · Philip Prindeville
Quoted 71 lines · Stephen Hemminger
Quoted 67 lines · On Wed, 12 Mar 2008 10:46:48 -0400 "Andy Gospodarek" <[email protected]> wrote:
Quoted 64 lines · Philip Prindeville
Quoted 47 lines · Stephen Hemminger
Quoted 28 lines · On Mon, 10 Mar 2008 11:05:53 -0700 Philip Prindeville…
I'm using Linux 2.6.20 (yes, I'll be upgrading to 2.6.24 as soon as it's stable).
I have 4 VIA rhine ethernet controllers on my Soekris net5501, plus an ADSL PCI card (a Sangoma S-518) that runs in AAL5-SNAP mode, so it looks like an Ethernet controller.
I'm trying to bridge eth0 and w1ad (the ADSL interface) into "br0". And I'm trying to force the traffic on br0 to have the MAC address that my ISP insists I use (i.e. that of the crappy little Westell 6100 modem they sent me).
The issue is the following. If I do:
ifconfig w1ad down hw ether x:x:x:x:x:x up
followed by either:
brctl addbr br0
brctl addif br0 eth0
brctl addif br0 w1ador:
brctl addbr br0
brctl addif br0 w1ad
brctl addif br0 eth0Quoted 8 lines
the bridge ends up taking the MAC address of eth0 either way, which I don't get (how does it decide which to use?).
I can clone the same MAC address to both eth0 and w1ad, but I don't know if that would cause me any problems or not (I haven't read the STP spec in about 15 years).
Having the same mac address on both just is going to be problematic (impossible to do STP), so don't if you don't have to.
But you can set address of bridge and eth0 to any address you want. So set these to the ISP assigned address. You probably will have to do it after bridge is created.Quoted 8 lines
brctl addbr br0
brctl addif br0 w1ad br0
ifconfig eth0 hw ether x:x:x:x:x:x up
ifconfig w1ad up
ifconfig br0 hw ether x:x:x:x:x:x upifconfig br0 A.B.C.D netmask 255.255.255.0
That seems to not work. I get:
# ifconfig br0 hw ether "00:18:3A:55:15:35"ifconfig: SIOCSIFHWADDR: Cannot assign requested address
#Quoted 9 lines
Quoted 6 lines
Quoted 3 lines
Quoted 3 lines
Any ideas why? I'm doing this before an IP address has even been assigned...
Assign the hardware address of the bridge was only added in later kernels.
Later being which kernel?
It looks like this commit did it:
commit
4505a3ef720845b5db3ddb440de13cd4800fd508Author: Stephen Hemminger <[email protected]> Date: Wed Dec 21 18:51:49 2005 -0800[BRIDGE]: allow setting hardware address of bridge pseudo-dev
Some people are using bridging to hide multiple machines from an ISP that restricts by MAC address. So in that case allow the bridge mac address to be set to any of the existing interfaces. I don't want to allow any arbitrary value and confuse STP.
Quoted 6 lines
Signed-off-by Stephen Hemminger <[email protected]>Signed-off-by David S. Miller <[email protected]>So that should mean it is in 2.6.15 and later (presuming this patch added all the needed functionality).
Well, I don't get it then.
I'm running Linux 2.6.20, with bridge-utils-1.2, and I'm still seeing it.
Can you send me the link to the patch, and I'll make sure it's in my sources?
Thanks,
-Philip
Quoted 12 lines
Quoted 12 lines
And to answer the earlier question, I was doing:
ifconfig brX down hw ether x:x:x:x:x:x up
so yes, the interface was down when I tried to change its address.
-Philip
Philip, sorry for the duplicate email. Forgot to CC the list the first time.
Perhaps the needed patch is the following, which allows setting the bridge hardware address to anything rather than just one of the port interface addresses. Seems to have got in after Linux 2.6.21, so should be in 2.6.22.
[~/git/linux-2.6] git-describe ffe1d49cc300f3dff990093aa952a2fbb371c1b6 v2.6.21-324-gffe1d49
[~/git/linux-2.6] git-diff-tree -p --pretty=fuller ffe1d49cc300f3dff990093aa952a2fbb371c1b6 commit ffe1d49cc300f3dff990093aa952a2fbb371c1b6
Author: Stephen Hemminger <[email protected]> AuthorDate: Mon Apr 9 11:49:58 2007 -0700 Commit: David S. Miller <[email protected]> CommitDate: Wed Apr 25 22:28:50 2007 -0700
bridge: allow changing hardware address to any valid address
For case of bridging pseudo devices, the get created/destroyed (Xen) need to allow setting address to any valid value.
net/bridge/br_device.c +0 -0
@@ -83,27 +83,22 @@ static int br_change_mtu(struct net_device *dev,
int new_mtu)
return 0;
}
-/* Allow setting mac address of pseudo-bridge to be same as
- * any of the bound interfaces
- */
+/* Allow setting mac address to any valid ethernet address. */
static int br_set_mac_address(struct net_device *dev, void *p)
{
struct net_bridge *br = netdev_priv(dev);
struct sockaddr *addr = p;
struct net_bridge_port *port;- int err = -EADDRNOTAVAIL;
+
+ if (!is_valid_ether_addr(addr->sa_data))
+ return -EINVAL;
spin_lock_bh(&br->lock);
- list_for_each_entry(port, &br->port_list, list) {
- if (!compare_ether_addr(port->dev->dev_addr, addr->sa_data)) {
- br_stp_change_bridge_id(br, addr->sa_data);
- err = 0;
- break;
- }
- }
+ memcpy(dev->dev_addr, addr->sa_data, ETH_ALEN);
+ br_stp_change_bridge_id(br, addr->sa_data);
spin_unlock_bh(&br->lock);- return err;
+ return 0;
}
static void br_getinfo(struct net_device *dev, struct ethtool_drvinfo *info)
Quoted 11 lines · Philip Prindeville
Well, I don't get it then.
I'm running Linux 2.6.20, with bridge-utils-1.2, and I'm still seeing it.
Can you send me the link to the patch, and I'll make sure it's in my sources?
Thanks,
-Philip
Quoted 60 lines · Srinivas M.A.
Philip, sorry for the duplicate email. Forgot to CC the list the first time.
Perhaps the needed patch is the following, which allows setting the bridge hardware address to anything rather than just one of the port interface addresses. Seems to have got in after Linux 2.6.21, so should be in 2.6.22.
[~/git/linux-2.6] git-describe
ffe1d49cc300f3dff990093aa952a2fbb371c1b6v2.6.21-324-gffe1d49[~/git/linux-2.6] git-diff-tree -p --pretty=fuller
ffe1d49cc300f3dff990093aa952a2fbb371c1b6commitffe1d49cc300f3dff990093aa952a2fbb371c1b6
Author: Stephen Hemminger <[email protected]>
AuthorDate: Mon Apr 9 11:49:58 2007 -0700
Commit: David S. Miller <[email protected]>
CommitDate: Wed Apr 25 22:28:50 2007 -0700bridge: allow changing hardware address to any valid address
For case of bridging pseudo devices, the get created/destroyed (Xen) need to allow setting address to any valid value.
Signed-off-by Stephen Hemminger <[email protected]>diff --git
a/net/bridge/br_device.cb/net/bridge/br_device.cindex b22ada5..39b87da 100644
---a/net/bridge/br_device.c
+++b/net/bridge/br_device.c
@@ -83,27 +83,22 @@ static intbr_change_mtu(struct net_device *dev, int new_mtu)return 0;}
-/* Allow setting mac address of pseudo-bridge to be same as
- * any of the bound interfaces
- */
+/* Allow setting mac address to any valid ethernet address. */
static intbr_set_mac_address(struct net_device *dev, void *p){ struct net_bridge *br = netdev_priv(dev); struct sockaddr *addr = p; struct net_bridge_port *port;- int err =
-EADDRNOTAVAIL;
+
+ if (!is_valid_ether_addr(addr->sa_data))
+ return-EINVAL;spin_lock_bh(&br->lock); - list_for_each_entry(port, &br->port_list, list) { - if (!compare_ether_addr(port->dev->dev_addr, addr->sa_data)) { - br_stp_change_bridge_id(br, addr->sa_data); - err = 0; - break; - } - } + memcpy(dev->dev_addr, addr->sa_data, ETH_ALEN); + br_stp_change_bridge_id(br, addr->sa_data); spin_unlock_bh(&br->lock);
Quoted 6 lines
- return err;
+ return 0;
}static void
br_getinfo(struct net_device *dev, struct ethtool_drvinfo *info)
Thanks, Srinivas! There's the 'additional' patch I was referencing. :-)
A message that is not in the archive (sent off-list or not yet received): [email protected]
A message that is not in the archive (sent off-list or not yet received): [email protected]
Searching for the commit by name on kernel.org:
http://git.kernel.org/?p=linux%2Fkernel%2Fgit%2Ftorvalds%2Flinux-2.6.git&a=search&h=v2.6.22-rc1&st=commit&s=allow+changing+hardware+address+to+any+valid+address
and then the link to the commit page itself (from the search results):
http://git.kernel.org/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=ffe1d49cc300f3dff990093aa952a2fbb371c1b6
Go to the "commitdiff" link and then "raw" which will give you the file you can use as a patch.
Quoted 5 lines · Philip Prindeville
Thanks. Can you send me a link so I can download it?
-Philip