cascardo/ovs.git
14 years agoovsdb: Add ovsdb IDL compiler to build system.
Ben Pfaff [Tue, 24 Nov 2009 00:07:36 +0000 (16:07 -0800)]
ovsdb: Add ovsdb IDL compiler to build system.

This first stab at any interface definition language and compiler for OVSDB
will give other developers a chance to look at it and try to integrate it.
The IDL is not actually implemented yet; I am working on that.

14 years agoovsdb: Rename variable to better describe its purpose.
Ben Pfaff [Fri, 20 Nov 2009 23:40:11 +0000 (15:40 -0800)]
ovsdb: Rename variable to better describe its purpose.

Apparently a cut-and-paste error gave this variable a deceptive name.

14 years agoshash: Make it more convenient to store "const" objects in an shash.
Ben Pfaff [Fri, 20 Nov 2009 23:39:07 +0000 (15:39 -0800)]
shash: Make it more convenient to store "const" objects in an shash.

14 years agoovsdb: Require database, table, column names to be valid identifiers.
Ben Pfaff [Fri, 20 Nov 2009 00:48:12 +0000 (16:48 -0800)]
ovsdb: Require database, table, column names to be valid identifiers.

Database, table, and column names have always been required by the OVSDB
specification to be identifiers (e.g. valid C identifiers), but this has
never been enforced.

This commit adds enforcement and fixes one instance of an invalid column
name in the vswitch schema.

14 years agoovsdb: Make ovsdb-server tests pass even when @RUNDIR@ is not writable.
Ben Pfaff [Wed, 18 Nov 2009 20:43:50 +0000 (12:43 -0800)]
ovsdb: Make ovsdb-server tests pass even when @RUNDIR@ is not writable.

14 years agoovsdb: Add more tests for "monitor" feature.
Ben Pfaff [Wed, 18 Nov 2009 20:43:30 +0000 (12:43 -0800)]
ovsdb: Add more tests for "monitor" feature.

14 years agoovsdb-server: Fix crash for invalid parameters to "monitor" request.
Ben Pfaff [Wed, 18 Nov 2009 19:32:16 +0000 (11:32 -0800)]
ovsdb-server: Fix crash for invalid parameters to "monitor" request.

Thanks to Jeremy Stribling <strib@nicira.com> for reporting the problem.

14 years agoovsdb: Monitor support.
Ben Pfaff [Mon, 16 Nov 2009 18:38:14 +0000 (10:38 -0800)]
ovsdb: Monitor support.

14 years agojsonrpc: Add logging for messages sent and received, at DBG level.
Ben Pfaff [Tue, 17 Nov 2009 00:55:35 +0000 (16:55 -0800)]
jsonrpc: Add logging for messages sent and received, at DBG level.

This made it much easier to see problems while developing some
ovsdb-server features.

14 years agoovsdb-server: Add "exit" unixctl command and --unixctl option.
Ben Pfaff [Wed, 18 Nov 2009 00:02:38 +0000 (16:02 -0800)]
ovsdb-server: Add "exit" unixctl command and --unixctl option.

This makes writing predictable test scripts easier.

14 years agoovsdb-parser: Fix logic in ovsdb_parser_member().
Ben Pfaff [Tue, 17 Nov 2009 00:54:13 +0000 (16:54 -0800)]
ovsdb-parser: Fix logic in ovsdb_parser_member().

I don't know why this test was written as it was.  The new test makes more
sense, and may be more correct as well.

14 years agoovsdb-server: Ignore replies to echo requests.
Ben Pfaff [Tue, 17 Nov 2009 00:18:02 +0000 (16:18 -0800)]
ovsdb-server: Ignore replies to echo requests.

Until this commit, ovsdb-server would send off echo requests when the
connection became idle, but then it would terminate the connection when
the reply arrived, because it didn't recognize that it was a reply to its
own request (!).

14 years agoovsdb: Add tests for file storage and for ovsdb-server.
Ben Pfaff [Mon, 16 Nov 2009 23:13:00 +0000 (15:13 -0800)]
ovsdb: Add tests for file storage and for ovsdb-server.

14 years agoovsdb-client: New command "transact".
Ben Pfaff [Mon, 16 Nov 2009 23:12:04 +0000 (15:12 -0800)]
ovsdb-client: New command "transact".

14 years agoovsdb-server: Maintain the database lock with --detach.
Ben Pfaff [Mon, 16 Nov 2009 23:09:50 +0000 (15:09 -0800)]
ovsdb-server: Maintain the database lock with --detach.

