+ uml-mechanical-tidying-after-random-macs-change.patch added to -mm tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



The patch titled

     uml: mechanical tidying after random MACs change

has been added to the -mm tree.  Its filename is

     uml-mechanical-tidying-after-random-macs-change.patch

See http://www.zip.com.au/~akpm/linux/patches/stuff/added-to-mm.txt to find
out what to do about this

------------------------------------------------------
Subject: uml: mechanical tidying after random MACs change
From: Jeff Dike <jdike@xxxxxxxxxxx>

Mechanical, hopefully non-functional changes stemming from
setup_etheraddr always succeeding now that it always assigns a MAC,
either from the command line or generated randomly:
   the test of the return of setup_etheraddr is removed, and code
dependent on it succeeding is now unconditional
   setup_etheraddr can now be made void
   struct uml_net.have_mac is now always 1, so tests of it can be
similarly removed, and uses of it can be replaced with 1
   struct uml_net.have_mac is no longer used, so it can be removed
   struct uml_net_private.have_mac is copied from struct uml_net, so
it is always 1
   tests of uml_net_private.have_mac can be removed
   uml_net_private.have_mac can now be removed
   the only call to dev_ip_addr was removed, so it can be deleted

It also turns out that setup_etheraddr is called only once, from the same
file, so it can be static and its declaration removed from net_kern.h.

Similarly, set_ether_mac is defined and called only from one file.

Finally, setup_etheraddr and set_ether_mac were moved to avoid needing forward
declarations.

Signed-off-by: Jeff Dike <jdike@xxxxxxxxxxx>
Signed-off-by: Andrew Morton <akpm@xxxxxxxx>
---

 arch/um/drivers/net_kern.c |  105 +++++++++++++----------------------
 arch/um/include/net_kern.h |   14 ----
 arch/um/include/net_user.h |    1 
 3 files changed, 40 insertions(+), 80 deletions(-)

diff -puN arch/um/drivers/net_kern.c~uml-mechanical-tidying-after-random-macs-change arch/um/drivers/net_kern.c
--- a/arch/um/drivers/net_kern.c~uml-mechanical-tidying-after-random-macs-change
+++ a/arch/um/drivers/net_kern.c
@@ -119,11 +119,6 @@ static int uml_net_open(struct net_devic
 		goto out;
 	}
 
