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

106 Commits

Author SHA1 Message Date
Jesse Gross
ac923e910e flow: Enable matching on new field 'pkt_mark'.
The Linux kernel datapath enables matching and setting the skb mark
but this functionality is currently used only internally by
ovs-vswitchd. This exposes it through NXM to enable external
controllers to interact with other kernel subsystems. Although this
is simply exporting the skb mark, the intention is that this is a
platform independent mechanism to access some system metadata and
therefore may have different implementations on various systems.

Bug #17855

Signed-off-by: Jesse Gross <jesse@nicira.com>
Acked-by: Andy Zhou <azhou@nicira.com>
2013-08-13 14:39:56 -07:00
Jesse Gross
1362e248d6 flow: Rename skb_mark to pkt_mark.
The skb_mark field is currently only available with the Linux datapath
and is only used internally. However, it is desirable to expose this
through OpenFlow and when it is exposed ideally it would not be system-
specific. In preparation for this, skb_mark is rename to pkt_mark in
internal data structures for consistency.

This does not rename the Linux interfaces because doing so would break
the API. It would not necessarily be desirable to do anyways since in
Linux-specific code it is clearer to use the actual name rather than a
generic one. This can lead to confusion in some places, however, because
we do not always strictly separate generic and platform dependent code
(one example is actions). This seems inevitable though at this point if
the lower and upper layers have different names (as they must given the
above requirements).

Signed-off-by: Jesse Gross <jesse@nicira.com>
Acked-by: Andy Zhou <azhou@nicira.com>
2013-08-13 14:39:39 -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
Ethan Jackson
f9c0c3eccd flow: New function hash_ofp_port() and hash_ofp_port().
These functions are used so often, that having an easy to read
helper is worth it.

Signed-off-by: Ethan Jackson <ethan@nicira.com>
Acked-by: Ben Pfaff <blp@nicira.com>
2013-06-24 14:15:50 -07:00
Alex Wang
4e022ec09e Create specific types for ofp and odp port
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-06-20 10:42:37 -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
Ethan Jackson
368eefac37 flow: Add new wildcard functions.
Rename the function flow_wildcards_combine() to flow_wildcards_and().
Add new flow_wildcards_or() and flow_hash_in_wildcards() functions.
These will be useful in a future patch.

Signed-off-by: Ethan Jackson <ethan@nicira.com>
Signed-off-by: Justin Pettit <jpettit@nicira.com>
2013-06-11 13:03:50 -07:00
Ethan Jackson
ad77e3c52a flow: Add new flow_wildcards_fold_minimask() function.
This function will be useful in a future commit.

Signed-off-by: Ethan Jackson <ethan@nicira.com>
Co-authored-by: Justin Pettit <jpettit@nicira.com>
Signed-off-by: Justin Pettit <jpettit@nicira.com>
2013-06-11 13:03:50 -07:00
Jarno Rajahalme
0ad90c845b OpenFlow-level flow-based tunneling support.
Adds tun_src and tun_dst match and set capabilities via new NXM fields
NXM_NX_TUN_IPV4_SRC and NXM_NX_TUN_IPV4_DST.  This allows management of
large number of tunnels via the flow tables, without requiring the tunnels
to be pre-configured.

Flow-based tunnels can be configured with options remote_ip=flow and
local_ip=flow.  local_ip=flow requires remote_ip=flow.  When set, the
tunnel remote IP address and/or local IP address is set from the flow,
instead of the tunnel configuration.

Example:

$ ovs-vsctl add-port br0 gre -- set Interface gre ofport_request=1 type=gre options:remote_ip=flow options:key=flow
$ ovs-ofctl add-flow br0 "in_port=LOCAL actions=set_tunnel:1,set_field:192.168.0.1->tun_dst,output:1"
$ ovs-ofctl add-flow br0 "in_port=1 tun_src=192.168.0.1 tun_id=1 actions=LOCAL"

Signed-off-by: Jarno Rajahalme <jarno.rajahalme@nsn.com>
Signed-off-by: Ben Pfaff <blp@nicira.com>
2013-05-10 10:50:06 -07:00
Simon Horman
cff78c8844 Remove encal_dl_type from struct flow
There were plans to use this in conjunction with inner/outer flows,
however that plan has been changed in favour of using recirculation.
This leaves us with the current usage.

