sliver-openvswitch.git
14 years agoMerge citrix branch into master.
Ben Pfaff [Tue, 22 Sep 2009 17:17:44 +0000 (10:17 -0700)]
Merge citrix branch into master.

14 years agobrcompatd: Delete VLAN tags only for the correct port in del_port().
Ben Pfaff [Mon, 21 Sep 2009 22:34:27 +0000 (15:34 -0700)]
brcompatd: Delete VLAN tags only for the correct port in del_port().

vlan.%s.* will match e.g. eth0.123 if the %s expands to eth0.  We only
want it to match eth0 in that case.

This is based on code inspection.  It may or may not fix a real problem.

14 years agoGet ready to tag 0.90.5 release.
Justin Pettit [Mon, 21 Sep 2009 20:08:27 +0000 (13:08 -0700)]
Get ready to tag 0.90.5 release.

14 years agoAdd ChangeLog to track changes
Justin Pettit [Mon, 21 Sep 2009 20:08:12 +0000 (13:08 -0700)]
Add ChangeLog to track changes

14 years agofatal-signal: Add clarifying comments.
Ben Pfaff [Mon, 21 Sep 2009 23:56:37 +0000 (16:56 -0700)]
fatal-signal: Add clarifying comments.

Suggested by Justin Pettit.

14 years agovconn-unix: Unlink Unix sockets for vconns at close and free memory.
Ben Pfaff [Mon, 21 Sep 2009 20:07:10 +0000 (13:07 -0700)]
vconn-unix: Unlink Unix sockets for vconns at close and free memory.

The make_unix_socket() function that Unix vconns use to create their
bindings calls fatal_signal_add_file_to_unlink() to make sure that the
binding socket gets unlinked from the file system if the process is killed
by a fatal signal.  However, this doesn't happen until the process is
actually killed, even if the vconn that owns the socket is actually closed.

This wasn't a problem when the vconn-unix code was written, because all
of the unix vconns were created at process start time and never destroyed
during the normal process runtime.  However, these days the vswitch can
create and destroy unix vconns at runtime depending on the contents of its
configuration file, so it's better to clean up the file system and free
the memory required to keep track of these sockets.

This commit makes unix vconns and pvconns delete their files and free
the memory used to track them when the (p)vconns are closed.

This is only a very minor leak most of the time.

Bug #1817.

14 years agofatal-signal: New function fatal_signal_unlink_file_now().
Ben Pfaff [Mon, 21 Sep 2009 19:37:20 +0000 (12:37 -0700)]
fatal-signal: New function fatal_signal_unlink_file_now().

This is a helper function that combines two actions that callers commonly
wanted.  It will have an additional user in an upcoming commit.

14 years agofatal-signal: Clean up code by using shash.
Ben Pfaff [Mon, 21 Sep 2009 19:38:58 +0000 (12:38 -0700)]
fatal-signal: Clean up code by using shash.

This simplifies the code here and should speed it up, too, when there are
lots of files to unlink on a fatal signal.

14 years agovconn: Remove unused "reconnectable" member from vconn.
Ben Pfaff [Mon, 21 Sep 2009 19:33:30 +0000 (12:33 -0700)]
vconn: Remove unused "reconnectable" member from vconn.

This member is initialized, but nothing ever reads it, so get rid of it.

14 years agovswitchd: Fix memory leak in bridge_reconfigure().
Ben Pfaff [Mon, 21 Sep 2009 20:06:47 +0000 (13:06 -0700)]
vswitchd: Fix memory leak in bridge_reconfigure().

Bug #1817.

14 years agonetdev: Fix memory leak in get_stats_via_netlink().
Ben Pfaff [Mon, 21 Sep 2009 23:10:42 +0000 (16:10 -0700)]
netdev: Fix memory leak in get_stats_via_netlink().

Bug #1817.

14 years agovswitch: More accurately identify slave status for compatibility
Justin Pettit [Tue, 15 Sep 2009 09:08:08 +0000 (02:08 -0700)]
vswitch: More accurately identify slave status for compatibility

Ben Pfaff dug through the kernel sources and reported that
bond_miimon_inspect() supports four BOND_LINK_* states:

       * BOND_LINK_UP: carrier detected, updelay has passed.

       * BOND_LINK_FAIL: carrier lost, downdelay in progress.

       * BOND_LINK_DOWN: carrier lost, downdelay has passed.

       * BOND_LINK_BACK: carrier detected, updelay in progress.

And that bond_info_show_slave() only considers BOND_LINK_UP to be "up"
and anything else to be "down".

Thanks for doing this and suggesting a fix, Ben!

14 years agoutil: Add comments.
Ben Pfaff [Thu, 17 Sep 2009 22:12:34 +0000 (15:12 -0700)]
util: Add comments.

14 years agovswitchd: Fix unimportant memory leak.
Ben Pfaff [Thu, 17 Sep 2009 21:46:18 +0000 (14:46 -0700)]
vswitchd: Fix unimportant memory leak.

Free dpif_names when we're done with it.

This memory leak is not a big deal since bridge_init() is only ever called
once in a given ovs-vswitchd execution.

14 years agobitmap: Don't allocate excessive memory.
Ben Pfaff [Thu, 17 Sep 2009 21:45:18 +0000 (14:45 -0700)]
bitmap: Don't allocate excessive memory.

ROUND_UP rounds up to a multiple of a given value.  That means that
bitmap_allocate() was allocating one byte for each bit in the bitmap,
which is clearly excessive.

Instead, just allocate one bit for every bit in the bitmap.

14 years agoin-band: Document logic behind in-band's design.
Justin Pettit [Tue, 8 Sep 2009 03:50:06 +0000 (20:50 -0700)]
in-band: Document logic behind in-band's design.

