diff --git a/sys/src/cmd/ip/ipconfig/dhcp.c b/sys/src/cmd/ip/ipconfig/dhcp.c index 064786ced..a312d2c07 100644 --- a/sys/src/cmd/ip/ipconfig/dhcp.c +++ b/sys/src/cmd/ip/ipconfig/dhcp.c @@ -243,6 +243,7 @@ dhcpwatch(int needconfig) t = secs; if(t >= conf.lease){ conf.lease = 0; + DEBUG("couldn't renew IP lease"); if(!noconfig){ ipunconfig(); needconfig = 1; diff --git a/sys/src/cmd/ip/ipconfig/ipv6.c b/sys/src/cmd/ip/ipconfig/ipv6.c index 09a0133fc..652814f12 100644 --- a/sys/src/cmd/ip/ipconfig/ipv6.c +++ b/sys/src/cmd/ip/ipconfig/ipv6.c @@ -415,7 +415,7 @@ recvra6on(Ipifc *ifc) return 0; else if(ifc->sendra6 > 0) return IsRouter; - else if(ifc->recvra6 > 0) + else if(ifc->recvra6 > 0 || noconfig) return IsHostRecv; else return IsHostNoRecv; @@ -712,6 +712,7 @@ recvrahost(uchar buf[], int pktlen) break; } } + issuebasera6(&conf); /* remove expired default routes */ @@ -722,10 +723,11 @@ recvrahost(uchar buf[], int pktlen) || r->prefixlt != ~0UL && r->prefixlt < now-r->time || r->routerlt != ~0UL && r->routerlt < now-r->time || ipcmp(r->src, ra->src) == 0 && r->routerlt != 0 && conf.routerlt == 0){ + DEBUG("purging RA from %I on %s; pfx %I %M", + r->src, conf.dev, r->laddr, r->mask); if(validip(r->gaddr)) removedefroute(r->gaddr, conf.lladdr, r->laddr, r->mask); *rr = r->next; - r->next = nil; free(r); continue; } @@ -774,7 +776,6 @@ recvrahost(uchar buf[], int pktlen) && ipcmp(r->laddr, conf.laddr) == 0){ seen = memcmp(r->hash, hash, SHA1dlen) == 0; *rr = r->next; - r->next = nil; break; } } @@ -805,6 +806,9 @@ recvrahost(uchar buf[], int pktlen) if(!seen) warning("igoring bogus prefix from %I on %s; pfx %I %M", ra->src, conf.dev, conf.v6pref, conf.mask); + + /* keep it arround so we wont comlain again */ + r->prefixlt = r->routerlt = ~0UL; continue; } @@ -821,6 +825,9 @@ recvrahost(uchar buf[], int pktlen) if(validip(conf.gaddr)) adddefroute(conf.gaddr, conf.lladdr, conf.laddr, conf.mask); + if(noconfig) + continue; + if(beprimary) putndb(); refresh(); @@ -892,7 +899,7 @@ recvra6(void) exits(nil); } - if(recvra6on(ifc) == IsHostNoRecv){ + if(recvra6on(ifc) == IsHostNoRecv || noconfig && sendrscnt < 0){ warning("recvra6: recvra off, quitting on %s", conf.dev); if(sendrscnt >= 0) rendezvous(recvra6, (void*)-1); diff --git a/sys/src/cmd/ip/ipconfig/main.c b/sys/src/cmd/ip/ipconfig/main.c index ed17f03ae..a35802048 100644 --- a/sys/src/cmd/ip/ipconfig/main.c +++ b/sys/src/cmd/ip/ipconfig/main.c @@ -404,7 +404,7 @@ main(int argc, char **argv) } if(myifc < 0) sysfatal("interface not found for: %s", conf.dev); - } else { + } else if(!noconfig) { /* open old interface */ binddevice(); } @@ -484,6 +484,11 @@ doremove(void) { if(!validip(conf.laddr)) sysfatal("remove requires an address"); + + DEBUG("removing address %I %M on %s", conf.laddr, conf.mask, conf.dev); + if(conf.cfd < 0) + return; + if(fprint(conf.cfd, "remove %I %M", conf.laddr, conf.mask) < 0) warning("can't remove %I %M: %r", conf.laddr, conf.mask); } @@ -491,6 +496,9 @@ doremove(void) static void dounbind(void) { + if(conf.cfd < 0) + return; + if(fprint(conf.cfd, "unbind") < 0) warning("can't unbind %s: %r", conf.dev); } @@ -589,11 +597,12 @@ ipunconfig(void) if(!validip(conf.laddr)) return; - DEBUG("couldn't renew IP lease, releasing %I", conf.laddr); - if(!validip(conf.mask)) ipmove(conf.mask, defmask(conf.laddr)); + if(validip(conf.gaddr)) + removedefroute(conf.gaddr, conf.laddr, conf.laddr, conf.mask); + doremove(); ipmove(conf.laddr, IPnoaddr); @@ -713,6 +722,9 @@ routectl(char *cmd, uchar *dst, uchar *mask, uchar *gate, uchar *ia, uchar *src, ctl = "%s %I %M %I %I %I %M"; else ctl = "%s %I %M %I %I"; + DEBUG(ctl, cmd, dst, mask, gate, ia, src, smask); + if(conf.rfd < 0) + return; fprint(conf.rfd, ctl, cmd, dst, mask, gate, ia, src, smask); }