Fedora kernel-2.6.17-1.2142_FC4 patched with stable patch-2.6.17.4-vs2.0.2-rc26.diff
[linux-2.6.git] / net / ipv4 / ipconfig.c
index a0c8504..cb8a92f 100644 (file)
@@ -42,6 +42,7 @@
 #include <linux/in.h>
 #include <linux/if.h>
 #include <linux/inet.h>
+#include <linux/inetdevice.h>
 #include <linux/netdevice.h>
 #include <linux/if_arp.h>
 #include <linux/skbuff.h>
 #include <linux/seq_file.h>
 #include <linux/major.h>
 #include <linux/root_dev.h>
+#include <linux/delay.h>
+#include <linux/nfs_fs.h>
 #include <net/arp.h>
 #include <net/ip.h>
 #include <net/ipconfig.h>
+#include <net/route.h>
 
 #include <asm/uaccess.h>
 #include <net/checksum.h>
@@ -84,8 +88,8 @@
 #endif
 
 /* Define the friendly delay before and after opening net devices */
-#define CONF_PRE_OPEN          (HZ/2)  /* Before opening: 1/2 second */
-#define CONF_POST_OPEN         (1*HZ)  /* After opening: 1 second */
+#define CONF_PRE_OPEN          500     /* Before opening: 1/2 second */
+#define CONF_POST_OPEN         1       /* After opening: 1 second */
 
 /* Define the timeout for waiting for a DHCP/BOOTP/RARP reply */
 #define CONF_OPEN_RETRIES      2       /* (Re)open devices twice */
  */
 int ic_set_manually __initdata = 0;            /* IPconfig parameters set manually */
 
-int ic_enable __initdata = 0;                  /* IP config enabled? */
+static int ic_enable __initdata = 0;           /* IP config enabled? */
 
 /* Protocol choice */
 int ic_proto_enabled __initdata = 0
@@ -124,10 +128,10 @@ int ic_proto_enabled __initdata = 0
 #endif
                        ;
 
-int ic_host_name_set __initdata = 0;           /* Host name set by us? */
+static int ic_host_name_set __initdata = 0;    /* Host name set by us? */
 
 u32 ic_myaddr = INADDR_NONE;           /* My IP address */
-u32 ic_netmask = INADDR_NONE;  /* Netmask for local subnet */
+static u32 ic_netmask = INADDR_NONE;   /* Netmask for local subnet */
 u32 ic_gateway = INADDR_NONE;  /* Gateway IP address */
 
 u32 ic_servaddr = INADDR_NONE; /* Boot server IP address */
@@ -137,9 +141,9 @@ u8 root_server_path[256] = { 0, };  /* Path to mount as root */
 
 /* Persistent data: */
 
-int ic_proto_used;                     /* Protocol used, if any */
-u32 ic_nameservers[CONF_NAMESERVERS_MAX]; /* DNS Server IP addresses */
-u8 ic_domain[64];              /* DNS (not NIS) domain name */
+static int ic_proto_used;                      /* Protocol used, if any */
+static u32 ic_nameservers[CONF_NAMESERVERS_MAX]; /* DNS Server IP addresses */
+static u8 ic_domain[64];               /* DNS (not NIS) domain name */
 
 /*
  * Private state.
@@ -152,7 +156,7 @@ static char user_dev_name[IFNAMSIZ] __initdata = { 0, };
 static int ic_proto_have_if __initdata = 0;
 
 #ifdef IPCONFIG_DYNAMIC
-static spinlock_t ic_recv_lock = SPIN_LOCK_UNLOCKED;
+static DEFINE_SPINLOCK(ic_recv_lock);
 static volatile int ic_got_reply __initdata = 0;    /* Proto(s) that replied */
 #endif
 #ifdef IPCONFIG_DHCP
@@ -182,7 +186,7 @@ static int __init ic_open_devs(void)
        unsigned short oflags;
 
        last = &ic_first_dev;
-       rtnl_shlock();
+       rtnl_lock();
 
        /* bring loopback device up first */
        if (dev_change_flags(&loopback_dev, loopback_dev.flags | IFF_UP) < 0)
@@ -211,7 +215,7 @@ static int __init ic_open_devs(void)
                                continue;
                        }
                        if (!(d = kmalloc(sizeof(struct ic_device), GFP_KERNEL))) {
-                               rtnl_shunlock();
+                               rtnl_unlock();
                                return -1;
                        }
                        d->dev = dev;
@@ -228,7 +232,7 @@ static int __init ic_open_devs(void)
                                dev->name, able, d->xid));
                }
        }
-       rtnl_shunlock();
+       rtnl_unlock();
 
        *last = NULL;
 
@@ -247,7 +251,7 @@ static void __init ic_close_devs(void)
        struct ic_device *d, *next;
        struct net_device *dev;
 
