openvswitch
13 years agoovs.jsonrpc: Fix static method Message.__validate_arg reference to 'self'.
Ben Pfaff [Thu, 25 Aug 2011 00:06:11 +0000 (17:06 -0700)]
ovs.jsonrpc: Fix static method Message.__validate_arg reference to 'self'.

This method needs to be an instance method because it refers to 'self'.

Found by pychecker.

13 years agoovs.json: Use Exception, which exists, instead of Error, which doesn't.
Ben Pfaff [Thu, 25 Aug 2011 00:04:20 +0000 (17:04 -0700)]
ovs.json: Use Exception, which exists, instead of Error, which doesn't.

Found by pychecker.

13 years agoovs.db.idl: Fix error message format arguments.
Ben Pfaff [Thu, 25 Aug 2011 00:03:42 +0000 (17:03 -0700)]
ovs.db.idl: Fix error message format arguments.

There's no variable table_name.

Found by pychecker.

13 years agoovs.daemon: Add missing format string argument.
Ben Pfaff [Thu, 25 Aug 2011 00:01:14 +0000 (17:01 -0700)]
ovs.daemon: Add missing format string argument.

Found by pychecker.

13 years agoovs.daemon: Fix name of EALREADY error.
Ben Pfaff [Thu, 25 Aug 2011 00:00:46 +0000 (17:00 -0700)]
ovs.daemon: Fix name of EALREADY error.

Found by pychecker.

13 years agoovs.daemon: Add missing 'global' when setting _pidfile_dev, _pidfile_ino.
Ben Pfaff [Thu, 25 Aug 2011 00:00:15 +0000 (17:00 -0700)]
ovs.daemon: Add missing 'global' when setting _pidfile_dev, _pidfile_ino.

Found by pychecker.

13 years agoovs.db.idl: Fix call to ovs.db.parser.Parser constructor.
Ben Pfaff [Thu, 25 Aug 2011 18:06:53 +0000 (11:06 -0700)]
ovs.db.idl: Fix call to ovs.db.parser.Parser constructor.

This bug was introduced by commit 4c0f62718f "ovs.db.idl: Improve error
reporting for bad <row-update>s."

Found by pychecker.
Bug #7006.

13 years agodebian: Apply Ubuntu patch to add DKMS support.
Chuck Short [Tue, 23 Aug 2011 22:37:11 +0000 (15:37 -0700)]
debian: Apply Ubuntu patch to add DKMS support.

I tested that installing openvswitch-datapath-dkms worked OK on my own
Debian machine.

The bulk of this patch is taken from downstream Ubuntu DKMS support written
by Chuck Short <zulcss@ubuntu.com>, version 1.2.0-1ubuntu1.  I made the
following changes:

  * Update debian/.gitignore.

  * Update debian/automake.mk.

  * Correct description in debian/control (it was a cut-and-paste from
    the openvswitch-datapath-source description without editing).

  * Fix up for --with-l26 to --with-linux and datapath/linux-2.6 to
    datapath/linux transitions.

CC: Chuck Short <zulcss@ubuntu.com>
CC: Dave Walker <DaveWalker@ubuntu.com>
Acked-by: Simon Horman <horms@verge.net.au>
13 years agodocs: Add Makefile rule to check syntax of manpages.
Ben Pfaff [Wed, 24 Aug 2011 17:45:32 +0000 (10:45 -0700)]
docs: Add Makefile rule to check syntax of manpages.

This should catch future nroff syntax errors immediately, instead of much
later.

13 years agodocs: Fix some manpage syntax errors found with "groff".
Ben Pfaff [Wed, 24 Aug 2011 17:43:41 +0000 (10:43 -0700)]
docs: Fix some manpage syntax errors found with "groff".

13 years agopython: Use enumerate() builtin function to simplify counted iteration.
Ben Pfaff [Tue, 23 Aug 2011 21:43:54 +0000 (14:43 -0700)]
python: Use enumerate() builtin function to simplify counted iteration.

Suggested-by: Reid Price <reid@nicira.com>
13 years agoovs.stream: Simplify logic in Stream.wait().
Ben Pfaff [Tue, 23 Aug 2011 18:16:57 +0000 (11:16 -0700)]
ovs.stream: Simplify logic in Stream.wait().

Suggested-by: Reid Price <reid@nicira.com>
13 years agoovs.stream: Drop Stream.get_name() since clients can use 'name' directly.
Ben Pfaff [Tue, 23 Aug 2011 18:16:27 +0000 (11:16 -0700)]
ovs.stream: Drop Stream.get_name() since clients can use 'name' directly.

Suggested-by: Reid Price <reid@nicira.com>
13 years agoovs.stream: Use %d in place of %ld since the two are equivalent in Python.
Ben Pfaff [Tue, 23 Aug 2011 17:47:53 +0000 (10:47 -0700)]
ovs.stream: Use %d in place of %ld since the two are equivalent in Python.

Reported-by: Reid Price <reid@nicira.com>
13 years agoovs.reconnect: Fix typo in documentation.
Ben Pfaff [Tue, 23 Aug 2011 18:33:08 +0000 (11:33 -0700)]
ovs.reconnect: Fix typo in documentation.

