ovs-save: Add a helper command to maintain ofport value.

This patch adds a helper command: save-ofports. The command
will o/p a shell script that will set the 'ofport_request' column
of the interface table with the value of the corresponding ofport.

This command takes a list of bridges as input and will be used by
a future commit to restore the ofport value across force-reload-kmod.

This command is only useful while trying to upgrade from a pre-1.10
branch to 1.10 or a later branch.

Issue #13556
Signed-off-by: Gurucharan Shetty <gshetty@nicira.com>
ovs-ctl.in: Restore ofport values across force-reload-kmod.

If we want to upgrade from pre-1.10 branch to 1.10 or later
and restore flows across force-reload-kmod, we need to maintain
the value of ofport.

To do this, we fetch the value of ofport before the upgrade and use
it to populate the column 'ofport_request' after ovsdb is upgraded.
We need to do this before vswitchd is restarted as vswitchd
needs the ofport_request column populated before it starts.

Issue #13556
Signed-off-by: Gurucharan Shetty <gshetty@nicira.com>
util: Introduce ovs_assert macro.

An occasionally significant problem with the standard "assert" macro is
that it writes the failure message to stderr.  In our daemons, stderr is
generally redirected to /dev/null.  It's more useful to write the failure
message to the log, which is what the new ovs_assert macro introduced in
this patch does.

Signed-off-by: Ben Pfaff <blp@nicira.com>
Acked-by: Ethan Jackson <ethan@nicira.com>
Replace most uses of assert by ovs_assert.

This is a straight search-and-replace, except that I also removed #include
<assert.h> from each file where there were no assert calls left.

Signed-off-by: Ben Pfaff <blp@nicira.com>
Acked-by: Ethan Jackson <ethan@nicira.com>
Remove useless use of <assert.h>.

These files #included <assert.h> but didn't ever use assert.

Signed-off-by: Ben Pfaff <blp@nicira.com>
Acked-by: Ethan Jackson <ethan@nicira.com>
Makefile.am: add check that <assert.h> is not used from unexpected files.

In general, with a few specific exceptions, ovs_assert is now preferred
over assert, so this commit adds a check for that in the top-level
Makefile.

Signed-off-by: Ben Pfaff <blp@nicira.com>
Acked-by: Ethan Jackson <ethan@nicira.com>
dpif-linux: Fix segfault when a port already exists.

Commit 78a2d59c (dpif-linux.c: Let the kernel pick a port number if one
not requested.) changed the logic for port assignment, but didn't
properly handle some error conditions.  An attempt to add a tunnel port
that already exists would lead to a segfault.  This commit fixes the
logic to stop processing and return an error.

Reported-by: Gurucharan Shetty <shettyg@nicira.com>
Signed-off-by: Justin Pettit <jpettit@nicira.com>
NEWS: Mention that bridge compatibility is gone.

Signed-off-by: Ben Pfaff <blp@nicira.com>
dpif-netdev: Limit scope of vlan in dp_netdev_execute_actions

This is to make the code consistent with the proposed MPLS changes
and avoid cluttering the top of the NL_ATTR_FOR_EACH_UNSAFE loop.

Signed-off-by: Simon Horman <horms@verge.net.au>
Signed-off-by: Ben Pfaff <blp@nicira.com>
ofproto: Add "actions=" to drop action in "ovs-appctl bridge/dump-flows".

The function flow_stats_ds() did its own formatting when there were no
actions, but this didn't include "action=".  There's actually no reason
to special-case this, since ofpact_format() properly handles actions
with a zero length and prints it properly.

Signed-off-by: Justin Pettit <jpettit@nicira.com>
debian: Change openvswitch restart logic for kernel package.

Currently, every time we install the non-dkms openvswitch kernel package,
we restart openvswitch. This has no useful effect when an Open vSwitch kernel
module is already loaded, because "/etc/init.d/openvswitch restart" does not
load the new version of the kernel module.

With this patch, we start openvswitch if there is no kernel module
currently loaded (which is a case for a fresh install of openvswitch). This
will load the kernel module.

If someone wants to use the latest kernel module after an upgrade, they need
to run "/etc/init.d/openvswitch-switch force-reload-kmod" manually.

Issue #13556
Signed-off-by: Gurucharan Shetty <gshetty@nicira.com>