-       rtnl_shlock();
+       rtnl_lock();
        next = ic_first_dev;
        while ((d = next)) {
                next = d->next;
@@ -258,7 +262,7 @@ static void __init ic_close_devs(void)
                }
                kfree(d);
        }
-       rtnl_shunlock();
+       rtnl_unlock();
 }
 
 /*
@@ -392,7 +396,7 @@ static int __init ic_defaults(void)
 
 #ifdef IPCONFIG_RARP
 
-static int ic_rarp_recv(struct sk_buff *skb, struct net_device *dev, struct packet_type *pt);
+static int ic_rarp_recv(struct sk_buff *skb, struct net_device *dev, struct packet_type *pt, struct net_device *orig_dev);
 
 static struct packet_type rarp_packet_type __initdata = {
        .type = __constant_htons(ETH_P_RARP),
@@ -413,7 +417,7 @@ static inline void ic_rarp_cleanup(void)
  *  Process received RARP packet.
  */
 static int __init
-ic_rarp_recv(struct sk_buff *skb, struct net_device *dev, struct packet_type *pt)
+ic_rarp_recv(struct sk_buff *skb, struct net_device *dev, struct packet_type *pt, struct net_device *orig_dev)
 {
        struct arphdr *rarp;
        unsigned char *rarp_ptr;
@@ -554,7 +558,7 @@ struct bootp_pkt {          /* BOOTP packet format */
 #define DHCPRELEASE    7
 #define DHCPINFORM     8
 
-static int ic_bootp_recv(struct sk_buff *skb, struct net_device *dev, struct packet_type *pt);
+static int ic_bootp_recv(struct sk_buff *skb, struct net_device *dev, struct packet_type *pt, struct net_device *orig_dev);
 
 static struct packet_type bootp_packet_type __initdata = {
        .type = __constant_htons(ETH_P_IP),
@@ -822,7 +826,7 @@ static void __init ic_do_bootp_ext(u8 *ext)
 /*
  *  Receive BOOTP reply.
  */
-static int __init ic_bootp_recv(struct sk_buff *skb, struct net_device *dev, struct packet_type *pt)
+static int __init ic_bootp_recv(struct sk_buff *skb, struct net_device *dev, struct packet_type *pt, struct net_device *orig_dev)
 {
        struct bootp_pkt *b;
        struct iphdr *h;
@@ -1101,10 +1105,8 @@ static int __init ic_dynamic(void)
 #endif
 
                jiff = jiffies + (d->next ? CONF_INTER_TIMEOUT : timeout);
-               while (time_before(jiffies, jiff) && !ic_got_reply) {
-                       barrier();
-                       cpu_relax();
-               }
+               while (time_before(jiffies, jiff) && !ic_got_reply)
+                       schedule_timeout_uninterruptible(1);
 #ifdef IPCONFIG_DHCP
                /* DHCP isn't done until we get a DHCPACK. */
                if ((ic_got_reply & IC_BOOTP)
@@ -1148,8 +1150,10 @@ static int __init ic_dynamic(void)
                ic_rarp_cleanup();
 #endif
 
-       if (!ic_got_reply)
+       if (!ic_got_reply) {
+               ic_myaddr = INADDR_NONE;
                return -1;
+       }
 
        printk("IP-Config: Got %s answer from %u.%u.%u.%u, ",
                ((ic_got_reply & IC_RARP) ? "RARP" 
@@ -1232,7 +1236,7 @@ u32 __init root_nfs_parse_addr(char *name)
                if (*cp == ':')
                        *cp++ = '\0';
                addr = in_aton(name);
-               strcpy(name, cp);
+               memmove(name, cp, strlen(cp) + 1);
        } else
                addr = INADDR_NONE;
 
@@ -1245,7 +1249,6 @@ u32 __init root_nfs_parse_addr(char *name)
 
 static int __init ip_auto_config(void)
 {
-       unsigned long jiff;
        u32 addr;
 
 #ifdef CONFIG_PROC_FS
@@ -1260,18 +1263,14 @@ static int __init ip_auto_config(void)
  try_try_again:
 #endif
        /* Give hardware a chance to settle */
-       jiff = jiffies + CONF_PRE_OPEN;
-       while (time_before(jiffies, jiff))
-               cpu_relax();
+       msleep(CONF_PRE_OPEN);
 
        /* Setup all network devices */
        if (ic_open_devs() < 0)
                return -1;
 
        /* Give drivers a chance to settle */
-       jiff = jiffies + CONF_POST_OPEN;
-       while (time_before(jiffies, jiff))
-               cpu_relax();
+       ssleep(CONF_POST_OPEN);
 
        /*
         * If the config information is insufficient (e.g., our IP address or