datapath: Backport eth_mac_addr().
authorJesse Gross <jesse@nicira.com>
Tue, 4 Dec 2012 18:06:55 +0000 (10:06 -0800)
committerJesse Gross <jesse@nicira.com>
Tue, 4 Dec 2012 18:08:30 +0000 (10:08 -0800)
eth_mac_addr() has always been available on the kernels that we
support but the behavior has varied over time.  This provides a
backport that is equivalent to the current kernel, previous OVS
behavior, and the bridge.

Signed-off-by: Jesse Gross <jesse@nicira.com>
datapath/linux/compat/include/linux/etherdevice.h
datapath/linux/compat/include/linux/if.h

index 7f04c96..b2c3353 100644 (file)
@@ -16,4 +16,20 @@ static inline void eth_hw_addr_random(struct net_device *dev)
 }
 #endif
 
+#if LINUX_VERSION_CODE < KERNEL_VERSION(3,6,0)
+#define eth_mac_addr rpl_eth_mac_addr
+static inline int eth_mac_addr(struct net_device *dev, void *p)
+{
+       struct sockaddr *addr = 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;
+}
+#endif
+
 #endif
index a09f112..f53cf97 100644 (file)
@@ -18,4 +18,8 @@
 #define IFF_OVS_DATAPATH 0
 #endif
 
+#ifndef IFF_LIVE_ADDR_CHANGE
+#define IFF_LIVE_ADDR_CHANGE 0
+#endif
+
 #endif