aboutsummaryrefslogtreecommitdiff
path: root/lib/ofp-util.c
AgeCommit message (Collapse)Author
2013-10-21ofp-actions: Distinguish OF1.1/1.2 push_mpls from OF1.3+.Joe Stringer
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-17ofp-util: Fix a comment.YAMAMOTO Takashi
Signed-off-by: YAMAMOTO Takashi <yamamoto@valinux.co.jp> Signed-off-by: Ben Pfaff <blp@nicira.com>
2013-09-27Remove mpls_depth field from flowSimon Horman
Rather than tracking the MPLS depth as a field in the flow, which is an entirely poor place for it, just track the delta to the MPLS depth during translation. This logic was developed while implementing recirculation and intended to be used to detect when recirculation should occur. This variant of the patch uses the logic to determine if processing of actions should stop due to an MPLS action which cannot be translated (without recirculation). A side-effect of this patch is that it resolves a bug whereby ovs-vswitchd will abort due to to an assertion on eth_type_mpls(ctx->xin->flow.dl_type) in compose_mpls_pop_action(() if the actions of a flow include pop_mpls twice without a push_mpls in between. Signed-off-by: Simon Horman <horms@verge.net.au> Signed-off-by: Ben Pfaff <blp@nicira.com>
2013-09-17openvswitch/types.h: New macros OVS_BE16_MAX, OVS_BE32_MAX, OVS_BE64_MAX.Ben Pfaff
These seem slightly nicer than e.g. htons(UINT16_MAX). Signed-off-by: Ben Pfaff <blp@nicira.com>
2013-09-13ofp-util: Announce OpenFlow 1.3 table features only in OpenFlow 1.3.Ben Pfaff
The translation into OpenFlow 1.2 didn't trim off the OpenFlow 1.3 specific bits. This fixes the problem. It would probably be wise to introduce an ofputil_table_stats structure. Using ofp12_table_stats is somewhat confusing. Reported-by: Torbjorn Tornkvist <kruskakli@gmail.com> Tested-by: Torbjorn Tornkvist <kruskakli@gmail.com> Signed-off-by: Ben Pfaff <blp@nicira.com>
2013-09-07openflow-1.1+: OFPT_TABLE_MOD (part 1)Andy Zhou
Added infrastructure to support Openflow OFPT_TABLE_MOD message. This patch does not include the flexible table miss handling code that is necessary to support the semantics specified in OFPT_TABLE_MOD messages. Current flow miss behavior continues to conform to Openflow 1.0. Future commits to add more flexible table miss support are needed to fully support OPFT_TABLE_MOD for Openflow-1.1+. Signed-off-by: Andy Zhou <azhou@nicira.com> Signed-off-by: Ben Pfaff <blp@nicira.com>
2013-09-05ovs-ofctl: Handle any number of buckets in group statisticsSimon Horman
struct ofputil_group_stats has an arbitrary limit of 16 buckets for which it can record statistics. However the code does not appear to enforce this limit and it seems to me that the code could overflow. This patch aims to remove the arbitrary limit by changing the 'bucket_stats' field of struct ofputil_group_stats from a fixed length array to a pointer whose storage is allocated and freed as necessary. Signed-off-by: Simon Horman <horms@verge.net.au> Signed-off-by: Ben Pfaff <blp@nicira.com>
2013-09-02Implement OpenFlow 1.1+ "groups" protocol.Neil Zhu
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-08-27lib: Keep track of usable protocols while parsing.Jarno Rajahalme
Keep track of usable protocols while parsing actions and matches, rather than checking for them afterwards. This fixes silently discarded meter and goto table instructions when not explicitly specifying the protocol to use. Signed-off-by: Jarno Rajahalme <jrajahalme@nicira.com> Signed-off-by: Ben Pfaff <blp@nicira.com>
2013-08-27ofp-util: Abstract flow_mod OFPFF_* flags.Ben Pfaff
The OFPFF_* flags used in flow_mods are just confusing enough that it seems worthwhile to try to abstract them out. In particular: * OFPFF_EMERG was introduced in OF1.0, deleted in OF1.1, and then its bit was reused for a different purpose in OF1.2. * OFPFF_RESET_COUNTS was introduced in OF1.2 but the semantics that it specifies are implied by "add" commands in earlier versions, so proper translation requires the OpenFlow version number and flow_mod command. This commit does the abstraction. Signed-off-by: Ben Pfaff <blp@nicira.com> Acked-by: Ethan Jackson <ethan@nicira.com>
2013-08-27Fix typos in a couple of OpenFlow related comments.Ben Pfaff
Signed-off-by: Ben Pfaff <blp@nicira.com> Acked-by: Ethan Jackson <ethan@nicira.com>
2013-08-22ofp-util: Add SCTP supportJoe Stringer
Reviewed-by: Simon Horman <horms@verge.net.au> Signed-off-by: Joe Stringer <joe@wand.net.nz> Signed-off-by: Ben Pfaff <blp@nicira.com>
2013-08-13flow: Enable matching on new field 'pkt_mark'.Jesse Gross
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-13flow: Rename skb_mark to pkt_mark.Jesse Gross
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-07-26Implement OpenFlow 1.3 queue stats duration feature.Ben Pfaff
Signed-off-by: Ben Pfaff <blp@nicira.com>
2013-07-26ofp-util: Fix port and queue stat counting for OpenFlow 1.3.Ben Pfaff
OpenFlow 1.0, 1.1, and 1.2 all have the same struct size for port and queue stats. OpenFlow 1.3 has larger structs, but the ofp-util code didn't realize that. This fixes the problem. It appears that the only consequence of this problem would have been printing the wrong count in ofp-print output. Signed-off-by: Ben Pfaff <blp@nicira.com>
2013-07-23clang: Fix the alignment warning.Alex Wang
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-18ofp-util: Un-"inline" should_send_version_bitmap().Ben Pfaff
There is no reason to mark this function as inline. Let the compiler do its job. Signed-off-by: Ben Pfaff <blp@nicira.com> Acked-by: Justin Pettit <jpettit@nicira.com>
2013-07-08Add basic OpenFlow 1.1 protocol support.Ben Pfaff
Signed-off-by: Ben Pfaff <blp@nicira.com>
2013-07-08ofp-util: Add 'modify_cookie' to struct ofputil_flow_mod, to support OF1.1.Ben Pfaff
Signed-off-by: Ben Pfaff <blp@nicira.com>
2013-06-28Fix table checking for goto table instruction.Jarno Rajahalme
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-28ofp-util: OpenFlow 1.0 can match IPv6 Ethertype even though not L3 or L4.Ben Pfaff
OpenFlow 1.0 can match on flows that have the IPv6 Ethertype, but ofputil_usable_protocols() incorrectly reported that such a match required NXM or OXM. This commit fixes the problem. Also, add some related tests. Reported-by: Nagi Reddy Jonnala <njonnala@Brocade.com> Signed-off-by: Ben Pfaff <blp@nicira.com>
2013-06-27ofp-util: Meter fixes.Jarno Rajahalme
Validate claimed message length for meter stats in ofp-util.c. Clean up meters in ofp-util.h. Fix the impossible duration values in ofp-print.at. Signed-off-by: Jarno Rajahalme <jarno.rajahalme@nsn.com> Signed-off-by: Ben Pfaff <blp@nicira.com>
2013-06-25ofp-util: Support for OpenFlow 1.3 meters.Jarno Rajahalme
Signed-off-by: Jarno Rajahalme <jarno.rajahalme@nsn.com> Signed-off-by: Ben Pfaff <blp@nicira.com>
2013-06-24ofp-util: New function ofputil_port_to_string().Ben Pfaff
This function is more convenient than ofputil_format_port() when a "struct ds" is not already in use. This commit converts one caller for which this was already true, and the following commit will add another. Signed-off-by: Ben Pfaff <blp@nicira.com>
2013-06-20Create specific types for ofp and odp portAlex Wang
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-10ofp-util: Don't return static data in ofputil_packet_in_reason_to_string().Ben Pfaff
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-05ofp-actions: enforce valid range for table_id in goto_table instructionJing Ai
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-05-30Implement duration fields in OpenFlow 1.3 port stats.Ben Pfaff
Signed-off-by: Ben Pfaff <blp@nicira.com>
2013-05-20ofp-util: Make ofputil_port_from_ofp11() return OFPP_NONE on error.Ben Pfaff
This makes life easier for a few callers, and it agrees with my usual preference that a function should fill in its output parameters whether it succeeds or not. CC: Jarno Rajahalme <jarno.rajahalme@nsn.com> Signed-off-by: Ben Pfaff <blp@nicira.com>
2013-05-10OpenFlow-level flow-based tunneling support.Jarno Rajahalme
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-03ofp-util: Fix type of 'port' param to ofputil_encode_dump_ports_request().Ben Pfaff
We always use unsigned types for port numbers elsewhere, so use one here too. Signed-off-by: Ben Pfaff <blp@nicira.com> Acked-by: Ethan Jackson <ethan@nicira.com>
2013-05-03ofp-util: Make names[] in ofputil_action_code_from_name() const-ier.Ben Pfaff
This changes allows the compiler to put 'names' in a read-only section. Signed-off-by: Ben Pfaff <blp@nicira.com>
2013-04-22some ctype related casts to suppress gcc warnings on NetBSDYAMAMOTO Takashi
where it can't be EOF, cast a value to unsigned char before passing it to ctype functions to avoid unintended sign extension. Signed-off-by: YAMAMOTO Takashi <yamt@mwd.biglobe.ne.jp> Signed-off-by: Ben Pfaff <blp@nicira.com>
2013-03-15Remove encal_dl_type from struct flowSimon Horman
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-08Add table_id to NXM flow_removed messages.Ben Pfaff
Feature #15466. Requested-by: Ronghua Zhang <rzhang@vmware.com> Signed-off-by: Ben Pfaff <blp@nicira.com>
2013-02-12Make OpenFlow 1.2+ role replies return the generation ID.Ben Pfaff
OpenFlow extensibility working group issue EXT-272 clarifies the use of the generation_id in role reply messages as used for the current generation ID or all-1-bits if there is no current generation ID. This commit implements EXT-272 in Open vSwitch. Unfortunately the full text of EXT-272 is not available freely online. (The "open" part of the Open Networking Foundation is the network, not the foundation) EXT-272. CC: Jarno Rajahalme <jarno.rajahalme@nsn.com> Signed-off-by: Ben Pfaff <blp@nicira.com>
2013-02-11ofp-util: Simplify struct ofputil_role_request.Ben Pfaff
It makes more sense to use enum ofp12_controller_role here than to use enum nx_role, because the former is a superset of the latter and we can then get rid of a bool member too. Signed-off-by: Ben Pfaff <blp@nicira.com>
2013-02-05nicira-ext: Remove the autopath action.Ethan Jackson
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-05User-Space MPLS actions and matchesSimon Horman
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-01ofp-util: Rename ofputil_port_from_string() variable to avoid hiding param.Ben Pfaff
This function has a parameter 's' and a local variable 's', so rename the local variable to reduce confusion. Found by Coverity. Signed-off-by: Ben Pfaff <blp@nicira.com> Acked-by: Ethan Jackson <ethan@nicira.com>
2013-01-16Replace most uses of assert by ovs_assert.Ben Pfaff
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-08ofp-util: Fix uninitialized bytes in OF1.0 and OF1.1 table stats replies.Ben Pfaff
Also, use ovs_strlcpy() instead of strcpy() just to be a teensy bit safer. Found by valgrind. Bug #14357. Signed-off-by: Ben Pfaff <blp@nicira.com> Acked-by: Ethan Jackson <ethan@nicira.com>
2012-12-28Add Openflow 1.2 role request/reply processing, update OF 1.2 tests. Add ↵Jarno Rajahalme
struct ofputil_role_request and encode/decode functions for role request/reply. Signed-off-by: Jarno Rajahalme <jarno.rajahalme@nsn.com> [blp@nicira.com made ofp-print print any error, renamed a function, added a comment] Signed-off-by: Ben Pfaff <blp@nicira.com>
2012-12-27ofp-util: features reply of openflow13 does not have portsSUGYO Kazushi
Signed-off-by: SUGYO Kazushi <sugyo.org@gmail.com> [blp@nicira.com moved the test from ofproto.c to ofp-util.c] Signed-off-by: Ben Pfaff <blp@nicira.com>
2012-12-18vswitchd: log skb_mark and skb_priorityAnsis Atteka
This patch adds logging support for skb_mark and skb_priority. Acked-by: Jesse Gross <jesse@nicira.com> Signed-off-by: Ansis Atteka <aatteka@nicira.com>
2012-12-13ofp-util: Fix typo in invalid port range error message.Justin Pettit
Signed-off-by: Justin Pettit <jpettit@nicira.com>
2012-12-08ofproto: Report correct error for emergency flow with timeout.Ben Pfaff
The OpenFlow 1.0 specification says: Emergency flow mod messages must have timeout values set to zero. Otherwise, the switch must refuse the addition and respond with an ofp_error_msg with OFPET_FLOW_MOD_FAILED type and OFPFMFC_BAD_EMERG_TIMEOUT code. but Open vSwitch reported OFPFMFC_TABLE_FULL in this case. This commit fixes the problem. Fixes detailed_contr_sw_messages.EmerFlowTimeout failure in OFTest. Signed-off-by: Ben Pfaff <blp@nicira.com> Acked-by: Kyle Mestery <kmestery@cisco.com>
2012-12-04Don't use error categories as if they were actually errors.Jarno Rajahalme
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-03include/openflow: Moved remaining common definitions from openflow-1.0.hJarno Rajahalme
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>