summaryrefslogtreecommitdiff
path: root/lib/util.h
Commit message (Collapse)AuthorAgeFilesLines
* dpif-netdev: Set timer slack for PMD threads.David Marchand2023-01-231-0/+1
| | | | | | | | | | | | | | | | | | | The default Linux timer slack groups timer expires into 50 uS intervals. With some traffic patterns this can mean that returning to process packets after a sleep takes too long and packets are dropped. Add a helper to util.c and set use it to reduce the timer slack for PMD threads, so that sleeps with smaller resolutions can be done to prevent sleeping for too long. Fixes: de3bbdc479a9 ("dpif-netdev: Add PMD load based sleeping.") Reported-at: https://mail.openvswitch.org/pipermail/ovs-dev/2023-January/401121.html Reported-by: Ilya Maximets <i.maximets@ovn.org> Signed-off-by: David Marchand <david.marchand@redhat.com> Co-authored-by: Kevin Traynor <ktraynor@redhat.com> Signed-off-by: Kevin Traynor <ktraynor@redhat.com> Signed-off-by: Ilya Maximets <i.maximets@ovn.org>
* util: Add non quiesce xnanosleep.Kevin Traynor2023-01-121-0/+1
| | | | | | | | | | | | | | | | xnanosleep forces the thread into quiesce state in anticipation that it will be sleeping for a considerable time and that the thread may need to quiesce before the sleep is finished. In some cases, a very short sleep may be requested and in that case the overhead of going to into quiesce state may be unnecessary. To allow for those cases add a xnanosleep_no_quiesce() variant. Suggested-by: Ilya Maximets <i.maximets@ovn.org> Reviewed-by: David Marchand <david.marchand@redhat.com> Signed-off-by: Kevin Traynor <ktraynor@redhat.com> Signed-off-by: Ilya Maximets <i.maximets@ovn.org>
* util: Update cache line size on PowerPC.Jeffrey Walton2022-07-011-0/+6
| | | | | | | | | PPC64 machines have a 128-byte L1 cache line size. See http://lists.llvm.org/pipermail/llvm-dev/2017-March/110982.html Submitted-at: https://github.com/openvswitch/ovs/pull/379 Signed-off-by: Jeffrey Walton <noloader@gmail.com> Signed-off-by: Ilya Maximets <i.maximets@ovn.org>
* util: Add token concatenation macro with argument expansion.Paolo Valerio2021-07-081-0/+7
| | | | | | | | | | | | | This macro is handy when it comes paste two tokens when one or both are macros. Rename CURSOR_JOIN() to OVS_JOIN() and move it to util.h so that it can be reused. Signed-off-by: Paolo Valerio <pvalerio@redhat.com> Acked-by: Gaetan Rivet <grive@u256.net> Acked-by: Aaron Conole <aconole@redhat.com> Signed-off-by: Ilya Maximets <i.maximets@ovn.org>
* util: Add allocation wrappers that don't increment coverage counters.Ben Pfaff2021-04-071-0/+9
| | | | | | | | | | | The thread-local data allocators can't increment coverage counters because this can cause reentrancy. Until now, this code has used explicit calls to malloc(). This code replaces them by calls to the new functions. This will make it easier in an upcoming patch to update all the code that can run out of memory. Signed-off-by: Ben Pfaff <blp@ovn.org> Acked-by: Ilya Maximets <i.maximets@ovn.org>
* odp-util: Fix clearing match mask if set action is partially unnecessary.Ilya Maximets2020-07-291-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | While committing set() actions, commit() could wildcard all the fields that are same in match key and in the set action. This leads to situation where mask after commit could actually contain less bits than it was before. And if set action was partially committed, all the fields that were the same will be cleared out from the matching key resulting in the incorrect (too wide) flow. For example, for the flow that matches on both src and dst mac addresses, if the dst mac is the same and only src should be changed by the set() action, destination address will be wildcarded in the match key and will never be matched, i.e. flows with any destination mac will match, which is not correct. Setting OF rule: in_port=1,dl_src=50:54:00:00:00:09 actions=mod_dl_dst(50:54:00:00:00:0a),output(2) Sending following packets on port 1: 1. eth(src=50:54:00:00:00:09,dst=50:54:00:00:00:0a),eth_type(0x0800) 2. eth(src=50:54:00:00:00:09,dst=50:54:00:00:00:0c),eth_type(0x0800) 3. eth(src=50:54:00:00:00:0b,dst=50:54:00:00:00:0c),eth_type(0x0800) Resulted datapath flows: eth(dst=50:54:00:00:00:0c),<...>, actions:set(eth(dst=50:54:00:00:00:0a)),2 eth(src=50:54:00:00:00:09,dst=50:54:00:00:00:0a),<...>, actions:2 The first flow doesn't have any match on source MAC address and the third packet successfully matched on it while it must be dropped. Fix that by updating the match mask with only the new bits set by commit(), but keeping those that were cleared (OR operation). With fix applied, resulted correct flows are: eth(src=50:54:00:00:00:09,dst=50:54:00:00:00:0a),<...>, actions:2 eth(src=50:54:00:00:00:09,dst=50:54:00:00:00:0c),<...>, actions:set(eth(dst=50:54:00:00:00:0a)),2 eth(src=50:54:00:00:00:0b),<...>, actions:drop The code before commit dbf4a92800d0 was not able to reduce the mask, it was only possible to expand it to exact match, so it was OK to update original matching mask with the new value in all cases. Fixes: dbf4a92800d0 ("odp-util: Do not rewrite fields with the same values as matched") Reported-at: https://bugzilla.redhat.com/show_bug.cgi?id=1854376 Acked-by: Eli Britstein <elibr@mellanox.com> Tested-by: Adrián Moreno <amorenoz@redhat.com> Signed-off-by: Ilya Maximets <i.maximets@ovn.org>
* netdev-afxdp: add new netdev type for AF_XDP.William Tu2019-07-191-0/+5
| | | | | | | | | | | | | | | | The patch introduces experimental AF_XDP support for OVS netdev. AF_XDP, the Address Family of the eXpress Data Path, is a new Linux socket type built upon the eBPF and XDP technology. It is aims to have comparable performance to DPDK but cooperate better with existing kernel's networking stack. An AF_XDP socket receives and sends packets from an eBPF/XDP program attached to the netdev, by-passing a couple of Linux kernel's subsystems As a result, AF_XDP socket shows much better performance than AF_PACKET For more details about AF_XDP, please see linux kernel's Documentation/networking/af_xdp.rst. Note that by default, this feature is not compiled in. Signed-off-by: William Tu <u9012063@gmail.com> Signed-off-by: Ilya Maximets <i.maximets@samsung.com>
* util: implement count_1bits with Neon intrinsics or gcc built-in for aarch64.Yanqin Wei2019-06-131-1/+6
| | | | | | | | | | | | | | | | | | Userspace datapath needs to traverse through miniflow values many times. In this process, 'count_1bits' operation for 'Flowmap' significantly impact performance. On arm, this function was defined by portable implementation because gcc for arm does not support popcnt feature. But in the aarch64, VCNT neon instruction can accelerate "count_1bits". From Gcc-7, the built-in function is implemented with neon intruction. In this patch, count_1bits function will be impelmented with gcc built-in from gcc-7 on, and with neon intrinsics in gcc-6. Performance test was run in two aarch64 machines. In the NIC2NIC test, one tuple dpcls lookup case achieves around 4% throughput improvement and 10(average) tuples case achieves around 5% improvement. Tested-by: Malvika Gupta <malvika.gupta@arm.com> Signed-off-by: Yanqin Wei <Yanqin.Wei@arm.com> Signed-off-by: Ben Pfaff <blp@ovn.org>
* vswitchd: Track status of memory locking.Ilya Maximets2019-05-241-0/+3
| | | | | | | | Needed for the future post-copy live migration support for vhost-user ports. Signed-off-by: Ilya Maximets <i.maximets@samsung.com> Reviewed-by: Maxime Coquelin <maxime.coquelin@redhat.com>
* ovs-vswitchd: Implement OFPT_TABLE_FEATURES table modification request.Ben Pfaff2019-01-151-0/+46
| | | | | | | | | This allows a controller to change the name of OpenFlow flow tables in the OVS software switch. CC: Brad Cowie <brad@cowie.nz> Acked-by: Justin Pettit <jpettit@ovn.org> Signed-off-by: Ben Pfaff <blp@ovn.org>
* tests: Use environment variable for default timeout.Ilya Maximets2018-08-151-0/+2
| | | | | | | | | | | Introduce new 'OVS_CTL_TIMEOUT' environment variable that, if set, will be used as a default timeout for OVS control utilities. Setting it in 'atlocal.in' will cover all the hangs inside the testsuite, even when utils called in a subshell. Signed-off-by: Ilya Maximets <i.maximets@samsung.com> Signed-off-by: Ben Pfaff <blp@ovn.org>
* util: Fix abs_file_name() bugs on Windows.Ben Pfaff2018-08-031-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | abs_file_name() believed that a file name that begins with / or contains : is absolute and that any other file name is relative. On Windows, this is wrong in at least the following ways: * / and \ are interchangeable on Windows. * A name that begins with \\ or // is also absolute. * A name that begins with X: but not X:\ is not absolute. * A name with : in some position other than the second position is not absolute (although it might not be valid either?). Furthermore, Windows has more than one current working directory (one per volume letter), so trying to make a file name absolute by just prefixing the current working directory for the current volume results in silliness. This patch attempts to fix the problem. This makes OVS link against shlwapi, which is needed to use PathIsRelative(). Found by inspection. Acked-by: Alin Gabriel Serdean <aserdean@ovn.org> Signed-off-by: Ben Pfaff <blp@ovn.org>
* util: Use lookup table to optimize hexit_value().Ben Pfaff2018-02-051-1/+1
| | | | | | | | | | | | Daniel Alvarez Sanchez reported a significant overall speedup in ovn-northd due to a similar patch. Reported-by: Daniel Alvarez Sanchez <dalvarez@redhat.com> Reported-at: https://mail.openvswitch.org/pipermail/ovs-discuss/2018-February/046120.html Signed-off-by: Ben Pfaff <blp@ovn.org> Acked-by: Daniel Alvarez <dalvarez@redhat.com> Reviewed-by: Yifeng Sun <pkusunyifeng@gmail.com> Signed-off-by: Ben Pfaff <blp@ovn.org>
* netdev: Custom statistics.Michal Weglicki2018-01-101-0/+2
| | | | | | | | | | | | | | | | | | | | | - New get_custom_stats interface function is added to netdev. It allows particular netdev implementation to expose custom counters in dictionary format (counter name/counter value). - New statistics are retrieved using experimenter code and are printed as a result to ofctl dump-ports. - New counters are available for OpenFlow 1.4+. - New statistics are printed to output via ofctl only if those are present in reply message. - New statistics definition is added to include/openflow/intel-ext.h. - Custom statistics are implemented only for dpdk-physical port type. - DPDK-physical implementation uses xstats to collect statistics. Only dropped and error counters are exposed. Co-authored-by: Ben Pfaff <blp@ovn.org> Signed-off-by: Ben Pfaff <blp@ovn.org> Signed-off-by: Michal Weglicki <michalx.weglicki@intel.com> Signed-off-by: Ben Pfaff <blp@ovn.org>
* sparse: Add guards to prevent FreeBSD-incompatible #include order.Ben Pfaff2017-12-221-0/+2
| | | | | | | | | | FreeBSD insists that <sys/types.h> be included before <netinet/in.h> and that <netinet/in.h> be included before <arpa/inet.h>. This adds guards to the "sparse" headers to yield a warning if this order is violated. This commit also adjusts the order of many #includes to suit this requirement. Signed-off-by: Ben Pfaff <blp@ovn.org> Acked-by: Justin Pettit <jpettit@ovn.org>
* util: Introduce str_to_ullong() helper function.Ilya Maximets2017-11-291-0/+1
| | | | | | | | Will be used to convert strings to unsigned long long. Signed-off-by: Ilya Maximets <i.maximets@samsung.com> Signed-off-by: Ben Pfaff <blp@ovn.org> Acked-by: Jan Scheurich <jan.scheurich@ericsson.com>
* util: Add high resolution sleep support.Bhanuprakash Bodireddy2017-11-281-0/+1
| | | | | | | | | | | | This commit introduces xnanosleep() for the threads needing high resolution sleep timeouts. usleep() that provides microsecond granularity is deprecated and threads wanting sub-second(ms,us,ns) granularity can use this implementation. Signed-off-by: Bhanuprakash Bodireddy <bhanuprakash.bodireddy@intel.com> Acked-by: Alin Gabriel Serdean <aserdean@ovn.org> Signed-off-by: Ben Pfaff <blp@ovn.org>
* packets: Fix C++ compilation issues when include packets.hYi-Hung Wei2017-11-021-1/+14
| | | | | | | | | | | | | | | | | | | | | This patch fixes three C++ compilation errors when it includes "lib/packets.h". 1) Fix in "include/openvswitch/util.h" is to avoid duplicated named_member__ in struct pkt_metadata. 2) Fix in "lib/packets.h" is because designated initializers are not implemented in GNU C++ [1]. 3) Fix in "lib/util.h" is because __builtin_types_compatible_p and __builtin_choose_expr are only supported in GCC. I use one solution for C++ that is type-safe and works at compile time from [2]. [1]: https://gcc.gnu.org/onlinedocs/gcc/Designated-Inits.html [2]: https://goo.gl/xNe48A Signed-off-by: Yi-Hung Wei <yihung.wei@gmail.com> Signed-off-by: Ben Pfaff <blp@ovn.org>
* util: Add PADDED_MEMBERS_CACHELINE_MARKER macro to mark cachelines.Bhanuprakash Bodireddy2017-08-031-0/+6
| | | | | | | | | | | | PADDED_MEMBERS_CACHELINE_MARKER macro introduces a way to mark cachelines. This macro expands to an anonymous union containing cacheline marker, members in nested anonymous structure, followed by array of bytes that is multiple of UNIT bytes. Signed-off-by: Bhanuprakash Bodireddy <bhanuprakash.bodireddy@intel.com> Signed-off-by: Ben Pfaff <blp@ovn.org>
* util: New function is_all_byte().Ben Pfaff2017-07-311-0/+1
| | | | | | | | This makes it easy for callers to choose all-ones or all-zeros based on a parameter instead of choice of function. Signed-off-by: Ben Pfaff <blp@ovn.org> Acked-by: Andy Zhou <azhou@ovn.org>
* process: Consolidate process related APIs.Bhanuprakash Bodireddy2017-07-131-0/+3
| | | | | | | | | | | | As part of retrieving system statistics, process status APIs along with helper functions were implemented. Some of them are very generic and can be reused by other subsystems. Move the APIs in system-stats.c to process.c and util.c and make them available. This patch doesn't change any functionality. Signed-off-by: Bhanuprakash Bodireddy <bhanuprakash.bodireddy@intel.com> Signed-off-by: Ben Pfaff <blp@ovn.org>
* treewide: Avoid undefined behavior passing null in nonnull parameters.Lance Richardson2017-06-131-0/+21
| | | | | | | | | | Eliminate a number of instances of undefined behavior related to passing NULL in parameters having "nonnull" annotations. Found with gcc's undefined behavior sanitizer. Signed-off-by: Lance Richardson <lrichard@redhat.com> Signed-off-by: Ben Pfaff <blp@ovn.org>
* util: New macro ovs_strlcpy_arrays().Ben Pfaff2017-04-061-1/+8
| | | | | | | | | | When both arguments to ovs_strlcpy() are character arrays, it makes sense to just pass the smaller of their sizes as the overall size. It's somewhat error-prone and definitely redundant to write that by hand, so this commit adds a new macro that does it automatically. Signed-off-by: Ben Pfaff <blp@ovn.org> Acked-by: Andy Zhou <azhou@ovn.org>
* ovsdb-data: Add support for integer ranges in database commandsLukasz Rzasik2017-01-051-0/+2
| | | | | | | | | | | | | | | | Adding / removing a range of integers to a column accepting a set of integers requires enumarating all of the integers. This patch simplifies it by introducing 'range' concept to the database commands. Two integers separated by a hyphen represent an inclusive range. The patch adds positive and negative tests for the new syntax. The patch was tested by 'make check'. Covarage was tested by 'make check-lcov'. Signed-off-by: Lukasz Rzasik <lukasz.rzasik@gmail.com> Suggested-by: <my_ovs_discuss@yahoo.com> Suggested-by: Ben Pfaff <blp@ovn.org> Signed-off-by: Ben Pfaff <blp@ovn.org>
* conntrack: New userspace connection tracker.Daniele Di Proietto2016-07-271-0/+9
| | | | | | | | | | | | | | | | | | | | | | This commit adds the conntrack module. It is a connection tracker that resides entirely in userspace. Its primary user will be the dpif-netdev datapath. The module main goal is to provide conntrack_execute(), which offers a convenient interface to implement the datapath ct() action. The conntrack module uses two submodules to deal with the l4 protocol details (conntrack-other for UDP and ICMP, conntrack-tcp for TCP). The conntrack-tcp submodule implementation is adapted from FreeBSD's pf subsystem, therefore it's BSD licensed. It has been slightly altered to match the OVS coding style and to allow the pickup of already established connections. Signed-off-by: Daniele Di Proietto <diproiettod@vmware.com> Acked-by: Antonio Fischetti <antonio.fischetti@intel.com> Acked-by: Joe Stringer <joe@ovn.org>
* util: Expose function nullable_string_is_equal.Ilya Maximets2016-07-251-0/+1
| | | | | | | | Implementation of 'nullable_string_is_equal()' moved to util.c and reused inside dpif-netdev. Signed-off-by: Ilya Maximets <i.maximets@samsung.com> Acked-by: Daniele Di Proietto <diproiettod@vmware.com>
* json: Move from lib to include/openvswitch.Terry Wilson2016-07-221-0/+1
| | | | | | | | | | | | | | | To easily allow both in- and out-of-tree building of the Python wrapper for the OVS JSON parser (e.g. w/ pip), move json.h to include/openvswitch. This also requires moving lib/{hmap,shash}.h. Both hmap.h and shash.h were #include-ing "util.h" even though the headers themselves did not use anything from there, but rather from include/openvswitch/util.h. Fixing that required including util.h in several C files mostly due to OVS_NOT_REACHED and things like xmalloc. Signed-off-by: Terry Wilson <twilson@redhat.com> Signed-off-by: Ben Pfaff <blp@ovn.org>
* util: New function nullable_xstrdup().Ben Pfaff2016-06-261-0/+1
| | | | | | It's a pretty common pattern so create a function for it. Signed-off-by: Ben Pfaff <blp@ovn.org>
* util: Pass 128-bit arguments directly instead of using pointers.Justin Pettit2016-05-081-10/+10
| | | | | | | | | | | Commit f2d105b5 (ofproto-dpif-xlate: xlate ct_{mark, label} correctly.) introduced the ovs_u128_and() function. It directly takes ovs_u128 values as arguments instead of pointers to them. As this is a bit more direct way to deal with 128-bit values, modify the other utility functions to do the same. Signed-off-by: Justin Pettit <jpettit@ovn.org> Acked-by: Joe Stringer <joe@ovn.org>
* util.h: Restore stdarg.h which is necessary for va_listYAMAMOTO Takashi2016-04-231-0/+1
| | | | | | | | Fixes a regression in commit b44aaaaff8d826535025f4f8d12808c4ef36a7a8 . ("Misc cleanup with "util.h" header files") Signed-off-by: YAMAMOTO Takashi <yamamoto@ovn.org> Acked-by: Ben Pfaff <blp@ovn.org>
* ofproto-dpif-xlate: xlate ct_{mark, label} correctly.Joe Stringer2016-04-221-0/+11
| | | | | | | | | | | | | | | | | | | | | | | | When translating multiple ct actions in a row which include modification of ct_mark or ct_labels, these fields could be incorrectly translated into datapath actions, resulting in modification of these fields for entries when the OpenFlow rules didn't actually specify the change. For instance, the following OpenFlow actions: ct(zone=1,commit,exec(set_field(1->ct_mark))),ct(zone=2,table=1),... Would translate into the datapath actions: ct(zone=1,commit,mark=1),ct(zone=2,mark=1),recirc(...),... This commit fixes the issue by zeroing the wildcards for these fields prior to performing nested actions translation (and restoring afterwards). As such, these fields do not hold both the match and the field modification values at the same time. As a result, the ct_mark and ct_labels don't leak from one ct action to the next. Fixes: 8e53fe8cf7a1 ("Add connection tracking mark support.") Fixes: 9daf23484fb1 ("Add connection tracking label support.") Signed-off-by: Joe Stringer <joe@ovn.org> Acked-by: Ben Pfaff <blp@ovn.org>
* Misc cleanup with "util.h" header filesBen Warren2016-04-141-51/+0
| | | | | | | | | Removed redundant #includes and moved some macros to different file scope Signed-off-by: Ben Warren <ben@skyportsystems.com> Acked-by: Ryan Moats <rmoats@us.ibm.com> Signed-off-by: Ben Pfaff <blp@ovn.org>
* util: Remove va_copy() implementation.Ben Pfaff2016-03-311-8/+0
| | | | | | | | | This was here to help out older compilers that do not include va_copy(), which was new in C99. All the compilers we care about these days (GCC, Clang, MSVC) do support va_copy(), so remove it. Signed-off-by: Ben Pfaff <blp@ovn.org> Acked-by: Russell Bryant <russell@ovn.org>
* util: Move build assertion macros to compiler.h.Ben Warren2016-03-301-28/+0
| | | | | Signed-off-by: Ben Warren <ben@skyportsystems.com> Signed-off-by: Ben Pfaff <blp@ovn.org>
* list: Move contents of lib/list.h to include/openvswitch directory.Ben Warren2016-03-301-100/+0
| | | | | | | | | | | Most of the list code is properly namespaced, so is OK to move to the global export directory. Some "lib/util.h" code had to move to the other directory as well, but I've tried to make that as small as possible Signed-off-by: Ben Warren <ben@skyportsystems.com> Acked-by: Ryan Moats <rmoats@us.ibm.com> Signed-off-by: Ben Pfaff <blp@ovn.org>
* ovs-ofctl: Add option for color output to dump-flows command.Quentin Monnet2016-03-181-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Add an option to ovs-ofctl utility so as to obtain colorized output in tty, for easier reading. Currently, only the dump-flows command supports colors. A new `--color` option has been added to ovs-ofctl so as to indicate whether color markers should be used or not. It can be set to `always` (force colors), `never` (no colors) or `auto` (use colors only if output is a tty). If provided without any value, it is the same as `auto`. If the option is not provided at all, colors are disabled by default. Examples: This first call will output colorized flows: ovs-ofctl dump-flows br0 --color=always These two calls will produce colorized output on a tty, but they will not use color markers if the output is redirected to a file or piped into another command: ovs-ofctl dump-flows br0 --color=auto ovs-ofctl dump-flows br0 --color These two calls will not use color markers: ovs-ofctl dump-flows br0 --color=never ovs-ofctl dump-flows br0 The result of this option is stored into a variable which is to be forwarded (in next commits) as a function argument until it reaches the functions that print the elements of the flows. Signed-off-by: Quentin Monnet <quentin.monnet@6wind.com> Signed-off-by: Ben Pfaff <blp@ovn.org>
* util: New macro BUILD_ASSERT_TYPE.Ben Pfaff2016-02-081-2/+18
| | | | | | | I intend to make further use of this in upcoming commits. Signed-off-by: Ben Pfaff <blp@ovn.org> Acked-by: Andy Zhou <azhou@ovn.org>
* flow: Pass last field to miniflow_pad_to_64().Simon Horman2015-12-221-0/+4
| | | | | | | | | Make miniflow_pad_to_64() a little more robust with regards to updates to struct flow by passing the last field, whose end should be considered for padding, rather than the next field, whose start should be considered. Signed-off-by: Simon Horman <simon.horman@netronome.com> Signed-off-by: Ben Pfaff <blp@ovn.org>
* types: Define OVS_*128_MAX statically.Joe Stringer2015-12-221-3/+1
| | | | | | | | | | | | | The previous definitions of these variables using designated initializers caused a variety of issues when attempting to compile with MSVC, particularly if including these headers from C++ code. By defining them like this, we can appease MSVC and keep the definitions the same on all platforms. VMware-BZ: #1517163 Suggested-by: Yin Lin <linyi@vmware.com> Signed-off-by: Joe Stringer <joe@ovn.org> Acked-by: Ben Pfaff <blp@ovn.org>
* types: Add big-endian 128-bit types and helpers.Joe Stringer2015-10-131-0/+30
| | | | | | | | | These types will be used by the following patches to ensure a consistent wire format for 128-bit connection tracking labels. Common functions for comparison, endian translation, etc. are provided. Signed-off-by: Joe Stringer <joestringer@nicira.com> Acked-by: Ben Pfaff <blp@nicira.com>
* util: Generalize rightmost_1bit_idx(), leftmost_1bit_idx().Ben Pfaff2015-09-291-13/+8
| | | | | | | | | | | | | | | | | These functions could only work with 32-bit integers because of their special cases for an argument of value 0. However, none of the existing users depended on this special case, and some of the users did try to use these functions with 64-bit integer arguments. Thus, this commit changes them to support 64-bit integer arguments and drops the special cases for zero. This fixes a latent bug that applied rightmost_1bit_idx() to an ofpact bitmap, which only becomes visible when an OFPACT_* with value greater than 32 is included in the bitmap. Reported-by: Kyle Upton <kupton@baymicrosystems.com> Reported-at: http://openvswitch.org/pipermail/dev/2015-September/060128.html Signed-off-by: Ben Pfaff <blp@nicira.com>
* Merge remote-tracking branch 'origin/master' into ovn4Justin Pettit2015-06-181-0/+3
|\
| * flow: Make assertions about offsets within struct flow easier to follow.Ben Pfaff2015-06-151-0/+3
| | | | | | | | | | Signed-off-by: Ben Pfaff <blp@nicira.com> Acked-by: Jarno Rajahalme <jrajahalme@nicira.com>
* | Merge "master" into "ovn".Ben Pfaff2015-06-131-1/+11
|\ \ | |/ | | | | | | | | | | | | | | This allows OVN to take advantage of the client scalability changes that have been committed to ovsdb-server on master recently. Conflicts: Makefile.am lib/learn.c
| * configure: Stop avoiding -Wformat-zero-length.Ben Pfaff2015-06-101-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Debian likes to enable -Wformat-zero-length, even over our code trying to disable it. It isn't too hard to make our code warning-free against this option, so this commit both stops disabling it and fixes the warnings. The first fix is to change set_subprogram_name() to take a plain string instead of a format string, and to adjust its few callers. This fixes one warning since one of those callers passed in an empty string. The second fix is to remove a test for ovs_scan() against an empty string. I couldn't find a way to avoid a warning for this test, and it isn't too valuable in any case. This allows us to drop filtering for -Wformat from the Debian rules file, so this commit removes it. Signed-off-by: Ben Pfaff <blp@nicira.com>
| * types: Rename and move ovs_u128_equal().Joe Stringer2015-06-091-0/+7
| | | | | | | | | | | | | | | | This function doesn't need to be exported in the public OVS headers, and it had an inconsistent name compared to uuid_equals(). Rename and move. Signed-off-by: Joe Stringer <joestringer@nicira.com> Acked-by: Ben Pfaff <blp@nicira.com>
| * util: Library routines for printing and scanning large hex integers.Jesse Gross2015-05-281-0/+3
| | | | | | | | | | | | | | | | | | | | Geneve options are variable length and up to 124 bytes long, which means that they can't be easily manipulated by the integer string functions like we do for other fields. This adds a few helper routines to make these operations easier. Signed-off-by: Jesse Gross <jesse@nicira.com> Acked-by: Andy Zhou <azhou@nicira.com>
* | util: Add more bitwise operations.Ben Pfaff2015-04-151-1/+8
|/ | | | | | | | To be used in upcoming commits. Signed-off-by: Ben Pfaff <blp@nicira.com> Acked-by: Andy Zhou <azhou@nicira.com> Acked-by: Russell Bryant <rbryant@redhat.com>
* lib/util.h: use types compatible with DWORDNithin Raju2015-02-121-4/+4
| | | | | | | | | | | | | | | | | | | _BitScanForward() and friends are part of the Windows API and take DWORD as parameter type. DWORD is defined to be 'unsigned long' in Windows' header files. We call into these functions from within lib/util.h. Currently, we pass arguments of type uint32_t which is type defined to 'unsigned int'. This incompatiblity causes failures when we compile the code as C++ code or with warnings enabled, when compiled as C code. The fix is to use 'unsigned long' rather than fixed size type. Co-Authored-by: Linda Sun <lsun@vmware.com> Signed-off-by: Nithin Raju <nithin@vmware.com> Signed-off-by: Linda Sun <lsun@vmware.com> Signed-off-by: Gurucharan Shetty <gshetty@nicira.com>
* lib: Expose SOURCE_LOCATOR as OVS_SOURCE_LOACATORThomas Graf2014-12-151-9/+1
| | | | | | | Required to expose headers which depend on SOURCE_LOCATOR Signed-off-by: Thomas Graf <tgraf@noironetworks.com> Acked-by: Ben Pfaff <blp@nicira.com>