aboutsummaryrefslogtreecommitdiff
path: root/lib/odp-util.c
AgeCommit message (Collapse)Author
2012-05-16odp-util: Update ODPUTIL_FLOW_KEY_BYTES for current kernel flow format.Ben Pfaff
Before we submitted the kernel module upstream, we updated the flow format by adding two fields to the description of packets with VLAN headers, but we forgot to update ODPUTIL_FLOW_KEY_BYTES to reflect these changes. The result was that a maximum-length flow did not fit in the given space. This fixes a crash processing IPv6 neighbor discovery packets with VLAN headers received in a tunnel configured with key=flow or in_key=flow. This updates some comments to better describe the implications of ODPUTIL_FLOW_KEY_BYTES (suggested by Justin). This also updates test-odp.c so that it would have caught this problem, and updates odp.at to demonstrate that a full 156 bytes are necessary. (To see that, revert the change to ODPUTIL_FLOW_KEY_BYTES and run the test.) Reported-by: Dan Wendlandt <dan@nicira.com> Signed-off-by: Ben Pfaff <blp@nicira.com>
2012-05-14ofp-util: Treat a packet-out in_port of OFPP_CONTROLLER as OFPP_NONE.Ben Pfaff
Some OpenFlow 1.0 controllers incorrectly use OPFP_CONTROLLER as the in_port in packet-out messages, when OFPP_NONE is their intent. Until now, Open vSwitch has rejected such requests with an error message. This commit makes Open vSwitch instead treat OFPP_CONTROLLER the same as OFPP_NONE for compatibility with those controllers. (Also, as of this writing, OpenFlow 1.0.1 appears to be changing the port to use from OFPP_NONE to OFPP_CONTROLLER.) Suggested-by: Rob Sherwood <rob.sherwood@bigswitch.com> Signed-off-by: Ben Pfaff <blp@nicira.com>
2012-05-10odp-util: Fix parsing of actions encapsulated within "sample" actions.Ben Pfaff
Signed-off-by: Ben Pfaff <blp@nicira.com>
2012-01-26odp-util: Describe invalid keys and actions in more detail.Ben Pfaff
I have an outstanding bug report that has tons of "***56 leftover bytes***" messages with no way to guess what the problem is. I hope this makes debugging possible. Bug #9346. Signed-off-by: Ben Pfaff <blp@nicira.com>
2012-01-16ofproto-dpif: Implement self-check of flow translations.Ben Pfaff
One of the major tasks of ofproto-dpif is to translate OpenFlow actions into "ODP" datapath actions. These translations are essentially a cache that requires revalidation when certain state changes occur. For best performance it's important to revalidate flows only when necessary, so from time to time Open vSwitch has gotten this wrong, which meant that stale flows could persist in the kernel and cause surprising behavior. This commit implements a simple "self check": every trip through the Open vSwitch main loop randomly chooses one flow entry and checks that its actions have been correctly translated. If not, Open vSwitch logs the details of the problem. This should help find problems more quickly in the future. Signed-off-by: Ben Pfaff <blp@nicira.com>
2012-01-11odp-util: Handle ipv6 in set nw action.Pravin B Shelar
Rather than silently skipping ipv6 action generation, following patch generates OVS_ACTION_ATTR_SET action for ipv6. Datapath which do not support ipv6 action can reject this action. Bug #8758 Signed-off-by: Pravin B Shelar <pshelar@nicira.com>
2012-01-10ofproto-dpif: Implement PACKET_IN in userspace.Ethan Jackson
In future patches, PACKET_IN messages will include meta-data which is only available in userspace during action translation. Either, this data needs to be stored until it's required by a userspace datapath action, or the PACKET_IN messages must be sent at the time the data is available. This patch implements the latter. Signed-off-by: Ethan Jackson <ethan@nicira.com>
2011-12-21flow: Rename 'priority' to 'skb_priority'.Ben Pfaff
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-11-28odp-util: Move commit_odp_actions() from ofproto-dpif.Ethan Jackson
In an effort to simplify ofproto-dpif, this commit moves the definition of commit_odp_actions() to odp-util.
2011-11-23ofproto-dpif: Support differing user/kernel packet parsing support.Ben Pfaff
Feature #4886.
2011-11-17tests: Rewrite code for comparing sets of ODP actions.Ben Pfaff
The compare-odp-actions.pl utility isn't fully general, even for its intended purpose of allowing sets of ODP actions to be compared ignoring unimportant differences in ordering of output actions and VLAN set actions. I decided that the proper way to do it was to have a utility that can actually parse the actions, instead of just doing textual transformations on them. So, this commit replaces compare-odp-actions.pl by "ovs-dpctl normalize-actions", which is sufficiently general for the intended purpose. The new ovs-dpctl functionality can be easily extended to handle differences in fields other than VLAN, but only VLAN is needed so far. This will be needed in an upcoming commit that in some cases introduces redundant "set vlan" actions into the ODP actions, which compare-odp-actions.pl doesn't tolerate.
2011-11-17odp-util: New function odp_actions_from_string().Ben Pfaff
An upcoming commit will add a user. The only planned users for now are part of unit tests themselves, so it doesn't seem important to unit test it.
2011-11-17odp-util: Add support for named ports to odp_flow_key_from_string().Ben Pfaff
Really the "trace" command should support this but in fact I need it for an upcoming update to a test.
2011-11-17odp-util: New function factored out of put_userspace_action().Ben Pfaff
An upcoming patch to odp-util will add a new user, but this seems like a reasonable change in any case.
2011-11-17odp-util: Code formatting improvements.Ben Pfaff
2011-11-17odp-util: Reorder OVS_KEY_ATTR_* cases for consistency.Ben Pfaff
This matches the order of their definition in openvswitch.h. Reported-by: Justin Pettit <jpettit@nicira.com>
2011-11-14datapath: Don't drop packets with partial vlan tags.Ben Pfaff
In the future it is likely that our vlan support will expand to include multiply tagged packets. When this happens, we would ideally like for it to be consistent with our current tagging. Currently, if we receive a packet with a partial VLAN tag we will automatically drop it in the kernel, which is unique among the protocols we support. The only other reason to drop a packet is a memory allocation error. For a doubly tagged packet, we will parse the first tag and indicate that another tag was present but do not drop if the second tag is incorrect as we do not parse it. This changes the behavior of the vlan parser to match other protocols and also deeper tags by indicating the presence of a broken tag with the 802.1Q EtherType but no vlan information. This shifts the policy decision to userspace on whether to drop broken tags and allows us to uniformly add new levels of tag parsing. Although additional levels of control are provided to userspace, this maintains the current behavior of dropping packets with a broken tag when using the NORMAL action because that is the correct behavior for an 802.1Q-aware switch. The userspace flow parser actually already had the new behavior so this corrects an inconsistency. Reported-by: Jesse Gross <jesse@nicira.com> Signed-off-by: Ben Pfaff <blp@nicira.com> Acked-by: Jesse Gross <jesse@nicira.com>
2011-11-14datapath: Describe policy for extending flow key, implement needed changes.Ben Pfaff
When the datapath was converted to use Netlink attributes for describing flow keys, I had a vague idea of how it could be smoothly extensible, but I didn't actually implement extensibility or carefully think it through. This commit adds a document that describes how flow keys can be extended in a compatible fashion and adapts the existing interface to match what it says. This commit doesn't actually implement extensibility. I already have a separate patch series out for that. This patch series borrows from that one heavily, but the extensibility series will need to be reworked somewhat once this one is in. This commit is only lightly tested because I don't have a good test setup for VLANs. Signed-off-by: Ben Pfaff <blp@nicira.com> Acked-by: Jesse Gross <jesse@nicira.com>
2011-11-14datapath: Allow flow key Netlink attributes to appear in any order.Ben Pfaff
This is more conventional use of Netlink. For upstreaming, 'u64 attrs' can be changed to u32 and the uses of 1ULL can be changed to 1. Signed-off-by: Ben Pfaff <blp@nicira.com> Acked-by: Jesse Gross <jesse@nicira.com>
2011-11-11odp-util: Use ovs_key_attr_to_string() names in format_odp_key_attr().Ben Pfaff
2011-11-11odp-util: Adjust style.Ben Pfaff
Usually we don't put a new-line in prototypes unless we have to. I also think that this comment deserves to be higher up in the file, so I moved it.
2011-11-11odp-util: Trigger warning for unhandled attrs in format_odp_key_attr().Ben Pfaff
I usually do things this way but must have overlooked this one a while ago.
2011-11-11odp-util: New function ovs_key_attr_to_string().Ben Pfaff
This seems like a worthwhile improvement in itself, but it will also see additional users in upcoming commits.
2011-11-10Prepend "nw_" to "frag" and "tos" elements.Justin Pettit
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-09datapath: Rename ipv6_tos to ipv6_tclass.Justin Pettit
IPv6 uses the term "traffic class" for what IPv4 calls "type-of-service". This commit renames the the "ipv6_tos" field to "ipv6_tclass" in the "ovs-key_ipv6" struct to be more consistent with the IPv6 terminology. Suggested-by: Jesse Gross <jesse@nicira.com> Signed-off-by: Justin Pettit <jpettit@nicira.com> Acked-by: Jesse Gross <jesse@nicira.com>
2011-11-09odp-util: Use PRIu8 instead of PRId8 when printing ip_proto.Justin Pettit
Suggested-by: Ben Pfaff <blp@nicira.com>
2011-11-09Support matching and modifying IP TTL.Justin Pettit
Add support matching the IPv4 TTL and IPv6 hop limit fields. This commit also adds support for modifying the IPv4 TTL. Modifying the IPv6 hop limit isn't currently supported, since we don't support modifying IPv6 headers. We will likely want to change the user-space interface, since basic matching and setting the TTL are not generally useful. We will probably want the ability to match on extraordinary events (such as TTL of 0 or 1) and a decrement action. Feature #8024 Signed-off-by: Justin Pettit <jpettit@nicira.com> Acked-by: Jesse Gross <jesse@nicira.com>
2011-11-09Support matching and modifying IP ECN bits.Justin Pettit
Signed-off-by: Justin Pettit <jpettit@nicira.com> Acked-by: Jesse Gross <jesse@nicira.com>
2011-11-09Don't overload IP TOS with the frag matching bits.Justin Pettit
This will be useful later when we add support for matching the ECN bits within the TOS field. Signed-off-by: Justin Pettit <jpettit@nicira.com> Acked-by: Jesse Gross <jesse@nicira.com>
2011-11-09Support matching IPv6 flow label.Justin Pettit
Signed-off-by: Justin Pettit <jpettit@nicira.com> Acked-by: Jesse Gross <jesse@nicira.com>
2011-11-01datapath: Convert kernel priority actions into match/set.Pravin B Shelar
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-01Fix build on FreeBSD.Edward Tomasz NapieraƂa
Patch below fixes build on FreeBSD; tested on 10.0-CURRENT. Signed-off-by: Edward Tomasz Napierala <trasz@FreeBSD.org> Signed-off-by: Ben Pfaff <blp@nicira.com>
2011-10-21Implement new fragment handling policy.Ben Pfaff
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-21datapath: Refactor actions in terms of match fields.Pravin B Shelar
Almost all current actions can be expressed in the form of push/pop/set <field>, where field is one of the match fields. We can create three base actions and take a field. This has both a nice symmetry and avoids inconsistencies where we can match on the vlan TPID but not set it. Following patch converts all actions to this new format. Signed-off-by: Pravin B Shelar <pshelar@nicira.com> Acked-by: Jesse Gross <jesse@nicira.com> Bug #7115
2011-10-12datapath-protocol: Rename enums for consistency.Ben Pfaff
Most of the enum tags in this file are lowercased versions of the uppercase enum prefixes (or slightly less abbreviated versions, e.g. "dp" becomes "datapath"). This commit fixes up the others for consistency. Signed-off-by: Ben Pfaff <blp@nicira.com> Acked-by: Jesse Gross <jesse@nicira.com>
2011-10-12datapath: Move Netlink PID for userspace actions from flows to actions.Ben Pfaff
Commit b063d9f06 "datapath: Use unicast Netlink sockets for upcalls" that switched from multicast to unicast Netlink for sending upcalls added a Netlink PID to each kernel flow, used by OVS_ACTION_ATTR_USERSPACE actions within the flow as target. This commit drops this per-flow PID in favor of a per-action PID, because that is more flexible. It does not yet make use of this additional flexibility, so behavior should not change. Signed-off-by: Ben Pfaff <blp@nicira.com> Acked-by: Jesse Gross <jesse@nicira.com> Bug #7559.
2011-10-11openflow: Delete icmp_type and icmp_code macros.Ben Pfaff
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-05odp-util: Use nl_parse_nested() to simplify format_odp_sample_action().Ben Pfaff
2011-09-28sFlow: Genericize/simplify kernel sFlow implementationPravin Shelar
Following patch adds sampling action which takes probability and set of actions as arguments. When probability is hit, actions are executed for given packet. USERSPACE action's userdata (u64) is used to store struct user_action_cookie as cookie. CONTROLLER action is fixed accordingly. Now we can remove sFlow code from kernel and implement sFlow generically as SAMPLE action. sFlow is defined as SAMPLE Action with probability (sFlow sampling rate) and USERSPACE action as argument. USERSPACE action's data is used as cookie. sFlow uses this cookie to store output-port, number of output ports and vlan-id. sample-pool is calculated by using vport stats. Signed-off-by: Pravin Shelar <pshelar@nicira.com> Acked-by: Jesse Gross <jesse@nicira.com> Acked-by: Ben Pfaff <blp@nicira.com>
2011-09-15odp-util: Drop pointless "if" statement.Ben Pfaff
2011-09-09datapath: VLAN actions should use push/pop semanticsPravin Shelar
Currently the kernel vlan actions mirror those used by OpenFlow 1.0. i.e. MODIFY and STRIP. More flexible approach is to have an action to push a tag and pop a tag off, so that it can handle multiple levels of vlan tags. Plus it aligns with newer version of OpenFlow. As this patch replaces MODIFY with PUSH semantic, action mapping done in userpace is fixed accordingly. GSO handling for multiple levels of vlan tags is also added as Jesse suggested before. Signed-off-by: Pravin B Shelar <pshelar@nicira.com> Acked-by: Jesse Gross <jesse@nicira.com>
2011-09-08datapath: Allow a packet with no input port to omit OVS_KEY_ATTR_IN_PORT.Ben Pfaff
When ovs-vswitchd executes actions on a synthesized packet, that is, on a packet that is not being forwarded from any particular port but is being generated by ovs-vswitchd itself or by an OpenFlow controller (using a OFPT_PACKET_OUT message with an in_port of OFPP_NONE), there is no good choice for the in_port to pass to the kernel in the flow in the OVS_PACKET_CMD_EXECUTE message. This commit allows ovs-vswitchd to omit the in_port entirely in this case. This fixes a bug in OFPT_PACKET_OUT: using an in_port of OFPP_NONE would cause the packet to be dropped by the kernel, since that's an invalid input port. Signed-off-by: Ben Pfaff <blp@nicira.com> Acked-by: Jesse Gross <jesse@nicira.com> Reported-by: Aaron Rosen <arosen@clemson.edu>
2011-08-19datapath: Use "OVS_*" as opposed to "ODP_*" for user<->kernel interactions.Justin Pettit
The prefix "ODP_*" is not overly descriptive in the context of the larger Linux tree. This commit changes the prefix to "OVS_*" for the userpace to kernel interactions. The userspace libraries still use "ODP_" in many of their interfaces since it is more descriptive in the OVS oeuvre. Feature #6904 Signed-off-by: Justin Pettit <jpettit@nicira.com> Acked-by: Jesse Gross <jesse@nicira.com>
2011-08-18odp-util: Fix parsing of Ethertypes 0x8000 and above.Ben Pfaff
An existing comment in the function being updated explains the problem: * Many of the sscanf calls in this function use oversized destination * fields because some sscanf() implementations truncate the range of %i * directives, so that e.g. "%"SCNi16 interprets input of "0xfedc" as a * value of 0x7fff. The other alternatives are to allow only a single * radix (e.g. decimal or hexadecimal) or to write more sophisticated * parsers.
2011-08-12lib: Whitespace cleanup.Ethan Jackson
2011-08-08odp-util: New function odp_flow_key_from_string().Ben Pfaff
This will be used in upcoming commits.
2011-08-08odp-util: Format VLAN headers more like other headers in ODP flow output.Ben Pfaff
The rest of the headers all follow the form "header(value)" or "header(key1=value1,key2=value2,...)" but VLAN headers left out the "=" characters. This adds them in for consistency.
2011-07-28Datapath action should not refer to controllerpravin shelar
ODP_ACTION_ATTR_CONTROLLER in the kernel actually sends packets to userspace, not the controller. To make it generic rename this action to ODP_ACTION_ATTR_USERSPACE. Signed-off-by: Pravin B Shelar <pshelar@nicira.com>
2011-06-09Remove NXAST_DROP_SPOOFED_ARP action.Justin Pettit
The NXAST_DROP_SPOOFED_ARP action has been deprecated in favor of defining flows using the NXM_NX_ARP_SHA flow match for a while. This commit removes it. Signed-off-by: Justin Pettit <jpettit@nicira.com> Acked-by: Jesse Gross <jesse@nicira.com>
2011-05-11ofproto: Break apart into generic and hardware-specific parts.Ben Pfaff
In addition to the changes to ofproto, this commit changes all of the instances of "struct flow" in the tree so that the "in_port" member is an OpenFlow port number. Previously, this member was an OpenFlow port number in some cases and an ODP port number in other cases.