[klibc] [klibc:master] ipconfig: Implement support -d ...:dns0:dns1 options

klibc-bot for Dimitri John Ledkov xnox at ubuntu.com
Sun Jul 28 12:48:11 PDT 2019


Commit-ID:  b86cd0ef3f225b0e68a7c49de2460829f6bfe2be
Gitweb:     http://git.kernel.org/?p=libs/klibc/klibc.git;a=commit;h=b86cd0ef3f225b0e68a7c49de2460829f6bfe2be
Author:     Dimitri John Ledkov <xnox at ubuntu.com>
AuthorDate: Wed, 17 Jul 2019 22:18:23 +0100
Committer:  Ben Hutchings <ben at decadent.org.uk>
CommitDate: Sun, 28 Jul 2019 20:12:38 +0100

[klibc] ipconfig: Implement support -d ...:dns0:dns1 options

Whilst ip= command is documented to support dns0:dns1 options as
arguments 7 and 8, the -d parser in ipconfig does not. This breaks
bringing up static ip configuration with dns nameservers set in the
ip= command.

Testcase:

$ ip link add name dummy0 type dummy
$ sudo /usr/lib/klibc/bin/ipconfig -d 10.245.237.7::10.245.237.1:255.255.255.0:ottawa:dummy0:none:8.8.8.8:8.8.4.4
IP-Config: dummy0 hardware address 76:39:ca:27:9b:90 mtu 1500
IP-Config: dummy0 guessed broadcast address 10.245.237.255
IP-Config: dummy0 complete:
 address: 10.245.237.7     broadcast: 10.245.237.255   netmask: 255.255.255.0
 gateway: 10.245.237.1     dns0     : 8.8.8.8          dns1   : 8.8.4.4
 host   : ottawa
 rootserver: 0.0.0.0 rootpath:
 filename  :

Signed-off-by: Dimitri John Ledkov <xnox at ubuntu.com>
Signed-off-by: Ben Hutchings <ben at decadent.org.uk>

---
 usr/kinit/ipconfig/main.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/usr/kinit/ipconfig/main.c b/usr/kinit/ipconfig/main.c
index a454022e..2c905986 100644
--- a/usr/kinit/ipconfig/main.c
+++ b/usr/kinit/ipconfig/main.c
@@ -611,7 +611,7 @@ static int parse_device(struct netdev *dev, char *ip)
 			if ((cp = strchr(ip, ':'))) {
 				*cp++ = '\0';
 			}
-			if (opt > 6) {
+			if (opt > 8) {
 				fprintf(stderr,
 					"%s: too many options for %s\n",
 					progname, dev->name);
@@ -647,6 +647,12 @@ static int parse_device(struct netdev *dev, char *ip)
 			case 6:
 				dev->caps = parse_proto(ip);
 				break;
+			case 7:
+				parse_addr(&dev->ip_nameserver[0], ip);
+				break;
+			case 8:
+				parse_addr(&dev->ip_nameserver[1], ip);
+				break;
 			}
 		}
 	}


More information about the klibc mailing list