Reported-by: Reid Price <reid@nicira.com>
13 years agoovs.reconnect: Make Reconnect.Reconnect inherit from object.
Ben Pfaff [Tue, 23 Aug 2011 17:45:43 +0000 (10:45 -0700)]
ovs.reconnect: Make Reconnect.Reconnect inherit from object.

Reported-by: Reid Price <reid@nicira.com>
13 years agoovs.jsonrpc: Use "not X" in place of "len(X) == 0" for testing strings.
Ben Pfaff [Tue, 23 Aug 2011 17:43:26 +0000 (10:43 -0700)]
ovs.jsonrpc: Use "not X" in place of "len(X) == 0" for testing strings.

Suggested-by: Reid Price <reid@nicira.com>
13 years agoovs.jsonrpc: Remove Connection.get_name()--clients can use 'name' directly.
Ben Pfaff [Tue, 23 Aug 2011 17:40:24 +0000 (10:40 -0700)]
ovs.jsonrpc: Remove Connection.get_name()--clients can use 'name' directly.

Suggested-by: Reid Price <reid@nicira.com>
13 years agoovs.jsonrpc: Remove dead class variable Message.__next_id.
Ben Pfaff [Tue, 23 Aug 2011 17:37:39 +0000 (10:37 -0700)]
ovs.jsonrpc: Remove dead class variable Message.__next_id.

Reported-by: Reid Price <reid@nicira.com>
13 years agoovs.json: Optimize __dump_string().
Ben Pfaff [Wed, 24 Aug 2011 19:05:13 +0000 (12:05 -0700)]
ovs.json: Optimize __dump_string().

Suggested-by: Reid Price <reid@nicira.com>
13 years agoovs.fatal_signal: Remove unnecessary "global" statement.
Ben Pfaff [Tue, 23 Aug 2011 17:31:22 +0000 (10:31 -0700)]
ovs.fatal_signal: Remove unnecessary "global" statement.

Suggested-by: Reid Price <reid@nicira.com>
13 years agoovs.fatal_signal: Reorder definitions to be more easily readable.
Ben Pfaff [Tue, 23 Aug 2011 17:29:40 +0000 (10:29 -0700)]
ovs.fatal_signal: Reorder definitions to be more easily readable.

Suggested-by: Reid Price <reid@nicira.com>
13 years agoovs.db.types: Introduce DEFAULT_MIN, DEFAULT_MAX as Type class members.
Ben Pfaff [Tue, 23 Aug 2011 17:06:04 +0000 (10:06 -0700)]
ovs.db.types: Introduce DEFAULT_MIN, DEFAULT_MAX as Type class members.

Suggested-by: Reid Price <reid@nicira.com>
13 years agoovs.db.types: Use toAtomicType() instead of open-coding it.
Ben Pfaff [Tue, 23 Aug 2011 17:04:14 +0000 (10:04 -0700)]
ovs.db.types: Use toAtomicType() instead of open-coding it.

Suggested-by: Reid Price <reid@nicira.com>
13 years agoovs.db.types: Simplify code to avoid try/except case.
Ben Pfaff [Tue, 23 Aug 2011 16:58:49 +0000 (09:58 -0700)]
ovs.db.types: Simplify code to avoid try/except case.

Also fixes a typo that caused one version of the error message to have a
hyphen and the other to have a space.

Suggested-by: Reid Price <reid@nicira.com>
13 years agoovs.db.types: Use .append instead of += for adding to lists.
Ben Pfaff [Tue, 23 Aug 2011 21:00:54 +0000 (14:00 -0700)]
ovs.db.types: Use .append instead of += for adding to lists.

Python does not do a good job of appending lists to lists.

Suggested-by: Reid Price <reid@nicira.com>
13 years agoovs.db.schema: Factor common checks for identifiers into new function.
Ben Pfaff [Tue, 23 Aug 2011 16:55:14 +0000 (09:55 -0700)]
ovs.db.schema: Factor common checks for identifiers into new function.

Suggested-by: Reid Price <reid@nicira.com>
13 years agoovs.db.parser: Simplify code.
Ben Pfaff [Tue, 23 Aug 2011 16:36:56 +0000 (09:36 -0700)]
ovs.db.parser: Simplify code.

Suggested-by: Reid Price <reid@nicira.com>
13 years agoovs.db.idl: Use top-level class to represent IDL rows.
Ben Pfaff [Tue, 23 Aug 2011 16:36:39 +0000 (09:36 -0700)]
ovs.db.idl: Use top-level class to represent IDL rows.

According to Reid, there may be some disadvantages to having this class be
anonymous, for example, cannot do instance/typechecking, might be
allocating a new class for every row as well, which isn't the most memory
efficient.

Suggested-by: Reid Price <reid@nicira.com>
13 years agoovs.db.idl: Actually use Idl.__modify_row()'s return value.
Ben Pfaff [Tue, 23 Aug 2011 16:26:29 +0000 (09:26 -0700)]
ovs.db.idl: Actually use Idl.__modify_row()'s return value.

Idl.__parse_row_update() assumed that every change that the database server
sent down actually modified the database.  This is generally true, but
since Idl.__modify_row() already returns whether there was a change, we
might as well use it.

Reported-by: Reid Price <reid@nicira.com>
13 years agoovs.db.idl: Improve error reporting for bad <row-update>s.
Ben Pfaff [Tue, 23 Aug 2011 00:12:59 +0000 (17:12 -0700)]
ovs.db.idl: Improve error reporting for bad <row-update>s.

