Ben Pfaff [Sat, 3 Jan 2009 00:13:07 +0000 (16:13 -0800)]
Use separate Netlink multicast groups for different datapaths.
Otherwise every socket that listens for OpenFlow multicast messages will
get them for every single datapath. Not only is that a waste of memory
and time, it also allows one congested bridge to effectively DoS other
bridges that have little traffic.
Ben Pfaff [Fri, 2 Jan 2009 21:58:08 +0000 (13:58 -0800)]
Discard OpenFlow messages not for us in dpif_recv_openflow().
Currently there is only a single Netlink multicast group that is shared
by all OpenFlow datapaths. This is undesirable and should be fixed, but
a solution in every case is impossible due to Linux kernel limitations.
This commit works around the problem by dropping OpenFlow messages that
are related to a datapath that we are not interested in.
This should fix vswitchd behavior when more than one bridge is configured.
Thanks to Keith and Justin for diagnosing the problem.
Justin Pettit [Wed, 31 Dec 2008 18:55:13 +0000 (10:55 -0800)]
Return meaningful errors for brctl modification commands.
When datapaths and interfaces are modified, we now do more thorough
checks to see whether they will succeed or not. When datapaths are
added, we now block until they are created, so that follow-on ioctl
calls to attach interfaces will immediately work.
Justin Pettit [Wed, 31 Dec 2008 06:31:38 +0000 (22:31 -0800)]
Add support for "brctl show".
This makes datapaths and their interfaces show up as you'd expect when
"brctl show" is run. To get this functionality, you must insmod the
brcompat kernel module.
Ben Pfaff [Tue, 30 Dec 2008 21:25:35 +0000 (13:25 -0800)]
brcompat: Write temporary file to same directory as config file.
Otherwise, we will write it in the current working directory, which will
be / if we're running as a daemon (see daemonize()). We shouldn't assume
that we can write to that directory, and it might not be in the same
file system as the output file anyhow.
Ben Pfaff [Tue, 30 Dec 2008 21:03:48 +0000 (13:03 -0800)]
Properly lock dp_mutex around changes to the datapath.
We weren't locking dp_mutex() here but it really is necessary. See the
comment on dp_mutex itself for details.
This actually restores some of the locking removed by commit 47b8652d
"Simplify use of dp_mutex." That commit is correct that we can take
dp_mutex at a high level in dp_genl_openflow(), but it removes locking
from functions that are not called through dp_genl_openflow(): in
particular any Netlink command other than DP_GENL_C_OPENFLOW does not
go through that function, so those commands need to acquire the mutex
themselves.
Ben Pfaff [Tue, 30 Dec 2008 19:40:22 +0000 (11:40 -0800)]
Fix GNU make warning about overriding commands for a target.
We would add a target to link a C file into datapath directories each
time that file was mentioned in a list of sources, so when we put a source
file into two different lists of sources it got two such targets. Fixed
by using the GNU make $(sort) function to eliminate duplicates.
Ben Pfaff [Tue, 30 Dec 2008 19:31:25 +0000 (11:31 -0800)]
Restore openflow-netlink.h ABI.
Inserting DP_GENL_A_DP_NAME above DP_GENL_A_PORTNAME in commit 660f6596ba31, "First cut at bridge compatibility for vswitchd" forces users
not to use any existing builds of userspace utilities, because the
numbering of all the netlink attributes for OpenFlow has changed. This
change restores the numbering and should make older dpctl, etc. still able
to work.
Justin Pettit [Tue, 30 Dec 2008 19:23:34 +0000 (11:23 -0800)]
Fix missing symbol in brcompat kernel module on older kernels.
In kernels older than 2.6.23, the genl_register_mc_group function is not
defined, so we fake it. The original checkin didn't build the C file
that contains the function's definition.
Ben Pfaff [Tue, 30 Dec 2008 18:26:03 +0000 (10:26 -0800)]
brcompat: Build brcompat module only under Linux 2.6.
brcompat fails to compile under Linux 2.4 due to the lack of brioctl_set()
and other symbols, but there's no intention of supporting Linux 2.4 for it
anyhow, so don't build it under Linux 2.4.
Ben Pfaff [Tue, 30 Dec 2008 18:25:50 +0000 (10:25 -0800)]
brcompat: Remove policy from Netlink code.
Policies are only useful for data that is received by a Netlink socket.
They do not apply to data that is sent out. Since this code does not
parse the messages that it receives at all, it does not need any policy.
Ben Pfaff [Tue, 30 Dec 2008 18:01:06 +0000 (10:01 -0800)]
Make datapath compile with Xen kernel.
The Xen kernel is based on 2.6.18 but backports many features from later
kernels. It is not always possible, therefore, to detect whether we need
to use compatibility code based on LINUX_VERSION_CODE. This commit fixes
the problem by using configure-time tests to check for the need for the
compatibility code.
Build-tested on Linux 2.6.15 through 2.6.28 with the default configuration
(except that some kernels needed preemption turned off) and with Xen
kernel 2.6.18-92.1.10.el5.xs5.0.0.394.644.
Justin Pettit [Tue, 30 Dec 2008 06:53:08 +0000 (22:53 -0800)]
First cut at bridge compatibility for vswitchd.
This set of changes allows the bridge ioctls to be used for adding and
removing datapaths and interfaces. To enable, one must insmod the
new "brcompat_mod.ko" kernel module. Then, vswitchd is run with the
"--brcompat" flag. See the man page for vswitchd for more details.
Ben Pfaff [Mon, 29 Dec 2008 22:29:26 +0000 (14:29 -0800)]
vswitchd: Fix svec_diff().
The logic bugs here were causing bridge.c to do too much work adding and
deleting interfaces unnecessarily and perhaps in some circumstances getting
the set of interfaces wrong entirely.
Ben Pfaff [Mon, 29 Dec 2008 21:26:19 +0000 (13:26 -0800)]
Make ds_cstr() always null-terminate the string.
Most of the time the string in "struct ds" is
null-terminated, but there seem to be a few corner cases
where it is not. Make ds_cstr() always put in the null
terminator, for safety.
Ben Pfaff [Sat, 27 Dec 2008 23:36:49 +0000 (15:36 -0800)]
Factor out common parts of manpages.
There was a lot of duplication in the sources for the
manpages, because many of the programs have common options.
This factors out some of the duplication into include
files, using the man ".so" directive. It also uses the
".ds" directive to define strings that should be
customized for each program's manpage.
Ben Pfaff [Sat, 27 Dec 2008 05:26:46 +0000 (21:26 -0800)]
vswitchd: Actually tag flows that go out bonded devices.
The change that introduced rebalancing for bonded devices
set up the infrastructure for revalidating flows that go
out bonded devices, but neglected to actually tag those
flows. This fixes the problem.
Ben Pfaff [Fri, 26 Dec 2008 18:28:17 +0000 (10:28 -0800)]
Fix learning-switch STP breakage from "out_port" in flow stats request.
ofp_flow_stats_request recently added a new member, "out_port", to select
only flows that output to a particular port. Unfortunately this code
in learning-switch.c was not updated to set that member to OFPP_NONE,
with the result that it would only get flows that output to port 0.
This bug was found when looking at this code for another reason and thus
is no guarantee that the STP code in learning-switch actually works.
Justin Pettit [Tue, 23 Dec 2008 08:30:38 +0000 (00:30 -0800)]
Fix setting "of" device name based on unitialized dp_idx.
The name of the "of" device is of the form "of<dp_idx>". The device
driver assumes the "dp_idx" field has been set in the datapath struct
before its called. This was not the case.
Justin Pettit [Fri, 19 Dec 2008 20:51:42 +0000 (12:51 -0800)]
Fix flag to indicate whether Flow End messages should be sent.
The secchan code set whether Flow End messages should based on the last
configuration request. This means that if NetFlow messages need to be
generated, but the cotnroller doesn't flow Flow Expiration messages, the
Flow End meta-message was disabled.
Justin Pettit [Fri, 19 Dec 2008 20:49:09 +0000 (12:49 -0800)]
Fix null pointer dereference when a delete flow command is executed.
A set of missing parentheses was causing an attempt to send a Flow End
message even if no flow existed. The code to send the Flow End message
would try to access data in the flow and cause a kernel panic.
Ben Pfaff [Thu, 18 Dec 2008 22:00:23 +0000 (14:00 -0800)]
Add support for VLAN tags to the MAC learning library.
vswitchd needs to keep separate per-VLAN MAC learning tables, so this adds
a VLAN tag to each MAC learning table entry. The existing users of the
MAC learning table don't care about VLANs, so they always pass in a VLAN
of 0.
There is a very good chance that vswitchd will need additional features in
its MAC learning table that don't fit well into the existing library. In
that case this commit will probably be reverted and a separate MAC learning
implementation added in the vswitch directory.
Ben Pfaff [Thu, 18 Dec 2008 19:17:36 +0000 (11:17 -0800)]
secchan: Switch in-band control traffic by hand only on OpenFlow TCP ports.
To run services, other than the controller itself, on the same IP and MAC
as the controller, sophisticated controllers such as NOX need to have some
insight into the controller's location, etc. Before this commit, this
was not possible, because any traffic to or from the controller's MAC
address was switched "by hand" by secchan, without involving the controller
at all.
After this commit, only traffic to or from the controller's MAC *and on
the OpenFlow TCP or SSL port* is switched by hand, which should fix the
problem.
Ben Pfaff [Wed, 17 Dec 2008 22:39:06 +0000 (14:39 -0800)]
Don't use separate asynchronous event connection for user datapath.
Commit 14439fa80c, "Maintain separate async and sync connections to nl:0
in secchan," modified secchan to use two separate connections to the
datapath, one for asynchronous events, one for requests and replies. This
technique doesn't work for the user datapath, which always sends
asynchronous events on all its connections. Fortunately, it isn't
necessary for the user datapath, either, because the user datapath is
smart enough not to drop message replies.
Justin Pettit [Wed, 17 Dec 2008 22:24:22 +0000 (14:24 -0800)]
Add support for exporting flow information in NetFlow v5 format.
This is implemented by having the datapath send a new meta-Flow End message
that contains all the information needed by NetFlow v5 and the OpenFlow
Flow Expiration messages. secchan grabs these Flow End messages and
generates any requested Flow End and NetFlow messages. The Flow End
message is implemented as a Nicira vendor extension, but it is only used
internally between the datapath and secchan, so the switch is still fully
compatible with OpenFlow v0.8.9.
NOTE: This change has not been ported to "switch", which means that it is
not able to generate NetFlow messages. "switch" is no longer maintained
and will be removed from the repository on January 1, 2009.