diff options
author | cinap_lenrek <cinap_lenrek@felloff.net> | 2019-09-06 18:48:35 +0200 |
---|---|---|
committer | cinap_lenrek <cinap_lenrek@felloff.net> | 2019-09-06 18:48:35 +0200 |
commit | 98e2ea45fb498274b4ea2af48db5c500d7614f7b (patch) | |
tree | cce723694bc22499058ee47578f5e8ee6a1ceb07 | |
parent | 8cbe3772c45431b962971e45581d831772a85947 (diff) | |
download | plan9front-98e2ea45fb498274b4ea2af48db5c500d7614f7b.tar.xz |
ip/ipconfig: don't leave behind null address when dhcp gets interrupted
cleanup the null address (::) when the command gets interrupted.
-rw-r--r-- | sys/src/cmd/ip/ipconfig/dhcp.c | 19 | ||||
-rw-r--r-- | sys/src/cmd/ip/ipconfig/main.c | 2 |
2 files changed, 17 insertions, 4 deletions
diff --git a/sys/src/cmd/ip/ipconfig/dhcp.c b/sys/src/cmd/ip/ipconfig/dhcp.c index 2b28a7f87..05c363dcb 100644 --- a/sys/src/cmd/ip/ipconfig/dhcp.c +++ b/sys/src/cmd/ip/ipconfig/dhcp.c @@ -155,11 +155,25 @@ dhcpinit(void) memcpy(requested, defrequested, nrequested); } +static void +removenulladdr(void) +{ + fprint(conf.cfd, "remove %I %M", IPnoaddr, IPnoaddr); + atexitdont(removenulladdr); +} + +static void +addnulladdr(void) +{ + atexit(removenulladdr); + fprint(conf.cfd, "add %I %M", IPnoaddr, IPnoaddr); +} + void dhcpquery(int needconfig, int startstate) { if(needconfig) - fprint(conf.cfd, "add %I %M", IPnoaddr, IPnoaddr); + addnulladdr(); conf.fd = openlisten(); if(conf.fd < 0){ @@ -192,8 +206,7 @@ dhcpquery(int needconfig, int startstate) close(conf.fd); if(needconfig) - fprint(conf.cfd, "remove %I %M", IPnoaddr, IPnoaddr); - + removenulladdr(); } enum { diff --git a/sys/src/cmd/ip/ipconfig/main.c b/sys/src/cmd/ip/ipconfig/main.c index 20113725c..52cf46fd9 100644 --- a/sys/src/cmd/ip/ipconfig/main.c +++ b/sys/src/cmd/ip/ipconfig/main.c @@ -806,7 +806,7 @@ catch(void*, char *msg) { if(strstr(msg, "alarm")) noted(NCONT); - noted(NDFLT); + exits(msg); } /* return pseudo-random integer in range low...(hi-1) */ |