.. | .. |
---|
85 | 85 | |
---|
86 | 86 | /* Define the friendly delay before and after opening net devices */ |
---|
87 | 87 | #define CONF_POST_OPEN 10 /* After opening: 10 msecs */ |
---|
88 | | -#define CONF_CARRIER_TIMEOUT 120000 /* Wait for carrier timeout */ |
---|
89 | 88 | |
---|
90 | 89 | /* Define the timeout for waiting for a DHCP/BOOTP/RARP reply */ |
---|
91 | 90 | #define CONF_OPEN_RETRIES 2 /* (Re)open devices twice */ |
---|
.. | .. |
---|
100 | 99 | |
---|
101 | 100 | #define NONE cpu_to_be32(INADDR_NONE) |
---|
102 | 101 | #define ANY cpu_to_be32(INADDR_ANY) |
---|
| 102 | + |
---|
| 103 | +/* Wait for carrier timeout default in seconds */ |
---|
| 104 | +static unsigned int carrier_timeout = 120; |
---|
103 | 105 | |
---|
104 | 106 | /* |
---|
105 | 107 | * Public IP configuration |
---|
.. | .. |
---|
220 | 222 | for_each_netdev(&init_net, dev) { |
---|
221 | 223 | if (!(dev->flags & IFF_LOOPBACK) && !netdev_uses_dsa(dev)) |
---|
222 | 224 | continue; |
---|
223 | | - if (dev_change_flags(dev, dev->flags | IFF_UP) < 0) |
---|
| 225 | + if (dev_change_flags(dev, dev->flags | IFF_UP, NULL) < 0) |
---|
224 | 226 | pr_err("IP-Config: Failed to open %s\n", dev->name); |
---|
225 | 227 | } |
---|
226 | 228 | |
---|
.. | .. |
---|
238 | 240 | if (ic_proto_enabled && !able) |
---|
239 | 241 | continue; |
---|
240 | 242 | oflags = dev->flags; |
---|
241 | | - if (dev_change_flags(dev, oflags | IFF_UP) < 0) { |
---|
| 243 | + if (dev_change_flags(dev, oflags | IFF_UP, NULL) < 0) { |
---|
242 | 244 | pr_err("IP-Config: Failed to open %s\n", |
---|
243 | 245 | dev->name); |
---|
244 | 246 | continue; |
---|
.. | .. |
---|
268 | 270 | |
---|
269 | 271 | /* wait for a carrier on at least one device */ |
---|
270 | 272 | start = jiffies; |
---|
271 | | - next_msg = start + msecs_to_jiffies(CONF_CARRIER_TIMEOUT/12); |
---|
| 273 | + next_msg = start + msecs_to_jiffies(20000); |
---|
272 | 274 | while (time_before(jiffies, start + |
---|
273 | | - msecs_to_jiffies(CONF_CARRIER_TIMEOUT))) { |
---|
| 275 | + msecs_to_jiffies(carrier_timeout * 1000))) { |
---|
274 | 276 | int wait, elapsed; |
---|
275 | 277 | |
---|
276 | 278 | for_each_netdev(&init_net, dev) |
---|
.. | .. |
---|
283 | 285 | continue; |
---|
284 | 286 | |
---|
285 | 287 | elapsed = jiffies_to_msecs(jiffies - start); |
---|
286 | | - wait = (CONF_CARRIER_TIMEOUT - elapsed + 500)/1000; |
---|
| 288 | + wait = (carrier_timeout * 1000 - elapsed + 500) / 1000; |
---|
287 | 289 | pr_info("Waiting up to %d more seconds for network.\n", wait); |
---|
288 | | - next_msg = jiffies + msecs_to_jiffies(CONF_CARRIER_TIMEOUT/12); |
---|
| 290 | + next_msg = jiffies + msecs_to_jiffies(20000); |
---|
289 | 291 | } |
---|
290 | 292 | have_carrier: |
---|
291 | 293 | rtnl_unlock(); |
---|
.. | .. |
---|
315 | 317 | dev = d->dev; |
---|
316 | 318 | if (d != ic_dev && !netdev_uses_dsa(dev)) { |
---|
317 | 319 | pr_debug("IP-Config: Downing %s\n", dev->name); |
---|
318 | | - dev_change_flags(dev, d->flags); |
---|
| 320 | + dev_change_flags(dev, d->flags, NULL); |
---|
319 | 321 | } |
---|
320 | 322 | kfree(d); |
---|
321 | 323 | } |
---|
.. | .. |
---|
429 | 431 | ic_netmask = htonl(IN_CLASSB_NET); |
---|
430 | 432 | else if (IN_CLASSC(ntohl(ic_myaddr))) |
---|
431 | 433 | ic_netmask = htonl(IN_CLASSC_NET); |
---|
| 434 | + else if (IN_CLASSE(ntohl(ic_myaddr))) |
---|
| 435 | + ic_netmask = htonl(IN_CLASSE_NET); |
---|
432 | 436 | else { |
---|
433 | 437 | pr_err("IP-Config: Unable to guess netmask for address %pI4\n", |
---|
434 | 438 | &ic_myaddr); |
---|
.. | .. |
---|
1333 | 1337 | |
---|
1334 | 1338 | /* Create a new file under /proc/net/ipconfig */ |
---|
1335 | 1339 | static int ipconfig_proc_net_create(const char *name, |
---|
1336 | | - const struct file_operations *fops) |
---|
| 1340 | + const struct proc_ops *proc_ops) |
---|
1337 | 1341 | { |
---|
1338 | 1342 | char *pname; |
---|
1339 | 1343 | struct proc_dir_entry *p; |
---|
.. | .. |
---|
1345 | 1349 | if (!pname) |
---|
1346 | 1350 | return -ENOMEM; |
---|
1347 | 1351 | |
---|
1348 | | - p = proc_create(pname, 0444, init_net.proc_net, fops); |
---|
| 1352 | + p = proc_create(pname, 0444, init_net.proc_net, proc_ops); |
---|
1349 | 1353 | kfree(pname); |
---|
1350 | 1354 | if (!p) |
---|
1351 | 1355 | return -ENOMEM; |
---|
.. | .. |
---|
1354 | 1358 | } |
---|
1355 | 1359 | |
---|
1356 | 1360 | /* Write NTP server IP addresses to /proc/net/ipconfig/ntp_servers */ |
---|
1357 | | -static int ntp_servers_seq_show(struct seq_file *seq, void *v) |
---|
| 1361 | +static int ntp_servers_show(struct seq_file *seq, void *v) |
---|
1358 | 1362 | { |
---|
1359 | 1363 | int i; |
---|
1360 | 1364 | |
---|
.. | .. |
---|
1364 | 1368 | } |
---|
1365 | 1369 | return 0; |
---|
1366 | 1370 | } |
---|
1367 | | - |
---|
1368 | | -static int ntp_servers_seq_open(struct inode *inode, struct file *file) |
---|
1369 | | -{ |
---|
1370 | | - return single_open(file, ntp_servers_seq_show, NULL); |
---|
1371 | | -} |
---|
1372 | | - |
---|
1373 | | -static const struct file_operations ntp_servers_seq_fops = { |
---|
1374 | | - .open = ntp_servers_seq_open, |
---|
1375 | | - .read = seq_read, |
---|
1376 | | - .llseek = seq_lseek, |
---|
1377 | | - .release = single_release, |
---|
1378 | | -}; |
---|
| 1371 | +DEFINE_PROC_SHOW_ATTRIBUTE(ntp_servers); |
---|
1379 | 1372 | #endif /* CONFIG_PROC_FS */ |
---|
1380 | 1373 | |
---|
1381 | 1374 | /* |
---|
.. | .. |
---|
1422 | 1415 | struct net_device *dev; |
---|
1423 | 1416 | int found = 0; |
---|
1424 | 1417 | |
---|
| 1418 | + /* make sure deferred device probes are finished */ |
---|
| 1419 | + wait_for_device_probe(); |
---|
| 1420 | + |
---|
1425 | 1421 | rtnl_lock(); |
---|
1426 | 1422 | for_each_netdev(&init_net, dev) { |
---|
1427 | 1423 | if (ic_is_init_dev(dev)) { |
---|
.. | .. |
---|
1448 | 1444 | int retries = CONF_OPEN_RETRIES; |
---|
1449 | 1445 | #endif |
---|
1450 | 1446 | int err; |
---|
1451 | | - unsigned int i; |
---|
| 1447 | + unsigned int i, count; |
---|
1452 | 1448 | |
---|
1453 | 1449 | /* Initialise all name servers and NTP servers to NONE (but only if the |
---|
1454 | 1450 | * "ip=" or "nfsaddrs=" kernel command line parameters weren't decoded, |
---|
.. | .. |
---|
1463 | 1459 | proc_create_single("pnp", 0444, init_net.proc_net, pnp_seq_show); |
---|
1464 | 1460 | |
---|
1465 | 1461 | if (ipconfig_proc_net_init() == 0) |
---|
1466 | | - ipconfig_proc_net_create("ntp_servers", &ntp_servers_seq_fops); |
---|
| 1462 | + ipconfig_proc_net_create("ntp_servers", &ntp_servers_proc_ops); |
---|
1467 | 1463 | #endif /* CONFIG_PROC_FS */ |
---|
1468 | 1464 | |
---|
1469 | 1465 | if (!ic_enable) |
---|
.. | .. |
---|
1493 | 1489 | * missing values. |
---|
1494 | 1490 | */ |
---|
1495 | 1491 | if (ic_myaddr == NONE || |
---|
1496 | | -#ifdef CONFIG_ROOT_NFS |
---|
| 1492 | +#if defined(CONFIG_ROOT_NFS) || defined(CONFIG_CIFS_ROOT) |
---|
1497 | 1493 | (root_server_addr == NONE && |
---|
1498 | 1494 | ic_servaddr == NONE && |
---|
1499 | | - ROOT_DEV == Root_NFS) || |
---|
| 1495 | + (ROOT_DEV == Root_NFS || ROOT_DEV == Root_CIFS)) || |
---|
1500 | 1496 | #endif |
---|
1501 | 1497 | ic_first_dev->next) { |
---|
1502 | 1498 | #ifdef IPCONFIG_DYNAMIC |
---|
.. | .. |
---|
1520 | 1516 | #ifdef CONFIG_ROOT_NFS |
---|
1521 | 1517 | if (ROOT_DEV == Root_NFS) { |
---|
1522 | 1518 | pr_err("IP-Config: Retrying forever (NFS root)...\n"); |
---|
| 1519 | + goto try_try_again; |
---|
| 1520 | + } |
---|
| 1521 | +#endif |
---|
| 1522 | +#ifdef CONFIG_CIFS_ROOT |
---|
| 1523 | + if (ROOT_DEV == Root_CIFS) { |
---|
| 1524 | + pr_err("IP-Config: Retrying forever (CIFS root)...\n"); |
---|
1523 | 1525 | goto try_try_again; |
---|
1524 | 1526 | } |
---|
1525 | 1527 | #endif |
---|
.. | .. |
---|
1576 | 1578 | if (ic_dev_mtu) |
---|
1577 | 1579 | pr_cont(", mtu=%d", ic_dev_mtu); |
---|
1578 | 1580 | /* Name servers (if any): */ |
---|
1579 | | - for (i = 0; i < CONF_NAMESERVERS_MAX; i++) { |
---|
| 1581 | + for (i = 0, count = 0; i < CONF_NAMESERVERS_MAX; i++) { |
---|
1580 | 1582 | if (ic_nameservers[i] != NONE) { |
---|
1581 | 1583 | if (i == 0) |
---|
1582 | 1584 | pr_info(" nameserver%u=%pI4", |
---|
.. | .. |
---|
1584 | 1586 | else |
---|
1585 | 1587 | pr_cont(", nameserver%u=%pI4", |
---|
1586 | 1588 | i, &ic_nameservers[i]); |
---|
| 1589 | + |
---|
| 1590 | + count++; |
---|
1587 | 1591 | } |
---|
1588 | | - if (i + 1 == CONF_NAMESERVERS_MAX) |
---|
| 1592 | + if ((i + 1 == CONF_NAMESERVERS_MAX) && count > 0) |
---|
1589 | 1593 | pr_cont("\n"); |
---|
1590 | 1594 | } |
---|
1591 | 1595 | /* NTP servers (if any): */ |
---|
1592 | | - for (i = 0; i < CONF_NTP_SERVERS_MAX; i++) { |
---|
| 1596 | + for (i = 0, count = 0; i < CONF_NTP_SERVERS_MAX; i++) { |
---|
1593 | 1597 | if (ic_ntp_servers[i] != NONE) { |
---|
1594 | 1598 | if (i == 0) |
---|
1595 | 1599 | pr_info(" ntpserver%u=%pI4", |
---|
.. | .. |
---|
1597 | 1601 | else |
---|
1598 | 1602 | pr_cont(", ntpserver%u=%pI4", |
---|
1599 | 1603 | i, &ic_ntp_servers[i]); |
---|
| 1604 | + |
---|
| 1605 | + count++; |
---|
1600 | 1606 | } |
---|
1601 | | - if (i + 1 == CONF_NTP_SERVERS_MAX) |
---|
| 1607 | + if ((i + 1 == CONF_NTP_SERVERS_MAX) && count > 0) |
---|
1602 | 1608 | pr_cont("\n"); |
---|
1603 | 1609 | } |
---|
1604 | 1610 | #endif /* !SILENT */ |
---|
.. | .. |
---|
1622 | 1628 | |
---|
1623 | 1629 | /* |
---|
1624 | 1630 | * Decode any IP configuration options in the "ip=" or "nfsaddrs=" kernel |
---|
1625 | | - * command line parameter. See Documentation/filesystems/nfs/nfsroot.txt. |
---|
| 1631 | + * command line parameter. See Documentation/admin-guide/nfs/nfsroot.rst. |
---|
1626 | 1632 | */ |
---|
1627 | 1633 | static int __init ic_proto_name(char *name) |
---|
1628 | 1634 | { |
---|
.. | .. |
---|
1792 | 1798 | return 1; |
---|
1793 | 1799 | } |
---|
1794 | 1800 | __setup("dhcpclass=", vendor_class_identifier_setup); |
---|
| 1801 | + |
---|
| 1802 | +static int __init set_carrier_timeout(char *str) |
---|
| 1803 | +{ |
---|
| 1804 | + ssize_t ret; |
---|
| 1805 | + |
---|
| 1806 | + if (!str) |
---|
| 1807 | + return 0; |
---|
| 1808 | + |
---|
| 1809 | + ret = kstrtouint(str, 0, &carrier_timeout); |
---|
| 1810 | + if (ret) |
---|
| 1811 | + return 0; |
---|
| 1812 | + |
---|
| 1813 | + return 1; |
---|
| 1814 | +} |
---|
| 1815 | +__setup("carrier_timeout=", set_carrier_timeout); |
---|