encal_dl_type is currently only used to allow decoding of packets used in
the test suite. However, this is a bit of a fudge and the packets may be
provided as hexadecimal instead.

Also remove comments from parse_l2_5_onward() relating to MPLS which are
not in keeping with the commenting throughout the rest of the function.

Signed-off-by: Simon Horman <horms@verge.net.au>
Signed-off-by: Jesse Gross <jesse@nicira.com>
2013-03-15 15:05:41 -07:00
Simon Horman
0c8dcab892 Revert "flow: Split flow_extract"
It was planned to use this code to allow further processing of packets, a
second pass done when constructing a flow.  Instead it is now planned to
use recirculation to address the problems that secondary processing aimed
to resolve.  As a result there are no longer plans to use
flow_extract_l3_onwards() and it seems prudent to remove it.

Signed-off-by: Simon Horman <horms@verge.net.au>
Signed-off-by: Jesse Gross <jesse@nicira.com>
2013-03-15 13:58:15 -07:00
Simon Horman
b02475c53b User-Space MPLS actions and matches
This patch implements use-space datapath and non-datapath code
to match and use the datapath API set out in Leo Alterman's patch
"user-space datapath: Add basic MPLS support to kernel".

The resulting MPLS implementation supports:
* Pushing a single MPLS label
* Poping a single MPLS label
* Modifying an MPLS lable using set-field or load actions
  that act on the label value, tc and bos bit.
* There is no support for manipulating the TTL
  this is considered future work.

The single-level push pop limitation is implemented by processing
push, pop and set-field/load actions in order and discarding information
that would require multiple levels of push/pop to be supported.

e.g.
   push,push -> the first push is discarded
   pop,pop -> the first pop is discarded

This patch is based heavily on work by Ravi K.

Cc: Ravi K <rkerur@gmail.com>
Reviewed-by: Isaku Yamahata <yamahata@valinux.co.jp>
Signed-off-by: Simon Horman <horms@verge.net.au>
Signed-off-by: Ben Pfaff <blp@nicira.com>
2013-02-05 09:17:45 -08:00
Simon Horman
ad128cc19f flow: Split flow_extract
Split the L3 and above portion of flow_extract() out into
flow_extract_l3_onwards() and call flow_extract_l3_onwards()
from flow_extract().

This is to allow re-extraction of l3 and higher information using
flow->encap_dl_type which may be set using information contained
in actions.

Signed-off-by: Simon Horman <horms@verge.net.au>
Signed-off-by: Ben Pfaff <blp@nicira.com>
2012-12-27 13:16:45 -08:00
Ansis Atteka
3b21e38717 vswitchd: fix 32-bit builds
My previous 72e8bf28bb38e8816435c64859fb350215b6a9e6 (datapath:
add skb mark matching and set action) commit broke 32-bit builds.
This patch assures that size of struct flow is equal on both
32-bit and 64-bit architectures so that build asserts would
not fire anymore.

Acked-by: Ben Pfaff <blp@nicira.com>
Signed-off-by: Ansis Atteka <aatteka@nicira.com>
2012-11-23 03:44:21 +02:00
Pravin B Shelar
4fe3445afb vswitchd: Log all tunnel parameters of given flow.
Signed-off-by: Pravin B Shelar <pshelar@nicira.com>
2012-11-21 18:51:36 -08:00
Ansis Atteka
72e8bf28bb datapath: add skb mark matching and set action
This patch adds support for skb mark matching and set action.

Acked-by: Jesse Gross <jesse@nicira.com>
Signed-off-by: Ansis Atteka <aatteka@nicira.com>
2012-11-21 16:19:30 -08:00
Justin Pettit
ddbfda8462 Use ODP ports in dpif layer and below.
The current code has a simple mapping between datapath and OpenFlow port
numbers (the port numbers were the same other than OFPP_LOCAL which maps
to datapath port 0).  Since the translation was know at compile time,
this allowed different layers to easily translate between the two, so
the translation often occurred late.

A future commit will break this simple mapping, so this commit draws a
line between where datapath and OpenFlow port numbers are used.  The
ofproto-dpif layer will be responsible for the translations.  Callers
above will use OpenFlow port numbers.  Providers below will use
datapath port numbers.

