]> err.no Git - linux-2.6/blobdiff - net/ipv4/ipconfig.c
[POWERPC] CPM: Rename commproc to cpm1 and cpm2_common.c to cpm2.c
[linux-2.6] / net / ipv4 / ipconfig.c
index 4303851749f6a5642f674040df86765910921cba..b8f7763b2261474e4e5d35961193bcdcbebf26cd 100644 (file)
@@ -190,11 +190,15 @@ static int __init ic_open_devs(void)
        rtnl_lock();
 
        /* bring loopback device up first */
-       if (dev_change_flags(&loopback_dev, loopback_dev.flags | IFF_UP) < 0)
-               printk(KERN_ERR "IP-Config: Failed to open %s\n", loopback_dev.name);
+       for_each_netdev(&init_net, dev) {
+               if (!(dev->flags & IFF_LOOPBACK))
+                       continue;
+               if (dev_change_flags(dev, dev->flags | IFF_UP) < 0)
+                       printk(KERN_ERR "IP-Config: Failed to open %s\n", dev->name);
+       }
 
        for_each_netdev(&init_net, dev) {
-               if (dev == &loopback_dev)
+               if (dev->flags & IFF_LOOPBACK)
                        continue;
                if (user_dev_name[0] ? !strcmp(dev->name, user_dev_name) :
                    (!(dev->flags & IFF_LOOPBACK) &&
@@ -753,8 +757,8 @@ static void __init ic_bootp_send_if(struct ic_device *d, unsigned long jiffies_d
        /* Chain packet down the line... */
        skb->dev = dev;
        skb->protocol = htons(ETH_P_IP);
-       if ((dev->hard_header &&
-            dev->hard_header(skb, dev, ntohs(skb->protocol), dev->broadcast, dev->dev_addr, skb->len) < 0) ||
+       if (dev_hard_header(skb, dev, ntohs(skb->protocol),
+                           dev->broadcast, dev->dev_addr, skb->len) < 0 ||
            dev_queue_xmit(skb) < 0)
                printk("E");
 }
@@ -1392,31 +1396,16 @@ late_initcall(ip_auto_config);
 
 /*
  *  Decode any IP configuration options in the "ip=" or "nfsaddrs=" kernel
- *  command line parameter. It consists of option fields separated by colons in
- *  the following order:
- *
- *  <client-ip>:<server-ip>:<gw-ip>:<netmask>:<host name>:<device>:<PROTO>
- *
- *  Any of the fields can be empty which means to use a default value:
- *     <client-ip>     - address given by BOOTP or RARP
- *     <server-ip>     - address of host returning BOOTP or RARP packet
- *     <gw-ip>         - none, or the address returned by BOOTP
- *     <netmask>       - automatically determined from <client-ip>, or the
- *                       one returned by BOOTP
- *     <host name>     - <client-ip> in ASCII notation, or the name returned
- *                       by BOOTP
- *     <device>        - use all available devices
- *     <PROTO>:
- *        off|none         - don't do autoconfig at all (DEFAULT)
- *        on|any           - use any configured protocol
- *        dhcp|bootp|rarp  - use only the specified protocol
- *        both             - use both BOOTP and RARP (not DHCP)
+ *  command line parameter.  See Documentation/nfsroot.txt.
  */
 static int __init ic_proto_name(char *name)
 {
        if (!strcmp(name, "on") || !strcmp(name, "any")) {
                return 1;
        }
+       if (!strcmp(name, "off") || !strcmp(name, "none")) {
+               return 0;
+       }
 #ifdef CONFIG_IP_PNP_DHCP
        else if (!strcmp(name, "dhcp")) {
                ic_proto_enabled &= ~IC_RARP;
@@ -1450,17 +1439,24 @@ static int __init ip_auto_config_setup(char *addrs)
        int num = 0;
 
        ic_set_manually = 1;
+       ic_enable = 1;
 
-       ic_enable = (*addrs &&
-               (strcmp(addrs, "off") != 0) &&
-               (strcmp(addrs, "none") != 0));
-       if (!ic_enable)
+       /*
+        * If any dhcp, bootp etc options are set, leave autoconfig on
+        * and skip the below static IP processing.
+        */
+       if (ic_proto_name(addrs))
                return 1;
 
-       if (ic_proto_name(addrs))
+       /* If no static IP is given, turn off autoconfig and bail.  */
+       if (*addrs == 0 ||
+           strcmp(addrs, "off") == 0 ||
+           strcmp(addrs, "none") == 0) {
+               ic_enable = 0;
                return 1;
+       }
 
-       /* Parse the whole string */
+       /* Parse string for static IP assignment.  */
        ip = addrs;
        while (ip && *ip) {
                if ((cp = strchr(ip, ':')))
@@ -1498,7 +1494,10 @@ static int __init ip_auto_config_setup(char *addrs)
                                strlcpy(user_dev_name, ip, sizeof(user_dev_name));
                                break;
                        case 6:
-                               ic_proto_name(ip);
+                               if (ic_proto_name(ip) == 0 &&
+                                   ic_myaddr == NONE) {
+                                       ic_enable = 0;
+                               }
                                break;
                        }
                }