Blame view

net/ipv4/ipconfig.c 39.5 KB
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1
  /*
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
2
3
4
5
6
7
8
9
10
11
12
   *  Automatic Configuration of IP -- use DHCP, BOOTP, RARP, or
   *  user-supplied information to configure own IP address and routes.
   *
   *  Copyright (C) 1996-1998 Martin Mares <mj@atrey.karlin.mff.cuni.cz>
   *
   *  Derived from network configuration code in fs/nfs/nfsroot.c,
   *  originally Copyright (C) 1995, 1996 Gero Kuhlmann and me.
   *
   *  BOOTP rewritten to construct and analyse packets itself instead
   *  of misusing the IP layer. num_bugs_causing_wrong_arp_replies--;
   *					     -- MJ, December 1998
e905a9eda   YOSHIFUJI Hideaki   [NET] IPV4: Fix w...
13
   *
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
   *  Fixed ip_auto_config_setup calling at startup in the new "Linker Magic"
   *  initialization scheme.
   *	- Arnaldo Carvalho de Melo <acme@conectiva.com.br>, 08/11/1999
   *
   *  DHCP support added.  To users this looks like a whole separate
   *  protocol, but we know it's just a bag on the side of BOOTP.
   *		-- Chip Salzenberg <chip@valinux.com>, May 2000
   *
   *  Ported DHCP support from 2.2.16 to 2.4.0-test4
   *              -- Eric Biederman <ebiederman@lnxi.com>, 30 Aug 2000
   *
   *  Merged changes from 2.2.19 into 2.4.3
   *              -- Eric Biederman <ebiederman@lnxi.com>, 22 April Aug 2001
   *
   *  Multiple Nameservers in /proc/net/pnp
   *              --  Josef Siemes <jsiemes@web.de>, Aug 2002
   */
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
31
32
33
34
35
36
37
38
39
40
  #include <linux/types.h>
  #include <linux/string.h>
  #include <linux/kernel.h>
  #include <linux/jiffies.h>
  #include <linux/random.h>
  #include <linux/init.h>
  #include <linux/utsname.h>
  #include <linux/in.h>
  #include <linux/if.h>
  #include <linux/inet.h>
14c850212   Arnaldo Carvalho de Melo   [INET_SOCK]: Move...
41
  #include <linux/inetdevice.h>
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
42
43
44
45
46
47
48
49
50
51
52
53
  #include <linux/netdevice.h>
  #include <linux/if_arp.h>
  #include <linux/skbuff.h>
  #include <linux/ip.h>
  #include <linux/socket.h>
  #include <linux/route.h>
  #include <linux/udp.h>
  #include <linux/proc_fs.h>
  #include <linux/seq_file.h>
  #include <linux/major.h>
  #include <linux/root_dev.h>
  #include <linux/delay.h>
43d60661a   Adrian Bunk   [IPV4]: net/ipv4/...
54
  #include <linux/nfs_fs.h>
5a0e3ad6a   Tejun Heo   include cleanup: ...
55
  #include <linux/slab.h>
bc3b2d7fb   Paul Gortmaker   net: Add export.h...
56
  #include <linux/export.h>
457c4cbc5   Eric W. Biederman   [NET]: Make /proc...
57
  #include <net/net_namespace.h>
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
58
59
60
  #include <net/arp.h>
  #include <net/ip.h>
  #include <net/ipconfig.h>
14c850212   Arnaldo Carvalho de Melo   [INET_SOCK]: Move...
61
  #include <net/route.h>
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
62
63
64
65
  
  #include <asm/uaccess.h>
  #include <net/checksum.h>
  #include <asm/processor.h>
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
66
67
68
69
70
71
72
73
74
75
76
77
78
79
  #if defined(CONFIG_IP_PNP_DHCP)
  #define IPCONFIG_DHCP
  #endif
  #if defined(CONFIG_IP_PNP_BOOTP) || defined(CONFIG_IP_PNP_DHCP)
  #define IPCONFIG_BOOTP
  #endif
  #if defined(CONFIG_IP_PNP_RARP)
  #define IPCONFIG_RARP
  #endif
  #if defined(IPCONFIG_BOOTP) || defined(IPCONFIG_RARP)
  #define IPCONFIG_DYNAMIC
  #endif
  
  /* Define the friendly delay before and after opening net devices */
3fb72f1e6   Micha Nelissen   ipconfig wait for...
80
81
  #define CONF_POST_OPEN		10	/* After opening: 10 msecs */
  #define CONF_CARRIER_TIMEOUT	120000	/* Wait for carrier timeout */
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
82
83
84
85
  
  /* Define the timeout for waiting for a DHCP/BOOTP/RARP reply */
  #define CONF_OPEN_RETRIES 	2	/* (Re)open devices twice */
  #define CONF_SEND_RETRIES 	6	/* Send six requests per open */
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
86
87
88
89
  #define CONF_BASE_TIMEOUT	(HZ*2)	/* Initial timeout: 2 seconds */
  #define CONF_TIMEOUT_RANDOM	(HZ)	/* Maximum amount of randomization */
  #define CONF_TIMEOUT_MULT	*7/4	/* Rate of timeout growth */
  #define CONF_TIMEOUT_MAX	(HZ*30)	/* Maximum allowed timeout */
e905a9eda   YOSHIFUJI Hideaki   [NET] IPV4: Fix w...
90
91
  #define CONF_NAMESERVERS_MAX   3       /* Maximum number of nameservers
  					   - '3' from resolv.h */
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
92

09640e636   Harvey Harrison   net: replace uses...
93
94
  #define NONE cpu_to_be32(INADDR_NONE)
  #define ANY cpu_to_be32(INADDR_ANY)
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
95
96
97
98
99
100
101
102
103
104
  
  /*
   * Public IP configuration
   */
  
  /* This is used by platforms which might be able to set the ipconfig
   * variables using firmware environment vars.  If this is set, it will
   * ignore such firmware variables.
   */
  int ic_set_manually __initdata = 0;		/* IPconfig parameters set manually */
0d3979b9c   Fabian Frederick   ipv4: remove 0/NU...
105
  static int ic_enable __initdata;		/* IP config enabled? */
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
106
107
108
109
110
111
112
113
114
115
116
117
118
  
  /* Protocol choice */
  int ic_proto_enabled __initdata = 0
  #ifdef IPCONFIG_BOOTP
  			| IC_BOOTP
  #endif
  #ifdef CONFIG_IP_PNP_DHCP
  			| IC_USE_DHCP
  #endif
  #ifdef IPCONFIG_RARP
  			| IC_RARP
  #endif
  			;
0d3979b9c   Fabian Frederick   ipv4: remove 0/NU...
119
  static int ic_host_name_set __initdata;	/* Host name set by us? */
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
120

5a874db4d   Al Viro   [NET]: ipconfig a...
121
122
123
  __be32 ic_myaddr = NONE;		/* My IP address */
  static __be32 ic_netmask = NONE;	/* Netmask for local subnet */
  __be32 ic_gateway = NONE;	/* Gateway IP address */
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
124

86ef7f9cb   David S. Miller   ipconfig: Protect...
125
  #ifdef IPCONFIG_DYNAMIC
0b392be9a   Ben Dooks   net: ipconfig: av...
126
  static __be32 ic_addrservaddr = NONE;	/* IP Address of the IP addresses'server */
86ef7f9cb   David S. Miller   ipconfig: Protect...
127
  #endif
9dd4a13a8   Philippe De Muyter   net/ipv4/ipconfig...
128

5a874db4d   Al Viro   [NET]: ipconfig a...
129
  __be32 ic_servaddr = NONE;	/* Boot server IP address */
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
130

5a874db4d   Al Viro   [NET]: ipconfig a...
131
  __be32 root_server_addr = NONE;	/* Address of NFS server */
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
132
  u8 root_server_path[256] = { 0, };	/* Path to mount as root */
1b0b04f9f   David S. Miller   [IPCONFIG]: Mark ...
133
134
  /* vendor class identifier */
  static char vendor_class_identifier[253] __initdata;
62013dbb8   Rainer Jochem   [IPV4] ipconfig: ...
135

26fb342c7   Li RongQing   ipconfig: send Cl...
136
137
138
  #if defined(CONFIG_IP_PNP_DHCP)
  static char dhcp_client_identifier[253] __initdata;
  #endif
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
139
  /* Persistent data: */
52b79e2bd   Arnd Bergmann   ipv4: ipconfig: a...
140
  #ifdef IPCONFIG_DYNAMIC
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
141
  static int ic_proto_used;			/* Protocol used, if any */
52b79e2bd   Arnd Bergmann   ipv4: ipconfig: a...
142
143
144
  #else
  #define ic_proto_used 0
  #endif
5a874db4d   Al Viro   [NET]: ipconfig a...
145
  static __be32 ic_nameservers[CONF_NAMESERVERS_MAX]; /* DNS Server IP addresses */
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
146
147
148
149
150
151
152
153
154
155
  static u8 ic_domain[64];		/* DNS (not NIS) domain name */
  
  /*
   * Private state.
   */
  
  /* Name of user-selected boot device */
  static char user_dev_name[IFNAMSIZ] __initdata = { 0, };
  
  /* Protocols supported by available interfaces */
0d3979b9c   Fabian Frederick   ipv4: remove 0/NU...
156
  static int ic_proto_have_if __initdata;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
157

9643f4551   Chris Friesen   ipv4: teach ipcon...
158
  /* MTU for boot device */
0d3979b9c   Fabian Frederick   ipv4: remove 0/NU...
159
  static int ic_dev_mtu __initdata;
9643f4551   Chris Friesen   ipv4: teach ipcon...
160

1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
161
162
  #ifdef IPCONFIG_DYNAMIC
  static DEFINE_SPINLOCK(ic_recv_lock);
0d3979b9c   Fabian Frederick   ipv4: remove 0/NU...
163
  static volatile int ic_got_reply __initdata;    /* Proto(s) that replied */
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
164
165
  #endif
  #ifdef IPCONFIG_DHCP
0d3979b9c   Fabian Frederick   ipv4: remove 0/NU...
166
  static int ic_dhcp_msgtype __initdata;	/* DHCP msg type received */
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
167
168
169
170
171
172
173
174
175
176
177
178
  #endif
  
  
  /*
   *	Network devices
   */
  
  struct ic_device {
  	struct ic_device *next;
  	struct net_device *dev;
  	unsigned short flags;
  	short able;
5a874db4d   Al Viro   [NET]: ipconfig a...
179
  	__be32 xid;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
180
  };
0d3979b9c   Fabian Frederick   ipv4: remove 0/NU...
181
  static struct ic_device *ic_first_dev __initdata;	/* List of open device */
