From 476ff5a0ad285b12de1cbe16453b8f12ff79afc6 Mon Sep 17 00:00:00 2001 From: Jesse Gross Date: Tue, 4 Dec 2012 10:06:55 -0800 Subject: [PATCH] datapath: Backport eth_mac_addr(). 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 --- .../linux/compat/include/linux/etherdevice.h | 16 ++++++++++++++++ datapath/linux/compat/include/linux/if.h | 4 ++++ 2 files changed, 20 insertions(+) diff --git a/datapath/linux/compat/include/linux/etherdevice.h b/datapath/linux/compat/include/linux/etherdevice.h index 7f04c962e..b2c335358 100644 --- a/datapath/linux/compat/include/linux/etherdevice.h +++ b/datapath/linux/compat/include/linux/etherdevice.h @@ -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 diff --git a/datapath/linux/compat/include/linux/if.h b/datapath/linux/compat/include/linux/if.h index a09f11283..f53cf9798 100644 --- a/datapath/linux/compat/include/linux/if.h +++ b/datapath/linux/compat/include/linux/if.h @@ -18,4 +18,8 @@ #define IFF_OVS_DATAPATH 0 #endif +#ifndef IFF_LIVE_ADDR_CHANGE +#define IFF_LIVE_ADDR_CHANGE 0 +#endif + #endif -- 2.45.2