diff options
| author | Roy Marples <roy@marples.name> | 2012-08-06 10:24:13 +0000 |
|---|---|---|
| committer | Roy Marples <roy@marples.name> | 2012-08-06 10:24:13 +0000 |
| commit | 8ce63895729394762733847918c1c6161560fd3f (patch) | |
| tree | cf950a55e2103dcf13273e0c637a715e4d7fe285 /dhcpcd.c | |
| parent | 50083515dbdac45ce9e2b77ca117f7c1c9a1a7f3 (diff) | |
| download | dhcpcd-8ce63895729394762733847918c1c6161560fd3f.tar.xz | |
If we fail to open sockets, don't bother sending the request.
Diffstat (limited to 'dhcpcd.c')
| -rw-r--r-- | dhcpcd.c | 17 |
1 files changed, 13 insertions, 4 deletions
@@ -326,7 +326,11 @@ send_message(struct interface *iface, int type, } /* Ensure sockets are open. */ - open_sockets(iface); + if (open_sockets(iface) == -1) { + if (!(options & DHCPCD_TEST)) + drop_dhcp(iface, "FAIL"); + return; + } /* If we couldn't open a UDP port for our IP address * then we cannot renew. @@ -1710,11 +1714,13 @@ handle_args(struct fd_list *fd, int argc, char **argv) return 0; } -void +int open_sockets(struct interface *iface) { + int r = 0; + if (iface->raw_fd == -1) { - if (open_socket(iface, ETHERTYPE_IP) == -1) + if ((r = open_socket(iface, ETHERTYPE_IP)) == -1) syslog(LOG_ERR, "%s: open_socket: %m", iface->name); else add_event(iface->raw_fd, handle_dhcp_packet, iface); @@ -1725,9 +1731,12 @@ open_sockets(struct interface *iface) (iface->state->new->cookie == htonl(MAGIC_COOKIE) || iface->state->options->options & DHCPCD_INFORM)) { - if (open_udp_socket(iface) == -1 && errno != EADDRINUSE) + if (open_udp_socket(iface) == -1 && errno != EADDRINUSE) { syslog(LOG_ERR, "%s: open_udp_socket: %m", iface->name); + r = -1; + } } + return r; } void |
