2
0
mirror of https://github.com/openvswitch/ovs synced 2025-08-22 18:07:40 +00:00

71 Commits

Author SHA1 Message Date
Justin Pettit
a61680c6d1 Support matching and modifying IP TTL.
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-09 13:24:52 -08:00
Justin Pettit
530180fd5a Support matching and modifying IP ECN bits.
Signed-off-by: Justin Pettit <jpettit@nicira.com>
Acked-by: Jesse Gross <jesse@nicira.com>
2011-11-09 10:47:59 -08:00
Justin Pettit
9e44d71563 Don't overload IP TOS with the frag matching bits.
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-09 10:37:57 -08:00
Justin Pettit
fa8223b7fd Support matching IPv6 flow label.
Signed-off-by: Justin Pettit <jpettit@nicira.com>
Acked-by: Jesse Gross <jesse@nicira.com>
2011-11-09 10:37:55 -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
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
Justin Pettit
dc56021df4 nicira-ext: Fix build problems on 64-bit systems.
Commit d2c0fe (nicira-ext: Bump number of registers to five from four.)
broke the build on 64-bit systems.  This commit fixes the problems it
introduced.
2011-10-04 11:50:51 -07:00
Ben Pfaff
993410fbc7 classifier: Move zero_wildcards() to flow.c as public flow_zero_wildcards().
This function will soon be used elsewhere.  As it doesn't inherently have
anything to with the classifier, move it to flow.c.
2011-09-13 11:46:09 -07:00
Ben Pfaff
aad29cd1a1 packets: Add more utility functions for IPv4 and IPv6 addresses.
We had these functions scattered around the source tree anyway.  packets.h
is a good place to centralize them.

I do plan to introduce some additional callers.
2011-09-13 11:46:08 -07:00
Ben Pfaff
e7ed3a3a5f classifier: Change cls_rule_set_nd_target() to take a pointer.
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-09-13 11:46:08 -07:00
Ethan Jackson
a877206f2f flow: New FLOW_WC_SEQ build assertion.
Changing "struct flow" or its wildcards requires minor adjustments
in many places in the code.  This patch adds a new FLOW_WC_SEQ
sequence number which when incremented will cause build assertion
failures aiding the developer in finding code which needs to
change.
2011-08-12 15:05:41 -07:00
Ethan Jackson
b53055f4da lib: Whitespace cleanup. 2011-08-12 15:05:41 -07:00
Ben Pfaff
fb115f912b classifier: Print ARP opcode as "arp_op" instead of "opcode".
"opcode" is not very specific.  All the other ARP fields have an "arp_"
prefix, so this commit adds one for the opcode too.
2011-06-30 10:02:55 -07:00
Ben Pfaff
57452fdcfb classifier: New function cls_rule_hash().
An upcoming commit will introduce the first use.
2011-06-14 11:21:51 -07:00
Ben Pfaff
1006cda6d4 flow: Give flow_wildcards_hash() a 'basis' parameter.
An upcoming commit will add more interesting uses.
2011-06-14 11:21:51 -07:00
Ben Pfaff
db7f828182 Better abstract wildcards for Ethernet destination field.
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-06-07 16:47:42 -07:00
Ben Pfaff
08944c1db1 ofproto: Make rule construction and destruction more symmetric.
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-05-11 14:06:48 -07:00
Ben Pfaff
c084ce1d3f classifier: Remove OF1.0 special case from classifier_find_rule_exactly().
This special case should never have actually triggered in practice, because
OpenFlow 1.0 cannot set up an exact-match rule as defined by
flow_wildcards_is_exact().  (OpenFlow 1.0 will always, for example,
wildcard all NXM registers.)

OVS implements this OF1.0 special case differently, by changing flow
priority to 65535 in cls_rule_from_match() if the flow is an exact match as
defined by OpenFlow 1.0.
2011-05-11 12:35:10 -07:00
Ben Pfaff
abe529af47 ofproto: Break apart into generic and hardware-specific parts.
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.
2011-05-11 12:35:09 -07:00
Ben Pfaff
ce0307c473 classifier: Omit all-1-bits mask for VLAN TCI in cls_rule_format().
To me, this seems to be easier to read.
2011-03-16 14:53:15 -07:00
Justin Pettit
685a51a5b8 nicira-ext: Support matching IPv6 Neighbor Discovery messages.
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-02 13:22:34 -08:00
Justin Pettit
d31f1109f1 nicira-ext: Support matching IPv6 traffic.
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-02 12:53:26 -08:00
Justin Pettit
bad68a9965 nicira-ext: Support matching ARP source and target hardware addresses.
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-02-02 12:42:40 -08:00
Justin Pettit
6767a2cce9 lib: Replace IP_TYPE_ references with IPPROTO_.
A few common IP protocol types were defined in "lib/packets.h".  However,
we already assume the existence of <netinet/in.h> which contains a more
exhaustive list and should be available on POSIX systems.
2011-02-02 11:50:17 -08:00
Ben Pfaff
8368c090ca Implement arbitrary bitwise masks for tun_id field.
This was documented to work, but not implemented.

