}
/* 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.
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);
(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
void start_reboot(struct interface *);
void start_expire(void *);
void send_decline(struct interface *);
-void open_sockets(struct interface *);
+int open_sockets(struct interface *);
void close_sockets(struct interface *);
void drop_dhcp(struct interface *, const char *);
void drop_interface(struct interface *, const char *);