Strangely malformed <row-update>s could hypothetically get confusing error
message.  Using the Parser class should avoid that.

Reported-by: Reid Price <reid@nicira.com>
13 years agoovsdb-data: Simplify converting an OVSDB datum to JSON by reordering logic.
Ben Pfaff [Mon, 22 Aug 2011 21:52:21 +0000 (14:52 -0700)]
ovsdb-data: Simplify converting an OVSDB datum to JSON by reordering logic.

Putting the "map" case first avoids duplicate tests.

Suggested-by: Reid Price <reid@nicira.com>
13 years agodaemon: Stylistic improvement for __read_pidfile in Python implementation.
Ben Pfaff [Mon, 22 Aug 2011 21:40:09 +0000 (14:40 -0700)]
daemon: Stylistic improvement for __read_pidfile in Python implementation.

Suggested-by: Reid Price <reid@nicira.com>
13 years agodaemon: Correct comment in Python implementation.
Ben Pfaff [Mon, 22 Aug 2011 21:26:58 +0000 (14:26 -0700)]
daemon: Correct comment in Python implementation.

Reported-by: Reid Price <reid@nicira.com>
13 years agopython: Avoid using 'tuple' as a variable name.
Ben Pfaff [Tue, 23 Aug 2011 17:50:47 +0000 (10:50 -0700)]
python: Avoid using 'tuple' as a variable name.

'tuple' is a Python built-in function, so it's best to avoid using it as a
variable name.

Suggested-by: Reid Price <reid@nicira.com>
13 years agopython: Avoid using 'type' as a variable name.
Ben Pfaff [Tue, 23 Aug 2011 16:50:46 +0000 (09:50 -0700)]
python: Avoid using 'type' as a variable name.

'type' is a Python built-in function, so it's best to avoid using it as
a variable name.

Reported-by: Reid Price <reid@nicira.com>
13 years agopython: Take advantage of Python "x < y < z" syntax.
Ben Pfaff [Mon, 22 Aug 2011 23:49:53 +0000 (16:49 -0700)]
python: Take advantage of Python "x < y < z" syntax.

Suggested-by: Reid Price <reid@nicira.com>
13 years agopython: Avoid lots of \" in quoted strings by using '' as outermost quotes.
Ben Pfaff [Mon, 22 Aug 2011 23:54:28 +0000 (16:54 -0700)]
python: Avoid lots of \" in quoted strings by using '' as outermost quotes.

Suggested-by: Reid Price <reid@nicira.com>
13 years agopython: Join a list of strings instead of concatenating a long string.
Ben Pfaff [Tue, 23 Aug 2011 21:02:03 +0000 (14:02 -0700)]
python: Join a list of strings instead of concatenating a long string.

Python does not do a good job of appending strings: it takes O(n**2) time
to append n strings.

Suggested-by: Reid Price <reid@nicira.com>
13 years agopython: Use getattr() and setattr() instead of __dict__.
Ben Pfaff [Mon, 22 Aug 2011 21:31:18 +0000 (14:31 -0700)]
python: Use getattr() and setattr() instead of __dict__.

This leaves one use of __dict__ used for iterating through attributes.
I could use dir() instead, but I was put off by this note in its
documentation in the Python Library Reference:

    Because dir() is supplied primarily as a convenience for use at an
    interactive prompt, it tries to supply an interesting set of names more
    than it tries to supply a rigorously or consistently defined set of names,
    and its detailed behavior may change across releases.  For example,
    metaclass attributes are not in the result list when the argument is a
    class.

Suggested-by: Reid Price <reid@nicira.com>
13 years agoovs.db.data: Fix bugs in Atom.is_default() and Datum.is_default().
Ben Pfaff [Wed, 24 Aug 2011 18:57:14 +0000 (11:57 -0700)]
ovs.db.data: Fix bugs in Atom.is_default() and Datum.is_default().

Reported-by: Reid Price <reid@nicira.com>
13 years agoovs.stream: Fix logic bug in Stream.connect().
Ben Pfaff [Tue, 23 Aug 2011 18:09:46 +0000 (11:09 -0700)]
ovs.stream: Fix logic bug in Stream.connect().

The loop here is supposed to run at least once, and to continue looping as
long as the loop body changes the current state, but this bug caused it to
continue looping until the connection completed in success or failure.  It
probably didn't cause many problems in practice because only Unix domain
socket connections are currently supported, and those connections normally
complete immediately.

Reported-by: Reid Price <reid@nicira.com>
13 years agoDebian: set -e in brcompat postinst
Simon Horman [Wed, 24 Aug 2011 01:40:55 +0000 (10:40 +0900)]
Debian: set -e in brcompat postinst

As reported by lintian:

The maintainer script doesn't seem to set the -e flag which ensures
that the script's execution is aborted when any executed command
fails.

Refer to Debian Policy Manual section 10.4 (Scripts) for details.

13 years agodoc: Add spaces between commas to avoid overflowing line during formatting.
Ben Pfaff [Wed, 24 Aug 2011 16:45:18 +0000 (09:45 -0700)]
doc: Add spaces between commas to avoid overflowing line during formatting.

This resolves a warning reported as
"71: warning [p 11, 5.0i]: cannot adjust line"