Requested-by: Pankaj Thakkar <thakkar@nicira.com>
2011-01-20 15:29:00 -08:00
Ben Pfaff
92ec574173 classifier: Insert commas after fields that lacked them in cls_rule_format(). 2010-12-15 09:48:18 -08:00
Ben Pfaff
8fe2b9682c classifier: Use OFP_DEFAULT_PRIORITY instead of literal 32768. 2010-12-15 09:48:18 -08:00
Ben Pfaff
b9298d3f82 Expand tunnel IDs from 32 to 64 bits.
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-10 11:14:13 -08:00
Ben Pfaff
07b37e8f98 classifier: Implement better classifier rule formatting.
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-07 12:45:26 -08:00
Ben Pfaff
87542e21fa classifier: New cls_rule functions for setting registers and tun_id. 2010-12-03 10:30:11 -08:00
Ben Pfaff
66642cb40b nx-match: Implement support for arbitrary VLAN TCI masks.
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-23 10:06:28 -08:00
Ben Pfaff
d8ae4d6726 flow: Fully separate flow_wildcards from OpenFlow wildcard bits.
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.
2010-11-22 10:11:40 -08:00
Ben Pfaff
844dff325b flow: Remove flow_to/from_match() in favor of cls_rule_to/from_match().
The flow_from_match() and flow_to_match() functions have to deal with most
of the state in a cls_rule anyhow, and this will increase in upcoming
commits, to the point that we might as well just use a cls_rule anyhow.
This commit therefore deletes flow_from_match() and flow_to_match(),
integrating their code into cls_rule_from_match() and the new function
cls_rule_to_match(), respectively.  It also changes each of the functions'
callers to use the new cls_rule_*() function.
2010-11-22 10:10:14 -08:00
Ben Pfaff
00561f415c flow: New function flow_wildcards_is_exact(). 2010-11-22 09:40:35 -08:00
Ben Pfaff
193eb87453 classifier: New function cls_rule_equal(). 2010-11-22 09:40:34 -08:00
Ben Pfaff
955f579d42 classifier: Fix segfault iterating with rules that differ only in priority.
When CLS_CURSOR_FOR_EACH(_SAFE) iterated through a classifier, the
cls_cursor_next() function did not properly handle the case where there was
more than a single rule on a list.  This commit fixes the problem.

The addition to the testsuite would have found the problem earlier.

Reported-by: Teemu Koponen <koponen@nicira.com>
CC: Teemu Koponen <koponen@nicira.com>
2010-11-19 16:41:02 -08:00
Ben Pfaff
f6acdb447e classifier: Remove classifier_for_each(), classifier_for_each_match().
These functions no longer have any users.
2010-11-15 15:10:03 -08:00
Ben Pfaff
5ecc9d8156 classifier: Add functions and macros for iteration, and use them in ofproto.
This is much more convenient in practice than being forced to use a
callback function.
2010-11-15 15:09:00 -08:00
Ben Pfaff
cd10ed7fb4 classifier: Delete dead code specialized for the exact table.
These functions and macros are no longer used.
2010-11-12 14:50:45 -08:00
Ben Pfaff
3c4486a5f7 classifier: Drop CLS_INC_* enumerations and related 'include' parameters.
This type and these parameters were useful when ofproto had the need to
separately traverse exact-match rules looking for subrules, but it no
longer does that because subrules (now called "facets") are not kept in
the classifier any longer.  All the callers are now passing CLS_INC_ALL
anyhow, so we might as well delete this feature and simplify the code.
2010-11-12 14:50:44 -08:00
Ben Pfaff
1e37a2d751 Add support for matching Ethernet multicast frames. 2010-11-11 10:46:23 -08:00
Ben Pfaff
b6c9e612fa ofproto: Implement support for registers in extended flow match. 2010-11-11 10:41:33 -08:00
Ben Pfaff
eacf6385a9 classifier: Pass correct member to CONTAINER_OF in cls_table_next_rule().
Fixes a segmentation fault in uses of CLASSIFIER_FOR_EACH_EXACT_RULE.

Reported-by: Derek Cormier <derek.cormier@lab.ntt.co.jp>
2010-11-11 10:25:34 -08:00
Ben Pfaff
b63f2ea794 flow: Better abstract flow_wildcards and use it more widely. 2010-11-08 10:43:32 -08:00
Ben Pfaff
81c9dad242 classifier: Add more cls_rule_set_*() functions.
These will be handy later but are not used yet.
2010-11-08 10:43:32 -08:00
Ben Pfaff
64420dfac5 classifier: Move in-band set_<field>() functions publicly available.
These will be useful elsewhere later.
2010-11-08 10:43:31 -08:00
Ben Pfaff
cf3fad8a1b ofproto: Change ofproto_add_flow(), ofproto_delete_flow() to take cls_rule.
This is a small cleanup that will make later changes to wildcards easier.
2010-11-08 10:43:31 -08:00
Ben Pfaff
52ce26ee3b Rename cls_rule_zero_wildcards() to cls_rule_zero_wildcarded_fields().
Justin said that he found the shorter name confusing.
2010-11-08 10:36:26 -08:00
Ben Pfaff
f9bfea1402 ofproto: Generalize tun_id_from_cookie into flow_format.
Upcoming commits will add more flow formats, so this needs to be
an enumerated type instead of a bool.
2010-11-05 11:10:35 -07:00