diff options
-rw-r--r-- | sys/src/cmd/ip/ipconfig/dhcp.c | 3 | ||||
-rw-r--r-- | sys/src/cmd/ip/ipconfig/ipconfig.h | 2 | ||||
-rw-r--r-- | sys/src/cmd/ip/ipconfig/ipv6.c | 13 | ||||
-rw-r--r-- | sys/src/cmd/ip/ipconfig/main.c | 27 |
4 files changed, 24 insertions, 21 deletions
diff --git a/sys/src/cmd/ip/ipconfig/dhcp.c b/sys/src/cmd/ip/ipconfig/dhcp.c index 7bd8141ba..2b28a7f87 100644 --- a/sys/src/cmd/ip/ipconfig/dhcp.c +++ b/sys/src/cmd/ip/ipconfig/dhcp.c @@ -264,8 +264,7 @@ dhcpwatch(int needconfig) * leave everything we've learned somewhere that * other procs can find it. */ - if(beprimary) - putndb(); + putndb(); refresh(); } } diff --git a/sys/src/cmd/ip/ipconfig/ipconfig.h b/sys/src/cmd/ip/ipconfig/ipconfig.h index c4784a5e3..9445e4965 100644 --- a/sys/src/cmd/ip/ipconfig/ipconfig.h +++ b/sys/src/cmd/ip/ipconfig/ipconfig.h @@ -98,7 +98,6 @@ struct Ctl extern Conf conf; extern int myifc; -extern int beprimary; extern int noconfig; extern int debug; @@ -120,6 +119,7 @@ void ipunconfig(void); void adddefroute(uchar*, uchar*, uchar*, uchar*); void removedefroute(uchar*, uchar*, uchar*, uchar*); +int isether(void); long jitter(void); void catch(void*, char*); int countaddrs(uchar *a, int len); diff --git a/sys/src/cmd/ip/ipconfig/ipv6.c b/sys/src/cmd/ip/ipconfig/ipv6.c index eb2ce4c7b..cbb2fd2f7 100644 --- a/sys/src/cmd/ip/ipconfig/ipv6.c +++ b/sys/src/cmd/ip/ipconfig/ipv6.c @@ -151,12 +151,6 @@ uchar v6solpfx[IPaddrlen] = { 0xff, 0, 0, 0, }; -uchar v6defmask[IPaddrlen] = { - 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, - 0, 0, 0, 0, - 0, 0, 0, 0 -}; void v6paraminit(Conf *cf) @@ -366,7 +360,7 @@ ip6cfg(void) if(!validip(conf.laddr) || isv4(conf.laddr)) return -1; - tentative = dupl_disc; + tentative = dupl_disc && isether(); Again: if(tentative) @@ -376,7 +370,7 @@ Again: n += snprint(buf+n, sizeof buf-n, " %I", conf.laddr); if(!validip(conf.mask)) - ipmove(conf.mask, v6defmask); + ipmove(conf.mask, defmask(conf.laddr)); n += snprint(buf+n, sizeof buf-n, " %M", conf.mask); if(validip(conf.raddr)){ n += snprint(buf+n, sizeof buf-n, " %I", conf.raddr); @@ -770,8 +764,7 @@ recvrahost(uchar buf[], int pktlen) if(noconfig) continue; - if(beprimary) - putndb(); + putndb(); refresh(); } } diff --git a/sys/src/cmd/ip/ipconfig/main.c b/sys/src/cmd/ip/ipconfig/main.c index 1a7199421..20113725c 100644 --- a/sys/src/cmd/ip/ipconfig/main.c +++ b/sys/src/cmd/ip/ipconfig/main.c @@ -211,11 +211,11 @@ parseargs(int argc, char **argv) switch(verb){ case Vether: case Vgbe: - case Vppp: case Vloopback: + case Vpkt: + case Vppp: case Vtorus: case Vtree: - case Vpkt: conf.type = *argv++; argc--; if(argc > 0){ @@ -283,10 +283,15 @@ findifc(char *net, char *dev) return -1; } -static int +int isether(void) { - return strcmp(conf.type, "ether") == 0 || strcmp(conf.type, "gbe") == 0; + switch(parseverb(conf.type)){ + case Vether: + case Vgbe: + return 1; + } + return 0; } /* create a client id */ @@ -394,6 +399,9 @@ main(int argc, char **argv) action = parseargs(argc, argv); + if(beprimary == -1 && (ipv6auto || parseverb(conf.type) == Vloopback)) + beprimary = 0; + myifc = findifc(conf.mpoint, conf.dev); if(myifc < 0) { switch(action){ @@ -420,6 +428,7 @@ main(int argc, char **argv) mkclientid(); if(dondbconfig){ dodhcp = 0; + beprimary = 0; ndbconfig(); break; } @@ -457,14 +466,14 @@ doadd(void) dhcpquery(!noconfig, Sselecting); } - if(!validip(conf.laddr)) + if(!validip(conf.laddr)){ if(rflag && dodhcp && !noconfig){ warning("couldn't determine ip address, retrying"); dhcpwatch(1); return; } else sysfatal("no success with DHCP"); - + } DEBUG("adding address %I %M on %s", conf.laddr, conf.mask, conf.dev); if(noconfig) return; @@ -480,8 +489,7 @@ doadd(void) } /* leave everything we've learned somewhere other procs can find it */ - if(beprimary && !dondbconfig && !ipv6auto) - putndb(); + putndb(); refresh(); } @@ -661,6 +669,9 @@ putndb(void) Ndb *db; int fd; + if(beprimary == 0) + return; + p = buf; e = buf + sizeof buf; p = seprint(p, e, "ip=%I ipmask=%M ipgw=%I\n", |