There have been numerous attempts at getting in-band correct.  If
history is at all an example, it probably still isn't.  However, this is
an attempt to document its current design, so that we can understand
what our current thinking is.

14 years agoAdd ChangeLog to track changes
Justin Pettit [Tue, 8 Sep 2009 03:44:25 +0000 (20:44 -0700)]
Add ChangeLog to track changes

14 years agoovs-appctl: Correct "target" option synopsis in man page
Justin Pettit [Wed, 16 Sep 2009 14:45:49 +0000 (07:45 -0700)]
ovs-appctl: Correct "target" option synopsis in man page

The synopsis section of the man page for ovs-appctl incorrectly stated
that the target option takes "pid" as an argument.  This commit corrects
that to say "socket".

14 years agoxenserver: Synchronize interface-reconfigure from Citrix.
Ian Campbell [Thu, 17 Sep 2009 18:32:54 +0000 (11:32 -0700)]
xenserver: Synchronize interface-reconfigure from Citrix.

* Drop "--test-mode" option -- it was never wired up to anything.

* Add some additional checks for valid parameter combinations

* Raise some errors for unimplemented (but not currently used in
  XenServer) options.

14 years agoovs-vswitchd: Define missing .IQ macro in manpage.
Ben Pfaff [Thu, 17 Sep 2009 16:32:21 +0000 (09:32 -0700)]
ovs-vswitchd: Define missing .IQ macro in manpage.

This manpage was using a nonstandard macro that it did not define.  Fix
the problem by adding the definition.

Reported-by: Ian Campbell <Ian.Campbell@citrix.com>
14 years agovswitchd: implement bond/hash unixctl
Ian Campbell [Thu, 17 Sep 2009 12:37:25 +0000 (13:37 +0100)]
vswitchd: implement bond/hash unixctl

Our test case automation has a requirement to know which hash value a
given MAC address hashes to, in order to validate that balancing is
happening as expect etc.. Rather than attempt to reimplement the hash
algorithm used by vswitchd in python instead expose an appctl which
returns this information.

14 years agoxenserver: Remove vswitch dbcache file during RPM uninstall.
Ben Pfaff [Thu, 17 Sep 2009 16:26:55 +0000 (09:26 -0700)]
xenserver: Remove vswitch dbcache file during RPM uninstall.

It's good to clean up.

Ported from "citrix" to "master" branch with file name updated.

CC: Keith Amidon <keith@nicira.com>
CC: Henrik Amren <henrik@nicira.com>
14 years agoxenserver: Drop "init-dbcache" by making PIF optional for "rewrite".
Ben Pfaff [Tue, 15 Sep 2009 17:07:23 +0000 (10:07 -0700)]
xenserver: Drop "init-dbcache" by making PIF optional for "rewrite".

Commit ac9634f0af "xenserver: Make RPM install work again" introduced a
new command "init-dbcache" for the interface-reconfigure script.  However
it is cleaner to simply make the PIF argument to the "rewrite" command
optional.

CC: Ian Campbell <Ian.Campbell@citrix.com>
14 years agoxenserver: Remove vswitch dbcache file during RPM uninstall.
Ben Pfaff [Wed, 16 Sep 2009 23:03:55 +0000 (16:03 -0700)]
xenserver: Remove vswitch dbcache file during RPM uninstall.

It's good to clean up.

CC: Keith Amidon <keith@nicira.com>
CC: Henrik Amren <henrik@nicira.com>
14 years agosecchan: Better tolerate failing controller admission control in fail-open.
Ben Pfaff [Wed, 16 Sep 2009 22:12:19 +0000 (15:12 -0700)]
secchan: Better tolerate failing controller admission control in fail-open.

When the switch is configured to connect to a controller that accepts
connections, waits a few seconds, and then disconnects without setting up
flows, currently this causes "fail-open" to flush the flow table and
stop setting up new flows during the connection duration.  This is OK if
it happens once, but it can easily happen every 8 seconds with typical
backoff settings, and that isn't so great.

This commit changes fail-open to only flush the flow table once the switch
appears to have been admitted by the controller, which prevents these
frequent network interruptions.

Thanks to Jesse Gross for especially valuable feedback.

QA notes: Behavior in fail-open and especially behavior with a controller
that rejects the switch after it connects needs to be re-tested.  The
ovs-controller --mute switch added by this commit is one simple way to
create such a controller.

CC: Peter Balland <peter@nicira.com>
Bug #1695.  Bug #2055.

14 years agoFactor out code for composing OFPT_PACKET_IN messages.
Ben Pfaff [Tue, 15 Sep 2009 22:23:45 +0000 (15:23 -0700)]
Factor out code for composing OFPT_PACKET_IN messages.

Currently only ofproto.c ever composes OFPT_PACKET_IN messages, but some
upcoming code wants to do the same thing, so factor this out into a new
function to avoid code duplication.

14 years agoFactor out code for composing benign packets.
Ben Pfaff [Tue, 15 Sep 2009 22:22:17 +0000 (15:22 -0700)]
Factor out code for composing benign packets.

The bonding code in vswitch sends out gratuitous learning packets that
are supposed to teach switches but not cause anything else to happen on
the network.  Some upcoming code wants to synthesize packets with similar
properties, so factor this code into a new function so that it can be
used in both places.

14 years agoovs-pki: Extend validity of generated CA certificates from 3 to 6 years.
Ben Pfaff [Wed, 16 Sep 2009 21:09:29 +0000 (14:09 -0700)]
ovs-pki: Extend validity of generated CA certificates from 3 to 6 years.

