netlink-notifier: Exit loop if nl_sock_recv() returns an error
authorDaniele Di Proietto <ddiproietto@vmware.com>
Tue, 22 Jul 2014 06:38:57 +0000 (06:38 +0000)
committerAlex Wang <alexw@nicira.com>
Tue, 22 Jul 2014 23:33:42 +0000 (16:33 -0700)
An error from nl_sock_recv() could mean that there are some issues with the
netlink socket (EBADF, ENOTSOCK, ...). Calling nl_sock_recv() in this case is
harmful: nln_run() will never return and since we are calling it from the main
thread, vswitchd becomes unresponsive.
Also, with this commit we avoid calling the notifier callback in case of error
(except for ENOBUFS, which means that there could be too many notifications)

Suggested-by: Alex Wang <alexw@nicira.com>
Signed-off-by: Daniele Di Proietto <ddiproietto@vmware.com>
Acked-by: Ben Pfaff <blp@nicira.com>
Acked-by: Alex Wang <alexw@nicira.com>
lib/netlink-notifier.c

index 9aa185d..0be8518 100644 (file)
@@ -182,12 +182,15 @@ nln_run(struct nln *nln)
             return;
         } else {
             if (error == ENOBUFS) {
+                /* The socket buffer might be full, there could be too many
+                 * notifications, so it makes sense to call nln_report() */
+                nln_report(nln, NULL);
                 VLOG_WARN_RL(&rl, "netlink receive buffer overflowed");
             } else {
                 VLOG_WARN_RL(&rl, "error reading netlink socket: %s",
                              ovs_strerror(error));
             }
-            nln_report(nln, NULL);
+            return;
         }
     }
 }