aboutsummaryrefslogtreecommitdiff
path: root/lib/netlink.c
AgeCommit message (Collapse)Author
2013-10-04ofproto-dpif-xlate: Suppress oversize datapath actions.Ben Pfaff
If we allow oversize datapath actions to make it out of translation, then we will assert-fail later when we try to put those actions into a Netlink attribute. Bug #19277. Reported-by: Paul ingram <paul@nicira.com> Signed-off-by: Ben Pfaff <blp@nicira.com> Acked-by: Justin Pettit <jpettit@nicira.com>
2013-07-23clang: Fix the alignment warning.Alex Wang
This commit fixes the warning issued by 'clang' when pointer is casted to one with greater alignment. Signed-off-by: Alex Wang <alexw@nicira.com> Signed-off-by: Ben Pfaff <blp@nicira.com>
2013-07-18netlink: Avoid designated initializers because MSVC does not support them.Ben Pfaff
CC: Linda Sun <lsun@vmware.com> Signed-off-by: Ben Pfaff <blp@nicira.com>
2013-06-20Create specific types for ofp and odp portAlex Wang
Until now, datapath ports and openflow ports were both represented by unsigned integers of various sizes. With implicit conversions, etc., it is easy to mix them up and use one where the other is expected. This commit creates two typedefs, ofp_port_t and odp_port_t. Both of these two types are marked by "__attribute__((bitwise))" so that sparse can be used to detect any misuse. Signed-off-by: Alex Wang <alexw@nicira.com> Signed-off-by: Ben Pfaff <blp@nicira.com>
2013-01-16Replace most uses of assert by ovs_assert.Ben Pfaff
This is a straight search-and-replace, except that I also removed #include <assert.h> from each file where there were no assert calls left. Signed-off-by: Ben Pfaff <blp@nicira.com> Acked-by: Ethan Jackson <ethan@nicira.com>
2012-05-02Global replace of Nicira Networks.Raju Subramanian
Replaced all instances of Nicira Networks(, Inc) to Nicira, Inc. Feature #10593 Signed-off-by: Raju Subramanian <rsubramanian@nicira.com> Signed-off-by: Ben Pfaff <blp@nicira.com>
2012-04-18netlink: Postpone choosing sequence numbers until send time.Ben Pfaff
Choosing sequence numbers at time of creating a packet means that nl_sock_transact_multiple() has to search for the sequence number of a reply, because the sequence numbers of the requests aren't necessarily sequential. This commit makes it possible to avoid the search, by deferring choice of sequence numbers until the time that we send the packets. It doesn't actually modify nl_sock_transact_multiple(), which will happen in a later commit. Previously, I was concerned about a theoretical race condition described in a comment in the old versino of this code: This implementation uses sequence numbers that are unique process-wide, to avoid a hypothetical race: send request, close socket, open new socket that reuses the old socket's PID value, send request on new socket, receive reply from kernel to old socket but with same PID and sequence number. (This race could be avoided other ways, e.g. by preventing PIDs from being quickly reused). However, I no longer believe that this can be a real problem, because Netlink operates synchronously. The reply to a request will always arrive before the socket can be closed and a new socket opened with the old socket's PID. Signed-off-by: Ben Pfaff <blp@nicira.com>
2011-11-11netlink: Refactor and simplify nl_policy_parse().Ben Pfaff
2011-11-11netlink: Use NL_ATTR_FOR_EACH in nl_policy_parse().Ben Pfaff
I don't see a reason not to use it and it simplifies the code a lot.
2011-10-14netlink: New functions for putting attributes at the beginning of a buffer.Ben Pfaff
These are really just copies of the corresponding "put" functions. An upcoming commit will introduce a user of nl_msg_push_u32(). I thought I might as well create all of these while I was at it.
2011-09-23netlink: Expose version of nl_attr_find for key and len.Jesse Gross
Many of our functions pass around a pointer to Netlink attributes and a length. This exposes the version of nl_attr_find that takes that format so it can be used by callers outside the Netlink library.
2011-02-05netlink: Use proper types and functions for half-aligned 64-bit values.Ben Pfaff
These haven't showed up as problems yet in my tests but it is only a matter of time.
2011-01-27netlink: Log duplicate attributes in nl_policy_parse().Ben Pfaff
This made finding one particular bug slightly easier for me. Reviewed by Justin Pettit.
2011-01-27netlink: New functions for finding a specific attribute.Ben Pfaff
These functions are useful in the occasional case where a piece of code only cares about one or a few attributes, probably knows that the format is correct, and doesn't want to go to the trouble of doing a full parse. Upcoming commits will add a user. Reviewed by Justin Pettit.
2010-12-10netlink: New function nl_attr_type().Ben Pfaff
Linux since v2.6.24 has a couple of couple of bits at the top of nla_type that one is apparently supposed to ignore. This commit starts doing that in Open vSwitch userspace. Acked-by: Jesse Gross <jesse@nicira.com>
2010-12-10netlink: Add functions for working with big-endian attribute values.Ben Pfaff
These _be<N> functions are completely equivalent to the corresponding _u<N> functions, but the names help to make their purpose clear. Acked-by: Jesse Gross <jesse@nicira.com>
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>
2010-12-07ofpbuf: New function ofpbuf_use_const().Ben Pfaff
This is a code cleanup. Suggested-by: Justin Pettit <jpettit@nicira.com> Acked-by: Jesse Gross <jesse@nicira.com>
2010-11-30Implement stress option framework.Ben Pfaff
Stress options allow developers testing Open vSwitch to trigger behavior that otherwise would occur only in corner cases. Developers and testers can thereby more easily discover bugs that would otherwise manifest only rarely or nondeterministically. Stress options may cause surprising behavior even when they do not actually reveal bugs, so they should only be enabled as part of testing Open vSwitch. This commit implements the framework and adds a few example stress options. This commit started from code written by Andrew Lambeth. Suggested-by: Henrik Amren <henrik@nicira.com> CC: Andrew Lambeth <wal@nicira.com>
2010-11-30coverage: Make the coverage counters catalog program-specific.Ben Pfaff
Until now, the collection of coverage counters supported by a given OVS program was not specific to that program. That means that, for example, even though ovs-dpctl does not have anything to do with mac_learning, it still has a coverage counter for it. This is confusing, at best. This commit fixes the problem on some systems, in particular on ones that use GCC and the GNU linker. It uses the feature of the GNU linker described in its manual as: If an orphaned section's name is representable as a C identifier then the linker will automatically see PROVIDE two symbols: __start_SECNAME and __end_SECNAME, where SECNAME is the name of the section. These indicate the start address and end address of the orphaned section respectively. Systems that don't support these features retain the earlier behavior. This commit also fixes the annoyance that files that include coverage counters must be listed on COVERAGE_FILES in lib/automake.mk. This commit also fixes the annoyance that modifying any source file that includes a coverage counter caused all programs that link against libopenvswitch.a to relink, even programs that the source file was not linked into. For example, modifying ofproto/ofproto.c (which includes coverage counters) caused tests/test-aes128 to relink, even though test-aes128 does not link again ofproto.o.
2010-10-29vlog: Make client supply semicolon for VLOG_DEFINE_THIS_MODULE.Ben Pfaff
It's kind of odd for VLOG_DEFINE_THIS_MODULE to supply its own semicolon, so this commit switches to the more common form.
2010-09-20Avoid shadowing local variable names.Ben Pfaff
All of these changes avoid using the same name for two local variables within a same function. None of them are actual bugs as far as I can tell, but any of them could be confusing to the casual reader. The one in lib/ovsdb-idl.c is particularly brilliant: inner and outer loops both using (different) variables named 'i'. Found with GCC -Wshadow.
2010-08-30treewide: Remove trailing whitespaceJoe Perches
Signed-off-by: Joe Perches <joe@perches.com> Acked-by: Simon Horman <horms@verge.net.au> Signed-off-by: Jesse Gross <jesse@nicira.com>
2010-07-21vlog: Introduce VLOG_DEFINE_THIS_MODULE for declaring vlog module in use.Ben Pfaff
Adding a macro to define the vlog module in use adds a level of indirection, which makes it easier to change how the vlog module must be defined. A followup commit needs to do that, so getting these widespread changes out of the way first should make that commit easier to review.
2010-06-17netlink: Improve support for nested Netlink attributes.Ben Pfaff
Fairly often it happens that nested Netlink attributes must themselves contain Netlink attributes. In such a case, nlmsg_put_nested() is not so convenient, because it requires the contents to be pre-assembled and then copied into place. This commit introduces a new interface that instead allows the nested attributes to be assembled in-place. As a demonstration, it updates nl_msg_put_nested() to use this new interface.
2010-06-17netlink: Add support for Netlink table dumping.Ben Pfaff
2010-06-17netlink: Add functions for handling nested attributes.Ben Pfaff
2010-06-17netlink: Make nl_sock_transact() always return a reply on success.Ben Pfaff
Until now, if nl_sock_transact() received a reply that merely acknowledged success, without providing any other payload, it would return success but not provide the reply to its caller. This is inconsistent and could easily cause a segfault in a caller that expects to see the reply on success, if kernel behavior changed, for whatever reason, so that a request that previously returned data now just returns an acknowledgment. In practice this kind of change should never happen, but it is still better to handle it properly.
2010-06-17netlink: Fix bad assumption about nested Netlink attributes.Ben Pfaff
I had assumed that nested Netlink attributes contained an entire Netlink message, including header. This is wrong: they contain only a series of attributes. Nothing in the tree actually used nested attributes until now, so this doesn't fix any existing bugs.
2010-06-17netlink: Make nl_sock_transact() discard reply if 'replyp' is null.Ben Pfaff
Sometimes only the success or failure return value is interesting, not the details of the reply, so this simplifies some callers.
2010-06-17netlink: Drop sock parameter from nl_msg_put_(ge)nlmsghdr().Ben Pfaff
These two functions use their "sock" parameter only to figure out the nlmsg_pid to put in the nlmsghdr. But that field can be filled in just as well right before sending the message. Since our functions for sending Netlink messages always modify the nlmsghdr anyhow (to fill in the length), there is little benefit to filling in the nlmsg_pid in advance. The cost, on the other hand, is having to pass another argument to functions that already have too many. So this commit removes the argument.
2010-06-08timeval: Use monotonic time where appropriate.Jesse Gross
Most of the timekeeping needs of OVS are simply to measure intervals, which means that it is sensitive to changes in the clock. This commit replaces the existing clocks with monotonic timers. An additional set of wall clock timers are added and used in locations that need absolute time. Bug #1858
2009-06-15Update primary code license to Apache 2.0.Ben Pfaff
2009-07-08Import from old repository commit 61ef2b42a9c4ba8e1600f15bb0236765edc2ad45.v0.90.0Ben Pfaff