2647cffb2   Uwe Kleine-König   net: ipconfig: Su...
182
  static struct ic_device *ic_dev __initdata;		/* Selected device */
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
183

3fb72f1e6   Micha Nelissen   ipconfig wait for...
184
  static bool __init ic_is_init_dev(struct net_device *dev)
964ad81cb   David S. Miller   ipconfig: Handle ...
185
  {
3fb72f1e6   Micha Nelissen   ipconfig wait for...
186
187
188
  	if (dev->flags & IFF_LOOPBACK)
  		return false;
  	return user_dev_name[0] ? !strcmp(dev->name, user_dev_name) :
964ad81cb   David S. Miller   ipconfig: Handle ...
189
190
  	    (!(dev->flags & IFF_LOOPBACK) &&
  	     (dev->flags & (IFF_POINTOPOINT|IFF_BROADCAST)) &&
3fb72f1e6   Micha Nelissen   ipconfig wait for...
191
  	     strncmp(dev->name, "dummy", 5));
964ad81cb   David S. Miller   ipconfig: Handle ...
192
  }
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
193
194
195
196
197
  static int __init ic_open_devs(void)
  {
  	struct ic_device *d, **last;
  	struct net_device *dev;
  	unsigned short oflags;
5e404cd65   Paul Gortmaker   ipconfig: add inf...
198
  	unsigned long start, next_msg;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
199
200
  
  	last = &ic_first_dev;
6756ae4b4   Stephen Hemminger   [NET]: Convert RT...
201
  	rtnl_lock();
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
202

728c02089   Florian Fainelli   net: ipv4: handle...
203
  	/* bring loopback and DSA master network devices up first */
0cc217e16   Eric W. Biederman   [IPV4]: When poss...
204
  	for_each_netdev(&init_net, dev) {
728c02089   Florian Fainelli   net: ipv4: handle...
205
  		if (!(dev->flags & IFF_LOOPBACK) && !netdev_uses_dsa(dev))
0cc217e16   Eric W. Biederman   [IPV4]: When poss...
206
207
  			continue;
  		if (dev_change_flags(dev, dev->flags | IFF_UP) < 0)
058bd4d2a   Joe Perches   net: Convert prin...
208
209
  			pr_err("IP-Config: Failed to open %s
  ", dev->name);
0cc217e16   Eric W. Biederman   [IPV4]: When poss...
210
  	}
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
211

881d966b4   Eric W. Biederman   [NET]: Make the d...
212
  	for_each_netdev(&init_net, dev) {
3fb72f1e6   Micha Nelissen   ipconfig wait for...
213
  		if (ic_is_init_dev(dev)) {
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
214
215
216
217
  			int able = 0;
  			if (dev->mtu >= 364)
  				able |= IC_BOOTP;
  			else
09605cc12   Bastian Stender   net ipv4: use pre...
218
219
  				pr_warn("DHCP/BOOTP: Ignoring device %s, MTU %d too small
  ",
058bd4d2a   Joe Perches   net: Convert prin...
220
  					dev->name, dev->mtu);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
221
222
223
224
225
226
227
  			if (!(dev->flags & IFF_NOARP))
  				able |= IC_RARP;
  			able &= ic_proto_enabled;
  			if (ic_proto_enabled && !able)
  				continue;
  			oflags = dev->flags;
  			if (dev_change_flags(dev, oflags | IFF_UP) < 0) {
058bd4d2a   Joe Perches   net: Convert prin...
228
229
230
  				pr_err("IP-Config: Failed to open %s
  ",
  				       dev->name);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
231
232
233
  				continue;
  			}
  			if (!(d = kmalloc(sizeof(struct ic_device), GFP_KERNEL))) {
6756ae4b4   Stephen Hemminger   [NET]: Convert RT...
234
  				rtnl_unlock();
964ad81cb   David S. Miller   ipconfig: Handle ...
235
  				return -ENOMEM;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
236
237
238
239
240
241
242
  			}
  			d->dev = dev;
  			*last = d;
  			last = &d->next;
  			d->flags = oflags;
  			d->able = able;
  			if (able & IC_BOOTP)
5a874db4d   Al Viro   [NET]: ipconfig a...
243
  				get_random_bytes(&d->xid, sizeof(__be32));
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
244
245
246
  			else
  				d->xid = 0;
  			ic_proto_have_if |= able;
09605cc12   Bastian Stender   net ipv4: use pre...
247
248
249
  			pr_debug("IP-Config: %s UP (able=%d, xid=%08x)
  ",
  				 dev->name, able, d->xid);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
250
251
  		}
  	}
3fb72f1e6   Micha Nelissen   ipconfig wait for...
252

cd7816d14   Gerlando Falauto   net: have ipconfi...
253
254
255
  	/* no point in waiting if we could not bring up at least one device */
  	if (!ic_first_dev)
  		goto have_carrier;
3fb72f1e6   Micha Nelissen   ipconfig wait for...
256
257
  	/* wait for a carrier on at least one device */
  	start = jiffies;
5e404cd65   Paul Gortmaker   ipconfig: add inf...
258
  	next_msg = start + msecs_to_jiffies(CONF_CARRIER_TIMEOUT/12);
c72c95a06   Himangi Saraogi   ipconfig: Use tim...
259
260
  	while (time_before(jiffies, start +
  			   msecs_to_jiffies(CONF_CARRIER_TIMEOUT))) {
5e404cd65   Paul Gortmaker   ipconfig: add inf...
261
  		int wait, elapsed;
3fb72f1e6   Micha Nelissen   ipconfig wait for...
262
263
264
265
266
  		for_each_netdev(&init_net, dev)
  			if (ic_is_init_dev(dev) && netif_carrier_ok(dev))
  				goto have_carrier;
  
  		msleep(1);
5e404cd65   Paul Gortmaker   ipconfig: add inf...
267

357137a42   FX Le Bail   ipv4: ipconfig.c:...
268
  		if (time_before(jiffies, next_msg))
5e404cd65   Paul Gortmaker   ipconfig: add inf...
269
270
271
272
273
274
275
  			continue;
  
  		elapsed = jiffies_to_msecs(jiffies - start);
  		wait = (CONF_CARRIER_TIMEOUT - elapsed + 500)/1000;
  		pr_info("Waiting up to %d more seconds for network.
  ", wait);
  		next_msg = jiffies + msecs_to_jiffies(CONF_CARRIER_TIMEOUT/12);
3fb72f1e6   Micha Nelissen   ipconfig wait for...
276
277
  	}
  have_carrier:
6756ae4b4   Stephen Hemminger   [NET]: Convert RT...
278
  	rtnl_unlock();
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
279
280
281
282
283
  
  	*last = NULL;
  
  	if (!ic_first_dev) {
  		if (user_dev_name[0])
058bd4d2a   Joe Perches   net: Convert prin...
284
285
286
  			pr_err("IP-Config: Device `%s' not found
  ",
  			       user_dev_name);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
287
  		else
058bd4d2a   Joe Perches   net: Convert prin...
288
289
  			pr_err("IP-Config: No network devices available
  ");
964ad81cb   David S. Miller   ipconfig: Handle ...
290
  		return -ENODEV;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
291
292
293
294
295
296
297
298
  	}
  	return 0;
  }
  
  static void __init ic_close_devs(void)
  {
  	struct ic_device *d, *next;
  	struct net_device *dev;
6756ae4b4   Stephen Hemminger   [NET]: Convert RT...
299
  	rtnl_lock();
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
300
301
302
303
  	next = ic_first_dev;
  	while ((d = next)) {
  		next = d->next;
  		dev = d->dev;
1ae292a24   Geert Uytterhoeven   net: ipconfig: Fi...
304
  		if ((!ic_dev || dev != ic_dev->dev) && !netdev_uses_dsa(dev)) {
09605cc12   Bastian Stender   net ipv4: use pre...
305
306
  			pr_debug("IP-Config: Downing %s
  ", dev->name);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
307
308
309
310
  			dev_change_flags(dev, d->flags);
  		}
  		kfree(d);
  	}
6756ae4b4   Stephen Hemminger   [NET]: Convert RT...
311
  	rtnl_unlock();
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
312
313
314
315
316
317
318
  }
  
  /*
   *	Interface to various network functions.
   */
  
  static inline void
5a874db4d   Al Viro   [NET]: ipconfig a...
319
  set_sockaddr(struct sockaddr_in *sin, __be32 addr, __be16 port)
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
320
321
322
323
324
  {
  	sin->sin_family = AF_INET;
  	sin->sin_addr.s_addr = addr;
  	sin->sin_port = port;
  }
9643f4551   Chris Friesen   ipv4: teach ipcon...
325
  static int __init ic_devinet_ioctl(unsigned int cmd, struct ifreq *arg)
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
326
327
328
329
330
  {
  	int res;
  
  	mm_segment_t oldfs = get_fs();
  	set_fs(get_ds());
e5b13cb10   Denis V. Lunev   [NETNS]: Process ...
331
  	res = devinet_ioctl(&init_net, cmd, (struct ifreq __user *) arg);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
332
333
334
  	set_fs(oldfs);
  	return res;
  }
9643f4551   Chris Friesen   ipv4: teach ipcon...
335
336
337
338
339
340
341
342
343
344
  static int __init ic_dev_ioctl(unsigned int cmd, struct ifreq *arg)
  {
  	int res;
  
  	mm_segment_t oldfs = get_fs();
  	set_fs(get_ds());
  	res = dev_ioctl(&init_net, cmd, (struct ifreq __user *) arg);
  	set_fs(oldfs);
  	return res;
  }
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
345
346
347
348
349
350
  static int __init ic_route_ioctl(unsigned int cmd, struct rtentry *arg)
  {
  	int res;
  
  	mm_segment_t oldfs = get_fs();
  	set_fs(get_ds());
1bad118a3   Denis V. Lunev   [NETNS]: Pass nam...
351
  	res = ip_rt_ioctl(&init_net, cmd, (void __user *) arg);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
  	set_fs(oldfs);
  	return res;
  }
  
  /*
   *	Set up interface addresses and routes.
   */
  
  static int __init ic_setup_if(void)
  {
  	struct ifreq ir;
  	struct sockaddr_in *sin = (void *) &ir.ifr_ifru.ifru_addr;
  	int err;
  
  	memset(&ir, 0, sizeof(ir));
2647cffb2   Uwe Kleine-König   net: ipconfig: Su...
367
  	strcpy(ir.ifr_ifrn.ifrn_name, ic_dev->dev->name);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
368
  	set_sockaddr(sin, ic_myaddr, 0);
9643f4551   Chris Friesen   ipv4: teach ipcon...
369
  	if ((err = ic_devinet_ioctl(SIOCSIFADDR, &ir)) < 0) {
058bd4d2a   Joe Perches   net: Convert prin...
370
371
372
  		pr_err("IP-Config: Unable to set interface address (%d)
  ",
  		       err);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
373
374
375
  		return -1;
  	}
  	set_sockaddr(sin, ic_netmask, 0);
9643f4551   Chris Friesen   ipv4: teach ipcon...
376
  	if ((err = ic_devinet_ioctl(SIOCSIFNETMASK, &ir)) < 0) {
058bd4d2a   Joe Perches   net: Convert prin...
377
378
379
  		pr_err("IP-Config: Unable to set interface netmask (%d)
  ",
  		       err);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
380
381
382
  		return -1;
  	}
  	set_sockaddr(sin, ic_myaddr | ~ic_netmask, 0);
9643f4551   Chris Friesen   ipv4: teach ipcon...
383
  	if ((err = ic_devinet_ioctl(SIOCSIFBRDADDR, &ir)) < 0) {
058bd4d2a   Joe Perches   net: Convert prin...
384
385
386
  		pr_err("IP-Config: Unable to set interface broadcast address (%d)
  ",
  		       err);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
387
388
  		return -1;
  	}
9643f4551   Chris Friesen   ipv4: teach ipcon...
389
390
391
392
393
  	/* Handle the case where we need non-standard MTU on the boot link (a network
  	 * using jumbo frames, for instance).  If we can't set the mtu, don't error
  	 * out, we'll try to muddle along.
  	 */
  	if (ic_dev_mtu != 0) {
2647cffb2   Uwe Kleine-König   net: ipconfig: Su...
394
  		strcpy(ir.ifr_name, ic_dev->dev->name);
9643f4551   Chris Friesen   ipv4: teach ipcon...
395
396
  		ir.ifr_mtu = ic_dev_mtu;
  		if ((err = ic_dev_ioctl(SIOCSIFMTU, &ir)) < 0)
058bd4d2a   Joe Perches   net: Convert prin...
397
398
399
  			pr_err("IP-Config: Unable to set interface mtu to %d (%d)
  ",
  			       ic_dev_mtu, err);
9643f4551   Chris Friesen   ipv4: teach ipcon...
400
  	}
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
401
402
403
404
405
406
  	return 0;
  }
  
  static int __init ic_setup_routes(void)
  {
  	/* No need to setup device routes, only the default route... */
5a874db4d   Al Viro   [NET]: ipconfig a...
407
  	if (ic_gateway != NONE) {
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
408
409
410
411
412
  		struct rtentry rm;
  		int err;
  
  		memset(&rm, 0, sizeof(rm));
  		if ((ic_gateway ^ ic_myaddr) & ic_netmask) {
058bd4d2a   Joe Perches   net: Convert prin...
413
414
  			pr_err("IP-Config: Gateway not on directly connected network
  ");
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
415
416
417
418
419
420
421
  			return -1;
  		}
  		set_sockaddr((struct sockaddr_in *) &rm.rt_dst, 0, 0);
  		set_sockaddr((struct sockaddr_in *) &rm.rt_genmask, 0, 0);
  		set_sockaddr((struct sockaddr_in *) &rm.rt_gateway, ic_gateway, 0);
  		rm.rt_flags = RTF_UP | RTF_GATEWAY;
  		if ((err = ic_route_ioctl(SIOCADDRT, &rm)) < 0) {
058bd4d2a   Joe Perches   net: Convert prin...
422
423
424
  			pr_err("IP-Config: Cannot add default route (%d)
  ",
  			       err);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
  			return -1;
  		}
  	}
  
  	return 0;
  }
  
  /*
   *	Fill in default values for all missing parameters.
   */
  
  static int __init ic_defaults(void)
  {
  	/*
  	 *	At this point we have no userspace running so need not
  	 *	claim locks on system_utsname
  	 */
e905a9eda   YOSHIFUJI Hideaki   [NET] IPV4: Fix w...
442

1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
443
  	if (!ic_host_name_set)
673d57e72   Harvey Harrison   net: replace NIPQ...
444
  		sprintf(init_utsname()->nodename, "%pI4", &ic_myaddr);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
445

5a874db4d   Al Viro   [NET]: ipconfig a...
446
  	if (root_server_addr == NONE)
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
447
  		root_server_addr = ic_servaddr;
5a874db4d   Al Viro   [NET]: ipconfig a...
448
  	if (ic_netmask == NONE) {
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
449
450
451
452
453
454
455
  		if (IN_CLASSA(ntohl(ic_myaddr)))
  			ic_netmask = htonl(IN_CLASSA_NET);
  		else if (IN_CLASSB(ntohl(ic_myaddr)))
  			ic_netmask = htonl(IN_CLASSB_NET);
  		else if (IN_CLASSC(ntohl(ic_myaddr)))
  			ic_netmask = htonl(IN_CLASSC_NET);
  		else {
058bd4d2a   Joe Perches   net: Convert prin...
456
457
458
  			pr_err("IP-Config: Unable to guess netmask for address %pI4
  ",
  			       &ic_myaddr);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
459
460
  			return -1;
  		}
09605cc12   Bastian Stender   net ipv4: use pre...
461
462
463
  		pr_notice("IP-Config: Guessing netmask %pI4
  ",
  			  &ic_netmask);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
464
465
466
467
468
469
470
471
472
473
  	}
  
  	return 0;
  }
  
  /*
   *	RARP support.
   */
  
  #ifdef IPCONFIG_RARP
f2ccd8fa0   David S. Miller   [NET]: Kill skb->...
474
  static int ic_rarp_recv(struct sk_buff *skb, struct net_device *dev, struct packet_type *pt, struct net_device *orig_dev);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
475
476
  
  static struct packet_type rarp_packet_type __initdata = {
09640e636   Harvey Harrison   net: replace uses...
477
  	.type =	cpu_to_be16(ETH_P_RARP),
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
478
479
  	.func =	ic_rarp_recv,
  };
45e741b89   Sam Ravnborg   ipv4: annotate a ...
480
  static inline void __init ic_rarp_init(void)
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
481
482
483
  {
  	dev_add_pack(&rarp_packet_type);
  }
45e741b89   Sam Ravnborg   ipv4: annotate a ...
484
  static inline void __init ic_rarp_cleanup(void)
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
485
486
487
488
489
490
491
492
  {
  	dev_remove_pack(&rarp_packet_type);
  }
  
  /*
   *  Process received RARP packet.
   */
  static int __init
f2ccd8fa0   David S. Miller   [NET]: Kill skb->...
493
  ic_rarp_recv(struct sk_buff *skb, struct net_device *dev, struct packet_type *pt, struct net_device *orig_dev)
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
494
495
496
  {
  	struct arphdr *rarp;
  	unsigned char *rarp_ptr;
5a874db4d   Al Viro   [NET]: ipconfig a...
497
  	__be32 sip, tip;
6b436d338   Fabian Frederick   ipv4: remove set ...
498
  	unsigned char *tha;		/* t for "target" */
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
499
  	struct ic_device *d;
721499e89   YOSHIFUJI Hideaki   netns: Use net_eq...
500
  	if (!net_eq(dev_net(dev), &init_net))
e730c1551   Eric W. Biederman   [NET]: Make packe...
501
  		goto drop;
51456b291   Ian Morris   ipv4: coding styl...
502
503
  	skb = skb_share_check(skb, GFP_ATOMIC);
  	if (!skb)
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
504
505
506
507
508
509
  		return NET_RX_DROP;
  
  	if (!pskb_may_pull(skb, sizeof(struct arphdr)))
  		goto drop;
  
  	/* Basic sanity checks can be done without the lock.  */
9c70220b7   Arnaldo Carvalho de Melo   [SK_BUFF]: Introd...
510
  	rarp = (struct arphdr *)skb_transport_header(skb);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
511
512
513
514
515
516
517
518
519
520
521
522
523
524
  
  	/* If this test doesn't pass, it's not IP, or we should
  	 * ignore it anyway.
  	 */
  	if (rarp->ar_hln != dev->addr_len || dev->type != ntohs(rarp->ar_hrd))
  		goto drop;
  
  	/* If it's not a RARP reply, delete it. */
  	if (rarp->ar_op != htons(ARPOP_RREPLY))
  		goto drop;
  
  	/* If it's not Ethernet, delete it. */
  	if (rarp->ar_pro != htons(ETH_P_IP))
  		goto drop;
988b70507   Pavel Emelyanov   [ARP]: Introduce ...
525
  	if (!pskb_may_pull(skb, arp_hdr_len(dev)))
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
526
527
528
  		goto drop;
  
  	/* OK, it is all there and looks valid, process... */
9c70220b7   Arnaldo Carvalho de Melo   [SK_BUFF]: Introd...
529
  	rarp = (struct arphdr *)skb_transport_header(skb);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
  	rarp_ptr = (unsigned char *) (rarp + 1);
  
  	/* One reply at a time, please. */
  	spin_lock(&ic_recv_lock);
  
  	/* If we already have a reply, just drop the packet */
  	if (ic_got_reply)
  		goto drop_unlock;
  
  	/* Find the ic_device that the packet arrived on */
  	d = ic_first_dev;
  	while (d && d->dev != dev)
  		d = d->next;
  	if (!d)
  		goto drop_unlock;	/* should never happen */
  
  	/* Extract variable-width fields */
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
547
548
549
550
551
552
553
554
555
556
557
558
  	rarp_ptr += dev->addr_len;
  	memcpy(&sip, rarp_ptr, 4);
  	rarp_ptr += 4;
  	tha = rarp_ptr;
  	rarp_ptr += dev->addr_len;
  	memcpy(&tip, rarp_ptr, 4);
  
  	/* Discard packets which are not meant for us. */
  	if (memcmp(tha, dev->dev_addr, dev->addr_len))
  		goto drop_unlock;
  
  	/* Discard packets which are not from specified server. */
5a874db4d   Al Viro   [NET]: ipconfig a...
559
  	if (ic_servaddr != NONE && ic_servaddr != sip)
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
560
561
562
  		goto drop_unlock;
  
  	/* We have a winner! */
2647cffb2   Uwe Kleine-König   net: ipconfig: Su...
563
  	ic_dev = d;
5a874db4d   Al Viro   [NET]: ipconfig a...
564
  	if (ic_myaddr == NONE)
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
565
566
  		ic_myaddr = tip;
  	ic_servaddr = sip;
9dd4a13a8   Philippe De Muyter   net/ipv4/ipconfig...
567
  	ic_addrservaddr = sip;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
  	ic_got_reply = IC_RARP;
  
  drop_unlock:
  	/* Show's over.  Nothing to see here.  */
  	spin_unlock(&ic_recv_lock);
  
  drop:
  	/* Throw the packet out. */
  	kfree_skb(skb);
  	return 0;
  }
  
  
  /*
   *  Send RARP request packet over a single interface.
   */
  static void __init ic_rarp_send_if(struct ic_device *d)
  {
  	struct net_device *dev = d->dev;
  	arp_send(ARPOP_RREQUEST, ETH_P_RARP, 0, dev, 0, NULL,
  		 dev->dev_addr, dev->dev_addr);
  }
  #endif
  
  /*
842b08bbe   Andy Shevchenko   ipconfig: fix tri...
593
594
595
596
597
598
599
600
601
602
603
   *  Predefine Nameservers
   */
  static inline void __init ic_nameservers_predef(void)
  {
  	int i;
  
  	for (i = 0; i < CONF_NAMESERVERS_MAX; i++)
  		ic_nameservers[i] = NONE;
  }
  
  /*
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
604
605
606
607
608
609
610
611
612
613
614
615
   *	DHCP/BOOTP support.
   */
  
  #ifdef IPCONFIG_BOOTP
  
  struct bootp_pkt {		/* BOOTP packet format */
  	struct iphdr iph;	/* IP header */
  	struct udphdr udph;	/* UDP header */
  	u8 op;			/* 1=request, 2=reply */
  	u8 htype;		/* HW address type */
  	u8 hlen;		/* HW address length */
  	u8 hops;		/* Used only by gateways */
5a874db4d   Al Viro   [NET]: ipconfig a...
616
617
618
619
620
621
622
  	__be32 xid;		/* Transaction ID */
  	__be16 secs;		/* Seconds since we started */
  	__be16 flags;		/* Just what it says */
  	__be32 client_ip;		/* Client's IP address if known */
  	__be32 your_ip;		/* Assigned IP address */
  	__be32 server_ip;		/* (Next, e.g. NFS) Server's IP address */
  	__be32 relay_ip;		/* IP address of BOOTP relay */
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
  	u8 hw_addr[16];		/* Client's HW address */
  	u8 serv_name[64];	/* Server host name */
  	u8 boot_file[128];	/* Name of boot file */
  	u8 exten[312];		/* DHCP options / BOOTP vendor extensions */
  };
  
  /* packet ops */
  #define BOOTP_REQUEST	1
  #define BOOTP_REPLY	2
  
  /* DHCP message types */
  #define DHCPDISCOVER	1
  #define DHCPOFFER	2
  #define DHCPREQUEST	3
  #define DHCPDECLINE	4
  #define DHCPACK		5
  #define DHCPNAK		6
  #define DHCPRELEASE	7
  #define DHCPINFORM	8
f2ccd8fa0   David S. Miller   [NET]: Kill skb->...
642
  static int ic_bootp_recv(struct sk_buff *skb, struct net_device *dev, struct packet_type *pt, struct net_device *orig_dev);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
643
644
  
  static struct packet_type bootp_packet_type __initdata = {
09640e636   Harvey Harrison   net: replace uses...
645
  	.type =	cpu_to_be16(ETH_P_IP),
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
646
647
  	.func =	ic_bootp_recv,
  };
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
648
649
650
651
652
653
654
655
656
  /*
   *  Initialize DHCP/BOOTP extension fields in the request.
   */
  
  static const u8 ic_bootp_cookie[4] = { 99, 130, 83, 99 };
  
  #ifdef IPCONFIG_DHCP
  
  static void __init
22fc53887   Uwe Kleine-König   net: ipconfig: Ad...
657
  ic_dhcp_init_options(u8 *options, struct ic_device *d)
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
658
  {
5a874db4d   Al Viro   [NET]: ipconfig a...
659
  	u8 mt = ((ic_servaddr == NONE)
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
660
661
  		 ? DHCPDISCOVER : DHCPREQUEST);
  	u8 *e = options;
62013dbb8   Rainer Jochem   [IPV4] ipconfig: ...
662
  	int len;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
663

22fc53887   Uwe Kleine-König   net: ipconfig: Ad...
664
665
  	pr_debug("DHCP: Sending message type %d (%s)
  ", mt, d->dev->name);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
  
  	memcpy(e, ic_bootp_cookie, 4);	/* RFC1048 Magic Cookie */
  	e += 4;
  
  	*e++ = 53;		/* DHCP message type */
  	*e++ = 1;
  	*e++ = mt;
  
  	if (mt == DHCPREQUEST) {
  		*e++ = 54;	/* Server ID (IP address) */
  		*e++ = 4;
  		memcpy(e, &ic_servaddr, 4);
  		e += 4;
  
  		*e++ = 50;	/* Requested IP address */
  		*e++ = 4;
  		memcpy(e, &ic_myaddr, 4);
  		e += 4;
  	}
  
  	/* always? */
  	{
  		static const u8 ic_req_params[] = {
  			1,	/* Subnet mask */
  			3,	/* Default gateway */
  			6,	/* DNS server */
  			12,	/* Host name */
  			15,	/* Domain name */
  			17,	/* Boot path */
9643f4551   Chris Friesen   ipv4: teach ipcon...
695
  			26,	/* MTU */
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
696
697
698
699
700
701
702
  			40,	/* NIS domain name */
  		};
  
  		*e++ = 55;	/* Parameter request list */
  		*e++ = sizeof(ic_req_params);
  		memcpy(e, ic_req_params, sizeof(ic_req_params));
  		e += sizeof(ic_req_params);
62013dbb8   Rainer Jochem   [IPV4] ipconfig: ...
703

130c0f47f   Wu Fengguang   ipconfig: send ho...
704
705
706
707
708
709
710
  		if (ic_host_name_set) {
  			*e++ = 12;	/* host-name */
  			len = strlen(utsname()->nodename);
  			*e++ = len;
  			memcpy(e, utsname()->nodename, len);
  			e += len;
  		}
62013dbb8   Rainer Jochem   [IPV4] ipconfig: ...
711
  		if (*vendor_class_identifier) {
058bd4d2a   Joe Perches   net: Convert prin...
712
713
714
  			pr_info("DHCP: sending class identifier \"%s\"
  ",
  				vendor_class_identifier);
62013dbb8   Rainer Jochem   [IPV4] ipconfig: ...
715
716
717
718
719
720
  			*e++ = 60;	/* Class-identifier */
  			len = strlen(vendor_class_identifier);
  			*e++ = len;
  			memcpy(e, vendor_class_identifier, len);
  			e += len;
  		}
26fb342c7   Li RongQing   ipconfig: send Cl...
721
722
723
724
725
726
727
728
729
730
  		len = strlen(dhcp_client_identifier + 1);
  		/* the minimum length of identifier is 2, include 1 byte type,
  		 * and can not be larger than the length of options
  		 */
  		if (len >= 1 && len < 312 - (e - options) - 1) {
  			*e++ = 61;
  			*e++ = len + 1;
  			memcpy(e, dhcp_client_identifier, len + 1);
  			e += len + 1;
  		}
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
  	}
  
  	*e++ = 255;	/* End of the list */
  }
  
  #endif /* IPCONFIG_DHCP */
  
  static void __init ic_bootp_init_ext(u8 *e)
  {
  	memcpy(e, ic_bootp_cookie, 4);	/* RFC1048 Magic Cookie */
  	e += 4;
  	*e++ = 1;		/* Subnet mask request */
  	*e++ = 4;
  	e += 4;
  	*e++ = 3;		/* Default gateway request */
  	*e++ = 4;
  	e += 4;
  	*e++ = 5;		/* Name server request */
  	*e++ = 8;
  	e += 8;
  	*e++ = 12;		/* Host name request */
  	*e++ = 32;
  	e += 32;
  	*e++ = 40;		/* NIS Domain name request */
  	*e++ = 32;
  	e += 32;
  	*e++ = 17;		/* Boot path */
  	*e++ = 40;
  	e += 40;
e905a9eda   YOSHIFUJI Hideaki   [NET] IPV4: Fix w...
760
  	*e++ = 57;		/* set extension buffer size for reply */
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
761
  	*e++ = 2;
e905a9eda   YOSHIFUJI Hideaki   [NET] IPV4: Fix w...
762
  	*e++ = 1;		/* 128+236+8+20+14, see dhcpd sources */
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
763
764
765
766
767
768
769
  	*e++ = 150;
  
  	*e++ = 255;		/* End of the list */
  }
  
  
  /*
5e953778a   Christoph Fritz   ipconfig: add nam...
770
771
772
773
774
   *  Initialize the DHCP/BOOTP mechanism.
   */
  static inline void __init ic_bootp_init(void)
  {
  	ic_nameservers_predef();
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
775
776
777
778
779
780
781
782
  
  	dev_add_pack(&bootp_packet_type);
  }
  
  
  /*
   *  DHCP/BOOTP cleanup.
   */
45e741b89   Sam Ravnborg   ipv4: annotate a ...
783
  static inline void __init ic_bootp_cleanup(void)
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
784
785
786
787
788
789
790
791
792
793
794
795
796
  {
  	dev_remove_pack(&bootp_packet_type);
  }
  
  
  /*
   *  Send DHCP/BOOTP request to single interface.
   */
  static void __init ic_bootp_send_if(struct ic_device *d, unsigned long jiffies_diff)
  {
  	struct net_device *dev = d->dev;
  	struct sk_buff *skb;
  	struct bootp_pkt *b;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
797
  	struct iphdr *h;
660882432   Herbert Xu   ipv4: Remove all ...
798
799
  	int hlen = LL_RESERVED_SPACE(dev);
  	int tlen = dev->needed_tailroom;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
800
801
  
  	/* Allocate packet */
660882432   Herbert Xu   ipv4: Remove all ...
802
  	skb = alloc_skb(sizeof(struct bootp_pkt) + hlen + tlen + 15,
f5184d267   Johannes Berg   net: Allow netdev...
803
  			GFP_KERNEL);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
804
805
  	if (!skb)
  		return;
660882432   Herbert Xu   ipv4: Remove all ...
806
  	skb_reserve(skb, hlen);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
807
808
809
810
  	b = (struct bootp_pkt *) skb_put(skb, sizeof(struct bootp_pkt));
  	memset(b, 0, sizeof(struct bootp_pkt));
  
  	/* Construct IP header */
04b964dba   Arnaldo Carvalho de Melo   [SK_BUFF] ipconfi...
811
  	skb_reset_network_header(skb);
eddc9ec53   Arnaldo Carvalho de Melo   [SK_BUFF]: Introd...
812
  	h = ip_hdr(skb);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
813
814
815
816
817
818
  	h->version = 4;
  	h->ihl = 5;
  	h->tot_len = htons(sizeof(struct bootp_pkt));
  	h->frag_off = htons(IP_DF);
  	h->ttl = 64;
  	h->protocol = IPPROTO_UDP;
5a874db4d   Al Viro   [NET]: ipconfig a...
819
  	h->daddr = htonl(INADDR_BROADCAST);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
820
821
822
823
824
825
826
827
828
829
830
831
  	h->check = ip_fast_csum((unsigned char *) h, h->ihl);
  
  	/* Construct UDP header */
  	b->udph.source = htons(68);
  	b->udph.dest = htons(67);
  	b->udph.len = htons(sizeof(struct bootp_pkt) - sizeof(struct iphdr));
  	/* UDP checksum not calculated -- explicitly allowed in BOOTP RFC */
  
  	/* Construct DHCP/BOOTP header */
  	b->op = BOOTP_REQUEST;
  	if (dev->type < 256) /* check for false types */
  		b->htype = dev->type;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
832
833
834
  	else if (dev->type == ARPHRD_FDDI)
  		b->htype = ARPHRD_ETHER;
  	else {
09605cc12   Bastian Stender   net ipv4: use pre...
835
836
837
  		pr_warn("Unknown ARP type 0x%04x for device %s
  ", dev->type,
  			dev->name);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
838
839
  		b->htype = dev->type; /* can cause undefined behavior */
  	}
dea75bdfa   Stephen Hemminger   [IPCONFIG]: The k...
840
841
  
  	/* server_ip and your_ip address are both already zero per RFC2131 */
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
842
  	b->hlen = dev->addr_len;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
843
844
845
846
847
848
849
  	memcpy(b->hw_addr, dev->dev_addr, dev->addr_len);
  	b->secs = htons(jiffies_diff / HZ);
  	b->xid = d->xid;
  
  	/* add DHCP options or BOOTP extensions */
  #ifdef IPCONFIG_DHCP
  	if (ic_proto_enabled & IC_USE_DHCP)
22fc53887   Uwe Kleine-König   net: ipconfig: Ad...
850
  		ic_dhcp_init_options(b->exten, d);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
851
852
853
854
855
856
857
  	else
  #endif
  		ic_bootp_init_ext(b->exten);
  
  	/* Chain packet down the line... */
  	skb->dev = dev;
  	skb->protocol = htons(ETH_P_IP);
0c4e85813   Stephen Hemminger   [NET]: Wrap netde...
858
  	if (dev_hard_header(skb, dev, ntohs(skb->protocol),
ad79eefc4   RongQing.Li   ipv4: fix a memor...
859
860
861
862
863
864
865
  			    dev->broadcast, dev->dev_addr, skb->len) < 0) {
  		kfree_skb(skb);
  		printk("E");
  		return;
  	}
  
  	if (dev_queue_xmit(skb) < 0)
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
  		printk("E");
  }
  
  
  /*
   *  Copy BOOTP-supplied string if not already set.
   */
  static int __init ic_bootp_string(char *dest, char *src, int len, int max)
  {
  	if (!len)
  		return 0;
  	if (len > max-1)
  		len = max-1;
  	memcpy(dest, src, len);
  	dest[len] = '\0';
  	return 1;
  }
  
  
  /*
   *  Process BOOTP extensions.
   */
  static void __init ic_do_bootp_ext(u8 *ext)
  {
747465ef7   Eric Dumazet   net: fix some spa...
890
891
892
  	u8 servers;
  	int i;
  	__be16 mtu;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
893

1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
894
  	u8 *c;
09605cc12   Bastian Stender   net ipv4: use pre...
895
  	pr_debug("DHCP/BOOTP: Got extension %d:", *ext);
132adf546   Stephen Hemminger   [IPV4]: cleanup
896
  	for (c=ext+2; c<ext+2+ext[1]; c++)
09605cc12   Bastian Stender   net ipv4: use pre...
897
898
899
  		pr_debug(" %02x", *c);
  	pr_debug("
  ");
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
900
901
  
  	switch (*ext++) {
1d67a5168   Joe Perches   ipconfig: Reduce ...
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
  	case 1:		/* Subnet mask */
  		if (ic_netmask == NONE)
  			memcpy(&ic_netmask, ext+1, 4);
  		break;
  	case 3:		/* Default gateway */
  		if (ic_gateway == NONE)
  			memcpy(&ic_gateway, ext+1, 4);
  		break;
  	case 6:		/* DNS server */
  		servers= *ext/4;
  		if (servers > CONF_NAMESERVERS_MAX)
  			servers = CONF_NAMESERVERS_MAX;
  		for (i = 0; i < servers; i++) {
  			if (ic_nameservers[i] == NONE)
  				memcpy(&ic_nameservers[i], ext+1+4*i, 4);
  		}
  		break;
  	case 12:	/* Host name */
  		ic_bootp_string(utsname()->nodename, ext+1, *ext,
  				__NEW_UTS_LEN);
  		ic_host_name_set = 1;
  		break;
  	case 15:	/* Domain name (DNS) */
  		ic_bootp_string(ic_domain, ext+1, *ext, sizeof(ic_domain));
  		break;
  	case 17:	/* Root path */
  		if (!root_server_path[0])
  			ic_bootp_string(root_server_path, ext+1, *ext,
  					sizeof(root_server_path));
  		break;
  	case 26:	/* Interface MTU */
  		memcpy(&mtu, ext+1, sizeof(mtu));
  		ic_dev_mtu = ntohs(mtu);
  		break;
  	case 40:	/* NIS Domain name (_not_ DNS) */
  		ic_bootp_string(utsname()->domainname, ext+1, *ext,
  				__NEW_UTS_LEN);
  		break;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
940
941
942
943
944
945
946
  	}
  }
  
  
  /*
   *  Receive BOOTP reply.
   */
f2ccd8fa0   David S. Miller   [NET]: Kill skb->...
947
  static int __init ic_bootp_recv(struct sk_buff *skb, struct net_device *dev, struct packet_type *pt, struct net_device *orig_dev)
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
948
949
950
951
952
  {
  	struct bootp_pkt *b;
  	struct iphdr *h;
  	struct ic_device *d;
  	int len, ext_len;
721499e89   YOSHIFUJI Hideaki   netns: Use net_eq...
953
  	if (!net_eq(dev_net(dev), &init_net))
e730c1551   Eric W. Biederman   [NET]: Make packe...
954
  		goto drop;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
955
956
957
  	/* Perform verifications before taking the lock.  */
  	if (skb->pkt_type == PACKET_OTHERHOST)
  		goto drop;
51456b291   Ian Morris   ipv4: coding styl...
958
959
  	skb = skb_share_check(skb, GFP_ATOMIC);
  	if (!skb)
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
960
961
962
963
964
965
  		return NET_RX_DROP;
  
  	if (!pskb_may_pull(skb,
  			   sizeof(struct iphdr) +
  			   sizeof(struct udphdr)))
  		goto drop;
eddc9ec53   Arnaldo Carvalho de Melo   [SK_BUFF]: Introd...
966
  	b = (struct bootp_pkt *)skb_network_header(skb);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
967
968
969
970
971
972
  	h = &b->iph;
  
  	if (h->ihl != 5 || h->version != 4 || h->protocol != IPPROTO_UDP)
  		goto drop;
  
  	/* Fragments are not supported */
56f8a75c1   Paul Gortmaker   ip: introduce ip_...
973
  	if (ip_is_fragment(h)) {
e87cc4728   Joe Perches   net: Convert net_...
974
975
  		net_err_ratelimited("DHCP/BOOTP: Ignoring fragmented reply
  ");
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
  		goto drop;
  	}
  
  	if (skb->len < ntohs(h->tot_len))
  		goto drop;
  
  	if (ip_fast_csum((char *) h, h->ihl))
  		goto drop;
  
  	if (b->udph.source != htons(67) || b->udph.dest != htons(68))
  		goto drop;
  
  	if (ntohs(h->tot_len) < ntohs(b->udph.len) + sizeof(struct iphdr))
  		goto drop;
  
  	len = ntohs(b->udph.len) - sizeof(struct udphdr);
  	ext_len = len - (sizeof(*b) -
  			 sizeof(struct iphdr) -
  			 sizeof(struct udphdr) -
  			 sizeof(b->exten));
  	if (ext_len < 0)
  		goto drop;
  
  	/* Ok the front looks good, make sure we can get at the rest.  */
  	if (!pskb_may_pull(skb, skb->len))
  		goto drop;
eddc9ec53   Arnaldo Carvalho de Melo   [SK_BUFF]: Introd...
1002
  	b = (struct bootp_pkt *)skb_network_header(skb);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
  	h = &b->iph;
  
  	/* One reply at a time, please. */
  	spin_lock(&ic_recv_lock);
  
  	/* If we already have a reply, just drop the packet */
  	if (ic_got_reply)
  		goto drop_unlock;
  
  	/* Find the ic_device that the packet arrived on */
  	d = ic_first_dev;
  	while (d && d->dev != dev)
  		d = d->next;
  	if (!d)
  		goto drop_unlock;  /* should never happen */
  
  	/* Is it a reply to our BOOTP request? */
  	if (b->op != BOOTP_REPLY ||
  	    b->xid != d->xid) {
22fc53887   Uwe Kleine-König   net: ipconfig: Ad...
1022
1023
1024
  		net_err_ratelimited("DHCP/BOOTP: Reply not for us on %s, op[%x] xid[%x]
  ",
  				    d->dev->name, b->op, b->xid);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1025
1026
1027
1028
1029
1030
  		goto drop_unlock;
  	}
  
  	/* Parse extensions */
  	if (ext_len >= 4 &&
  	    !memcmp(b->exten, ic_bootp_cookie, 4)) { /* Check magic cookie */
e905a9eda   YOSHIFUJI Hideaki   [NET] IPV4: Fix w...
1031
  		u8 *end = (u8 *) b + ntohs(b->iph.tot_len);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1032
1033
1034
1035
  		u8 *ext;
  
  #ifdef IPCONFIG_DHCP
  		if (ic_proto_enabled & IC_USE_DHCP) {
5a874db4d   Al Viro   [NET]: ipconfig a...
1036
  			__be32 server_id = NONE;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
  			int mt = 0;
  
  			ext = &b->exten[4];
  			while (ext < end && *ext != 0xff) {
  				u8 *opt = ext++;
  				if (*opt == 0)	/* Padding */
  					continue;
  				ext += *ext + 1;
  				if (ext >= end)
  					break;
  				switch (*opt) {
  				case 53:	/* Message type */
  					if (opt[1])
  						mt = opt[2];
  					break;
  				case 54:	/* Server ID (IP address) */
  					if (opt[1] >= 4)
  						memcpy(&server_id, opt + 2, 4);
  					break;
3ff50b799   Stephen Hemminger   [NET]: cleanup ex...
1056
  				}
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1057
  			}
22fc53887   Uwe Kleine-König   net: ipconfig: Ad...
1058
1059
  			pr_debug("DHCP: Got message type %d (%s)
  ", mt, d->dev->name);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1060
1061
1062
1063
1064
1065
  
  			switch (mt) {
  			case DHCPOFFER:
  				/* While in the process of accepting one offer,
  				 * ignore all others.
  				 */
5a874db4d   Al Viro   [NET]: ipconfig a...
1066
  				if (ic_myaddr != NONE)
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1067
1068
1069
1070
1071
  					goto drop_unlock;
  
  				/* Let's accept that offer. */
  				ic_myaddr = b->your_ip;
  				ic_servaddr = server_id;
09605cc12   Bastian Stender   net ipv4: use pre...
1072
1073
1074
  				pr_debug("DHCP: Offered address %pI4 by server %pI4
  ",
  					 &ic_myaddr, &b->iph.saddr);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1075
1076
1077
1078
  				/* The DHCP indicated server address takes
  				 * precedence over the bootp header one if
  				 * they are different.
  				 */
5a874db4d   Al Viro   [NET]: ipconfig a...
1079
  				if ((server_id != NONE) &&
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
  				    (b->server_ip != server_id))
  					b->server_ip = ic_servaddr;
  				break;
  
  			case DHCPACK:
  				if (memcmp(dev->dev_addr, b->hw_addr, dev->addr_len) != 0)
  					goto drop_unlock;
  
  				/* Yeah! */
  				break;
  
  			default:
  				/* Urque.  Forget it*/
5a874db4d   Al Viro   [NET]: ipconfig a...
1093
1094
  				ic_myaddr = NONE;
  				ic_servaddr = NONE;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1095
  				goto drop_unlock;
3ff50b799   Stephen Hemminger   [NET]: cleanup ex...
1096
  			}
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
  
  			ic_dhcp_msgtype = mt;
  
  		}
  #endif /* IPCONFIG_DHCP */
  
  		ext = &b->exten[4];
  		while (ext < end && *ext != 0xff) {
  			u8 *opt = ext++;
  			if (*opt == 0)	/* Padding */
  				continue;
  			ext += *ext + 1;
  			if (ext < end)
  				ic_do_bootp_ext(opt);
  		}
  	}
  
  	/* We have a winner! */
2647cffb2   Uwe Kleine-König   net: ipconfig: Su...
1115
  	ic_dev = d;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1116
1117
  	ic_myaddr = b->your_ip;
  	ic_servaddr = b->server_ip;
9dd4a13a8   Philippe De Muyter   net/ipv4/ipconfig...
1118
  	ic_addrservaddr = b->iph.saddr;
5a874db4d   Al Viro   [NET]: ipconfig a...
1119
  	if (ic_gateway == NONE && b->relay_ip)
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1120
  		ic_gateway = b->relay_ip;
5a874db4d   Al Viro   [NET]: ipconfig a...
1121
  	if (ic_nameservers[0] == NONE)
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
  		ic_nameservers[0] = ic_servaddr;
  	ic_got_reply = IC_BOOTP;
  
  drop_unlock:
  	/* Show's over.  Nothing to see here.  */
  	spin_unlock(&ic_recv_lock);
  
  drop:
  	/* Throw the packet out. */
  	kfree_skb(skb);
  
  	return 0;
e905a9eda   YOSHIFUJI Hideaki   [NET] IPV4: Fix w...
1134
  }
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
  
  
  #endif
  
  
  /*
   *	Dynamic IP configuration -- DHCP, BOOTP, RARP.
   */
  
  #ifdef IPCONFIG_DYNAMIC
  
  static int __init ic_dynamic(void)
  {
  	int retries;
  	struct ic_device *d;
  	unsigned long start_jiffies, timeout, jiff;
  	int do_bootp = ic_proto_have_if & IC_BOOTP;
  	int do_rarp = ic_proto_have_if & IC_RARP;
  
  	/*
  	 * If none of DHCP/BOOTP/RARP was selected, return with an error.
  	 * This routine gets only called when some pieces of information
  	 * are missing, and without DHCP/BOOTP/RARP we are unable to get it.
  	 */
  	if (!ic_proto_enabled) {
058bd4d2a   Joe Perches   net: Convert prin...
1160
1161
  		pr_err("IP-Config: Incomplete network configuration information
  ");
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1162
1163
1164
1165
1166
  		return -1;
  	}
  
  #ifdef IPCONFIG_BOOTP
  	if ((ic_proto_enabled ^ ic_proto_have_if) & IC_BOOTP)
058bd4d2a   Joe Perches   net: Convert prin...
1167
1168
  		pr_err("DHCP/BOOTP: No suitable device found
  ");
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1169
1170
1171
  #endif
  #ifdef IPCONFIG_RARP
  	if ((ic_proto_enabled ^ ic_proto_have_if) & IC_RARP)
058bd4d2a   Joe Perches   net: Convert prin...
1172
1173
  		pr_err("RARP: No suitable device found
  ");
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
  #endif
  
  	if (!ic_proto_have_if)
  		/* Error message already printed */
  		return -1;
  
  	/*
  	 * Setup protocols
  	 */
  #ifdef IPCONFIG_BOOTP
  	if (do_bootp)
  		ic_bootp_init();
  #endif
  #ifdef IPCONFIG_RARP
  	if (do_rarp)
  		ic_rarp_init();
  #endif
  
  	/*
  	 * Send requests and wait, until we get an answer. This loop
  	 * seems to be a terrible waste of CPU time, but actually there is
  	 * only one process running at all, so we don't need to use any
  	 * scheduler functions.
e905a9eda   YOSHIFUJI Hideaki   [NET] IPV4: Fix w...
1197
  	 * [Actually we could now, but the nothing else running note still
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1198
1199
  	 *  applies.. - AC]
  	 */
058bd4d2a   Joe Perches   net: Convert prin...
1200
1201
1202
1203
1204
  	pr_notice("Sending %s%s%s requests .",
  		  do_bootp
  		  ? ((ic_proto_enabled & IC_USE_DHCP) ? "DHCP" : "BOOTP") : "",
  		  (do_bootp && do_rarp) ? " and " : "",
  		  do_rarp ? "RARP" : "");
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1205
1206
1207
1208
1209
  
  	start_jiffies = jiffies;
  	d = ic_first_dev;
  	retries = CONF_SEND_RETRIES;
  	get_random_bytes(&timeout, sizeof(timeout));
95c961747   Eric Dumazet   net: cleanup unsi...
1210
  	timeout = CONF_BASE_TIMEOUT + (timeout % (unsigned int) CONF_TIMEOUT_RANDOM);
132adf546   Stephen Hemminger   [IPV4]: cleanup
1211
  	for (;;) {
405fd7071   David S. Miller   ipconfig: Only bo...
1212
  #ifdef IPCONFIG_BOOTP
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1213
1214
1215
1216
1217
1218
1219
  		if (do_bootp && (d->able & IC_BOOTP))
  			ic_bootp_send_if(d, jiffies - start_jiffies);
  #endif
  #ifdef IPCONFIG_RARP
  		if (do_rarp && (d->able & IC_RARP))
  			ic_rarp_send_if(d);
  #endif
e06885340   Uwe Kleine-König   net: ipconfig: dr...
1220
1221
1222
1223
1224
  		if (!d->next) {
  			jiff = jiffies + timeout;
  			while (time_before(jiffies, jiff) && !ic_got_reply)
  				schedule_timeout_uninterruptible(1);
  		}
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1225
1226
  #ifdef IPCONFIG_DHCP
  		/* DHCP isn't done until we get a DHCPACK. */
9d4fb27db   Joe Perches   net/ipv4: Move &&...
1227
1228
1229
  		if ((ic_got_reply & IC_BOOTP) &&
  		    (ic_proto_enabled & IC_USE_DHCP) &&
  		    ic_dhcp_msgtype != DHCPACK) {
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1230
  			ic_got_reply = 0;
2647cffb2   Uwe Kleine-König   net: ipconfig: Su...
1231
1232
  			/* continue on device that got the reply */
  			d = ic_dev;
6c1c36b02   Geert Uytterhoeven   net/ipv4/ipconfig...
1233
  			pr_cont(",");
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1234
1235
1236
1237
1238
  			continue;
  		}
  #endif /* IPCONFIG_DHCP */
  
  		if (ic_got_reply) {
6c1c36b02   Geert Uytterhoeven   net/ipv4/ipconfig...
1239
1240
  			pr_cont(" OK
  ");
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1241
1242
1243
1244
1245
1246
1247
  			break;
  		}
  
  		if ((d = d->next))
  			continue;
  
  		if (! --retries) {
6c1c36b02   Geert Uytterhoeven   net/ipv4/ipconfig...
1248
1249
  			pr_cont(" timed out!
  ");
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1250
1251
1252
1253
1254
1255
1256
1257
  			break;
  		}
  
  		d = ic_first_dev;
  
  		timeout = timeout CONF_TIMEOUT_MULT;
  		if (timeout > CONF_TIMEOUT_MAX)
  			timeout = CONF_TIMEOUT_MAX;
6c1c36b02   Geert Uytterhoeven   net/ipv4/ipconfig...
1258
  		pr_cont(".");
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
  	}
  
  #ifdef IPCONFIG_BOOTP
  	if (do_bootp)
  		ic_bootp_cleanup();
  #endif
  #ifdef IPCONFIG_RARP
  	if (do_rarp)
  		ic_rarp_cleanup();
  #endif
7a1af5d7b   Maxime Bizon   [IPV4]: ipconfig....
1269
  	if (!ic_got_reply) {
5a874db4d   Al Viro   [NET]: ipconfig a...
1270
  		ic_myaddr = NONE;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1271
  		return -1;
7a1af5d7b   Maxime Bizon   [IPV4]: ipconfig....
1272
  	}
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1273

6c1c36b02   Geert Uytterhoeven   net/ipv4/ipconfig...
1274
1275
  	pr_info("IP-Config: Got %s answer from %pI4, my address is %pI4
  ",
e905a9eda   YOSHIFUJI Hideaki   [NET] IPV4: Fix w...
1276
  		((ic_got_reply & IC_RARP) ? "RARP"
09605cc12   Bastian Stender   net ipv4: use pre...
1277
  		: (ic_proto_enabled & IC_USE_DHCP) ? "DHCP" : "BOOTP"),
6c1c36b02   Geert Uytterhoeven   net/ipv4/ipconfig...
1278
  		&ic_addrservaddr, &ic_myaddr);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
  
  	return 0;
  }
  
  #endif /* IPCONFIG_DYNAMIC */
  
  #ifdef CONFIG_PROC_FS
  
  static int pnp_seq_show(struct seq_file *seq, void *v)
  {
  	int i;
  
  	if (ic_proto_used & IC_PROTO)
  		seq_printf(seq, "#PROTO: %s
  ",
  			   (ic_proto_used & IC_RARP) ? "RARP"
  			   : (ic_proto_used & IC_USE_DHCP) ? "DHCP" : "BOOTP");
  	else
  		seq_puts(seq, "#MANUAL
  ");
  
  	if (ic_domain[0])
  		seq_printf(seq,
  			   "domain %s
  ", ic_domain);
  	for (i = 0; i < CONF_NAMESERVERS_MAX; i++) {
5a874db4d   Al Viro   [NET]: ipconfig a...
1305
  		if (ic_nameservers[i] != NONE)
673d57e72   Harvey Harrison   net: replace NIPQ...
1306
1307
1308
  			seq_printf(seq, "nameserver %pI4
  ",
  				   &ic_nameservers[i]);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1309
  	}
5a874db4d   Al Viro   [NET]: ipconfig a...
1310
  	if (ic_servaddr != NONE)
673d57e72   Harvey Harrison   net: replace NIPQ...
1311
1312
1313
  		seq_printf(seq, "bootserver %pI4
  ",
  			   &ic_servaddr);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1314
1315
1316
1317
1318
1319
1320
  	return 0;
  }
  
  static int pnp_seq_open(struct inode *indoe, struct file *file)
  {
  	return single_open(file, pnp_seq_show, NULL);
  }
9a32144e9   Arjan van de Ven   [PATCH] mark stru...
1321
  static const struct file_operations pnp_seq_fops = {
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
  	.owner		= THIS_MODULE,
  	.open		= pnp_seq_open,
  	.read		= seq_read,
  	.llseek		= seq_lseek,
  	.release	= single_release,
  };
  #endif /* CONFIG_PROC_FS */
  
  /*
   *  Extract IP address from the parameter string if needed. Note that we
   *  need to have root_server_addr set _before_ IPConfig gets called as it
   *  can override it.
   */
5a874db4d   Al Viro   [NET]: ipconfig a...
1335
  __be32 __init root_nfs_parse_addr(char *name)
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1336
  {
5a874db4d   Al Viro   [NET]: ipconfig a...
1337
  	__be32 addr;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
  	int octets = 0;
  	char *cp, *cq;
  
  	cp = cq = name;
  	while (octets < 4) {
  		while (*cp >= '0' && *cp <= '9')
  			cp++;
  		if (cp == cq || cp - cq > 3)
  			break;
  		if (*cp == '.' || octets == 3)
  			octets++;
  		if (octets < 4)
  			cp++;
  		cq = cp;
  	}
  	if (octets == 4 && (*cp == ':' || *cp == '\0')) {
  		if (*cp == ':')
  			*cp++ = '\0';
  		addr = in_aton(name);
  		memmove(name, cp, strlen(cp) + 1);
  	} else
5a874db4d   Al Viro   [NET]: ipconfig a...
1359
  		addr = NONE;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1360
1361
1362
  
  	return addr;
  }
964ad81cb   David S. Miller   ipconfig: Handle ...
1363
1364
1365
1366
1367
  #define DEVICE_WAIT_MAX		12 /* 12 seconds */
  
  static int __init wait_for_devices(void)
  {
  	int i;
964ad81cb   David S. Miller   ipconfig: Handle ...
1368
1369
1370
1371
1372
1373
  	for (i = 0; i < DEVICE_WAIT_MAX; i++) {
  		struct net_device *dev;
  		int found = 0;
  
  		rtnl_lock();
  		for_each_netdev(&init_net, dev) {
3fb72f1e6   Micha Nelissen   ipconfig wait for...
1374
  			if (ic_is_init_dev(dev)) {
964ad81cb   David S. Miller   ipconfig: Handle ...
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
  				found = 1;
  				break;
  			}
  		}
  		rtnl_unlock();
  		if (found)
  			return 0;
  		ssleep(1);
  	}
  	return -ENODEV;
  }
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1386
1387
1388
1389
1390
1391
  /*
   *	IP Autoconfig dispatcher.
   */
  
  static int __init ip_auto_config(void)
  {
5a874db4d   Al Viro   [NET]: ipconfig a...
1392
  	__be32 addr;
9d8dba6c9   Benjamin Zores   ipv4: fix infinit...
1393
1394
1395
  #ifdef IPCONFIG_DYNAMIC
  	int retries = CONF_OPEN_RETRIES;
  #endif
964ad81cb   David S. Miller   ipconfig: Handle ...
1396
  	int err;
5e953778a   Christoph Fritz   ipconfig: add nam...
1397
  	unsigned int i;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1398
1399
  
  #ifdef CONFIG_PROC_FS
d4beaa66a   Gao feng   net: proc: change...
1400
  	proc_create("pnp", S_IRUGO, init_net.proc_net, &pnp_seq_fops);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1401
1402
1403
1404
  #endif /* CONFIG_PROC_FS */
  
  	if (!ic_enable)
  		return 0;
09605cc12   Bastian Stender   net ipv4: use pre...
1405
1406
  	pr_debug("IP-Config: Entered.
  ");
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1407
1408
1409
  #ifdef IPCONFIG_DYNAMIC
   try_try_again:
  #endif
964ad81cb   David S. Miller   ipconfig: Handle ...
1410
1411
1412
1413
  	/* Wait for devices to appear */
  	err = wait_for_devices();
  	if (err)
  		return err;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1414
1415
  
  	/* Setup all network devices */
964ad81cb   David S. Miller   ipconfig: Handle ...
1416
1417
1418
  	err = ic_open_devs();
  	if (err)
  		return err;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1419
1420
  
  	/* Give drivers a chance to settle */
3fb72f1e6   Micha Nelissen   ipconfig wait for...
1421
  	msleep(CONF_POST_OPEN);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1422
1423
1424
1425
1426
1427
1428
  
  	/*
  	 * If the config information is insufficient (e.g., our IP address or
  	 * IP address of the boot server is missing or we have multiple network
  	 * interfaces and no default was set), use BOOTP or RARP to get the
  	 * missing values.
  	 */
5a874db4d   Al Viro   [NET]: ipconfig a...
1429
  	if (ic_myaddr == NONE ||
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1430
  #ifdef CONFIG_ROOT_NFS
9d4fb27db   Joe Perches   net/ipv4: Move &&...
1431
1432
1433
  	    (root_server_addr == NONE &&
  	     ic_servaddr == NONE &&
  	     ROOT_DEV == Root_NFS) ||
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1434
1435
1436
  #endif
  	    ic_first_dev->next) {
  #ifdef IPCONFIG_DYNAMIC
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
  		if (ic_dynamic() < 0) {
  			ic_close_devs();
  
  			/*
  			 * I don't know why, but sometimes the
  			 * eepro100 driver (at least) gets upset and
  			 * doesn't work the first time it's opened.
  			 * But then if you close it and reopen it, it
  			 * works just fine.  So we need to try that at
  			 * least once before giving up.
  			 *
  			 * Also, if the root will be NFS-mounted, we
  			 * have nowhere to go if DHCP fails.  So we
  			 * just have to keep trying forever.
  			 *
  			 * 				-- Chip
  			 */
  #ifdef CONFIG_ROOT_NFS
  			if (ROOT_DEV ==  Root_NFS) {
058bd4d2a   Joe Perches   net: Convert prin...
1456
1457
  				pr_err("IP-Config: Retrying forever (NFS root)...
  ");
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1458
1459
1460
1461
1462
  				goto try_try_again;
  			}
  #endif
  
  			if (--retries) {
058bd4d2a   Joe Perches   net: Convert prin...
1463
1464
  				pr_err("IP-Config: Reopening network devices...
  ");
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1465
1466
1467
1468
  				goto try_try_again;
  			}
  
  			/* Oh, well.  At least we tried. */
058bd4d2a   Joe Perches   net: Convert prin...
1469
1470
  			pr_err("IP-Config: Auto-configuration of network failed
  ");
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1471
1472
1473
  			return -1;
  		}
  #else /* !DYNAMIC */
058bd4d2a   Joe Perches   net: Convert prin...
1474
1475
  		pr_err("IP-Config: Incomplete network configuration information
  ");
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1476
1477
1478
1479
1480
  		ic_close_devs();
  		return -1;
  #endif /* IPCONFIG_DYNAMIC */
  	} else {
  		/* Device selected manually or only one device -> use it */
2647cffb2   Uwe Kleine-König   net: ipconfig: Su...
1481
  		ic_dev = ic_first_dev;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1482
1483
1484
  	}
  
  	addr = root_nfs_parse_addr(root_server_path);
5a874db4d   Al Viro   [NET]: ipconfig a...
1485
  	if (root_server_addr == NONE)
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1486
1487
1488
  		root_server_addr = addr;
  
  	/*
25985edce   Lucas De Marchi   Fix common misspe...
1489
  	 * Use defaults wherever applicable.
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1490
1491
1492
1493
1494
  	 */
  	if (ic_defaults() < 0)
  		return -1;
  
  	/*
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
  	 * Record which protocol was actually used.
  	 */
  #ifdef IPCONFIG_DYNAMIC
  	ic_proto_used = ic_got_reply | (ic_proto_enabled & IC_USE_DHCP);
  #endif
  
  #ifndef IPCONFIG_SILENT
  	/*
  	 * Clue in the operator.
  	 */
058bd4d2a   Joe Perches   net: Convert prin...
1505
1506
  	pr_info("IP-Config: Complete:
  ");
9ecd1c3d6   Claudio Fontana   net/ipv4/ipconfig...
1507
1508
1509
  
  	pr_info("     device=%s, hwaddr=%*phC, ipaddr=%pI4, mask=%pI4, gw=%pI4
  ",
2647cffb2   Uwe Kleine-König   net: ipconfig: Su...
1510
  		ic_dev->dev->name, ic_dev->dev->addr_len, ic_dev->dev->dev_addr,
9ecd1c3d6   Claudio Fontana   net/ipv4/ipconfig...
1511
  		&ic_myaddr, &ic_netmask, &ic_gateway);
058bd4d2a   Joe Perches   net: Convert prin...
1512
1513
1514
1515
1516
  	pr_info("     host=%s, domain=%s, nis-domain=%s
  ",
  		utsname()->nodename, ic_domain, utsname()->domainname);
  	pr_info("     bootserver=%pI4, rootserver=%pI4, rootpath=%s",
  		&ic_servaddr, &root_server_addr, root_server_path);
9643f4551   Chris Friesen   ipv4: teach ipcon...
1517
  	if (ic_dev_mtu)
058bd4d2a   Joe Perches   net: Convert prin...
1518
  		pr_cont(", mtu=%d", ic_dev_mtu);
5e953778a   Christoph Fritz   ipconfig: add nam...
1519
1520
  	for (i = 0; i < CONF_NAMESERVERS_MAX; i++)
  		if (ic_nameservers[i] != NONE) {
6c1c36b02   Geert Uytterhoeven   net/ipv4/ipconfig...
1521
  			pr_cont("     nameserver%u=%pI4",
5e953778a   Christoph Fritz   ipconfig: add nam...
1522
1523
1524
1525
1526
  				i, &ic_nameservers[i]);
  			break;
  		}
  	for (i++; i < CONF_NAMESERVERS_MAX; i++)
  		if (ic_nameservers[i] != NONE)
6c1c36b02   Geert Uytterhoeven   net/ipv4/ipconfig...
1527
1528
1529
  			pr_cont(", nameserver%u=%pI4", i, &ic_nameservers[i]);
  	pr_cont("
  ");
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1530
  #endif /* !SILENT */
9c706a49d   Uwe Kleine-König   net: ipconfig: fi...
1531
1532
1533
1534
  	/*
  	 * Close all network devices except the device we've
  	 * autoconfigured and set up routes.
  	 */
9c706a49d   Uwe Kleine-König   net: ipconfig: fi...
1535
  	if (ic_setup_if() < 0 || ic_setup_routes() < 0)
d2d371ae5   Thierry Reding   net: ipconfig: Fi...
1536
1537
1538
  		err = -1;
  	else
  		err = 0;
9c706a49d   Uwe Kleine-König   net: ipconfig: fi...
1539

d2d371ae5   Thierry Reding   net: ipconfig: Fi...
1540
  	ic_close_devs();
9c706a49d   Uwe Kleine-König   net: ipconfig: fi...
1541

d2d371ae5   Thierry Reding   net: ipconfig: Fi...
1542
  	return err;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1543
1544
1545
1546
1547
1548
1549
  }
  
  late_initcall(ip_auto_config);
  
  
  /*
   *  Decode any IP configuration options in the "ip=" or "nfsaddrs=" kernel
dc7a08166   J. Bruce Fields   nfs: new subdir D...
1550
   *  command line parameter.  See Documentation/filesystems/nfs/nfsroot.txt.
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1551
1552
1553
1554
1555
1556
   */
  static int __init ic_proto_name(char *name)
  {
  	if (!strcmp(name, "on") || !strcmp(name, "any")) {
  		return 1;
  	}
a6c05c3d0   Simon Horman   [IPV4]: Fix ip co...
1557
  	if (!strcmp(name, "off") || !strcmp(name, "none")) {
92ffb85dd   Amos Waterland   [IPV4] ipconfig: ...
1558
  		return 0;
a6c05c3d0   Simon Horman   [IPV4]: Fix ip co...
1559
  	}
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1560
  #ifdef CONFIG_IP_PNP_DHCP
26fb342c7   Li RongQing   ipconfig: send Cl...
1561
1562
  	else if (!strncmp(name, "dhcp", 4)) {
  		char *client_id;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1563
  		ic_proto_enabled &= ~IC_RARP;
26fb342c7   Li RongQing   ipconfig: send Cl...
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
  		client_id = strstr(name, "dhcp,");
  		if (client_id) {
  			char *v;
  
  			client_id = client_id + 5;
  			v = strchr(client_id, ',');
  			if (!v)
  				return 1;
  			*v = 0;
  			if (kstrtou8(client_id, 0, dhcp_client_identifier))
09605cc12   Bastian Stender   net ipv4: use pre...
1574
1575
  				pr_debug("DHCP: Invalid client identifier type
  ");
26fb342c7   Li RongQing   ipconfig: send Cl...
1576
1577
1578
  			strncpy(dhcp_client_identifier + 1, v + 1, 251);
  			*v = ',';
  		}
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
  		return 1;
  	}
  #endif
  #ifdef CONFIG_IP_PNP_BOOTP
  	else if (!strcmp(name, "bootp")) {
  		ic_proto_enabled &= ~(IC_RARP | IC_USE_DHCP);
  		return 1;
  	}
  #endif
  #ifdef CONFIG_IP_PNP_RARP
  	else if (!strcmp(name, "rarp")) {
  		ic_proto_enabled &= ~(IC_BOOTP | IC_USE_DHCP);
  		return 1;
  	}
  #endif
  #ifdef IPCONFIG_DYNAMIC
  	else if (!strcmp(name, "both")) {
  		ic_proto_enabled &= ~IC_USE_DHCP; /* backward compat :-( */
  		return 1;
  	}
  #endif
  	return 0;
  }
  
  static int __init ip_auto_config_setup(char *addrs)
  {
  	char *cp, *ip, *dp;
  	int num = 0;
  
  	ic_set_manually = 1;
9cecd07c3   Simon Horman   [IPV4] Fix ip=dhc...
1609
  	ic_enable = 1;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1610

92ffb85dd   Amos Waterland   [IPV4] ipconfig: ...
1611
1612
1613
1614
  	/*
  	 * If any dhcp, bootp etc options are set, leave autoconfig on
  	 * and skip the below static IP processing.
  	 */
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1615
1616
  	if (ic_proto_name(addrs))
  		return 1;
92ffb85dd   Amos Waterland   [IPV4] ipconfig: ...
1617
1618
1619
1620
1621
1622
1623
  	/* If no static IP is given, turn off autoconfig and bail.  */
  	if (*addrs == 0 ||
  	    strcmp(addrs, "off") == 0 ||
  	    strcmp(addrs, "none") == 0) {
  		ic_enable = 0;
  		return 1;
  	}
5e953778a   Christoph Fritz   ipconfig: add nam...
1624
  	ic_nameservers_predef();
92ffb85dd   Amos Waterland   [IPV4] ipconfig: ...
1625
  	/* Parse string for static IP assignment.  */
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1626
1627
1628
1629
1630
  	ip = addrs;
  	while (ip && *ip) {
  		if ((cp = strchr(ip, ':')))
  			*cp++ = '\0';
  		if (strlen(ip) > 0) {
09605cc12   Bastian Stender   net ipv4: use pre...
1631
1632
  			pr_debug("IP-Config: Parameter #%d: `%s'
  ", num, ip);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1633
1634
  			switch (num) {
  			case 0:
e6f1cebf7   Al Viro   [NET] endianness ...
1635
  				if ((ic_myaddr = in_aton(ip)) == ANY)
5a874db4d   Al Viro   [NET]: ipconfig a...
1636
  					ic_myaddr = NONE;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1637
1638
  				break;
  			case 1:
e6f1cebf7   Al Viro   [NET] endianness ...
1639
  				if ((ic_servaddr = in_aton(ip)) == ANY)
5a874db4d   Al Viro   [NET]: ipconfig a...
1640
  					ic_servaddr = NONE;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1641
1642
  				break;
  			case 2:
e6f1cebf7   Al Viro   [NET] endianness ...
1643
  				if ((ic_gateway = in_aton(ip)) == ANY)
5a874db4d   Al Viro   [NET]: ipconfig a...
1644
  					ic_gateway = NONE;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1645
1646
  				break;
  			case 3:
e6f1cebf7   Al Viro   [NET] endianness ...
1647
  				if ((ic_netmask = in_aton(ip)) == ANY)
5a874db4d   Al Viro   [NET]: ipconfig a...
1648
  					ic_netmask = NONE;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1649
1650
1651
1652
  				break;
  			case 4:
  				if ((dp = strchr(ip, '.'))) {
  					*dp++ = '\0';
e9ff3990f   Serge E. Hallyn   [PATCH] namespace...
1653
1654
  					strlcpy(utsname()->domainname, dp,
  						sizeof(utsname()->domainname));
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1655
  				}
e9ff3990f   Serge E. Hallyn   [PATCH] namespace...
1656
1657
  				strlcpy(utsname()->nodename, ip,
  					sizeof(utsname()->nodename));
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1658
1659
1660
1661
1662
1663
  				ic_host_name_set = 1;
  				break;
  			case 5:
  				strlcpy(user_dev_name, ip, sizeof(user_dev_name));
  				break;
  			case 6:
92ffb85dd   Amos Waterland   [IPV4] ipconfig: ...
1664
1665
1666
1667
  				if (ic_proto_name(ip) == 0 &&
  				    ic_myaddr == NONE) {
  					ic_enable = 0;
  				}
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1668
  				break;
5e953778a   Christoph Fritz   ipconfig: add nam...
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
  			case 7:
  				if (CONF_NAMESERVERS_MAX >= 1) {
  					ic_nameservers[0] = in_aton(ip);
  					if (ic_nameservers[0] == ANY)
  						ic_nameservers[0] = NONE;
  				}
  				break;
  			case 8:
  				if (CONF_NAMESERVERS_MAX >= 2) {
  					ic_nameservers[1] = in_aton(ip);
  					if (ic_nameservers[1] == ANY)
  						ic_nameservers[1] = NONE;
  				}
  				break;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1683
1684
1685
1686
1687
1688
1689
1690
  			}
  		}
  		ip = cp;
  		num++;
  	}
  
  	return 1;
  }
b37f4d7b0   Eldad Zack   net/ipv4/ipconfig...
1691
  __setup("ip=", ip_auto_config_setup);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1692
1693
1694
1695
1696
  
  static int __init nfsaddrs_config_setup(char *addrs)
  {
  	return ip_auto_config_setup(addrs);
  }
b37f4d7b0   Eldad Zack   net/ipv4/ipconfig...
1697
  __setup("nfsaddrs=", nfsaddrs_config_setup);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1698

62013dbb8   Rainer Jochem   [IPV4] ipconfig: ...
1699
1700
1701
1702
1703
  static int __init vendor_class_identifier_setup(char *addrs)
  {
  	if (strlcpy(vendor_class_identifier, addrs,
  		    sizeof(vendor_class_identifier))
  	    >= sizeof(vendor_class_identifier))
09605cc12   Bastian Stender   net ipv4: use pre...
1704
1705
  		pr_warn("DHCP: vendorclass too long, truncated to \"%s\"
  ",
058bd4d2a   Joe Perches   net: Convert prin...
1706
  			vendor_class_identifier);
62013dbb8   Rainer Jochem   [IPV4] ipconfig: ...
1707
1708
  	return 1;
  }
62013dbb8   Rainer Jochem   [IPV4] ipconfig: ...
1709
  __setup("dhcpclass=", vendor_class_identifier_setup);