Reported-by: Simon Horman <horms@verge.net.au>
Found by lintian.

13 years agodocs: Add missing escape
Simon Horman [Wed, 24 Aug 2011 01:40:53 +0000 (10:40 +0900)]
docs: Add missing escape

This adds what appears to be a missing character to an escape sequence.

This resolves a problem reported as
"a newline character is not allowed in an escape name".

Reported by lintian

13 years agodocs: Suppress "warning: macro `DD' not defined" warning
Simon Horman [Wed, 24 Aug 2011 01:40:52 +0000 (10:40 +0900)]
docs: Suppress "warning: macro `DD' not defined" warning

Suppress "warning: macro `DD' not defined" warning for ovs-brcompatd.8.

As per the description by Ben Pfaff for the same problem effecting
other files:

deamon.man allows the file that is including it to include extra
text in the description of --detach by defining a macro named DD.
Only some of the manpages that included it did this (only those
manpages that needed extra text there).  But it's better to be
quiet in "man --warnings", so this defines DD to an empty value in
the other manpages that include daemon.man.

Reported by lintian

13 years agoDebian: Add dependency on ${misc:Depends}
Simon Horman [Wed, 24 Aug 2011 01:40:51 +0000 (10:40 +0900)]
Debian: Add dependency on ${misc:Depends}

Add dependency on ${misc:Depends} to openvswitch-brcompat and ovsdbmonitor.
As reported by Lintian:

The source package uses debhelper, but it does not include
${misc:Depends} in the given binary package's debian/control entry.
Any debhelper command may add dependencies to ${misc:Depends} that
are required for the work that it does, so recommended best
practice is always add ${misc:Depends} to the dependencies of each
binary package if debhelper is in use.

Refer to the debhelper(7) manual page for details.

13 years agodpif-linux: Call rtnetlink_notifier_run() as required.
Ethan Jackson [Sat, 20 Aug 2011 00:50:32 +0000 (17:50 -0700)]
dpif-linux: Call rtnetlink_notifier_run() as required.

I don't think this actually fixes a bug, as netdev-linux calls this
function. However, it seems stylistically more correct.

13 years agortnetlink: Notifiers should only run once per poll loop.
Ethan Jackson [Mon, 22 Aug 2011 19:47:43 +0000 (12:47 -0700)]
rtnetlink: Notifiers should only run once per poll loop.

rtnetlink_notifier_run() does quite a bit of work, and is likely
only to have interesting effects once per poll loop.

13 years agoDrop spurious 'H' cases from daemon option parsing switch statements.
Ben Pfaff [Mon, 22 Aug 2011 17:41:21 +0000 (10:41 -0700)]
Drop spurious 'H' cases from daemon option parsing switch statements.

Help is 'h'.  I don't see how 'H' can ever happen.

13 years agodatapath: Remove unneeded { } around single statement.
Ben Pfaff [Fri, 19 Aug 2011 22:43:06 +0000 (15:43 -0700)]
datapath: Remove unneeded { } around single statement.

I noticed this looking around at other code.

Signed-off-by: Ben Pfaff <blp@nicira.com>
Acked-by: Jesse Gross <jesse@nicira.com>
13 years agodatapath: Use "OVS_*" as opposed to "ODP_*" for user<->kernel interactions.
Justin Pettit [Thu, 18 Aug 2011 17:35:40 +0000 (10:35 -0700)]
datapath: Use "OVS_*" as opposed to "ODP_*" for user<->kernel interactions.

The prefix "ODP_*" is not overly descriptive in the context of the
larger Linux tree.  This commit changes the prefix to "OVS_*" for the
userpace to kernel interactions.  The userspace libraries still use
"ODP_" in many of their interfaces since it is more descriptive in the
OVS oeuvre.

Feature #6904

Signed-off-by: Justin Pettit <jpettit@nicira.com>
Acked-by: Jesse Gross <jesse@nicira.com>
13 years agoofproto-dpif: Delete MAC learning entries when they expire.
Ben Pfaff [Fri, 19 Aug 2011 21:29:27 +0000 (14:29 -0700)]
ofproto-dpif: Delete MAC learning entries when they expire.

Commit fa066f015f716c7 "bridge: Move packet processing functionality into
ofproto" deleted the call to mac_learning_run() that deletes MAC learning
table entries when they expire.  This fixes the problem.

13 years agoclassifier: Fix typo in comment.
Ben Pfaff [Thu, 18 Aug 2011 20:02:22 +0000 (13:02 -0700)]
classifier: Fix typo in comment.

13 years agodatapath-protocol: Correct a description in odp_flow_attr structure.
Justin Pettit [Thu, 18 Aug 2011 17:31:15 +0000 (10:31 -0700)]
datapath-protocol: Correct a description in odp_flow_attr structure.

The description referenced "ODPAT_*", but it should be "ODP_ACTION_ATTR_".

Signed-off-by: Justin Pettit <jpettit@nicira.com>
13 years agodatapath: Correct comment for vport_add().
Justin Pettit [Thu, 18 Aug 2011 16:57:23 +0000 (09:57 -0700)]
datapath: Correct comment for vport_add().

The comment describing vport_add() incorrectly stated that the function
added the vport to the datapath.  It is the responsibility of the caller
to do that.

