aboutsummaryrefslogtreecommitdiff
path: root/lib/classifier.h
AgeCommit message (Collapse)Author
2013-10-22classifier: Fix a typo.Gurucharan Shetty
Signed-off-by: Gurucharan Shetty <gshetty@nicira.com> Acked-by: Ben Pfaff <blp@nicira.com>
2013-09-26classifier: Avoid accumulating junk in cls_partition 'tags'.Ben Pfaff
It's easy to add two tags together, but it's hard to subtract them. The new "tag_tracker" data structure provides a solution. Signed-off-by: Ben Pfaff <blp@nicira.com>
2013-09-26classifier: Speed up lookup when metadata partitions the flow table.Ben Pfaff
We have a controller that puts many rules with different metadata values into the flow table, where metadata is used (by "resubmit"s) to distinguish stages in a pipeline. Thus, any given flow only needs to be hashed into classifier "cls_table"s that contain a match for the flow's metadata value. This commit optimizes the classifier lookup by (probabilistically) skipping the "cls_table"s that can't possibly match. (The "metadata" referred to here is the OpenFlow 1.1+ "metadata" field, which is a 64-bit field similar in purpose to the "registers" defined by Open vSwitch.) Previous versions of this patch, with earlier versions of the controller in question, improved flow setup performance by about 19%. Bug #14282. Signed-off-by: Ben Pfaff <blp@nicira.com>
2013-09-12ofproto: Add global locking around flow table changes.Ben Pfaff
This makes 'ofproto_mutex' protect the flow table well enough that threads other than the main one can realistically modify flows. I need to look at the interface between ofproto and connmgr: I think that there might need to be some locking there too. Signed-off-by: Ben Pfaff <blp@nicira.com> Acked-by: Ethan Jackson <ethan@nicira.com>
2013-09-12classifier: Allow CLS_CURSOR_FOR_EACH to use a const-qualified iterator.Ben Pfaff
Signed-off-by: Ben Pfaff <blp@nicira.com> Acked-by: Ethan Jackson <ethan@nicira.com>
2013-08-27classifier: New function cls_rule_move().Ben Pfaff
This function will acquire its first user in an upcoming commit. Signed-off-by: Ben Pfaff <blp@nicira.com> Acked-by: Ethan Jackson <ethan@nicira.com>
2013-08-09classifier: Make use of the classifier thread safe.Ethan Jackson
Signed-off-by: Ethan Jackson <ethan@nicira.com> Acked-by: Ben Pfaff <blp@nicira.com>
2013-07-22clang: Fix the "expression result unused" warning.Alex Wang
This commit makes macro function "ASSIGN_CONTAINER()" evaluates to "(void)0". This is to avoid the 'clang' warning: "expression result unused", since most of time, the final evaluated value is not used. Signed-off-by: Alex Wang <alexw@nicira.com> Signed-off-by: Ben Pfaff <blp@nicira.com>
2013-07-22clang: Fix segfault in unit tests.Alex Wang
It seems that 'clang' compiler applies strict protection on pointer dereference. And it causes unexpected execution in macro functions like "HMAP_FOR_EACH()" and unit test failures. This commit fixes this issue and pass all unit tests. Co-authored-by: Ethan Jackson <ethan@nicira.com> Signed-off-by: Alex Wang <alexw@nicira.com> Signed-off-by: Ben Pfaff <blp@nicira.com>
2013-06-11classifier: Add 'wc' argument to classifier_lookup().Ethan Jackson
A future commit will want to know what bits were significant during the classifier lookup. 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-02-11classifier: Maintain tables in descending priority order.Jarno Rajahalme
Signed-off-by: Jarno Rajahalme <jarno.rajahalme@nsn.com> [blp@nicira.com: this along with Jarno's previous patch to the classifier give me a combined 15% boost in "ovs-benchmark rate" with a complicated flow table involving multiple resubmits] Signed-off-by: Ben Pfaff <blp@nicira.com>
2013-02-08Optimize classifier by maintaining the priority of the highest priority rule ↵Jarno Rajahalme
in each table. Signed-off-by: Jarno Rajahalme <jarno.rajahalme@nsn.com> Signed-off-by: Ben Pfaff <blp@nicira.com>
2012-09-04Introduce sparse flows and masks, to reduce memory usage and improve speed.Ben Pfaff
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-04classifier: Optimize iteration with a catch-all target rule.Ben Pfaff
When cls_cursor_init() is given a NULL target, it can skip an expensive step comparing the rule against the target for every table and every rule in the classifier. collect_rule_loose() and other callers could take advantage of this optimization, except that they actually pass in a rule that matches everything instead of a NULL rule (e.g. for "ovs-ofctl dump-flows <bridge>" without specifying a matching rule). This optimizes that case. Signed-off-by: Ben Pfaff <blp@nicira.com>
2012-09-04classifier: Prepare for "struct cls_rule" needing to be destroyed.Ben Pfaff
Until now, "struct cls_rule" didn't own any data outside its own memory block. An upcoming commit will make "struct cls_rule" sometimes own blocks of memory, so it needs "destroy" and to a lesser extent "clone" functions. This commit adds these in advance, even though they are mostly no-ops, to make it possible to separately review the memory management. Signed-off-by: Ben Pfaff <blp@nicira.com>
2012-09-04classifier: Break cls_rule 'flow' and 'wc' members into new "struct match".Ben Pfaff
Signed-off-by: Ben Pfaff <blp@nicira.com>
2012-07-23meta-flow: Add OF1.2-like MFF_VLAN_VID and MFF_VLAN_PCP.Ben Pfaff
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-19OXM: Allow masking of ARP SHA and THASimon Horman
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-19OXM: Allow masking of IPv6 Flow LabelSimon Horman
Signed-off-by: Simon Horman <horms@verge.net.au> Signed-off-by: Ben Pfaff <blp@nicira.com>
2012-07-12classifier: New function cls_rule_is_loose_match().Ben Pfaff
This function will be useful in an upcoming commit. Signed-off-by: Ben Pfaff <blp@nicira.com>
2012-06-26Add OXM_OF_METADATA field as a step toward OpenFlow 1.1 support.Joe Stringer
Signed-off-by: Joe Stringer <joe@wand.net.nz> Signed-off-by: Ben Pfaff <blp@nicira.com>
2012-05-29flow: Adds support for arbitrary ethernet maskingJoe Stringer
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-02Global replace of Nicira Networks.Raju Subramanian
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-04-26nicira-ext: Support masking of nd_target fieldAnsis Atteka
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-18classifier: Optimize search of "catchall" table.Ben Pfaff
Most flow tables have some kind of "catchall" rule that matches every packet. For this table, the cost of copying, zeroing, and hashing the input flow is significant. This patch avoids these costs. Signed-off-by: Ben Pfaff <blp@nicira.com>
2012-02-02Add support for bitwise matching on TCP and UDP ports.Ben Pfaff
Bug #8827. Signed-off-by: Ben Pfaff <blp@nicira.com>
2012-01-10classifier: Update cls_rule_set_in_port() prototype.Ethan Jackson
Signed-off-by: Ethan Jackson <ethan@nicira.com>
2011-11-10classifier: Don't check masks when adding IPv4/IPv6 addresses.Justin Pettit
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-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-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-09Support matching IPv6 flow label.Justin Pettit
Signed-off-by: Justin Pettit <jpettit@nicira.com> Acked-by: Jesse Gross <jesse@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-09-13ofproto-dpif: Optimize flow revalidation for MAC learning.Ben Pfaff
Without this commit, every NXAST_LEARN action that adds a flow causes every facet to be revalidated. With this commit, as long as the "Usage Advice" in the large comment on struct nx_action_learn in nicira-ext.h is followed, this no longer happens.
2011-09-13classifier: Change cls_rule_set_nd_target() to take a pointer.Ben Pfaff
The other cls_rule_*() functions that take IPv6 addresses take a pointer to an in6_addr, so cls_rule_set_nd_target() should as well for consistency. Possibly this is more efficient also, although I guess it doesn't really make much of a difference either way.
2011-08-19classifier: Fix typo in comment.Ben Pfaff
2011-08-04lib: Adapt headers for use in C++.Casey Barker
This commit makes several library headers suitable for inclusion in C++. It adds [extern "C"] guards and makes minor changes to fix casting and keyword issues.
2011-06-14classifier: New function cls_rule_hash().Ben Pfaff
An upcoming commit will introduce the first use.
2011-06-07Better abstract wildcards for Ethernet destination field.Ben Pfaff
I think that this makes nx-match.c a little easier to read. The new functions added here will have more users in an upcoming patch.
2011-05-11ofproto: Make rule construction and destruction more symmetric.Ben Pfaff
Before, ->rule_construct() both created the rule and inserted into the flow table, but ->rule_destruct() only destroyed the rule. This makes ->rule_destruct() also remove the rule from the flow table.
2011-02-02nicira-ext: Support matching IPv6 Neighbor Discovery messages.Justin Pettit
IPv6 uses Neighbor Discovery messages in a similar manner to how IPv4 uses ARP. This commit adds support for matching deeper into the payloads of Neighbor Solicitation (NS) and Neighbor Advertisement (NA) messages. Currently, the matching fields include: - NS and NA Target (nd_target) - NS Source Link Layer Address (nd_sll) - NA Target Link Layer Address (nd_tll) When defining IPv6 Neighbor Discovery rules, the Nicira Extensible Match (NXM) extension to OVS must be used. Signed-off-by: Justin Pettit <jpettit@nicira.com> Acked-by: Ben Pfaff <blp@nicira.com>
2011-02-02nicira-ext: Support matching IPv6 traffic.Justin Pettit
Provides ability to match over IPv6 traffic in the same manner as IPv4. Currently, the matching fields include: - IPv6 source and destination addresses (ipv6_src and ipv6_dst) - Traffic Class (nw_tos) - Next Header (nw_proto) - ICMPv6 Type and Code (icmp_type and icmp_code) - TCP and UDP Ports over IPv6 (tp_src and tp_dst) When defining IPv6 rules, the Nicira Extensible Match (NXM) extension to OVS must be used. Signed-off-by: Justin Pettit <jpettit@nicira.com> Acked-by: Ben Pfaff <blp@nicira.com>
2011-02-02nicira-ext: Support matching ARP source and target hardware addresses.Justin Pettit
OpenFlow 1.0 doesn't allow matching on the ARP source and target hardware address. This has caused us to introduce hacks such as the Drop Spoofed ARP action. Now that we have extensible match, we can match on more fields within ARP: - Source Hardware Address (arp_sha) - Target Hardware Address (arp_tha) Signed-off-by: Justin Pettit <jpettit@nicira.com> Acked-by: Jesse Gross <jesse@nicira.com> Acked-by: Ben Pfaff <blp@nicira.com>
2011-01-20Implement arbitrary bitwise masks for tun_id field.Ben Pfaff
This was documented to work, but not implemented. Requested-by: Pankaj Thakkar <thakkar@nicira.com>
2010-12-10Expand tunnel IDs from 32 to 64 bits.Ben Pfaff
We have a need to identify tunnels with keys longer than 32 bits. This commit adds basic datapath and OpenFlow support for such keys. It doesn't actually add any tunnel protocols that support 64-bit keys, so this is not very useful yet. The 'arg' member of struct odp_msg had to be expanded to 64-bits also, because it sometimes contains a tunnel ID. This member also contains the argument passed to ODPAT_CONTROLLER, so I expanded that action's argument to 64 bits also so that it can use the full width of the expanded 'arg'. Userspace doesn't take advantage of the new space though (it was only using 16 bits anyhow). This commit has been tested only to the extent that it doesn't disrupt basic Open vSwitch operation. I have not tested it with tunnel traffic. Signed-off-by: Ben Pfaff <blp@nicira.com> Acked-by: Jesse Gross <jesse@nicira.com> Feature #3976.
2010-12-07classifier: Implement better classifier rule formatting.Ben Pfaff
The old formatting was only good enough for debugging, but now we need to be able to format cls_rules as part of ofp-print.c. This new code is modeled after ofp_match_to_string().
2010-12-06util: Introduce ASSIGN_CONTAINER to make iteration macros easier to read.Ben Pfaff
2010-12-03classifier: New cls_rule functions for setting registers and tun_id.Ben Pfaff
2010-11-23nx-match: Implement support for arbitrary VLAN TCI masks.Ben Pfaff
Since the Nicira Extended Match was specified nicira-ext.h has claimed that arbitrary masks are allowed, but in fact only certain masks were actually implemented. This commit implements general masking for the 802.1Q VLAN TCI field.
2010-11-22flow: Fully separate flow_wildcards from OpenFlow wildcard bits.Ben Pfaff
Originally, wildcards were just the OpenFlow OFPFW_* bits. Then, when OpenFlow added CIDR masks for IP addresses, struct flow_wildcards was born with additional members for those masks, derived from the wildcard bits. Then, when OVS added support for tunnels, we added another bit NXFW_TUN_ID that coexisted with the OFPFW_*. Later we added even more bits that do not appear in the OpenFlow 1.0 match structure at all. This had become really confusing, and the difficulties were especially visible in the long list of invariants in comments on struct flow_wildcards. This commit cleanly separates the OpenFlow 1.0 wildcard bits from the bits used inside Open vSwitch, by defining a new set of bits that are used only internally to Open vSwitch and converting to and from those wildcard bits at the point where data comes off or goes onto the wire. It also moves those functions into ofp-util.[ch] since they are only for dealing with OpenFlow wire protocol now.