From: Inaky Perez-Gonzalez <inaky@linux.intel.com>
To: netdev@vger.kernel.org, wimax@linuxwimax.org
Subject: [patch 2.6.31 01/10] wimax/i2400m: generate fake source MAC address with random_ether_addr()
Date: Wed, 27 May 2009 18:05:06 -0700 [thread overview]
Message-ID: <e9de4b9426eeeddf56110425cfd88e43828e7146.1243472510.git.inaky@linux.intel.com> (raw)
In-Reply-To: <cover.1243472509.git.inaky@linux.intel.com>
In-Reply-To: <cover.1243472509.git.inaky@linux.intel.com>
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>
---
drivers/net/wimax/i2400m/driver.c | 2 ++
drivers/net/wimax/i2400m/i2400m.h | 5 +++++
drivers/net/wimax/i2400m/netdev.c | 3 ++-
3 files changed, 9 insertions(+), 1 deletions(-)
diff --git a/drivers/net/wimax/i2400m/driver.c b/drivers/net/wimax/i2400m/driver.c
index 07a54ba..a21318b 100644
--- a/drivers/net/wimax/i2400m/driver.c
+++ b/drivers/net/wimax/i2400m/driver.c
@@ -62,6 +62,7 @@
* unregister_netdev()
*/
#include "i2400m.h"
+#include <linux/etherdevice.h>
#include <linux/wimax/i2400m.h>
#include <linux/module.h>
#include <linux/moduleparam.h>
@@ -650,6 +651,7 @@ int i2400m_setup(struct i2400m *i2400m, enum i2400m_bri bm_flags)
result = i2400m_read_mac_addr(i2400m);
if (result < 0)
goto error_read_mac_addr;
+ random_ether_addr(i2400m->src_mac_addr);
result = register_netdev(net_dev); /* Okey dokey, bring it up */
if (result < 0) {
diff --git a/drivers/net/wimax/i2400m/i2400m.h b/drivers/net/wimax/i2400m/i2400m.h
index 3ae2df3..434ba31 100644
--- a/drivers/net/wimax/i2400m/i2400m.h
+++ b/drivers/net/wimax/i2400m/i2400m.h
@@ -323,6 +323,10 @@ struct i2400m_roq;
* delivered. Then the driver can release them to the host. See
* 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
* 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
@@ -421,6 +425,7 @@ struct i2400m {
unsigned rx_pl_num, rx_pl_max, rx_pl_min,
rx_num, rx_size_acc, rx_size_min, rx_size_max;
struct i2400m_roq *rx_roq; /* not under rx_lock! */
+ u8 src_mac_addr[ETH_HLEN];
struct mutex msg_mutex; /* serialize command execution */
struct completion msg_completion;
diff --git a/drivers/net/wimax/i2400m/netdev.c b/drivers/net/wimax/i2400m/netdev.c
index 6b1fe7a..af81d27 100644
--- a/drivers/net/wimax/i2400m/netdev.c
+++ b/drivers/net/wimax/i2400m/netdev.c
@@ -404,10 +404,11 @@ static
void i2400m_rx_fake_eth_header(struct net_device *net_dev,
void *_eth_hdr, __be16 protocol)
{
+ struct i2400m *i2400m = net_dev_to_i2400m(net_dev);
struct ethhdr *eth_hdr = _eth_hdr;
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;
}
--
1.6.2.3
next prev parent reply other threads:[~2009-05-28 1:05 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-05-28 1:05 [patch 2.6.31 00/10] WiMAX pull request Inaky Perez-Gonzalez
2009-05-28 1:05 ` Inaky Perez-Gonzalez [this message]
2009-05-28 1:05 ` [patch 2.6.31 02/10] wimax/i2400m: trace commands sent from user space on the "echo" pipe Inaky Perez-Gonzalez
2009-05-28 1:05 ` [patch 2.6.31 03/10] wimax/i2400m: allow kernel commands to device to be logged too Inaky Perez-Gonzalez
2009-05-28 1:05 ` [patch 2.6.31 04/10] wimax/i2400m: factor out 'state report's TLV handling to a function Inaky Perez-Gonzalez
2009-05-28 1:05 ` [patch 2.6.31 05/10] wimax/i2400m: remove redundant readiness checks from i2400m_report_tlv_*() Inaky Perez-Gonzalez
2009-05-28 1:05 ` [patch 2.6.31 06/10] wimax: document why wimax_msg_*() operations can be used in any state Inaky Perez-Gonzalez
2009-05-28 1:05 ` [patch 2.6.31 07/10] wimax/i2400m: sdio: set the block size before enabling the function Inaky Perez-Gonzalez
2009-05-28 1:05 ` [patch 2.6.31 08/10] wimax: Add netlink interface to get device state Inaky Perez-Gonzalez
2009-05-28 1:05 ` [patch 2.6.31 09/10] wimax/i2400m: usb: fix device reset on autosuspend while not yet idle Inaky Perez-Gonzalez
2009-05-28 1:05 ` [patch 2.6.31 10/10] wimax: a new API call was added, increment minor protocol version number Inaky Perez-Gonzalez
2009-05-28 1:21 ` [patch 2.6.31 08/10] wimax: Add netlink interface to get device state Stephen Hemminger
2009-05-28 16:16 ` Inaky Perez-Gonzalez
2009-05-28 22:06 ` David Miller
2009-05-28 22:09 ` Inaky Perez-Gonzalez
-- strict thread matches above, loose matches on Subject: below --
2009-05-29 1:12 [patch 2.6.31 00/10] WiMAX pull request (v2) Inaky Perez-Gonzalez
2009-05-29 1:12 ` [patch 2.6.31 01/10] wimax/i2400m: generate fake source MAC address with random_ether_addr() Inaky Perez-Gonzalez
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=e9de4b9426eeeddf56110425cfd88e43828e7146.1243472510.git.inaky@linux.intel.com \
--to=inaky@linux.intel.com \
--cc=netdev@vger.kernel.org \
--cc=wimax@linuxwimax.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).