netdev: DM9000: remove BLACKFIN hacking in DM9000 netdev driver
[safe/jmp/linux-2.6] / net / ipv4 / ipconfig.c
index 10013cc..42065ff 100644 (file)
@@ -1,6 +1,4 @@
 /*
- *  $Id: ipconfig.c,v 1.46 2002/02/01 22:01:04 davem Exp $
- *
  *  Automatic Configuration of IP -- use DHCP, BOOTP, RARP, or
  *  user-supplied information to configure own IP address and routes.
  *
                                           - '3' from resolv.h */
 
 #define NONE __constant_htonl(INADDR_NONE)
+#define ANY __constant_htonl(INADDR_ANY)
 
 /*
  * Public IP configuration
@@ -291,7 +290,7 @@ static int __init ic_dev_ioctl(unsigned int cmd, struct ifreq *arg)
 
        mm_segment_t oldfs = get_fs();
        set_fs(get_ds());
-       res = devinet_ioctl(cmd, (struct ifreq __user *) arg);
+       res = devinet_ioctl(&init_net, cmd, (struct ifreq __user *) arg);
        set_fs(oldfs);
        return res;
 }
@@ -375,7 +374,7 @@ static int __init ic_defaults(void)
         */
 
        if (!ic_host_name_set)
-               sprintf(init_utsname()->nodename, "%u.%u.%u.%u", NIPQUAD(ic_myaddr));
+               sprintf(init_utsname()->nodename, NIPQUAD_FMT, NIPQUAD(ic_myaddr));
 
        if (root_server_addr == NONE)
                root_server_addr = ic_servaddr;
@@ -388,11 +387,11 @@ static int __init ic_defaults(void)
                else if (IN_CLASSC(ntohl(ic_myaddr)))
                        ic_netmask = htonl(IN_CLASSC_NET);
                else {
-                       printk(KERN_ERR "IP-Config: Unable to guess netmask for address %u.%u.%u.%u\n",
+                       printk(KERN_ERR "IP-Config: Unable to guess netmask for address " NIPQUAD_FMT "\n",
                                NIPQUAD(ic_myaddr));
                        return -1;
                }
-               printk("IP-Config: Guessing netmask %u.%u.%u.%u\n", NIPQUAD(ic_netmask));
+               printk("IP-Config: Guessing netmask " NIPQUAD_FMT "\n", NIPQUAD(ic_netmask));
        }
 
        return 0;
@@ -411,12 +410,12 @@ static struct packet_type rarp_packet_type __initdata = {
        .func = ic_rarp_recv,
 };
 
-static inline void ic_rarp_init(void)
+static inline void __init ic_rarp_init(void)
 {
        dev_add_pack(&rarp_packet_type);
 }
 
-static inline void ic_rarp_cleanup(void)
+static inline void __init ic_rarp_cleanup(void)
 {
        dev_remove_pack(&rarp_packet_type);
 }
