openvswitch
14 years agodatapath: Fix OOPS when dp_sysfs_add_if() fails.
Ben Pfaff [Wed, 5 Aug 2009 22:22:25 +0000 (15:22 -0700)]
datapath: Fix OOPS when dp_sysfs_add_if() fails.

Until now, when dp_sysfs_add_if() failed, the caller ignored the failure.
This is a minor problem, because everything else should continue working,
without sysfs entries for the interface, in theory anyhow.  In actual
practice, the error exit path of dp_sysfs_add_if() does a kobject_put(),
and that kobject_put() calls release_nbp(), so that the new port gets
freed.  The next reference to the new port (usually in an ovs-vswitchd call
to the ODP_PORT_LIST ioctl) will then use the freed data and probably OOPS.

The fix is to make the datapath code, as opposed to the sysfs code,
responsible for creating and destroying the net_bridge_port kobject.  The
dp_sysfs_{add,del}_if() functions then just attach and detach the kobject
to sysfs and their cleanup routines no longer need to destroy the kobject
and indeed we don't care whether dp_sysfs_add_if() really succeeds.

This commit also makes the same transformation to the datapath's ifobj,
for consistency.

It is easy to trigger the OOPS fixed by this commit by adding a network
device A to a datapath, then renaming network device A to B, then renaming
network device C to A, then adding A to the datapath.  The last attempt to
add A will fail because a file named /sys/class/net/<datapath>/brif/A
already exists from the time that C was added to the datapath under the
name A.

This commit also adds some compatibility infrastructure, because it moves
code out of #ifdef SUPPORT_SYSFS and it otherwise wouldn't build.

14 years agodatapath: Prepare to extend lifetime of kobjects.
Ben Pfaff [Wed, 5 Aug 2009 20:45:13 +0000 (13:45 -0700)]
datapath: Prepare to extend lifetime of kobjects.

The following commit will move the initialization of the datapath and
net_bridge_port kobjects earlier and the destruction later, without
changing when those kobjects are attached to sysfs.  To do so, the
initialization of kobjects and attaching to sysfs has to be done as
separate steps.  That's already the case for net_bridge_port kobjects, and
this commit makes it so for datapath kobjects too.

This commit also simplifies some code, since the split API exists both
before and after 2.6.25, but the combined functions changed names.

Also, in dp_sysfs_add_if() call kobject_init() after initializing the
kset member, since kobject_init() expects that.  This makes no actual
difference in this case since the kobj is obtained from kzalloc(), but
it still seems better.

14 years agodatapath: Rename brc_sysfs_* to dp_sysfs_*.
Ben Pfaff [Wed, 5 Aug 2009 19:56:23 +0000 (12:56 -0700)]
datapath: Rename brc_sysfs_* to dp_sysfs_*.

These files and names are now part of the datapath, not brcompat, so name
them appropriately so as not to confuse anyone.

14 years agodatapath: Move sysfs support from brcompat_mod into openvswitch_mod.
Ben Pfaff [Wed, 5 Aug 2009 19:51:30 +0000 (12:51 -0700)]
datapath: Move sysfs support from brcompat_mod into openvswitch_mod.

In the past problems have arisen due to the different ways that datapaths
are created and destroyed in the three different cases:

1. sysfs supported, brcompat_mod loaded.
2. sysfs supported, brcompat_mod not loaded.
3. sysfs not supported.

