2
0
mirror of https://github.com/openvswitch/ovs synced 2025-08-28 21:07:47 +00:00

74 Commits

Author SHA1 Message Date
Jarno Rajahalme
a6fd70bb89 ofp-actions: Set-Field OF 1.0/1.1 compatibility.
Output set field actions as standard OF1.0/1.1 set actions or to
reg_load instructions, when a compatible set action(s) do not exist.

Signed-off-by: Jarno Rajahalme <jrajahalme@nicira.com>
Signed-off-by: Ben Pfaff <blp@nicira.com>
2013-11-01 16:02:57 -07:00
Jarno Rajahalme
b2dd70be13 Native Set-Field action.
Signed-off-by: Jarno Rajahalme <jrajahalme@nicira.com>
Signed-off-by: Ben Pfaff <blp@nicira.com>
2013-11-01 15:43:59 -07:00
Jarno Rajahalme
64fcc07313 OF 1.1 pop vlan compatibility.
Store the original action code with the strip vlan action,
so that it can be printed back properly.

Signed-off-by: Jarno Rajahalme <jrajahalme@nicira.com>
Signed-off-by: Ben Pfaff <blp@nicira.com>
2013-11-01 14:09:54 -07:00
Jarno Rajahalme
ca287d2062 OF 1.1 set vlan vid/pcp compatibility.
OpenFlow 1.1 set vlan actions only modify existing vlan
headers, while OF 1.0 actions push a new vlan header if one
does not exist already.

Signed-off-by: Jarno Rajahalme <jrajahalme@nicira.com>
Signed-off-by: Ben Pfaff <blp@nicira.com>
2013-11-01 14:07:40 -07:00
Jarno Rajahalme
8621547cc9 lib/ofp-actions: Enforce action consistency.
OpenFlow 1.1+ specs encourage switches to verify action consistency
at flow setup time.  Implement this for OpenFlow 1.1+ only to not
break any current OF 1.0 based use.

Signed-off-by: Jarno Rajahalme <jrajahalme@nicira.com>
Signed-off-by: Ben Pfaff <blp@nicira.com>
2013-10-23 13:52:24 -07:00
Ben Pfaff
dba70df0cb ofp-actions: Make union ofp_action more generic.
Make union ofp_action more generic by allowing it to be used for
all actions.  OFP_ACTION_ALIGN (which is 8, as the sizeof(union
ofp_action) used to be) is now used where sizeof union ofp_action
was used before.  On the same note, variable name 'n_actions' is
changed to 'max_actions' as the number of actions cannot be simply
divided when actions have various sizes.

Signed-off-by: Jarno Rajahalme <jrajahalme@nicira.com>
Signed-off-by: Ben Pfaff <blp@nicira.com>
2013-10-23 13:47:04 -07:00
Jarno Rajahalme
0c20dbe410 Add OF11 SET IP TTL action.
Signed-off-by: Jarno Rajahalme <jrajahalme@nicira.com>
Signed-off-by: Ben Pfaff <blp@nicira.com>
2013-10-23 10:24:31 -07:00
Jarno Rajahalme
ff14eb7ac9 Add OF11 set IPv4 ECN action.
Signed-off-by: Jarno Rajahalme <jrajahalme@nicira.com>
Signed-off-by: Ben Pfaff <blp@nicira.com>
2013-10-23 10:05:14 -07:00
Ben Pfaff
04f01c24b5 Allow OFPACT_SET_IP_DSCP to act on both IPv4 and IPv6 packets.
This removes semantic differences between different OpenFlow
versions, making it easier to translate between them.
Also, rename OFPACT_SET_IPV4_DSCP to OFPACT_SET_IP_DSCP.

Signed-off-by: Jarno Rajahalme <jrajahalme@nicira.com>
Signed-off-by: Ben Pfaff <blp@nicira.com>
2013-10-23 09:58:44 -07:00
Joe Stringer
a7a2d006ba ofp-actions: Distinguish OF1.1/1.2 push_mpls from OF1.3+.
In OpenFlow 1.1 and 1.2, the push_mpls action pushes the MPLS label after
any existing VLAN tag.  In OpenFlow 1.3, it pushes the label before any
existing VLAN tag.  Until now, the action parser didn't distinguish these
cases.  This commit adds support.  Nothing yet actually changes the
behavior of push_mpls.

enum ofpact_mpls_position contributed by Ben Pfaff.

