diff options
| author | Roy Marples <roy@marples.name> | 2008-07-09 10:20:36 +0000 |
|---|---|---|
| committer | Roy Marples <roy@marples.name> | 2008-07-09 10:20:36 +0000 |
| commit | fb91c8af2a3311923cb1a38c85f04e1e7782ed0a (patch) | |
| tree | ab3b0c6035d994cdb9720cdfda95d40686a4806f /configure.c | |
| parent | 52a9906822ea14727c8f4dad4448bf41326cb136 (diff) | |
| download | dhcpcd-fb91c8af2a3311923cb1a38c85f04e1e7782ed0a.tar.xz | |
And turn this into a function so save a few bytes.
Diffstat (limited to 'configure.c')
| -rw-r--r-- | configure.c | 36 |
1 files changed, 18 insertions, 18 deletions
diff --git a/configure.c b/configure.c index 01f14d84..349002ce 100644 --- a/configure.c +++ b/configure.c @@ -404,6 +404,21 @@ configure_routes(struct interface *iface, const struct dhcp_message *dhcp, return retval; } +static int +delete_address(struct interface *iface) +{ + int retval; + logger(LOG_DEBUG, "deleting IP address %s/%d", + inet_ntoa(iface->addr), + inet_ntocidr(iface->net)); + retval = del_address(iface->name, &iface->addr, &iface->net); + if (retval == -1 && errno != ENOENT) + logger(LOG_ERR, "del_address: %s", strerror(errno)); + iface->addr.s_addr = 0; + iface->net.s_addr = 0; + return retval; +} + int configure(struct interface *iface, const char *reason, const struct dhcp_message *dhcp, const struct dhcp_message *old, @@ -435,16 +450,7 @@ configure(struct interface *iface, const char *reason, /* Only reset things if we had set them before */ if (iface->addr.s_addr != 0) { delete_routes(iface, options->metric); - logger(LOG_DEBUG, "deleting IP address %s/%d", - inet_ntoa(iface->addr), - inet_ntocidr(iface->net)); - if (del_address(iface->name, &iface->addr, - &iface->net) == -1 && - errno != ENOENT) - logger(LOG_ERR, "del_address: %s", - strerror(errno)); - iface->addr.s_addr = 0; - iface->net.s_addr = 0; + delete_address(iface); } exec_script(options, iface->name, reason, NULL, old); @@ -466,14 +472,8 @@ configure(struct interface *iface, const char *reason, /* Now delete the old address if different */ if (iface->addr.s_addr != addr.s_addr && - iface->addr.s_addr != 0) { - logger(LOG_DEBUG, "deleting IP address %s/%d", - inet_ntoa(iface->addr), - inet_ntocidr(iface->net)); - if (del_address(iface->name, &iface->addr, &iface->net) == -1 - && errno != ENOENT) - logger(LOG_ERR, "del_address: %s", strerror(errno)); - } + iface->addr.s_addr != 0) + delete_address(iface); #ifdef __linux__ /* On linux, we need to change the subnet route to have our metric. */ |