Before this commit, "ovsdb-server --detach" would detach after it opened
the database file, which meant that the child process did not hold the
file lock on the database file (because a forked child process does not
inherit its parents' locks).  This commit fixes the problem by making
ovsdb-server open the database only after it has detached.  This fix, in
turn, required that daemonize() not chdir to /, because this would break
databases whose names are given relative to the current directory, and so
this commit also changes ovsdb-server to do so later.

14 years agoovsdb: Refactor JSON-RPC database server implementation.
Ben Pfaff [Fri, 13 Nov 2009 22:47:25 +0000 (14:47 -0800)]
ovsdb: Refactor JSON-RPC database server implementation.

This refactoring breaks up jsonrpc-server.c in a more modular fashion, in
preparation for adding code for table monitors.

14 years agoovsdb: Add replication support and refactor files in terms of replication.
Ben Pfaff [Fri, 13 Nov 2009 21:37:55 +0000 (13:37 -0800)]
ovsdb: Add replication support and refactor files in terms of replication.

An upcoming commit will add support for replicating tables across JSON-RPC
connection.  As a prerequisite ovsdb itself must support basic replication.
This commit adds that support and then reimplements the ovsdb file storage
in terms of that replication.

14 years agoovsdb: Rename ovsdb_file to ovsdb_log.
Ben Pfaff [Fri, 13 Nov 2009 21:23:35 +0000 (13:23 -0800)]
ovsdb: Rename ovsdb_file to ovsdb_log.

This prepares for introducing a new, higher-level ovsdb_file that
encapsulates ovsdb storage in a file.

14 years agoovsdb: Fix use of non-array for JSON-RPC parameters.
Ben Pfaff [Fri, 13 Nov 2009 23:05:19 +0000 (15:05 -0800)]
ovsdb: Fix use of non-array for JSON-RPC parameters.

JSON-RPC requires that "params" be an array, but we weren't observing this
properly in the ovsdb specifications or code.

Thanks to Jeremy Stribling for pointing out the problem.

14 years agoovsdb-parser: Fix indentation.
Ben Pfaff [Mon, 16 Nov 2009 17:19:36 +0000 (09:19 -0800)]
ovsdb-parser: Fix indentation.

14 years agoovsdb-client: Support listening for incoming connections too.
Ben Pfaff [Thu, 12 Nov 2009 20:53:05 +0000 (12:53 -0800)]
ovsdb-client: Support listening for incoming connections too.

This makes it easier to test ovsdb-server's support for active connections.
It might also be useful occasionally, too.

14 years agoovsdb-server: Reconnect to clients specified on --connect.
Ben Pfaff [Thu, 12 Nov 2009 20:58:53 +0000 (12:58 -0800)]
ovsdb-server: Reconnect to clients specified on --connect.

14 years agostream: New function pstream_accept_block().
Ben Pfaff [Thu, 12 Nov 2009 20:52:12 +0000 (12:52 -0800)]
stream: New function pstream_accept_block().

14 years agoNew "reconnect" library for managing network connection attempts.
Ben Pfaff [Tue, 10 Nov 2009 23:30:49 +0000 (15:30 -0800)]
New "reconnect" library for managing network connection attempts.

This library implements the reconnection FSM used by the "rconn" library.
Therefore, it makes sense to change rconn to use this, and I have a patch
to do that, but I am not applying it at the moment to avoid changing unrelated
code on the "db" branch.

14 years agosvec: New function svec_is_empty().
Ben Pfaff [Tue, 10 Nov 2009 23:31:03 +0000 (15:31 -0800)]
svec: New function svec_is_empty().

14 years agovswitch: Only one Open vSwitch daemon is supported per database.
Ben Pfaff [Thu, 12 Nov 2009 20:55:40 +0000 (12:55 -0800)]
vswitch: Only one Open vSwitch daemon is supported per database.

14 years agoovsdb: Add new ovsdb-client program.
Ben Pfaff [Fri, 6 Nov 2009 23:35:34 +0000 (15:35 -0800)]
ovsdb: Add new ovsdb-client program.

14 years agoovsdb: Add documentation for ovsdb-server and ovsdb-tool programs.
Ben Pfaff [Fri, 6 Nov 2009 23:35:10 +0000 (15:35 -0800)]
ovsdb: Add documentation for ovsdb-server and ovsdb-tool programs.

14 years agoovsdb: Improve error message for transaction that uses unknown operation.
Ben Pfaff [Fri, 6 Nov 2009 23:33:25 +0000 (15:33 -0800)]
ovsdb: Improve error message for transaction that uses unknown operation.

Without this commit, misspelling an operation name provokes a mysterious
error message.

14 years agoDon't try to distribute file that doesn't exist.
Ben Pfaff [Fri, 6 Nov 2009 23:28:59 +0000 (15:28 -0800)]
Don't try to distribute file that doesn't exist.

lib/ovsdb-client.h was in my source tree at one point but was never checked
in.

Fixes "make dist".

14 years agoovsdb: Fix inverted logic in ovsdb_open().
Ben Pfaff [Fri, 6 Nov 2009 21:38:00 +0000 (13:38 -0800)]
ovsdb: Fix inverted logic in ovsdb_open().

We want ovsdb_create() (and thus, the open database) to receive the file
only if it is a read-write database.  If it is read-only, then there is
no need to keep the file around, since we will never read or write it
after opening the database.

14 years agoovsdb: Fix use-after-free error in ovsdb_destroy().
Ben Pfaff [Fri, 6 Nov 2009 21:36:41 +0000 (13:36 -0800)]
ovsdb: Fix use-after-free error in ovsdb_destroy().

14 years agoovsdb-server: Remove unixctl transaction support.
Ben Pfaff [Fri, 6 Nov 2009 21:36:17 +0000 (13:36 -0800)]
ovsdb-server: Remove unixctl transaction support.

Executing transactions over JSON-RPC makes more sense, now that it is
supported, so remove the older support for unixctl.

14 years agoovsdb-tool: Make "query" and "transact" commands work properly.
Ben Pfaff [Fri, 6 Nov 2009 21:35:32 +0000 (13:35 -0800)]
ovsdb-tool: Make "query" and "transact" commands work properly.

These were passing O_RDONLY or O_RDWR as arguments to a function that
expected "true" or "false", respectively.

14 years agoovsdb: Make JSON-RPC sessions other than the first work.
Ben Pfaff [Fri, 6 Nov 2009 20:26:00 +0000 (12:26 -0800)]
ovsdb: Make JSON-RPC sessions other than the first work.

The number of open sessions wasn't being tracked properly, so closing a
JSON-RPC database session made it impossible to open any more.

14 years agojson: Make json_equal() compare objects correctly.
Ben Pfaff [Fri, 6 Nov 2009 20:24:44 +0000 (12:24 -0800)]
json: Make json_equal() compare objects correctly.

The previous code checked only that JSON objects have members with the
same names.  This commit makes json_equal() also check that like-named
members have the same values.

14 years agoovsdb: Fix bug in JSON-RPC server.
Jeremy Stribling [Fri, 6 Nov 2009 18:54:16 +0000 (10:54 -0800)]
ovsdb: Fix bug in JSON-RPC server.

14 years agovswitch: First try at an OVSDB schema.
Ben Pfaff [Thu, 5 Nov 2009 19:32:44 +0000 (11:32 -0800)]
vswitch: First try at an OVSDB schema.

14 years agoInitial implementation of OVSDB.
Ben Pfaff [Wed, 4 Nov 2009 23:11:44 +0000 (15:11 -0800)]
Initial implementation of OVSDB.

14 years agoImplement JSON-RPC protocol.
Ben Pfaff [Mon, 26 Oct 2009 22:04:05 +0000 (15:04 -0700)]
Implement JSON-RPC protocol.

14 years agobyteq: Move from extras/ezio into lib and export some private functions.
Ben Pfaff [Wed, 28 Oct 2009 18:06:31 +0000 (11:06 -0700)]
byteq: Move from extras/ezio into lib and export some private functions.

The upcoming JSON-RPC library wants to use this library, and it needs some
functions that are currently declared static.

14 years agostream: New library for bidirectional streams (e.g. TCP, SSL, Unix sockets).
Ben Pfaff [Wed, 4 Nov 2009 23:02:32 +0000 (15:02 -0800)]
stream: New library for bidirectional streams (e.g. TCP, SSL, Unix sockets).

This code is heavily based on the vconn code.  Eventually we should make
the stream-based vconns (currently that's all of them) a wrapper around
streams, but I haven't done that yet.

SSL is not implemented yet.

14 years agosocket-util: Make TCP open function support no default port.
Ben Pfaff [Wed, 28 Oct 2009 22:20:42 +0000 (15:20 -0700)]
socket-util: Make TCP open function support no default port.

Until now, tcp_open_active() and tcp_open_passive() have only been used
in situations where there is a reasonable default port, e.g. OFP_TCP_PORT.
But now, in the upcoming JSON-RPC library and underlying stream library,
there is no reasonable default, so enhance these functions so that they
can require the user to specify a port explicitly.

14 years agoFactor out common code from utilities that multiplex commands.
Ben Pfaff [Fri, 23 Oct 2009 18:49:39 +0000 (11:49 -0700)]
Factor out common code from utilities that multiplex commands.

An upcoming commit will add yet another such utility and the code
redundancy was getting to be a bit much.

14 years agoNew dir_name() function plus tests.
Ben Pfaff [Mon, 19 Oct 2009 21:04:14 +0000 (14:04 -0700)]
New dir_name() function plus tests.

14 years agoutil: Make ovs_error() understand that EOF means "end of file".
Ben Pfaff [Wed, 28 Oct 2009 18:11:18 +0000 (11:11 -0700)]
util: Make ovs_error() understand that EOF means "end of file".

This convention is in use in a few places in the source tree, and so it
seems to be about time to start putting it into central places.

14 years agoImplement RFC 4122-compliant UUIDs.
Ben Pfaff [Thu, 24 Sep 2009 22:02:36 +0000 (15:02 -0700)]
Implement RFC 4122-compliant UUIDs.

This UUID library will be used by the upcoming configuration database.

14 years agoImplement JSON parsing and serialization.
Ben Pfaff [Wed, 4 Nov 2009 22:55:53 +0000 (14:55 -0800)]
Implement JSON parsing and serialization.

This will be used by the upcoming Open vSwitch configuration database.

14 years agosha1: Add functions, macros for converting digests to and from strings.
Ben Pfaff [Wed, 4 Nov 2009 23:12:54 +0000 (15:12 -0800)]
sha1: Add functions, macros for converting digests to and from strings.

These will be used in the upcoming OVSDB.

The SHA1_FMT and SHA1_ARGS macros are arguably absurd, but they are
also convenient.

14 years agoqueue: New function queue_is_empty().
Ben Pfaff [Wed, 28 Oct 2009 18:10:22 +0000 (11:10 -0700)]
queue: New function queue_is_empty().

14 years agoshash: New function shash_sort().
Ben Pfaff [Thu, 29 Oct 2009 21:51:25 +0000 (14:51 -0700)]
shash: New function shash_sort().

14 years agoshash: New function shash_count().
Ben Pfaff [Wed, 4 Nov 2009 22:56:03 +0000 (14:56 -0800)]
shash: New function shash_count().

14 years agoshash: New function shash_find_and_delete().
Ben Pfaff [Wed, 28 Oct 2009 18:10:36 +0000 (11:10 -0700)]
shash: New function shash_find_and_delete().

14 years agohmap: New functions, macros for iterating buckets without comparing hashes.
Ben Pfaff [Tue, 6 Oct 2009 20:31:30 +0000 (13:31 -0700)]
hmap: New functions, macros for iterating buckets without comparing hashes.

Usually, the hash comparison that HMAP_FOR_EACH_WITH_HASH does is an
optimization, because comparing a hash value is usually cheaper than
comparing an entire hash map key.  But for simple hash map keys, it makes
sense to just compare the key directly, because it avoids doing two
comparisons when a single simple comparison suffices.  This commit adds new
functions and macros to support this simple case.

14 years agohmap: Fix bug in hmap_replace().
Ben Pfaff [Tue, 3 Nov 2009 20:50:46 +0000 (12:50 -0800)]
hmap: Fix bug in hmap_replace().

When hmap_replace() replaces one hash table node by another, it must
ensure that any nodes following the old node also follow the new node,
by copying the "next" pointer from "old" to "new".

14 years agohash: Improve hash function for integers.
Ben Pfaff [Thu, 22 Oct 2009 19:58:41 +0000 (12:58 -0700)]
hash: Improve hash function for integers.

As previously defined, the following both returned the same value for
given values of 'basis':
hash_int(0, hash_int(1, basis))
hash_int(1, hash_int(0, basis))
because hash_int(0, basis) evaluated to basis and hash_int(1, basis)
evaluated to c + basis for some constant c.

This commit fixes the problem, by eliminating any simple linear
relationship between basis and the hash value.

We should write some tests for hash function quality.

14 years agohash: Implement hash function for Boolean values.
Ben Pfaff [Wed, 4 Nov 2009 23:01:00 +0000 (15:01 -0800)]
hash: Implement hash function for Boolean values.

This will be used by the configuration database, and it's generally useful
to have around.

14 years agohash: Implement hash function for "double" values.
Ben Pfaff [Thu, 15 Oct 2009 00:03:55 +0000 (17:03 -0700)]
hash: Implement hash function for "double" values.

This will be used by the configuration database, which can store real
numbers.

14 years agohash: Implement hash function for pointer values.
Ben Pfaff [Wed, 4 Nov 2009 23:00:28 +0000 (15:00 -0800)]
hash: Implement hash function for pointer values.

This will be used by an upcoming commit, and it's generally useful to
have around.

14 years agoAdd new function xzalloc(n) as a shorthand for xcalloc(1, n).
Ben Pfaff [Mon, 28 Sep 2009 20:56:42 +0000 (13:56 -0700)]
Add new function xzalloc(n) as a shorthand for xcalloc(1, n).

14 years agoImplement library for lockfiles and use it in cfg code.
Ben Pfaff [Wed, 14 Oct 2009 23:52:04 +0000 (16:52 -0700)]
Implement library for lockfiles and use it in cfg code.

This is useful because the upcoming configuration database also needs a
lockfile implementation.

Also adds tests.

14 years agounixctl: Allow passing auxiliary data to unixctl commands.
Ben Pfaff [Thu, 29 Oct 2009 22:20:21 +0000 (15:20 -0700)]
unixctl: Allow passing auxiliary data to unixctl commands.

This will allow users of unixctl to avoid using global variables, leading
to cleaner code.

14 years agocfg: Fix implementation of timeout in attempting to lock the config file.
Ben Pfaff [Thu, 15 Oct 2009 17:42:59 +0000 (10:42 -0700)]
cfg: Fix implementation of timeout in attempting to lock the config file.

Without removing SA_RESTART from the SIGALRM handler, the fcntl call will
never return, even after the signal handler is invoked and returns.

We haven't seen a problem in practice, at least not recently, but that's
probably just luck combined with not holding the configuration file lock
for very long.

14 years agoAdd test to ensure that time advances both normally and in a daemon.
Ben Pfaff [Wed, 14 Oct 2009 20:14:43 +0000 (13:14 -0700)]
Add test to ensure that time advances both normally and in a daemon.

This commit adds a test to ensure that the fix that makes daemonize()
reinitialize the periodic timer actually worked.

14 years agoDistribute README-gcov, so that users building from tarballs can read it.
Ben Pfaff [Wed, 21 Oct 2009 17:44:44 +0000 (10:44 -0700)]
Distribute README-gcov, so that users building from tarballs can read it.

14 years agoMerge "citrix" into "master".
Ben Pfaff [Fri, 23 Oct 2009 00:43:28 +0000 (17:43 -0700)]
Merge "citrix" into "master".

This merge took a little bit of care due to two issues:

    - Crossport of "interface-reconfigure" fixes from master back to
      citrix that had happened and needed to be canceled out of the merge.

    - New script "refresh-xs-network-uuids" added on citrix branch that
      needed to be moved from /root/vswitch/scripts to
      /usr/share/vswitch/scripts.

14 years agobridge: Eject NORMAL flows without a learning entry from datapath.
Jesse Gross [Thu, 22 Oct 2009 18:40:04 +0000 (11:40 -0700)]
bridge: Eject NORMAL flows without a learning entry from datapath.

When revalidating NORMAL flows we consult the learning table, which
could be empty if a packet hasn't come to userspace in a while or we
just did a bridge flush.  If there is no learning entry then existing
flows will begin flooding packets until a new flow is setup.  The
problem is worse with bonding because we can receive one of the flooded
packets back on a bond slave and learn that port, causing us to send
traffic to the wrong location.

14 years agobonding: Balance bond slaves based on ratio.
Jesse Gross [Wed, 21 Oct 2009 02:26:55 +0000 (19:26 -0700)]
bonding: Balance bond slaves based on ratio.

Previously when deciding whether to migrate a hash between slaves
we would never move it if it would cause more load on the new slave
than the old.  This could lead to a situation where the slaves would
be imbalanced but no migration would occur since it would flip the
load.  This will do the migration if it will decrease the ratio.

Bug NIC-49

14 years agobonding: Drop unicast packets which have a different learned port.
Jesse Gross [Mon, 12 Oct 2009 20:09:51 +0000 (13:09 -0700)]
bonding: Drop unicast packets which have a different learned port.

Drop packets received on a bond port if we have learned a different
source port for that MAC.  We were already doing this for multicast
packets but extend the logic to unicast packets as well since the
same situation can occur if the connected switch has not learned the
MAC address and is flooding.  Otherwise vSwitch will learn the bond
port as the source of that MAC.

Bug #2167

14 years agoxen: Restore state files for VIF VLANs
Jesse Gross [Tue, 20 Oct 2009 03:14:31 +0000 (20:14 -0700)]
xen: Restore state files for VIF VLANs

A change on master to use ovs-vsctl instead of state files for VLANs
was ported to the citrix branch, which does not have ovs-vsctl.  The
interface reconfigure portion, which does not store the state files
was ported but the vif-hotput script portion was not.  This restores
interface reconfigure to again save the state files.

Bug #2187

14 years agoxen: Correctly write VLAN key in config file.
Jesse Gross [Tue, 20 Oct 2009 01:40:11 +0000 (18:40 -0700)]
xen: Correctly write VLAN key in config file.

When adding the VLAN key the name of the vif was from a variable in
use on only the xs5.7 branch.  This uses the correct variable name
for the master branch

14 years agoovs-vsctl: Add tests that adding duplicate bridges or ports fails.
Ben Pfaff [Fri, 16 Oct 2009 16:49:59 +0000 (09:49 -0700)]
ovs-vsctl: Add tests that adding duplicate bridges or ports fails.

Suggested-by: Reid Price <reid@nicira.com>
14 years agoovs-vsctl: Add the ability to perform multiple operations in a single run.
Ben Pfaff [Fri, 16 Oct 2009 16:42:21 +0000 (09:42 -0700)]
ovs-vsctl: Add the ability to perform multiple operations in a single run.

CC: Ian Campbell <Ian.Campbell@citrix.com>
14 years agoovs-vsctl: Refactor internals to increase flexibility.
Ben Pfaff [Fri, 16 Oct 2009 16:36:25 +0000 (09:36 -0700)]
ovs-vsctl: Refactor internals to increase flexibility.

This changes the interface of each of the command implementations, making
them take the configuration as an argument and return the output.  This
will make it easier to support alternate output formats and to execute more
than one command per invocation (both happening in upcoming commits).

14 years agoovs-vsctl: Allow bridge name to be omitted from del-port command.
Ben Pfaff [Thu, 15 Oct 2009 19:47:05 +0000 (12:47 -0700)]
ovs-vsctl: Allow bridge name to be omitted from del-port command.

The 'bridge' argument to ovs-vsctl's del-port command is only supplied as
a form of error checking.  Sometimes the name of the bridge isn't readily
available, so for such situations this commit allows the user to omit the
name of the bridge entirely.

CC: Ian Campbell <Ian.Campbell@citrix.com>
14 years agoovs-vsctl: Log changes to configuration file to syslog.
Ben Pfaff [Fri, 16 Oct 2009 16:26:20 +0000 (09:26 -0700)]
ovs-vsctl: Log changes to configuration file to syslog.

This feature, which has been in ovs-cfg-mod for some time as the "-c"
option, makes it much easier to see what changes ovs-vsctl actually makes
to ovs-vswitchd.conf.

CC: <Ian.Campbell@citrix.com>
14 years agoMake sure that time advances in a daemon between calls to time_refresh().
Ben Pfaff [Thu, 15 Oct 2009 17:39:10 +0000 (10:39 -0700)]
Make sure that time advances in a daemon between calls to time_refresh().

Open vSwitch uses an interval timer signal to tell it that its cached idea
of the current time has expired.  However, this didn't work in a daemon
detached from the foreground session (invoked with --detach) because a
child created with fork() does not inherit the parent's interval timer and
we did not re-set it after calling fork().

This commit fixes the problem by setting the interval timer back up after
calling fork() from daemonize().

This fix is based on code inspection (which was then verified to be correct
through testing).  It may not fix any actual problems in practice, because
time_refresh() is called every time through the poll loop, and the poll
loop typically runs more quickly than the periodic timer fires (1 ms or so
average in ovs-vswitchd, vs. 100 ms timer interval).

14 years agodatapath: Fix build with Linux 2.6.31.
Ben Pfaff [Mon, 12 Oct 2009 18:13:55 +0000 (11:13 -0700)]
datapath: Fix build with Linux 2.6.31.

Linux 2.6.31 breaks the network device functions pointers into a separate
"netdev_ops" structure, so we need to handle this case now too.

14 years agodatapath: Ignore return value from rtnl_notify().
Ben Pfaff [Wed, 24 Jun 2009 21:58:57 +0000 (14:58 -0700)]
datapath: Ignore return value from rtnl_notify().

In Linux 2.6.30, the rtnl_notify() return type was changed from int to
void along with the following commit message:

    This patch also modifies the rtnetlink code to ignore the return
    value of rtnl_notify() in all callers. The function rtnl_notify()
    (before this patch) returned the error of the unicast notification
    which makes rtnl_set_sk_err() reports errors to all listeners. This
    is not of any help since the origin of the change (the socket that
    requested the echoing) notices the ENOBUFS error if the notification
    fails and should resync itself.

Thus there's no point in checking the return value, even in older versions
of the kernel, and so this commit changes our code to ignore it, even
on older kernel versions.  We also update the rtnl_notify() wrapper macros
to make the return type void on older kernel versions.

This has not been tested, just built.

Thanks to Mikio for spurring me to try building with Linux 2.6.29 and
2.6.30.

14 years agodatapath: Fix warning on 64-bit builds.
Ben Pfaff [Mon, 12 Oct 2009 17:34:38 +0000 (10:34 -0700)]
datapath: Fix warning on 64-bit builds.

14 years agodatapath: Factor out code for getting and setting listen mask.
Ben Pfaff [Mon, 12 Oct 2009 17:34:10 +0000 (10:34 -0700)]
datapath: Factor out code for getting and setting listen mask.

This fixes GCC warnings on 64-bit architectures caused by storing an "int"
in the "void *" f->private_data field.

14 years agovlan: Compare vlan tags before implicit tagging when RSPANing.
Jesse Gross [Thu, 8 Oct 2009 19:31:03 +0000 (12:31 -0700)]
vlan: Compare vlan tags before implicit tagging when RSPANing.

We check that a packet is not sent out the on the in port on the
same VLAN when performing RSPAN.  However, we were comparing the
vlan tag from a packet after implicit tagging with a tag from
before implicit tagging.  This ensures that we always compare them
before such tagging.

14 years agodatapath: Fix build with Centos 5.3 kernel.
Ben Pfaff [Fri, 9 Oct 2009 16:41:29 +0000 (09:41 -0700)]
datapath: Fix build with Centos 5.3 kernel.

Centos 5.3 backports more functions from later kernel versions to 2.6.18,
so the kernel version number is no longer a reliable way to check for these
functions.  Thus, add a "configure" test for them.

Reported-by: Paulo Cravero <pcravero@as2594.net>
14 years agodatapath: Add cpumask.h header wrapper to distribution.
Ben Pfaff [Fri, 9 Oct 2009 16:44:47 +0000 (09:44 -0700)]
datapath: Add cpumask.h header wrapper to distribution.

This header was included in the Git tree but we failed to distribute it
as part of the tarball.

This problem was found by inspection.  I am not aware of an actual problem
this fixes.

14 years agoxenserver: Crossport "master" interface-reconfigure to "citrix".
Ben Pfaff [Wed, 7 Oct 2009 19:07:27 +0000 (12:07 -0700)]
xenserver: Crossport "master" interface-reconfigure to "citrix".

This commit copies the interface-reconfigure script from "master" into
"citrix" and fixes up a few incompatibilities: the location of ovs-cfg-mod,
which in master is in /usr/bin and in citrix is in /root/vswitch/bin, and
the RPM spec file fragments needed to initialize the database cache.

The purpose of this commit is to obtain the bug fixes that have been
applied (mainly by Ian Campbell) to "master" but which are not in "citrix".

It's difficult to understand the changes from this commit alone.  It is
more meaningful to compare the resulting files against those currently
on the master branch.

14 years agoofproto: Make current packet counts more accurate.
Jesse Gross [Fri, 14 Aug 2009 20:47:28 +0000 (13:47 -0700)]
ofproto: Make current packet counts more accurate.

When the stats for a currently active flow are requested this
ensures that the packets not handled by the kernel are counted
immediately.  Before, these packets would only be counted once
the kernel flow expired and the counts were combined.

14 years agobonding: Compare ports, not interfaces, for loop checks.
Jesse Gross [Thu, 8 Oct 2009 19:20:10 +0000 (12:20 -0700)]
bonding: Compare ports, not interfaces, for loop checks.

In order to avoid loops we check that the input and output ports
are not equal.  When selecting mirror outputs for RSPAN we were
checking interfaces instead of ports.  This lead to loops when
using RSPAN with bonded ports.

Bug #2118

14 years agoovs-ofctl: Fix use-after-free error in mod-flows command.
Jean Tourrilhes [Thu, 8 Oct 2009 17:39:49 +0000 (10:39 -0700)]
ovs-ofctl: Fix use-after-free error in mod-flows command.

14 years agodatapath: Fix validation of ODPAT_SET_VLAN_PCP actions.
Jean Tourrilhes [Thu, 8 Oct 2009 17:37:43 +0000 (10:37 -0700)]
datapath: Fix validation of ODPAT_SET_VLAN_PCP actions.

The VLAN PCP mask is in the rightmost bits of the vlan_pcp member but we
were checking for it in its position in the VLAN tag field instead.

Slightly modified from Jean's original patch by adding and using the
VLAN_PCP_SHIFT macro.

14 years agoxenserver: Fix ovs-vsctl in built RPM by defining /etc as sysconfdir.
Ben Pfaff [Wed, 7 Oct 2009 17:19:31 +0000 (10:19 -0700)]
xenserver: Fix ovs-vsctl in built RPM by defining /etc as sysconfdir.

By default, the "configure" script picks a sysconfdir of $prefix/etc,
which works out to /usr/etc in our case.  That's wrong, of course--it
should be /etc--but we didn't notice until now because sysconfdir was
only used in ovs-vsctl, which in turn wasn't used at all on a XenServer
system until recently.

This bug is present on all branches, but it is only potentially visible
on "master" and "xs5.7", since only those have ovs-vsctl.  It is only
actually visible on "xs5.7", since that is the only branch where the
system uses ovs-vsctl itself (from /etc/xensource/scripts/vif), but this
is being committed to master in case we start using ovs-vsctl there too.

Reported-by: Henrik Amren <henrik@nicira.com>
14 years agoMerge commit 'v0.90.6' into citrix
Justin Pettit [Tue, 6 Oct 2009 21:33:31 +0000 (14:33 -0700)]
Merge commit 'v0.90.6' into citrix

14 years agoPrepare for v0.90.6 release. v0.90.6
Justin Pettit [Tue, 6 Oct 2009 21:25:36 +0000 (14:25 -0700)]
Prepare for v0.90.6 release.

14 years agoxenserver: Fix dbcache location for xen-bugtool
Justin Pettit [Tue, 6 Oct 2009 18:38:57 +0000 (11:38 -0700)]
xenserver: Fix dbcache location for xen-bugtool

I forgot to add my local changes to xen-bugtool that reflected the new
location for dbcache.

14 years agoMerge commit 'origin/citrix'
Justin Pettit [Tue, 6 Oct 2009 18:08:31 +0000 (11:08 -0700)]
Merge commit 'origin/citrix'

14 years agoxenserver: Include dbcache in xen-bugtool output
Justin Pettit [Tue, 6 Oct 2009 00:32:36 +0000 (17:32 -0700)]
xenserver: Include dbcache in xen-bugtool output

It has been pointed out that it would be useful to have a copy of the
dbcache file in the bug report.  This adds that.

Bug #2106

14 years agonetflow: Increase maximum number of NetFlow records to 30.
Jesse Gross [Mon, 5 Oct 2009 20:25:19 +0000 (13:25 -0700)]
netflow: Increase maximum number of NetFlow records to 30.

NetFlow v5 allows up to 30 records per packet but we were incorrectly
limiting to 29.  This corrects that and also uses the count of the
number of records in the header rather than the packet size since
it is easier to reason about.

Bug #2103

14 years agoMerge "citrix" branch into "master.
Ben Pfaff [Mon, 5 Oct 2009 17:29:07 +0000 (10:29 -0700)]
Merge "citrix" branch into "master.

14 years agobonding: Update the link status on the bond fake interface.
Jesse Gross [Sat, 3 Oct 2009 01:08:05 +0000 (18:08 -0700)]
bonding: Update the link status on the bond fake interface.

Brings the fake bond interface up and down to match our notion of
whether the bond is currently active.  This solves an issue where
XenCenter would always show the bond as disconnected.

Bug #1703

14 years agoxenserver: use ovs-vsctl for VIF VLANs instead of separate state files
Ian Campbell [Mon, 5 Oct 2009 15:32:53 +0000 (16:32 +0100)]
xenserver: use ovs-vsctl for VIF VLANs instead of separate state files

ovs-vsctl did not exist when this code was originally written, but it
provides exactly what is needed to get rid of those separate state
files.

The vif hotplug script diff is against the xs5.7 branch but I think is
applicable to master and/or citrix with just context changes.

I was thinking of using ovs-vsctl exclusively for configuration
modifications from the vif hotplug script but that would need a
mechanism to pass the additional vif details to ovs-vsctl add-port as
well as perhaps making the bridge optional to del-port. The other option
would be to use the --no-reload option and split the config mods into
two parts, but I don't like that idea much.

14 years agoxenserver: Include bridge.*.xs-network-uuids for all networks
Ian Campbell [Mon, 5 Oct 2009 15:27:01 +0000 (16:27 +0100)]
xenserver: Include bridge.*.xs-network-uuids for all networks

Previously I advised that only networks which were currently attached to
the host be listed in /etc/ovs-vswitchd.conf. However I've just realised
that this interacts badly with the slightly ugly special case used for
PIF.currently-attached when reading from dbcache instead of talking to
Xapi. This bites on boot when /etc/init.d/management-interface tries to
plug a selection of PIFs which are deemed to be somehow required by
xapi. (not helped by a bug in XenServer 5.7.0 which can cause this list
to be larger than it should be and not internally consistent).

For now I think it prudent to simply list all networks which could
potentially be attached to a given datapath, until I can figure out what
the sane fix is on the XenServer end.

(I think there are two options for a proper fix, either inspect the
current state of the network devices or assume dbcache represents the
desired final state after devices are plugged on boot. I'm leaning
towards the later since the dbcache should indicate the set of PIFs
which were attached on shutdown, which xapi will likely be trying to
replug on boot... Needs more thought though).