netdev-linux: Only call set_nonblocking() if socket creation succeeds.
authorBen Pfaff <blp@nicira.com>
Fri, 29 Apr 2011 22:53:36 +0000 (15:53 -0700)
committerBen Pfaff <blp@nicira.com>
Fri, 13 May 2011 21:45:53 +0000 (14:45 -0700)
Reviewed-by: Simon Horman <horms@verge.net.au>
lib/netdev-linux.c

index 384fdafee96818cb74e703ca7c5495fa705cb8f7..1c5ddc53bf311baa321c03f08d05e659b9568e41 100644 (file)
@@ -451,11 +451,12 @@ netdev_linux_init(void)
             /* Create AF_PACKET socket. */
             af_packet_sock = socket(AF_PACKET, SOCK_RAW, 0);
             status = af_packet_sock >= 0 ? 0 : errno;
-            if (status) {
+            if (!status) {
+                set_nonblocking(af_packet_sock);
+            } else {
                 VLOG_ERR("failed to create packet socket: %s",
                          strerror(status));
             }
-            set_nonblocking(af_packet_sock);
         }
 
         /* Create rtnetlink socket. */