Justin Pettit [Fri, 13 Mar 2009 00:32:33 +0000 (17:32 -0700)]
Don't send mgmt OpenFlow messages if mgmt_rconn isn't set.
In some circumstances we try to send a configuration update to the
controller, regardless of whether we're actually connected. This fixes
that and warns if others try to do similar things.
Ben Pfaff [Fri, 13 Mar 2009 00:22:38 +0000 (17:22 -0700)]
debian: Fix confusion between dp0 and of0.
Earlier, 'nl:0' was changed to read 'dp0' in the Debian init script, but
this didn't take into account that this would also change the name of the
"local port" for the datapath from 'of0' to 'dp0'.
The "cleanest" fix would probably be to change all the instances of of0
to dp0, but this would also require changing the names of files in the
file system (e.g. /etc/openflow-switch/of0-cert.pem), so it's easier to
just change the dp0 instances to of0. Thanks to Reid for suggesting this
simpler fix.
Ben Pfaff [Thu, 12 Mar 2009 21:45:36 +0000 (14:45 -0700)]
secchan: Treat invalid table IDs in stats requests as requests for no flows.
Before, we treated invalid table IDs as requests for any flows in the table
at all, but it makes more sense to treat them as requests for no flows at
all. (The value 0xff is explicitly defined by OpenFlow to mean "all
tables".)
Ben Pfaff [Thu, 12 Mar 2009 17:00:35 +0000 (10:00 -0700)]
cfg: Write "# This file intentionally left blank.\n" to empty config file.
It's somewhat surprising to see an empty config file--it makes folks wonder
if something went wrong. If we write a comment, it is more reassuring.
The main part of the change is refactoring. This may be going a bit
overboard, but it should make the code more obvious and easier to
maintain, I hope.
Justin Pettit [Thu, 12 Mar 2009 02:03:42 +0000 (19:03 -0700)]
Allow ignoring "mgmt.controller" settings per bridge.
By setting the "bridge.<name>.controller" key to an empty value, it is
now possible to perform local switching, while allowing the rest of
vswitchd to be remotely controlled.
Justin Pettit [Thu, 12 Mar 2009 01:41:12 +0000 (18:41 -0700)]
Indicate that SSL configuration is global in vswitchd.
The vconn-ssl library only supports global settings for keys and other
SSL configuration. Make vswitchd.conf mgmt use "ssl." instead of
"mgmt.ssl." to relect that the settings are shared with the bridges.
Justin Pettit [Thu, 12 Mar 2009 00:09:21 +0000 (17:09 -0700)]
Various fixes for SSL configruation and mgmt id generation.
To configure SSL options in vswitchd, one now uses the "mgmt.ssl" key
prefix. This commit also fixes a problem where a management id would
change part way through the startup. Also, documents how to configure
mgmt in vswitch.conf.
Ben Pfaff [Thu, 12 Mar 2009 00:10:42 +0000 (17:10 -0700)]
secchan: Drop configuration file support.
Configuration file support was added to secchan specifically to allow
vswitchd to change the set of NetFlow collectors at runtime without killing
and restarting secchan. secchan is integrated into vswitchd, so vswitchd
can now do this through a function call instead of through a configuration
file. This means that we can kill off the secchan configuration file
and add back the --netflow option that it replaced.
Also, add a --mgmt-id option to supplant the other use for the
configuration file that had appeared in the meantime.
Ben Pfaff [Wed, 11 Mar 2009 22:38:22 +0000 (15:38 -0700)]
vswitch: Don't delete all flows on SIGHUP if a controller is configured.
This was intended to only take effect when we had been running standalone
and were now connecting to a controller, but the test was reversed.
Instead of just reversing the test, this change also deletes flows when
we switch from connected to standalone as well.
Ben Pfaff [Wed, 11 Mar 2009 21:43:53 +0000 (14:43 -0700)]
cfg: Fix cfg_unlock() to remove the lockfile unconditionally.
Calling remove_lockfile() does the wrong thing here, because it only
removes stale lockfiles. Here, the lockfile is not stale, because we know
that we own it. Therefore, we can remove it unconditionally.
Ben Pfaff [Wed, 11 Mar 2009 21:23:15 +0000 (14:23 -0700)]
cfg: Initialize lock_fd to -1.
Otherwise cfg_unlock() will close stdin on the first call. Since
create_lockfile() calls remove_lockfile() as its first action, that's
on every useful execution.
Ben Pfaff [Wed, 11 Mar 2009 20:41:15 +0000 (13:41 -0700)]
datapath: Always return EFAULT to userspace when copy_to/from_user() fails.
copy_from_user() and copy_to_user() return the number of bytes that could
not be copied, not a conventional error code, so we need to translate it
into -EFAULT ourselves.
Ben Pfaff [Wed, 11 Mar 2009 18:13:01 +0000 (11:13 -0700)]
datapath: Refuse module load if an active bridge exists.
Loading when an active bridge exists will cause an OOPS as soon as any
packet is received on a bridged interface, because the datapath will
attempt to interpret the bridge's "struct net_bridge_port" as a datapath
"struct net_bridge_port", which is completely wrong.
Justin Pettit [Wed, 11 Mar 2009 06:59:36 +0000 (23:59 -0700)]
First cut of management control protocol.
Defines a management control protocol between the switch and NOX.
Currently, this is only used by vswitchd. It allows the configuration
and monitoring of a switch as a whole, as opposed to the flow table view
provided by OpenFlow. To enable, add the appropriate "mgmt" keys to
"vswitchd.conf". Better docs will be forthcoming...
Ben Pfaff [Tue, 10 Mar 2009 23:54:00 +0000 (16:54 -0700)]
secchan: In ofproto_set_controller(), only reconnect if controller really changed.
The vswitchd bridge code tries not to call this function if it doesn't
have to, but it's not doing a good job. We should fix it in vswitchd, but
it's also a good idea to do it here.
Ben Pfaff [Tue, 10 Mar 2009 21:04:16 +0000 (14:04 -0700)]
vswitch: Work in terms of ODP port numbers.
The vswitch used to be an OpenFlow client, so all of its internals were in
terms of OpenFlow port numbering. When it was converted to be a datapath
client instead, a shim layer that converted between OpenFlow and ODP port
numbering was inserted, so that it could still work internally in terms of
OpenFlow port numbers.
This commit makes the vswitch use ODP port numbering internally, removing
this shim layer.
Ben Pfaff [Mon, 9 Mar 2009 18:28:01 +0000 (11:28 -0700)]
secchan: Keep track of ofproto even when translating nested actions.
Allowing vswitch to hook OFPP_NORMAL will require nested actions (via
NXAST_RESUBMIT) to access the ofproto, so we need to be able to get to it
in that case.
Ben Pfaff [Mon, 9 Mar 2009 22:37:16 +0000 (15:37 -0700)]
vswitch: Eliminate OpenFlow connection to ofproto.
The vswitch interface to the ofproto is now entirely a functional
interface, instead of going partially over an OpenFlow connection that
"loops back" to the ofproto via a socketpair. So this commit drops
the code that connects and maintains that connection.
Ben Pfaff [Mon, 9 Mar 2009 21:12:25 +0000 (14:12 -0700)]
secchan: Make netflow expiration arguments more sensible.
This cleanup is useful preparation for adding a flow expiration hook for
vswitchd to use, since that hook wants to receive essentially the same
information.
Ben Pfaff [Mon, 9 Mar 2009 18:07:06 +0000 (11:07 -0700)]
secchan: Retain original input port for NXAST_RESUBMIT action.
The NXAST_RESUBMIT action causes a secondary lookup in the flow table with
a different input port value. However, we want to retain the original
input port for processing the result of that secondary lookup. Otherwise,
output to OFPP_IN_PORT will send the packet to the wrong port, and output
to the input port without specifying OFPP_IN_PORT will be mistakenly
allowed.
Ben Pfaff [Fri, 6 Mar 2009 22:34:46 +0000 (14:34 -0800)]
Keep secchan and vswitchd from consuming 100% CPU when a datapath is deleted.
Before this commit, "dpctl deldp x" would cause secchan or vswitchd to
consume 100% CPU if they were responsible for the given datapath. This
fixes the problem.
Ben Pfaff [Fri, 6 Mar 2009 22:12:36 +0000 (14:12 -0800)]
vswitch: Keep existing datapaths when starting up.
Until now, vswitchd has deleted all existing datapaths when it started up,
and then re-created the ones that are actually configured. This is a very
"clean", conservative design, but it has undesirable effects in practice.
In particular, if any datapath has a local port with an IP address
configured on it, then deleting the datapath and recreating it will drop
that IP address, which can mean that your machine just lost connectivity
to the outside world.
So, with this commit, now vswitchd only deletes datapaths at startup that
don't have configured bridges, preserving local port IP addresses.
Ben Pfaff [Fri, 6 Mar 2009 22:03:24 +0000 (14:03 -0800)]
dpif: New function dpif_get_name().
This function is equivalent to querying the ODPP_LOCAL port, but its name
better reflects the caller's intent, and its interface is slightly more
convenient.
Ben Pfaff [Fri, 6 Mar 2009 21:30:09 +0000 (13:30 -0800)]
flow: Properly translate port numbers in flow_from_match().
The OpenFlow and datapath port numbers for the local port are different.
We were translating them in one direction (in flow_to_match()) but not
in the other (in flow_from_match()).
This fixes a performance problem (we were setting up the wrong flow).
Ben Pfaff [Fri, 6 Mar 2009 17:52:08 +0000 (09:52 -0800)]
secchan: Fix use-after-free by allocating rule actions as separate blocks.
The ofproto code tried to cleverly save memory and time by allocating
rule actions as a flexible array member at the end of "struct rule". When
the actions changed, this required a realloc() call. Unfortunately, there
are sometimes pointers to rules (e.g. the "super" pointer from subrules)
that were not getting adjusted to point to the new location.
It's better to just allocate actions separately, so fix it by doing that.
Ben Pfaff [Fri, 6 Mar 2009 01:34:42 +0000 (17:34 -0800)]
secchan: Correctly maintain rule's number of actions.
We were reallocating memory properly but not updating the "n_actions"
member, which sometimes led to reading past the end of a block.
This problem possibly caused segfaults, since the OpenFlow->ODP action
translation code assumes that OpenFlow actions are prevalidated, and
random memory is not necessarily valid OpenFlow actions :-)