libnl: Add nl_socket_set_nonblocking() function

Change-Id: I80fad954f588baf1af216ca6fe659d295233bbe5
Signed-off-by: Dmitry Shmidt <dimitrysh@google.com>
diff --git a/libnl_2/socket.c b/libnl_2/socket.c
index e94eb9e..f51cf56 100644
--- a/libnl_2/socket.c
+++ b/libnl_2/socket.c
@@ -18,6 +18,7 @@
 
 #include <errno.h>
 #include <unistd.h>
+#include <fcntl.h>
 #include <malloc.h>
 #include <sys/time.h>
 #include <sys/socket.h>
@@ -139,3 +140,14 @@
 {
 	return nl_cb_get(sk->s_cb);
 }
+
+int nl_socket_set_nonblocking(struct nl_sock *sk)
+{
+	if (sk->s_fd == -1)
+		return -NLE_BAD_SOCK;
+
+	if (fcntl(sk->s_fd, F_SETFL, O_NONBLOCK) < 0)
+		return -errno;
+
+	return 0;
+}