aboutsummaryrefslogtreecommitdiff
path: root/lib/netlink-socket.c
AgeCommit message (Collapse)Author
2012-03-15netlink-socket: Increase Netlink socket receive buffer size.Ben Pfaff
Open vSwitch userspace can set up flows at a high rate, but it is somewhat "bursty" in opportunities to set up flows, by which I mean that OVS sets up a batch of flows, then goes off and does some other work for a while, then sets up another batch of flows, and so on. The result is that, if a large number of packets that need flow setups come in all at once, then some of them can overflow the relatively small kernel-to-user buffers. This commit increases the kernel-to-user buffers from the default of approximately 120 kB each to 1 MB each. In one somewhat synthetic test case that I ran based on an "hping3" that generated a load of about 20,000 new flows per second (including both requests and replies), this reduced the packets dropped at the kernel-to-user interface from about 30% to none. I expect that it will similarly improve packet loss in workloads where flow arrival is not easily predictable. (This has little effect on workloads generated by "ovs-benchmark rate" because that benchmark is effectively "self-clocking", that is, a new flow is triggered only by a reply to a request made earlier, which means that the number of buffered packets at any given has a known, constant upper limit.) Bug #10210. Signed-off-by: Ben Pfaff <blp@nicira.com>
2011-11-28netlink-socket: Let the kernel choose Netlink pids for us.Ben Pfaff
The Netlink code in the Linux kernel has been willing to choose unique Netlink pids for userspace sockets since at least 2.4.36 and probably earlier. There's no value in choosing them ourselves. This simplifies the code and eliminates the possibility of exhausting our supply of Netlink PIDs.
2011-11-28dpif-linux: Use poll() internally in dpif_linux_recv().Ben Pfaff
Using poll() internally in dpif_linux_recv(), instead of relying on the results of the main loop poll() call, brings netperf CRR performance back within 1% of par versus the code base before the poll_fd_woke() optimizations were introduced. It also increases the ovs-benchmark results by about 5% versus that baseline, too. My theory is that this is because the main loop takes long enough that a significant number of packets can arrive during the main loop itself, so this reduces the time before OVS gets to those packets.
2011-11-28Revert "poll-loop: Enable checking whether a FD caused a wakeup."Ben Pfaff
This reverts commit 1e276d1a10539a8cd97d2ad63c073a9a43f0f1ef. The poll_fd_woke() and nl_sock_woke() function added in that commit are no longer used, so there is no reason to keep them in the tree.
2011-10-14netlink-socket: New function nl_sock_transact_multiple().Ben Pfaff
This will be used in an upcoming commit.
2011-10-11netlink: New macros NL_NESTED_FOR_EACH, NL_NESTED_FOR_EACH_UNSAFE.Ben Pfaff
Upcoming commits will introduce more users.
2011-09-23poll-loop: Enable checking whether a FD caused a wakeup.Jesse Gross
Each time we run through the poll loop, we check all file descriptors that we were waiting on to see if there is data available. However, this requires a system call and poll already provides information on which FDs caused the wakeup so it is inefficient as the number of active FDs grows. This provides a way to check whether a given FD has data.
2011-09-23netlink: Expose method to get Netlink pid of a socket.Jesse Gross
In the future, the kernel will use unicast messages instead of multicast to send upcalls. As a result, we need to be able to tell it where to direct the traffic. This adds a function to expose the Netlink pid of a socket so it can be included in messages to the kernel.
2011-09-22netlink-socket: Async notifications are incompatible with other operations.Ben Pfaff
A Netlink socket that receives asynchronous notifications (e.g. from a multicast group) cannot be used for transactions or dumps, because those operations would discard asynchronous messages that arrive while waiting for replies. This commit documents this issue in a comment on nl_sock_join_mcgroup(). It also removes an internal attempt to avoid mixing multicast reception with other operations. The attempt was incomplete, because it only handled dumps even though ordinary transactions are also problematic. It seems better to remove it than to fix it because, first, all of the existing users in OVS already separate multicast reception from other operations and, second, an upcoming commit will start using unicast Netlink for asynchronous notifications, which has the same issues but doesn't use nl_sock_join_mcgroup().
2011-09-21netlink-socket: Fix typo in comment.Ben Pfaff
2011-09-16dpif-linux: Handle nl_lookup_genl_mcgroup() failures.Ethan Jackson
The nl_lookup_genl_mcgroup() function can fail on older kernels which do not support the required netlink interface. Before this patch, dpif-linux would refuse to create a datapath when this happened. With this patch, it attempts to use a workaround. If the workaround fails it simply disables the affected features without completely disabling the dpif.
2011-09-09netlink-socket: Avoid use-after-free in nl_lookup_genl_mcgroup().Ben Pfaff
Commit e408762f "netlink-socket: New function nl_lookup_genl_mcgroup()" modified do_lookup_genl_family() to return the Netlink attributes to the caller, but it still freed the Netlink message itself, which meant that the attributes pointed into freed memory. This commit fixes the problem. This commit is not a minimal fix. It refactors do_lookup_genl_family(), changing the return value from "negative errno value or positive genl family id" to the more common "zero or positive errno value". Found by valgrind.
2011-09-01netlink-socket: New function nl_lookup_genl_mcgroup().Ethan Jackson
2011-07-27netlink-socket: Reduce nl_sock_recv() from 2 (or more) system calls to 1.Ben Pfaff
Until now, each attempt to receive a message from a Netlink socket has taken at least two system calls, one to check the size of the message to be received and a second one to delete the message from the socket buffer. This commit switches to a new strategy that requires only one system call per message received. In my testing this increases the maximum flow setups per second by a little over 10%.
2011-07-27netlink-socket: Remove unused nl_sock_sendv() function.Ben Pfaff
This function hasn't been used for ages.
2011-01-27netlink-socket: Log Generic Netlink family names.Ben Pfaff
The ids for Generic Netlink family names aren't very helpful because they can vary from machine to machine and even from one boot to the next. So this change logs their names too. This only affects logging at DBG level. Reviewed by Ethan Jackson <ethan@nicira.com>.
2011-01-27netlink-socket: Consistently log sequence numbers in hexadecimal.Ben Pfaff
nlmsghdr_to_string() wrote sequence numbers in hex, but nl_sock_transact() wrote them in decimal. This consistently switches to hexadecimal. Reviewed by Ethan Jackson <ethan@nicira.com>.
2011-01-27netlink-socket: Make dumping and doing transactions on same nl_sock safe.Ben Pfaff
It's not safe to use a single Netlink fd to do multiple operations in an synchronous way. Some of the limitations are fundamental; for example, the kernel only supports a single "dump" operation at a time. Others are limitations imposed by the OVS coding style; for example, our Netlink library is not callback based, so nothing can be done about incoming messages that can't be handled immediately. Regardless, in OVS multicast groups, transactions, and dumps cannot coexist on a single nl_sock. This is only mildly irritating at the moment, but it will become much worse later on, when dpif-linux shifts to using Netlink dumps for listing various kinds of datapath entities. When that happens, a dump will be in progress in situations where the dpif-linux client might want to do other operations. For example, it is reasonable for the client to list flows and, in the middle, look up information on vports mentioned in those flows. It might be possible to simply ban and avoid such nested operations--I have not even audited the source tree to find out whether we do anything like that already--but that seems like an unnecessary cramp on our coding style. Furthermore, it's difficult to explain and justify without understanding the implementation. This patch takes another approach, by improving the Netlink socket library to avoid artificial constraints. When an operation, or a dump, or joining a multicast group would cause a problem, this patch makes the library transparently create a separate Netlink socket. This solves the problem without putting any onerous restrictions on use. This commit also slightly simplifies netdev_vport_reset_names(). It had been written to destroy the dump object before the Netlink socket that it used, but this is no longer necessary and doing it in the opposite order saved a few lines of code. Reviewed by Ethan Jackson <ethan@nicira.com>.
2011-01-27netlink-socket: Slightly improve logging of Generic Netlink messages.Ben Pfaff
This makes the stream of requests and replies very slightly easier to understand. Reviewed by Justin Pettit.
2011-01-27netlink-socket: New function for draining the receive buffer.Ben Pfaff
This will be used in an upcoming patch. Reviewed by Justin Pettit.
2011-01-27netlink-socket: Add functions for joining and leaving multicast groups.Ben Pfaff
When this library was originally implemented, support for Linux 2.4 was important. The Netlink implementation in Linux only added support for joining and leaving multicast groups after a socket is bound as of Linux 2.6.14, so the library did not support it either. But the current version of Open vSwitch targets Linux 2.6.18 and over, so it's fine to add this support now, and this commit does so. This will be used more extensively in upcoming commits. Reviewed by Justin Pettit.
2010-12-10netlink: Split into generic and Linux-specific parts.Ben Pfaff
The parts of the netlink module that are related to sockets are Linux-specific, since only Linux has AF_NETLINK sockets. The rest can be built anywhere. This commit breaks them into two modules, and builds the generic one on all platforms. Acked-by: Jesse Gross <jesse@nicira.com>