Signed-off-by: Justin Pettit <jpettit@nicira.com>
2012-11-01 22:54:27 -07:00
Jesse Gross
c97a72ea2e flow: Fix struct flow size build assertion failure.
The new struct flow_tnl contains an extra four bytes of padding on
64-bit machines but we currently assert that the total struct flow
is a fixed size.  The size difference isn't actually a problem
because both are multiples of 4 and the build assertion is only
intended to remind people to update FLOW_WC_SEQ when new fields are
added.  This changes the assertion to fix just the non-tunnel field
size.

Suggested-by: Ben Pfaff <blp@nicira.com>
Signed-off-by: Jesse Gross <jesse@nicira.com>
2012-10-03 11:29:05 -07:00
Jesse Gross
296e07ace0 flow: Extend struct flow to contain tunnel outer header.
Soon the kernel will begin supplying the information about the outer
IP header for tunneled packets and userspace will need to be able to
track it as part of the flow.  For the time being this is only used
internally by OVS and not exposed outwards to OpenFlow.  As a result,
this threads the information throughout userspace but simply stores
the existing tun_id in it.

Signed-off-by: Jesse Gross <jesse@nicira.com>
2012-10-03 10:04:10 -07:00
Ben Pfaff
5cb7a79840 Introduce sparse flows and masks, to reduce memory usage and improve speed.
A cls_rule is 324 bytes on i386 now.  The cost of a flow table lookup is
currently proportional to this size, which is going to continue to grow.
However, the required cost of a flow table lookup, with the classifier that
we currently use, is only proportional to the number of bits that a rule
actually matches.  This commit implements that optimization by replacing
the match inside "struct cls_rule" by a sparse representation.

This reduces struct cls_rule to 100 bytes on i386.

There is still some headroom for further optimization following this
commit:

    - I suspect that adding an 'n' member to struct miniflow would make
      miniflow operations faster, since popcount() has some cost.

    - It's probably possible to replace the "struct minimatch" in cls_rule
      by just a "struct miniflow", since the cls_rule's cls_table has a
      copy of the minimask.

    - Some of the miniflow operations aren't well-optimized.

Signed-off-by: Ben Pfaff <blp@nicira.com>
2012-09-04 12:43:53 -07:00
Ben Pfaff
659c234679 flow: Simplify many functions for working with flows and wildcards.
Now that "struct flow" and "struct flow_wildcards" have the same simple
and uniform structure, it's easy to handle common operations by just
iterating over the bits inside them.

Signed-off-by: Ben Pfaff <blp@nicira.com>
2012-09-04 11:19:16 -07:00
Ben Pfaff
e7b4ef5eac flow: Remove flow_wildcards_is_exact().
It's only used in a not-very-useful assertion in some test code.  In
general, exact-match flows make very little sense anymore, and they're
basically on their way out.

Signed-off-by: Ben Pfaff <blp@nicira.com>
2012-09-04 11:19:16 -07:00
Ben Pfaff
26720e2449 flow: Replace flow_wildcards members by a single "struct flow".
Signed-off-by: Ben Pfaff <blp@nicira.com>
2012-09-04 11:19:16 -07:00
Ben Pfaff
16c6d0c384 flow: Take advantage of zero-padding in struct flow and flow_wildcards.
Since we know these bytes are always 0 in both structures, we can use
faster functions that only work with full words.

Signed-off-by: Ben Pfaff <blp@nicira.com>
2012-09-04 11:19:16 -07:00
Ben Pfaff
51c14ddd8d flow: Ensure that padding is always zeroed.
Signed-off-by: Ben Pfaff <blp@nicira.com>
2012-09-04 11:19:15 -07:00
Ben Pfaff
0bdc4bec4f flow: Use bit-mask for in_port match, instead of FWW_* flag.
Signed-off-by: Ben Pfaff <blp@nicira.com>
2012-09-04 11:19:15 -07:00
Ben Pfaff
e2170cffc1 flow: Use bit-mask for Ethernet type match, instead of FWW_* flag.
Signed-off-by: Ben Pfaff <blp@nicira.com>
2012-09-04 11:19:15 -07:00
Ben Pfaff
851d3105c7 flow: Use bit-mask for IP protocol match, instead of FWW_* flag.
Signed-off-by: Ben Pfaff <blp@nicira.com>
2012-09-04 11:19:15 -07:00
Ben Pfaff
3840c40624 flow: Use bit-mask for TTL match, instead of FWW_* flag.
Signed-off-by: Ben Pfaff <blp@nicira.com>
2012-09-04 11:19:14 -07:00
Ben Pfaff
5d9499c4dc flow: Use bit-mask for DSCP and ECN bits, instead of FWW_* flags.
Signed-off-by: Ben Pfaff <blp@nicira.com>
2012-09-04 11:19:14 -07:00
Ben Pfaff
27cafc5fc0 flow: Fully separate FWW_* from OFPFW10_*.
It might have been a useful optimization at one point to have FWW_*
correspond in OFPFW10_* where possible, but it doesn't seem worthwhile for
only 3 corresponding values.  It also makes the code somewhat more
confusing.

