aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/wimax
diff options
context:
space:
mode:
authorInaky Perez-Gonzalez <inaky@linux.intel.com>2009-04-22 19:53:08 -0400
committerInaky Perez-Gonzalez <inaky@linux.intel.com>2009-05-28 21:01:24 -0400
commitfe442683853a2c0863b700acc4328b4d73090206 (patch)
treebd65e359b36f02c92819dc488eae0c981c09bc5f /drivers/net/wimax
parent7d18f114897ff4358419b14d551e704a4299a440 (diff)
wimax/i2400m: generate fake source MAC address with random_ether_addr()
The WiMAX i2400m driver needs to generate a fake source MAC address to fake an ethernet header (for destination, the card's MAC is used). This is the source of the packet, which is the basestation it came from. The basestation's mac address is not usable for this, as it uses its own namespace and it is not always available. Currently the fake source MAC address was being set to all zeros, which was causing trouble with bridging. Use random_ether_addr() to generate a proper one that creates no trouble. Signed-off-by: Inaky Perez-Gonzalez <inaky@linux.intel.com>
Diffstat (limited to 'drivers/net/wimax')
-rw-r--r--drivers/net/wimax/i2400m/driver.c2
-rw-r--r--drivers/net/wimax/i2400m/i2400m.h5
-rw-r--r--drivers/net/wimax/i2400m/netdev.c4
3 files changed, 10 insertions, 1 deletions
diff --git a/drivers/net/wimax/i2400m/driver.c b/drivers/net/wimax/i2400m/driver.c
index 07a54bad237..a21318b34bf 100644
--- a/drivers/net/wimax/i2400m/driver.c
+++ b/drivers/net/wimax/i2400m/driver.c
@@ -62,6 +62,7 @@
62 * unregister_netdev() 62 * unregister_netdev()
63 */ 63 */
64#include "i2400m.h" 64#include "i2400m.h"
65#include <linux/etherdevice.h>
65#include <linux/wimax/i2400m.h> 66#include <linux/wimax/i2400m.h>
66#include <linux/module.h> 67#include <linux/module.h>
67#include <linux/moduleparam.h> 68#include <linux/moduleparam.h>
@@ -650,6 +651,7 @@ int i2400m_setup(struct i2400m *i2400m, enum i2400m_bri bm_flags)
650 result = i2400m_read_mac_addr(i2400m); 651 result = i2400m_read_mac_addr(i2400m);
651 if (result < 0) 652 if (result < 0)
652 goto error_read_mac_addr; 653 goto error_read_mac_addr;
654 random_ether_addr(i2400m->src_mac_addr);
653 655
654 result = register_netdev(net_dev); /* Okey dokey, bring it up */ 656 result = register_netdev(net_dev); /* Okey dokey, bring it up */
655 if (result < 0) { 657 if (result < 0) {
diff --git a/drivers/net/wimax/i2400m/i2400m.h b/drivers/net/wimax/i2400m/i2400m.h
index 3ae2df38b59..434ba310c2f 100644
--- a/drivers/net/wimax/i2400m/i2400m.h
+++ b/drivers/net/wimax/i2400m/i2400m.h
@@ -323,6 +323,10 @@ struct i2400m_roq;
323 * delivered. Then the driver can release them to the host. See 323 * delivered. Then the driver can release them to the host. See
324 * drivers/net/i2400m/rx.c for details. 324 * drivers/net/i2400m/rx.c for details.
325 * 325 *
326 * @src_mac_addr: MAC address used to make ethernet packets be coming
327 * from. This is generated at i2400m_setup() time and used during
328 * the life cycle of the instance. See i2400m_fake_eth_header().
329 *
326 * @init_mutex: Mutex used for serializing the device bringup 330 * @init_mutex: Mutex used for serializing the device bringup
327 * sequence; this way if the device reboots in the middle, we 331 * sequence; this way if the device reboots in the middle, we
328 * don't try to do a bringup again while we are tearing down the 332 * don't try to do a bringup again while we are tearing down the
@@ -421,6 +425,7 @@ struct i2400m {
421 unsigned rx_pl_num, rx_pl_max, rx_pl_min, 425 unsigned rx_pl_num, rx_pl_max, rx_pl_min,
422 rx_num, rx_size_acc, rx_size_min, rx_size_max; 426 rx_num, rx_size_acc, rx_size_min, rx_size_max;
423 struct i2400m_roq *rx_roq; /* not under rx_lock! */ 427 struct i2400m_roq *rx_roq; /* not under rx_lock! */
428 u8 src_mac_addr[ETH_HLEN];
424 429
425 struct mutex msg_mutex; /* serialize command execution */ 430 struct mutex msg_mutex; /* serialize command execution */
426 struct completion msg_completion; 431 struct completion msg_completion;
diff --git a/drivers/net/wimax/i2400m/netdev.c b/drivers/net/wimax/i2400m/netdev.c
index 6b1fe7a81f2..9653f478b38 100644
--- a/drivers/net/wimax/i2400m/netdev.c
+++ b/drivers/net/wimax/i2400m/netdev.c
@@ -404,10 +404,12 @@ static
404void i2400m_rx_fake_eth_header(struct net_device *net_dev, 404void i2400m_rx_fake_eth_header(struct net_device *net_dev,
405 void *_eth_hdr, __be16 protocol) 405 void *_eth_hdr, __be16 protocol)
406{ 406{
407 struct i2400m *i2400m = net_dev_to_i2400m(net_dev);
407 struct ethhdr *eth_hdr = _eth_hdr; 408 struct ethhdr *eth_hdr = _eth_hdr;
408 409
409 memcpy(eth_hdr->h_dest, net_dev->dev_addr, sizeof(eth_hdr->h_dest)); 410 memcpy(eth_hdr->h_dest, net_dev->dev_addr, sizeof(eth_hdr->h_dest));
410 memset(eth_hdr->h_source, 0, sizeof(eth_hdr->h_dest)); 411 memcpy(eth_hdr->h_source, i2400m->src_mac_addr,
412 sizeof(eth_hdr->h_source));
411 eth_hdr->h_proto = protocol; 413 eth_hdr->h_proto = protocol;
412} 414}
413 415