[IPV4] fib_trie: fix warning from rcu_assign_poinger
[safe/jmp/linux-2.6] / net / ipv4 / ipconfig.c
index 4303851..7c992fb 100644 (file)
                                           - '3' from resolv.h */
 
 #define NONE __constant_htonl(INADDR_NONE)
+#define ANY __constant_htonl(INADDR_ANY)
 
 /*
  * Public IP configuration
@@ -140,6 +141,9 @@ __be32 ic_servaddr = NONE;  /* Boot server IP address */
 __be32 root_server_addr = NONE;        /* Address of NFS server */
 u8 root_server_path[256] = { 0, };     /* Path to mount as root */
 
+/* vendor class identifier */
+static char vendor_class_identifier[253] __initdata;
+
 /* Persistent data: */
 
 static int ic_proto_used;                      /* Protocol used, if any */
@@ -190,11 +194,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) &&
@@ -295,7 +303,7 @@ static int __init ic_route_ioctl(unsigned int cmd, struct rtentry *arg)
 
        mm_segment_t oldfs = get_fs();
        set_fs(get_ds());
-       res = ip_rt_ioctl(cmd, (void __user *) arg);
+       res = ip_rt_ioctl(&init_net, cmd, (void __user *) arg);
        set_fs(oldfs);
        return res;
 }
@@ -584,6 +592,7 @@ ic_dhcp_init_options(u8 *options)
        u8 mt = ((ic_servaddr == NONE)
                 ? DHCPDISCOVER : DHCPREQUEST);
        u8 *e = options;
+       int len;
 
 #ifdef IPCONFIG_DEBUG
        printk("DHCP: Sending message type %d\n", mt);
@@ -624,6 +633,16 @@ ic_dhcp_init_options(u8 *options)
                *e++ = sizeof(ic_req_params);
                memcpy(e, ic_req_params, sizeof(ic_req_params));
                e += sizeof(ic_req_params);
+
+               if (*vendor_class_identifier) {
+                       printk(KERN_INFO "DHCP: sending class identifier \"%s\"\n",
+                              vendor_class_identifier);
+                       *e++ = 60;      /* Class-identifier */
+                       len = strlen(vendor_class_identifier);
+                       *e++ = len;
+                       memcpy(e, vendor_class_identifier, len);
+                       e += len;
+               }
        }
 
        *e++ = 255;     /* End of the list */
@@ -735,9 +754,9 @@ static void __init ic_bootp_send_if(struct ic_device *d, unsigned long jiffies_d
                printk("Unknown ARP type 0x%04x for device %s\n", dev->type, dev->name);
                b->htype = dev->type; /* can cause undefined behavior */
        }
+
+       /* server_ip and your_ip address are both already zero per RFC2131 */
        b->hlen = dev->addr_len;
-       b->your_ip = NONE;
-       b->server_ip = NONE;
        memcpy(b->hw_addr, dev->dev_addr, dev->addr_len);
        b->secs = htons(jiffies_diff / HZ);
        b->xid = d->xid;
@@ -753,8 +772,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");
 }
@@ -1372,7 +1391,7 @@ static int __init ip_auto_config(void)
         * Clue in the operator.
         */
        printk("IP-Config: Complete:");
-       printk("\n      device=%s", ic_dev->name);
+       printk("\n     device=%s", ic_dev->name);
        printk(", addr=%u.%u.%u.%u", NIPQUAD(ic_myaddr));
        printk(", mask=%u.%u.%u.%u", NIPQUAD(ic_netmask));
        printk(", gw=%u.%u.%u.%u", NIPQUAD(ic_gateway));
@@ -1392,31 +1411,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 +1454,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, ':')))
@@ -1469,19 +1480,19 @@ static int __init ip_auto_config_setup(char *addrs)
                        DBG(("IP-Config: Parameter #%d: `%s'\n", num, ip));
                        switch (num) {
                        case 0:
-                               if ((ic_myaddr = in_aton(ip)) == INADDR_ANY)
+                               if ((ic_myaddr = in_aton(ip)) == ANY)
                                        ic_myaddr = NONE;
                                break;
                        case 1:
-                               if ((ic_servaddr = in_aton(ip)) == INADDR_ANY)
+                               if ((ic_servaddr = in_aton(ip)) == ANY)
                                        ic_servaddr = NONE;
                                break;
                        case 2:
-                               if ((ic_gateway = in_aton(ip)) == INADDR_ANY)
+                               if ((ic_gateway = in_aton(ip)) == ANY)
                                        ic_gateway = NONE;
                                break;
                        case 3:
-                               if ((ic_netmask = in_aton(ip)) == INADDR_ANY)
+                               if ((ic_netmask = in_aton(ip)) == ANY)
                                        ic_netmask = NONE;
                                break;
                        case 4:
@@ -1498,7 +1509,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;
                        }
                }
@@ -1514,5 +1528,16 @@ static int __init nfsaddrs_config_setup(char *addrs)
        return ip_auto_config_setup(addrs);
 }
 
+static int __init vendor_class_identifier_setup(char *addrs)
+{
+       if (strlcpy(vendor_class_identifier, addrs,
+                   sizeof(vendor_class_identifier))
+           >= sizeof(vendor_class_identifier))
+               printk(KERN_WARNING "DHCP: vendorclass too long, truncated to \"%s\"",
+                      vendor_class_identifier);
+       return 1;
+}
+
 __setup("ip=", ip_auto_config_setup);
 __setup("nfsaddrs=", nfsaddrs_config_setup);
+__setup("dhcpclass=", vendor_class_identifier_setup);