The brcompat_mod loaded versus not loaded distinction is the stickiest
because we have to do all the calls into brcompat_mod through hook
functions, which in turn causes pressure to keep the number of hook
functions small and well-defined, which makes it really difficult to put
the hook call points at exactly the right place.  Witness, for example,
this piece of code in datapath.c:

        int dp_del_port(struct net_bridge_port *p)
        {
                ASSERT_RTNL();

        #ifdef SUPPORT_SYSFS
                if (p->port_no != ODPP_LOCAL && dp_del_if_hook)
                        sysfs_remove_link(&p->dp->ifobj, p->dev->name);
        #endif

The code inside the #ifdef is logically part of the brcompat_mod sysfs
support, but the author of this code (quite reasonably) didn't want to
add a hook function call there.  After all, what would you call the
hook function?  There's no obvious name from the dp_del_port() caller's
perspective.

All this argues that sysfs support should be in openvswitch_mod itself,
since it has to be tightly integrated, not bolted on.  So this commit
moves it there.

Now, this is not to say that openvswitch_mod should actually be
implementing bridge-compatible sysfs.  In the future, it probably should
not be; rather, it should implement something appropriate for Open vSwitch
datapaths instead.  But right now we have bridge-compatible sysfs, and so
that's what this commit moves.

14 years agoxenserver: Really take devices down in interface-reconfigure.
Ben Pfaff [Wed, 5 Aug 2009 18:39:03 +0000 (11:39 -0700)]
xenserver: Really take devices down in interface-reconfigure.

When down_netdev was called with deconfigure=True (which is the default),
it would invoke, e.g. "/sbin/ifconfig eth0 down 0.0.0.0", with the
intention of taking the interface down and removing any IP address from it
at the same time.

In fact, this removed any IP address from it and brought the device *up*,
because ifconfig executes its commands in the order that they are
specified, and setting or unsetting an IP address brings a device up.

We could specify the commands in the opposite order ("0.0.0.0 down") but
it seems to me more obviously correct to just run ifconfig twice, so that
is what this commit does.

This commit could break things, because it could be that there is a bug
elsewhere that depends on down_netdev not actually bringing a device down,
but it is needed for the upcoming device renaming commit (to fix bug
NIC-20), because a network device has to be down to be renamed.

14 years agobrcompat: Add comments to sysfs code.
Ben Pfaff [Wed, 5 Aug 2009 20:09:15 +0000 (13:09 -0700)]
brcompat: Add comments to sysfs code.

I got tired of figuring out over and over what these function calls do.

14 years agovswitchd: Fix logged warnings for new internal ports.
Ben Pfaff [Thu, 6 Aug 2009 17:33:26 +0000 (10:33 -0700)]
vswitchd: Fix logged warnings for new internal ports.

Justin reported that adding an internal port to a bridge caused
ovs-vswitchd to log a pair of warnings.  This commit suppresses those
warnings, which were harmless.

14 years agodatapath: Support jumbo frames in the datapath device
Justin Pettit [Sat, 1 Aug 2009 07:09:56 +0000 (00:09 -0700)]
datapath: Support jumbo frames in the datapath device

The datapath has no problems switching jumbo frames (frames with a payload
greater than 1500 bytes), but it has not supported sending and receiving
them to the device itself.  With this commit, the MTU can be set as large
as the minimum MTU size of the devices that are directly attached, or 1500
bytes if there are none.  This mimics the behavior of the Linux bridge.

Feature #1736

14 years agovswitchd: Initialize cfg properly and check return values
Justin Pettit [Sat, 1 Aug 2009 08:03:23 +0000 (01:03 -0700)]
vswitchd: Initialize cfg properly and check return values

A previous checkin added the cfg_init() function, so we now call it.  We
also check the return value of the initial call to cfg_read(), since if
it fails, there's not much point in continuing.

14 years agocfg: Terminate cfg to prevent crashes
Justin Pettit [Sat, 1 Aug 2009 07:58:31 +0000 (00:58 -0700)]
cfg: Terminate cfg to prevent crashes

If cfg_* accessor calls were made before cfg_read() was called (or it
returned error), they could cause segfault.  This checkin terminates the
cfg structure in such a way that will prevent these run-time problems.

Bug #1693

14 years agoFix broken build by making "make dist" include lib/netdev-provider.h.
Ben Pfaff [Fri, 31 Jul 2009 00:10:13 +0000 (17:10 -0700)]
Fix broken build by making "make dist" include lib/netdev-provider.h.

14 years agortnetlink: Move into separate source and header file.
Ben Pfaff [Tue, 28 Jul 2009 20:05:20 +0000 (13:05 -0700)]
rtnetlink: Move into separate source and header file.

Now that rtnetlink isn't named similarly to netdev_linux, it might as well
have its own source and header files to avoid confusing everyone.

14 years agortnetlink: Document.
Ben Pfaff [Tue, 28 Jul 2009 19:38:14 +0000 (12:38 -0700)]
rtnetlink: Document.

14 years agonetdev-linux: Rename "linux_netdev_*" to "rtnetlink_*".
Ben Pfaff [Tue, 28 Jul 2009 19:36:32 +0000 (12:36 -0700)]
netdev-linux: Rename "linux_netdev_*" to "rtnetlink_*".

It was getting to be too confusing to have both netdev_linux_* functions
and linux_netdev_* functions.  Rename the latter to make the distinction
more obvious.  "rtnetlink" seems to be a fairly good name because that's
what the kernel calls it, so the name will be familiar at least to people
who know about rtnetlink.

14 years agonetdev: Implement an abstract interface to network devices.
Ben Pfaff [Thu, 30 Jul 2009 23:04:45 +0000 (16:04 -0700)]
netdev: Implement an abstract interface to network devices.

This new abstraction layer allows multiple implementations of network
devices in a single running process.  This will be useful, for example, to
support network devices that are simulated entirely in the running process
or that communicate with other processes over Unix domain sockets, etc.

The reimplemented tap device support in this commit has not been tested.

14 years agonetdev: Remove netdev_nodev_*() functions.
Ben Pfaff [Thu, 23 Jul 2009 21:49:52 +0000 (14:49 -0700)]
netdev: Remove netdev_nodev_*() functions.

These functions are now unused, so they may be deleted.

14 years agonetdev: Make netdev_get_vlan_vid() take a netdev instead of a name.
Ben Pfaff [Thu, 23 Jul 2009 20:36:08 +0000 (13:36 -0700)]
netdev: Make netdev_get_vlan_vid() take a netdev instead of a name.

For consistency, it's best if every netdev function takes a netdev instead
of a device name.  The netdev_nodev_*() functions have always been a bit
ugly.

14 years agovswitchd: Avoid netdev_nodev_*() functions.
Ben Pfaff [Thu, 23 Jul 2009 21:50:55 +0000 (14:50 -0700)]
vswitchd: Avoid netdev_nodev_*() functions.

The netdev_nodev_*() functions have always been a bit of a kluge.  It's
better to keep a network device open than to open it every time that it is
needed.  This commit converts all of the users of these functions to use
the corresponding functions that take a "struct netdev *" instead.

14 years agovswitchd: Avoid netdev_nodev_set_policing().
Ben Pfaff [Thu, 23 Jul 2009 23:49:19 +0000 (16:49 -0700)]
vswitchd: Avoid netdev_nodev_set_policing().

The netdev_nodev_*() functions have always been a bit of a kluge.  It's
better to keep a network device open than to open it every time that it is
needed.

14 years agonetdev: Make netdev_find_dev_by_in4() use netdevs, not device names.
Ben Pfaff [Fri, 24 Jul 2009 00:09:43 +0000 (17:09 -0700)]
netdev: Make netdev_find_dev_by_in4() use netdevs, not device names.

The netdev_nodev_*() functions have always been a bit of a kluge.  It's
better to keep a network device open than to open it every time that it is
needed.

Also updates the only user of netdev_find_dev_by_in4().

14 years agovswitchd: Don't keep track of mac in struct iface.
Ben Pfaff [Thu, 23 Jul 2009 21:28:21 +0000 (14:28 -0700)]
vswitchd: Don't keep track of mac in struct iface.

It's easy to get the Ethernet address of the interface from the netdev
code, and so we don't have to keep track of it in the bridge too.

14 years agovswitchd: Keep a netdev open for each interface.
Ben Pfaff [Thu, 30 Jul 2009 23:00:41 +0000 (16:00 -0700)]
vswitchd: Keep a netdev open for each interface.

This will allow the vswitch to use the netdev functions that take a
netdev parameter instead of the ones that take a device name.

14 years agovswitchd: Factor out iteration over interfaces with deletion.
Ben Pfaff [Thu, 30 Jul 2009 22:56:17 +0000 (15:56 -0700)]
vswitchd: Factor out iteration over interfaces with deletion.

Two different pieces of code in vswitchd were both iterating over all
the interfaces in a bridge and deleting some of them, then deleting any
ports that ended up with no interfaces because of this.  This commit
factors this operation out into a helper function.

14 years agoofproto: Don't use netdev_nodev_get_etheraddr() in pick_datapath_id().
Ben Pfaff [Tue, 28 Jul 2009 18:01:44 +0000 (11:01 -0700)]
ofproto: Don't use netdev_nodev_get_etheraddr() in pick_datapath_id().

The netdev_nodev_*() functions have always been a bit of a kluge.  It's
better to keep a network device open than to open it every time that it is
needed.

This commit gets rid of a usage of netdev_nodev_get_etheraddr() in
pick_datapath_id(), by using the netdev that the datapath already has open
for the local port.

14 years agonetdev: Add 'netdev' parameter to netdev_add_router().
Ben Pfaff [Thu, 23 Jul 2009 19:18:14 +0000 (12:18 -0700)]
netdev: Add 'netdev' parameter to netdev_add_router().

When there is the possibility of multiple classes of netdevs,
netdev_add_router() needs to know which of these to use, so it needs a
"struct netdev *" parameter.

14 years agonetdev: New function netdev_exists().
Ben Pfaff [Thu, 23 Jul 2009 17:42:48 +0000 (10:42 -0700)]
netdev: New function netdev_exists().

This new function allows cleanup of code that was using
netdev_nodev_get_flags() or ad-hoc methods to detect whether a network
device with the given name exists.

14 years agonetdev: Get rid of netdev_open_tap().
Ben Pfaff [Thu, 23 Jul 2009 19:21:11 +0000 (12:21 -0700)]
netdev: Get rid of netdev_open_tap().

netdev_open() can always be used in place of netdev_open_tap().  The
former is going to be generalized to support pluggable network device
types, so it makes sense to use it everywhere.

14 years agonetdev: Change netdev_get_in4() to return an error code.
Ben Pfaff [Tue, 28 Jul 2009 20:43:52 +0000 (13:43 -0700)]
netdev: Change netdev_get_in4() to return an error code.

Until now, netdev_get_in4() and netdev_nodev_get_in4() have returned a
bool that represents success or failure.  This commit changes the return
value to an int that can indicate what kind of error occurred, which is
both more consistent with the rest of the netdev interfaces and more
meaningful, and updates all callers to the new interface.

(Currently netdev_get_in4() won't ever return an error, but other future
implementations might.)

14 years agonetdev: Change netdev_get_mtu() to return an error code.
Ben Pfaff [Tue, 28 Jul 2009 20:43:35 +0000 (13:43 -0700)]
netdev: Change netdev_get_mtu() to return an error code.

To make the netdev code more portable, it needs to support returning error
codes from functions that don't have them.  This commit changes
netdev_get_mtu() to return an error code and updates its caller.

(Currently netdev_get_mtu() won't ever return an error, but other future
implementations might.)

14 years agonetdev: Change netdev_get_etheraddr() to return an error code.
Ben Pfaff [Tue, 28 Jul 2009 20:31:49 +0000 (13:31 -0700)]
netdev: Change netdev_get_etheraddr() to return an error code.

To make the netdev code more portable, it needs to support returning error
codes from functions that don't have them.  This commit changes
netdev_get_etheraddr() to return an error code and updates all of its
callers.

(Currently netdev_get_etheraddr() won't ever return an error, but other
future implementations might.)

14 years agoshash: Introduce new macros SHASH_FOR_EACH, SHASH_FOR_EACH_SAFE.
Ben Pfaff [Wed, 22 Jul 2009 23:33:43 +0000 (16:33 -0700)]
shash: Introduce new macros SHASH_FOR_EACH, SHASH_FOR_EACH_SAFE.

This is both more convenient and cleaner than using HMAP_FOR_EACH(_SAFE)
directly.

14 years agoshash: Make shash_add() return the new node.
Ben Pfaff [Tue, 28 Jul 2009 20:29:57 +0000 (13:29 -0700)]
shash: Make shash_add() return the new node.

14 years agovswitchd: Update /proc/net/bonding when bonded port properties change.
Ben Pfaff [Wed, 29 Jul 2009 16:56:46 +0000 (09:56 -0700)]
vswitchd: Update /proc/net/bonding when bonded port properties change.

Until now ovs-vswitchd has created the files in /proc/net/bonding, but not
updated them, because there was little need.  But the Citrix QA tests check
that the list of bond hashes in that file is kept up-to-date, so we need
to update them whenever the bond hashes (or other data in the file) change.
This commit does that.

Bug NIC-16.

14 years agovswitchd: Add bond hashes to /proc/net/bonding compatibility layer.
Ben Pfaff [Wed, 29 Jul 2009 00:10:10 +0000 (17:10 -0700)]
vswitchd: Add bond hashes to /proc/net/bonding compatibility layer.

The Citrix QA scripts require the bond hashes and their assigned devices
to be noted in /proc/net/bonding.  We weren't doing that, so this commit
adds them.

Bug NIC-16.

14 years agoXenServer: Correct license in spec file
Justin Pettit [Thu, 30 Jul 2009 06:37:28 +0000 (23:37 -0700)]
XenServer: Correct license in spec file

The license file indicated that the software is licensed under the GPLv3
license.  This commit corrects that to state that it's licensed under
the Apache 2.0 license with the exception of the "datapath" directory,
which is GPLv2.  The style and abbreviations were from the following
page:

    http://fedoraproject.org/wiki/Packaging/LicensingGuidelines

14 years agovswitchd: Add unixctl command to dump all flows, including hidden ones
Justin Pettit [Tue, 14 Jul 2009 20:03:57 +0000 (13:03 -0700)]
vswitchd: Add unixctl command to dump all flows, including hidden ones

Previously, the only way to query the flow table was to run "ovs-ofctl
dump-flows".  This returned most flows, but not those marked hidden by
secchan.  Hidden flows are setup by mechanisms such as in-band control,
since they must not be modified by users of the controller.  However,
when debugging problems on the switch, it is often useful to see what
the flow table is actually doing.  The new "bridge/dump-flows" command
added to ovs-appctl shows all flows being used by the OpenFlow stack.

14 years agoAlways distribute extras/ezio/ezio3.ti.
Ben Pfaff [Thu, 30 Jul 2009 00:04:10 +0000 (17:04 -0700)]
Always distribute extras/ezio/ezio3.ti.

I had thought that Automake was smart enough to ignore conditionals around
EXTRA_DIST, so that all files always got distributed regardless of whether
Automake conditionals were set.  I was wrong.

This pushes the conditionals for building the ezio binaries down into
extras/ezio/automake.mk and thereby makes adding ezio3.ti to EXTRA_DIST
unconditional, so that it always gets distributed.  Otherwise, this file
will not be distributed on systems that don't have curses or don't have
PCRE, which is very surprising.

14 years agoRemove --disable-userspace "configure" option, since it breaks "make dist".
Ben Pfaff [Wed, 29 Jul 2009 23:48:45 +0000 (16:48 -0700)]
Remove --disable-userspace "configure" option, since it breaks "make dist".

I had thought that Automake was smart enough to ignore conditionals around
EXTRA_DIST, so that all files always got distributed regardless of whether
Automake conditionals were set.  I was wrong.

This commit removes the --disable-userspace option to "configure", which
put a conditional around most of Makefile.am and thus unintentionally
caused most of the distribution to be left out if --disable-userspace was
specified.  The alternative (fixing --disable-userspace) seems like too
much work--it would require pushing "if ENABLE_USERSPACE" down into lots
of subdirectory--and would be difficult to maintain.

14 years agoFix DHCP request source port and add port #define's
Justin Pettit [Thu, 16 Jul 2009 22:02:53 +0000 (15:02 -0700)]
Fix DHCP request source port and add port #define's

DHCP requests were sent with a source port of 66, when it should be 68.
This code has been tested, so apparently many DHCP servers don't pay
attention to the source port.  This commit also adds #define's for the
DHCP ports, so that magic numbers don't need to be used.

14 years agoFix tab/space issue in datapath-protocol.h
Justin Pettit [Thu, 16 Jul 2009 22:21:47 +0000 (15:21 -0700)]
Fix tab/space issue in datapath-protocol.h

14 years agovswitchd: Remove non-used function to prevent compiler warnings
Justin Pettit [Wed, 8 Jul 2009 21:51:47 +0000 (14:51 -0700)]
vswitchd: Remove non-used function to prevent compiler warnings

The function send_ofmp_error_msg() is not currently used, so it was
producing compiler warnings that it was defined.  Remove the function
until it's needed.

14 years agoCleanup warnings about "save_ptr" in strtok_r argument
Justin Pettit [Wed, 8 Jul 2009 21:43:29 +0000 (14:43 -0700)]
Cleanup warnings about "save_ptr" in strtok_r argument

The compiler warns about the "save_ptr" argument to strtok_r being
unitialized.  This cleans that up.

14 years agoAdd support for code coverage analysis with gcov and lcov.
Ben Pfaff [Mon, 27 Jul 2009 23:42:51 +0000 (16:42 -0700)]
Add support for code coverage analysis with gcov and lcov.

14 years agoUse Autotest for the Open vSwitch test suite.
Ben Pfaff [Mon, 27 Jul 2009 23:40:11 +0000 (16:40 -0700)]
Use Autotest for the Open vSwitch test suite.

Autotest doesn't provide a lot of benefit by itself but it does allow us
to easily put a wrapper around each test by using a macro to invoke it.
(To do that with the built-in Automake test framework you need to write
or generate a separate wrapper script for each test, which is a pain.)
The next commit will take advantage of this possibility by adding support
for code coverage analysis.

14 years agoReduce default probe interval to 5 seconds (and fail-open timeout to 15).
Ben Pfaff [Wed, 29 Jul 2009 18:31:07 +0000 (11:31 -0700)]
Reduce default probe interval to 5 seconds (and fail-open timeout to 15).

Before now, the default probe interval (the idle time after which an echo
request is sent on an OpenFlow connection) was set to 15 seconds.  The
fail-open timeout is 3 times the probe interval, so this meant that it
took 45 seconds for a switch to fail open.

Users at Nicira have commented that this is too long.  They don't like the
idea that the network will be down for most of a minute before it begins to
recover.  So this commit changes the default probe interval to 5 seconds,
hence the fail-open timeout to 15 seconds.

14 years agoReduce default maximum connection timeout from 15 seconds to 8 seconds.
Ben Pfaff [Tue, 28 Jul 2009 17:21:03 +0000 (10:21 -0700)]
Reduce default maximum connection timeout from 15 seconds to 8 seconds.

Users at Nicira have commented that a maximum reconnection time of 15
seconds, which was the default, is too long.  This commit cuts it to 8
seconds, on the theory that an administrator is willing to wait that long
before deciding that a change that should restore connectivity did not
work.

14 years agoxenserver: Do not set or remove vSwitchVersion xapi parameter anymore.
Ben Pfaff [Tue, 28 Jul 2009 22:35:57 +0000 (15:35 -0700)]
xenserver: Do not set or remove vSwitchVersion xapi parameter anymore.

The other-config:vSwitchVersion parameter was used to announce the Open
vSwitch version installed on a XenServer host, but this had the problem
that it could not be read or updated if the connection to the pool master
was down.  Because of this problem, the only user of this parameter in
Open vSwitch was removed (in commit 3cdc31a4c3a "xenserver: Retrieve
vSwitch version from binary in xsconsole").  So this commit finished the
process and removes the parameter entirely.

This should fix hangs on Open vSwitch installation and removal due to
waiting on the connection to the pool master.

14 years agoxenserver: Honor the MAC address specified in xapi database for bonds.
Ben Pfaff [Wed, 22 Jul 2009 19:21:25 +0000 (12:21 -0700)]
xenserver: Honor the MAC address specified in xapi database for bonds.

The xapi database for PIFs specifies the MAC address that should be used
for bonds, but interface-reconfigure didn't honor it and ovs-vswitchd
didn't have a way to configure it anyhow.  This commit fixes both problems.

Bug #1645.

14 years agoMerge commit 'origin/citrix'
Justin Pettit [Wed, 29 Jul 2009 05:19:28 +0000 (22:19 -0700)]
Merge commit 'origin/citrix'

14 years agoMerge commit 'origin/citrix'
Justin Pettit [Wed, 29 Jul 2009 05:16:50 +0000 (22:16 -0700)]
Merge commit 'origin/citrix'

Conflicts:

configure.ac

14 years agoxenserver: Enable ARP filtering to work around xhad bug.
Ben Pfaff [Tue, 28 Jul 2009 22:44:58 +0000 (15:44 -0700)]
xenserver: Enable ARP filtering to work around xhad bug.

This works around a bug in xhad, which binds to a particular Ethernet
device, which in turn causes ICMP port unreachable messages if packets are
received are on the wrong interface, which in turn can happen if we send
out ARP replies on every interface (as Linux does by default) instead of
just on the interface that has the IP address being ARPed for, which this
sysctl setting in turn works around.

Justin Pettit did most of the work tracking down the origin of this bug.

Bug #1378.

14 years agoxenserver: Retrieve vSwitch version from binary in xsconsole
Justin Pettit [Tue, 28 Jul 2009 22:24:32 +0000 (15:24 -0700)]
xenserver: Retrieve vSwitch version from binary in xsconsole

The xsconsole plugin shows status information about Open vSwitch.  The
version information was retrieved from XAPI, but this could cause
problems.  The most easily reproduced is to make a XenServer part of a
pool, then remove it.  The version string is no longer in the
XenServer's local XAPI view, so it reports "<unknown>".  A more direct
way to get the information is to directly query the binary, which is
what this commit does.

Bug #1626

15 years agoLabel the current "citrix" release 0.90.4.
Justin Pettit [Tue, 28 Jul 2009 18:05:28 +0000 (11:05 -0700)]
Label the current "citrix" release 0.90.4.

15 years agoDo not try to resolve DNS for OpenFlow controllers or netflow collectors.
Ben Pfaff [Wed, 15 Jul 2009 22:29:49 +0000 (15:29 -0700)]
Do not try to resolve DNS for OpenFlow controllers or netflow collectors.

Until now, setting a netflow collector to a DNS name would cause
secchan to attempt to resolve that DNS name each time that the set of
netflow collectors is re-set.  For the vswitch, this is every time that
the vswitch reconfigures itself.

Unfortunately, DNS lookup within secchan cannot work as currently
implemented, because it needs both an asynchronous DNS resolver library
and in-band control updates.  Currently we have neither.  Attempting to
look up DNS anyway just hangs.

This commit disables DNS lookup entirely, and updates the documentation to
change user expectations.  DNS still won't work, but at least it won't
hang.

Bug #1609.

15 years agoxenserver: Fix creating, destroying bonds with the management connection.
Ben Pfaff [Fri, 17 Jul 2009 19:37:01 +0000 (12:37 -0700)]
xenserver: Fix creating, destroying bonds with the management connection.

Creating a bond from the network device that holds the Xen management
connection automatically transfers the management connection to that bond.
However, we weren't properly removing the IP address from the network
devices that constituted the bond.  This commit fixes that problem.

Bug #1566.

15 years agoVarious clean-ups to INSTALL.OpenFlow
Justin Pettit [Fri, 17 Jul 2009 07:21:59 +0000 (00:21 -0700)]
Various clean-ups to INSTALL.OpenFlow

15 years agoAdd INSTALL.bridge and INSTALL.OpenFlow to distribution
Justin Pettit [Fri, 17 Jul 2009 03:50:58 +0000 (20:50 -0700)]
Add INSTALL.bridge and INSTALL.OpenFlow to distribution

15 years agoSet version number to 0.90.3.
Justin Pettit [Fri, 17 Jul 2009 03:47:00 +0000 (20:47 -0700)]
Set version number to 0.90.3.

15 years agoFirst cut of guide to using Open vSwitch as a simple OpenFlow switch.
Justin Pettit [Fri, 17 Jul 2009 03:45:53 +0000 (20:45 -0700)]
First cut of guide to using Open vSwitch as a simple OpenFlow switch.

15 years agoMinor documentation fixups.
Keith Amidon [Fri, 17 Jul 2009 01:07:10 +0000 (18:07 -0700)]
Minor documentation fixups.

15 years agobrcompat: Make "brctl showmacs" honor Linux notion of bridge composition.
Ben Pfaff [Thu, 16 Jul 2009 22:16:06 +0000 (15:16 -0700)]
brcompat: Make "brctl showmacs" honor Linux notion of bridge composition.

The kernel only handles a single VLAN per bridge, but vswitchd can deal
with all the VLANs on a single bridge.  This commit makes "brctl showmacs"
pretend that the former is the case even though the latter is the
implementation.

Bug #1567.

15 years agovswitchd: Make "fdb/show" output more meaningful port numbers.
Ben Pfaff [Thu, 16 Jul 2009 22:15:02 +0000 (15:15 -0700)]
vswitchd: Make "fdb/show" output more meaningful port numbers.

The "fdb/show" unixctl command was showing vswitch-internal port indexes,
which cannot be meaningfully interpreted by software outside vswitchd.
Also, they potentially change every time the vswitchd configuration file
changes.  This commit changes it to use a datapath port index instead,
which are both more meaningful and more stable.

15 years agocfg: New function cfg_get_matches().
Ben Pfaff [Thu, 16 Jul 2009 22:07:05 +0000 (15:07 -0700)]
cfg: New function cfg_get_matches().

15 years agoMerge citrix branch into master.
Ben Pfaff [Thu, 16 Jul 2009 18:54:37 +0000 (11:54 -0700)]
Merge citrix branch into master.

15 years agoImplement "brctl showmacs" support in brcompat and ovs-brcompatd.
Ben Pfaff [Wed, 15 Jul 2009 19:46:06 +0000 (12:46 -0700)]
Implement "brctl showmacs" support in brcompat and ovs-brcompatd.

This is needed by the Citrix test infrastructure.

15 years agobrcompat: Refactor infrastructure for communication with ovs-brcompatd.
Ben Pfaff [Wed, 15 Jul 2009 19:40:16 +0000 (12:40 -0700)]
brcompat: Refactor infrastructure for communication with ovs-brcompatd.

In an upcoming change, brcompat will need to receive bulk data from
ovs-brcompatd.  The existing brcompat infrastructure for receiving data
only supports returning an error code, so this commit adds the ability to
receive an arbitrary sk_buff and updates the existing users to handle it.

15 years agobrcompatd: Factor code out of prune_ports().
Ben Pfaff [Wed, 15 Jul 2009 19:09:43 +0000 (12:09 -0700)]
brcompatd: Factor code out of prune_ports().

An upcoming commit will also need to gather all of the interfaces on a
specified bridge, so break this code into a helper function.

15 years agoprocess: New function process_run_capture().
Ben Pfaff [Wed, 15 Jul 2009 19:45:44 +0000 (12:45 -0700)]
process: New function process_run_capture().

In an upcoming commit, ovs-brcompatd will need to create a subprocess and
capture both its stdout and stderr separately, which one cannot do with
simple interfaces such as popen().  This function provides that ability.

15 years agoprocess: Factor code out of process_start() into helper functions.
Ben Pfaff [Wed, 15 Jul 2009 19:07:02 +0000 (12:07 -0700)]
process: Factor code out of process_start() into helper functions.

An upcoming commit will add a new function that can also use these helper
functions.

15 years agoprocess: Fix races on fatal signal handling in process_start().
Ben Pfaff [Wed, 15 Jul 2009 19:05:04 +0000 (12:05 -0700)]
process: Fix races on fatal signal handling in process_start().

To prevent fatal signals in a child process from causing the parent
process's pidfile, etc. to be deleted, we need to block fatal signals
around fork and call fatal_signal_fork() in the child process.

This problem was noticed through code inspection; it has not been observed
in practice.

15 years agovswitchd: New unixctl command "fdb/show" to print the MAC learing table.
Ben Pfaff [Wed, 15 Jul 2009 18:05:37 +0000 (11:05 -0700)]
vswitchd: New unixctl command "fdb/show" to print the MAC learing table.

To implement "brctl showmacs" for bridge compatibility, brcompatd needs to
be able to extract the MAC learning table from ovs-vswitchd.  This provides
a way, and it may be directly useful to switch administrators also.

15 years agomac-learning: New function mac_entry_age().
Ben Pfaff [Wed, 15 Jul 2009 18:02:24 +0000 (11:02 -0700)]
mac-learning: New function mac_entry_age().

This function will be used as part of printing the MAC learning table at
user request.

15 years agoAdd macros for parsing MAC addresses from strings.
Ben Pfaff [Wed, 15 Jul 2009 17:58:30 +0000 (10:58 -0700)]
Add macros for parsing MAC addresses from strings.

15 years agoNew function ds_steal_cstr().
Ben Pfaff [Wed, 15 Jul 2009 17:57:17 +0000 (10:57 -0700)]
New function ds_steal_cstr().

15 years agoAdd function get_null_fd(), to reduce code redundancy.
Ben Pfaff [Wed, 15 Jul 2009 17:54:51 +0000 (10:54 -0700)]
Add function get_null_fd(), to reduce code redundancy.

15 years agoovs-ofctl: Use 65535 instead of 0 for OFPP_CONTROLLER max_len.
Ben Pfaff [Wed, 15 Jul 2009 20:25:11 +0000 (13:25 -0700)]
ovs-ofctl: Use 65535 instead of 0 for OFPP_CONTROLLER max_len.

OpenFlow 0.9 will change the interpretation of a max_len of 0 in an
OFPP_CONTROLLER output action from "send entire packet" to "send 0 bytes
of packet", but ovs-ofctl documents that specifying no argument or "ALL"
as the argument to a CONTROLLER output action sends the whole packet, so
we need to make that happen.

15 years agobrcompat: Improve comments in header file.
Ben Pfaff [Tue, 14 Jul 2009 16:16:55 +0000 (09:16 -0700)]
brcompat: Improve comments in header file.

15 years agovswitchd: Skip updelay on slave when only a single bond slave is up.
Ben Pfaff [Mon, 13 Jul 2009 18:09:52 +0000 (11:09 -0700)]
vswitchd: Skip updelay on slave when only a single bond slave is up.

If a network device takes a few seconds to detect carrier, as some do, then
when bringing up a network device and then immediately adding that device
to a bridge, the bond code would start out with that slave considered down
and apply the full updelay to it before bringing it up.  With the 31-second
updelay set by XenServer, this is excessive: we end up having no
connectivity at all for 31 seconds even though there is no reason for it.

This commit makes the bond code disregard the updelay when an interface
comes up on a bond that has no enabled interfaces, and updates the
documentation to match.

Part of bug #1566.

15 years agovswitchd: Fix log messages when bond slaves are enabled or disabled.
Ben Pfaff [Mon, 13 Jul 2009 17:04:45 +0000 (10:04 -0700)]
vswitchd: Fix log messages when bond slaves are enabled or disabled.

We were printg "enabled" when a slave was disabled and vice versa.

Part of bug #1566.

15 years agoFix unitialized variable in coverage_log()
Justin Pettit [Tue, 14 Jul 2009 07:25:44 +0000 (00:25 -0700)]
Fix unitialized variable in coverage_log()

When providing the ability to force coverage printouts to occur, some
code was moved around that allowed the "hash" variable to be used
unitialized.  This fixes that.

Thanks to Ben for pointing out the problem.

Bug #1577

15 years agodatapath: Don't orphan packets in dp_dev transmit path.
Ben Pfaff [Mon, 13 Jul 2009 22:50:32 +0000 (15:50 -0700)]
datapath: Don't orphan packets in dp_dev transmit path.

Before commit 72ca14c1 "datapath: Fix race against workqueue in dp_dev and
simplify code," the dp_dev network device had a device queue, and we would
orphan packets before sticking them on the queue.  This screwed up socket
accounting a bit, but the effect was limited to the device queue length.

Now, after that commit, the dp_dev device has no device queue, but it still
orphans packets.  This screws up socket accounting a *lot*, because the
effect is now unlimited, since there is no queue to limit it.

The solution is to not orphan packets at all.  There is little need for it
now since packet transmission now happens immediately, not in a workqueue
whose execution may be delayed.

This should fix bug #1519, which tests "netperf -t UDP_STREAM" performance,
finding that an unrealistically high number of UDP packets could be sent
but that none at all were received.  The send rate is due to the orphaning,
the receive rate presumably because at least one out of approx. 65535/1500
= 44 fragments per full packet were dropped in each case.

15 years agovconn: Fix detection of vconn local IP address, to fix in-band control.
Ben Pfaff [Mon, 13 Jul 2009 22:05:51 +0000 (15:05 -0700)]
vconn: Fix detection of vconn local IP address, to fix in-band control.

The in-band control code needs to know the IP and port of both ends of the
control connection.  However, the vconn code was only reporting the local
address after the connection had already succeeded, which created a
chicken-and-egg problem.  In practice we would fail to connect until the
switch went into fail-open, at which point the connection would go through.

Fortunately, we can get the local IP address right after we try to connect,
not just after the connection completes, so this commit changes the code
to do that.

This commit also breaks setting the remote IP and port into functions
separate from vconn_init(), which makes the code more readable.

15 years agoRevert "datapath: Don't orphan packets in dp_dev transmit path."
Ben Pfaff [Mon, 13 Jul 2009 18:56:26 +0000 (11:56 -0700)]
Revert "datapath: Don't orphan packets in dp_dev transmit path."

This reverts commit 0858ad2b9d2f594f99bb11fc9b331ce8b1de953d.
Although that commit partially fixed a performance regression
relative to the Linux bridge, it introduced other problems that
were not apparent in the performance testing (e.g.
WARN_ON_ONCE(skb->destructor) now triggers in dp_process_received_packet()).
The fix is not completely obvious, so reverting now to ensure stability
while investigating the problem.

15 years agodatapath: Don't orphan packets in dp_dev transmit path.
Ben Pfaff [Mon, 13 Jul 2009 16:41:26 +0000 (09:41 -0700)]
datapath: Don't orphan packets in dp_dev transmit path.

Before commit 72ca14c1 "datapath: Fix race against workqueue in dp_dev and
simplify code," the dp_dev network device had a device queue, and we would
orphan packets before sticking them on the queue.  This screwed up socket
accounting a bit, but the effect was limited to the device queue length.

Now, after that commit, the dp_dev device has no device queue, but it still
orphans packets.  This screws up socket accounting a *lot*, because the
effect is now unlimited, since there is no queue to limit it.

The solution is to not orphan packets at all.  There is little need for it
now since packet transmission now happens immediately, not in a workqueue
whose execution may be delayed.

This should fix bug #1519, which tests "netperf -t UDP_STREAM" performance,
finding that an unrealistically high number of UDP packets could be sent
but that none at all were received.  The send rate is due to the orphaning,
the receive rate presumably because at least one out of approx. 65535/1500
= 44 fragments per full packet were dropped in each case.

15 years agoRemove "coverage/clear" command due its limited use
Justin Pettit [Sat, 11 Jul 2009 00:36:09 +0000 (17:36 -0700)]
Remove "coverage/clear" command due its limited use

The poll loop calls coverage_clear on every pass anyway, so provide a
function to call it separately is of limited value.

15 years agoFix small typo in ovs-ofctl man page.
Justin Pettit [Sat, 11 Jul 2009 00:33:41 +0000 (17:33 -0700)]
Fix small typo in ovs-ofctl man page.

15 years agoProvide ability to retrieve coverage information
Justin Pettit [Fri, 10 Jul 2009 22:09:41 +0000 (15:09 -0700)]
Provide ability to retrieve coverage information

Previously, there was no way to induce coverage information to be
displayed; it would only print when the system noticed unusual delays
between polling intervals.  Now, production of coverage logs can be
forced with "coverage/log" command in ovs-appctl.  Coverage counters may
be reset with "coverage/clear".

15 years agoDocument how to submit patches for Open vSwitch.
Ben Pfaff [Fri, 10 Jul 2009 20:38:58 +0000 (13:38 -0700)]
Document how to submit patches for Open vSwitch.

15 years agoDocument how to report bugs in Open vSwitch.
Ben Pfaff [Fri, 10 Jul 2009 18:04:05 +0000 (11:04 -0700)]
Document how to report bugs in Open vSwitch.

15 years agoINSTALL.bridge: Add detail suggested by Pete.
Ben Pfaff [Fri, 10 Jul 2009 18:03:00 +0000 (11:03 -0700)]
INSTALL.bridge: Add detail suggested by Pete.

15 years agoDocument how to use Open vSwitch as a replacement for the Linux bridge.
Ben Pfaff [Fri, 10 Jul 2009 17:35:36 +0000 (10:35 -0700)]
Document how to use Open vSwitch as a replacement for the Linux bridge.

15 years agodatapath: Fix races in updating dp_dev port statistics.
Ben Pfaff [Wed, 8 Jul 2009 19:32:07 +0000 (12:32 -0700)]
datapath: Fix races in updating dp_dev port statistics.

15 years agodatapath: Fix race in datapath creation.
Ben Pfaff [Wed, 8 Jul 2009 18:31:59 +0000 (11:31 -0700)]
datapath: Fix race in datapath creation.

Before we create the local port, we should allocate and assign the table.
Otherwise packets sent on the local port before we do so will cause an
OOPS.

This is a theoretical race that has not been observed in practice.

15 years agodatapath: Fix race against workqueue in dp_dev and simplify code.
Ben Pfaff [Wed, 8 Jul 2009 19:23:32 +0000 (12:23 -0700)]
datapath: Fix race against workqueue in dp_dev and simplify code.

The dp_dev_destroy() function failed to cancel the xmit_queue work, which
allowed it to run after the device had been destroyed, accessing freed
memory.  However, simply canceling the work with cancel_work_sync() would
be insufficient, since other packets could get queued while the work
function was running.  Stopping the queue with netif_tx_disable() doesn't
help, because the final action in dp_dev_do_xmit() is to re-enable the TX
queue.

This issue led me to re-examine why the dp_dev needs to use a work_struct
at all.  This was implemented in commit 71f13ed0b "Send of0 packets from
workqueue, to avoid recursive locking of ofN device" due to a complaint
from lockdep about recursive locking.

However, there's no actual reason that we need any locking around
dp_dev_xmit().  Until now, it has accepted the standard locking provided
by the network stack.  But looking at the other software devices (veth,
loopback), those use NETIF_F_LLTX, which disables this locking, and
presumably do so for this very reason.  In fact, the lwn article at
http://lwn.net/Articles/121566/ hints that NETIF_F_LLTX, which is otherwise
discouraged in the kernel, is acceptable for "certain types of software
device."

So this commit switches to using NETIF_F_LLTX for dp_dev and gets rid
of the work_struct.

In the process, I noticed that veth and loopback also take advantage of
a network device destruction "hook" using the net_device "destructor"
member.  Using this we can automatically get called on network device
destruction at the point where rtnl_unlock() is called.  This allows us
to stop stringing the dp_devs that are being destroyed onto a list so
that we can free them, and thus simplifies the code along all the paths
that call dp_dev_destroy().

This commit gets rid of a call to synchronize_rcu() (disguised as a call
to synchronize_net(), which is a macro that expands to synchronize_rcu()),
so it probably speeds up deleting ports, too.

15 years agodatapath: Remove declarations of functions that are never defined or used.
Ben Pfaff [Wed, 8 Jul 2009 17:53:18 +0000 (10:53 -0700)]
datapath: Remove declarations of functions that are never defined or used.

15 years agodatapath: Fix use-after-free error in datapath destruction.
Ben Pfaff [Fri, 26 Jun 2009 21:15:04 +0000 (14:15 -0700)]
datapath: Fix use-after-free error in datapath destruction.

When we create a datapath we do this:

1. Create local port.
2. Call add_dp hook.
3. Allow userspace to add more ports.

When we deleted a datapath we were doing this:

1. Call del_dp hook
2. Delete all the ports.

Unfortunately step 1 destroys dp->ifobj, then dp_del_port on any port other
than the local port in step 2 tries to reference dp->ifobj through a call
to sysfs_remove_link().

This commit fixes the problem by changing datapath deletion to mirror
creation:

1. Delete all the ports but the local port.
2. Call dp_del hook.
3. Delete local port.

Commit 010082639 "datapath: Add sysfs support for all (otherwise supported)
Linux versions" makes this problem obvious on a 2.6.25+ kernel configured
with slab debugging, because on such kernels the ifobj is a pointer to a
slab object that is freed by the del_dp hook function (when brcompat_mod
is loaded).  This bug may be just as present on older kernels, but there
the ifobj is part of struct datapath, not a pointer, and thus it is much
harder to trigger.

Bug #1465.

15 years agodatapath: Remove redundant synchronize_rcu() call.
Ben Pfaff [Fri, 26 Jun 2009 19:20:02 +0000 (12:20 -0700)]
datapath: Remove redundant synchronize_rcu() call.

There is no benefit to synchronizing twice, and it might cost us a lot of
time.

15 years agosecchan: Various fixes to run in-band on non-"local" port
Justin Pettit [Wed, 8 Jul 2009 17:40:55 +0000 (10:40 -0700)]
secchan: Various fixes to run in-band on non-"local" port

The in-band control code assumed that we would connect to the controller
over the datapath's "local" port.  If the switch had multiple datapaths,
and the controller was only available through one of them, the other
datapaths would fail to connect.  This is addressed by the following
changes:

    - The controller's MAC address is looked up through the connection's
      interface instead of the datapath's local one.

    - We allow ARP traffic to be sent by the connection's interface.

    - We allow ARP traffic to be sent to the controller's MAC address.
      This is necessary if the controller is running locally (e.g. in a VM).

Bug #1466

15 years agoProvide method to locate device by IP and add more nodev functions to netdev
Justin Pettit [Mon, 6 Jul 2009 22:37:19 +0000 (15:37 -0700)]
Provide method to locate device by IP and add more nodev functions to netdev

In some cases we need to be able to locate a device by its IPv4 address.
There doesn't seem to be an easy way to do this on Linux, so we iterate
through all devices until it's found.  The caller can provide a hint as
to the device, so subsequent checks can be quicker.

This checkin also adds nodev versions of functions to lookup ARP entries
and the IPv4 address of a device.

15 years agoShow more information about connection when querying status.
Justin Pettit [Thu, 2 Jul 2009 20:40:20 +0000 (13:40 -0700)]
Show more information about connection when querying status.

It is often useful in debugging to know the ports and IP addresses being
used in an OpenFlow connection.  This commit adds the remote and local
IP addresses and ports used for a connection to the "status" information
returned by ovs-ofctl.

Feature #1484.