X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=lib%2Fnetlink.c;h=ba32ca3a0da6792bb844dffd2274124de30bb3df;hb=7da5c9390e3b6c3ad5e0443e171e570fc16ff978;hp=0d072d0898af5a43483034e6a9a6f8176d9ddaca;hpb=d98e60075528c3065ad453f7add4b30f22edcde3;p=openvswitch diff --git a/lib/netlink.c b/lib/netlink.c index 0d072d08..ba32ca3a 100644 --- a/lib/netlink.c +++ b/lib/netlink.c @@ -29,12 +29,19 @@ #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); +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 #define SOL_NETLINK 270 @@ -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; }