aboutsummaryrefslogtreecommitdiff
path: root/datapath
diff options
context:
space:
mode:
authorDanny Kukawka <danny.kukawka@bisect.de>2012-02-15 15:13:19 -0800
committerJesse Gross <jesse@nicira.com>2012-02-15 15:16:36 -0800
commit550534413c31d7c91181305962fc7fc982465ac0 (patch)
treedfc063b4cf9dcbb4c6433c47f9bc6198c9986a4a /datapath
parent0e553d9c1063be047824c6f1afce9ffc6db6c671 (diff)
datapath: use eth_hw_addr_random() and reset addr_assign_type
Use eth_hw_addr_random() instead of calling random_ether_addr() to set addr_assign_type correctly to NET_ADDR_RANDOM. Reset the state to NET_ADDR_PERM as soon as the MAC get changed via .ndo_set_mac_address. Signed-off-by: Danny Kukawka <danny.kukawka@bisect.de> [jesse: add backporting to older kernels] Signed-off-by: Jesse Gross <jesse@nicira.com>
Diffstat (limited to 'datapath')
-rw-r--r--datapath/linux/Modules.mk1
-rw-r--r--datapath/linux/compat/include/linux/etherdevice.h19
-rw-r--r--datapath/vport-internal_dev.c5
3 files changed, 24 insertions, 1 deletions
diff --git a/datapath/linux/Modules.mk b/datapath/linux/Modules.mk
index 7f54bde4..97d977b7 100644
--- a/datapath/linux/Modules.mk
+++ b/datapath/linux/Modules.mk
@@ -18,6 +18,7 @@ openvswitch_headers += \
linux/compat/include/linux/cpumask.h \
linux/compat/include/linux/dmi.h \
linux/compat/include/linux/err.h \
+ linux/compat/include/linux/etherdevice.h \
linux/compat/include/linux/flex_array.h \
linux/compat/include/linux/genetlink.h \
linux/compat/include/linux/icmp.h \
diff --git a/datapath/linux/compat/include/linux/etherdevice.h b/datapath/linux/compat/include/linux/etherdevice.h
new file mode 100644
index 00000000..7a8178e5
--- /dev/null
+++ b/datapath/linux/compat/include/linux/etherdevice.h
@@ -0,0 +1,19 @@
+#ifndef __LINUX_ETHERDEVICE_WRAPPER_H
+#define __LINUX_ETHERDEVICE_WRAPPER_H 1
+
+#include_next <linux/etherdevice.h>
+#include <linux/version.h>
+
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,36)
+static inline void eth_hw_addr_random(struct net_device *dev)
+{
+ random_ether_addr(dev->dev_addr);
+}
+#elif LINUX_VERSION_CODE < KERNEL_VERSION(3,3,0)
+static inline void eth_hw_addr_random(struct net_device *dev)
+{
+ dev_hw_addr_random(dev, dev->dev_addr);
+}
+#endif
+
+#endif
diff --git a/datapath/vport-internal_dev.c b/datapath/vport-internal_dev.c
index 46b78d22..9647a617 100644
--- a/datapath/vport-internal_dev.c
+++ b/datapath/vport-internal_dev.c
@@ -87,6 +87,9 @@ static int internal_dev_mac_addr(struct net_device *dev, void *p)
if (!is_valid_ether_addr(addr->sa_data))
return -EADDRNOTAVAIL;
+#ifdef NET_ADDR_RANDOM
+ dev->addr_assign_type &= ~NET_ADDR_RANDOM;
+#endif
memcpy(dev->dev_addr, addr->sa_data, dev->addr_len);
return 0;
}
@@ -213,7 +216,7 @@ static void do_setup(struct net_device *netdev)
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,39)
netdev->hw_features = netdev->features & ~NETIF_F_LLTX;
#endif
- random_ether_addr(netdev->dev_addr);
+ eth_hw_addr_random(netdev);
}
static struct vport *internal_dev_create(const struct vport_parms *parms)