Justin Pettit [Tue, 3 Jan 2012 00:06:48 +0000 (16:06 -0800)]
ofproto-dpif: Have lookup_input_bundle() return a bundle.
Previously, the function returned an "ofport_dpif", but it makes more
sense to return an "ofbundle". This will also be helpful in a
forthcoming commit.
SLB bonds are very strange beasts. It's taken OVS a while to figure out
how they should really work. Way back in the mists of time, when we were
in the midst of this process, we noticed that the following could happen:
1. Local VM sends a packet to the OVS bridge.
2. OVS bridge learns VM's MAC, forwards packets to SLB bond.
3. Remote switch hasn't learned packet's destination and
forwards packet back to other interfaces in the SLB bond.
Normally nothing bad happens in this scenario because OVS has already
learned the local port for the VM's MAC in step 2 and the rules for SLB
bonding (this is rule #2 in vswitchd/INTERNALS). But at the time we were
implementing this, OVS didn't yet use active flows to keep MAC learning
entries alive; only new flows prevented a MAC entry from aging out. So
in steady state (e.g. just "ping" traffic) OVS would regularly forget MAC
addresses. If the remote switch also happened to forward a packet back to
one of the SLB bond interfaces, then OVS would learn the VM's address on
the bond, with the result that any traffic coming in from the remote switch
would be black-holed until the VM sent a new packet. This was not good.
The fix we applied at the time was commit 2416b8ecea (bridge: Eject NORMAL
flows without a learning entry from datapath.) followed by a small
refinement in commit e96a4d8035 (bridge: Feed flow stats into learning
table.). This fix causes flows that don't have a learning entry to be
ejected from the datapath if revalidation occurs. This forced the next
packet in the flow to go to userspace, which in turn caused learning to
happen, fixing the problem.
However, this isn't a good solution for several reasons:
* It forces more packets to userspace, which is expensive.
* It doesn't just affect the cases where it helps, those where an
SLB bond is actually involved. (This could be fixed, but it is
not worth it.)
* It means that flow installability becomes nondeterministic. When
the first packet shows up for a flow, we install it. But later
if we revalidate it, we have to uninstall it. That doesn't make
sense; a flow should be either installable or not installable,
not some weird mix.
Fortunately, the situation has improved since this fix was originally
designed. First, active flows now keep MAC learning entries alive, since
commit e96a4d8035367 (bridge: Feed flow stats into learning table.)
Second, gratuitous ARP locking, added in commit 7febb9100b (bridge: Filter
some gratuitous ARPs on bond slaves.) means that gratuitous ARPs reflected
on bond slaves don't cause confusion (this is rule #4 in
vswitchd/INTERNALS).
These improvements mean that it is no longer necessary to have this
strange special case at all. Therefore, this commit removes it.
I found this while investigating reports from code that I added to
occasionally check that flow actions were correct.
Ben Pfaff [Tue, 3 Jan 2012 21:34:47 +0000 (13:34 -0800)]
vswitchd: Also consider access port VLANs as "in use" for VLAN splinters.
It's natural to add an access port to a bridge and expect that trunk ports
will then immediately start to work properly with that VLAN without
additional configuration. This change makes that happen.
Ben Pfaff [Thu, 22 Dec 2011 23:51:39 +0000 (15:51 -0800)]
unixctl: Improve readability of "help" output for long command names.
Without this change, if a unixctl command name is 23 character long or
longer, no space appeared between the command name and its usage. This
commit ensures that at least one space always appears.
No command yet has a name this long. I discovered this issue when I added
one that does.
Ben Pfaff [Mon, 2 Jan 2012 20:46:17 +0000 (12:46 -0800)]
ofproto-dpif: Fix GCC warning.
gcc (GCC) 4.1.2 20080704 (Red Hat 4.1.2-48) warned:
ofproto/ofproto-dpif.c: In function 'bundle_send_learning_packets':
ofproto/ofproto-dpif.c:1835: warning: dereferencing type-punned pointer
will break strict-aliasing rules
I agree that its analysis matches what the C standard says. This commit
fixes the problem and avoids the warning.
The assignment to 'port' isn't actually necessary. I included it because
I like to have a variable with the correct type near the use of that type
through a "void *". Then "grep" for that type is more effective, and the
compiler will be able to diagnose any later change to (in this case) the
type of the first parameter to send_packet().
Ben Pfaff [Mon, 26 Dec 2011 22:40:54 +0000 (14:40 -0800)]
ofproto-dpif: Omit "execute" operation entirely when there are no actions.
There's no point in executing an empty set of actions.
dpif_execute() has had this optimization internally for a long time but
dpif_operate() doesn't. For dpif_operate() it seems like a bigger win to
optimize it at this higher level, avoiding adding any operation to the
array at all.
Justin Pettit [Sat, 31 Dec 2011 01:56:08 +0000 (17:56 -0800)]
ovs-ofctl: Fix "cookie mask" issue in diff-flows command.
Commit e729e79 (Add ability to restrict flow mods and flow stats
requests to cookies.) introduced a cookie_mask field to the
ofputil_flow_stats_request struct that allowed restricting the flows to
a particular cookie pattern. The diff-flows command uses the
read_flows_from_switch() function, which did not properly initialize
this field, which would cause it to miss flows. This commit sets the
value to zero, which allows any cookie.
Justin Pettit [Fri, 23 Dec 2011 20:23:24 +0000 (12:23 -0800)]
Add ability to restrict flow mods and flow stats requests to cookies.
With this commit, it is possible to limit flow deletions and
modifications to specific cookies. It also provides the ability to
dump flows based on their cookies.
Jesse Gross [Tue, 27 Dec 2011 01:33:03 +0000 (17:33 -0800)]
packet: Match userspace and kernel definition of ICMP header.
Current userspace considers an ICMP header to be 4 bytes consisting
of the type, code, and checksum. The kernel considers it to be 8
bytes because it also counts the two data fields that contain
type-specific information (and are always present). Since flow
extract will zero out headers that are not completely present this
means that an ICMP packet that has a header of 5-7 bytes will be
interpreted differently by userspace and kernel. This fixes the
problem by adopting the kernel's version of the ICMP header in
userspace.
Ansis Atteka [Mon, 19 Dec 2011 20:43:34 +0000 (12:43 -0800)]
vswitchd: In-band rules for Controller are missing after executing force-reload-kmod command
In current implementation vswitchd adds Controller in-band rules only if
there is a route in kernel routing table that might route traffic to the
Controller. But, when executing force-reload-kmod command, network
configuration (e.g. assigned IP addresses, routes) are flushed away,
hence Controller in-band rules are not added.
This commit fixes this limitation and allows vswitchd to add Controller
in-band rules even if there are no routes in the kernel routing table.
Ben Pfaff [Mon, 19 Dec 2011 22:46:16 +0000 (14:46 -0800)]
netflow: Add basic unit tests.
These tests would have caught the flow statistics bug introduced by commit 501f8d1fd75 (ofproto-dpif: Batch interacting with the dpif on flow miss
operations.)
Ben Pfaff [Mon, 19 Dec 2011 22:18:00 +0000 (14:18 -0800)]
netflow: Move packet definitions to header file.
An upcoming commit will introduce code outside of ofproto/netflow.c that
works with NetFlow packets, so we need the protocol definitions in a common
location.
Ben Pfaff [Thu, 8 Dec 2011 21:22:50 +0000 (13:22 -0800)]
tests: Add expected output parameter to OVS_VSWITCHD_START.
It's convenient to pass commands for ovs-vsctl directly to
OVS_VSWITCHD_START, but until now those commands could have no output
because that would cause a test failure. This commit adds an optional
argument to supply ovs-vsctl expected output, and adjusts some test
cases to use it instead of calling ovs-vsctl a second time.
Ben Pfaff [Thu, 8 Dec 2011 20:45:18 +0000 (12:45 -0800)]
tests: Update ovs-vswitchd log messages to ignore.
Commit 579a77e024 (tests: Allow unit tests to run as root.) means that
ovs-vswitchd doesn't output either of these log messages anymore when
the unit tests run, so there's no need to ignore them anymore.
Ben Pfaff [Mon, 19 Dec 2011 22:28:42 +0000 (14:28 -0800)]
poll-loop: Track the poll timeout as an absolute, not a relative time.
This is a necessary prerequisite for allowing time to be "fast forwarded"
in unit tests, to keep tests that depend on the passage of time from
running in real time. Without this change, a code sequence like this:
poll_timer_wait(1000);
...fast forward time 5 seconds...
poll_block();
would still sleep for a second, because the poll_loop module would still
have a relative timeout of 1000 ms.
Ben Pfaff [Fri, 2 Dec 2011 23:29:19 +0000 (15:29 -0800)]
unixctl: Implement quoting.
The protocol used by ovs-appctl has a long-standing bug that there
is no way to distinguish "ovs-appctl a b c" from "ovs-appctl 'a b c'".
This isn't a big deal because none of the current commands really
want to accept arguments that include spaces, but it's kind of a silly
limitation.
At the same time, the internal API is awkward because every user is
stuck doing its own argument parsing, which is no fun.
This commit fixes both problems, by adding shell-like quoting to the
protocol and modifying the internal API from one that passes a string
to one that passes in an array of pre-parsed strings. Command
implementations may now specify how many arguments they expect. This
simplifies some command implementations significantly.
Ben Pfaff [Thu, 8 Dec 2011 20:40:01 +0000 (12:40 -0800)]
ofproto-dpif: Include datapath flow misses in flow statistics.
Commit 501f8d1fd75 (ofproto-dpif: Batch interacting with the dpif on flow
miss operations.) caused packets handled manually in userspace not to be
counted in flow statistics. This patch fixes the problem.
Signed-off-by: Ben Pfaff <blp@nicira.com>
Bug #8494.
Ethan Jackson [Thu, 15 Dec 2011 21:39:38 +0000 (13:39 -0800)]
bond: Warn of imminent default bond_mode change.
Post version 1.4.*, we are planning to change the default bond_mode
from balance-slb to active-backup. This commit warns users of the
change so that they can prepare.
Ben Pfaff [Fri, 16 Dec 2011 18:09:30 +0000 (10:09 -0800)]
ofproto-dpif: Fix use-after-free for OFPP_CONTROLLER flows.
When a flow consists solely of an output to OFPP_CONTROLLER, we avoid a
round trip to the kernel and back by calling execute_controller_action()
from handle_flow_miss(). However, execute_controller_action() frees the
packet passed in. This is dangerous, because the packet and the upcall
key are in the same block of malloc()'d memory, as the comment on struct
dpif_upcall says:
/* A packet passed up from the datapath to userspace.
*
* If 'key' or 'actions' is nonnull, then it points into data owned by
* 'packet', so their memory cannot be freed separately. (This is hardly a
* great way to do things but it works out OK for the dpif providers and
* clients that exist so far.)
*/
Thus, we get a use-after-free later on in handle_flow_miss() and eventually
a double free.
This fixes the problem by making execute_controller_action() clone the
packet in this case.
Ben Pfaff [Fri, 16 Dec 2011 18:02:51 +0000 (10:02 -0800)]
ofproto-dpif: Flush MACs for deleted ports from every bridge.
Consider this scenario: two hypervisors HV-1 and HV-2, connected to a
common physical network over SLB bonds. Two virtual machines VM-1 and VM-2
are both running on HV-1. Patch ports are in use, so that each VM is not
connected to a bridge with a physical Ethernet port but is actually one
virtual "hop" away across a patch port to a second OVS bridge. VM-2 is
running a "ping" process directed at VM-1.
Now migrate VM-1 to HV-2. Suppose that VM-1 fails to send out a gratuitous
ARP following migration, or that the gratuitous ARPs are lost, e.g. because
they are sent before the OpenFlow controller manages to populate the flow
table with rules to allow the VM's traffic
Now we are in a situation where HV-1 has learned that VM-1 is local and
HV-2 has learned that VM-1 is on its bond; both are wrong. One would
expect the problem to resolve itself as soon the VM-1 sends out its first
packet. However, SLB bonds (for important reasons documented in
vswitchd/INTERNALS) are very reluctant to learn that a currently local MAC
is actually on the bond: the only ways to learn that the MAC is on the bond
are to receive a gratuitous ARP (which we won't, since they were dropped)
or for the MAC learning entry to expire after 60 seconds. This means that
VM-1 can send out as much ordinary traffic as it wants (even ARP requests
and other broadcasts) but HV-1 will drop all of it at the physical Ethernet
since it believes that VM-1 is local.
(In an ordinary setup with a single bridge, HV-1 would have unlearned the
address for VM-1 when VM-1's port was deleted, but that didn't happen
because HV-1 only learned that VM-1 was on the patch port that leads to the
integration bridge. The patch port didn't get deleted.)
HV-2 does quickly learn that VM-1 is now local. SLB bonds are only
reluctant to learn that something they think is local is actually on the
bond, not the reverse.
This commit attempts to work around the problem by flushing the MAC
associated with a port from *every* bridge when a port is deleted.
This commit demonstrates yet another good reason not to use SLB bonds.
Ben Pfaff [Fri, 16 Dec 2011 18:03:08 +0000 (10:03 -0800)]
dpif-netdev: Correctly report types of dummy netdevs.
When dpif-netdev is in use as a "dummy" datapath, the devices that are
added to it have type "dummy", but the dpif methods that report the types
of ports reported that they had type "system". This meant that every time
the bridge code reconfigured, it would see that the ports had the wrong
types and delete and re-add them, which had other undesirable effects such
as flushing the entire MAC learning table whenever ovs-vsctl changed the
configuration.
Ben Pfaff [Fri, 9 Dec 2011 23:54:43 +0000 (15:54 -0800)]
dpif-linux: Avoid valgrind warning in epoll_ctl() call.
Valgrind points out correctly that there are uninitialized bytes in the
'event' structure. That's OK, but it doesn't hurt to suppress the warning
by zeroing all of the bytes.
Ben Pfaff [Mon, 12 Dec 2011 22:44:23 +0000 (14:44 -0800)]
bridge: Enable support for access and native VLAN ports on bonds.
Since Open vSwitch's inception we've disabled the use of bonds as access
ports, for no particularly good reason. This also unintentionally
prevented bonds from being used as native VLAN ports.
This commit removes the code that prevented using bonds these ways
Reported-and-tested-by: "Michael A. Collins" <mike.a.collins@ark-net.org> Signed-off-by: Ben Pfaff <blp@nicira.com>
Ben Pfaff [Mon, 12 Dec 2011 17:37:34 +0000 (09:37 -0800)]
debian: Correct licensing information for user/kernel shared header files.
The intent is to license all shared user/kernel header files under both
GPLv2 and Apache v2. The license statement here said GPLv3 instead of
GPLv2, so this commit fixes that problem.
Also, include/openvswitch used to be where all the shared user/kernel
header files were located, but this is no longer true, and now there is a
userspace-only header file also in include/openvswitch, so this commit now
lists all of the user/kernel header files explicitly.
Neil McKee [Sat, 10 Dec 2011 00:56:32 +0000 (16:56 -0800)]
sFlow: add Sun Industry Standards Source License 1.1 as licensing option
The sFlow License was not on the list for the Fedora Project, but the
Sun Industry Standards Source License 1.1 was (and it has the right
properties). So this patch includes it as a licensing option in the
relevant places (COPYING and the lib/sflow* sources). Let me know
if this looks OK or not.
Signed-off-by: Neil McKee <neil.mckee@inmon.com> Signed-off-by: Ben Pfaff <blp@nicira.com> Acked-by: Chris Wright <chrisw@sous-sol.org>
Ben Pfaff [Fri, 9 Dec 2011 23:57:55 +0000 (15:57 -0800)]
bridge: Avoid use-after-free with VLAN splinters and multiple bridges.
The VLAN splinters feature uses a "pool" to track and free allocated
blocks. There's only one pool, but the implementation was freeing all of
the blocks in it for every bridge during reconfiguration, not just once for
each reconfiguration, so caused a use-after-free when there was more than
one bridge and a bridge other than the last one in the list of bridges had
a VLAN splinter port.
Bug #8671. Reported-by: Michael Mao <mmao@nicira.com> Signed-off-by: Ben Pfaff <blp@nicira.com>
Ben Pfaff [Fri, 9 Dec 2011 21:09:23 +0000 (13:09 -0800)]
lacp: Avoid valgrind warning in lacp_configure() if custom timing not used.
The caller currently doesn't fill in s->custom_time unless it actually
wants a custom LACP time, but lacp_configure() still does a calculation
with it, provoking a warning from valgrind. This eliminates the warning.
The calculated value was not actually used in this case, so this commit
does not fix a real bug.
The xenserver specfile still places them in /etc/xensource/bugtool since
that's a distro policy. Of course, the rpmlint warnings are as well,
however, this seems like a more logical place for the bugtool plugins.
Signed-off-by: Chris Wright <chrisw@sous-sol.org> Signed-off-by: Ben Pfaff <blp@nicira.com>
Chris Wright [Fri, 9 Dec 2011 07:36:03 +0000 (23:36 -0800)]
man: fix pic issue at the source
The commit 0993b66 (man: pic failed to run during manpage-check) worked
around the manpage-check warning generated by groff. Using "-T ascii"
rather "-T utf8" was enough to silence the warning because the man page
has this condition in it:
.if !'\*[.T]'ascii'
However, rpmlint generates the same warning as manpage-check was (it
uses -Tutf8), and manpages are generated using -Tutf8 (leading to an
fairly unreadable drawing). So let's change the logic a bit and allow
pdf generation w/ nice drawing and kill it for tty's.
Cc: Ethan Jackson <ethan@nicira.com> Signed-off-by: Chris Wright <chrisw@sous-sol.org> Signed-off-by: Ben Pfaff <blp@nicira.com>
Ben Pfaff [Tue, 6 Dec 2011 23:55:22 +0000 (15:55 -0800)]
socket-util: Correctly return negative values for errors.
The comment on this function says that negative values indicate errors, and
the callers assume that too, but in fact it was returning positive errno
values, which are indistinguishable from valid fd numbers.
It really seems to me that this should have been found pretty quickly in
the field, since stream-tcp and stream-ssl both use inet_open_passive to
implement their passive listeners. I'm surprised that no one has reported
it.
Rob Hoes [Mon, 5 Dec 2011 14:43:12 +0000 (14:43 +0000)]
xenserver: Reduce number of xapi DB calls in plugin
When there are lots of PIFs in a XenServer/XCP pool, for example when
there are many VLANs configured on the pool, operations such as
PIF.get_all and loops over all PIFs which include database operations,
are very inefficient when executed on a pool slave, and should be
avoided as much as possible. This patch reduces the number of database
calls in the update function of the openvswitch-cfg-update xapi plugin.
Signed-off-by: Rob Hoes <rob.hoes@citrix.com> Acked-by: Dominic Curran <Dominic.curran@citrix.com>
Justin Pettit [Mon, 5 Dec 2011 00:33:54 +0000 (16:33 -0800)]
netdev-linux: Don't restrict policing to IPv4 and don't call "tc".
Mike Bursell pointed out that our policer only works on IPv4
traffic--and specifically not IPv6. By using the "basic" filter, we can
enforce policing on all traffic for a particular interface.
Jamal Hadi Salim pointed out that calling "tc" directly with system() is
pretty ugly. This commit switches our remaining "tc" calls to directly
sending the appropriate netlink messages.
Suggested-by: Mike Bursell <mike.bursell@citrix.com> Suggested-by: Jamal Hadi Salim <hadi@cyberus.ca>
Today i played with openvswitch on my workstation with kernel 2.6.40 and found that it break when i built. The
+issue is introduced by commit ceb176fdb72bb7ce90debc66e1eeb1d25823d30a
Jesse Gross [Fri, 2 Dec 2011 00:09:05 +0000 (16:09 -0800)]
datapath: Remove custom version of ipv6_skip_exthdr().
We currently have a version of ipv6_skip_exthdr() which is
identical to the main one with the addition of fragment reporting.
We can propose our version for upstream and then use it directly
without duplication.
Signed-off-by: Jesse Gross <jesse@nicira.com> Acked-by: Ben Pfaff <blp@nicira.com>
Ben Pfaff [Wed, 30 Nov 2011 18:59:12 +0000 (10:59 -0800)]
netdev-linux: Ref and unref the netdev_linux_cache_notifier for taps too.
netdev-linux uses netdev_linux_cache_notifier to flush its cache when the
kernel notifies userspace that a particular network device's configuration
or status has changed. This is as applicable to tap devices as to system
and internal devices, so we should create and destroy the notifier for
tap devices also.
I doubt that in practice it's possible to run ovs-vswitchd without having
a non-tap device open, at least with the kernel datapath, because the
local port for a bridge is not a tap device, so there should be no need to
backport this to older versions.
Ben Pfaff [Wed, 30 Nov 2011 21:07:38 +0000 (13:07 -0800)]
ovs-ofctl: Improve usage message.
TARGET and SWITCH are different because TARGET can refer to a switch or a
controller whereas SWITCH must be a switch, but TARGET wasn't defined
before.
Also, TARGET seems a little more user-friendly than the VCONN that was used
here before.
Ben Pfaff [Wed, 30 Nov 2011 20:09:35 +0000 (12:09 -0800)]
bridge: Configure datapath ID earlier.
The design intent is for LACP ports to use the datapath ID as the default
system ID when none is specifically configured. However, the datapath ID
is not available that early. This commit makes it available earlier.
This commit does not fix another bug that prevents the LACP system ID from
being set properly (nothing sets it at all, in fact, so it always uses 0).
Ben Pfaff [Wed, 16 Nov 2011 22:38:52 +0000 (14:38 -0800)]
ovsdb: Correctly implement conditions that include multiple clauses.
Multiple-clause conditions in OVSDB operations with "where" clauses are
supposed to be conjunctions, that is, the condition is true only if every
clause is true. In fact, the implementation only checked a single clause
(not necessarily the first one) and ignored the rest. This fixes the
problem and adds test coverage for multiple-clause conditions.
Ben Pfaff [Wed, 23 Nov 2011 20:15:42 +0000 (12:15 -0800)]
daemon: Better log when fork child dies early from signals.
On one machine, "/etc/init.d/openvswitch-switch start" failed to start
with:
ovs-vswitchd: fork child failed to signal startup (Success)
Starting ovs-vswitchd ... failed!
"strace" revealed that the fork child was actually segfaulting, but the
message output didn't indicate that in any way. This commit fixes the
log message (but not the segfault itself).
Reported-by: Michael Hu <mhu@nicira.com>
Bug #8457.