Signed-off-by: Justin Pettit <jpettit@nicira.com>
13 years agoodp-util: Fix parsing of Ethertypes 0x8000 and above.
Ben Pfaff [Thu, 18 Aug 2011 17:33:32 +0000 (10:33 -0700)]
odp-util: Fix parsing of Ethertypes 0x8000 and above.

An existing comment in the function being updated explains the problem:

    * Many of the sscanf calls in this function use oversized destination
    * fields because some sscanf() implementations truncate the range of %i
    * directives, so that e.g. "%"SCNi16 interprets input of "0xfedc" as a
    * value of 0x7fff.  The other alternatives are to allow only a single
    * radix (e.g. decimal or hexadecimal) or to write more sophisticated
    * parsers.

13 years agoINSTALL.Linux: Fix up reference to old option name --with-l26.
Philippe Jung [Wed, 17 Aug 2011 18:34:09 +0000 (11:34 -0700)]
INSTALL.Linux: Fix up reference to old option name --with-l26.

13 years agoofproto: Update 'struct facet''s comments.
Ethan Jackson [Tue, 16 Aug 2011 21:14:33 +0000 (14:14 -0700)]
ofproto: Update 'struct facet''s comments.

Some of the comments in the definition of 'struct facet' had become
out of date.

13 years agoofproto: Remove extra_bytes parameter of facet_account().
Ethan Jackson [Tue, 16 Aug 2011 21:21:12 +0000 (14:21 -0700)]
ofproto: Remove extra_bytes parameter of facet_account().

It no longer has interesting users.

13 years agoofproto: Fix over accounting of byte counters.
Ethan Jackson [Tue, 16 Aug 2011 21:16:58 +0000 (14:16 -0700)]
ofproto: Fix over accounting of byte counters.

The update_stats() function in ofproto was attributing more bytes
to facets than they had actually accrued.  This could potentially
throw off bond load balancing.

Found by inspection.

13 years agoofproto: Clear packet and byte counters on flow additions.
Ethan Jackson [Tue, 16 Aug 2011 20:50:00 +0000 (13:50 -0700)]
ofproto: Clear packet and byte counters on flow additions.

When a flow is added to the flow table, its packet and byte
counters should be reset.  This patch efficiently approximates this
behavior.  It also does some minor code refactoring.

Bug #3183.

13 years agovswitch.xml: Remove unused "hwaddr" other-config key.
Justin Pettit [Mon, 15 Aug 2011 20:51:09 +0000 (13:51 -0700)]
vswitch.xml: Remove unused "hwaddr" other-config key.

13 years agoofp-print: Add missing "break".
Ben Pfaff [Mon, 15 Aug 2011 22:18:12 +0000 (15:18 -0700)]
ofp-print: Add missing "break".

This is not a bug yet, but it could be the next time someone carelessly
adds a new case.

13 years agoovs-ofctl: Fix a few formatting typos in manpage.
Ben Pfaff [Mon, 15 Aug 2011 20:17:58 +0000 (13:17 -0700)]
ovs-ofctl: Fix a few formatting typos in manpage.

13 years agoconnmgr: Remove unused function ofconn_n_pending_opgroups().
Ben Pfaff [Wed, 10 Aug 2011 19:46:36 +0000 (12:46 -0700)]
connmgr: Remove unused function ofconn_n_pending_opgroups().

13 years agopoll-loop: Remove static variable n_waiters.
Ben Pfaff [Wed, 10 Aug 2011 19:49:35 +0000 (12:49 -0700)]
poll-loop: Remove static variable n_waiters.

It's always a little risky to track the length of a list by hand, because
it is easy to miss a spot where the length can change.  So it seems like
a small cleanup to just measure the length of the 'waiters' list at the
point where we need to know it.  list_size() is O(n) in the length of the
list, but the function that calls it is already O(n) in that length so it
seems like a fair trade-off.

13 years agodpif-netdev: Avoid pointlessly maintaining a port count.
Ben Pfaff [Wed, 10 Aug 2011 19:40:10 +0000 (12:40 -0700)]
dpif-netdev: Avoid pointlessly maintaining a port count.

'n_ports' was only used for testing for nonzero, and we can rewrite the
code that does that to more straightforwardly use LIST_FOR_EACH_SAFE.

13 years agoofproto-dpif: Print register values in trace.
Ethan Jackson [Fri, 12 Aug 2011 21:10:15 +0000 (14:10 -0700)]
ofproto-dpif: Print register values in trace.

I found this patch useful in tracking down a bug recently.

13 years agonicra-ext: New action NXAST_OUTPUT_REG.
Ethan Jackson [Wed, 10 Aug 2011 20:05:17 +0000 (13:05 -0700)]
nicra-ext: New action NXAST_OUTPUT_REG.

The NXAST_OUTPUT_REG action outputs to the OpenFlow port contained
in a supplied NXM field.

13 years agonx-match: New function nxm_read_field_bits().
Ethan Jackson [Wed, 10 Aug 2011 20:32:51 +0000 (13:32 -0700)]
nx-match: New function nxm_read_field_bits().

nxm_read_field_bits() simplifies reading of NXM fields with an
ofs_nbits parameter.  This patch updates nxm_execute_reg_move() to
use the new function.  A user outside of the nx-match module will
be added in future patches.

13 years agonx-match: Update register check functions.
Ethan Jackson [Wed, 10 Aug 2011 20:09:18 +0000 (13:09 -0700)]
nx-match: Update register check functions.

