From: Luis R. Rodriguez Date: Fri, 20 Jul 2012 01:22:55 +0000 (-0700) Subject: compat: backport eth_random_addr() X-Git-Url: http://git.lede-project.org./?a=commitdiff_plain;h=452c560abcccf596891fca10f1e84cf481236211;p=openwrt%2Fstaging%2Fblogic.git compat: backport eth_random_addr() This really was a rename but to make code simpler just reimplement this for all kernels. commit 0a4dd594982a321699000218715e28664ec49169 Author: Joe Perches Date: Thu Jul 12 19:33:05 2012 +0000 etherdevice: Rename random_ether_addr to eth_random_addr Add some API symmetry to eth_broadcast_addr and add a #define to the old name for backward compatibility. Signed-off-by: Joe Perches Signed-off-by: David S. Miller mcgrof@tux ~/compat (git::master)$ ckmake -t Trying kernel 3.4.0-030400rc1-generic [OK] Trying kernel 3.3.7-030307-generic [OK] Trying kernel 3.2.2-030202-generic [OK] Trying kernel 3.1.10-030110-generic [OK] Trying kernel 3.0.18-030018-generic [OK] Trying kernel 2.6.39-02063904-generic [OK] Trying kernel 2.6.38-02063808-generic [OK] Trying kernel 2.6.37-02063706-generic [OK] Trying kernel 2.6.36-02063604-generic [OK] Trying kernel 2.6.35-02063512-generic [OK] Trying kernel 2.6.34-02063410-generic [OK] Trying kernel 2.6.33-02063305-generic [OK] Trying kernel 2.6.32-02063255-generic [OK] Trying kernel 2.6.31-02063113-generic [OK] Trying kernel 2.6.30-02063010-generic [OK] Trying kernel 2.6.29-02062906-generic [OK] Trying kernel 2.6.28-02062810-generic [OK] Trying kernel 2.6.27-020627-generic [OK] Trying kernel 2.6.26-020626-generic [OK] Trying kernel 2.6.25-020625-generic [OK] Trying kernel 2.6.24-020624-generic [OK] real 4m25.765s user 9m56.460s sys 1m24.650s real 2m7.808s user 3m20.640s sys 0m40.520s Signed-off-by: Luis R. Rodriguez --- diff --git a/include/linux/compat-3.6.h b/include/linux/compat-3.6.h index 9da8ec500919..0b36ca0090cb 100644 --- a/include/linux/compat-3.6.h +++ b/include/linux/compat-3.6.h @@ -6,6 +6,21 @@ #if (LINUX_VERSION_CODE < KERNEL_VERSION(3,6,0)) #include +#include + +/** + * eth_random_addr - Generate software assigned random Ethernet address + * @addr: Pointer to a six-byte array containing the Ethernet address + * + * Generate a random Ethernet address (MAC) that is not multicast + * and has the local assigned bit set. + */ +static inline void eth_random_addr(u8 *addr) +{ + get_random_bytes(addr, ETH_ALEN); + addr[0] &= 0xfe; /* clear multicast bit */ + addr[0] |= 0x02; /* set local assignment bit (IEEE802) */ +} #define GENLMSG_DEFAULT_SIZE (NLMSG_DEFAULT_SIZE - GENL_HDRLEN)