Skip to contentSkip to conversation

rt2x00: Use addr_mask to catch invalid MAC addresses

PATCH In review Helmut Schaa 3 participants 6 messages Nov 27, 2012 – Nov 28, 2012 1 message not in the archive Networking drivers (wireless)

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 rt2x00: Use addr_mask to catch invalid MAC addresses

This ensures that a user cannot accidentally set up a virtual interface with a MAC address the rt2800 hw cannot handle.

---
 drivers/net/wireless/rt2x00/rt2800lib.c |    3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)
drivers/net/wireless/rt2x00/rt2800lib.c +3 -0
index c0441a7..7f0df12 100644
@@ -5108,6 +5108,9 @@ static int rt2800_probe_hw_mode(struct rt2x00_dev *rt2x00dev)
 				rt2x00_eeprom_addr(rt2x00dev,
 						   EEPROM_MAC_ADDR_0));
 
+	/* Only the last three bits are variable in rt2800 devices. */
+	rt2x00dev->hw->wiphy->addr_mask[ETH_ALEN - 1] = 0x7;
+
 	/*
 	 * As rt2800 has a global fallback table we cannot specify
 	 * more then one tx rate per frame but since the hw will
Signature · 1 line
1.7.7

A message that is not in the archive (sent off-list or not yet received): CAOZOX0XN+pd7k-WQ0U1Vs=+21wyUmEDMJVJHekAj2NvmZfaJTg@mail.gmail.com

#2 lore raw

Hi Ivo,

Quoted 21 lines · Ivo Van Doorn

Hi,

Quoted 19 lines

This ensures that a user cannot accidentally set up a virtual interface with a MAC address the rt2800 hw cannot handle.

---
 drivers/net/wireless/rt2x00/rt2800lib.c |    3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)
drivers/net/wireless/rt2x00/rt2800lib.c +0 -0
index c0441a7..7f0df12 100644
@@ -5108,6 +5108,9 @@ static int rt2800_probe_hw_mode(struct rt2x00_dev
 *rt2x00dev)
                                rt2x00_eeprom_addr(rt2x00dev,
                                                   EEPROM_MAC_ADDR_0));
 
Quoted 5 lines

drivers/net/wireless/rt2x00/rt2800lib.c static int rt2800_probe_hw_mode(struct rt2x00_dev *rt2x00dev) · line 5112

Quoted 2 lines
drivers/net/wireless/rt2x00/rt2800lib.c +2 -0
+       /* Only the last three bits are variable in rt2800 devices. */
+       rt2x00dev->hw->wiphy->addr_mask[ETH_ALEN - 1] = 0x7;

Shouldn't this be added for rt61pci and rt73usb as well?

I'm not 100% sure if the same is true in rt61pci and rt73usb. Are they also using an
address mask?

Thanks,
Helmut

#3 lore raw
Quoted 5 lines · Helmut Schaa
Quoted 1 line

Shouldn't this be added for rt61pci and rt73usb as well?

I'm not 100% sure if the same is true in rt61pci and rt73usb. Are they also using an
address mask?

Hmm, I think Ivo is right. We should add the same for rt61pci and rt73usb but they only support the last two bits to be used. Hence an address mask of 0x3.

I'll send a follow-up.

Helmut

#4 lore raw

PATCH v2 1/1 rt2x00: Use addr_mask to disallow invalid MAC addresses in mutli-bssid mode

In reply to Helmut Schaa
---
 drivers/net/wireless/rt2x00/rt2x00dev.c |    7 +++++++
 1 files changed, 7 insertions(+), 0 deletions(-)
drivers/net/wireless/rt2x00/rt2x00dev.c +7 -0
index 69097d1..f9d9754 100644
@@ -1182,6 +1182,13 @@ int rt2x00lib_probe_dev(struct rt2x00_dev *rt2x00dev)
 	rt2x00dev->hw->vif_data_size = sizeof(struct rt2x00_intf);
 
 	/*
+	 * rt2x00 devices can only use the last n bits of the MAC address
+	 * for virtual interfaces.
+	 */
+	rt2x00dev->hw->wiphy->addr_mask[ETH_ALEN - 1] =
+		(rt2x00dev->ops->max_ap_intf - 1);
+
+	/*
 	 * Determine which operating modes are supported, all modes
 	 * which require beaconing, depend on the availability of
 	 * beacon entries.
Signature · 1 line
1.7.7
Acked-by on v2 1/1
#5 lore raw

Re: [PATCHv2] rt2x00: Use addr_mask to disallow invalid MAC addresses in mutli-bssid mode

Quoted 2 lines · Helmut Schaa
Quoted 25 lines
---
 drivers/net/wireless/rt2x00/rt2x00dev.c |    7 +++++++
 1 files changed, 7 insertions(+), 0 deletions(-)
drivers/net/wireless/rt2x00/rt2x00dev.c +7 -1
index 69097d1..f9d9754 100644
@@ -1182,6 +1182,13 @@ int rt2x00lib_probe_dev(struct rt2x00_dev *rt2x00dev)
        rt2x00dev->hw->vif_data_size = sizeof(struct rt2x00_intf);
 
        /*
+        * rt2x00 devices can only use the last n bits of the MAC address
+        * for virtual interfaces.
+        */
+       rt2x00dev->hw->wiphy->addr_mask[ETH_ALEN - 1] =
+               (rt2x00dev->ops->max_ap_intf - 1);
+
+       /*
         * Determine which operating modes are supported, all modes
         * which require beaconing, depend on the availability of
         * beacon entries.
--

1.7.7

Signature · 2 lines
---
Gertjan
Acked-by on v2 1/1
#6 lore raw

Re: [PATCHv2] rt2x00: Use addr_mask to disallow invalid MAC addresses in mutli-bssid mode

In reply to Helmut Schaa

Hi,

Quoted 2 lines
Quoted 25 lines
---
 drivers/net/wireless/rt2x00/rt2x00dev.c |    7 +++++++
 1 files changed, 7 insertions(+), 0 deletions(-)
drivers/net/wireless/rt2x00/rt2x00dev.c +7 -1
index 69097d1..f9d9754 100644
@@ -1182,6 +1182,13 @@ int rt2x00lib_probe_dev(struct rt2x00_dev *rt2x00dev)
        rt2x00dev->hw->vif_data_size = sizeof(struct rt2x00_intf);
 
        /*
+        * rt2x00 devices can only use the last n bits of the MAC address
+        * for virtual interfaces.
+        */
+       rt2x00dev->hw->wiphy->addr_mask[ETH_ALEN - 1] =
+               (rt2x00dev->ops->max_ap_intf - 1);
+
+       /*
         * Determine which operating modes are supported, all modes
         * which require beaconing, depend on the availability of
         * beacon entries.
--

1.7.7