Diff markup
1 /* 1 /*
>> 2 * $Id: ipconfig.c,v 1.46 2002/02/01 22:01:04 davem Exp $
>> 3 *
2 * Automatic Configuration of IP -- use DHCP, 4 * Automatic Configuration of IP -- use DHCP, BOOTP, RARP, or
3 * user-supplied information to configure own 5 * user-supplied information to configure own IP address and routes.
4 * 6 *
5 * Copyright (C) 1996-1998 Martin Mares <mj@a 7 * Copyright (C) 1996-1998 Martin Mares <mj@atrey.karlin.mff.cuni.cz>
6 * 8 *
7 * Derived from network configuration code in 9 * Derived from network configuration code in fs/nfs/nfsroot.c,
8 * originally Copyright (C) 1995, 1996 Gero K 10 * originally Copyright (C) 1995, 1996 Gero Kuhlmann and me.
9 * 11 *
10 * BOOTP rewritten to construct and analyse p 12 * BOOTP rewritten to construct and analyse packets itself instead
11 * of misusing the IP layer. num_bugs_causing 13 * of misusing the IP layer. num_bugs_causing_wrong_arp_replies--;
12 * - 14 * -- MJ, December 1998
13 * 15 *
14 * Fixed ip_auto_config_setup calling at star 16 * Fixed ip_auto_config_setup calling at startup in the new "Linker Magic"
15 * initialization scheme. 17 * initialization scheme.
16 * - Arnaldo Carvalho de Melo <acme@conec 18 * - Arnaldo Carvalho de Melo <acme@conectiva.com.br>, 08/11/1999
17 * 19 *
18 * DHCP support added. To users this looks l 20 * DHCP support added. To users this looks like a whole separate
19 * protocol, but we know it's just a bag on t 21 * protocol, but we know it's just a bag on the side of BOOTP.
20 * -- Chip Salzenberg <chip@valin 22 * -- Chip Salzenberg <chip@valinux.com>, May 2000
21 * 23 *
22 * Ported DHCP support from 2.2.16 to 2.4.0-t 24 * Ported DHCP support from 2.2.16 to 2.4.0-test4
23 * -- Eric Biederman <ebiederman@ 25 * -- Eric Biederman <ebiederman@lnxi.com>, 30 Aug 2000
24 * 26 *
25 * Merged changes from 2.2.19 into 2.4.3 27 * Merged changes from 2.2.19 into 2.4.3
26 * -- Eric Biederman <ebiederman@ 28 * -- Eric Biederman <ebiederman@lnxi.com>, 22 April Aug 2001
27 * 29 *
28 * Multiple Nameservers in /proc/net/pnp 30 * Multiple Nameservers in /proc/net/pnp
29 * -- Josef Siemes <jsiemes@web. 31 * -- Josef Siemes <jsiemes@web.de>, Aug 2002
30 */ 32 */
31 33
32 #include <linux/types.h> 34 #include <linux/types.h>
33 #include <linux/string.h> 35 #include <linux/string.h>
34 #include <linux/kernel.h> 36 #include <linux/kernel.h>
35 #include <linux/jiffies.h> 37 #include <linux/jiffies.h>
36 #include <linux/random.h> 38 #include <linux/random.h>
37 #include <linux/init.h> 39 #include <linux/init.h>
38 #include <linux/utsname.h> 40 #include <linux/utsname.h>
39 #include <linux/in.h> 41 #include <linux/in.h>
40 #include <linux/if.h> 42 #include <linux/if.h>
41 #include <linux/inet.h> 43 #include <linux/inet.h>
42 #include <linux/inetdevice.h> 44 #include <linux/inetdevice.h>
43 #include <linux/netdevice.h> 45 #include <linux/netdevice.h>
44 #include <linux/if_arp.h> 46 #include <linux/if_arp.h>
45 #include <linux/skbuff.h> 47 #include <linux/skbuff.h>
46 #include <linux/ip.h> 48 #include <linux/ip.h>
47 #include <linux/socket.h> 49 #include <linux/socket.h>
48 #include <linux/route.h> 50 #include <linux/route.h>
49 #include <linux/udp.h> 51 #include <linux/udp.h>
50 #include <linux/proc_fs.h> 52 #include <linux/proc_fs.h>
51 #include <linux/seq_file.h> 53 #include <linux/seq_file.h>
52 #include <linux/major.h> 54 #include <linux/major.h>
53 #include <linux/root_dev.h> 55 #include <linux/root_dev.h>
54 #include <linux/delay.h> 56 #include <linux/delay.h>
55 #include <linux/nfs_fs.h> 57 #include <linux/nfs_fs.h>
56 #include <net/net_namespace.h> 58 #include <net/net_namespace.h>
57 #include <net/arp.h> 59 #include <net/arp.h>
58 #include <net/ip.h> 60 #include <net/ip.h>
59 #include <net/ipconfig.h> 61 #include <net/ipconfig.h>
60 #include <net/route.h> 62 #include <net/route.h>
61 63
62 #include <asm/uaccess.h> 64 #include <asm/uaccess.h>
63 #include <net/checksum.h> 65 #include <net/checksum.h>
64 #include <asm/processor.h> 66 #include <asm/processor.h>
65 67
66 /* Define this to allow debugging output */ 68 /* Define this to allow debugging output */
67 #undef IPCONFIG_DEBUG 69 #undef IPCONFIG_DEBUG
68 70
69 #ifdef IPCONFIG_DEBUG 71 #ifdef IPCONFIG_DEBUG
70 #define DBG(x) printk x 72 #define DBG(x) printk x
71 #else 73 #else
72 #define DBG(x) do { } while(0) 74 #define DBG(x) do { } while(0)
73 #endif 75 #endif
74 76
75 #if defined(CONFIG_IP_PNP_DHCP) 77 #if defined(CONFIG_IP_PNP_DHCP)
76 #define IPCONFIG_DHCP 78 #define IPCONFIG_DHCP
77 #endif 79 #endif
78 #if defined(CONFIG_IP_PNP_BOOTP) || defined(CO 80 #if defined(CONFIG_IP_PNP_BOOTP) || defined(CONFIG_IP_PNP_DHCP)
79 #define IPCONFIG_BOOTP 81 #define IPCONFIG_BOOTP
80 #endif 82 #endif
81 #if defined(CONFIG_IP_PNP_RARP) 83 #if defined(CONFIG_IP_PNP_RARP)
82 #define IPCONFIG_RARP 84 #define IPCONFIG_RARP
83 #endif 85 #endif
84 #if defined(IPCONFIG_BOOTP) || defined(IPCONFI 86 #if defined(IPCONFIG_BOOTP) || defined(IPCONFIG_RARP)
85 #define IPCONFIG_DYNAMIC 87 #define IPCONFIG_DYNAMIC
86 #endif 88 #endif
87 89
88 /* Define the friendly delay before and after 90 /* Define the friendly delay before and after opening net devices */
89 #define CONF_PRE_OPEN 500 /* Bef 91 #define CONF_PRE_OPEN 500 /* Before opening: 1/2 second */
90 #define CONF_POST_OPEN 1 /* Aft 92 #define CONF_POST_OPEN 1 /* After opening: 1 second */
91 93
92 /* Define the timeout for waiting for a DHCP/B 94 /* Define the timeout for waiting for a DHCP/BOOTP/RARP reply */
93 #define CONF_OPEN_RETRIES 2 /* (Re 95 #define CONF_OPEN_RETRIES 2 /* (Re)open devices twice */
94 #define CONF_SEND_RETRIES 6 /* Sen 96 #define CONF_SEND_RETRIES 6 /* Send six requests per open */
95 #define CONF_INTER_TIMEOUT (HZ/2) /* Int 97 #define CONF_INTER_TIMEOUT (HZ/2) /* Inter-device timeout: 1/2 second */
96 #define CONF_BASE_TIMEOUT (HZ*2) /* Ini 98 #define CONF_BASE_TIMEOUT (HZ*2) /* Initial timeout: 2 seconds */
97 #define CONF_TIMEOUT_RANDOM (HZ) /* Max 99 #define CONF_TIMEOUT_RANDOM (HZ) /* Maximum amount of randomization */
98 #define CONF_TIMEOUT_MULT *7/4 /* Rat 100 #define CONF_TIMEOUT_MULT *7/4 /* Rate of timeout growth */
99 #define CONF_TIMEOUT_MAX (HZ*30) /* Max 101 #define CONF_TIMEOUT_MAX (HZ*30) /* Maximum allowed timeout */
100 #define CONF_NAMESERVERS_MAX 3 /* Maxi 102 #define CONF_NAMESERVERS_MAX 3 /* Maximum number of nameservers
101 - ' 103 - '3' from resolv.h */
102 104
103 #define NONE cpu_to_be32(INADDR_NONE) !! 105 #define NONE __constant_htonl(INADDR_NONE)
104 #define ANY cpu_to_be32(INADDR_ANY) !! 106 #define ANY __constant_htonl(INADDR_ANY)
105 107
106 /* 108 /*
107 * Public IP configuration 109 * Public IP configuration
108 */ 110 */
109 111
110 /* This is used by platforms which might be ab 112 /* This is used by platforms which might be able to set the ipconfig
111 * variables using firmware environment vars. 113 * variables using firmware environment vars. If this is set, it will
112 * ignore such firmware variables. 114 * ignore such firmware variables.
113 */ 115 */
114 int ic_set_manually __initdata = 0; 116 int ic_set_manually __initdata = 0; /* IPconfig parameters set manually */
115 117
116 static int ic_enable __initdata = 0; 118 static int ic_enable __initdata = 0; /* IP config enabled? */
117 119
118 /* Protocol choice */ 120 /* Protocol choice */
119 int ic_proto_enabled __initdata = 0 121 int ic_proto_enabled __initdata = 0
120 #ifdef IPCONFIG_BOOTP 122 #ifdef IPCONFIG_BOOTP
121 | IC_BOOTP 123 | IC_BOOTP
122 #endif 124 #endif
123 #ifdef CONFIG_IP_PNP_DHCP 125 #ifdef CONFIG_IP_PNP_DHCP
124 | IC_USE_DHCP 126 | IC_USE_DHCP
125 #endif 127 #endif
126 #ifdef IPCONFIG_RARP 128 #ifdef IPCONFIG_RARP
127 | IC_RARP 129 | IC_RARP
128 #endif 130 #endif
129 ; 131 ;
130 132
131 static int ic_host_name_set __initdata = 0; 133 static int ic_host_name_set __initdata = 0; /* Host name set by us? */
132 134
133 __be32 ic_myaddr = NONE; /* My 135 __be32 ic_myaddr = NONE; /* My IP address */
134 static __be32 ic_netmask = NONE; /* Net 136 static __be32 ic_netmask = NONE; /* Netmask for local subnet */
135 __be32 ic_gateway = NONE; /* Gateway IP 137 __be32 ic_gateway = NONE; /* Gateway IP address */
136 138
137 __be32 ic_servaddr = NONE; /* Boot server 139 __be32 ic_servaddr = NONE; /* Boot server IP address */
138 140
139 __be32 root_server_addr = NONE; /* Address of 141 __be32 root_server_addr = NONE; /* Address of NFS server */
140 u8 root_server_path[256] = { 0, }; /* Pat 142 u8 root_server_path[256] = { 0, }; /* Path to mount as root */
141 143
142 u32 ic_dev_xid; /* Device under config <<
143 <<
144 /* vendor class identifier */ 144 /* vendor class identifier */
145 static char vendor_class_identifier[253] __ini 145 static char vendor_class_identifier[253] __initdata;
146 146
147 /* Persistent data: */ 147 /* Persistent data: */
148 148
149 static int ic_proto_used; 149 static int ic_proto_used; /* Protocol used, if any */
150 static __be32 ic_nameservers[CONF_NAMESERVERS_ 150 static __be32 ic_nameservers[CONF_NAMESERVERS_MAX]; /* DNS Server IP addresses */
151 static u8 ic_domain[64]; /* DNS 151 static u8 ic_domain[64]; /* DNS (not NIS) domain name */
152 152
153 /* 153 /*
154 * Private state. 154 * Private state.
155 */ 155 */
156 156
157 /* Name of user-selected boot device */ 157 /* Name of user-selected boot device */
158 static char user_dev_name[IFNAMSIZ] __initdata 158 static char user_dev_name[IFNAMSIZ] __initdata = { 0, };
159 159
160 /* Protocols supported by available interfaces 160 /* Protocols supported by available interfaces */
161 static int ic_proto_have_if __initdata = 0; 161 static int ic_proto_have_if __initdata = 0;
162 162
163 /* MTU for boot device */ <<
164 static int ic_dev_mtu __initdata = 0; <<
165 <<
166 #ifdef IPCONFIG_DYNAMIC 163 #ifdef IPCONFIG_DYNAMIC
167 static DEFINE_SPINLOCK(ic_recv_lock); 164 static DEFINE_SPINLOCK(ic_recv_lock);
168 static volatile int ic_got_reply __initdata = 165 static volatile int ic_got_reply __initdata = 0; /* Proto(s) that replied */
169 #endif 166 #endif
170 #ifdef IPCONFIG_DHCP 167 #ifdef IPCONFIG_DHCP
171 static int ic_dhcp_msgtype __initdata = 0; 168 static int ic_dhcp_msgtype __initdata = 0; /* DHCP msg type received */
172 #endif 169 #endif
173 170
174 171
175 /* 172 /*
176 * Network devices 173 * Network devices
177 */ 174 */
178 175
179 struct ic_device { 176 struct ic_device {
180 struct ic_device *next; 177 struct ic_device *next;
181 struct net_device *dev; 178 struct net_device *dev;
182 unsigned short flags; 179 unsigned short flags;
183 short able; 180 short able;
184 __be32 xid; 181 __be32 xid;
185 }; 182 };
186 183
187 static struct ic_device *ic_first_dev __initda 184 static struct ic_device *ic_first_dev __initdata = NULL;/* List of open device */
188 static struct net_device *ic_dev __initdata = 185 static struct net_device *ic_dev __initdata = NULL; /* Selected device */
189 186
190 static int __init ic_open_devs(void) 187 static int __init ic_open_devs(void)
191 { 188 {
192 struct ic_device *d, **last; 189 struct ic_device *d, **last;
193 struct net_device *dev; 190 struct net_device *dev;
194 unsigned short oflags; 191 unsigned short oflags;
195 192
196 last = &ic_first_dev; 193 last = &ic_first_dev;
197 rtnl_lock(); 194 rtnl_lock();
198 195
199 /* bring loopback device up first */ 196 /* bring loopback device up first */
200 for_each_netdev(&init_net, dev) { 197 for_each_netdev(&init_net, dev) {
201 if (!(dev->flags & IFF_LOOPBAC 198 if (!(dev->flags & IFF_LOOPBACK))
202 continue; 199 continue;
203 if (dev_change_flags(dev, dev- 200 if (dev_change_flags(dev, dev->flags | IFF_UP) < 0)
204 printk(KERN_ERR "IP-Co 201 printk(KERN_ERR "IP-Config: Failed to open %s\n", dev->name);
205 } 202 }
206 203
207 for_each_netdev(&init_net, dev) { 204 for_each_netdev(&init_net, dev) {
208 if (dev->flags & IFF_LOOPBACK) 205 if (dev->flags & IFF_LOOPBACK)
209 continue; 206 continue;
210 if (user_dev_name[0] ? !strcmp 207 if (user_dev_name[0] ? !strcmp(dev->name, user_dev_name) :
211 (!(dev->flags & IFF_LOOPBA 208 (!(dev->flags & IFF_LOOPBACK) &&
212 (dev->flags & (IFF_POINTO 209 (dev->flags & (IFF_POINTOPOINT|IFF_BROADCAST)) &&
213 strncmp(dev->name, "dummy 210 strncmp(dev->name, "dummy", 5))) {
214 int able = 0; 211 int able = 0;
215 if (dev->mtu >= 364) 212 if (dev->mtu >= 364)
216 able |= IC_BOO 213 able |= IC_BOOTP;
217 else 214 else
218 printk(KERN_WA 215 printk(KERN_WARNING "DHCP/BOOTP: Ignoring device %s, MTU %d too small", dev->name, dev->mtu);
219 if (!(dev->flags & IFF 216 if (!(dev->flags & IFF_NOARP))
220 able |= IC_RAR 217 able |= IC_RARP;
221 able &= ic_proto_enabl 218 able &= ic_proto_enabled;
222 if (ic_proto_enabled & 219 if (ic_proto_enabled && !able)
223 continue; 220 continue;
224 oflags = dev->flags; 221 oflags = dev->flags;
225 if (dev_change_flags(d 222 if (dev_change_flags(dev, oflags | IFF_UP) < 0) {
226 printk(KERN_ER 223 printk(KERN_ERR "IP-Config: Failed to open %s\n", dev->name);
227 continue; 224 continue;
228 } 225 }
229 if (!(d = kmalloc(size 226 if (!(d = kmalloc(sizeof(struct ic_device), GFP_KERNEL))) {
230 rtnl_unlock(); 227 rtnl_unlock();
231 return -1; 228 return -1;
232 } 229 }
233 d->dev = dev; 230 d->dev = dev;
234 *last = d; 231 *last = d;
235 last = &d->next; 232 last = &d->next;
236 d->flags = oflags; 233 d->flags = oflags;
237 d->able = able; 234 d->able = able;
238 if (able & IC_BOOTP) 235 if (able & IC_BOOTP)
239 get_random_byt 236 get_random_bytes(&d->xid, sizeof(__be32));
240 else 237 else
241 d->xid = 0; 238 d->xid = 0;
242 ic_proto_have_if |= ab 239 ic_proto_have_if |= able;
243 DBG(("IP-Config: %s UP 240 DBG(("IP-Config: %s UP (able=%d, xid=%08x)\n",
244 dev->name, abl 241 dev->name, able, d->xid));
245 } 242 }
246 } 243 }
247 rtnl_unlock(); 244 rtnl_unlock();
248 245
249 *last = NULL; 246 *last = NULL;
250 247
251 if (!ic_first_dev) { 248 if (!ic_first_dev) {
252 if (user_dev_name[0]) 249 if (user_dev_name[0])
253 printk(KERN_ERR "IP-Co 250 printk(KERN_ERR "IP-Config: Device `%s' not found.\n", user_dev_name);
254 else 251 else
255 printk(KERN_ERR "IP-Co 252 printk(KERN_ERR "IP-Config: No network devices available.\n");
256 return -1; 253 return -1;
257 } 254 }
258 return 0; 255 return 0;
259 } 256 }
260 257
261 static void __init ic_close_devs(void) 258 static void __init ic_close_devs(void)
262 { 259 {
263 struct ic_device *d, *next; 260 struct ic_device *d, *next;
264 struct net_device *dev; 261 struct net_device *dev;
265 262
266 rtnl_lock(); 263 rtnl_lock();
267 next = ic_first_dev; 264 next = ic_first_dev;
268 while ((d = next)) { 265 while ((d = next)) {
269 next = d->next; 266 next = d->next;
270 dev = d->dev; 267 dev = d->dev;
271 if (dev != ic_dev) { 268 if (dev != ic_dev) {
272 DBG(("IP-Config: Downi 269 DBG(("IP-Config: Downing %s\n", dev->name));
273 dev_change_flags(dev, 270 dev_change_flags(dev, d->flags);
274 } 271 }
275 kfree(d); 272 kfree(d);
276 } 273 }
277 rtnl_unlock(); 274 rtnl_unlock();
278 } 275 }
279 276
280 /* 277 /*
281 * Interface to various network functions 278 * Interface to various network functions.
282 */ 279 */
283 280
284 static inline void 281 static inline void
285 set_sockaddr(struct sockaddr_in *sin, __be32 a 282 set_sockaddr(struct sockaddr_in *sin, __be32 addr, __be16 port)
286 { 283 {
287 sin->sin_family = AF_INET; 284 sin->sin_family = AF_INET;
288 sin->sin_addr.s_addr = addr; 285 sin->sin_addr.s_addr = addr;
289 sin->sin_port = port; 286 sin->sin_port = port;
290 } 287 }
291 288
292 static int __init ic_devinet_ioctl(unsigned in <<
293 { <<
294 int res; <<
295 <<
296 mm_segment_t oldfs = get_fs(); <<
297 set_fs(get_ds()); <<
298 res = devinet_ioctl(&init_net, cmd, (s <<
299 set_fs(oldfs); <<
300 return res; <<
301 } <<
302 <<
303 static int __init ic_dev_ioctl(unsigned int cm 289 static int __init ic_dev_ioctl(unsigned int cmd, struct ifreq *arg)
304 { 290 {
305 int res; 291 int res;
306 292
307 mm_segment_t oldfs = get_fs(); 293 mm_segment_t oldfs = get_fs();
308 set_fs(get_ds()); 294 set_fs(get_ds());
309 res = dev_ioctl(&init_net, cmd, (struc !! 295 res = devinet_ioctl(cmd, (struct ifreq __user *) arg);
310 set_fs(oldfs); 296 set_fs(oldfs);
311 return res; 297 return res;
312 } 298 }
313 299
314 static int __init ic_route_ioctl(unsigned int 300 static int __init ic_route_ioctl(unsigned int cmd, struct rtentry *arg)
315 { 301 {
316 int res; 302 int res;
317 303
318 mm_segment_t oldfs = get_fs(); 304 mm_segment_t oldfs = get_fs();
319 set_fs(get_ds()); 305 set_fs(get_ds());
320 res = ip_rt_ioctl(&init_net, cmd, (voi 306 res = ip_rt_ioctl(&init_net, cmd, (void __user *) arg);
321 set_fs(oldfs); 307 set_fs(oldfs);
322 return res; 308 return res;
323 } 309 }
324 310
325 /* 311 /*
326 * Set up interface addresses and routes. 312 * Set up interface addresses and routes.
327 */ 313 */
328 314
329 static int __init ic_setup_if(void) 315 static int __init ic_setup_if(void)
330 { 316 {
331 struct ifreq ir; 317 struct ifreq ir;
332 struct sockaddr_in *sin = (void *) &ir 318 struct sockaddr_in *sin = (void *) &ir.ifr_ifru.ifru_addr;
333 int err; 319 int err;
334 320
335 memset(&ir, 0, sizeof(ir)); 321 memset(&ir, 0, sizeof(ir));
336 strcpy(ir.ifr_ifrn.ifrn_name, ic_dev-> 322 strcpy(ir.ifr_ifrn.ifrn_name, ic_dev->name);
337 set_sockaddr(sin, ic_myaddr, 0); 323 set_sockaddr(sin, ic_myaddr, 0);
338 if ((err = ic_devinet_ioctl(SIOCSIFADD !! 324 if ((err = ic_dev_ioctl(SIOCSIFADDR, &ir)) < 0) {
339 printk(KERN_ERR "IP-Config: Un 325 printk(KERN_ERR "IP-Config: Unable to set interface address (%d).\n", err);
340 return -1; 326 return -1;
341 } 327 }
342 set_sockaddr(sin, ic_netmask, 0); 328 set_sockaddr(sin, ic_netmask, 0);
343 if ((err = ic_devinet_ioctl(SIOCSIFNET !! 329 if ((err = ic_dev_ioctl(SIOCSIFNETMASK, &ir)) < 0) {
344 printk(KERN_ERR "IP-Config: Un 330 printk(KERN_ERR "IP-Config: Unable to set interface netmask (%d).\n", err);
345 return -1; 331 return -1;
346 } 332 }
347 set_sockaddr(sin, ic_myaddr | ~ic_netm 333 set_sockaddr(sin, ic_myaddr | ~ic_netmask, 0);
348 if ((err = ic_devinet_ioctl(SIOCSIFBRD !! 334 if ((err = ic_dev_ioctl(SIOCSIFBRDADDR, &ir)) < 0) {
349 printk(KERN_ERR "IP-Config: Un 335 printk(KERN_ERR "IP-Config: Unable to set interface broadcast address (%d).\n", err);
350 return -1; 336 return -1;
351 } 337 }
352 /* Handle the case where we need non-s <<
353 * using jumbo frames, for instance). <<
354 * out, we'll try to muddle along. <<
355 */ <<
356 if (ic_dev_mtu != 0) { <<
357 strcpy(ir.ifr_name, ic_dev->na <<
358 ir.ifr_mtu = ic_dev_mtu; <<
359 if ((err = ic_dev_ioctl(SIOCSI <<
360 printk(KERN_ERR "IP-Co <<
361 ic_de <<
362 } <<
363 return 0; 338 return 0;
364 } 339 }
365 340
366 static int __init ic_setup_routes(void) 341 static int __init ic_setup_routes(void)
367 { 342 {
368 /* No need to setup device routes, onl 343 /* No need to setup device routes, only the default route... */
369 344
370 if (ic_gateway != NONE) { 345 if (ic_gateway != NONE) {
371 struct rtentry rm; 346 struct rtentry rm;
372 int err; 347 int err;
373 348
374 memset(&rm, 0, sizeof(rm)); 349 memset(&rm, 0, sizeof(rm));
375 if ((ic_gateway ^ ic_myaddr) & 350 if ((ic_gateway ^ ic_myaddr) & ic_netmask) {
376 printk(KERN_ERR "IP-Co 351 printk(KERN_ERR "IP-Config: Gateway not on directly connected network.\n");
377 return -1; 352 return -1;
378 } 353 }
379 set_sockaddr((struct sockaddr_ 354 set_sockaddr((struct sockaddr_in *) &rm.rt_dst, 0, 0);
380 set_sockaddr((struct sockaddr_ 355 set_sockaddr((struct sockaddr_in *) &rm.rt_genmask, 0, 0);
381 set_sockaddr((struct sockaddr_ 356 set_sockaddr((struct sockaddr_in *) &rm.rt_gateway, ic_gateway, 0);
382 rm.rt_flags = RTF_UP | RTF_GAT 357 rm.rt_flags = RTF_UP | RTF_GATEWAY;
383 if ((err = ic_route_ioctl(SIOC 358 if ((err = ic_route_ioctl(SIOCADDRT, &rm)) < 0) {
384 printk(KERN_ERR "IP-Co 359 printk(KERN_ERR "IP-Config: Cannot add default route (%d).\n", err);
385 return -1; 360 return -1;
386 } 361 }
387 } 362 }
388 363
389 return 0; 364 return 0;
390 } 365 }
391 366
392 /* 367 /*
393 * Fill in default values for all missing 368 * Fill in default values for all missing parameters.
394 */ 369 */
395 370
396 static int __init ic_defaults(void) 371 static int __init ic_defaults(void)
397 { 372 {
398 /* 373 /*
399 * At this point we have no users 374 * At this point we have no userspace running so need not
400 * claim locks on system_utsname 375 * claim locks on system_utsname
401 */ 376 */
402 377
403 if (!ic_host_name_set) 378 if (!ic_host_name_set)
404 sprintf(init_utsname()->nodena !! 379 sprintf(init_utsname()->nodename, "%u.%u.%u.%u", NIPQUAD(ic_myaddr));
405 380
406 if (root_server_addr == NONE) 381 if (root_server_addr == NONE)
407 root_server_addr = ic_servaddr 382 root_server_addr = ic_servaddr;
408 383
409 if (ic_netmask == NONE) { 384 if (ic_netmask == NONE) {
410 if (IN_CLASSA(ntohl(ic_myaddr) 385 if (IN_CLASSA(ntohl(ic_myaddr)))
411 ic_netmask = htonl(IN_ 386 ic_netmask = htonl(IN_CLASSA_NET);
412 else if (IN_CLASSB(ntohl(ic_my 387 else if (IN_CLASSB(ntohl(ic_myaddr)))
413 ic_netmask = htonl(IN_ 388 ic_netmask = htonl(IN_CLASSB_NET);
414 else if (IN_CLASSC(ntohl(ic_my 389 else if (IN_CLASSC(ntohl(ic_myaddr)))
415 ic_netmask = htonl(IN_ 390 ic_netmask = htonl(IN_CLASSC_NET);
416 else { 391 else {
417 printk(KERN_ERR "IP-Co !! 392 printk(KERN_ERR "IP-Config: Unable to guess netmask for address %u.%u.%u.%u\n",
418 &ic_myaddr); !! 393 NIPQUAD(ic_myaddr));
419 return -1; 394 return -1;
420 } 395 }
421 printk("IP-Config: Guessing ne !! 396 printk("IP-Config: Guessing netmask %u.%u.%u.%u\n", NIPQUAD(ic_netmask));
422 } 397 }
423 398
424 return 0; 399 return 0;
425 } 400 }
426 401
427 /* 402 /*
428 * RARP support. 403 * RARP support.
429 */ 404 */
430 405
431 #ifdef IPCONFIG_RARP 406 #ifdef IPCONFIG_RARP
432 407
433 static int ic_rarp_recv(struct sk_buff *skb, s 408 static int ic_rarp_recv(struct sk_buff *skb, struct net_device *dev, struct packet_type *pt, struct net_device *orig_dev);
434 409
435 static struct packet_type rarp_packet_type __i 410 static struct packet_type rarp_packet_type __initdata = {
436 .type = cpu_to_be16(ETH_P_RARP), !! 411 .type = __constant_htons(ETH_P_RARP),
437 .func = ic_rarp_recv, 412 .func = ic_rarp_recv,
438 }; 413 };
439 414
440 static inline void __init ic_rarp_init(void) !! 415 static inline void ic_rarp_init(void)
441 { 416 {
442 dev_add_pack(&rarp_packet_type); 417 dev_add_pack(&rarp_packet_type);
443 } 418 }
444 419
445 static inline void __init ic_rarp_cleanup(void !! 420 static inline void ic_rarp_cleanup(void)
446 { 421 {
447 dev_remove_pack(&rarp_packet_type); 422 dev_remove_pack(&rarp_packet_type);
448 } 423 }
449 424
450 /* 425 /*
451 * Process received RARP packet. 426 * Process received RARP packet.
452 */ 427 */
453 static int __init 428 static int __init
454 ic_rarp_recv(struct sk_buff *skb, struct net_d 429 ic_rarp_recv(struct sk_buff *skb, struct net_device *dev, struct packet_type *pt, struct net_device *orig_dev)
455 { 430 {
456 struct arphdr *rarp; 431 struct arphdr *rarp;
457 unsigned char *rarp_ptr; 432 unsigned char *rarp_ptr;
458 __be32 sip, tip; 433 __be32 sip, tip;
459 unsigned char *sha, *tha; 434 unsigned char *sha, *tha; /* s for "source", t for "target" */
460 struct ic_device *d; 435 struct ic_device *d;
461 436
462 if (!net_eq(dev_net(dev), &init_net)) !! 437 if (dev->nd_net != &init_net)
463 goto drop; 438 goto drop;
464 439
465 if ((skb = skb_share_check(skb, GFP_AT 440 if ((skb = skb_share_check(skb, GFP_ATOMIC)) == NULL)
466 return NET_RX_DROP; 441 return NET_RX_DROP;
467 442
468 if (!pskb_may_pull(skb, sizeof(struct 443 if (!pskb_may_pull(skb, sizeof(struct arphdr)))
469 goto drop; 444 goto drop;
470 445
471 /* Basic sanity checks can be done wit 446 /* Basic sanity checks can be done without the lock. */
472 rarp = (struct arphdr *)skb_transport_ 447 rarp = (struct arphdr *)skb_transport_header(skb);
473 448
474 /* If this test doesn't pass, it's not 449 /* If this test doesn't pass, it's not IP, or we should
475 * ignore it anyway. 450 * ignore it anyway.
476 */ 451 */
477 if (rarp->ar_hln != dev->addr_len || d 452 if (rarp->ar_hln != dev->addr_len || dev->type != ntohs(rarp->ar_hrd))
478 goto drop; 453 goto drop;
479 454
480 /* If it's not a RARP reply, delete it 455 /* If it's not a RARP reply, delete it. */
481 if (rarp->ar_op != htons(ARPOP_RREPLY) 456 if (rarp->ar_op != htons(ARPOP_RREPLY))
482 goto drop; 457 goto drop;
483 458
484 /* If it's not Ethernet, delete it. */ 459 /* If it's not Ethernet, delete it. */
485 if (rarp->ar_pro != htons(ETH_P_IP)) 460 if (rarp->ar_pro != htons(ETH_P_IP))
486 goto drop; 461 goto drop;
487 462
488 if (!pskb_may_pull(skb, arp_hdr_len(de !! 463 if (!pskb_may_pull(skb,
>> 464 sizeof(struct arphdr) +
>> 465 (2 * dev->addr_len) +
>> 466 (2 * 4)))
489 goto drop; 467 goto drop;
490 468
491 /* OK, it is all there and looks valid 469 /* OK, it is all there and looks valid, process... */
492 rarp = (struct arphdr *)skb_transport_ 470 rarp = (struct arphdr *)skb_transport_header(skb);
493 rarp_ptr = (unsigned char *) (rarp + 1 471 rarp_ptr = (unsigned char *) (rarp + 1);
494 472
495 /* One reply at a time, please. */ 473 /* One reply at a time, please. */
496 spin_lock(&ic_recv_lock); 474 spin_lock(&ic_recv_lock);
497 475
498 /* If we already have a reply, just dr 476 /* If we already have a reply, just drop the packet */
499 if (ic_got_reply) 477 if (ic_got_reply)
500 goto drop_unlock; 478 goto drop_unlock;
501 479
502 /* Find the ic_device that the packet 480 /* Find the ic_device that the packet arrived on */
503 d = ic_first_dev; 481 d = ic_first_dev;
504 while (d && d->dev != dev) 482 while (d && d->dev != dev)
505 d = d->next; 483 d = d->next;
506 if (!d) 484 if (!d)
507 goto drop_unlock; /* sho 485 goto drop_unlock; /* should never happen */
508 486
509 /* Extract variable-width fields */ 487 /* Extract variable-width fields */
510 sha = rarp_ptr; 488 sha = rarp_ptr;
511 rarp_ptr += dev->addr_len; 489 rarp_ptr += dev->addr_len;
512 memcpy(&sip, rarp_ptr, 4); 490 memcpy(&sip, rarp_ptr, 4);
513 rarp_ptr += 4; 491 rarp_ptr += 4;
514 tha = rarp_ptr; 492 tha = rarp_ptr;
515 rarp_ptr += dev->addr_len; 493 rarp_ptr += dev->addr_len;
516 memcpy(&tip, rarp_ptr, 4); 494 memcpy(&tip, rarp_ptr, 4);
517 495
518 /* Discard packets which are not meant 496 /* Discard packets which are not meant for us. */
519 if (memcmp(tha, dev->dev_addr, dev->ad 497 if (memcmp(tha, dev->dev_addr, dev->addr_len))
520 goto drop_unlock; 498 goto drop_unlock;
521 499
522 /* Discard packets which are not from 500 /* Discard packets which are not from specified server. */
523 if (ic_servaddr != NONE && ic_servaddr 501 if (ic_servaddr != NONE && ic_servaddr != sip)
524 goto drop_unlock; 502 goto drop_unlock;
525 503
526 /* We have a winner! */ 504 /* We have a winner! */
527 ic_dev = dev; 505 ic_dev = dev;
528 if (ic_myaddr == NONE) 506 if (ic_myaddr == NONE)
529 ic_myaddr = tip; 507 ic_myaddr = tip;
530 ic_servaddr = sip; 508 ic_servaddr = sip;
531 ic_got_reply = IC_RARP; 509 ic_got_reply = IC_RARP;
532 510
533 drop_unlock: 511 drop_unlock:
534 /* Show's over. Nothing to see here. 512 /* Show's over. Nothing to see here. */
535 spin_unlock(&ic_recv_lock); 513 spin_unlock(&ic_recv_lock);
536 514
537 drop: 515 drop:
538 /* Throw the packet out. */ 516 /* Throw the packet out. */
539 kfree_skb(skb); 517 kfree_skb(skb);
540 return 0; 518 return 0;
541 } 519 }
542 520
543 521
544 /* 522 /*
545 * Send RARP request packet over a single int 523 * Send RARP request packet over a single interface.
546 */ 524 */
547 static void __init ic_rarp_send_if(struct ic_d 525 static void __init ic_rarp_send_if(struct ic_device *d)
548 { 526 {
549 struct net_device *dev = d->dev; 527 struct net_device *dev = d->dev;
550 arp_send(ARPOP_RREQUEST, ETH_P_RARP, 0 528 arp_send(ARPOP_RREQUEST, ETH_P_RARP, 0, dev, 0, NULL,
551 dev->dev_addr, dev->dev_addr) 529 dev->dev_addr, dev->dev_addr);
552 } 530 }
553 #endif 531 #endif
554 532
555 /* 533 /*
556 * DHCP/BOOTP support. 534 * DHCP/BOOTP support.
557 */ 535 */
558 536
559 #ifdef IPCONFIG_BOOTP 537 #ifdef IPCONFIG_BOOTP
560 538
561 struct bootp_pkt { /* BOOTP packe 539 struct bootp_pkt { /* BOOTP packet format */
562 struct iphdr iph; /* IP header * 540 struct iphdr iph; /* IP header */
563 struct udphdr udph; /* UDP header 541 struct udphdr udph; /* UDP header */
564 u8 op; /* 1=request, 542 u8 op; /* 1=request, 2=reply */
565 u8 htype; /* HW address 543 u8 htype; /* HW address type */
566 u8 hlen; /* HW address 544 u8 hlen; /* HW address length */
567 u8 hops; /* Used only b 545 u8 hops; /* Used only by gateways */
568 __be32 xid; /* Transaction 546 __be32 xid; /* Transaction ID */
569 __be16 secs; /* Seconds sin 547 __be16 secs; /* Seconds since we started */
570 __be16 flags; /* Just what i 548 __be16 flags; /* Just what it says */
571 __be32 client_ip; /* Cli 549 __be32 client_ip; /* Client's IP address if known */
572 __be32 your_ip; /* Assigned IP 550 __be32 your_ip; /* Assigned IP address */
573 __be32 server_ip; /* (Ne 551 __be32 server_ip; /* (Next, e.g. NFS) Server's IP address */
574 __be32 relay_ip; /* IP 552 __be32 relay_ip; /* IP address of BOOTP relay */
575 u8 hw_addr[16]; /* Client's HW 553 u8 hw_addr[16]; /* Client's HW address */
576 u8 serv_name[64]; /* Server host 554 u8 serv_name[64]; /* Server host name */
577 u8 boot_file[128]; /* Name of boo 555 u8 boot_file[128]; /* Name of boot file */
578 u8 exten[312]; /* DHCP option 556 u8 exten[312]; /* DHCP options / BOOTP vendor extensions */
579 }; 557 };
580 558
581 /* packet ops */ 559 /* packet ops */
582 #define BOOTP_REQUEST 1 560 #define BOOTP_REQUEST 1
583 #define BOOTP_REPLY 2 561 #define BOOTP_REPLY 2
584 562
585 /* DHCP message types */ 563 /* DHCP message types */
586 #define DHCPDISCOVER 1 564 #define DHCPDISCOVER 1
587 #define DHCPOFFER 2 565 #define DHCPOFFER 2
588 #define DHCPREQUEST 3 566 #define DHCPREQUEST 3
589 #define DHCPDECLINE 4 567 #define DHCPDECLINE 4
590 #define DHCPACK 5 568 #define DHCPACK 5
591 #define DHCPNAK 6 569 #define DHCPNAK 6
592 #define DHCPRELEASE 7 570 #define DHCPRELEASE 7
593 #define DHCPINFORM 8 571 #define DHCPINFORM 8
594 572
595 static int ic_bootp_recv(struct sk_buff *skb, 573 static int ic_bootp_recv(struct sk_buff *skb, struct net_device *dev, struct packet_type *pt, struct net_device *orig_dev);
596 574
597 static struct packet_type bootp_packet_type __ 575 static struct packet_type bootp_packet_type __initdata = {
598 .type = cpu_to_be16(ETH_P_IP), !! 576 .type = __constant_htons(ETH_P_IP),
599 .func = ic_bootp_recv, 577 .func = ic_bootp_recv,
600 }; 578 };
601 579
602 580
603 /* 581 /*
604 * Initialize DHCP/BOOTP extension fields in 582 * Initialize DHCP/BOOTP extension fields in the request.
605 */ 583 */
606 584
607 static const u8 ic_bootp_cookie[4] = { 99, 130 585 static const u8 ic_bootp_cookie[4] = { 99, 130, 83, 99 };
608 586
609 #ifdef IPCONFIG_DHCP 587 #ifdef IPCONFIG_DHCP
610 588
611 static void __init 589 static void __init
612 ic_dhcp_init_options(u8 *options) 590 ic_dhcp_init_options(u8 *options)
613 { 591 {
614 u8 mt = ((ic_servaddr == NONE) 592 u8 mt = ((ic_servaddr == NONE)
615 ? DHCPDISCOVER : DHCPREQUEST) 593 ? DHCPDISCOVER : DHCPREQUEST);
616 u8 *e = options; 594 u8 *e = options;
617 int len; 595 int len;
618 596
619 #ifdef IPCONFIG_DEBUG 597 #ifdef IPCONFIG_DEBUG
620 printk("DHCP: Sending message type %d\ 598 printk("DHCP: Sending message type %d\n", mt);
621 #endif 599 #endif
622 600
623 memcpy(e, ic_bootp_cookie, 4); /* RFC 601 memcpy(e, ic_bootp_cookie, 4); /* RFC1048 Magic Cookie */
624 e += 4; 602 e += 4;
625 603
626 *e++ = 53; /* DHCP messag 604 *e++ = 53; /* DHCP message type */
627 *e++ = 1; 605 *e++ = 1;
628 *e++ = mt; 606 *e++ = mt;
629 607
630 if (mt == DHCPREQUEST) { 608 if (mt == DHCPREQUEST) {
631 *e++ = 54; /* Server ID ( 609 *e++ = 54; /* Server ID (IP address) */
632 *e++ = 4; 610 *e++ = 4;
633 memcpy(e, &ic_servaddr, 4); 611 memcpy(e, &ic_servaddr, 4);
634 e += 4; 612 e += 4;
635 613
636 *e++ = 50; /* Requested I 614 *e++ = 50; /* Requested IP address */
637 *e++ = 4; 615 *e++ = 4;
638 memcpy(e, &ic_myaddr, 4); 616 memcpy(e, &ic_myaddr, 4);
639 e += 4; 617 e += 4;
640 } 618 }
641 619
642 /* always? */ 620 /* always? */
643 { 621 {
644 static const u8 ic_req_params[ 622 static const u8 ic_req_params[] = {
645 1, /* Subnet mask 623 1, /* Subnet mask */
646 3, /* Default gat 624 3, /* Default gateway */
647 6, /* DNS server 625 6, /* DNS server */
648 12, /* Host name * 626 12, /* Host name */
649 15, /* Domain name 627 15, /* Domain name */
650 17, /* Boot path * 628 17, /* Boot path */
651 26, /* MTU */ <<
652 40, /* NIS domain 629 40, /* NIS domain name */
653 }; 630 };
654 631
655 *e++ = 55; /* Parameter r 632 *e++ = 55; /* Parameter request list */
656 *e++ = sizeof(ic_req_params); 633 *e++ = sizeof(ic_req_params);
657 memcpy(e, ic_req_params, sizeo 634 memcpy(e, ic_req_params, sizeof(ic_req_params));
658 e += sizeof(ic_req_params); 635 e += sizeof(ic_req_params);
659 636
660 if (*vendor_class_identifier) 637 if (*vendor_class_identifier) {
661 printk(KERN_INFO "DHCP 638 printk(KERN_INFO "DHCP: sending class identifier \"%s\"\n",
662 vendor_class_id 639 vendor_class_identifier);
663 *e++ = 60; /* Cla 640 *e++ = 60; /* Class-identifier */
664 len = strlen(vendor_cl 641 len = strlen(vendor_class_identifier);
665 *e++ = len; 642 *e++ = len;
666 memcpy(e, vendor_class 643 memcpy(e, vendor_class_identifier, len);
667 e += len; 644 e += len;
668 } 645 }
669 } 646 }
670 647
671 *e++ = 255; /* End of the list */ 648 *e++ = 255; /* End of the list */
672 } 649 }
673 650
674 #endif /* IPCONFIG_DHCP */ 651 #endif /* IPCONFIG_DHCP */
675 652
676 static void __init ic_bootp_init_ext(u8 *e) 653 static void __init ic_bootp_init_ext(u8 *e)
677 { 654 {
678 memcpy(e, ic_bootp_cookie, 4); /* RFC 655 memcpy(e, ic_bootp_cookie, 4); /* RFC1048 Magic Cookie */
679 e += 4; 656 e += 4;
680 *e++ = 1; /* Subnet mask 657 *e++ = 1; /* Subnet mask request */
681 *e++ = 4; 658 *e++ = 4;
682 e += 4; 659 e += 4;
683 *e++ = 3; /* Default gat 660 *e++ = 3; /* Default gateway request */
684 *e++ = 4; 661 *e++ = 4;
685 e += 4; 662 e += 4;
686 *e++ = 5; /* Name server 663 *e++ = 5; /* Name server request */
687 *e++ = 8; 664 *e++ = 8;
688 e += 8; 665 e += 8;
689 *e++ = 12; /* Host name r 666 *e++ = 12; /* Host name request */
690 *e++ = 32; 667 *e++ = 32;
691 e += 32; 668 e += 32;
692 *e++ = 40; /* NIS Domain 669 *e++ = 40; /* NIS Domain name request */
693 *e++ = 32; 670 *e++ = 32;
694 e += 32; 671 e += 32;
695 *e++ = 17; /* Boot path * 672 *e++ = 17; /* Boot path */
696 *e++ = 40; 673 *e++ = 40;
697 e += 40; 674 e += 40;
698 675
699 *e++ = 57; /* set extensi 676 *e++ = 57; /* set extension buffer size for reply */
700 *e++ = 2; 677 *e++ = 2;
701 *e++ = 1; /* 128+236+8+2 678 *e++ = 1; /* 128+236+8+20+14, see dhcpd sources */
702 *e++ = 150; 679 *e++ = 150;
703 680
704 *e++ = 255; /* End of the 681 *e++ = 255; /* End of the list */
705 } 682 }
706 683
707 684
708 /* 685 /*
709 * Initialize the DHCP/BOOTP mechanism. 686 * Initialize the DHCP/BOOTP mechanism.
710 */ 687 */
711 static inline void __init ic_bootp_init(void) !! 688 static inline void ic_bootp_init(void)
712 { 689 {
713 int i; 690 int i;
714 691
715 for (i = 0; i < CONF_NAMESERVERS_MAX; 692 for (i = 0; i < CONF_NAMESERVERS_MAX; i++)
716 ic_nameservers[i] = NONE; 693 ic_nameservers[i] = NONE;
717 694
718 dev_add_pack(&bootp_packet_type); 695 dev_add_pack(&bootp_packet_type);
719 } 696 }
720 697
721 698
722 /* 699 /*
723 * DHCP/BOOTP cleanup. 700 * DHCP/BOOTP cleanup.
724 */ 701 */
725 static inline void __init ic_bootp_cleanup(voi !! 702 static inline void ic_bootp_cleanup(void)
726 { 703 {
727 dev_remove_pack(&bootp_packet_type); 704 dev_remove_pack(&bootp_packet_type);
728 } 705 }
729 706
730 707
731 /* 708 /*
732 * Send DHCP/BOOTP request to single interfac 709 * Send DHCP/BOOTP request to single interface.
733 */ 710 */
734 static void __init ic_bootp_send_if(struct ic_ 711 static void __init ic_bootp_send_if(struct ic_device *d, unsigned long jiffies_diff)
735 { 712 {
736 struct net_device *dev = d->dev; 713 struct net_device *dev = d->dev;
737 struct sk_buff *skb; 714 struct sk_buff *skb;
738 struct bootp_pkt *b; 715 struct bootp_pkt *b;
>> 716 int hh_len = LL_RESERVED_SPACE(dev);
739 struct iphdr *h; 717 struct iphdr *h;
740 718
741 /* Allocate packet */ 719 /* Allocate packet */
742 skb = alloc_skb(sizeof(struct bootp_pk !! 720 skb = alloc_skb(sizeof(struct bootp_pkt) + hh_len + 15, GFP_KERNEL);
743 GFP_KERNEL); <<
744 if (!skb) 721 if (!skb)
745 return; 722 return;
746 skb_reserve(skb, LL_RESERVED_SPACE(dev !! 723 skb_reserve(skb, hh_len);
747 b = (struct bootp_pkt *) skb_put(skb, 724 b = (struct bootp_pkt *) skb_put(skb, sizeof(struct bootp_pkt));
748 memset(b, 0, sizeof(struct bootp_pkt)) 725 memset(b, 0, sizeof(struct bootp_pkt));
749 726
750 /* Construct IP header */ 727 /* Construct IP header */
751 skb_reset_network_header(skb); 728 skb_reset_network_header(skb);
752 h = ip_hdr(skb); 729 h = ip_hdr(skb);
753 h->version = 4; 730 h->version = 4;
754 h->ihl = 5; 731 h->ihl = 5;
755 h->tot_len = htons(sizeof(struct bootp 732 h->tot_len = htons(sizeof(struct bootp_pkt));
756 h->frag_off = htons(IP_DF); 733 h->frag_off = htons(IP_DF);
757 h->ttl = 64; 734 h->ttl = 64;
758 h->protocol = IPPROTO_UDP; 735 h->protocol = IPPROTO_UDP;
759 h->daddr = htonl(INADDR_BROADCAST); 736 h->daddr = htonl(INADDR_BROADCAST);
760 h->check = ip_fast_csum((unsigned char 737 h->check = ip_fast_csum((unsigned char *) h, h->ihl);
761 738
762 /* Construct UDP header */ 739 /* Construct UDP header */
763 b->udph.source = htons(68); 740 b->udph.source = htons(68);
764 b->udph.dest = htons(67); 741 b->udph.dest = htons(67);
765 b->udph.len = htons(sizeof(struct boot 742 b->udph.len = htons(sizeof(struct bootp_pkt) - sizeof(struct iphdr));
766 /* UDP checksum not calculated -- expl 743 /* UDP checksum not calculated -- explicitly allowed in BOOTP RFC */
767 744
768 /* Construct DHCP/BOOTP header */ 745 /* Construct DHCP/BOOTP header */
769 b->op = BOOTP_REQUEST; 746 b->op = BOOTP_REQUEST;
770 if (dev->type < 256) /* check for fals 747 if (dev->type < 256) /* check for false types */
771 b->htype = dev->type; 748 b->htype = dev->type;
772 else if (dev->type == ARPHRD_IEEE802_T 749 else if (dev->type == ARPHRD_IEEE802_TR) /* fix for token ring */
773 b->htype = ARPHRD_IEEE802; 750 b->htype = ARPHRD_IEEE802;
774 else if (dev->type == ARPHRD_FDDI) 751 else if (dev->type == ARPHRD_FDDI)
775 b->htype = ARPHRD_ETHER; 752 b->htype = ARPHRD_ETHER;
776 else { 753 else {
777 printk("Unknown ARP type 0x%04 754 printk("Unknown ARP type 0x%04x for device %s\n", dev->type, dev->name);
778 b->htype = dev->type; /* can c 755 b->htype = dev->type; /* can cause undefined behavior */
779 } 756 }
780 757
781 /* server_ip and your_ip address are b 758 /* server_ip and your_ip address are both already zero per RFC2131 */
782 b->hlen = dev->addr_len; 759 b->hlen = dev->addr_len;
783 memcpy(b->hw_addr, dev->dev_addr, dev- 760 memcpy(b->hw_addr, dev->dev_addr, dev->addr_len);
784 b->secs = htons(jiffies_diff / HZ); 761 b->secs = htons(jiffies_diff / HZ);
785 b->xid = d->xid; 762 b->xid = d->xid;
786 763
787 /* add DHCP options or BOOTP extension 764 /* add DHCP options or BOOTP extensions */
788 #ifdef IPCONFIG_DHCP 765 #ifdef IPCONFIG_DHCP
789 if (ic_proto_enabled & IC_USE_DHCP) 766 if (ic_proto_enabled & IC_USE_DHCP)
790 ic_dhcp_init_options(b->exten) 767 ic_dhcp_init_options(b->exten);
791 else 768 else
792 #endif 769 #endif
793 ic_bootp_init_ext(b->exten); 770 ic_bootp_init_ext(b->exten);
794 771
795 /* Chain packet down the line... */ 772 /* Chain packet down the line... */
796 skb->dev = dev; 773 skb->dev = dev;
797 skb->protocol = htons(ETH_P_IP); 774 skb->protocol = htons(ETH_P_IP);
798 if (dev_hard_header(skb, dev, ntohs(sk 775 if (dev_hard_header(skb, dev, ntohs(skb->protocol),
799 dev->broadcast, de 776 dev->broadcast, dev->dev_addr, skb->len) < 0 ||
800 dev_queue_xmit(skb) < 0) 777 dev_queue_xmit(skb) < 0)
801 printk("E"); 778 printk("E");
802 } 779 }
803 780
804 781
805 /* 782 /*
806 * Copy BOOTP-supplied string if not already 783 * Copy BOOTP-supplied string if not already set.
807 */ 784 */
808 static int __init ic_bootp_string(char *dest, 785 static int __init ic_bootp_string(char *dest, char *src, int len, int max)
809 { 786 {
810 if (!len) 787 if (!len)
811 return 0; 788 return 0;
812 if (len > max-1) 789 if (len > max-1)
813 len = max-1; 790 len = max-1;
814 memcpy(dest, src, len); 791 memcpy(dest, src, len);
815 dest[len] = '\0'; 792 dest[len] = '\0';
816 return 1; 793 return 1;
817 } 794 }
818 795
819 796
820 /* 797 /*
821 * Process BOOTP extensions. 798 * Process BOOTP extensions.
822 */ 799 */
823 static void __init ic_do_bootp_ext(u8 *ext) 800 static void __init ic_do_bootp_ext(u8 *ext)
824 { 801 {
825 u8 servers; 802 u8 servers;
826 int i; 803 int i;
827 u16 mtu; <<
828 804
829 #ifdef IPCONFIG_DEBUG 805 #ifdef IPCONFIG_DEBUG
830 u8 *c; 806 u8 *c;
831 807
832 printk("DHCP/BOOTP: Got extension %d:" 808 printk("DHCP/BOOTP: Got extension %d:",*ext);
833 for (c=ext+2; c<ext+2+ext[1]; c++) 809 for (c=ext+2; c<ext+2+ext[1]; c++)
834 printk(" %02x", *c); 810 printk(" %02x", *c);
835 printk("\n"); 811 printk("\n");
836 #endif 812 #endif
837 813
838 switch (*ext++) { 814 switch (*ext++) {
839 case 1: /* Subnet mask 815 case 1: /* Subnet mask */
840 if (ic_netmask == NONE 816 if (ic_netmask == NONE)
841 memcpy(&ic_net 817 memcpy(&ic_netmask, ext+1, 4);
842 break; 818 break;
843 case 3: /* Default gat 819 case 3: /* Default gateway */
844 if (ic_gateway == NONE 820 if (ic_gateway == NONE)
845 memcpy(&ic_gat 821 memcpy(&ic_gateway, ext+1, 4);
846 break; 822 break;
847 case 6: /* DNS server 823 case 6: /* DNS server */
848 servers= *ext/4; 824 servers= *ext/4;
849 if (servers > CONF_NAM 825 if (servers > CONF_NAMESERVERS_MAX)
850 servers = CONF 826 servers = CONF_NAMESERVERS_MAX;
851 for (i = 0; i < server 827 for (i = 0; i < servers; i++) {
852 if (ic_nameser 828 if (ic_nameservers[i] == NONE)
853 memcpy 829 memcpy(&ic_nameservers[i], ext+1+4*i, 4);
854 } 830 }
855 break; 831 break;
856 case 12: /* Host name * 832 case 12: /* Host name */
857 ic_bootp_string(utsnam 833 ic_bootp_string(utsname()->nodename, ext+1, *ext, __NEW_UTS_LEN);
858 ic_host_name_set = 1; 834 ic_host_name_set = 1;
859 break; 835 break;
860 case 15: /* Domain name 836 case 15: /* Domain name (DNS) */
861 ic_bootp_string(ic_dom 837 ic_bootp_string(ic_domain, ext+1, *ext, sizeof(ic_domain));
862 break; 838 break;
863 case 17: /* Root path * 839 case 17: /* Root path */
864 if (!root_server_path[ 840 if (!root_server_path[0])
865 ic_bootp_strin 841 ic_bootp_string(root_server_path, ext+1, *ext, sizeof(root_server_path));
866 break; 842 break;
867 case 26: /* Interface M <<
868 memcpy(&mtu, ext+1, si <<
869 ic_dev_mtu = ntohs(mtu <<
870 break; <<
871 case 40: /* NIS Domain 843 case 40: /* NIS Domain name (_not_ DNS) */
872 ic_bootp_string(utsnam 844 ic_bootp_string(utsname()->domainname, ext+1, *ext, __NEW_UTS_LEN);
873 break; 845 break;
874 } 846 }
875 } 847 }
876 848
877 849
878 /* 850 /*
879 * Receive BOOTP reply. 851 * Receive BOOTP reply.
880 */ 852 */
881 static int __init ic_bootp_recv(struct sk_buff 853 static int __init ic_bootp_recv(struct sk_buff *skb, struct net_device *dev, struct packet_type *pt, struct net_device *orig_dev)
882 { 854 {
883 struct bootp_pkt *b; 855 struct bootp_pkt *b;
884 struct iphdr *h; 856 struct iphdr *h;
885 struct ic_device *d; 857 struct ic_device *d;
886 int len, ext_len; 858 int len, ext_len;
887 859
888 if (!net_eq(dev_net(dev), &init_net)) !! 860 if (dev->nd_net != &init_net)
889 goto drop; 861 goto drop;
890 862
891 /* Perform verifications before taking 863 /* Perform verifications before taking the lock. */
892 if (skb->pkt_type == PACKET_OTHERHOST) 864 if (skb->pkt_type == PACKET_OTHERHOST)
893 goto drop; 865 goto drop;
894 866
895 if ((skb = skb_share_check(skb, GFP_AT 867 if ((skb = skb_share_check(skb, GFP_ATOMIC)) == NULL)
896 return NET_RX_DROP; 868 return NET_RX_DROP;
897 869
898 if (!pskb_may_pull(skb, 870 if (!pskb_may_pull(skb,
899 sizeof(struct iphdr 871 sizeof(struct iphdr) +
900 sizeof(struct udphd 872 sizeof(struct udphdr)))
901 goto drop; 873 goto drop;
902 874
903 b = (struct bootp_pkt *)skb_network_he 875 b = (struct bootp_pkt *)skb_network_header(skb);
904 h = &b->iph; 876 h = &b->iph;
905 877
906 if (h->ihl != 5 || h->version != 4 || 878 if (h->ihl != 5 || h->version != 4 || h->protocol != IPPROTO_UDP)
907 goto drop; 879 goto drop;
908 880
909 /* Fragments are not supported */ 881 /* Fragments are not supported */
910 if (h->frag_off & htons(IP_OFFSET | IP 882 if (h->frag_off & htons(IP_OFFSET | IP_MF)) {
911 if (net_ratelimit()) 883 if (net_ratelimit())
912 printk(KERN_ERR "DHCP/ 884 printk(KERN_ERR "DHCP/BOOTP: Ignoring fragmented "
913 "reply.\n"); 885 "reply.\n");
914 goto drop; 886 goto drop;
915 } 887 }
916 888
917 if (skb->len < ntohs(h->tot_len)) 889 if (skb->len < ntohs(h->tot_len))
918 goto drop; 890 goto drop;
919 891
920 if (ip_fast_csum((char *) h, h->ihl)) 892 if (ip_fast_csum((char *) h, h->ihl))
921 goto drop; 893 goto drop;
922 894
923 if (b->udph.source != htons(67) || b-> 895 if (b->udph.source != htons(67) || b->udph.dest != htons(68))
924 goto drop; 896 goto drop;
925 897
926 if (ntohs(h->tot_len) < ntohs(b->udph. 898 if (ntohs(h->tot_len) < ntohs(b->udph.len) + sizeof(struct iphdr))
927 goto drop; 899 goto drop;
928 900
929 len = ntohs(b->udph.len) - sizeof(stru 901 len = ntohs(b->udph.len) - sizeof(struct udphdr);
930 ext_len = len - (sizeof(*b) - 902 ext_len = len - (sizeof(*b) -
931 sizeof(struct iphdr) 903 sizeof(struct iphdr) -
932 sizeof(struct udphdr) 904 sizeof(struct udphdr) -
933 sizeof(b->exten)); 905 sizeof(b->exten));
934 if (ext_len < 0) 906 if (ext_len < 0)
935 goto drop; 907 goto drop;
936 908
937 /* Ok the front looks good, make sure 909 /* Ok the front looks good, make sure we can get at the rest. */
938 if (!pskb_may_pull(skb, skb->len)) 910 if (!pskb_may_pull(skb, skb->len))
939 goto drop; 911 goto drop;
940 912
941 b = (struct bootp_pkt *)skb_network_he 913 b = (struct bootp_pkt *)skb_network_header(skb);
942 h = &b->iph; 914 h = &b->iph;
943 915
944 /* One reply at a time, please. */ 916 /* One reply at a time, please. */
945 spin_lock(&ic_recv_lock); 917 spin_lock(&ic_recv_lock);
946 918
947 /* If we already have a reply, just dr 919 /* If we already have a reply, just drop the packet */
948 if (ic_got_reply) 920 if (ic_got_reply)
949 goto drop_unlock; 921 goto drop_unlock;
950 922
951 /* Find the ic_device that the packet 923 /* Find the ic_device that the packet arrived on */
952 d = ic_first_dev; 924 d = ic_first_dev;
953 while (d && d->dev != dev) 925 while (d && d->dev != dev)
954 d = d->next; 926 d = d->next;
955 if (!d) 927 if (!d)
956 goto drop_unlock; /* should n 928 goto drop_unlock; /* should never happen */
957 929
958 /* Is it a reply to our BOOTP request? 930 /* Is it a reply to our BOOTP request? */
959 if (b->op != BOOTP_REPLY || 931 if (b->op != BOOTP_REPLY ||
960 b->xid != d->xid) { 932 b->xid != d->xid) {
961 if (net_ratelimit()) 933 if (net_ratelimit())
962 printk(KERN_ERR "DHCP/ 934 printk(KERN_ERR "DHCP/BOOTP: Reply not for us, "
963 "op[%x] xid[%x] 935 "op[%x] xid[%x]\n",
964 b->op, b->xid); 936 b->op, b->xid);
965 goto drop_unlock; 937 goto drop_unlock;
966 } 938 }
967 939
968 /* Is it a reply for the device we are <<
969 if (b->xid != ic_dev_xid) { <<
970 if (net_ratelimit()) <<
971 printk(KERN_ERR "DHCP/ <<
972 goto drop_unlock; <<
973 } <<
974 <<
975 /* Parse extensions */ 940 /* Parse extensions */
976 if (ext_len >= 4 && 941 if (ext_len >= 4 &&
977 !memcmp(b->exten, ic_bootp_cookie, 942 !memcmp(b->exten, ic_bootp_cookie, 4)) { /* Check magic cookie */
978 u8 *end = (u8 *) b + ntohs(b-> 943 u8 *end = (u8 *) b + ntohs(b->iph.tot_len);
979 u8 *ext; 944 u8 *ext;
980 945
981 #ifdef IPCONFIG_DHCP 946 #ifdef IPCONFIG_DHCP
982 if (ic_proto_enabled & IC_USE_ 947 if (ic_proto_enabled & IC_USE_DHCP) {
983 __be32 server_id = NON 948 __be32 server_id = NONE;
984 int mt = 0; 949 int mt = 0;
985 950
986 ext = &b->exten[4]; 951 ext = &b->exten[4];
987 while (ext < end && *e 952 while (ext < end && *ext != 0xff) {
988 u8 *opt = ext+ 953 u8 *opt = ext++;
989 if (*opt == 0) 954 if (*opt == 0) /* Padding */
990 contin 955 continue;
991 ext += *ext + 956 ext += *ext + 1;
992 if (ext >= end 957 if (ext >= end)
993 break; 958 break;
994 switch (*opt) 959 switch (*opt) {
995 case 53: 960 case 53: /* Message type */
996 if (op 961 if (opt[1])
997 962 mt = opt[2];
998 break; 963 break;
999 case 54: 964 case 54: /* Server ID (IP address) */
1000 if (o 965 if (opt[1] >= 4)
1001 966 memcpy(&server_id, opt + 2, 4);
1002 break 967 break;
1003 } 968 }
1004 } 969 }
1005 970
1006 #ifdef IPCONFIG_DEBUG 971 #ifdef IPCONFIG_DEBUG
1007 printk("DHCP: Got mes 972 printk("DHCP: Got message type %d\n", mt);
1008 #endif 973 #endif
1009 974
1010 switch (mt) { 975 switch (mt) {
1011 case DHCPOFFER: 976 case DHCPOFFER:
1012 /* While in t 977 /* While in the process of accepting one offer,
1013 * ignore all 978 * ignore all others.
1014 */ 979 */
1015 if (ic_myaddr 980 if (ic_myaddr != NONE)
1016 goto 981 goto drop_unlock;
1017 982
1018 /* Let's acce 983 /* Let's accept that offer. */
1019 ic_myaddr = b 984 ic_myaddr = b->your_ip;
1020 ic_servaddr = 985 ic_servaddr = server_id;
1021 #ifdef IPCONFIG_DEBUG 986 #ifdef IPCONFIG_DEBUG
1022 printk("DHCP: !! 987 printk("DHCP: Offered address %u.%u.%u.%u",
1023 &ic_my !! 988 NIPQUAD(ic_myaddr));
>> 989 printk(" by server %u.%u.%u.%u\n",
>> 990 NIPQUAD(ic_servaddr));
1024 #endif 991 #endif
1025 /* The DHCP i 992 /* The DHCP indicated server address takes
1026 * precedence 993 * precedence over the bootp header one if
1027 * they are d 994 * they are different.
1028 */ 995 */
1029 if ((server_i 996 if ((server_id != NONE) &&
1030 (b->serve 997 (b->server_ip != server_id))
1031 b->se 998 b->server_ip = ic_servaddr;
1032 break; 999 break;
1033 1000
1034 case DHCPACK: 1001 case DHCPACK:
1035 if (memcmp(de 1002 if (memcmp(dev->dev_addr, b->hw_addr, dev->addr_len) != 0)
1036 goto 1003 goto drop_unlock;
1037 1004
1038 /* Yeah! */ 1005 /* Yeah! */
1039 break; 1006 break;
1040 1007
1041 default: 1008 default:
1042 /* Urque. Fo 1009 /* Urque. Forget it*/
1043 ic_myaddr = N 1010 ic_myaddr = NONE;
1044 ic_servaddr = 1011 ic_servaddr = NONE;
1045 goto drop_unl 1012 goto drop_unlock;
1046 } 1013 }
1047 1014
1048 ic_dhcp_msgtype = mt; 1015 ic_dhcp_msgtype = mt;
1049 1016
1050 } 1017 }
1051 #endif /* IPCONFIG_DHCP */ 1018 #endif /* IPCONFIG_DHCP */
1052 1019
1053 ext = &b->exten[4]; 1020 ext = &b->exten[4];
1054 while (ext < end && *ext != 0 1021 while (ext < end && *ext != 0xff) {
1055 u8 *opt = ext++; 1022 u8 *opt = ext++;
1056 if (*opt == 0) /* Pa 1023 if (*opt == 0) /* Padding */
1057 continue; 1024 continue;
1058 ext += *ext + 1; 1025 ext += *ext + 1;
1059 if (ext < end) 1026 if (ext < end)
1060 ic_do_bootp_e 1027 ic_do_bootp_ext(opt);
1061 } 1028 }
1062 } 1029 }
1063 1030
1064 /* We have a winner! */ 1031 /* We have a winner! */
1065 ic_dev = dev; 1032 ic_dev = dev;
1066 ic_myaddr = b->your_ip; 1033 ic_myaddr = b->your_ip;
1067 ic_servaddr = b->server_ip; 1034 ic_servaddr = b->server_ip;
1068 if (ic_gateway == NONE && b->relay_ip 1035 if (ic_gateway == NONE && b->relay_ip)
1069 ic_gateway = b->relay_ip; 1036 ic_gateway = b->relay_ip;
1070 if (ic_nameservers[0] == NONE) 1037 if (ic_nameservers[0] == NONE)
1071 ic_nameservers[0] = ic_servad 1038 ic_nameservers[0] = ic_servaddr;
1072 ic_got_reply = IC_BOOTP; 1039 ic_got_reply = IC_BOOTP;
1073 1040
1074 drop_unlock: 1041 drop_unlock:
1075 /* Show's over. Nothing to see here. 1042 /* Show's over. Nothing to see here. */
1076 spin_unlock(&ic_recv_lock); 1043 spin_unlock(&ic_recv_lock);
1077 1044
1078 drop: 1045 drop:
1079 /* Throw the packet out. */ 1046 /* Throw the packet out. */
1080 kfree_skb(skb); 1047 kfree_skb(skb);
1081 1048
1082 return 0; 1049 return 0;
1083 } 1050 }
1084 1051
1085 1052
1086 #endif 1053 #endif
1087 1054
1088 1055
1089 /* 1056 /*
1090 * Dynamic IP configuration -- DHCP, BOO 1057 * Dynamic IP configuration -- DHCP, BOOTP, RARP.
1091 */ 1058 */
1092 1059
1093 #ifdef IPCONFIG_DYNAMIC 1060 #ifdef IPCONFIG_DYNAMIC
1094 1061
1095 static int __init ic_dynamic(void) 1062 static int __init ic_dynamic(void)
1096 { 1063 {
1097 int retries; 1064 int retries;
1098 struct ic_device *d; 1065 struct ic_device *d;
1099 unsigned long start_jiffies, timeout, 1066 unsigned long start_jiffies, timeout, jiff;
1100 int do_bootp = ic_proto_have_if & IC_ 1067 int do_bootp = ic_proto_have_if & IC_BOOTP;
1101 int do_rarp = ic_proto_have_if & IC_R 1068 int do_rarp = ic_proto_have_if & IC_RARP;
1102 1069
1103 /* 1070 /*
1104 * If none of DHCP/BOOTP/RARP was sel 1071 * If none of DHCP/BOOTP/RARP was selected, return with an error.
1105 * This routine gets only called when 1072 * This routine gets only called when some pieces of information
1106 * are missing, and without DHCP/BOOT 1073 * are missing, and without DHCP/BOOTP/RARP we are unable to get it.
1107 */ 1074 */
1108 if (!ic_proto_enabled) { 1075 if (!ic_proto_enabled) {
1109 printk(KERN_ERR "IP-Config: I 1076 printk(KERN_ERR "IP-Config: Incomplete network configuration information.\n");
1110 return -1; 1077 return -1;
1111 } 1078 }
1112 1079
1113 #ifdef IPCONFIG_BOOTP 1080 #ifdef IPCONFIG_BOOTP
1114 if ((ic_proto_enabled ^ ic_proto_have 1081 if ((ic_proto_enabled ^ ic_proto_have_if) & IC_BOOTP)
1115 printk(KERN_ERR "DHCP/BOOTP: 1082 printk(KERN_ERR "DHCP/BOOTP: No suitable device found.\n");
1116 #endif 1083 #endif
1117 #ifdef IPCONFIG_RARP 1084 #ifdef IPCONFIG_RARP
1118 if ((ic_proto_enabled ^ ic_proto_have 1085 if ((ic_proto_enabled ^ ic_proto_have_if) & IC_RARP)
1119 printk(KERN_ERR "RARP: No sui 1086 printk(KERN_ERR "RARP: No suitable device found.\n");
1120 #endif 1087 #endif
1121 1088
1122 if (!ic_proto_have_if) 1089 if (!ic_proto_have_if)
1123 /* Error message already prin 1090 /* Error message already printed */
1124 return -1; 1091 return -1;
1125 1092
1126 /* 1093 /*
1127 * Setup protocols 1094 * Setup protocols
1128 */ 1095 */
1129 #ifdef IPCONFIG_BOOTP 1096 #ifdef IPCONFIG_BOOTP
1130 if (do_bootp) 1097 if (do_bootp)
1131 ic_bootp_init(); 1098 ic_bootp_init();
1132 #endif 1099 #endif
1133 #ifdef IPCONFIG_RARP 1100 #ifdef IPCONFIG_RARP
1134 if (do_rarp) 1101 if (do_rarp)
1135 ic_rarp_init(); 1102 ic_rarp_init();
1136 #endif 1103 #endif
1137 1104
1138 /* 1105 /*
1139 * Send requests and wait, until we g 1106 * Send requests and wait, until we get an answer. This loop
1140 * seems to be a terrible waste of CP 1107 * seems to be a terrible waste of CPU time, but actually there is
1141 * only one process running at all, s 1108 * only one process running at all, so we don't need to use any
1142 * scheduler functions. 1109 * scheduler functions.
1143 * [Actually we could now, but the no 1110 * [Actually we could now, but the nothing else running note still
1144 * applies.. - AC] 1111 * applies.. - AC]
1145 */ 1112 */
1146 printk(KERN_NOTICE "Sending %s%s%s re 1113 printk(KERN_NOTICE "Sending %s%s%s requests .",
1147 do_bootp 1114 do_bootp
1148 ? ((ic_proto_enabled & IC_USE 1115 ? ((ic_proto_enabled & IC_USE_DHCP) ? "DHCP" : "BOOTP") : "",
1149 (do_bootp && do_rarp) ? " and 1116 (do_bootp && do_rarp) ? " and " : "",
1150 do_rarp ? "RARP" : ""); 1117 do_rarp ? "RARP" : "");
1151 1118
1152 start_jiffies = jiffies; 1119 start_jiffies = jiffies;
1153 d = ic_first_dev; 1120 d = ic_first_dev;
1154 retries = CONF_SEND_RETRIES; 1121 retries = CONF_SEND_RETRIES;
1155 get_random_bytes(&timeout, sizeof(tim 1122 get_random_bytes(&timeout, sizeof(timeout));
1156 timeout = CONF_BASE_TIMEOUT + (timeou 1123 timeout = CONF_BASE_TIMEOUT + (timeout % (unsigned) CONF_TIMEOUT_RANDOM);
1157 for (;;) { 1124 for (;;) {
1158 /* Track the device we are co <<
1159 ic_dev_xid = d->xid; <<
1160 <<
1161 #ifdef IPCONFIG_BOOTP 1125 #ifdef IPCONFIG_BOOTP
1162 if (do_bootp && (d->able & IC 1126 if (do_bootp && (d->able & IC_BOOTP))
1163 ic_bootp_send_if(d, j 1127 ic_bootp_send_if(d, jiffies - start_jiffies);
1164 #endif 1128 #endif
1165 #ifdef IPCONFIG_RARP 1129 #ifdef IPCONFIG_RARP
1166 if (do_rarp && (d->able & IC_ 1130 if (do_rarp && (d->able & IC_RARP))
1167 ic_rarp_send_if(d); 1131 ic_rarp_send_if(d);
1168 #endif 1132 #endif
1169 1133
1170 jiff = jiffies + (d->next ? C 1134 jiff = jiffies + (d->next ? CONF_INTER_TIMEOUT : timeout);
1171 while (time_before(jiffies, j 1135 while (time_before(jiffies, jiff) && !ic_got_reply)
1172 schedule_timeout_unin 1136 schedule_timeout_uninterruptible(1);
1173 #ifdef IPCONFIG_DHCP 1137 #ifdef IPCONFIG_DHCP
1174 /* DHCP isn't done until we g 1138 /* DHCP isn't done until we get a DHCPACK. */
1175 if ((ic_got_reply & IC_BOOTP) 1139 if ((ic_got_reply & IC_BOOTP)
1176 && (ic_proto_enabled & IC 1140 && (ic_proto_enabled & IC_USE_DHCP)
1177 && ic_dhcp_msgtype != DHC 1141 && ic_dhcp_msgtype != DHCPACK)
1178 { 1142 {
1179 ic_got_reply = 0; 1143 ic_got_reply = 0;
1180 printk(","); 1144 printk(",");
1181 continue; 1145 continue;
1182 } 1146 }
1183 #endif /* IPCONFIG_DHCP */ 1147 #endif /* IPCONFIG_DHCP */
1184 1148
1185 if (ic_got_reply) { 1149 if (ic_got_reply) {
1186 printk(" OK\n"); 1150 printk(" OK\n");
1187 break; 1151 break;
1188 } 1152 }
1189 1153
1190 if ((d = d->next)) 1154 if ((d = d->next))
1191 continue; 1155 continue;
1192 1156
1193 if (! --retries) { 1157 if (! --retries) {
1194 printk(" timed out!\n 1158 printk(" timed out!\n");
1195 break; 1159 break;
1196 } 1160 }
1197 1161
1198 d = ic_first_dev; 1162 d = ic_first_dev;
1199 1163
1200 timeout = timeout CONF_TIMEOU 1164 timeout = timeout CONF_TIMEOUT_MULT;
1201 if (timeout > CONF_TIMEOUT_MA 1165 if (timeout > CONF_TIMEOUT_MAX)
1202 timeout = CONF_TIMEOU 1166 timeout = CONF_TIMEOUT_MAX;
1203 1167
1204 printk("."); 1168 printk(".");
1205 } 1169 }
1206 1170
1207 #ifdef IPCONFIG_BOOTP 1171 #ifdef IPCONFIG_BOOTP
1208 if (do_bootp) 1172 if (do_bootp)
1209 ic_bootp_cleanup(); 1173 ic_bootp_cleanup();
1210 #endif 1174 #endif
1211 #ifdef IPCONFIG_RARP 1175 #ifdef IPCONFIG_RARP
1212 if (do_rarp) 1176 if (do_rarp)
1213 ic_rarp_cleanup(); 1177 ic_rarp_cleanup();
1214 #endif 1178 #endif
1215 1179
1216 if (!ic_got_reply) { 1180 if (!ic_got_reply) {
1217 ic_myaddr = NONE; 1181 ic_myaddr = NONE;
1218 return -1; 1182 return -1;
1219 } 1183 }
1220 1184
1221 printk("IP-Config: Got %s answer from !! 1185 printk("IP-Config: Got %s answer from %u.%u.%u.%u, ",
1222 ((ic_got_reply & IC_RARP) ? " 1186 ((ic_got_reply & IC_RARP) ? "RARP"
1223 : (ic_proto_enabled & IC_USE 1187 : (ic_proto_enabled & IC_USE_DHCP) ? "DHCP" : "BOOTP"),
1224 &ic_servaddr); !! 1188 NIPQUAD(ic_servaddr));
1225 printk("my address is %pI4\n", &ic_my !! 1189 printk("my address is %u.%u.%u.%u\n", NIPQUAD(ic_myaddr));
1226 1190
1227 return 0; 1191 return 0;
1228 } 1192 }
1229 1193
1230 #endif /* IPCONFIG_DYNAMIC */ 1194 #endif /* IPCONFIG_DYNAMIC */
1231 1195
1232 #ifdef CONFIG_PROC_FS 1196 #ifdef CONFIG_PROC_FS
1233 1197
1234 static int pnp_seq_show(struct seq_file *seq, 1198 static int pnp_seq_show(struct seq_file *seq, void *v)
1235 { 1199 {
1236 int i; 1200 int i;
1237 1201
1238 if (ic_proto_used & IC_PROTO) 1202 if (ic_proto_used & IC_PROTO)
1239 seq_printf(seq, "#PROTO: %s\n 1203 seq_printf(seq, "#PROTO: %s\n",
1240 (ic_proto_used & I 1204 (ic_proto_used & IC_RARP) ? "RARP"
1241 : (ic_proto_used & 1205 : (ic_proto_used & IC_USE_DHCP) ? "DHCP" : "BOOTP");
1242 else 1206 else
1243 seq_puts(seq, "#MANUAL\n"); 1207 seq_puts(seq, "#MANUAL\n");
1244 1208
1245 if (ic_domain[0]) 1209 if (ic_domain[0])
1246 seq_printf(seq, 1210 seq_printf(seq,
1247 "domain %s\n", ic_ 1211 "domain %s\n", ic_domain);
1248 for (i = 0; i < CONF_NAMESERVERS_MAX; 1212 for (i = 0; i < CONF_NAMESERVERS_MAX; i++) {
1249 if (ic_nameservers[i] != NONE 1213 if (ic_nameservers[i] != NONE)
1250 seq_printf(seq, "name !! 1214 seq_printf(seq,
1251 &ic_namese !! 1215 "nameserver %u.%u.%u.%u\n",
>> 1216 NIPQUAD(ic_nameservers[i]));
1252 } 1217 }
1253 if (ic_servaddr != NONE) 1218 if (ic_servaddr != NONE)
1254 seq_printf(seq, "bootserver % !! 1219 seq_printf(seq,
1255 &ic_servaddr); !! 1220 "bootserver %u.%u.%u.%u\n",
>> 1221 NIPQUAD(ic_servaddr));
1256 return 0; 1222 return 0;
1257 } 1223 }
1258 1224
1259 static int pnp_seq_open(struct inode *indoe, 1225 static int pnp_seq_open(struct inode *indoe, struct file *file)
1260 { 1226 {
1261 return single_open(file, pnp_seq_show 1227 return single_open(file, pnp_seq_show, NULL);
1262 } 1228 }
1263 1229
1264 static const struct file_operations pnp_seq_f 1230 static const struct file_operations pnp_seq_fops = {
1265 .owner = THIS_MODULE, 1231 .owner = THIS_MODULE,
1266 .open = pnp_seq_open, 1232 .open = pnp_seq_open,
1267 .read = seq_read, 1233 .read = seq_read,
1268 .llseek = seq_lseek, 1234 .llseek = seq_lseek,
1269 .release = single_release, 1235 .release = single_release,
1270 }; 1236 };
1271 #endif /* CONFIG_PROC_FS */ 1237 #endif /* CONFIG_PROC_FS */
1272 1238
1273 /* 1239 /*
1274 * Extract IP address from the parameter str 1240 * Extract IP address from the parameter string if needed. Note that we
1275 * need to have root_server_addr set _before 1241 * need to have root_server_addr set _before_ IPConfig gets called as it
1276 * can override it. 1242 * can override it.
1277 */ 1243 */
1278 __be32 __init root_nfs_parse_addr(char *name) 1244 __be32 __init root_nfs_parse_addr(char *name)
1279 { 1245 {
1280 __be32 addr; 1246 __be32 addr;
1281 int octets = 0; 1247 int octets = 0;
1282 char *cp, *cq; 1248 char *cp, *cq;
1283 1249
1284 cp = cq = name; 1250 cp = cq = name;
1285 while (octets < 4) { 1251 while (octets < 4) {
1286 while (*cp >= '' && *cp <= '9 1252 while (*cp >= '' && *cp <= '9')
1287 cp++; 1253 cp++;
1288 if (cp == cq || cp - cq > 3) 1254 if (cp == cq || cp - cq > 3)
1289 break; 1255 break;
1290 if (*cp == '.' || octets == 3 1256 if (*cp == '.' || octets == 3)
1291 octets++; 1257 octets++;
1292 if (octets < 4) 1258 if (octets < 4)
1293 cp++; 1259 cp++;
1294 cq = cp; 1260 cq = cp;
1295 } 1261 }
1296 if (octets == 4 && (*cp == ':' || *cp 1262 if (octets == 4 && (*cp == ':' || *cp == '\0')) {
1297 if (*cp == ':') 1263 if (*cp == ':')
1298 *cp++ = '\0'; 1264 *cp++ = '\0';
1299 addr = in_aton(name); 1265 addr = in_aton(name);
1300 memmove(name, cp, strlen(cp) 1266 memmove(name, cp, strlen(cp) + 1);
1301 } else 1267 } else
1302 addr = NONE; 1268 addr = NONE;
1303 1269
1304 return addr; 1270 return addr;
1305 } 1271 }
1306 1272
1307 /* 1273 /*
1308 * IP Autoconfig dispatcher. 1274 * IP Autoconfig dispatcher.
1309 */ 1275 */
1310 1276
1311 static int __init ip_auto_config(void) 1277 static int __init ip_auto_config(void)
1312 { 1278 {
1313 __be32 addr; 1279 __be32 addr;
1314 #ifdef IPCONFIG_DYNAMIC <<
1315 int retries = CONF_OPEN_RETRIES; <<
1316 #endif <<
1317 1280
1318 #ifdef CONFIG_PROC_FS 1281 #ifdef CONFIG_PROC_FS
1319 proc_net_fops_create(&init_net, "pnp" 1282 proc_net_fops_create(&init_net, "pnp", S_IRUGO, &pnp_seq_fops);
1320 #endif /* CONFIG_PROC_FS */ 1283 #endif /* CONFIG_PROC_FS */
1321 1284
1322 if (!ic_enable) 1285 if (!ic_enable)
1323 return 0; 1286 return 0;
1324 1287
1325 DBG(("IP-Config: Entered.\n")); 1288 DBG(("IP-Config: Entered.\n"));
1326 #ifdef IPCONFIG_DYNAMIC 1289 #ifdef IPCONFIG_DYNAMIC
1327 try_try_again: 1290 try_try_again:
1328 #endif 1291 #endif
1329 /* Give hardware a chance to settle * 1292 /* Give hardware a chance to settle */
1330 msleep(CONF_PRE_OPEN); 1293 msleep(CONF_PRE_OPEN);
1331 1294
1332 /* Setup all network devices */ 1295 /* Setup all network devices */
1333 if (ic_open_devs() < 0) 1296 if (ic_open_devs() < 0)
1334 return -1; 1297 return -1;
1335 1298
1336 /* Give drivers a chance to settle */ 1299 /* Give drivers a chance to settle */
1337 ssleep(CONF_POST_OPEN); 1300 ssleep(CONF_POST_OPEN);
1338 1301
1339 /* 1302 /*
1340 * If the config information is insuf 1303 * If the config information is insufficient (e.g., our IP address or
1341 * IP address of the boot server is m 1304 * IP address of the boot server is missing or we have multiple network
1342 * interfaces and no default was set) 1305 * interfaces and no default was set), use BOOTP or RARP to get the
1343 * missing values. 1306 * missing values.
1344 */ 1307 */
1345 if (ic_myaddr == NONE || 1308 if (ic_myaddr == NONE ||
1346 #ifdef CONFIG_ROOT_NFS 1309 #ifdef CONFIG_ROOT_NFS
1347 (root_server_addr == NONE 1310 (root_server_addr == NONE
1348 && ic_servaddr == NONE 1311 && ic_servaddr == NONE
1349 && ROOT_DEV == Root_NFS) || 1312 && ROOT_DEV == Root_NFS) ||
1350 #endif 1313 #endif
1351 ic_first_dev->next) { 1314 ic_first_dev->next) {
1352 #ifdef IPCONFIG_DYNAMIC 1315 #ifdef IPCONFIG_DYNAMIC
>> 1316
>> 1317 int retries = CONF_OPEN_RETRIES;
>> 1318
1353 if (ic_dynamic() < 0) { 1319 if (ic_dynamic() < 0) {
1354 ic_close_devs(); 1320 ic_close_devs();
1355 1321
1356 /* 1322 /*
1357 * I don't know why, 1323 * I don't know why, but sometimes the
1358 * eepro100 driver (a 1324 * eepro100 driver (at least) gets upset and
1359 * doesn't work the f 1325 * doesn't work the first time it's opened.
1360 * But then if you cl 1326 * But then if you close it and reopen it, it
1361 * works just fine. 1327 * works just fine. So we need to try that at
1362 * least once before 1328 * least once before giving up.
1363 * 1329 *
1364 * Also, if the root 1330 * Also, if the root will be NFS-mounted, we
1365 * have nowhere to go 1331 * have nowhere to go if DHCP fails. So we
1366 * just have to keep 1332 * just have to keep trying forever.
1367 * 1333 *
1368 * 1334 * -- Chip
1369 */ 1335 */
1370 #ifdef CONFIG_ROOT_NFS 1336 #ifdef CONFIG_ROOT_NFS
1371 if (ROOT_DEV == Root 1337 if (ROOT_DEV == Root_NFS) {
1372 printk(KERN_E 1338 printk(KERN_ERR
1373 "IP-C 1339 "IP-Config: Retrying forever (NFS root)...\n");
1374 goto try_try_ 1340 goto try_try_again;
1375 } 1341 }
1376 #endif 1342 #endif
1377 1343
1378 if (--retries) { 1344 if (--retries) {
1379 printk(KERN_E 1345 printk(KERN_ERR
1380 "IP-Co 1346 "IP-Config: Reopening network devices...\n");
1381 goto try_try_ 1347 goto try_try_again;
1382 } 1348 }
1383 1349
1384 /* Oh, well. At leas 1350 /* Oh, well. At least we tried. */
1385 printk(KERN_ERR "IP-C 1351 printk(KERN_ERR "IP-Config: Auto-configuration of network failed.\n");
1386 return -1; 1352 return -1;
1387 } 1353 }
1388 #else /* !DYNAMIC */ 1354 #else /* !DYNAMIC */
1389 printk(KERN_ERR "IP-Config: I 1355 printk(KERN_ERR "IP-Config: Incomplete network configuration information.\n");
1390 ic_close_devs(); 1356 ic_close_devs();
1391 return -1; 1357 return -1;
1392 #endif /* IPCONFIG_DYNAMIC */ 1358 #endif /* IPCONFIG_DYNAMIC */
1393 } else { 1359 } else {
1394 /* Device selected manually o 1360 /* Device selected manually or only one device -> use it */
1395 ic_dev = ic_first_dev->dev; 1361 ic_dev = ic_first_dev->dev;
1396 } 1362 }
1397 1363
1398 addr = root_nfs_parse_addr(root_serve 1364 addr = root_nfs_parse_addr(root_server_path);
1399 if (root_server_addr == NONE) 1365 if (root_server_addr == NONE)
1400 root_server_addr = addr; 1366 root_server_addr = addr;
1401 1367
1402 /* 1368 /*
1403 * Use defaults whereever applicable. 1369 * Use defaults whereever applicable.
1404 */ 1370 */
1405 if (ic_defaults() < 0) 1371 if (ic_defaults() < 0)
1406 return -1; 1372 return -1;
1407 1373
1408 /* 1374 /*
1409 * Close all network devices except t 1375 * Close all network devices except the device we've
1410 * autoconfigured and set up routes. 1376 * autoconfigured and set up routes.
1411 */ 1377 */
1412 ic_close_devs(); 1378 ic_close_devs();
1413 if (ic_setup_if() < 0 || ic_setup_rou 1379 if (ic_setup_if() < 0 || ic_setup_routes() < 0)
1414 return -1; 1380 return -1;
1415 1381
1416 /* 1382 /*
1417 * Record which protocol was actually 1383 * Record which protocol was actually used.
1418 */ 1384 */
1419 #ifdef IPCONFIG_DYNAMIC 1385 #ifdef IPCONFIG_DYNAMIC
1420 ic_proto_used = ic_got_reply | (ic_pr 1386 ic_proto_used = ic_got_reply | (ic_proto_enabled & IC_USE_DHCP);
1421 #endif 1387 #endif
1422 1388
1423 #ifndef IPCONFIG_SILENT 1389 #ifndef IPCONFIG_SILENT
1424 /* 1390 /*
1425 * Clue in the operator. 1391 * Clue in the operator.
1426 */ 1392 */
1427 printk("IP-Config: Complete:"); 1393 printk("IP-Config: Complete:");
1428 printk("\n device=%s", ic_dev->na 1394 printk("\n device=%s", ic_dev->name);
1429 printk(", addr=%pI4", &ic_myaddr); !! 1395 printk(", addr=%u.%u.%u.%u", NIPQUAD(ic_myaddr));
1430 printk(", mask=%pI4", &ic_netmask); !! 1396 printk(", mask=%u.%u.%u.%u", NIPQUAD(ic_netmask));
1431 printk(", gw=%pI4", &ic_gateway); !! 1397 printk(", gw=%u.%u.%u.%u", NIPQUAD(ic_gateway));
1432 printk(",\n host=%s, domain=%s, n 1398 printk(",\n host=%s, domain=%s, nis-domain=%s",
1433 utsname()->nodename, ic_domain 1399 utsname()->nodename, ic_domain, utsname()->domainname);
1434 printk(",\n bootserver=%pI4", &ic !! 1400 printk(",\n bootserver=%u.%u.%u.%u", NIPQUAD(ic_servaddr));
1435 printk(", rootserver=%pI4", &root_ser !! 1401 printk(", rootserver=%u.%u.%u.%u", NIPQUAD(root_server_addr));
1436 printk(", rootpath=%s", root_server_p 1402 printk(", rootpath=%s", root_server_path);
1437 if (ic_dev_mtu) <<
1438 printk(", mtu=%d", ic_dev_mtu <<
1439 printk("\n"); 1403 printk("\n");
1440 #endif /* !SILENT */ 1404 #endif /* !SILENT */
1441 1405
1442 return 0; 1406 return 0;
1443 } 1407 }
1444 1408
1445 late_initcall(ip_auto_config); 1409 late_initcall(ip_auto_config);
1446 1410
1447 1411
1448 /* 1412 /*
1449 * Decode any IP configuration options in th 1413 * Decode any IP configuration options in the "ip=" or "nfsaddrs=" kernel
1450 * command line parameter. See Documentatio 1414 * command line parameter. See Documentation/filesystems/nfsroot.txt.
1451 */ 1415 */
1452 static int __init ic_proto_name(char *name) 1416 static int __init ic_proto_name(char *name)
1453 { 1417 {
1454 if (!strcmp(name, "on") || !strcmp(na 1418 if (!strcmp(name, "on") || !strcmp(name, "any")) {
1455 return 1; 1419 return 1;
1456 } 1420 }
1457 if (!strcmp(name, "off") || !strcmp(n 1421 if (!strcmp(name, "off") || !strcmp(name, "none")) {
1458 return 0; 1422 return 0;
1459 } 1423 }
1460 #ifdef CONFIG_IP_PNP_DHCP 1424 #ifdef CONFIG_IP_PNP_DHCP
1461 else if (!strcmp(name, "dhcp")) { 1425 else if (!strcmp(name, "dhcp")) {
1462 ic_proto_enabled &= ~IC_RARP; 1426 ic_proto_enabled &= ~IC_RARP;
1463 return 1; 1427 return 1;
1464 } 1428 }
1465 #endif 1429 #endif
1466 #ifdef CONFIG_IP_PNP_BOOTP 1430 #ifdef CONFIG_IP_PNP_BOOTP
1467 else if (!strcmp(name, "bootp")) { 1431 else if (!strcmp(name, "bootp")) {
1468 ic_proto_enabled &= ~(IC_RARP 1432 ic_proto_enabled &= ~(IC_RARP | IC_USE_DHCP);
1469 return 1; 1433 return 1;
1470 } 1434 }
1471 #endif 1435 #endif
1472 #ifdef CONFIG_IP_PNP_RARP 1436 #ifdef CONFIG_IP_PNP_RARP
1473 else if (!strcmp(name, "rarp")) { 1437 else if (!strcmp(name, "rarp")) {
1474 ic_proto_enabled &= ~(IC_BOOT 1438 ic_proto_enabled &= ~(IC_BOOTP | IC_USE_DHCP);
1475 return 1; 1439 return 1;
1476 } 1440 }
1477 #endif 1441 #endif
1478 #ifdef IPCONFIG_DYNAMIC 1442 #ifdef IPCONFIG_DYNAMIC
1479 else if (!strcmp(name, "both")) { 1443 else if (!strcmp(name, "both")) {
1480 ic_proto_enabled &= ~IC_USE_D 1444 ic_proto_enabled &= ~IC_USE_DHCP; /* backward compat :-( */
1481 return 1; 1445 return 1;
1482 } 1446 }
1483 #endif 1447 #endif
1484 return 0; 1448 return 0;
1485 } 1449 }
1486 1450
1487 static int __init ip_auto_config_setup(char * 1451 static int __init ip_auto_config_setup(char *addrs)
1488 { 1452 {
1489 char *cp, *ip, *dp; 1453 char *cp, *ip, *dp;
1490 int num = 0; 1454 int num = 0;
1491 1455
1492 ic_set_manually = 1; 1456 ic_set_manually = 1;
1493 ic_enable = 1; 1457 ic_enable = 1;
1494 1458
1495 /* 1459 /*
1496 * If any dhcp, bootp etc options are 1460 * If any dhcp, bootp etc options are set, leave autoconfig on
1497 * and skip the below static IP proce 1461 * and skip the below static IP processing.
1498 */ 1462 */
1499 if (ic_proto_name(addrs)) 1463 if (ic_proto_name(addrs))
1500 return 1; 1464 return 1;
1501 1465
1502 /* If no static IP is given, turn off 1466 /* If no static IP is given, turn off autoconfig and bail. */
1503 if (*addrs == 0 || 1467 if (*addrs == 0 ||
1504 strcmp(addrs, "off") == 0 || 1468 strcmp(addrs, "off") == 0 ||
1505 strcmp(addrs, "none") == 0) { 1469 strcmp(addrs, "none") == 0) {
1506 ic_enable = 0; 1470 ic_enable = 0;
1507 return 1; 1471 return 1;
1508 } 1472 }
1509 1473
1510 /* Parse string for static IP assignm 1474 /* Parse string for static IP assignment. */
1511 ip = addrs; 1475 ip = addrs;
1512 while (ip && *ip) { 1476 while (ip && *ip) {
1513 if ((cp = strchr(ip, ':'))) 1477 if ((cp = strchr(ip, ':')))
1514 *cp++ = '\0'; 1478 *cp++ = '\0';
1515 if (strlen(ip) > 0) { 1479 if (strlen(ip) > 0) {
1516 DBG(("IP-Config: Para 1480 DBG(("IP-Config: Parameter #%d: `%s'\n", num, ip));
1517 switch (num) { 1481 switch (num) {
1518 case 0: 1482 case 0:
1519 if ((ic_myadd 1483 if ((ic_myaddr = in_aton(ip)) == ANY)
1520 ic_my 1484 ic_myaddr = NONE;
1521 break; 1485 break;
1522 case 1: 1486 case 1:
1523 if ((ic_serva 1487 if ((ic_servaddr = in_aton(ip)) == ANY)
1524 ic_se 1488 ic_servaddr = NONE;
1525 break; 1489 break;
1526 case 2: 1490 case 2:
1527 if ((ic_gatew 1491 if ((ic_gateway = in_aton(ip)) == ANY)
1528 ic_ga 1492 ic_gateway = NONE;
1529 break; 1493 break;
1530 case 3: 1494 case 3:
1531 if ((ic_netma 1495 if ((ic_netmask = in_aton(ip)) == ANY)
1532 ic_ne 1496 ic_netmask = NONE;
1533 break; 1497 break;
1534 case 4: 1498 case 4:
1535 if ((dp = str 1499 if ((dp = strchr(ip, '.'))) {
1536 *dp++ 1500 *dp++ = '\0';
1537 strlc 1501 strlcpy(utsname()->domainname, dp,
1538 1502 sizeof(utsname()->domainname));
1539 } 1503 }
1540 strlcpy(utsna 1504 strlcpy(utsname()->nodename, ip,
1541 sizeo 1505 sizeof(utsname()->nodename));
1542 ic_host_name_ 1506 ic_host_name_set = 1;
1543 break; 1507 break;
1544 case 5: 1508 case 5:
1545 strlcpy(user_ 1509 strlcpy(user_dev_name, ip, sizeof(user_dev_name));
1546 break; 1510 break;
1547 case 6: 1511 case 6:
1548 if (ic_proto_ 1512 if (ic_proto_name(ip) == 0 &&
1549 ic_myaddr 1513 ic_myaddr == NONE) {
1550 ic_en 1514 ic_enable = 0;
1551 } 1515 }
1552 break; 1516 break;
1553 } 1517 }
1554 } 1518 }
1555 ip = cp; 1519 ip = cp;
1556 num++; 1520 num++;
1557 } 1521 }
1558 1522
1559 return 1; 1523 return 1;
1560 } 1524 }
1561 1525
1562 static int __init nfsaddrs_config_setup(char 1526 static int __init nfsaddrs_config_setup(char *addrs)
1563 { 1527 {
1564 return ip_auto_config_setup(addrs); 1528 return ip_auto_config_setup(addrs);
1565 } 1529 }
1566 1530
1567 static int __init vendor_class_identifier_set 1531 static int __init vendor_class_identifier_setup(char *addrs)
1568 { 1532 {
1569 if (strlcpy(vendor_class_identifier, 1533 if (strlcpy(vendor_class_identifier, addrs,
1570 sizeof(vendor_class_ident 1534 sizeof(vendor_class_identifier))
1571 >= sizeof(vendor_class_identifier 1535 >= sizeof(vendor_class_identifier))
1572 printk(KERN_WARNING "DHCP: ve 1536 printk(KERN_WARNING "DHCP: vendorclass too long, truncated to \"%s\"",
1573 vendor_class_identifie 1537 vendor_class_identifier);
1574 return 1; 1538 return 1;
1575 } 1539 }
1576 1540
1577 __setup("ip=", ip_auto_config_setup); 1541 __setup("ip=", ip_auto_config_setup);
1578 __setup("nfsaddrs=", nfsaddrs_config_setup); 1542 __setup("nfsaddrs=", nfsaddrs_config_setup);
1579 __setup("dhcpclass=", vendor_class_identifier 1543 __setup("dhcpclass=", vendor_class_identifier_setup);
1580 1544
|
This page was automatically generated by the
LXR engine.
|