]> git.ipfire.org Git - thirdparty/bird.git/commitdiff
Kernel socket missing err_hook fix
authorJan Moskyto Matejka <mq@ucw.cz>
Thu, 29 Sep 2016 10:00:53 +0000 (12:00 +0200)
committerJan Moskyto Matejka <mq@ucw.cz>
Thu, 29 Sep 2016 11:21:16 +0000 (13:21 +0200)
Thanks to Tim Weippert for bugreport.

sysdep/bsd/krt-sock.c
sysdep/linux/netlink.c
sysdep/unix/io.c

index 6ff3b2b7363cb4ed0d2126a7e258df891bdbb109..f2ae81c33162c2e67bd6969bb9092e033357eeeb 100644 (file)
@@ -911,6 +911,12 @@ krt_sock_hook(sock *sk, int size UNUSED)
   return 0;
 }
 
+static void
+krt_sock_err_hook(sock *sk, int e UNUSED)
+{
+  krt_sock_hook(sk, 0);
+}
+
 static sock *
 krt_sock_open(pool *pool, void *data, int table_id)
 {
@@ -932,6 +938,7 @@ krt_sock_open(pool *pool, void *data, int table_id)
   sk = sk_new(pool);
   sk->type = SK_MAGIC;
   sk->rx_hook = krt_sock_hook;
+  sk->err_hook = krt_sock_err_hook;
   sk->fd = fd;
   sk->data = data;
 
index 1490213e04efb9b9431c729bb4dd8273f00cc131..79dd1405081b91ae69c401f46fb8d8d9748913be 100644 (file)
@@ -1525,6 +1525,12 @@ nl_async_hook(sock *sk, int size UNUSED)
   return 1;
 }
 
+static void
+nl_async_err_hook(sock *sk, int e UNUSED)
+{
+  nl_async_hook(sk, 0);
+}
+
 static void
 nl_open_async(void)
 {
@@ -1563,6 +1569,7 @@ nl_open_async(void)
   sk = nl_async_sk = sk_new(krt_pool);
   sk->type = SK_MAGIC;
   sk->rx_hook = nl_async_hook;
+  sk->err_hook = nl_async_err_hook;
   sk->fd = fd;
   if (sk_open(sk) < 0)
     bug("Netlink: sk_open failed");
index 120eb906911e507408f219fe19d479d604eae6cc..3ceadd982f619757aec0aa4c0b7608299cc638e6 100644 (file)
@@ -1857,7 +1857,7 @@ void
 sk_err(sock *s, int revents)
 {
   int se = 0, sse = sizeof(se);
-  if (revents & POLLERR)
+  if ((s->type != SK_MAGIC) && (revents & POLLERR))
     if (getsockopt(s->fd, SOL_SOCKET, SO_ERROR, &se, &sse) < 0)
     {
       log(L_ERR "IO: Socket error: SO_ERROR: %m");