aboutsummaryrefslogtreecommitdiffstats
path: root/target/linux/uml/patches-4.4/102-pseudo-random-mac.patch
diff options
context:
space:
mode:
authorFlorian Fainelli <f.fainelli@gmail.com>2017-12-16 14:37:51 -0800
committerFlorian Fainelli <f.fainelli@gmail.com>2018-03-08 11:44:26 -0800
commit30d42f85ae489cfe8394d2a2fc1f85e1d6fc0b58 (patch)
tree9f6ef6760b9b37131e27be8b33062e16d343a916 /target/linux/uml/patches-4.4/102-pseudo-random-mac.patch
parent7cc9914aae55b87e4fb002b5faf9cf5ff8d44880 (diff)
downloadupstream-30d42f85ae489cfe8394d2a2fc1f85e1d6fc0b58.tar.gz
upstream-30d42f85ae489cfe8394d2a2fc1f85e1d6fc0b58.tar.bz2
upstream-30d42f85ae489cfe8394d2a2fc1f85e1d6fc0b58.zip
uml: Remove 4.4 patches
Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
Diffstat (limited to 'target/linux/uml/patches-4.4/102-pseudo-random-mac.patch')
-rw-r--r--target/linux/uml/patches-4.4/102-pseudo-random-mac.patch124
1 files changed, 0 insertions, 124 deletions
diff --git a/target/linux/uml/patches-4.4/102-pseudo-random-mac.patch b/target/linux/uml/patches-4.4/102-pseudo-random-mac.patch
deleted file mode 100644
index fc54f603c0..0000000000
--- a/target/linux/uml/patches-4.4/102-pseudo-random-mac.patch
+++ /dev/null
@@ -1,124 +0,0 @@
-===============================================================================
-
-This patch makes MAC addresses of network interfaces predictable. In
-particular, it adds a small routine that computes MAC addresses of based on
-a SHA1 hash of the virtual machine name and interface ID.
-
-TECHNICAL INFORMATION:
-
-Applies to vanilla kernel 3.9.4.
-
-===============================================================================
---- a/arch/um/Kconfig.net
-+++ b/arch/um/Kconfig.net
-@@ -21,6 +21,19 @@ config UML_NET
- enable at least one of the following transport options to actually
- make use of UML networking.
-
-+config UML_NET_RANDOM_MAC
-+ bool "Use random MAC addresses for network interfaces"
-+ default n
-+ depends on UML_NET
-+ help
-+ Virtual network devices inside a User-Mode Linux instance must be
-+ assigned a MAC (Ethernet) address. If none is specified on the UML
-+ command line, one must be automatically computed. If this option is
-+ enabled, a randomly generated address is used. Otherwise, if this
-+ option is disabled, the address is generated from a SHA1 hash of
-+ the umid of the UML instance and the interface name. The latter choice
-+ is useful to make MAC addresses predictable.
-+
- config UML_NET_ETHERTAP
- bool "Ethertap transport"
- depends on UML_NET
---- a/arch/um/drivers/net_kern.c
-+++ b/arch/um/drivers/net_kern.c
-@@ -25,6 +25,13 @@
- #include <net_kern.h>
- #include <net_user.h>
-
-+#include <crypto/sha.h>
-+#include <linux/string.h>
-+#include <linux/crypto.h>
-+#include <linux/err.h>
-+#include <linux/scatterlist.h>
-+#include "os.h"
-+
- #define DRIVER_NAME "uml-netdev"
-
- static DEFINE_SPINLOCK(opened_lock);
-@@ -295,11 +302,47 @@ static void uml_net_user_timer_expire(un
- #endif
- }
-
-+#ifndef CONFIG_UML_NET_RANDOM_MAC
-+
-+/* Compute a SHA1 hash of the UML instance's id and
-+ * * an interface name. */
-+static int compute_hash(const char *umid, const char *ifname, char *hash) {
-+ char vmif[1024];
-+ struct scatterlist sg;
-+ struct crypto_hash *tfm;
-+ struct hash_desc desc;
-+
-+ strcpy (vmif, umid);
-+ strcat (vmif, ifname);
-+
-+ tfm = crypto_alloc_hash("sha1", 0, CRYPTO_ALG_ASYNC);
-+ if (IS_ERR(tfm))
-+ return 1;
-+
-+ desc.tfm = tfm;
-+ desc.flags = 0;
-+
-+ sg_init_table(&sg, 1);
-+ sg_set_buf(&sg, vmif, strlen(vmif));
-+
-+ if (crypto_hash_digest(&desc, &sg, strlen(vmif), hash)) {
-+ crypto_free_hash(tfm);
-+ return 1;
-+ }
-+
-+ crypto_free_hash(tfm);
-+
-+ return 0;
-+}
-+
-+#endif
-+
- static void setup_etheraddr(struct net_device *dev, char *str)
- {
- unsigned char *addr = dev->dev_addr;
- char *end;
- int i;
-+ u8 hash[SHA1_DIGEST_SIZE];
-
- if (str == NULL)
- goto random;
-@@ -340,9 +383,26 @@ static void setup_etheraddr(struct net_d
- return;
-
- random:
-+#ifdef CONFIG_UML_NET_RANDOM_MAC
- printk(KERN_INFO
- "Choosing a random ethernet address for device %s\n", dev->name);
- eth_hw_addr_random(dev);
-+#else
-+ printk(KERN_INFO
-+ "Computing a digest to use as ethernet address for device %s\n", dev->name);
-+ if (compute_hash(get_umid(), dev->name, hash)) {
-+ printk(KERN_WARNING
-+ "Could not compute digest to use as ethernet address for device %s. "
-+ "Using random address instead.\n", dev->name);
-+ random_ether_addr(addr);
-+ }
-+ else {
-+ for (i=0; i < 6; i++)
-+ addr[i] = (hash[i] + hash[i+6]) % 0x100;
-+ }
-+ addr [0] &= 0xfe; /* clear multicast bit */
-+ addr [0] |= 0x02; /* set local assignment bit (IEEE802) */
-+#endif
- }
-
- static DEFINE_SPINLOCK(devices_lock);