This patch simplifies the API of nxm_dst_check() and adds a new
function nxm_src_check() for checking source fields.

13 years agotests: test "load" and "move" actions.
Ethan Jackson [Fri, 12 Aug 2011 02:07:35 +0000 (19:07 -0700)]
tests: test "load" and "move" actions.

13 years agonx-match: Fix bug in "move" action.
Ethan Jackson [Fri, 12 Aug 2011 18:15:53 +0000 (11:15 -0700)]
nx-match: Fix bug in "move" action.

This patch fixes a bug introduced in Commit 43edca57 "nx-match: New
helpers.", which caused the "move" action to improperly handle bit
ranges.

13 years agoflow: New FLOW_WC_SEQ build assertion.
Ethan Jackson [Fri, 29 Jul 2011 20:15:09 +0000 (13:15 -0700)]
flow: New FLOW_WC_SEQ build assertion.

Changing "struct flow" or its wildcards requires minor adjustments
in many places in the code.  This patch adds a new FLOW_WC_SEQ
sequence number which when incremented will cause build assertion
failures aiding the developer in finding code which needs to
change.

13 years agotests: Update gitignore.
Ethan Jackson [Wed, 10 Aug 2011 21:48:48 +0000 (14:48 -0700)]
tests: Update gitignore.

13 years agolib: Whitespace cleanup.
Ethan Jackson [Thu, 4 Aug 2011 23:50:25 +0000 (16:50 -0700)]
lib: Whitespace cleanup.

13 years agoofp-parse: Fix parsing of register values 2**31 and greater.
Ben Pfaff [Fri, 12 Aug 2011 21:59:11 +0000 (14:59 -0700)]
ofp-parse: Fix parsing of register values 2**31 and greater.

Reported-by: Ethan Jackson <ethan@nicira.com>
13 years agoovs-ofctl: Document that all actions are supported now.
Ben Pfaff [Wed, 10 Aug 2011 23:50:41 +0000 (16:50 -0700)]
ovs-ofctl: Document that all actions are supported now.

This comment must be very old.  ovs-ofctl has supported all the OpenFlow
and Nicira extensions actions for a long time now.

13 years agodebian: Avoid installing duplicate files in ovsdbmonitor package.
Ben Pfaff [Wed, 10 Aug 2011 16:13:12 +0000 (09:13 -0700)]
debian: Avoid installing duplicate files in ovsdbmonitor package.

