2
0
mirror of https://github.com/openvswitch/ovs synced 2025-08-28 12:58:00 +00:00

39 Commits

Author SHA1 Message Date
Ben Pfaff
9f0721e989 ofp-actions: Improve a few error messages.
Acked-by: Numan Siddique <nusiddiq@redhat.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
2019-06-09 16:01:55 -07:00
Ben Pfaff
be51cd4173 ovs-actions: New document describing OVS actions in detail.
Acked-by: Mark Michelson <mmichels@redhat.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
2019-01-10 15:52:05 -08:00
Martin Xu
84ddf96ce0 bundle: add symmetric_l3 hash method for multipath
Add a symmetric_l3 hash method that uses both network destination
address and network source address.

VMware-BZ: #2112940
Signed-off-by: Martin Xu <martinxu9.ovs@gmail.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
2018-10-02 15:17:43 -07:00
Ben Pfaff
0d71302e36 ofp-util, ofp-parse: Break up into many separate modules.
ofp-util had been far too large and monolithic for a long time.  This
commit breaks it up into units that make some logical sense.  It also
moves the pieces of ofp-parse that were specific to each unit into the
relevant unit.

Most of this commit is just moving code around.

Signed-off-by: Ben Pfaff <blp@ovn.org>
Reviewed-by: Yifeng Sun <pkusunyifeng@gmail.com>
2018-02-13 10:43:13 -08:00
Ben Pfaff
b2befd5bb2 sparse: Add guards to prevent FreeBSD-incompatible #include order.
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>
2017-12-22 12:58:02 -08:00
wenxu
417cfdb60c bundle: add nw_src/dst hash method
Add only nw_src or nw_dst hash feature to bundle and multipath.

Signed-off-by: wenxu <wenxu@ucloud.cn>
Signed-off-by: Ben Pfaff <blp@ovn.org>
2017-04-06 17:06:28 -07:00
Ben Pfaff
fd13c6b549 Fix format specifier technicalities.
Various printf() format specifiers in the tree had minor technical issues
which the Mac OS build reported, e.g. here:
https://s3.amazonaws.com/archive.travis-ci.org/jobs/208718342/log.txt

These tend to fall into two categories of harmless warnings:

1. Wrong width for types that are all promoted to 'int'.  For example,
both uint8_t and uint16_t are both promoted to 'int' as part of a call
to printf(), but using PRIu8 for a uint16_t causes a warning.

2. Wrong format specifier for type promoted to 'int' due to arithmetic.
For example, if 'x' is a uint8_t, then x >> 1 has type 'int' due to
C's promotion rules, so the correct format specifier is %d and using
PRIu8 will cause a warning.

This commit fixes the warnings.  I didn't see anything that rose to the
level of a bug.

These warnings only showed up on Mac OS X because of differences in the
format specifiers that Mac OS uses for PRI*.

Reported-by: Shu Shen <shu.shen@gmail.com>
Acked-by: Daniele Di Proietto <diproiettod@vmware.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
2017-03-17 13:39:01 -07:00
Jarno Rajahalme
67210a5510 lib: Check match and action prerequisities with 'match'.
Supply the match mask to prerequisities checking when available.  This
allows checking for zero-valued matches.  Non-zero valued matches
imply the presense of corresponding mask bits, but for zero valued
matches we must explicitly check the mask, too.

This is required now only for conntrack validity checking due to the
conntrack state having and 'invalid' bit, but not 'valid' bit.  One
way to match an valid conntrack state is to match on the 'tracked' bit
being one and 'invalid' bit being zero.  The latter requires the
corresponding mask bit be verified.

Signed-off-by: Jarno Rajahalme <jarno@ovn.org>
Acked-by: Joe Stringer <joe@ovn.org>
2017-03-08 17:22:27 -08:00
Terry Wilson
ee89ea7b47 json: Move from lib to include/openvswitch.
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>
2016-07-22 17:09:17 -07:00
Ben Warren
b598f21436 Move lib/ofp-actions.h to include/openvswitch directory
Signed-off-by: Ben Warren <ben@skyportsystems.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
2016-04-14 16:38:24 -07:00
Ben Warren
f424833659 Move lib/ofp-util.h to include/openvswitch directory
This commit also adds several #include directives in source files in
order to make the 'ofp-util.h' move possible