-	if(!lp->have_mac){
- 		dev_ip_addr(dev, &lp->mac[2]);
- 		set_ether_mac(dev, lp->mac);
-	}
-
 	lp->fd = (*lp->open)(&lp->user);
 	if(lp->fd < 0){
 		err = lp->fd;
@@ -287,6 +282,39 @@ void uml_net_user_timer_expire(unsigned 
 #endif
 }
 
+static void setup_etheraddr(char *str, unsigned char *addr)
+{
+	char *end;
+	int i;
+
+	if(str == NULL)
+		goto random;
+
+	for(i=0;i<6;i++){
+		addr[i] = simple_strtoul(str, &end, 16);
+		if((end == str) ||
+		   ((*end != ':') && (*end != ',') && (*end != '\0'))){
+			printk(KERN_ERR
+			       "setup_etheraddr: failed to parse '%s' "
+			       "as an ethernet address\n", str);
+			goto random;
+		}
+		str = end + 1;
+	}
+	if(addr[0] & 1){
+		printk(KERN_ERR
+		       "Attempt to assign a broadcast ethernet address to a "
+		       "device disallowed\n");
+		goto random;
+	}
+	return;
+
+random:
+	addr[0] = 0xfe;
+	addr[1] = 0xfd;
+	random_mac(addr);
+}
+
 static DEFINE_SPINLOCK(devices_lock);
 static LIST_HEAD(devices);
 
@@ -322,15 +350,13 @@ static int eth_configure(int n, void *in
 	list_add(&device->list, &devices);
 	spin_unlock(&devices_lock);
 
-	if (setup_etheraddr(mac, device->mac))
-		device->have_mac = 1;
+	setup_etheraddr(mac, device->mac);
 
 	printk(KERN_INFO "Netdevice %d ", n);
-	if (device->have_mac)
-		printk("(%02x:%02x:%02x:%02x:%02x:%02x) ",
-		       device->mac[0], device->mac[1],
-		       device->mac[2], device->mac[3],
-		       device->mac[4], device->mac[5]);
+	printk("(%02x:%02x:%02x:%02x:%02x:%02x) ",
+	       device->mac[0], device->mac[1],
+	       device->mac[2], device->mac[3],
+	       device->mac[4], device->mac[5]);
 	printk(": ");
 	dev = alloc_etherdev(size);
 	if (dev == NULL) {
@@ -396,7 +422,6 @@ static int eth_configure(int n, void *in
 		  .dev 			= dev,
 		  .fd 			= -1,
 		  .mac 			= { 0xfe, 0xfd, 0x0, 0x0, 0x0, 0x0},
-		  .have_mac 		= device->have_mac,
 		  .protocol 		= transport->kern->protocol,
 		  .open 		= transport->user->open,
 		  .close 		= transport->user->close,
@@ -411,14 +436,12 @@ static int eth_configure(int n, void *in
 	init_timer(&lp->tl);
 	spin_lock_init(&lp->lock);
 	lp->tl.function = uml_net_user_timer_expire;
-	if (lp->have_mac)
-		memcpy(lp->mac, device->mac, sizeof(lp->mac));
+	memcpy(lp->mac, device->mac, sizeof(lp->mac));
 
 	if (transport->user->init) 
 		(*transport->user->init)(&lp->user, dev);
 
-	if (device->have_mac)
-		set_ether_mac(dev, device->mac);
+	set_ether_mac(dev, device->mac);
 
 	return 0;
 }
@@ -747,54 +770,6 @@ static void close_devices(void)
 
 __uml_exitcall(close_devices);
 
-int setup_etheraddr(char *str, unsigned char *addr)
-{
-	char *end;
-	int i;
-
-	if(str == NULL)
-		goto random;
-
-	for(i=0;i<6;i++){
-		addr[i] = simple_strtoul(str, &end, 16);
-		if((end == str) ||
-		   ((*end != ':') && (*end != ',') && (*end != '\0'))){
-			printk(KERN_ERR 
-			       "setup_etheraddr: failed to parse '%s' "
-			       "as an ethernet address\n", str);
-			goto random;
-		}
-		str = end + 1;
-	}
-	if(addr[0] & 1){
-		printk(KERN_ERR 
-		       "Attempt to assign a broadcast ethernet address to a "
-		       "device disallowed\n");
-		goto random;
-	}
-	return 1;
-
-random:
-	addr[0] = 0xfe;
-	addr[1] = 0xfd;
-	random_mac(addr);
-	return 1;
-}
-
-void dev_ip_addr(void *d, unsigned char *bin_buf)
-{
-	struct net_device *dev = d;
-	struct in_device *ip = dev->ip_ptr;
-	struct in_ifaddr *in;
-
-	if((ip == NULL) || ((in = ip->ifa_list) == NULL)){
-		printk(KERN_WARNING "dev_ip_addr - device not assigned an "
-		       "IP address\n");
-		return;
-	}
-	memcpy(bin_buf, &in->ifa_address, sizeof(in->ifa_address));
-}
-
 struct sk_buff *ether_adjust_skb(struct sk_buff *skb, int extra)
 {
 	if((skb != NULL) && (skb_tailroom(skb) < extra)){
diff -puN arch/um/include/net_kern.h~uml-mechanical-tidying-after-random-macs-change arch/um/include/net_kern.h
--- a/arch/um/include/net_kern.h~uml-mechanical-tidying-after-random-macs-change
+++ a/arch/um/include/net_kern.h
@@ -18,7 +18,6 @@ struct uml_net {
 	struct platform_device pdev;
 	int index;
 	unsigned char mac[ETH_ALEN];
-	int have_mac;
 };
 
 struct uml_net_private {
@@ -29,7 +28,6 @@ struct uml_net_private {
 	struct net_device_stats stats;
 	int fd;
 	unsigned char mac[ETH_ALEN];
-	int have_mac;
 	unsigned short (*protocol)(struct sk_buff *);
 	int (*open)(void *);
 	void (*close)(int, void *);
@@ -62,7 +60,6 @@ struct transport {
 
 extern struct net_device *ether_init(int);
 extern unsigned short ether_protocol(struct sk_buff *);
-extern int setup_etheraddr(char *str, unsigned char *addr);
 extern struct sk_buff *ether_adjust_skb(struct sk_buff *skb, int extra);
 extern int tap_setup_common(char *str, char *type, char **dev_name, 
 			    char **mac_out, char **gate_addr);
@@ -70,14 +67,3 @@ extern void register_transport(struct tr
 extern unsigned short eth_protocol(struct sk_buff *skb);
 
 #endif
-
-/*
- * Overrides for Emacs so that we follow Linus's tabbing style.
- * Emacs will notice this stuff at the end of the file and automatically
- * adjust the settings for this buffer only.  This must remain at the end
- * of the file.
- * ---------------------------------------------------------------------------
- * Local variables:
- * c-file-style: "linux"
- * End:
- */
diff -puN arch/um/include/net_user.h~uml-mechanical-tidying-after-random-macs-change arch/um/include/net_user.h
--- a/arch/um/include/net_user.h~uml-mechanical-tidying-after-random-macs-change
+++ a/arch/um/include/net_user.h
@@ -25,7 +25,6 @@ struct net_user_info {
 };
 
 extern void ether_user_init(void *data, void *dev);
-extern void dev_ip_addr(void *d, unsigned char *bin_buf);
 extern void iter_addresses(void *d, void (*cb)(unsigned char *,
 					       unsigned char *, void *),
 			   void *arg);
_

Patches currently in -mm which might be from jdike@xxxxxxxxxxx are

origin.patch
uml-assign-random-macs-to-interfaces-if-necessary.patch
uml-mechanical-tidying-after-random-macs-change.patch
uml-locking-documentation.patch
uml-close-file-descriptor-leaks.patch
uml-stack-consumption-reduction.patch
uml-remove-pte_mkexec.patch
simplify-update_times-avoid-jiffies-jiffies_64-aliasing-problem-2.patch
kill-wall_jiffies.patch
const-struct-tty_operations.patch
namespaces-utsname-switch-to-using-uts-namespaces.patch
introduce-kernel_execve.patch
rename-the-provided-execve-functions-to-kernel_execve.patch
provide-kernel_execve-on-all-architectures.patch
provide-kernel_execve-on-all-architectures-fix.patch
remove-the-use-of-_syscallx-macros-in-uml.patch
sh64-remove-the-use-of-kernel-syscalls.patch
remove-remaining-errno-and-__kernel_syscalls__-references.patch

-
To unsubscribe from this list: send the line "unsubscribe mm-commits" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Kernel Newbies FAQ]     [Kernel Archive]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [Bugtraq]     [Photo]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]

  Powered by Linux