return "Unknown";
}
+static int fd_set_nonblocking(int sockfd)
+{
+ int flags = fcntl(sockfd, F_GETFL, 0);
+ if (flags == -1) {
+ syslog(LOG_ERR,
+ "Failed to get the dhcpv6 socket flags: fcntl F_GETFL failed (%s)",
+ strerror(errno));
+ return -1;
+ }
+
+ // Set the socket to non-blocking
+ if (fcntl(sockfd, F_SETFL, flags | O_NONBLOCK) == -1) {
+ syslog(LOG_ERR,
+ "Failed to set the dhcpv6 socket to non-blocking: fcntl F_SETFL failed (%s)",
+ strerror(errno));
+ return -1;
+ }
+
+ return 0;
+}
+
int init_dhcpv6(const char *ifname, unsigned int options, int sk_prio, int sol_timeout, unsigned int dscp)
{
client_options = options;
ifindex = ifr.ifr_ifindex;
+ // Set the socket to non-blocking mode
+ if (fd_set_nonblocking(sock) < 0)
+ goto failure;
+
// Create client DUID
size_t client_id_len;
odhcp6c_get_state(STATE_CLIENT_ID, &client_id_len);