From 222f04515fe158935e61c3db9e974ce5b8615944 Mon Sep 17 00:00:00 2001 From: Daniele Di Proietto Date: Tue, 22 Jul 2014 06:38:57 +0000 Subject: netlink-notifier: Exit loop if nl_sock_recv() returns an error 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 Signed-off-by: Daniele Di Proietto Acked-by: Ben Pfaff Acked-by: Alex Wang --- lib/netlink-notifier.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'lib/netlink-notifier.c') diff --git a/lib/netlink-notifier.c b/lib/netlink-notifier.c index 9aa185d5b..0be851838 100644 --- a/lib/netlink-notifier.c +++ b/lib/netlink-notifier.c @@ -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; } } } -- cgit v1.2.1