Signed-off-by: Joe Stringer <joe@wand.net.nz>
Signed-off-by: Simon Horman <horms@verge.net.au>
Signed-off-by: Ben Pfaff <blp@nicira.com>
2013-10-21 13:12:37 -07:00
Jarno Rajahalme
e45e72f1de include/openflow: Move union ofp_action away from headers.
union ofp_action cannot remain in the OF 1.0 header as it is expanded
to include actions from later versions.  Also, it is not part of the
protocol interface and will be easier to update where it is actually
used.

Signed-off-by: Jarno Rajahalme <jrajahalme@nicira.com>
Signed-off-by: Ben Pfaff <blp@nicira.com>
2013-10-17 11:47:52 -07:00
YAMAMOTO Takashi
3d7e1e9432 ofp-actions: Consistently use helper function.
No functional changes.

Signed-off-by: YAMAMOTO Takashi <yamamoto@valinux.co.jp>
Signed-off-by: Ben Pfaff <blp@nicira.com>
2013-10-17 09:55:00 -07:00
YAMAMOTO Takashi
2b11907b15 ofp-actions: Fix some ofpbuf usage problems in write-actions code.
This code kept a pointer to data that might have been reallocated.

For longer term, "nested" variants of some ofpact functions
which using ofpbuf->l3 might be desirable.

Signed-off-by: YAMAMOTO Takashi <yamamoto@valinux.co.jp>
Signed-off-by: Ben Pfaff <blp@nicira.com>
2013-10-17 08:53:51 -07:00
Simon Horman
7fdb60a758 Add support for write-actions
Implementation note:

All actions which modify a field are added to the action set
at the point where "set" actions should be added. In general
modifying a field many times is the same as only modifying it
the last time so the implementation simply adds all set actions to
the action set in the order they are specified. However, this breaks
down if two actions modify different portions of the same field.

Some examples.

1. load acting a subfield
2. mod_vlan_vid, mod_vlan_pcp

If this is considered to be a problem one possible solution would be to
either disallow all set actions other than set_field in write_actions.
Another possible solution is prohibit problematic the actions listed above
in write actions.

Signed-off-by: Simon Horman <horms@verge.net.au>
[blp@nicira.com simplified and edited the code]
Signed-off-by: Ben Pfaff <blp@nicira.com>
2013-10-14 15:20:03 -07:00
Ben Pfaff
455ecd775d ofp-actions: Make ofpacts_format() caller add "actions=" if it wants it.
An upcoming caller doesn't want it.

Signed-off-by: Ben Pfaff <blp@nicira.com>
2013-10-14 14:08:20 -07:00
Jarno Rajahalme
6a8a8528ac Suppress warnings about unused variables and functions.
These variables and functions are unused but we don't want to remove
their definitions.

Found by Clang.

Signed-off-by: Jarno Rajahalme <jrajahalme@nicira.com>
Signed-off-by: Ben Pfaff <blp@nicira.com>
Acked-by: Ethan Jackson <ethan@nicira.com>
2013-09-27 16:27:41 -07:00
Ben Pfaff
b826639572 openvswitch/types.h: New macros OVS_BE16_MAX, OVS_BE32_MAX, OVS_BE64_MAX.
These seem slightly nicer than e.g. htons(UINT16_MAX).

Signed-off-by: Ben Pfaff <blp@nicira.com>
2013-09-17 16:17:26 -07:00
Ben Pfaff
d6fb622dcb ofproto: Move function find_meter() into ofpacts as ofpacts_get_meter().
ofproto is too big anyway so we might as well move out code that can
reasonably live elsewhere.

Signed-off-by: Ben Pfaff <blp@nicira.com>
Acked-by: Ethan Jackson <ethan@nicira.com>
2013-09-12 17:43:05 -07:00
Neil Zhu
7395c05254 Implement OpenFlow 1.1+ "groups" protocol.
This doesn't include a dpif implementation of groups functionality.  In its
current form, it is untested.

Signed-off-by: Neil Zhu <zhuj@centecnetworks.com>
Co-authored-by: Ben Pfaff <blp@nicira.com>
Signed-off-by: Ben Pfaff <blp@nicira.com>
Co-authored-by: Simon Horman <horms@verge.net.au>
Signed-off-by: Simon Horman <horms@verge.net.au>
Co-authored-by: Jarno Rajahalme <jrajahalme@nicira.com>
Signed-off-by: Jarno Rajahalme <jrajahalme@nicira.com>
2013-09-02 09:23:49 -07:00
Alex Wang
db5a101931 clang: Fix the alignment warning.
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-23 12:34:41 -07:00
Jarno Rajahalme
e3b5693319 Fix table checking for goto table instruction.
Usually the table id in flow mods is 255, which means that goto table
instruction cannot be checked before the table is picked (for flow add),
or the rules to be modified are found (flow mod).

