87
87
#endif
88
88
89
89
/* Define the friendly delay before and after opening net devices */
90
- #define CONF_PRE_OPEN 500 /* Before opening: 1/2 second */
91
- #define CONF_POST_OPEN 1 /* After opening: 1 second */
90
+ #define CONF_POST_OPEN 10 /* After opening: 10 msecs */
91
+ #define CONF_CARRIER_TIMEOUT 120000 /* Wait for carrier timeout */
92
92
93
93
/* Define the timeout for waiting for a DHCP/BOOTP/RARP reply */
94
94
#define CONF_OPEN_RETRIES 2 /* (Re)open devices twice */
@@ -188,21 +188,22 @@ struct ic_device {
188
188
static struct ic_device * ic_first_dev __initdata = NULL ;/* List of open device */
189
189
static struct net_device * ic_dev __initdata = NULL ; /* Selected device */
190
190
191
- static bool __init ic_device_match (struct net_device * dev )
191
+ static bool __init ic_is_init_dev (struct net_device * dev )
192
192
{
193
- if (user_dev_name [0 ] ? !strcmp (dev -> name , user_dev_name ) :
193
+ if (dev -> flags & IFF_LOOPBACK )
194
+ return false;
195
+ return user_dev_name [0 ] ? !strcmp (dev -> name , user_dev_name ) :
194
196
(!(dev -> flags & IFF_LOOPBACK ) &&
195
197
(dev -> flags & (IFF_POINTOPOINT |IFF_BROADCAST )) &&
196
- strncmp (dev -> name , "dummy" , 5 )))
197
- return true;
198
- return false;
198
+ strncmp (dev -> name , "dummy" , 5 ));
199
199
}
200
200
201
201
static int __init ic_open_devs (void )
202
202
{
203
203
struct ic_device * d , * * last ;
204
204
struct net_device * dev ;
205
205
unsigned short oflags ;
206
+ unsigned long start ;
206
207
207
208
last = & ic_first_dev ;
208
209
rtnl_lock ();
@@ -216,9 +217,7 @@ static int __init ic_open_devs(void)
216
217
}
217
218
218
219
for_each_netdev (& init_net , dev ) {
219
- if (dev -> flags & IFF_LOOPBACK )
220
- continue ;
221
- if (ic_device_match (dev )) {
220
+ if (ic_is_init_dev (dev )) {
222
221
int able = 0 ;
223
222
if (dev -> mtu >= 364 )
224
223
able |= IC_BOOTP ;
@@ -252,6 +251,17 @@ static int __init ic_open_devs(void)
252
251
dev -> name , able , d -> xid ));
253
252
}
254
253
}
254
+
255
+ /* wait for a carrier on at least one device */
256
+ start = jiffies ;
257
+ while (jiffies - start < msecs_to_jiffies (CONF_CARRIER_TIMEOUT )) {
258
+ for_each_netdev (& init_net , dev )
259
+ if (ic_is_init_dev (dev ) && netif_carrier_ok (dev ))
260
+ goto have_carrier ;
261
+
262
+ msleep (1 );
263
+ }
264
+ have_carrier :
255
265
rtnl_unlock ();
256
266
257
267
* last = NULL ;
@@ -1324,14 +1334,13 @@ static int __init wait_for_devices(void)
1324
1334
{
1325
1335
int i ;
1326
1336
1327
- msleep (CONF_PRE_OPEN );
1328
1337
for (i = 0 ; i < DEVICE_WAIT_MAX ; i ++ ) {
1329
1338
struct net_device * dev ;
1330
1339
int found = 0 ;
1331
1340
1332
1341
rtnl_lock ();
1333
1342
for_each_netdev (& init_net , dev ) {
1334
- if (ic_device_match (dev )) {
1343
+ if (ic_is_init_dev (dev )) {
1335
1344
found = 1 ;
1336
1345
break ;
1337
1346
}
@@ -1378,7 +1387,7 @@ static int __init ip_auto_config(void)
1378
1387
return err ;
1379
1388
1380
1389
/* Give drivers a chance to settle */
1381
- ssleep (CONF_POST_OPEN );
1390
+ msleep (CONF_POST_OPEN );
1382
1391
1383
1392
/*
1384
1393
* If the config information is insufficient (e.g., our IP address or
0 commit comments