Signed-off-by: Ben Pfaff <blp@nicira.com>
2012-09-04 11:19:14 -07:00
Ben Pfaff
42edbe39dd Do not include zeroed metadata fields in NXM/OXM packet-in messages.
NXM and OpenFlow 1.2+ allow including the values of arbitrary flow metadata
in "packet-in" messages.  Open vSwitch has until now always included all
the values of the metadata fields that it implements in NXT_PACKET_IN
messages.

However, this has at least two disadvantages:

    - Most of the metadata fields tend to be zero most of the time, which
      wastes space in the message.

    - It means that controllers must be very liberal about accepting
      fields that they know nothing about in packet-in messages, since any
      switch upgrade could cause new fields to appear even if the
      controller does nothing to give them nonzero values.  (Controllers
      have to be prepared to tolerate unknown fields in any case, but this
      property makes unknown fields more likely to appear than otherwise.)

This commit changes Open vSwitch so that metadata fields whose values are
zero are not reported in packet-ins, fixing both problems.  (This is
explicitly allowed by OpenFlow 1.2+.)

This commit mainly fixes a sort of internal conceptual dissonance centering
around struct flow_metadata.  This structure is supposed to report the
metadata for a given flow.  If you look at a flow, it has particular
metadata values; it doesn't have masks, and the idea of a mask for a
particular flow doesn't really make sense.  However, struct flow_metadata
did have masks.  This led to internal confusion; one can see this in, for
example, the following code removed by this commit in ofproto-dpif.c to
handle misses in the OpenFlow flow table:

    /* Registers aren't meaningful on a miss. */
    memset(pin.fmd.reg_masks, 0, sizeof pin.fmd.reg_masks);

