Commit fe442683 authored by Inaky Perez-Gonzalez's avatar Inaky Perez-Gonzalez

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: default avatarInaky Perez-Gonzalez <inaky@linux.intel.com>
parent 7d18f114
...@@ -62,6 +62,7 @@ ...@@ -62,6 +62,7 @@
* unregister_netdev() * unregister_netdev()
*/ */
#include "i2400m.h" #include "i2400m.h"
#include <linux/etherdevice.h>
#include <linux/wimax/i2400m.h> #include <linux/wimax/i2400m.h>
#include <linux/module.h> #include <linux/module.h>
#include <linux/moduleparam.h> #include <linux/moduleparam.h>
...@@ -650,6 +651,7 @@ int i2400m_setup(struct i2400m *i2400m, enum i2400m_bri bm_flags) ...@@ -650,6 +651,7 @@ int i2400m_setup(struct i2400m *i2400m, enum i2400m_bri bm_flags)
result = i2400m_read_mac_addr(i2400m); result = i2400m_read_mac_addr(i2400m);
if (result < 0) if (result < 0)
goto error_read_mac_addr; goto error_read_mac_addr;
random_ether_addr(i2400m->src_mac_addr);
result = register_netdev(net_dev); /* Okey dokey, bring it up */ result = register_netdev(net_dev); /* Okey dokey, bring it up */
if (result < 0) { if (result < 0) {
......
...@@ -323,6 +323,10 @@ struct i2400m_roq; ...@@ -323,6 +323,10 @@ struct i2400m_roq;
* delivered. Then the driver can release them to the host. See * delivered. Then the driver can release them to the host. See
* drivers/net/i2400m/rx.c for details. * drivers/net/i2400m/rx.c for details.
* *
* @src_mac_addr: MAC address used to make ethernet packets be coming
* from. This is generated at i2400m_setup() time and used during
* the life cycle of the instance. See i2400m_fake_eth_header().
*
* @init_mutex: Mutex used for serializing the device bringup * @init_mutex: Mutex used for serializing the device bringup
* sequence; this way if the device reboots in the middle, we * sequence; this way if the device reboots in the middle, we
* don't try to do a bringup again while we are tearing down the * don't try to do a bringup again while we are tearing down the
...@@ -421,6 +425,7 @@ struct i2400m { ...@@ -421,6 +425,7 @@ struct i2400m {
unsigned rx_pl_num, rx_pl_max, rx_pl_min, unsigned rx_pl_num, rx_pl_max, rx_pl_min,
rx_num, rx_size_acc, rx_size_min, rx_size_max; rx_num, rx_size_acc, rx_size_min, rx_size_max;
struct i2400m_roq *rx_roq; /* not under rx_lock! */ struct i2400m_roq *rx_roq; /* not under rx_lock! */
u8 src_mac_addr[ETH_HLEN];
struct mutex msg_mutex; /* serialize command execution */ struct mutex msg_mutex; /* serialize command execution */
struct completion msg_completion; struct completion msg_completion;
......
...@@ -404,10 +404,12 @@ static ...@@ -404,10 +404,12 @@ static
void i2400m_rx_fake_eth_header(struct net_device *net_dev, void i2400m_rx_fake_eth_header(struct net_device *net_dev,
void *_eth_hdr, __be16 protocol) void *_eth_hdr, __be16 protocol)
{ {
struct i2400m *i2400m = net_dev_to_i2400m(net_dev);
struct ethhdr *eth_hdr = _eth_hdr; struct ethhdr *eth_hdr = _eth_hdr;
memcpy(eth_hdr->h_dest, net_dev->dev_addr, sizeof(eth_hdr->h_dest)); memcpy(eth_hdr->h_dest, net_dev->dev_addr, sizeof(eth_hdr->h_dest));
memset(eth_hdr->h_source, 0, sizeof(eth_hdr->h_dest)); memcpy(eth_hdr->h_source, i2400m->src_mac_addr,
sizeof(eth_hdr->h_source));
eth_hdr->h_proto = protocol; eth_hdr->h_proto = protocol;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment