ip/ipconfig: don't leave behind null address when dhcp gets interrupted
cleanup the null address (::) when the command gets interrupted.
This commit is contained in:
parent
8cbe3772c4
commit
98e2ea45fb
2 changed files with 17 additions and 4 deletions
|
@ -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 {
|
||||
|
|
|
@ -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) */
|
||||
|
|
Loading…
Reference in a new issue