Signed-off-by: Ben Warren <ben@skyportsystems.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
2016-04-14 13:48:25 -07:00
Ben Warren
3e8a2ad145 Move lib/dynamic-string.h to include/openvswitch directory
Signed-off-by: Ben Warren <ben@skyportsystems.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
2016-03-19 10:02:12 -07:00
Ben Warren
e03c096dd0 Move lib/ofp-errors.h to include/openvswitch directory
Signed-off-by: Ben Warren <ben@skyportsystems.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
2016-03-19 09:43:12 -07:00
Quentin Monnet
b1c5bf1f39 ofp-actions: Color output of flow actions for ovs-ofctl dump-flows.
Add color output for flow actions for ovs-ofctl dump-flows command
utility, by inserting color markers in the functions responsible for
printing those actions.

Signed-off-by: Quentin Monnet <quentin.monnet@6wind.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
2016-03-18 14:02:51 -07:00
Jeroen van Bemmel
4249b5470e hash: Add symmetric L3/L4 hash functions for multipath, bundle hashing.
Signed-off-by: Jeroen van Bemmel <jvb127@gmail.com>
[blp@nicira.com made code style fixes, expanded documentation]
Signed-off-by: Ben Pfaff <blp@nicira.com>
2015-07-08 08:33:27 -07:00
Thomas Graf
cab5044987 lib: Move compiler.h to <openvswitch/compiler.h>
The following macros are renamed to avoid conflicts with other headers:
 * WARN_UNUSED_RESULT to OVS_WARN_UNUSED_RESULT
 * PRINTF_FORMAT to OVS_PRINTF_FORMAT
 * NO_RETURN to OVS_NO_RETURN

Signed-off-by: Thomas Graf <tgraf@noironetworks.com>
Acked-by: Ben Pfaff <blp@nicira.com>
2014-12-15 14:14:47 +01:00
Ben Pfaff
bad8a43994 ofp-actions: Support experimenter OXMs in Nicira extensions.
Some of the Nicira extension actions include fixed-size 32-bit members that
designate NXM fields.  These actions can't accommodate 64-bit experimenter
OXMs, so we need to figure out some kind of solution.  This commit does
that, in different ways for different actions.

For some actions, I did not think it was worthwhile to worry about
experimenter OXM, so I just disabled use of them.  This is what I did for
bundle, learn, and multipath actions.

Other actions could be gracefully reinterpreted to support experimenter
OXM.  This is true of reg_move, which use NXM headers only at the end of
the action and such that using an experimenter OXM would make the action
longer (which unambigously signals to older OVS that the action is an
error, which is desired behavior since older OVS cannot interpret this
action).  The stack push and pop actions are also in this category.

reg_load was the most frustrating case.  In OpenFlow 1.5 we had already
eliminated this action in favor of OF1.5+ set_field.  In other OpenFlow
versions, though, reg_load is more powerful than set_field because it
can modify partial fields.  This commit therefore adds a new variant of
reg_load, called reg_load2, which is simply OF1.5+ set_field with a Nicira
extension header on it.

Signed-off-by: Ben Pfaff <blp@nicira.com>
Acked-by: Jarno Rajahalme <jrajahalme@nicira.com>
2014-10-08 16:36:43 -07:00
Ben Pfaff
c2d936a44f ofp-actions: Centralize all OpenFlow action code for maintainability.
Until now, knowledge about OpenFlow has been somewhat scattered around the
tree.  Some of it is in ofp-actions, some of it is in ofp-util, some in
separate files for individual actions, and most of the wire format
declarations are in include/openflow.  This commit centralizes all of that
in ofp-actions.

Encoding and decoding OpenFlow actions was previously broken up by OpenFlow
version.  This was OK with only OpenFlow 1.0 and 1.1, but each additional
version added a new wrapper around the existing ones, which started to
become hard to understand.  This commit merges all of the processing for
the different versions, to the extent that they are similar, making the
version differences clearer.

Previously, ofp-actions contained OpenFlow encoding and decoding, plus
ofpact formatting, but OpenFlow parsing was separated into ofp-parse, which
seems an odd division.  This commit moves the parsing code into ofp-actions
with the rest of the code.

Before this commit, the four main bits of code associated with a particular
ofpact--OpenFlow encoding and decoding, ofpact formatting and parsing--were
all found far away from each other.  This often made it hard to see what
was going on for a particular ofpact, since you had to search around to
many different pieces of code.  This commit reorganizes so that all of the
code for a given ofpact is in a single place.

As a code refactoring, this commit has little visible behavioral change.
The update to ofproto-dpif.at illustrates one minor bug fix as a side
effect: a flow that was added with the action "dec_ttl" (a standard
OpenFlow action) was previously formatted as "dec_ttl(0)" (using a Nicira
extension to specifically direct packets bounced to the controller because
of too-low TTL), but after this commit it is correctly formatted as
"dec_ttl".