Move goto table checking from decode (ofp-util) to actions checking
(ofp-actions), and postpone the action checking until the table in
which the actions are added is known.

This fixes OFPBRC_BAD_TABLE_ID errors for flow adds that specify the table
id as 255, and have a goto table instruction.

Signed-off-by: Jarno Rajahalme <jarno.rajahalme@nsn.com>
Signed-off-by: Ben Pfaff <blp@nicira.com>
2013-06-28 10:22:26 -07:00
Jarno Rajahalme
9cae45dc69 ofproto: Implement OpenFlow 1.3 meter table.
Signed-off-by: Jarno Rajahalme <jarno.rajahalme@nsn.com>
Co-authored-by: Ben Pfaff <blp@nicira.com>
Signed-off-by: Ben Pfaff <blp@nicira.com>
2013-06-28 09:41:18 -07:00
Ben Pfaff
084c53de85 ofpact: New function ovs_instruction_type_from_ofpact_type().
Signed-off-by: Ben Pfaff <blp@nicira.com>
2013-06-28 09:09:45 -07:00
Ben Pfaff
ba0bc9b06f ofp-actions: Give ovs_instruction funcs names that start with that prefix.
This seems slightly clearer, because ofpact_instruction_* makes me look
for a type named ofpact_instruction.

Signed-off-by: Ben Pfaff <blp@nicira.com>
2013-06-28 09:09:45 -07:00
Ben Pfaff
f4104c6882 ofp-errors: New error code ONFBIC_DUP_INSTRUCTION.
This is a prototype of OpenFlow enhancement proposal EXT-260 "Add error
code for duplicate instruction."  It uses the error code proposed there.

Signed-off-by: Ben Pfaff <blp@nicira.com>
2013-06-25 10:52:21 -07:00
Jarno Rajahalme
638a19b045 ofp-util: Support for OpenFlow 1.3 meters.
Signed-off-by: Jarno Rajahalme <jarno.rajahalme@nsn.com>
Signed-off-by: Ben Pfaff <blp@nicira.com>
2013-06-25 10:34:09 -07:00
Jarno Rajahalme
eca39bced3 ofpacts_check: Remove unnecessary flow copying.
Signed-off-by: Jarno Rajahalme <jarno.rajahalme@nsn.com>
Signed-off-by: Ben Pfaff <blp@nicira.com>
2013-06-24 10:12:21 -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
Ben Pfaff
5014a89d93 ofp-util: Don't return static data in ofputil_packet_in_reason_to_string().
Returning a static data buffer makes code more brittle and definitely
not thread-safe, so this commit switches to using a caller-provided
buffer instead.

Signed-off-by: Ben Pfaff <blp@nicira.com>
2013-06-10 11:13:54 -07:00
Jing Ai
bff7eeb648 ofp-actions: enforce valid range for table_id in goto_table instruction
Found a bug that OVS allows goto_table_id to be smaller than (or equal to)
the current table id where the flow resides. It potentially creates an
infinite loop when composing actions for a packet. To fix it, we just let
OVS returns an error message to prevent such flow to be programmed.

Signed-off-by: Jing Ai <jinga@google.com>
Signed-off-by: Ben Pfaff <blp@nicira.com>
2013-06-05 13:34:25 -07:00
Simon Horman
e655542cf3 Always use valid ids pointer in dec_ttl_cnt_ids_from_openflow()
Always update the ids pointer after calling ofpbuf_put()
to ensure that it is valid when accessed.

During testing a case came up where the call to ofpbuf_put() in the
for (i = 0; i < ids->n_controllers; i++) loop would cause the underlying
buffer to be reallocated. This resulted in ids->n_controllers being an
incorrect value, the loop continuing on longer than desired and finally a
segmentation fault.

Reported-by: Joe Stringer <joe@wand.net.nz>
Signed-off-by: Simon Horman <horms@verge.net.au>
Signed-off-by: Ben Pfaff <blp@nicira.com>
2013-06-04 10:23:06 -07:00
Simon Horman
500d243dad Use updated dl_type when checking actions that use fields
Update handling of the following actions to use the dl_type set by MPLS
push and pop actions if it differs from the original dl_type. This is
consistent with the existing checking of load actions and allows
their existing checks to enforce dl_type pre-requisites correctly.

	output_reg
	bundle
	reg_move
	stack_push
	stack_pop
	learn
	multipath

In order to avoid the verbosity of updating the flow for each applicable
action the update is treated as a common case and performed in
ofpact_check().  This was suggested by Jesse Gross.

Cc: Jesse Gross <jesse@nicira.com>
Signed-off-by: Simon Horman <horms@verge.net.au>
Signed-off-by: Jesse Gross <jesse@nicira.com>
2013-05-10 09:16:34 -07:00
Romain Lenglet
29089a540c Implement IPFIX export
Define a new NXAST_SAMPLE OpenFlow vendor action and the corresponding
OFPACT_SAMPLE OVS action, to do per-flow packet sampling, translated
into a new SAMPLE "flow_sample" dp action.

Make the userspace action's userdata size vary depending on the union
member used.  Add a new "flow_sample" upcall to do per-flow packet
sampling.  Add a new "ipfix" upcall to do per-bridge packet sampling
to IPFIX collectors.

Extend the OVSDB schema to support configuring IPFIX collector sets.
Add support for configuring multiple IPFIX collectors for per-flow
packet sampling.  Add support for configuring per-bridge IPFIX
sampling.

Automatically generate standard IPFIX entity definitions from the IANA
specs.  Send one IPFIX data record message for every packet sampled by
an OpenFlow sample action or received by a bridge configured with
IPFIX sampling, and periodically send IPFIX template set messages.

Signed-off-by: Romain Lenglet <rlenglet@vmware.com>
Signed-off-by: Ben Pfaff <blp@nicira.com>
2013-04-22 14:33:58 -07:00
Andy Zhou
bd85dac14e nicira-ext: Add Nicira actions NXAST_STACK_PUSH and NXAST_STACK_POP.
The Push action takes a single parameter. Any source allowed by NXAST_REG_MOVE
is allowed to be pushed onto the stack. When the source is a bit field,
its value will be right shifted to bit zero before being pushed onto the
stack. The remaining bits will be set to zero.

The Pop action also takes a single parameter. Any destination allowed by
NXAST_REG_MOVE can be used as the destination of the action. The value, in
case of a bit field, will be taken from top of the stack, starting from
bit zero.

The stack size is not limited. The initial 8KB is statically allocated to
efficiently handle most common use cases. When more stack space is
required, the stack can grow using malloc().

Signed-off-by: Andy Zhou <azhou@nicira.com>
Signed-off-by: Ben Pfaff <blp@nicira.com>
2013-03-06 13:40:28 -08:00
Simon Horman
0f3f3c3db0 Add support for set_mpls_ttl action
This adds support for the OpenFlow 1.1+ set_mpls_ttl action.
And also adds an NX set_mpls_ttl action.

The handling of the TTL modification is entirely handled in userspace.

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-03-06 08:50:43 -08:00
Simon Horman
b676167a6f Add support for dec_mpls_ttl action
This adds support for the OpenFlow 1.1+ dec_mpls_ttl action.
And also adds an NX dec_mpls_ttl action.

The handling of the TTL modification is entirely handled in userspace.

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-03-06 08:28:42 -08:00
Ethan Jackson
1bda9b9e1a nicira-ext: Remove the autopath action.
The autopath action was attempting to achieve functionality similar
to the bundle action, but was significantly clunkier, more
difficult to understand, more difficult to use, and less reliable.
This patch removes it.

Signed-off-by: Ethan Jackson <ethan@nicira.com>
2013-02-05 12:50:17 -08: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
Ben Pfaff
cb22974d77 Replace most uses of assert by ovs_assert.
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>
2013-01-16 16:03:37 -08:00
Ben Pfaff
6813ee7c06 ofp-actions: Fix the check for instruction ordering and duplication.
Open vSwitch enforces that, when instructions appear as Nicira extensions
in OpenFlow 1.0 action lists, the instructions appear in the order that
an OpenFlow 1.1+ switch would execute them and that no duplicates appear.
But the check wasn't general enough, because it had been implemented when
only one instruction was implemented and never later generalized.  This
commit fixes the problem.

One of the tests was actually testing for the wrong behavior that the
check implemented, so this commit corrects that test.  It also updates
another test with updated log messages.

Reported-by: Jing Ai <ai_jing2000@hotmail.com>
Tested-by: Jing Ai <ai_jing2000@hotmail.com>
Signed-off-by: Ben Pfaff <blp@nicira.com>
2013-01-03 12:22:16 -08:00
Ethan Jackson
5dca28b517 ovs: Replace TODO:XXX with XXX.
According to the coding style, XXX is the appropriate tag for code
that needs work.

Signed-off-by: Ethan Jackson <ethan@nicira.com>
2012-12-21 15:24:21 -08:00
Ben Pfaff
ed36537ebf packets: Change IP_ARGS interface to take an ovs_be32 instead of a pointer.
An ovs_be32 is a more obvious way to represent an IP address than a
pointer to one.  It is also more type-safe, especially since "sparse" is
able to check that the argument is in network byte order.

Signed-off-by: Ben Pfaff <blp@nicira.com>
Acked-by: Ethan Jackson <ethan@nicira.com>
2012-12-12 15:26:21 -08:00
Jarno Rajahalme
1554987853 Don't use error categories as if they were actually errors.
The OFPERR_* naming scheme is confusing, because it mixes categories with
specific errors.  Categories can't be encoded for sending to controllers,
so this is a problem.  This commit fixes up the cases where categories
were used as errors, replacing them by real errors types.

Signed-off-by: Jarno Rajahalme <jarno.rajahalme@nsn.com>
Signed-off-by: Ben Pfaff <blp@nicira.com>
2012-12-04 08:25:55 -08:00
Jarno Rajahalme
31a9e63f0f include/openflow: Moved remaining common definitions from openflow-1.0.h
Moved remaining common definitions from openflow-1.0.h to
 openflow-common.h and renamed 1.0 specific definitions with
 the "10" infix. Added hstamp rules for new headers, fixed
 non-ASCII characters in openflow-1.3.h, Commented out
 trailing zero-length data members.

Signed-off-by: Jarno Rajahalme <jarno.rajahalme@nsn.com>
Signed-off-by: Ben Pfaff <blp@nicira.com>
2012-12-03 13:03:06 -08:00
Simon Horman
276c4e7a24 ofp-actions: Add OpenFlow1.1+ Set Queue action
Signed-off-by: Simon Horman <horms@verge.net.au>
Signed-off-by: Ben Pfaff <blp@nicira.com>
2012-11-30 13:32:10 -08:00
Isaku Yamahata
3e34fbdd62 OF11: push_vlan support
This implementes push_vlan with 802.1Q.
NOTE: 802.1AD (QinQ) is not supported. It requires another effort.

Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp>
Signed-off-by: Ben Pfaff <blp@nicira.com>
2012-10-26 09:49:05 -07:00
Joe Stringer
4cceacb94c ofp-actions: Implement writing to metadata field
In OpenFlow 1.1, we add support for OFPIT_WRITE_METADATA. This allows us to
write to the metadata field. Internally it is represented using ofpact_metadata.

We introduce NXAST_WRITE_METADATA to handle writing to the metadata field in
OpenFlow 1.0+. This structure reflects OFPIT_WRITE_METADATA.

When writing out the structure to OpenFlow 1.1, it uses the OFPIT_WRITE_METADATA
instruction only, and not the new NXAST action (which would be redundant).

Signed-off-by: Joe Stringer <joe@wand.net.nz>
Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp>
Signed-off-by: Ben Pfaff <blp@nicira.com>
2012-10-18 12:44:54 -07:00
Ben Pfaff
9908606290 ofp-actions: Prefer OFPAT11_DEC_TTL to NXAST_DEC_TTL for OpenFlow 1.1+.
When "dec_ttl" is specified as the name of an action, in OpenFlow 1.1 and
later we should prefer to use the standardized action, rather than the
Nicira extension.

Reported-by: Isaku Yamahata <yamahata@valinux.co.jp>
Signed-off-by: Ben Pfaff <blp@nicira.com>
Reviewed-by: Isaku Yamahata <yamahata@valinux.co.jp>
2012-10-18 11:39:28 -07:00
Isaku Yamahata
8e61c1104e ofpaction: support OF11 pop_vlan
This patch adds support of OF11+ pop_vlan.

Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp>
[blp@nicira.com added a test]
Signed-off-by: Ben Pfaff <blp@nicira.com>
2012-10-18 10:36:07 -07:00
Isaku Yamahata
7bcb1506ee lib: support OF11 dec_nw_ttl
Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp>
[blp@nicira.com changed code to use "dec_ttl" instead of "dec_nw_ttl"]
Signed-off-by: Ben Pfaff <blp@nicira.com>
2012-10-18 08:52:57 -07:00