]> git.puffer.fish Git - matthieu/frr.git/commitdiff
pimd: Only make the pim sockets non blocking.
authorDonald Sharp <sharpd@cumulusnetworks.com>
Fri, 18 Nov 2016 19:11:31 +0000 (14:11 -0500)
committerDonald Sharp <sharpd@cumulusnetworks.com>
Thu, 22 Dec 2016 01:26:16 +0000 (20:26 -0500)
Only make the pim sockets non-blocking on reads.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
pimd/pim_sock.c

index 12f222bb80dd40935be23fe6a5c1745bd495335d..6ce336d605a222fc35c49054355ea3b629b466ff 100644 (file)
@@ -230,24 +230,25 @@ int pim_socket_mcast(int protocol, struct in_addr ifaddr, int ifindex, u_char lo
       zlog_warn("%s: Failure to set buffer size to %d",
                __PRETTY_FUNCTION__, rcvbuf);
 
-  {
-    long flags;
-
-    flags = fcntl(fd, F_GETFL, 0);
-    if (flags < 0) {
-      zlog_warn("Could not get fcntl(F_GETFL,O_NONBLOCK) on socket fd=%d: errno=%d: %s",
-               fd, errno, safe_strerror(errno));
-      close(fd);
-      return PIM_SOCK_ERR_NONBLOCK_GETFL;
-    }
+  if (protocol == IPPROTO_PIM)
+    {
+      long flags;
+
+      flags = fcntl(fd, F_GETFL, 0);
+      if (flags < 0) {
+       zlog_warn("Could not get fcntl(F_GETFL,O_NONBLOCK) on socket fd=%d: errno=%d: %s",
+                 fd, errno, safe_strerror(errno));
+       close(fd);
+       return PIM_SOCK_ERR_NONBLOCK_GETFL;
+      }
 
-    if (fcntl(fd, F_SETFL, flags | O_NONBLOCK)) {
-      zlog_warn("Could not set fcntl(F_SETFL,O_NONBLOCK) on socket fd=%d: errno=%d: %s",
-               fd, errno, safe_strerror(errno));
-      close(fd);
-      return PIM_SOCK_ERR_NONBLOCK_SETFL;
+      if (fcntl(fd, F_SETFL, flags | O_NONBLOCK)) {
+       zlog_warn("Could not set fcntl(F_SETFL,O_NONBLOCK) on socket fd=%d: errno=%d: %s",
+                 fd, errno, safe_strerror(errno));
+       close(fd);
+       return PIM_SOCK_ERR_NONBLOCK_SETFL;
+      }
     }
-  }
 
   return fd;
 }