What this code was really trying to say is that on a flow miss, the
registers are zero, so they shouldn't be included in the packet-in message.
It did manage to omit the registers, by marking them as "wild", but it is
conceptually more correct to simply omit them because they are zero (and
that's one effect of this commit).

Bug #12968.
Reported-by: Igor Ganichev <iganichev@nicira.com>
Signed-off-by: Ben Pfaff <blp@nicira.com>
2012-08-17 13:20:53 -07:00
Ben Pfaff
cc34bc8c86 meta-flow: Add OF1.2-like MFF_VLAN_VID and MFF_VLAN_PCP.
OpenFlow 1.0 and 1.2 have notions of VLAN that are different
enough to warrant separate "meta-flow" fields, which this commit
adds.

Signed-off-by: Ben Pfaff <blp@nicira.com>
Acked-by: Simon Horman <horms@verge.net.au>
2012-07-23 09:21:37 -07:00
Ben Pfaff
fb0451d9bf flow: Rename flow_set_vlan_vid() to flow_set_dl_vlan().
This function is specific to the OF1.0 dl_vlan field, so name it
consistently.

Signed-off-by: Ben Pfaff <blp@nicira.com>
Acked-by: Simon Horman <horms@verge.net.au>
2012-07-23 09:21:34 -07:00
Simon Horman
e878338bf1 OXM: Allow masking of ARP SHA and THA
Signed-off-by: Simon Horman <horms@verge.net.au>
[blp@nicira.com added NEWS, updated a few overlooked meta-flow bits]
Signed-off-by: Ben Pfaff <blp@nicira.com>
2012-07-19 09:33:31 -07:00
Simon Horman
3245502404 OXM: Allow masking of IPv6 Flow Label
Signed-off-by: Simon Horman <horms@verge.net.au>
Signed-off-by: Ben Pfaff <blp@nicira.com>
2012-07-19 08:49:06 -07:00
Joe Stringer
969fc56c2a Add OXM_OF_METADATA field as a step toward OpenFlow 1.1 support.
Signed-off-by: Joe Stringer <joe@wand.net.nz>
Signed-off-by: Ben Pfaff <blp@nicira.com>
2012-06-26 22:31:44 -07:00
Ben Pfaff
eec25dc1ae openflow-1.0: Rename ofp_match to ofp10_match, OFPFW_* to OFPFW10_*.
This better fits our general policy of adding a version number suffix
to structures and constants whose values differ from one OpenFlow
version to the next.

Reviewed-by: Simon Horman <horms@verge.net.au>
Signed-off-by: Ben Pfaff <blp@nicira.com>
2012-06-12 21:19:09 -07:00
Joe Stringer
73c0ce349b flow: Adds support for arbitrary ethernet masking
Arbitrary ethernet mask support is one step on the way to support for OpenFlow
1.1+. This patch set seeks to add this capability without breaking current
protocol support.

Signed-off-by: Joe Stringer <joe@wand.net.nz>
[blp@nicira.com made some updates, see
 http://openvswitch.org/pipermail/dev/2012-May/017585.html]
Signed-off-by: Ben Pfaff <blp@nicira.com>
2012-05-29 12:24:07 -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
Ansis Atteka
47284b1fc6 nicira-ext: Support masking of nd_target field
This commit adds support to specify a mask in CIDR format for
the nd_target field.

Signed-off-by: Ansis Atteka <aatteka@nicira.com>
2012-04-26 15:22:48 -07:00
Ethan Jackson
e9358af610 nicira-ext: Increase the number of NXM registers to 8.
Requested-by: Amar Padmanabhan <amar@nicira.com>
Signed-off-by: Ethan Jackson <ethan@nicira.com>
2012-03-09 13:56:04 -08:00
Ben Pfaff
73f3356323 Add support for bitwise matching on TCP and UDP ports.
Bug #8827.
Signed-off-by: Ben Pfaff <blp@nicira.com>
2012-02-02 16:46:22 -08:00
Ethan Jackson
5d6c3af0fb flow: Create new flow_metadata structure for packet_in messages.
This will ease the implementation of future patches.

Signed-off-by: Ethan Jackson <ethan@nicira.com>
2012-01-10 14:30:15 -08:00
Ben Pfaff
deedf7e78b flow: Rename 'priority' to 'skb_priority'.
This priority's mean is completely different from the priority of an
OpenFlow rule, so it is confusing for it to have the same name.

We should be on the lookout for a less Linux-specific name, but this one
seems fine for now.

Signed-off-by: Ben Pfaff <blp@nicira.com>
2011-12-21 15:52:38 -08:00
Ben Pfaff
3719455c2a flow: New functions for setting a VLAN VID or PCP value. 2011-11-21 14:45:53 -08:00
Ben Pfaff
79049a242a flow: Rename flow_compare() to flow_compare_3way().
I like the _3way suffix convention.  It makes the interpretation of the
return value clear.  We use it elsewhere in the tree, so use it here too.

There weren't any users of flow_compare() outside of flow.h, but there soon
will be.
2011-11-17 10:11:53 -08:00
Justin Pettit
2486e66ab5 flow: Use FWW_ flags to wildcard IP DSCP and ECN.
It's no longer necessary to maintain a "nw_tos_mask" wildcard member,
since we only care about completely wildcarding the DSCP and ECN
portions of the IP TOS field.  This commit makes that change.  It also
goes a bit further in internally using "tos" to refer to the entire TOS
field (ie, DSCP and ECN).  We must still refer to the DSCP portions as
"nw_tos" externally through OpenFlow 1.0, since that's the convention it
uses.
2011-11-10 18:03:05 -08:00
Justin Pettit
209c0b17d9 classifier: Don't check masks when adding IPv4/IPv6 addresses.
The meta-flow code enforces IPv4/IPv6 masks, so there's no reason to do
it again in the classifier.  This allows a number of functions to be
removed, since the only callers were in this classifier code.
2011-11-10 18:03:04 -08:00
Justin Pettit
eadef31329 Prepend "nw_" to "frag" and "tos" elements.
Most of the members in structures referring to network elements indicate
the layer (e.g., "tl_", "nw_", "tp_").  The "frag" and "tos" members
didn't, so this commit add them.
2011-11-10 18:03:04 -08:00