This is just a typo introduced in commit 57483aeda (debian: Fix bug from
commit 211b05b5 "debian: Modernize use of dh_install.) that caused the
ovsdbmonitor package to install too many files.

Bug-report: http://bugs.debian.org/636815
Reported-by: Ralf Treinen <treinen@free.fr>
13 years agoofp-util: Rename struct flow_stats_request with ofputil_ prefix.
Ben Pfaff [Mon, 8 Aug 2011 21:48:48 +0000 (14:48 -0700)]
ofp-util: Rename struct flow_stats_request with ofputil_ prefix.

Most of the structs in ofp-util.h have the ofputil_ prefix.  Rename this
one for consistency.

13 years agoofp-util: Rename struct flow_mod to struct ofputil_flow_mod.
Ben Pfaff [Mon, 8 Aug 2011 21:46:38 +0000 (14:46 -0700)]
ofp-util: Rename struct flow_mod to struct ofputil_flow_mod.

Most of the structs in ofp-util.h have the ofputil_ prefix.  Rename this
one for consistency.

13 years agonicira-ext: Fix NXM example.
Ben Pfaff [Tue, 9 Aug 2011 20:46:51 +0000 (13:46 -0700)]
nicira-ext: Fix NXM example.

The code and the specification say that nxm_length includes both value
and mask, but this example showed nxm_length only including the value.
This commit fixes it.

Reported-by: Justin Pettit <jpettit@nicira.com>
13 years agoovs-ofctl: Fix reading flows from file for "replace-flows", "diff-flows".
Ben Pfaff [Tue, 9 Aug 2011 19:55:13 +0000 (12:55 -0700)]
ovs-ofctl: Fix reading flows from file for "replace-flows", "diff-flows".

Commit c821124b25e "ovs-ofctl: Accept only valid flow_mod and
flow_stats_request fields" caused actions read by read_flows_from_file()
to be ignored and treated as "drop".  This fixes the problem.

13 years agoOption to forward BPDU (Ethernet control class) frames
Sanjay Sane [Tue, 9 Aug 2011 18:08:27 +0000 (11:08 -0700)]
Option to forward BPDU (Ethernet control class) frames

Currently, a NORMAL action bridge drops reserved-multicast-mac addresses;
01-80-c2-00-00-[f0:ff]. A node that does not implement STP should have an
option to forward such frames.

This commit proposes to have a configuration option to allow forwarding of
BPDU class frames.  To ensure backward compatibility, this option is
disabled by default.

This config can be set using bridge's other-config column, for e.g
ovs-vsctl set bridge br0 other-config:forward-bpdu=true

Changing this option can revalidate all flows in a software-OVS
implementation (ofproto-dpif)

--------
unit tests:

------------
make config changes, test runtime behavior

-- test runtime behavior --
continuously send packets to br0 with dest-mac=01:80:c2:00:00:00

ovs-dpctl dump-flows br0
ovs-vsctl set bridge br0 other-config:forward-bpdu=true
ovs-dpctl dump-flows br0
ovs-vsctl set bridge br0 other-config:forward-bpdu=false
ovs-dpctl dump-flows br0
ovs-vsctl set bridge br0 other-config:forward-bpdu=true
ovs-dpctl dump-flows br0
ovs-vsctl remove bridge br0 other-config forward-bpdu=true
ovs-dpctl dump-flows br0

--result--
 ovs-dpctl dump-flows br0
 in_port(1),eth(src=00:0c:29:d1:39:42,dst=01:80:c2:00:00:00), packets:29550, bytes:1773000, used:0.004s, actions:drop
 ovs-vsctl set bridge br0 other-config:forward-bpdu=true

 ovs-dpctl dump-flows br0
in_port(1),eth(src=00:0c:29:d1:39:42,dst=01:80:c2:00:00:00), packets:8209, bytes:492540, used:0.000s, actions:2,0

 ovs-vsctl set bridge br0 other-config:forward-bpdu=false
 ovs-dpctl dump-flows br0
in_port(1),eth(src=00:0c:29:d1:39:42,dst=01:80:c2:00:00:00), packets:19, bytes:1140, used:0.000s, actions:drop

 ovs-vsctl set bridge br0 other-config:forward-bpdu=true
 ovs-dpctl dump-flows br0
in_port(1),eth(src=00:0c:29:d1:39:42,dst=01:80:c2:00:00:00), packets:29, bytes:1740, used:0.000s, actions:2,0

 ovs-vsctl remove bridge br0 other-config forward-bpdu=true
 ovs-dpctl dump-flows br0
in_port(1),eth(src=00:0c:29:d1:39:42,dst=01:80:c2:00:00:00), packets:0, bytes:0, used:never, actions:drop

Bug #6624
Reported-by: Niklas Andersson <nandersson@nicira.com>
13 years agoNew action NXAST_RESUBMIT_TABLE.
Ben Pfaff [Tue, 9 Aug 2011 16:24:18 +0000 (09:24 -0700)]
New action NXAST_RESUBMIT_TABLE.

This makes multiple table support in ofproto-dpif useful, by allowing
resubmits into tables other than 0.

13 years agoofproto-dpif: Add multiple table support.
Ben Pfaff [Thu, 28 Jul 2011 22:25:48 +0000 (15:25 -0700)]
ofproto-dpif: Add multiple table support.

Tables other than 0 can be modified and dumped, but they are not yet useful
because actions and flow table lookups never use them.

13 years agoofproto: New helper macro OFPROTO_FOR_EACH_TABLE.
Ben Pfaff [Thu, 28 Jul 2011 22:02:06 +0000 (15:02 -0700)]
ofproto: New helper macro OFPROTO_FOR_EACH_TABLE.

In my opinion this makes the code slightly easier to read and write.

13 years agoofproto: Allow ->rule_choose_table() to be NULL regardless of table count.
Ben Pfaff [Thu, 28 Jul 2011 22:01:20 +0000 (15:01 -0700)]
ofproto: Allow ->rule_choose_table() to be NULL regardless of table count.

In the upcoming software switch implementation of multiple tables, there is
no reason to prefer one table over another, so we always put rules into
table 0 by default.  This commit allows this to be done simply by
specifying NULL as ->rule_choose_table().

13 years agoofproto: Make ->construct() and ->destruct() more symmetrical.
Ben Pfaff [Thu, 28 Jul 2011 21:19:52 +0000 (14:19 -0700)]
ofproto: Make ->construct() and ->destruct() more symmetrical.

The ofproto_provider's ->construct() was required to allocate and
initialize the flow tables, but ->destruct() was not allowed to
uninitialize and free them.  This arrangement is oddly asymmetrical (and
undocumented), so this commit changes the code so that the client is
responsible for both allocation and freeing.

Reported-by: Hao Zheng <hzheng@nicira.com>
CC: Hao Zheng <hzheng@nicira.com>
13 years agoofproto-dpif: Fix pointer arithmetic on null pointer.
Ben Pfaff [Mon, 8 Aug 2011 23:01:05 +0000 (16:01 -0700)]
ofproto-dpif: Fix pointer arithmetic on null pointer.

rule_dpif_lookup() can return a null pointer as 'rule' so we shouldn't
try to calculate '&rule->up' before it's been found to be nonnull.

This doesn't appear to fix a real bug because 'up' is the first member
of 'rule' so when rule is NULL then &rule->up is also NULL.

Reported-by: Ethan Jackson <ethan@nicira.com>
13 years agoofproto-dpif: Make ofproto/trace accept an odp_flow in place of a packet.
Ben Pfaff [Mon, 8 Aug 2011 22:43:29 +0000 (15:43 -0700)]
ofproto-dpif: Make ofproto/trace accept an odp_flow in place of a packet.

It's often easier to get a flow than it is to get a packet.  For example,
"ovs-dpctl dump-flows" prints flows, but it doesn't print any of the
packets in those flows.  It is also easier to construct a flow by hand than
it is to construct packet bytes.

This commit, therefore, makes ofproto/trace accept a flow specification in
place of packet data.  In a few cases a flow by itself is not sufficient
to determine what would happen to a packet, so in those cases the command
prints a message to that effect.

An upcoming commit will also start using this feature to unit-test action
translation in ofproto-dpif.

Suggested-by: Reid Price <reid@nicira.com>
13 years agoodp-util: New function odp_flow_key_from_string().
Ben Pfaff [Thu, 4 Aug 2011 23:20:34 +0000 (16:20 -0700)]
odp-util: New function odp_flow_key_from_string().

This will be used in upcoming commits.

13 years agoodp-util: Format VLAN headers more like other headers in ODP flow output.
Ben Pfaff [Thu, 4 Aug 2011 20:32:19 +0000 (13:32 -0700)]
odp-util: Format VLAN headers more like other headers in ODP flow output.

The rest of the headers all follow the form "header(value)" or
"header(key1=value1,key2=value2,...)" but VLAN headers left out the "="
characters.  This adds them in for consistency.

13 years agonetdev: Get rid of struct netdev_options and netdev_open_default().
Ben Pfaff [Fri, 5 Aug 2011 21:18:06 +0000 (14:18 -0700)]
netdev: Get rid of struct netdev_options and netdev_open_default().

Now that netdev_options only has two members, we might as well pass them
directly as parameters.

13 years agonetdev: Decouple creating and configuring network devices.
Ben Pfaff [Mon, 8 Aug 2011 19:49:17 +0000 (12:49 -0700)]
netdev: Decouple creating and configuring network devices.

Until now, each call to netdev_open() for a particular network device
had to either specify a set of network device arguments that was either
empty or (for devices that already existed) equal to the existing device's
configuration.  Unfortunately, the definition of "equality" in the latter
case was mostly done in terms of strict equality of string-to-string maps,
which caused problems in cases where, for example, one set of arguments
specified the default value of an optional argument explicitly and the
other omitted it.

The netdev interface does have provisions for defining equality other ways,
but this had only been done in one case that was especially problematic in
practice.  One way to solve this particular problem would be to carefully
define equality in all the problematic cases.

This commit takes another approach based on the realization that there is
really no need to do any comparisons.  Instead, it removes configuration
at netdev_open() time entirely, because almost all of netdev_open()'s
callers are not interested in creating and configuring a netdev.  Most of
them just want to open a configured device and use it.  Therefore, this
commit stops providing any configuration arguments to netdev_open() and the
provider functions that it calls.  Instead, a caller that does want to
configure a device does so after it opens it, by calling
netdev_set_config().

This change allows us to simplify the netdev interface a bit.  There is no
longer any need to implement argument comparisons.  As a result, there is
also no need for "struct netdev_dev" to keep track of configuration at all.
Instead, the network devices that have configuration keep track of it in
their own internal form.

This new interface does mean that it becomes possible to accidentally
create and try to use an unconfigured netdev that requires configuration.

Bug #6677.
Reported-by: Paul Ingram <paul@nicira.com>
13 years agodebian: Ensure that /var/run/openvswitch exists in controller init script.
Ben Pfaff [Mon, 8 Aug 2011 17:58:38 +0000 (10:58 -0700)]
debian: Ensure that /var/run/openvswitch exists in controller init script.

It would be better to use ovs-ctl from this script, but until now this is
an adequate solution.

Reported-by: Jibesh Patra
Bug-report: https://bugs.launchpad.net/bugs/822142

13 years agonetdev: Clean up and refactor packet receive interface.
Ben Pfaff [Fri, 5 Aug 2011 21:15:32 +0000 (14:15 -0700)]
netdev: Clean up and refactor packet receive interface.

The Open vSwitch tree only has one user of the ability for a netdev to
receive packets from a network device.  Thus, this commit simplifies the
common-case use of the netdev interface by replacing the "ethertype" option
from "struct netdev_options" by a new netdev_listen() call.

The only user of netdev_listen() wants to receive all packets from a
network device, so this commit also removes the ability to restrict the
received packets to a particular protocol.  (This ability was once used by
the Open vSwitch integrated DHCP client, but that code has been removed.)

This commit also simplifies and improves the implementation of the code
in netdev-linux that started listening to a network device.  Before, I had
not figured out how to avoid receiving all packets on all devices before
binding to a particular device, but I took a closer look at the kernel code
and figured it out.

I've tested that the userspace datapath (dpif-netdev), the only user of
netdev_recv(), still works after this change.

13 years agobridge: Add port to datapath before trying to retrieve device stats.
Ben Pfaff [Fri, 5 Aug 2011 21:14:18 +0000 (14:14 -0700)]
bridge: Add port to datapath before trying to retrieve device stats.

Virtual ports such as GRE tunnels don't exist until after the port is
added to the datapath, so without this change adding such a port yields
a warning like the following:

netdev|WARN|failed to retrieve MTU for network device gre0: No such device

13 years agoovsdb: Correct specification inconsistency between "lock" and "assert".
Ben Pfaff [Fri, 5 Aug 2011 22:56:05 +0000 (15:56 -0700)]
ovsdb: Correct specification inconsistency between "lock" and "assert".

The "lock" request requires the lock name to be an <id> but it is shown as
<string> in the "assert" operation.  This corrects the "assert"
specification and fixes the suggested naming convention (since ":" is not
valid in an <id>).

This commit also updates the implementation to match the specification.

Reported-by: Jeremy Stribling <strib@nicira.com>