@@ -433,7 +432,7 @@ ic_rarp_recv(struct sk_buff *skb, struct net_device *dev, struct packet_type *pt
        unsigned char *sha, *tha;               /* s for "source", t for "target" */
        struct ic_device *d;
 
-       if (dev->nd_net != &init_net)
+       if (!net_eq(dev_net(dev), &init_net))
                goto drop;
 
        if ((skb = skb_share_check(skb, GFP_ATOMIC)) == NULL)
@@ -459,10 +458,7 @@ ic_rarp_recv(struct sk_buff *skb, struct net_device *dev, struct packet_type *pt
        if (rarp->ar_pro != htons(ETH_P_IP))
                goto drop;
 
-       if (!pskb_may_pull(skb,
-                          sizeof(struct arphdr) +
-                          (2 * dev->addr_len) +
-                          (2 * 4)))
+       if (!pskb_may_pull(skb, arp_hdr_len(dev)))
                goto drop;
 
        /* OK, it is all there and looks valid, process... */
@@ -684,7 +680,7 @@ static void __init ic_bootp_init_ext(u8 *e)
 /*
  *  Initialize the DHCP/BOOTP mechanism.
  */
-static inline void ic_bootp_init(void)
+static inline void __init ic_bootp_init(void)
 {
        int i;
 
@@ -698,7 +694,7 @@ static inline void ic_bootp_init(void)
 /*
  *  DHCP/BOOTP cleanup.
  */
-static inline void ic_bootp_cleanup(void)
+static inline void __init ic_bootp_cleanup(void)
 {
        dev_remove_pack(&bootp_packet_type);
 }
@@ -712,14 +708,14 @@ static void __init ic_bootp_send_if(struct ic_device *d, unsigned long jiffies_d
        struct net_device *dev = d->dev;
        struct sk_buff *skb;
        struct bootp_pkt *b;
-       int hh_len = LL_RESERVED_SPACE(dev);
        struct iphdr *h;
 
        /* Allocate packet */
-       skb = alloc_skb(sizeof(struct bootp_pkt) + hh_len + 15, GFP_KERNEL);
+       skb = alloc_skb(sizeof(struct bootp_pkt) + LL_ALLOCATED_SPACE(dev) + 15,
+                       GFP_KERNEL);
        if (!skb)
                return;
-       skb_reserve(skb, hh_len);
+       skb_reserve(skb, LL_RESERVED_SPACE(dev));
        b = (struct bootp_pkt *) skb_put(skb, sizeof(struct bootp_pkt));
        memset(b, 0, sizeof(struct bootp_pkt));
 
@@ -753,9 +749,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;
@@ -856,7 +852,7 @@ static int __init ic_bootp_recv(struct sk_buff *skb, struct net_device *dev, str
        struct ic_device *d;
        int len, ext_len;
 
-       if (dev->nd_net != &init_net)
+       if (!net_eq(dev_net(dev), &init_net))
                goto drop;
 
        /* Perform verifications before taking the lock.  */
@@ -983,9 +979,9 @@ static int __init ic_bootp_recv(struct sk_buff *skb, struct net_device *dev, str
                                ic_myaddr = b->your_ip;
                                ic_servaddr = server_id;
 #ifdef IPCONFIG_DEBUG
-                               printk("DHCP: Offered address %u.%u.%u.%u",
+                               printk("DHCP: Offered address " NIPQUAD_FMT,
                                       NIPQUAD(ic_myaddr));
-                               printk(" by server %u.%u.%u.%u\n",
+                               printk(" by server " NIPQUAD_FMT "\n",
                                       NIPQUAD(ic_servaddr));
 #endif
                                /* The DHCP indicated server address takes
@@ -1181,11 +1177,11 @@ static int __init ic_dynamic(void)
                return -1;
        }
 
-       printk("IP-Config: Got %s answer from %u.%u.%u.%u, ",
+       printk("IP-Config: Got %s answer from " NIPQUAD_FMT ", ",
                ((ic_got_reply & IC_RARP) ? "RARP"
                 : (ic_proto_enabled & IC_USE_DHCP) ? "DHCP" : "BOOTP"),
                NIPQUAD(ic_servaddr));
-       printk("my address is %u.%u.%u.%u\n", NIPQUAD(ic_myaddr));
+       printk("my address is " NIPQUAD_FMT "\n", NIPQUAD(ic_myaddr));
 
        return 0;
 }
@@ -1211,12 +1207,12 @@ static int pnp_seq_show(struct seq_file *seq, void *v)
        for (i = 0; i < CONF_NAMESERVERS_MAX; i++) {
                if (ic_nameservers[i] != NONE)
                        seq_printf(seq,
-                                  "nameserver %u.%u.%u.%u\n",
+                                  "nameserver " NIPQUAD_FMT "\n",
                                   NIPQUAD(ic_nameservers[i]));
        }
        if (ic_servaddr != NONE)
                seq_printf(seq,
-                          "bootserver %u.%u.%u.%u\n",
+                          "bootserver " NIPQUAD_FMT "\n",
                           NIPQUAD(ic_servaddr));
        return 0;
 }
@@ -1391,13 +1387,13 @@ static int __init ip_auto_config(void)
         */
        printk("IP-Config: Complete:");
        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));
+       printk(", addr=" NIPQUAD_FMT, NIPQUAD(ic_myaddr));
+       printk(", mask=" NIPQUAD_FMT, NIPQUAD(ic_netmask));
+       printk(", gw=" NIPQUAD_FMT, NIPQUAD(ic_gateway));
        printk(",\n     host=%s, domain=%s, nis-domain=%s",
               utsname()->nodename, ic_domain, utsname()->domainname);
-       printk(",\n     bootserver=%u.%u.%u.%u", NIPQUAD(ic_servaddr));
-       printk(", rootserver=%u.%u.%u.%u", NIPQUAD(root_server_addr));
+       printk(",\n     bootserver=" NIPQUAD_FMT, NIPQUAD(ic_servaddr));
+       printk(", rootserver=" NIPQUAD_FMT, NIPQUAD(root_server_addr));
        printk(", rootpath=%s", root_server_path);
        printk("\n");
 #endif /* !SILENT */
@@ -1410,7 +1406,7 @@ late_initcall(ip_auto_config);
 
 /*
  *  Decode any IP configuration options in the "ip=" or "nfsaddrs=" kernel
- *  command line parameter.  See Documentation/nfsroot.txt.
+ *  command line parameter.  See Documentation/filesystems/nfsroot.txt.
  */
 static int __init ic_proto_name(char *name)
 {
@@ -1479,19 +1475,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: