2
0
mirror of https://github.com/openvswitch/ovs synced 2025-08-29 13:27:59 +00:00

148 Commits

Author SHA1 Message Date
Ben Pfaff
e8fa940e4a ofp-print: Slightly extend ofp_print_bit_names().
In an upcoming commit I want to print comma-separated, not space-separated,
names for a set of bits.

Signed-off-by: Ben Pfaff <blp@nicira.com>
2012-07-12 14:12:56 -07:00
Ben Pfaff
de0f16bc0b ofp-print: Print out_port field in "flow_mod"s.
Somehow we've overlooked this for a long time.  I guess that feature
doesn't get used very much.

Also updates the test output for OFPT_FLOW_MOD to include the out_port
output and adds out_port to the NXT_FLOW_MOD tests.

Signed-off-by: Ben Pfaff <blp@nicira.com>
2012-07-12 14:09:34 -07:00
Ben Pfaff
bdcc592595 ovs-ofctl: Add --sort and --rsort options for "dump-flows" command.
Feature #8754.
Signed-off-by: Arun Sharma <arun.sharma@calsoftinc.com>
[blp@nicira.com rewrote most of the code]
Signed-off-by: Ben Pfaff <blp@nicira.com>
2012-07-12 13:32:47 -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
Ben Pfaff
690a61c50a ofp-util: Add OFPUTIL_ACTION_INVALID to enum ofputil_action_code.
Possibly the ofputil_decode_action() interface should be rethought now
that ofputil_action_code has an invalid value.

Reviewed-by: Simon Horman <horms@verge.net.au>
Signed-off-by: Ben Pfaff <blp@nicira.com>
2012-07-03 22:21:11 -07:00
Simon Horman
4232ef7755 openflow: Add Open Flow 1.2 to ofp_to_string__()
Signed-off-by: Simon Horman <horms@verge.net.au>
[blp@nicira.com fixed testsuite failure.]
Signed-off-by: Ben Pfaff <blp@nicira.com>
2012-06-27 14:07:47 -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
Justin Pettit
623e1caf2f ofp-util: Clean up cookie handling.
Commit e72e793 (Add ability to restrict flow mods and flow stats
requests to cookies.) modified cookie handling.  Some of its behavior
was unintuitive and there was at least one bug (described below).
Commit f66b87d (DESIGN: Document uses for flow cookies.) attempted to
document a clean design for cookie handling.  This commit updates the
DESIGN document and brings the implementation in line with it.

In commit e72e793, the code that handled processing OpenFlow flow
modification requests set the cookie mask to exact-match.  This seems
reasonable for adding flows, but is not correct for matching, since
OpenFlow 1.0 doesn't support matching based on the cookie.  This commit
changes to cookie mask to fully wildcarded, which is the correct
behavior for modifications and deletions.  It doesn't cause any problems
for flow additions, since the mask is ignored for that operation.

Bug #9742

Reported-by: Luca Giraudo <lgiraudo@nicira.com>
Reported-by: Paul Ingram <paul@nicira.com>
Signed-off-by: Justin Pettit <jpettit@nicira.com>
2012-05-29 01:41:21 -07:00
Ben Pfaff
f5cd6874f1 Avoid writes to variables that are never read back.
Found by clang.

Signed-off-by: Ben Pfaff <blp@nicira.com>
2012-05-14 09:37:18 -07:00
Justin Pettit
2be393edd3 ofproto: Add support for OF1.3 port description multipart message.
OpenFlow 1.0 is limited to displaying 1364 ports in the Features Reply
message, and there is no other way to get consolidated port information.
OpenFlow 1.3 adds a new port description multipart message
(OFPMP_PORT_DESC) that is not limited by size.  This commit adds support
through the OpenFlow 1.0 stats mechanism, since they have complimentary
enum values.

Bug #11040

Signed-off-by: Justin Pettit <jpettit@nicira.com>
2012-05-08 09:51:43 -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
b9718b7ba7 ofp-print: Add some more white space to flow dumps.
Before idle_age and hard_age were added, in the absence of timeouts there
was a space between the statistics for a flow and the start of the flow
match.  This restores that space.

Requested-by: Paul Ingram <paul@nicira.com>
Signed-off-by: Ben Pfaff <blp@nicira.com>
2012-05-01 15:21:39 -07:00
Simon Horman
04f68eb209 Add some missing Open Flow 1.1 definitions
Signed-off-by: Simon Horman <horms@verge.net.au>
[blp@nicira.com added OFPRR_GROUP_DELETE to
 ofp_flow_removed_reason_to_string()]
Signed-off-by: Ben Pfaff <blp@nicira.com>
2012-03-30 09:14:04 -07:00
Ben Pfaff
9e1fd49b0c Abstract everything that uses ofp_phy_port, add OF1.1 support.
Reviewed-by: Simon Horman <horms@verge.net.au>
Signed-off-by: Ben Pfaff <blp@nicira.com>
2012-03-07 14:05:11 -08:00
Ben Pfaff
08f94c0e1a openflow: Split OFPAT_* into OFPAT10_* and OFPAT11_*.
An upcoming commit will start referring to OpenFlow 1.1 actions, which are
renumbered relative to OpenFlow 1.0 actions, so this commit prepares by
changing all the existing uses of OFPAT_* to instead use OFPAT10_*.

This commit also introduces the OFPAT11_* constants.

Reviewed-by: Simon Horman <horms@verge.net.au>
Signed-off-by: Ben Pfaff <blp@nicira.com>
2012-03-07 14:05:10 -08:00
Ben Pfaff
3811e66bb6 ofp-print: Print OpenFlow version number of message, unless it's 1.0.
The version number is an important part of the OpenFlow message's
meaning, so include it.  Version 1.0 is grandfathered in so existing output
parsers don't have to change.

Reviewed-by: Simon Horman <horms@verge.net.au>
Signed-off-by: Ben Pfaff <blp@nicira.com>
2012-03-07 14:05:08 -08:00
Ben Pfaff
27527aa09c Introduce ofputil_protocol, to abstract the protocol in use on a connection.
Open vSwitch already handles a few different protocol variations, but it
does so in a nonuniform manner:

  - OpenFlow 1.0 and NXM flow formats are distinguished using the NXFF_*
    constant values from nicira-ext.h.

  - The "flow_mod_table_id" feature setting is maintained in ofproto as
    part of an OpenFlow connection's (ofconn's) state.

There's no way to easily communicate this state among components.  It's
not much of a problem yet, but as more protocol support is added it seems
better to have an abstract, uniform way to represent protocol versions and
variants.  This commit implements that by introducing a new type
"enum ofputil_protocol".  Each ofputil_protocol value represents a variant
of a protocol version.  Each value is a separate bit, so a single enum
can also represent a set of protocols, which is often useful as well.

Reviewed-by: Simon Horman <horms@verge.net.au>
Signed-off-by: Ben Pfaff <blp@nicira.com>
2012-03-07 13:59:02 -08:00
Ben Pfaff
032f3fbd85 ofp-print: Remove unused function ofp_message_type_to_string().
ofputil_msg_type_name() is a better interface.

Reviewed-by: Simon Horman <horms@verge.net.au>
Signed-off-by: Ben Pfaff <blp@nicira.com>
2012-03-07 13:59:01 -08:00
Ben Pfaff
a7349929fb Add ability to direct "packet-in"s to particular controllers.
Nicira's controllers are somewhat heterogeneous, so that particular
"packet-in" messages should be directed to particular controllers.  This
new Nicira extension action allows designating a controller or controllers
to receive the "packet-in" using a 16-bit integer ID.

The new NXAST_CONTROLLER action also specifies the "reason" code to include
in the "packet-in" message.  This is particularly useful for simulating a
"no-match" "packet-in" using a rule.

Feature #8946.
Signed-off-by: Ben Pfaff <blp@nicira.com>
2012-02-27 13:21:44 -08:00
Ben Pfaff
7c1a76a467 ofp-util: New functions for string versions of ofp_packet_in_reason.
Upcoming commits add a user for ofputil_packet_in_reason_from_string()
and more users for ofputil_packet_in_reason_to_string().

Signed-off-by: Ben Pfaff <blp@nicira.com>
2012-02-27 13:21:43 -08:00
Ben Pfaff
0e553d9c10 Implement new "fin_timeout" action and "learn" feature.
The "learn" action can create matching return flows.  If those have a long
timeout then it's a good idea to have a way to notice when in fact the
flows have terminated.  This new action and matching "learn" feature
provides that way.

Feature #8603.
Signed-off-by: Ben Pfaff <blp@nicira.com>
2012-02-15 10:37:03 -08:00
Ethan Jackson
2953097759 ofp-print: Fix compiler warning.
Signed-off-by: Ethan Jackson <ethan@nicira.com>
2012-02-09 01:55:48 -08:00
Ben Pfaff
80d5aefd65 ofproto: Implement OpenFlow extension to allow control over async messages.
Until now, the rules that cover the asynchronous messages that Open vSwitch
sends to a controller have been ad hoc.  The new NXT_SET_ASYNC_CONFIG
message provides systematic, precise control.

Feature #7086.
Signed-off-by: Ben Pfaff <blp@nicira.com>
2012-02-09 14:06:35 -08:00
Ben Pfaff
a993007bee Add support for parsing and printing OFPFF_* flags.
I intend to use OFPFF_SEND_FLOW_REM in upcoming unit tests.  I threw in
OFPFF_CHECK_OVERLAP also because it didn't cost me anything.  I omitted
parsing support for OFPFF_EMERG because we opposed its inclusion from the
start and it was removed from OpenFlow 1.2.

Signed-off-by: Ben Pfaff <blp@nicira.com>
2012-02-09 13:23:36 -08:00
Ben Pfaff
c6a93eb711 ofp-util: Add struct ofputil_packet_out, helper functions, and use it all.
This makes the ofp-util support for packet_out better match the support
that ofp-util has for other OpenFlow messages.  It also prepares for an
upcoming patch that adds a new piece of code that generates packet_out
messages.

Signed-off-by: Ben Pfaff <blp@nicira.com>
2012-02-09 13:23:36 -08:00
Ben Pfaff
aae410b9dc ofp-print: Fix up doubled "break;".
Reported-by: Justin Pettit <jpettit@nicira.com>
Signed-off-by: Ben Pfaff <blp@nicira.com>
2012-02-08 11:23:37 -08:00
Ben Pfaff
f27f21341a Add information about time left before timeouts to flow dumps.
The "learn" action is useful for MAC learning, but until now there has been
no way to find out through OpenFlow how much time remains before a MAC
learning entry (a learned flow) expires.  This commit adds that ability.

Feature #7193.
Signed-off-by: Ben Pfaff <blp@nicira.com>
2012-02-07 15:48:53 -08:00
Ben Pfaff
3370cd3c3c ofp-print: Merge two cases in ofp_to_string__().
It looks like other cases are merged this way, so make this one consistent.

Signed-off-by: Ben Pfaff <blp@nicira.com>
2012-02-07 15:12:04 -08: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
Pravin B Shelar
f0fd1a1772 ofproto: New action TTL decrement.
Following patch implements dec_ttl as vendor action with similar
semantics as OpenFlow 1.2. If TTL reaches zero while procession
actions in current table, the remaining actions in previous tables
are processed. A configuration parameter is added to make TTL
decrement to zero generate packet in.

Feature #8758
Signed-off-by: Pravin B Shelar <pshelar@nicira.com>
2012-01-13 17:54:04 -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
73dbf4abd1 nicira-ext: Rename "struct nxt_*" to "struct nx_*".
Most structures in this file have an "nx_" prefix, so this makes naming
more consistent.

Signed-off-by: Ben Pfaff <blp@nicira.com>
2012-01-12 11:35:50 -08:00
Ethan Jackson
5483496034 openflow: New Nicira Extended PACKET_IN format.
The new PACKET_IN format implemented in this patch includes flow
metadata such as the cookie, table_id, and registers.

Signed-off-by: Ethan Jackson <ethan@nicira.com>
2012-01-10 14:30:15 -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
Ethan Jackson
65120a8a4e ofputil: New function ofputil_decode_packet_in().
Signed-off-by: Ethan Jackson <ethan@nicira.com>
2012-01-10 14:30:15 -08:00
Ethan Jackson
e50abca5be ofp-print: Print checksum in ofp_packet_to_string().
This will improve the unit tests of future patches.

Signed-off-by: Ethan Jackson <ethan@nicira.com>
2012-01-10 14:30:14 -08:00
Ethan Jackson
897a8e0791 ofp-print: Remove tcpdump from ofp_packet_to_string().
Instead this patch uses flow_format() which gives very similar
output.  This patch will improve the reliability of unit tests in
future patches which rely on the results of ofp_packet_to_string().

Signed-off-by: Ethan Jackson <ethan@nicira.com>
2012-01-10 14:30:14 -08:00
Ethan Jackson
c499c75db6 ofp-print: Remove vestigial 'total_len' argument.
ofp_print_packet() and ofp_packet_to_string() don't use the
'total_len' argument which they require callers to supply.

Signed-off-by: Ethan Jackson <ethan@nicira.com>
2012-01-10 14:29:17 -08:00
Pravin B Shelar
abff858b5a datapath: Convert kernel priority actions into match/set.
Following patch adds skb-priority to flow key. So userspace will know
what was priority when packet arrived and we can remove the pop/reset
priority action. It's no longer necessary to have a special action for
pop that is based on the kernel remembering original skb->priority.
Userspace can just emit a set priority action with the original value.

Since the priority field is a match field with just a normal set action,
we can convert it into the new model for actions that are based on
matches.

Signed-off-by: Pravin B Shelar <pshelar@nicira.com>
Acked-by: Jesse Gross <jesse@nicira.com>

Bug #7715
2011-11-01 10:13:16 -07:00
Ethan Jackson
848e88098f nicira-ext: New action "exit".
The exit action causes the switch to immediately halt processing of
further actions. It's intended to be used in conjunction with
multi table support.  It allows a table to force tables which call
it to discontinue processing a flow.
2011-10-28 18:16:40 -07:00
Ben Pfaff
fdc5d61fb7 ofp-print: Pretty-print payloads in all error messages, except "hello"s.
This function was only pretty-printing "bad request" error payloads.  I
don't know why.  It makes sense to pretty-print all of them except for
"hello" messages, which already have their own special cases.

Suggestion #7369.
Suggested-by: Reid Price <reid@nicira.com>
2011-10-27 10:50:18 -07:00
Ben Pfaff
7257b535ab Implement new fragment handling policy.
Until now, OVS has handled IP fragments more awkwardly than necessary.  It
has not been possible to match on L4 headers, even in fragments with offset
0 where they are actually present.  This means that there was no way to
implement ACLs that treat, say, different TCP ports differently, on
fragmented traffic; instead, all decisions for fragment forwarding had to
be made on the basis of L2 and L3 headers alone.

This commit improves the situation significantly.  It is still not possible
to match on L4 headers in fragments with nonzero offset, because that
information is simply not present in such fragments, but this commit adds
the ability to match on L4 headers for fragments with zero offset.  This
means that it becomes possible to implement ACLs that drop such "first
fragments" on the basis of L4 headers.  In practice, that effectively
blocks even fragmented traffic on an L4 basis, because the receiving IP
stack cannot reassemble a full packet when the first fragment is missing.

This commit works by adding a new "fragment type" to the kernel flow match
and making it available through OpenFlow as a new NXM field named
NXM_NX_IP_FRAG.  Because OpenFlow 1.0 explicitly says that the L4 fields
are always 0 for IP fragments, it adds a new OpenFlow fragment handling
mode that fills in the L4 fields for "first fragments".  It also enhances
ovs-ofctl to allow users to configure this new fragment handling mode and
to parse the new field.

Signed-off-by: Ben Pfaff <blp@nicira.com>
Bug #7557.
2011-10-21 15:07:36 -07:00
Ben Pfaff
3ee8a9f002 openflow: Delete icmp_type and icmp_code macros.
These macros caused trouble if datapath-protocol.h was included before
openflow.h.  Later references to the icmp_type and icmp_code members of
struct ovs_key_icmp caused compiler errors, because the macros caused them
to try to refer to nonexistent tp_src and tp_dst members in those
structures.
2011-10-11 10:37:25 -07:00
Ben Pfaff
05b8f1c2b4 ofp-print: Avoid double space before "actions" for catch-all flows.
Bug #7434.
Reported-by: Michael Mao <mmao@nicira.com>
2011-09-22 14:35:05 -07:00
Ben Pfaff
75a7504356 Implement new "learn" action.
There are a few loose ends here.  First, learning actions cause too much
flow revalidation.  Upcoming commits will fix that problem.  The following
additional issues have not yet been addressed:

    * Resource limits: nothing yet limits the maximum number of flows that
      can be learned.  It is possible to exhaust all system memory.

    * Age reporting: there is no way to find out how soon a learned table
      entry is due to be evicted.

To try this action out, here's a recipe for a very simple-minded MAC
learning switch.  It uses a 10-second MAC expiration time to make it easier
to see what's going on:

ovs-vsctl del-controller br0
ovs-ofctl del-flows br0
ovs-ofctl add-flow br0 "table=0 actions=learn(table=1, hard_timeout=10, \
	NXM_OF_VLAN_TCI[0..11], NXM_OF_ETH_DST[]=NXM_OF_ETH_SRC[], \
	output:NXM_OF_IN_PORT[]), resubmit(,1)"
ovs-ofctl add-flow br0 "table=1 priority=0 actions=flood"

You can then dump the MAC learning table with:

ovs-ofctl dump-flows br0 table=1
2011-09-13 11:46:09 -07:00
Ben Pfaff
39dc90822e ofp-util: New functions for parsing and formatting OpenFlow port numbers.
These functions were previously used only in ofp-parse.c and ofp-print.c,
but they are more generally useful and future commits will add more users.
2011-09-13 11:46:08 -07:00
Ben Pfaff
0c58c0c4da ofp-print: Add missing "break".
This is not a bug yet, but it could be the next time someone carelessly
adds a new case.
2011-08-15 15:18:30 -07:00
Ethan Jackson
f694937d4e nicra-ext: New action NXAST_OUTPUT_REG.
The NXAST_OUTPUT_REG action outputs to the OpenFlow port contained
in a supplied NXM field.
2011-08-12 15:06:53 -07:00
Ben Pfaff
81d1ea9414 ofp-util: Rename struct flow_stats_request with ofputil_ prefix.
Most of the structs in ofp-util.h have the ofputil_ prefix.  Rename this
one for consistency.
2011-08-09 13:53:21 -07:00