Dan requested this change to make it less likely that a user encounter a
CA certificate expiring.

For the "citrix" branch instead of "master" in case a customer upgrades
(without generating new CA certificates) away from the beta.

CC: Dan Wendlandt <dan@nicira.com>
14 years agonetdev-linux: Set missing cache validity bit.
Jesse Gross [Wed, 16 Sep 2009 18:03:42 +0000 (11:03 -0700)]
netdev-linux: Set missing cache validity bit.

Whether a port is internal is cached to avoid requerying the kernel
every time stats are requested.  However, the cache vality bit was
never being set so the cache wasn't used.  This corrects that
oversight.

Thanks to Ben Pfaff for noticing.

14 years agocreate/remove /var/lock/subsys/vswitch on initscript start/stop
Ian Campbell [Wed, 16 Sep 2009 14:56:00 +0000 (15:56 +0100)]
create/remove /var/lock/subsys/vswitch on initscript start/stop

A lock file in /var/lock/subsys must be created with the same name as
the initscript in order for the stop action to be automatically called
on runlevel change. This is true at least on Red Hat derived systems
such as XenServer where /etc/rcS contains:
        # First, run the KILL scripts.
        for i in /etc/rc$runlevel.d/K* ; do
                check_runlevel "$i" || continue

                # Check if the subsystem is already up.
                subsys=${i#/etc/rc$runlevel.d/K??}
                [ -f /var/lock/subsys/$subsys -o -f /var/lock/subsys/$subsys.init ] \
                        || continue
                ...

(This could potentially expose bugs e.g. in the stop priority for the
script since I think it is likely that the stop action hasn't been
running to now. I haven't closely considered this case yet but vswitch
is currently scheduled at K91vswitch vs K90network which seems correct
at first glance)

14 years agodatapath: Fix mutual exclusion with bridge on Linux 2.6.27+.
Ben Pfaff [Fri, 11 Sep 2009 22:49:37 +0000 (15:49 -0700)]
datapath: Fix mutual exclusion with bridge on Linux 2.6.27+.

Linux 2.6.27 introduces a new mechanism for sharing STP packets among
kernel modules, which means that the code in datapath.c to avoid loading
when the Linux bridging module is also loaded has false positives.  So
fall back on these newer kernels to a less reliable way of avoiding the
bridge module, but one that does not have false positives.

CC: Jean Tourrihles <jt@hpl.hp.com>
14 years agoxenserver: Fix detection of xs-network-uuids in interface-reconfigure.
Ben Pfaff [Tue, 15 Sep 2009 21:21:00 +0000 (14:21 -0700)]
xenserver: Fix detection of xs-network-uuids in interface-reconfigure.

Commit c798b21c6a "xenserver: Only consider the host we are running on in
interface-reconfigure" dropped the get_pifs_by_record function in favor
of get_pifs_by_device, but didn't adapt callers properly, so that the
XenServer network PIFs weren't properly found and thus the xs-network-uuids
keys weren't set correctly.

This fixes the caller.

Bug #2043.

14 years agoovs-vsctl: /var/run/ovs-vswitchd.*.ctl is a Unix domain socket
Ian Campbell [Tue, 15 Sep 2009 16:24:46 +0000 (09:24 -0700)]
ovs-vsctl: /var/run/ovs-vswitchd.*.ctl is a Unix domain socket

Currently ov-vsctl tries to treat /var/run/ovs-vswitchd.*.ctl as a
file/pipe when it is actually a Unix domain socket:

        # ovs-vsctl add-br TEST
        Traceback (most recent call last):
          File "/usr/bin/ovs-vsctl", line 498, in ?
            main()
          File "/usr/bin/ovs-vsctl", line 493, in main
            function(*args)
          File "/usr/bin/ovs-vsctl", line 345, in cmd_add_br
            cfg_save(cfg, VSWITCHD_CONF)
          File "/usr/bin/ovs-vsctl", line 142, in cfg_save
            cfg_reload()
          File "/usr/bin/ovs-vsctl", line 126, in cfg_reload
            f = open(target, "r+")
        IOError: [Errno 6] No such device or address: ' '
        # ls -l /var/run/ovs-vswitchd.4173.ctl
        srw------- 1 root root 0 Sep 14 12:25 /var/run/ovs-vswitchd.4173.ctl

From strace:
        open("/var/run/ovs-vswitchd.4173.ctl", O_RDWR|O_LARGEFILE) = -1 ENXIO (No such device or address)

14 years agoovs-vsctl: Add test suite, documentation for br-to-vlan, br-to-parent.
Ben Pfaff [Mon, 14 Sep 2009 18:28:57 +0000 (11:28 -0700)]
ovs-vsctl: Add test suite, documentation for br-to-vlan, br-to-parent.

CC: Ian Campbell <Ian.Campbell@citrix.com>
14 years agonetdev: Swap transmit and receive stats on internal ports.
Jesse Gross [Mon, 14 Sep 2009 21:12:23 +0000 (14:12 -0700)]
netdev: Swap transmit and receive stats on internal ports.

Internal ports appear to have their transmit and receive stats swapped
because from the kernel's point of view these ports are acting like
the machine connected to the switch, not the switch itself.  This swaps
the stats for consistency with other ports.

14 years agosecchan: Fix bad pointer dereference sending flow expirations.
Ben Pfaff [Mon, 14 Sep 2009 20:37:00 +0000 (13:37 -0700)]
secchan: Fix bad pointer dereference sending flow expirations.

14 years agodatapath: Fix WARN_ON sending GSO packets to userspace in Linux 2.6.22+.
Ben Pfaff [Mon, 14 Sep 2009 16:20:58 +0000 (09:20 -0700)]
datapath: Fix WARN_ON sending GSO packets to userspace in Linux 2.6.22+.

Until now, when dp_output_control() queued a GSO packet to userspace, it
would first compute the checksum for the whole GSO packet, then break the
packet into segments.  However this had two drawbacks:

    1. The checksum had to be recomputed for each segment, wasting time.
    2. Linux 2.6.22 and later would emit a warning in skb_gso_segment()
       because the checksum was precomputed.

This commit changes dp_output_control() to instead break the packet into
segments, then compute the checksum across each of the segments
individually.  This fixes both drawbacks.

This commit has seen light testing on Xen's 2.6.27.  It has been build
tested on a few different kernel versions.

14 years agodatapath: Fix comments.
Ben Pfaff [Fri, 11 Sep 2009 17:51:36 +0000 (10:51 -0700)]
datapath: Fix comments.

14 years agoovs-vsctl: additional commands for querying VLAN fake bridges.
Ian Campbell [Mon, 14 Sep 2009 18:27:39 +0000 (11:27 -0700)]
ovs-vsctl: additional commands for querying VLAN fake bridges.

Our test automation needs to be able to validate that a VLAN bridge and
for this I needed two new operations in ovs-vsctl:
      * The ability to query the VLAN tag for a bridge.
      * The ability to query the 'parent' of a bridge. The parent is the
        non-VLAN/untagged bridge with the same physical devices and
        could be a bond.

So given xenbr0 (containing eth0) + xapi2 (VLAN 42 on eth0) and xapi1
(containing bond0 == eth2+eth3) + xapi3 (VLAN 23 on the bonded
interface):

[root@warlock ~]# ovs-vsctl br-to-vlan xapi2
42
[root@warlock ~]# ovs-vsctl br-to-vlan xapi3
23
[root@warlock ~]# ovs-vsctl br-to-parent xapi2
xenbr0
[root@warlock ~]# ovs-vsctl br-to-parent xapi3
xapi1

14 years agoNew utility ovs-vsctl.
Ben Pfaff [Mon, 14 Sep 2009 17:05:13 +0000 (10:05 -0700)]
New utility ovs-vsctl.

14 years agovswitch: Correctly identify slave status in /proc compatibility layer
Justin Pettit [Mon, 14 Sep 2009 11:07:53 +0000 (04:07 -0700)]
vswitch: Correctly identify slave status in /proc compatibility layer

In the /proc compatibility layer, the bond member was reported as up
immediately after link recovery, regardless of the updelay.  I believe
the compatibility code was correct if the check had been done with carrier,
but since 'iface->enabled' already does that calculation, we can use it
directly.

Additinally, when a bond slave was enabled or disabled, the bond
compatibility code was not being told to update its state.  This commit
makes that call.

NIC-39

14 years agoRaise MAC learning table capacity from 1,024 to 2,048 entries per bridge.
Ben Pfaff [Fri, 11 Sep 2009 21:40:02 +0000 (14:40 -0700)]
Raise MAC learning table capacity from 1,024 to 2,048 entries per bridge.

Given a possible 1,024 ports on a bridge the previous limit of 2,048
entries seems low.

If we want to increase this further we should introduce dynamic allocation
of table entries to avoid wasting memory in the common case.

CC: Keith Amidon <keith@nicira.com>
14 years agodatapath: Raise maximum ports per datapath from 256 to 1024.
Ben Pfaff [Fri, 11 Sep 2009 21:32:50 +0000 (14:32 -0700)]
datapath: Raise maximum ports per datapath from 256 to 1024.

This makes the datapath port limit the same as the Linux bridge module
port limit.

CC: Keith Amidon <keith@nicira.com>
14 years agoxenserver: Have xen-bugtool collect OVS logs
Justin Pettit [Sat, 12 Sep 2009 23:40:03 +0000 (16:40 -0700)]
xenserver: Have xen-bugtool collect OVS logs

The original xen-bugtool did not collect any OVS logs.  Now that more
logging is moving from /var/log/messages to ovs-vswitchd's and
ovs-brcompatd's private log files, we should include them in the
information collected for bug reports.

14 years agoMerge commit 'origin/citrix'
Justin Pettit [Sat, 12 Sep 2009 07:49:30 +0000 (00:49 -0700)]
Merge commit 'origin/citrix'

Conflicts:
vswitchd/ovs-vswitchd.8.in
vswitchd/ovs-vswitchd.conf.5.in
xenserver/etc_init.d_vswitch

14 years agoMerge commit 'origin/ctrix' into k
Justin Pettit [Sat, 12 Sep 2009 01:40:38 +0000 (18:40 -0700)]
Merge commit 'origin/ctrix' into k

14 years agoxenserver: Have ovs-brcompatd's log file rotated
Justin Pettit [Fri, 11 Sep 2009 15:15:49 +0000 (08:15 -0700)]
xenserver: Have ovs-brcompatd's log file rotated

Suggested by Ian Campbell.

14 years agovconn: Fix byte-swapping of message type when validating OpenFlow actions.
Jean Tourrihles [Fri, 11 Sep 2009 22:19:15 +0000 (15:19 -0700)]
vconn: Fix byte-swapping of message type when validating OpenFlow actions.

It seems really strange that this one slipped through.  Perhaps this
means that we have never tested with any action other than OFPAT_OUTPUT
(which has value 0 and thus is not affected by byte-swapping).

14 years agoxenserver: Install kernel modules in proper system locations.
Ben Pfaff [Thu, 27 Aug 2009 21:45:36 +0000 (14:45 -0700)]
xenserver: Install kernel modules in proper system locations.

This gets rid of the last files in /root/vswitch.  With this change, the
Open vSwitch RPMs should now comply with FHS (http://www.pathname.com/fhs/).

14 years agoxenserver: Install into /usr instead of /root/vswitch.
Ben Pfaff [Fri, 11 Sep 2009 22:13:08 +0000 (15:13 -0700)]
xenserver: Install into /usr instead of /root/vswitch.

/usr is the standard location for installation, so use that instead of our
nonstandard location under /root.

This migrates everything except the kernel modules to /usr.  The kernel
modules will be migrated in an upcoming commit.

One possibly surprising change is that the manpages listed in the %files
section of vswitch-xen.spec not only moved but added .gz extensions.  This
seems to be because RPM automatically compresses manpages, but only if they
are installed in a standard system location.

14 years agoxenserver: Make RPM install work again.
Ben Pfaff [Fri, 11 Sep 2009 21:41:39 +0000 (14:41 -0700)]
xenserver: Make RPM install work again.

The RPM install was generating a database cache in Python pickle format in
/etc/ovs-vswitchd.conf, but interface-reconfigure was looking for it in
XML format in /var/lib/openvswitch/dbcache.  This fixes the problem, by
adding an init-dbcache command to interface-reconfigure and then using that
at RPM install time.

This moves the database cache creation from %pre to %post.  This is
necessary so that interface-reconfigure is available from the install
script.

14 years agoxenserver: Remove dead store from interface-reconfigure.
Ben Pfaff [Fri, 11 Sep 2009 21:03:00 +0000 (14:03 -0700)]
xenserver: Remove dead store from interface-reconfigure.

No point in looking up pifrec if we're not going to use it.

14 years agoxenserver: Remove unmaintained comments in interface-reconfigure.
Ben Pfaff [Fri, 11 Sep 2009 21:02:17 +0000 (14:02 -0700)]
xenserver: Remove unmaintained comments in interface-reconfigure.

I added these comments a long time ago and have not kept them up-to-date,
so it is probably better to delete them than to confuse people.

14 years agoxenserver: Fix syntax error in vswitch-xen.spec %pre fragment.
Ben Pfaff [Fri, 11 Sep 2009 20:13:37 +0000 (13:13 -0700)]
xenserver: Fix syntax error in vswitch-xen.spec %pre fragment.

14 years agoxenserver: Set default file log level and fix brcompatd file
Justin Pettit [Fri, 11 Sep 2009 17:52:40 +0000 (10:52 -0700)]
xenserver: Set default file log level and fix brcompatd file

Set the default log level for file logging to INFO for ovs-vswitchd and
ovs-brcompatd.  This is done so that coverage messages are kept in the
log file, since we no longer log them through syslog due its synchronous
writing on Xen hosts.  The issue is described in detail in commit 6bc995e.

Fix test for whether file logging should be enabled for ovs-brcompatd.

Reported by Ian Campbell.

14 years agologging: Lower logging level for coverage messages due to slow poll loops
Justin Pettit [Fri, 11 Sep 2009 14:15:24 +0000 (07:15 -0700)]
logging: Lower logging level for coverage messages due to slow poll loops

By default, many OVS processes keep track of their time through a poll
loop.  If it takes an unusually long time (measured as some distance
from the mean), the processes will log stats it has been keeping about
coverage.  It was doing this at level WARN.

On Xen systems, syslog messages written at level INFO and higher are
written to /var/log/messages synchronously.  This would mean that there
would be dire messages that it took a few dozen milliseconds to go
through the loop, meanwhile, it would take up to 6(!) seconds writing
those.  Meanwhile, the process would do no other processing, which could
be quite serious in the case of a process such as ovs-vswitchd.
This problem was somewhat masked because the time used by this logging
was not used in the calculations for determining how long it was taking
to get through the loop.

This commit lowers the default log level for those coverage messages to
INFO.  On Xen systems, it raises the default level at which messages are
written to syslog to WARN.

Diagnosed and fixed with the help of Ian Campbell.

14 years agoDocument ovs-vswitchd's ovs-appctl commands and some ovs-vswitchd internals.
Ben Pfaff [Wed, 9 Sep 2009 18:16:55 +0000 (11:16 -0700)]
Document ovs-vswitchd's ovs-appctl commands and some ovs-vswitchd internals.

CC: Justin Pettit <jpettit@nicira.com>
14 years agoIncrease the default priority of vswitchd and brcompatd
Ben Pfaff [Wed, 9 Sep 2009 17:52:26 +0000 (10:52 -0700)]
Increase the default priority of vswitchd and brcompatd

Our hope is that this will resolve many of the issues we have seen
where temporary delays in the forwarding of packets have caused issues
of various types.

This is a crossport from master of commit 44cb492 by Ian Campbell.

14 years agoRevert "xenserver: Renice netback process to priority 0 by default."
Ben Pfaff [Wed, 9 Sep 2009 17:50:32 +0000 (10:50 -0700)]
Revert "xenserver: Renice netback process to priority 0 by default."

This reverts commit 641a0a4ed0a79d53a52d4e78ce1d90140a768798.

This is a crossport from master of commit b2cdfea by Ian Campbell, with
the following commit message:

Do not renice the netback thread.

We should increase the vswitchd daemon's priority instead.

14 years agoIncrease the default priority of vswitchd and brcompatd
Ian Campbell [Wed, 9 Sep 2009 17:08:59 +0000 (18:08 +0100)]
Increase the default priority of vswitchd and brcompatd

Our hope is that this will resolve many of the issues we have seen
where temporary delays in the forwarding of packets have caused issues
of various types.

14 years agoDo not renice the netback thread.
Ian Campbell [Wed, 9 Sep 2009 17:08:58 +0000 (18:08 +0100)]
Do not renice the netback thread.

We should increase the vswitchd daemon's priority instead.

Reverts 641a0a4ed

14 years agoOnly write Network.PIF elements for this host to dbcache.
Ian Campbell [Wed, 9 Sep 2009 17:09:02 +0000 (18:09 +0100)]
Only write Network.PIF elements for this host to dbcache.

14 years agoAdd PIF.currently_attached to the list of fields used by interface-reconfigure
Ian Campbell [Wed, 9 Sep 2009 17:09:01 +0000 (18:09 +0100)]
Add PIF.currently_attached to the list of fields used by interface-reconfigure

14 years agoMove vswitch state files to /var/lib.
Ian Campbell [Wed, 9 Sep 2009 17:09:00 +0000 (18:09 +0100)]
Move vswitch state files to /var/lib.

I believe this is the correct location for files of this type.

14 years agoxenserver: Don't (try to) remove log files on RPM uninstall.
Ben Pfaff [Thu, 27 Aug 2009 21:36:06 +0000 (14:36 -0700)]
xenserver: Don't (try to) remove log files on RPM uninstall.

The RPM spec file was trying to remove Open vSwitch log files as part of
the RPM uninstall process.  It wasn't succeeding, however, since the glob
pattern was wrong.

Instead of fixing the glob pattern, just stop trying to remove the log
files.  Log files are, after all, important for trying to debug problems,
and if we delete them at uninstall time then that makes life harder.

14 years agoxenserver: Improve readability of /etc/init.d scripts.
Ben Pfaff [Thu, 27 Aug 2009 20:31:52 +0000 (13:31 -0700)]
xenserver: Improve readability of /etc/init.d scripts.

Less redundancy makes code easier to read.

14 years agoxenserver: Don't install at same time as XS 5.5.900 "openvswitch" package.
Ben Pfaff [Tue, 8 Sep 2009 20:20:35 +0000 (13:20 -0700)]
xenserver: Don't install at same time as XS 5.5.900 "openvswitch" package.

XenServer 5.5.900 installs an "openvswitch" package that this package
conflicts with, so add a "Conflicts: openvswitch" to the RPM packaging.

14 years agoxenserver: Avoid "rpm -i" warnings on XenServer 5.5.900.
Ben Pfaff [Tue, 8 Sep 2009 20:18:13 +0000 (13:18 -0700)]
xenserver: Avoid "rpm -i" warnings on XenServer 5.5.900.

Open vSwitch installs successfully on XenServer 5.5.900 but it prints some
worrying messages during the process.  This commit fixes them.

14 years agovswitch: Document that fail-open is enabled by default.
Ben Pfaff [Fri, 4 Sep 2009 20:35:36 +0000 (13:35 -0700)]
vswitch: Document that fail-open is enabled by default.

The vswitchd.conf manpage said that fail-open is disabled by default.  This
is wrong: it is enabled by default.  This commit fixes the documentation.

CC: Sujatha Sumanth <ssumanth@nicira.com>
14 years agovswitchd: Fix typo in comment.
Ben Pfaff [Tue, 8 Sep 2009 19:54:07 +0000 (12:54 -0700)]
vswitchd: Fix typo in comment.

14 years agoMerge commit 'origin/citrix'
Justin Pettit [Sat, 5 Sep 2009 05:23:29 +0000 (22:23 -0700)]
Merge commit 'origin/citrix'

14 years agodatapath: Don't drop MTU-sized VLAN packets from userspace
Justin Pettit [Sat, 5 Sep 2009 00:03:22 +0000 (17:03 -0700)]
datapath: Don't drop MTU-sized VLAN packets from userspace

Before transimitting a packet, the datapath checks that the packet
length is not greater than the MTU.  It determines the length based on
the 'protocol' field in the skb.  If 'protocol' is ETH_P_8021Q, it reduces
the packet length as stored in the 'len' field by four bytes, which
is the size of a VLAN tag header.  Unfortunately, packets that arrived
from userspace were not having the 'protocol' field set, which would
cause MTU-sized packets to be dropped.  This commit sets the 'protocol'
field appropriately.

Thanks to Ben Pfaff for the help diagnosing this issue.

NIC-17 and NIC-26

14 years agoxenserver: Install /etc/sysconfig/vswitch by default.
Ben Pfaff [Thu, 3 Sep 2009 21:28:44 +0000 (14:28 -0700)]
xenserver: Install /etc/sysconfig/vswitch by default.

Until now, the vswitch RPM has installed /etc/sysconfig/vswitch.example
and made the system administrator copy it to /etc/sysconfig/vswitch if he
desires.  This is slightly inconvenient, since it is slightly easier for
the admin if he can just edit /etc/sysconfig/vswitch directly.  This commit
changes to the latter behavior.

Bug #1810.

14 years agoxenserver: Create vswitchd configuration file if it does not exist.
Ben Pfaff [Thu, 3 Sep 2009 19:51:51 +0000 (12:51 -0700)]
xenserver: Create vswitchd configuration file if it does not exist.

/etc/ovs-vswitchd.conf should always be there.  Nevertheless, it is not
nice to entirely break vswitch if it is accidentally deleted.  This commit
makes /etc/init.d/vswitch create an empty configuration file if it is
missing.

Bug #1821.

14 years agovswitchd: Explain why mirroring to a VLAN can cause network problems.
Ben Pfaff [Thu, 3 Sep 2009 19:58:25 +0000 (12:58 -0700)]
vswitchd: Explain why mirroring to a VLAN can cause network problems.

Bug #1963.

14 years agoxenserver: Document all the /etc/sysconfig/vswitch settings.
Ben Pfaff [Thu, 3 Sep 2009 18:53:31 +0000 (11:53 -0700)]
xenserver: Document all the /etc/sysconfig/vswitch settings.

Bug #1853.

14 years agorconn: Speed up in-band control connections, by caching the remote address.
Ben Pfaff [Wed, 2 Sep 2009 19:52:50 +0000 (12:52 -0700)]
rconn: Speed up in-band control connections, by caching the remote address.

In-band control needs to know the IP and port of the controller, so that
it can set up the correct flows to talk to that controller.  Until now,
the rconn code has only made this available when a connection was actually
in progress.  This means that, say, ARP packets will not be allowed through
when the rconn backs off.  The same is true of packets sent by switches
that access the controller through this one.

This commit makes the rconn cache the remote IP and port and local IP
across connection attempts, improving the situation.  In particular, it
reduces the overall amount of time that it takes to connect in my own
simple test case from over 10 seconds to about 2 seconds.

14 years agovconn-tcp: Report correct remote IP and remote port.
Ben Pfaff [Wed, 2 Sep 2009 18:16:40 +0000 (11:16 -0700)]
vconn-tcp: Report correct remote IP and remote port.

TCP vconns were reporting indeterminate remote IP and remote port, which
prevented in-band control from working for TCP vconns.

The code that this fixes is implemented differently on the citrix branch
and thus the bug was not present there.

14 years agoofproto: Fix bad merge in previous commit.
Ben Pfaff [Wed, 2 Sep 2009 18:11:38 +0000 (11:11 -0700)]
ofproto: Fix bad merge in previous commit.

This was fixed in my working tree before I pushed it, but I forgot to
commit it.  Oops.

14 years agoMerge citrix branch into master.
Ben Pfaff [Wed, 2 Sep 2009 17:14:53 +0000 (10:14 -0700)]
Merge citrix branch into master.

14 years agoin-band: Implement L3-based in-band control
Justin Pettit [Mon, 31 Aug 2009 22:18:43 +0000 (15:18 -0700)]
in-band: Implement L3-based in-band control

Previously, in-band control was L2-based.  This worked well when the
controller was on the same network segment as the switch.  However, many
configurations are not set up this way.  These changes allow a switch and
controller to be on different subnets.

This set of changes also fixes some problems related to passing DHCP
traffic as described in Bug #1618.

A full description of the reasoning and supported configurations of
in-band will be forthcoming.

14 years agodpif: Add dpif_port_get_name call
Justin Pettit [Sat, 29 Aug 2009 23:02:56 +0000 (16:02 -0700)]
dpif: Add dpif_port_get_name call

Add ability to lookup a device name by its dpif port number.

14 years agonetdev: Add netdev_get_next_hop call
Justin Pettit [Sat, 29 Aug 2009 22:58:40 +0000 (15:58 -0700)]
netdev: Add netdev_get_next_hop call

Add ability to determine the next hop IP address and device used to
reach a given host.

14 years agoAdd ability for the datapath to match IP address in ARPs
Justin Pettit [Thu, 16 Jul 2009 19:58:28 +0000 (12:58 -0700)]
Add ability for the datapath to match IP address in ARPs

The ability to match the IP addresses in ARP packets allows for fine-grained
control of ARP processing.  Some forthcoming changes to allow in-band
control to operate over L3 requires this support if we don't want to
allow overly broad rules regarding ARPs to always be white-listed.
Unfortunately, OpenFlow does not support this sort of processing yet, so
we must treat OpenFlow ARP rules as having wildcarded those L3 fields.

14 years agoReturn netmask along with IP address when querying through netdev
Justin Pettit [Sat, 11 Jul 2009 00:21:43 +0000 (17:21 -0700)]
Return netmask along with IP address when querying through netdev

The call netdev_get_in4() now allows the caller to also retrieve the
associated netmask.

14 years agosecchan: Tighten in-band traffic always allowed into switch
Justin Pettit [Wed, 8 Jul 2009 22:41:42 +0000 (15:41 -0700)]
secchan: Tighten in-band traffic always allowed into switch

In-band control sets up a bunch of invisible flows that allow the switch
and controller to communicate over OpenFlow.  The rules may have been a
bit too permissive, since it allowed any traffic to reach the
connection's interface.  This set of changes tries to tighten that to
only OpenFlow traffic and ARPs.

14 years agoin-band: Fix status checks that could prevent in-band updates
Justin Pettit [Thu, 27 Aug 2009 22:13:59 +0000 (15:13 -0700)]
in-band: Fix status checks that could prevent in-band updates

The method the status callback was using to retrieve the local and
remote MAC addresses pushed back the refresh timer.  If this were done
frequently, it could prevent in-band control from updating its rules.

14 years agoofproto: Cleanup bridge/dump-flows output
Justin Pettit [Sat, 29 Aug 2009 22:54:28 +0000 (15:54 -0700)]
ofproto: Cleanup bridge/dump-flows output

Add separator that was missing from the output of the "bridge/dump-flows"
command from ovs-appctl.

14 years agonetdev: Fix reversed arguments in netdev_recv warning.
Justin Pettit [Mon, 31 Aug 2009 06:51:41 +0000 (23:51 -0700)]
netdev: Fix reversed arguments in netdev_recv warning.

14 years agodatapath: Use hash table more tolerant of collisions for flow table.
Ben Pfaff [Tue, 1 Sep 2009 17:31:32 +0000 (10:31 -0700)]
datapath: Use hash table more tolerant of collisions for flow table.

The hash table used until now in the kernel datapath for storing the flow
table provides only two slots that a given flow can occupy.  If both of
those slots are already full, for a given flow, then that flow cannot be
added at all and its packets must be handled entirely in userspace, taking
a performance hit.  The code does attempt to compensate for this by making
the flow table rather large: 8 slots per flow actually in the flow table.
In practice, this is usually good enough, but some of the tests that we
have run show bad enough performance degradation or even timeouts of
various kinds that we want to implement something better.

This commit replaces the existing hash table by one with a completely
different design in which buckets are flexibly sized and can accept any
number of collisions.  By use of suitable levels of indirection, this
design is both simple and RCU-compatible.  I did consider other schemes,
but none of the ones that I came up with shared both of those two
properties.

This commit also adds kerneldoc comments for all of the flow table
non-static functions and data structures.

This has been lightly tested for correctness.  It has not been tested for
performance.

Bug #1656.  Bug #1851.

14 years agodatapath: Remove WARN_ON_ONCE(1) now that this code has been exercised.
Ben Pfaff [Tue, 1 Sep 2009 17:12:12 +0000 (10:12 -0700)]
datapath: Remove WARN_ON_ONCE(1) now that this code has been exercised.

The code on one side of this #if fork was difficult to test until Xen
upgraded to a new enough kernel that it would exercise it.  Later Xen
kernels are now available and this code path has been tested, at least to
some extent, so remove the warning.

Thanks to Ian Campbell <Ian.Campbell@citrix.com> for pointing out the
warning.

14 years agocorekeeper: Always include PID in core dump names.
Ben Pfaff [Fri, 28 Aug 2009 20:05:48 +0000 (13:05 -0700)]
corekeeper: Always include PID in core dump names.

Some distributions automatically set /proc/sys/kernel/core_uses_pid to 1
and others leave it at its default setting of 0.  That means that, with the
core_pattern that corekeeper was setting, on the former distributions the
PID would be included in core names and on the latter the PID would be
omitted.  For consistency, this commit forces the PID to be in the core
file name in either case (note that putting %p in core_pattern causes
the core_uses_pid setting to be disregarded).

CC: Martin Casado <casado@nicira.com>
14 years agosecchan: Avoid sending NetFlow packets for empty flows.
Ben Pfaff [Fri, 28 Aug 2009 21:59:42 +0000 (14:59 -0700)]
secchan: Avoid sending NetFlow packets for empty flows.

There is no value in sending out NetFlow messages when the byte counter
(hence, packet counter) is 0.  This does not often happen, but it can in
corner cases where a flow gets installed but never sees any traffic before
it is uninstalled.

CC: Peter Balland <peter@nicira.com>
14 years agovswitchd: Mirror nothing, not everything, if mirror ports don't exist.
Ben Pfaff [Mon, 24 Aug 2009 18:06:34 +0000 (11:06 -0700)]
vswitchd: Mirror nothing, not everything, if mirror ports don't exist.

If all of the ports specified as mirror selection criteria actually do not
exist, then until now the bridge would mirror all incoming packets (on
specified VLAN(s), if any).  This matches the behavior that occurs if no
mirror selection ports were specified at all, and so it makes a certain
amount of logical sense.

But it is far more likely that the user simply misspelled a port name, or
specified the name of a port that does not always exist.  In fact we have
seen this behavior in practice when the controller has not caught up to
the switch's current configuration.  So this commit changes the bridge to
instead disable a mirror if ports are specified and none of those ports
exist.

Bug #1904.

14 years agovswitchd: Avoid output port explosion with mirrors that output to VLANs.
Ben Pfaff [Mon, 24 Aug 2009 17:42:44 +0000 (10:42 -0700)]
vswitchd: Avoid output port explosion with mirrors that output to VLANs.

compose_dsts() was updating the VLAN of packets sent to VLAN mirrors
before it changed the VLAN value, but of course it's the final VLAN value
that actually matters.

Thanks to Reid for his good work tracking this one down.

Bug #1898.

14 years agovswitchd: Fix bug in Ethernet address selection for bridge.
Ben Pfaff [Wed, 26 Aug 2009 19:51:39 +0000 (12:51 -0700)]
vswitchd: Fix bug in Ethernet address selection for bridge.

This bug was introduced in the merge from the citrix branch in commit
8fef8c71 "Merge citrix into master."

Thanks to Reid for characterizing the problem.

Bug #1907.

14 years agotests: Cleanup getsockname argument warning
Justin Pettit [Tue, 25 Aug 2009 23:34:45 +0000 (16:34 -0700)]
tests: Cleanup getsockname argument warning

The second argument was being passed in as a sockaddr_in, when it should
be a sockaddr.  This commit cleans up the warning by casting it.

14 years agotests: Cleanup islower() warning.
Justin Pettit [Tue, 25 Aug 2009 23:33:16 +0000 (16:33 -0700)]
tests: Cleanup islower() warning.

NetBSD's gcc complains if islower()'s argument is an unadorned char.  This
provides an appropriate cast.

14 years agoCleanup incorrect unitialized variable warnings.
Justin Pettit [Tue, 25 Aug 2009 23:26:36 +0000 (16:26 -0700)]
Cleanup incorrect unitialized variable warnings.

The NetBSD compiler warns that these variables may be used unitialized.
They are not, but this commit gets rid of the warnings.

14 years agotests: Rename NTOHL/NTOHS macros
Justin Pettit [Tue, 25 Aug 2009 23:22:44 +0000 (16:22 -0700)]
tests: Rename NTOHL/NTOHS macros

NetBSD defines NTOHL and NTOHS macros that are used differently than how
they are defined in the test-classifier.c.  This commit renames the local
definition so there's no conflict.