The other visible effect is to drop support for the Nicira extension
dec_ttl action in OpenFlow 1.1 and later in favor of the equivalent
standard action.  It seems unlikely that anyone was really using the
Nicira extension in OF1.1 or later.

Signed-off-by: Ben Pfaff <blp@nicira.com>
Acked-by: Jarno Rajahalme <jrajahalme@nicira.com>
2014-08-11 12:57:17 -07:00
Harold Lim
428b2eddc9 Rename NOT_REACHED to OVS_NOT_REACHED
This allows other libraries to use util.h that has already
defined NOT_REACHED.

Signed-off-by: Harold Lim <haroldl@vmware.com>
Signed-off-by: Ben Pfaff <blp@nicira.com>
2013-12-17 13:16:39 -08:00
Alin Serdean
34582733d9 Avoid printf type modifiers not supported by MSVC C runtime library.
The MSVC C library printf() implementation does not support the 'z', 't',
'j', or 'hh' format specifiers.  This commit changes the Open vSwitch code
to avoid those format specifiers, switching to standard macros from
<inttypes.h> where available and inventing new macros resembling them
where necessary.  It also updates CodingStyle to specify the macros' use
and adds a Makefile rule to report violations.

Signed-off-by: Alin Serdean <aserdean@cloudbasesolutions.com>
Co-authored-by: Ben Pfaff <blp@nicira.com>
Signed-off-by: Ben Pfaff <blp@nicira.com>
2013-11-25 23:38:59 -08:00
Justin Pettit
f74e7df745 ofproto-dpif: Always un-wildcard fields that are being set.
The ODP library has an optimization to not set a header if the field was
not changed, regardless of whether an action to set the field was
present.  That library is also responsible for un-wildcarding fields
that are bieng modified.  This leads to a problem where a packet matches
a flow that updates a field, but that particular packet's field already
has that value.  As such, an overly loose megaflow will be generated
that doesn't match on that field and the actions won't update it.  A
second packet that should have the field set will match that flow and
will not be modified.

This commit changes the behavior to always un-wildcard fields that are
being modified.  Since the ODP library updates the entire header if a
field in it is modified, and all those fields will be un-wildcarded, the
generated flows may be different.  However, they should be correct.

Bug #18946.

Reported-by: Jesse Gross <jesse@nicira.com>
Signed-off-by: Justin Pettit <jpettit@nicira.com>
Acked-by: Ben Pfaff <blp@nicira.com>
2013-08-02 23:21:21 -07:00
Ben Pfaff
bdda5aca7b ofp-parse: Do not exit() upon a parse error.
Until now, failure to parse a flow in the ofp-parse module has caused the
program to abort immediately with a fatal error.  This makes it hard to
use these functions from any long-lived program.  This commit fixes the
problem.

Signed-off-by: Ben Pfaff <blp@nicira.com>
2013-07-08 10:15:00 -07:00
Justin Pettit
6cdd514560 flow: Only un-wildcard relevant IP headers.
When determining the fields to un-wildcard, we need to be careful
about only un-wildcarding fields that are relevant.  Also, we
didn't properly handle IPv6 addresses.

Signed-off-by: Justin Pettit <jpettit@nicira.com>
Acked-by: Ethan Jackson <ethan@nicira.com>
2013-06-27 19:30:26 -07:00
Justin Pettit
bcd2633a5b ofproto-dpif: Store relevant fields for wildcarding in facet.
Dynamically determines the flow fields that were relevant in
processing flows based on the OpenFlow flow table and switch
configuration.  The immediate use for this functionality is to
cache action translations for similar flows in facets.  This yields
a roughly 80% improvement in flow set up rates for a complicated
flow table.

More importantly, these wildcards will be used to determine what to
wildcard for the forthcoming kernel wildcard (megaflow) patches
that will allow wildcarding in the kernel, which will provide
significant flow set up improvements.

The approach to tracking fields and caching action translations in
facets was based on an impressive prototype by Ethan Jackson.

Co-authored-by: Ethan Jackson <ethan@nicira.com>
Signed-off-by: Ethan Jackson <ethan@nicira.com>
Signed-off-by: Justin Pettit <jpettit@nicira.com>
2013-06-11 13:03:50 -07:00
Ben Pfaff
f25d0cf3c3 Introduce ofpacts, an abstraction of OpenFlow actions.
OpenFlow actions have always been somewhat awkward to handle.
Moreover, over time we've started creating actions that require more
complicated parsing.  When we maintain those actions internally in
their wire format, we end up parsing them multiple times, whenever
we have to look at the set of actions.

When we add support for OpenFlow 1.1 or later protocols, the situation
will get worse, because these newer protocols support many of the same
actions but with different representations.  It becomes unrealistic to
handle each protocol in its wire format.

