From: root Date: Wed, 23 Apr 2008 22:20:58 +0000 (-0700) Subject: Tolerate ENOBUFS from kernel netlink code in second call to recvmsg. X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=cdd0a5ba367772ae2c1abddfcc15e8a323f9d493;p=openvswitch Tolerate ENOBUFS from kernel netlink code in second call to recvmsg. The Linux kernel returns ENOBUFS to userspace code to indicate that a netlink message that the kernel wanted to send could not be due to a lack of buffer space. We checked for this and dealt with it in one recvmsg call but not in another. This change tolerates it in both places. Should fix a problem encountered on the OF6k under "hping3 --flood". ** This fix was done by Ben. ** --- diff --git a/lib/netlink.c b/lib/netlink.c index 36754ee4..1bb4af48 100644 --- a/lib/netlink.c +++ b/lib/netlink.c @@ -296,11 +296,20 @@ try_again: iov.iov_len = 1; do { nbytes2 = recvmsg(sock->fd, &msg, MSG_DONTWAIT); - if (nbytes2 < 0) { - VLOG_ERR("failed to remove nlmsg from socket: %d\n", errno); - } } while (nbytes2 < 0 && errno == EINTR); - + if (nbytes2 < 0) { + if (errno == ENOBUFS) { + /* The kernel is notifying us that a message it tried to send to us + * was dropped. We have to pass this along to the caller in case + * it wants to retry a request. So kill the buffer, which we can + * re-read next time. */ + buffer_delete(buf); + return ENOBUFS; + } else { + VLOG_ERR("failed to remove nlmsg from socket: %s\n", + strerror(errno)); + } + } if (!NLMSG_OK(nlmsghdr, nbytes)) { VLOG_ERR("received invalid nlmsg (%zd bytes < %d)", bufsize, NLMSG_HDRLEN);