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 [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 [Wed, 17 Dec 2008 00:57:40 +0000 (16:57 -0800)]
Add new "fd" vconn, which takes a file descriptor number as argument.
This requires introducing the concept of a "reconnectable" vconn. A vconn
is reconnectable if, when it is closed, it is possible to try to reconnect
to it using the name that was originally used. This is the case for all
existing vconn types, but it is not true for fd vconns, because closing a
fd vconn closes the specified file descriptor, and thus attempting to
reopen it will get an EBADF error.
An rconn is not reliable if it is connected to a vconn that is not
reconnectable.
Ben Pfaff [Wed, 17 Dec 2008 00:19:36 +0000 (16:19 -0800)]
Introduce x2nrealloc() helper function, and use it.
Also fixes a bug in read_cert_file() in vconn-ssl.c: "sizeof *certs"
should have been "sizeof **certs". In fact the sizes will be identical
in all practical cases since both *certs and **certs are pointer types,
so this is not an important fix.
Ben Pfaff [Wed, 17 Dec 2008 00:13:36 +0000 (16:13 -0800)]
Make datapath interface library more flexible.
A single netlink socket can address any kernel datapath, but the datapath
interface library was artificially restricting a dpif to address a single
datapath that was selected at dpif creation time. This commit removes
that restriction.
This is useful for vswitchd, which can create and destroy any number of
datapaths and add and remove ports on them. It's more convenient to use
a single dpif for that instead of many.
Ben Pfaff [Wed, 17 Dec 2008 00:10:31 +0000 (16:10 -0800)]
Move DP_MAX into public header file.
vswitchd wants to know the maximum number of datapaths, so DP_MAX needs to
be exported.
(This is not an ideal situation. Really the kernel should not have an
explicit limit on the number of datapaths, and userspace should be able
to query the current maximum.)
Ben Pfaff [Wed, 17 Dec 2008 00:35:56 +0000 (16:35 -0800)]
Improve formatting of process termination messages in secchan logging.
My expectation was that strsignal() returns the signal's name, e.g.
SIGTERM. It actually returns an English explanation, so that the existing
code would log a message like "terminated by signal Terminated". This
commit changes the message to the more sensible "terminated by signal 15
(Terminated)".
Also, the recently approved POSIX 2008 standardized strsignal() and in
particular says that it may return NULL for unknown signal numbers, so
this commit fixes the behavior on NULL return.
Previously the arguments of rate-limited messages were always evaluated
and passed to vlog_rate_limit(). This commit short-circuits the case
where the vlog levels would prevent any messages from being logged even
without considering rate limiting.
Ben Pfaff [Tue, 2 Dec 2008 16:27:31 +0000 (08:27 -0800)]
Update prerequisite Autoconf version to 2.60 (from 2.59).
We use the MKDIR_P variable that only Autoconf 2.60 and
later supports, but we were only requiring Autoconf 2.59
or later. This fixes the problem.
Also, we were not explicitly invoking AC_PROG_MKDIR_P from
configure.ac, even though we were using $(MKDIR_P). Some
other macro must have been internally invoking
AC_PROG_MKDIR_P, but it's not good to depend on that, so
this commit adds an explicit call to it.
Justin Pettit [Mon, 1 Dec 2008 22:34:23 +0000 (14:34 -0800)]
Add support for listing and deleting entries based on an output port.
To support this, an "out_port" field has been added to the "ofp_flow_mod",
"ofp_flow_stats_request", and "ofp_aggregate_stats_request" messages. If an
"out_port" contains a value other than "OFPP_NONE", it introduces a constraint
when matching. This constraint is that the rule must contain an output action
directed at that port. Other constraints such as ofp_match structs and
priorities are still used; this is purely an *additional* constraint. Note
that to get previous behavior, though, "out_port" must be set to "OFPP_NONE",
since "0" is a valid port id. This only applies to the delete and
delete_strict flow mod commands; the field is ignored by add, modify, and
modify_strict.
Ben Pfaff [Thu, 27 Nov 2008 00:25:55 +0000 (16:25 -0800)]
Free txbuf, rxbuf in vconn-ssl and vconn-stream destructors.
This bug was causing secchan to leak a little bit of memory on almost every
connection close. This is most visible when openflow-monitor is running,
because openflow-monitor connects to secchan once per second.
Ben Pfaff [Fri, 21 Nov 2008 21:05:37 +0000 (13:05 -0800)]
Maintain separate async and sync connections to nl:0 in secchan.
When a network link is flooded with traffic, secchan's OpenFlow socket
queue becomes congested with traffic. This leaves no room for replies
to OpenFlow requests relayed to that socket by secchan.
This commit modifies secchan to use separate sockets for asynchronous
traffic and for OpenFlow requests/replies, which should avoid the problem.