ipconfig: Tidy up reporting of name servers
authorChris Novakovic <chris@chrisn.me.uk>
Tue, 24 Apr 2018 02:56:33 +0000 (03:56 +0100)
committerDavid S. Miller <davem@davemloft.net>
Tue, 24 Apr 2018 17:40:41 +0000 (13:40 -0400)
Commit 5e953778a2aab04929a5e7b69f53dc26e39b079e ("ipconfig: add
nameserver IPs to kernel-parameter ip=") adds the IP addresses of
discovered name servers to the summary printed by ipconfig when
configuration is complete. It appears the intention in ip_auto_config()
was to print the name servers on a new line (especially given the
spacing and lack of comma before "nameserver0="), but they're actually
printed on the same line as the NFS root filesystem configuration
summary:

  [    0.686186] IP-Config: Complete:
  [    0.686226]      device=eth0, hwaddr=xx:xx:xx:xx:xx:xx, ipaddr=10.0.0.2, mask=255.255.255.0, gw=10.0.0.1
  [    0.686328]      host=test, domain=example.com, nis-domain=(none)
  [    0.686386]      bootserver=10.0.0.1, rootserver=10.0.0.1, rootpath=     nameserver0=10.0.0.1

This makes it harder to read and parse ipconfig's output. Instead, print
the name servers on a separate line:

  [    0.791250] IP-Config: Complete:
  [    0.791289]      device=eth0, hwaddr=xx:xx:xx:xx:xx:xx, ipaddr=10.0.0.2, mask=255.255.255.0, gw=10.0.0.1
  [    0.791407]      host=test, domain=example.com, nis-domain=(none)
  [    0.791475]      bootserver=10.0.0.1, rootserver=10.0.0.1, rootpath=
  [    0.791476]      nameserver0=10.0.0.1

Signed-off-by: Chris Novakovic <chris@chrisn.me.uk>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/ipv4/ipconfig.c

index 43f620feb1c45854f847010090fc43a8e810d4ef..d0ea0ecc900863b0468649b377bbf71653d5ccbe 100644 (file)
@@ -1481,16 +1481,19 @@ static int __init ip_auto_config(void)
                &ic_servaddr, &root_server_addr, root_server_path);
        if (ic_dev_mtu)
                pr_cont(", mtu=%d", ic_dev_mtu);
-       for (i = 0; i < CONF_NAMESERVERS_MAX; i++)
+       /* Name servers (if any): */
+       for (i = 0; i < CONF_NAMESERVERS_MAX; i++) {
                if (ic_nameservers[i] != NONE) {
-                       pr_cont("     nameserver%u=%pI4",
-                               i, &ic_nameservers[i]);
-                       break;
+                       if (i == 0)
+                               pr_info("     nameserver%u=%pI4",
+                                       i, &ic_nameservers[i]);
+                       else
+                               pr_cont(", nameserver%u=%pI4",
+                                       i, &ic_nameservers[i]);
                }
-       for (i++; i < CONF_NAMESERVERS_MAX; i++)
-               if (ic_nameservers[i] != NONE)
-                       pr_cont(", nameserver%u=%pI4", i, &ic_nameservers[i]);
-       pr_cont("\n");
+               if (i + 1 == CONF_NAMESERVERS_MAX)
+                       pr_cont("\n");
+       }
 #endif /* !SILENT */
 
        /*