X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=lib%2Fnetlink.c;h=ba32ca3a0da6792bb844dffd2274124de30bb3df;hb=7da5c9390e3b6c3ad5e0443e171e570fc16ff978;hp=66c27b1fb894f816441461e8e5fadc592baae6a3;hpb=2a022368f4b37559de5d5621a88c648023493f75;p=openvswitch diff --git a/lib/netlink.c b/lib/netlink.c index 66c27b1f..ba32ca3a 100644 --- a/lib/netlink.c +++ b/lib/netlink.c @@ -29,11 +29,18 @@ #include "netlink-protocol.h" #include "ofpbuf.h" #include "poll-loop.h" +#include "stress.h" #include "timeval.h" #include "util.h" #include "vlog.h" -VLOG_DEFINE_THIS_MODULE(netlink) +VLOG_DEFINE_THIS_MODULE(netlink); + +COVERAGE_DEFINE(netlink_overflow); +COVERAGE_DEFINE(netlink_received); +COVERAGE_DEFINE(netlink_recv_retry); +COVERAGE_DEFINE(netlink_send); +COVERAGE_DEFINE(netlink_sent); /* Linux header file confusion causes this to be undefined. */ #ifndef SOL_NETLINK @@ -253,6 +260,15 @@ nl_sock_sendv(struct nl_sock *sock, const struct iovec iov[], size_t n_iov, return error; } +/* This stress option is useful for testing that OVS properly tolerates + * -ENOBUFS on NetLink sockets. Such errors are unavoidable because they can + * occur if the kernel cannot temporarily allocate enough GFP_ATOMIC memory to + * reply to a request. They can also occur if messages arrive on a multicast + * channel faster than OVS can process them. */ +STRESS_OPTION( + netlink_overflow, "simulate netlink socket receive buffer overflow", + 5, 1, -1, 100); + /* Tries to receive a netlink message from the kernel on 'sock'. If * successful, stores the received message into '*bufp' and returns 0. The * caller is responsible for destroying the message with ofpbuf_delete(). On @@ -334,9 +350,16 @@ try_again: ofpbuf_delete(buf); return EPROTO; } + + if (STRESS(netlink_overflow)) { + ofpbuf_delete(buf); + return ENOBUFS; + } + *bufp = buf; log_nlmsg(__func__, 0, buf->data, buf->size); COVERAGE_INC(netlink_received); + return 0; }