Jesse Gross [Sat, 19 Nov 2011 21:45:48 +0000 (13:45 -0800)]
datapath: Directly use methods for protecting RCU/RTNL data.
We currently have a wrapper to protect the datapath ports array.
However, this can lead to confusion over exactly what lock is
protecting the access (either RTNL or RCU). This removes the
wrapper in favor of directly accessing the data, which also has
the benefit of being less permissive about what lock we allow so
it can be restricted to the one that we expect.
Signed-off-by: Jesse Gross <jesse@nicira.com> Acked-by: Ben Pfaff <blp@nicira.com>
Jesse Gross [Sat, 19 Nov 2011 21:25:43 +0000 (13:25 -0800)]
datapath: Add genl_dereference() and use it.
We currently use a specialized version of what amounts to
genl_dereference() to protect the flow table. This prepares to
propose genl_dereference() upstream and uses it instead of our
version.
Signed-off-by: Jesse Gross <jesse@nicira.com> Acked-by: Ben Pfaff <blp@nicira.com>
Jesse Gross [Sat, 19 Nov 2011 17:08:56 +0000 (09:08 -0800)]
datapath: Use u64_stats_sync for datapath and vport stats.
We currently use a seqcount to prevent reading partial 64-bit stats
on 32-bit CPUs. u64_stats_sync uses the same logic but elides it on
64-bit and uniprocessor machines. This improves performance (primarily
on non-x86 architectures) at the cost of not guaranteeing that packet
and byte counts were necessarily read together.
Suggested-by: Stephen Hemminger <shemminger@vyatta.com> Signed-off-by: Jesse Gross <jesse@nicira.com> Acked-by: Ben Pfaff <blp@nicira.com>
Jesse Gross [Thu, 17 Nov 2011 23:54:10 +0000 (15:54 -0800)]
datapath: Better handle vlan packets sent to userspace.
We no longer clone packets that are sent via the userspace action
because placing them in Netlink attributes makes a copy so we
generally don't touch the original. The one exception to this is
accelerated vlan tags, which are currently inserted into the
original packet as long as it isn't cloned. Although the clone
check prevents us from causing problems for past packets it has
issues for future processing:
* It turns accelerated tags into non-accelerated tags. This isn't
inherently a problem but some cards may not properly support
offloads with in-band tags.
* It doesn't update CHECKSUM_COMPLETE if there is one.
* If the operation fails, it will free the packet resulting in a
later use-after-free.
This patch fixes the above issues with a conservative approach.
It's possible to do it more efficiently but it probably doesn't
matter in most cases.
Signed-off-by: Jesse Gross <jesse@nicira.com> Acked-by: Ben Pfaff <blp@nicira.com>
Ethan Jackson [Fri, 18 Nov 2011 00:47:49 +0000 (16:47 -0800)]
ofproto-dpif: Simplify output action composition.
Before this patch, the logic for outputting to a port was scattered
all around ofproto-dpif. This patch simplifies the code by forcing
it to use one code path to check if a port is forwarding, and
output if appropriate. Future patches will rely on this
simplification to implement new features.
Ethan Jackson [Fri, 18 Nov 2011 00:52:09 +0000 (16:52 -0800)]
ofproto-dpif: Improperly handled OFPP_ALL action.
According to the OpenFlow specification, the OFPP_ALL output to
every port except the input port regardless of whether or not they
are "blocked or link down". This patch implements this logic, and
marginally simplifies the interface of flood_packets().
Ethan Jackson [Fri, 18 Nov 2011 01:11:04 +0000 (17:11 -0800)]
ofproto-dpif: Consistently set NetFlow Output Interface.
Some parts of the code set the NetFlow Output Interface to the
OpenFlow port. Other set it to the datapath port. This patch
consistently sets it to the OpenFlow port.
Ethan Jackson [Fri, 18 Nov 2011 02:06:55 +0000 (18:06 -0800)]
tests: Allow unit tests to run as root.
The unit tests did not allow users to run them as root because
ovs-vswitchd would destroy all of the existing 'system' datapaths.
This patch prevents ovs-vswitchd from registering 'system'
datapaths when running unit tests preventing the issue.
Ansis Atteka [Fri, 18 Nov 2011 21:11:46 +0000 (13:11 -0800)]
packaging: Fix Xen and RH packaging error that was introduced with ovs-test utility
My previous ovs-test utility commit broke Xen and RH packaging.
This commit will address this issue by not including any ovs-test related
files into those two packages.
Jesse Gross [Fri, 18 Nov 2011 18:54:12 +0000 (10:54 -0800)]
datapath: Fix unaligned access when storing stats.
Both datapath and vport stats contain 64-bit members in a struct
but we write them directly in Netlink attributes which only
guarantee 32-bit alignment. This causes problems on RISC
architectures that care about alignment so this computes the stats
on the stack and then memcpy's them.
Signed-off-by: Jesse Gross <jesse@nicira.com> Acked-by: Ben Pfaff <blp@nicira.com>
Ansis Atteka [Mon, 31 Oct 2011 21:56:08 +0000 (14:56 -0700)]
ovs-test: A new tool that allows to diagnose connectivity and performance issues
This tool will be a replacement for the current ovs-vlan-test
utility. Besides from connectivity issues it will also be able
to detect performance related issues in Open vSwitch setups.
Currently it uses UDP and TCP protocols for stressing.
Justin Pettit [Thu, 17 Nov 2011 22:08:09 +0000 (14:08 -0800)]
ofproto-dpif: Fix segfault in mirror_update_dups().
Fixes crash introduced in 9ba15e (ofproto-dpif: Improve RSPAN
translation performance from O(n**2) to O(n).) The code always
dereferenced the members of the "mirrors" array in ofproto even if they
were null.
Ben Pfaff [Thu, 17 Nov 2011 18:46:03 +0000 (10:46 -0800)]
ofproto-dpif: Get rid of "struct dst".
struct dst is an intermediate form for OFPP_NORMAL translation that
has existed since the beginning of Open vSwitch development. It
has always been a bit ugly, since ideally we wouldn't need any intermediate
form at all. This commit eliminates it, which speeds up OFPP_NORMAL
translation.
struct dst was used earlier to eliminate duplicate packets in OFPP_NORMAL
output. Now, we have rules that eliminate duplicate packets in a cheaper
way.
OFPP_NORMAL outputs packets for two different reasons, forwarding and
mirroring, so those are the two possible sources of packet duplication.
Forwarding by itself never outputs two copies of a packet to a single port
on a given VLAN, and this is also true of mirroring by itself since commit
"ofproto-dpif: Improve RSPAN translation performance from O(n**2) to O(n)".
The only remaining possibility, then, is that forwarding and mirroring
between them duplicate an output packet. However, the algorithms are now
designed to prevent this. Forwarding will never output to a mirroring
destination output port. Forwarding will only output to a mirroring
output VLAN if the packet arrived on a mirroring output VLAN, and in that
case mirroring is disabled.
This commit has the side effect of improving behavior for VLAN output.
Previously, a packet that arrived with an 802.1Q tag with both VID and PCP
of 0 would be output with a similar tag in some cases; now it is
consistently stripped. This change is reflected in the unit test change.
We really need some unit tests for mirroring. I have not tested mirroring
behavior, only theorized about it (see above).
Ben Pfaff [Thu, 17 Nov 2011 18:24:05 +0000 (10:24 -0800)]
tests: Rewrite code for comparing sets of ODP actions.
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.
Ben Pfaff [Wed, 5 Oct 2011 23:33:57 +0000 (16:33 -0700)]
ofproto-dpif: Improve RSPAN translation performance from O(n**2) to O(n).
This code previously checked whether each individual mirror output was
already in the set of destinations. This is O(n**2) in the number of
ports in a bridge.
The new code uses a smarter algorithm to eliminate duplicates, one that is
O(n) in the number of ports in a bridge.
Ben Pfaff [Wed, 5 Oct 2011 22:42:17 +0000 (15:42 -0700)]
ofproto-dpif: Make compose_mirror_dsts() harder to screw up.
I came close to add a "continue;" inside the main "while" loop in
compose_mirror_dsts(), which would have turned it into an infinite loop.
This commit changes it to a "for" loop that is harder to screw up.
Ben Pfaff [Fri, 11 Nov 2011 23:25:49 +0000 (15:25 -0800)]
ofproto-dpif: Remove duplicate VLAN logic.
flow_get_vlan() duplicated the logic in input_vid_to_vlan() in an
unclear way and added some logic of its own to detect invalid
input VLANs. This commit eliminates the duplication and makes the
code easier to understand.
Ben Pfaff [Wed, 5 Oct 2011 22:26:49 +0000 (15:26 -0700)]
ofproto-dpif: Do not output RSPAN packets to SPAN ports.
It's always been my intention that ports used as port mirroring
destinations (SPAN) be reserved solely for that purpose. When SPAN and
RSPAN are both configured, however, RSPAN mirror packets could get directed
to SPAN ports, which was unintentional.
This commit also updates the documentation to make it clear (if that is
even necessary) that this behavior is intentional.
Jesse Gross [Wed, 16 Nov 2011 21:39:40 +0000 (13:39 -0800)]
datapath: Reformat copyright messages.
Many of our kernel copyright messages make reference to code being
copied from the Linux kernel, which is a bit odd for code in the
kernel. This changes them to use the standard GNU GPL boilerplate
instead. It does not change the actual license, which continues to
be GPLv2.
Signed-off-by: Jesse Gross <jesse@nicira.com> Acked-by: Ben Pfaff <blp@nicira.com>
Justin Pettit [Tue, 15 Nov 2011 09:33:08 +0000 (01:33 -0800)]
ofproto: Disable STP when unregistering a port.
If a port is removed when spanning tree was configured on it, then the
system may crash, since the STP library will try to send packets out a
now non-existent port. This commit disables STP on ports when they are
destroyed.
Justin Pettit [Tue, 15 Nov 2011 08:20:09 +0000 (00:20 -0800)]
stp: Fix tick remainder calculation.
The spanning tree library keeps track of time to know how often it
should update its state and send out BPDUs. OVS is able to track time
in milliseconds, but STP uses a coarser-grained count (256 ticks per
second). To prevent losing milliseconds that didn't account for an
entire tick, the library keeps track of these remaining milliseconds. A
bug miscalculated the remainder and made it too high, which caused the
library to think time was passing more quickly than it was.
This bug wasn't noticeable on a quiet system, since STP only asks to be
woken every second. However, a system with a lot of activity would wake
OVS more frequently and have it call the subsystems' "run" functions.
Justin Pettit [Mon, 14 Nov 2011 23:04:14 +0000 (15:04 -0800)]
stp: Track BPDU tx and rx counts.
When debugging spanning tree, it's useful to have counters about how
many BPDUs have been sent and received. This commit keeps track of
these counters and stores them in a new "statistics" column of the Port
table.
Ben Pfaff [Tue, 15 Nov 2011 01:19:41 +0000 (17:19 -0800)]
datapath: Don't drop packets with partial vlan tags.
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.
Ben Pfaff [Mon, 14 Nov 2011 23:56:43 +0000 (15:56 -0800)]
datapath: Describe policy for extending flow key, implement needed changes.
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>
Simon Horman [Mon, 14 Nov 2011 08:41:28 +0000 (17:41 +0900)]
Make unixctl_command_register() idempotent
The assert() statement in unixctl_command_register() implies that it is
intended to be idempotent but inserting the same name and callback twice
would fail because:
* The callback is not stored directly in the hash, rather it the
cb element of a struct unixctl_command which is stored in the hash.
* Insertion would be attempted even if the entry was already present.
Tyler Coumbes [Mon, 14 Nov 2011 17:08:03 +0000 (09:08 -0800)]
rhel: Add ability to enable bridge compatibility mode in /etc/sysconfig/openvswitch
Add the ability to enable bridge compatibility mode through BRCOMPAT
variable in /etc/sysconfig/openvswitch for the rhel build. When
BRCOMPAT is set to 'yes' the brcompat_mod will be loaded and
ovs-brcompatd daemon will be started.
Ben Pfaff [Thu, 10 Nov 2011 00:15:36 +0000 (16:15 -0800)]
openvswitch.h: Change OVS_KEY_ATTR_TUN_ID from 100 to 63.
It's useful to be able to track sets of attributes by using their values as
bit indexes. That's easier if the values are all in the range of a basic
C integer type.
Signed-off-by: Ben Pfaff <blp@nicira.com> Acked-by: Jesse Gross <jesse@nicira.com>
Ben Pfaff [Fri, 11 Nov 2011 23:10:55 +0000 (15:10 -0800)]
docs: Always build ovs-vswitchd.conf.db.5 in srcdir.
Otherwise we build it in the build directory by default, which breaks the
Debian package build (unless we're working from a "make dist" created
tarball since that has ovs-vswitchd.conf.db.5 in the srcdir as part of
the distribution).
Justin Pettit [Thu, 10 Nov 2011 07:39:16 +0000 (23:39 -0800)]
flow: Use FWW_ flags to wildcard IP DSCP and ECN.
It's no longer necessary to maintain a "nw_tos_mask" wildcard member,
since we only care about completely wildcarding the DSCP and ECN
portions of the IP TOS field. This commit makes that change. It also
goes a bit further in internally using "tos" to refer to the entire TOS
field (ie, DSCP and ECN). We must still refer to the DSCP portions as
"nw_tos" externally through OpenFlow 1.0, since that's the convention it
uses.
Justin Pettit [Thu, 10 Nov 2011 01:42:17 +0000 (17:42 -0800)]
classifier: Don't check masks when adding IPv4/IPv6 addresses.
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.
Justin Pettit [Thu, 10 Nov 2011 01:10:27 +0000 (17:10 -0800)]
Prepend "nw_" to "frag" and "tos" elements.
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.
Ansis Atteka [Tue, 8 Nov 2011 22:32:13 +0000 (14:32 -0800)]
datapath: Kernel flow metadata parsing should be less restrictive
The function flow_metadata_from_nlattrs() is very restrictive
about the ordering and type of metadata attributes that it receives.
This patch will change flow_metadata_from_nlattrs() behavior by
ignoring attributes that it does not understand and allowing them
to be passed in arbitrary order.
Ben Pfaff [Wed, 9 Nov 2011 16:35:33 +0000 (08:35 -0800)]
debian: Strip epoch from version number used in directory names.
This doesn't fix a visible bug, since there's no epoch in the Open vSwitch
version used in Debian, but some Nicira internal build scripts were
inserting an epoch so it was visible in our builds.
Justin Pettit [Wed, 9 Nov 2011 20:17:38 +0000 (12:17 -0800)]
datapath: Rename ipv6_tos to ipv6_tclass.
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.
Justin Pettit [Sat, 5 Nov 2011 22:48:12 +0000 (15:48 -0700)]
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.
Justin Pettit [Thu, 3 Nov 2011 01:22:22 +0000 (18:22 -0700)]
flow: Rearrange IPv6 addresses to remove potential hole in structure.
On some platforms, the in6_addr structure is made up of 16- or 32-bit
members. Depending on the members of the "flow" structure, this can
lead to holes in the middle. Moving the IPv6 addresses to the middle
fixes that on these platforms.
Justin Pettit [Wed, 9 Nov 2011 01:31:04 +0000 (17:31 -0800)]
ofproto-dpif: Actually disable STP on port when disabling STP on port.
When disabling STP on a port that has it enabled on the bridge, STP was
not actually being disabled on the port. This commit directly calls the
update function in this situation.
Jesse Gross [Tue, 8 Nov 2011 04:01:52 +0000 (20:01 -0800)]
tunneling: Separate out multicast port pools.
Currently multicast and unicast tunnel ports share port pools but
there's no overlap between the two in the lookup, which means that
we can do a lookup that has no chance of ever finding a port. This
separates them out.
Suggested-by: Ben Pfaff <blp@nicira.com> Signed-off-by: Jesse Gross <jesse@nicira.com> Acked-by: Ben Pfaff <blp@nicira.com>
Jesse Gross [Sun, 6 Nov 2011 00:18:04 +0000 (17:18 -0700)]
tunneling: Reduce priority of multicast tunnels.
It's possible to have an incoming packet that matches both a unicast
and multicast tunnel if the source address corresponds to the remote_ip
of a unicast tunnel and the destination is multicast. Currently this
will match the multicast tunnel but in reality the unicast tunnel
should probably be considered more specific. This is actually a
common situation in protocols that use a combination of multicast
for flooding and unicast for responses.
Signed-off-by: Jesse Gross <jesse@nicira.com> Acked-by: Ben Pfaff <blp@nicira.com>
Jesse Gross [Sun, 6 Nov 2011 03:13:55 +0000 (20:13 -0700)]
datapath: Renumber non-upstreamable interfaces.
The interfaces related to tunneling aren't finalized enough to be
sent upstream but we also still want to retain them in the OVS
repository. Since userspace should be compatible with both versions
of the kernel, this renumbers the tunnel interfaces to high numbers
so that we can continue to add new interfaces without conflict.
Signed-off-by: Jesse Gross <jesse@nicira.com> Acked-by: Ben Pfaff <blp@nicira.com>
Jesse Gross [Sun, 6 Nov 2011 00:08:21 +0000 (17:08 -0700)]
datapath: Slim down the vport interface.
Many of the function in vport.c are simply pass throughs to their
underlying vport implementation and, of these, many are used only
for bridge compatibility code. This allows users of these functions
to directly call through the ops structure, reducing boilerplate code
and keeping more of the compatibility code together.
Signed-off-by: Jesse Gross <jesse@nicira.com> Acked-by: Ben Pfaff <blp@nicira.com>
ovs-vswitchd.conf.db is distributed so it's in the source directory not
the build directory.
This fixes a Debian package build failure introduced by commit 9840bdbd
"debian: Install ovs-vswitchd.conf.db(5) manpage." I did test that commit
but the build failure didn't show up in my environment (probably I had a
stray file left over from development).
Pravin B Shelar [Fri, 4 Nov 2011 20:31:45 +0000 (13:31 -0700)]
datapath: Convert internal_dev to ndo_fix_features.
From 2.6.39 kernel netdev features are set using set_features and
fix_features APIs. Since internal-dev does not need any special
checks on setting feature, there is no need to define set_features
or fix_features. Only hw_features needs to be set to features that
are supported by internal-dev.
Following patch does same and drops discrete offload setting ops for
newer kernel.
Justin Pettit [Sun, 30 Oct 2011 03:31:00 +0000 (20:31 -0700)]
meta-flow: Update mf_field description of size.
Commit 7257b5 (Implement new fragment handling policy.) added a new
"is_frag" meta-field that used fewer bits than the width of the field.
A comment in mf_field lists these cases, but "is_frag" wasn't included.
This commit updates that.
Justin Pettit [Sun, 30 Oct 2011 03:04:21 +0000 (20:04 -0700)]
nx-match: Increase upper bound length for an nx_match.
Commits d2c0fed (nicira-ext: Bump number of registers to five from
four.) and 7257b5 (Implement new fragment handling policy.) added new
match fields, but didn't update the maximum length of an NXM message.
This commit increases the maximum NXM size to 384 bytes.
Justin Pettit [Mon, 31 Oct 2011 21:32:08 +0000 (14:32 -0700)]
tests: Provide banner for ODP tests.
Previously, the ODP tests were being grouped together with the ovs-ofctl
ones, which is clearly not right. This commit puts it in its own
"datapath parsing and formatting" group.