This commit adopts a new strategy, by converting OpenFlow actions into
an internal form from the wire format when they are read, and converting
them back to the wire format when flows are dumped.  I believe that this
will be more maintainable over time.

Thanks to Simon Horman and Pravin Shelar for reviews.

Signed-off-by: Ben Pfaff <blp@nicira.com>
2012-07-03 22:21:11 -07:00
Raju Subramanian
e0edde6fee Global replace of Nicira Networks.
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-05-02 17:08:02 -07:00
Ben Pfaff
816fd533f8 meta-flow: New "subfield" data structure.
Until now, parts of a field have been dealt with in a fairly ad-hoc way.
struct mf_subfield and the supporting functions added by this commit make
their use more systematic.

Signed-off-by: Ben Pfaff <blp@nicira.com>
2012-02-01 14:15:11 -08:00
Ben Pfaff
300c69464c multipath: Correctly calculate number of required destination bits.
The previous calculation was wrong when n_links was a power of 2.

Reported-by: Paul Ingram <paul@nicira.com>
Signed-off-by: Ben Pfaff <blp@nicira.com>
2012-01-12 16:51:29 -08:00
Ben Pfaff
90bf1e0732 Better abstract OpenFlow error codes.
This commit switches from using the actual protocol values of error codes
internally in Open vSwitch, to using abstract values that are translated to
and from protocol values at message parsing and serialization time.  I
believe that this makes the code easier to read and to write.

This is also one step along the way toward OpenFlow 1.1 support because
OpenFlow 1.1 renumbered a bunch of error codes.

Signed-off-by: Ben Pfaff <blp@nicira.com>
2012-01-12 15:54:25 -08:00
Ben Pfaff
93996add1c ofp-util: Add type-safe functions for serializing actions. 2011-09-13 11:46:08 -07:00
Ethan Jackson
ce523f65fc nx-match: Update register check functions.
This patch simplifies the API of nxm_dst_check() and adds a new
function nxm_src_check() for checking source fields.
2011-08-12 15:06:53 -07:00
Ethan Jackson
43edca5717 nx-match: New helpers.
This patch creates two new helper functions, nxm_reg_load() and
nxm_dst_check().  The new nxm_dst_check() function may be used to
check the validity of destination fields used by actions.  The new
nxm_reg_load() function may be used by actions which need to write
to NXM fields.

This patch also allows multipath and autopath to write their result
to non-register NXM fields.
2011-07-22 17:46:48 -07:00
Ethan Jackson
520e9a2acd nicira-ext: Generalize nx_mp_fields into nx_hash_fields.
Future patches will use nx_hash_fields for non-multipath related
actions.  This patch renames nx_mp_fields and creates a new
flow_hash_fields() function.
2011-07-19 11:34:26 -07:00
Ben Pfaff
770f1f66bb multipath: Validate multipath actions more thoroughly in multipath_parse().
The stricter validation requires updates to the calls to test-multipath
to supply a valid n_links value.  test-multipath doesn't actually use
that value (it runs over different values in an internal "for" loop), so
this doesn't change any behavior.

Also adds a test to exercise each possible multipath_parse() error message.

Reported-by: Reid Price <reid@nicira.com>
Bug #4462.
2011-02-23 09:42:32 -08:00
Ethan Jackson
ff55ea1f29 lib: Move l4 flow hash to the flow library.
This commit moves hash_symmetric_l4() to the flow library so that
it may be used in future patches.
2011-02-02 11:32:40 -08:00
Ben Pfaff
d7bf2b001f multipath: Fix off-by-one in hash_threshold multipath calculation.
0xffffffff / (0xffffffff / n) can have a value as large as n (consider the
n == 1 case), but we need a value no bigger than n-1.  So add 1 before
dividing to fix the problem.

This caused a test failure on Debian "lenny" amd64 when apparently
unrelated code changed.

Reported-by: Justin Pettit <jpettit@nicira.com>
2011-01-21 17:09:21 -08:00
Ethan Jackson
19f62195a5 multipath: Fix compiler warning.
This commit fixes the following compiler warning:
"cast from function call of type 'uint16_t' to non-matching type
'enum nx_mp_fields'"
2011-01-04 10:30:36 -08:00
Ben Pfaff
7cfb3c26b2 multipath: Zero padding bytes in fields before hashing.
Otherwise the hash includes 3 bytes of trailing indeterminate data.

Reported-by: Pankaj Thakkar <thakkar@nicira.com>
2010-12-28 22:32:13 -08:00
Ben Pfaff
53ddd40ab5 Implement a new Nicira extension action for multipath link selection. 2010-12-17 14:38:50 -08:00