cascardo/ovs.git
8 years agoovs-bugtool: Add conntrack output.
William Tu [Wed, 13 Jan 2016 23:51:44 +0000 (15:51 -0800)]
ovs-bugtool: Add conntrack output.

Add a script to show all the connection entries in the tracker.

Signed-off-by: William Tu <u9012063@gmail.com>
Acked-by: Gurucharan Shetty <guru@ovn.org>
8 years agoMerge branch 'master' of ssh://github.com/openvswitch/ovs into master_new
Gurucharan Shetty [Thu, 14 Jan 2016 17:03:06 +0000 (09:03 -0800)]
Merge branch 'master' of ssh://github.com/openvswitch/ovs into master_new

8 years ago{lib, utilities}: Fix ct_state constants in docs.
Joe Stringer [Wed, 13 Jan 2016 18:59:03 +0000 (10:59 -0800)]
{lib, utilities}: Fix ct_state constants in docs.

These pieces of documentation were not updated when the CS_* flags were
reordered on the OpenFlow interface.

Fixes: 63bc9fb1c69f ("packets: Reorder CS_* flags to remove gap.")
Signed-off-by: Joe Stringer <joe@ovn.org>
Acked-by: Russell Bryant <russell@ovn.org>
8 years agolib: remove unused function
Andy Zhou [Tue, 12 Jan 2016 19:42:30 +0000 (11:42 -0800)]
lib: remove unused function

Remove unused implementation of ovsdb_idl_row_apply_diff().

Reported-by: Ben Pfaff <blp@ovn.org>
Signed-off-by: Andy Zhou <azhou@ovn.org>
Acked-by: Ben Pfaff <blp@ovn.org>
8 years agonetdev-dpdk: Fix thread_is_pmd() symbol conflict.
Joe Stringer [Tue, 12 Jan 2016 19:32:41 +0000 (11:32 -0800)]
netdev-dpdk: Fix thread_is_pmd() symbol conflict.

DPDK build was broken after commit 2f8932e8403a ("poll: Suppress logging
for pmd threads.") due to the following error:

lib/netdev-dpdk.c:245:13: error: static declaration of ‘thread_is_pmd’
follows non-static declaration
lib/ovs-thread.h:526:6: note: previous declaration of ‘thread_is_pmd’
was here

The version used in this file operates in the fastpath, so it cannot
switch to using the newly introduced version; the new version lives
outside of the dpdk portions of OVS so its implementation cannot be
shared with this function. Rename it to resolve the conflict.

Fixes: 2f8932e8403a ("poll: Suppress logging for pmd threads.")
Suggested-by: Flavio Leitner <fbl@sysclose.org>
Signed-off-by: Joe Stringer <joe@ovn.org>
Acked-by: Flavio Leitner <fbl@sysclose.org>
8 years agodatapath: Fix deadlock on STT device destroy.
Pravin B Shelar [Tue, 12 Jan 2016 19:45:18 +0000 (11:45 -0800)]
datapath: Fix deadlock on STT device destroy.

STT unregisters nf-hook when there are no other STT devices
left in the namespace. On some kernel versions the nf-unreg API
take RTNL lock, but it is already taken in the tunnel device
destroy code path which results in deadlock. To fix the issue
I moved the unreg call into net-exit.

VMware-BZ: #1582410
Reported-by: Joe Stringer <joe@ovn.org>
Signed-off-by: Pravin B Shelar <pshelar@nicira.com>
Acked-by: Joe Stringer <joe@ovn.org>
8 years agoovsdb-idl: Add support for column tracking in IDL.
Shad Ansari [Thu, 10 Dec 2015 09:12:31 +0000 (01:12 -0800)]
ovsdb-idl: Add support for column tracking in IDL.

Recent IDL change tracking patches allow quick traversal of changed
rows. This patch adds additional support to track changed columns.
It allows an IDL client to efficiently check if a specific column
of a row was updated by IDL.

Signed-off-by: Shad Ansari <shad.ansar@hpe.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
8 years agoovs-ofctl.8.in: Fix indentation.
Joe Stringer [Tue, 12 Jan 2016 00:43:52 +0000 (16:43 -0800)]
ovs-ofctl.8.in: Fix indentation.

This extraneous .RE caused the indentation for the subsequent actions to
drop back an extra step, fix it.

Fixes: 8e53fe8cf7a1 ("Add connection tracking mark support.")
Signed-off-by: Joe Stringer <joe@ovn.org>
Acked-by: Ben Pfaff <blp@ovn.org>
8 years agoxml2nroff: Fix build breakage when srcdir differs from builddir.
Ben Pfaff [Tue, 12 Jan 2016 18:37:48 +0000 (10:37 -0800)]
xml2nroff: Fix build breakage when srcdir differs from builddir.

When the source directory and build directory differ, xml2nroff needs
to pull include files from the source directory, but it was blindly
using the current working directory (the build directory) instead.

Signed-off-by: Ben Pfaff <blp@ovn.org>
Fixes: 7ba0c32f610 ("ovn-nbctl: add db commands help and manpage")
Tested-by: Joe Stringer <joe@ovn.org>
Acked-by: Joe Stringer <joe@ovn.org>
8 years agonetdev-dpdk: Consistently use xstrdup() instead of strdup().
Ben Pfaff [Mon, 11 Jan 2016 23:04:08 +0000 (15:04 -0800)]
netdev-dpdk: Consistently use xstrdup() instead of strdup().

This avoids a segmentation fault in case of memory allocation failure.

Found by inspection.

Signed-off-by: Ben Pfaff <blp@ovn.org>
Acked-by: Aaron Conole <aconole@redhat.com>
8 years agopython: Fix print function compatibility.
Russell Bryant [Mon, 14 Dec 2015 15:21:53 +0000 (10:21 -0500)]
python: Fix print function compatibility.

The print statement from Python 2 is a function in Python 3.  Enable
print function support for Python 2 and convert print statements to
function calls.

Enable the H233 flake8 warning.  If the hacking plugin is installed,
this will generate warnings for print statement usage not compatible
with Python 3.

  H233 Python 3.x incompatible use of print operator

Signed-off-by: Russell Bryant <russell@ovn.org>
Acked-by: Ben Pfaff <blp@ovn.org>
8 years agopython: Fix exception handler compatibility.
Russell Bryant [Wed, 6 Jan 2016 18:48:16 +0000 (13:48 -0500)]
python: Fix exception handler compatibility.

Python 3 dropped exception handlers of the deprecated form:

  except Exception, e:

You must use the newer syntax of:

  except Exception as e:

This patch also enables a flake8 warning for this.

  H231 Python 3.x incompatible 'except x,y:' construct

Signed-off-by: Russell Bryant <russell@ovn.org>
Acked-by: Ben Pfaff <blp@ovn.org>
8 years agopython: Stop use of tuple parameter unpacking
Russell Bryant [Mon, 14 Dec 2015 19:22:21 +0000 (14:22 -0500)]
python: Stop use of tuple parameter unpacking

Python 3 removed support for tuple parameter unpacking.

https://www.python.org/dev/peps/pep-3113/

Instead of:

    def foo((a, b)):
        print(a)
        print(b)

you should do:

    def foo(a_b):
        a, b = a_b
        print(a)
        print(b)

but in both uses here, the values were never used so the fix is even
simpler.

Signed-off-by: Russell Bryant <russell@ovn.org>
Acked-by: Ben Pfaff <blp@ovn.org>
8 years agopython: Start fixing some Python 3 issues.
Terry Wilson [Thu, 30 Jul 2015 02:12:45 +0000 (21:12 -0500)]
python: Start fixing some Python 3 issues.

This patch fixes just the Python 3 problems found by running:

  python3 setup.py install

There are still many other issues to be fixed, but this is a start.

Signed-off-by: Terry Wilson <twilson@redhat.com>
[russell@ovn.org resolved conflicts with current master]
Signed-off-by: Russell Bryant <russell@ovn.org>
Acked-by: Ben Pfaff <blp@ovn.org>
8 years agoacinclude.m4: Fix dpdk build if -mssse3 not supported.
Ilya Maximets [Tue, 12 Jan 2016 11:15:39 +0000 (14:15 +0300)]
acinclude.m4: Fix dpdk build if -mssse3 not supported.

On arm/arm64:
gcc: error: unrecognized command line option '-mssse3'

Signed-off-by: Ilya Maximets <i.maximets@samsung.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
8 years agoovn-nbctl: add db commands help and manpage
Wei Li [Tue, 12 Jan 2016 01:35:06 +0000 (09:35 +0800)]
ovn-nbctl: add db commands help and manpage

db-ctl-base: add xml format db help
xml2nroff: support xinclude

Submitted-at: https://github.com/openvswitch/ovs/pull/93
Signed-off-by: l0310 <liw@dtdream.com>
[russell@ovn.org updated lib/automake.mk]
Signed-off-by: Russell Bryant <russell@ovn.org>
8 years agoflow: fix compilation of MINIFLOW_ASSERT
Simon Horman [Mon, 11 Jan 2016 05:00:25 +0000 (14:00 +0900)]
flow: fix compilation of MINIFLOW_ASSERT

Often MINIFLOW_ASSERT is a no-op and compilation of code that uses
it is optimised out. This patch fixes compilation errors that occur
when that is not the case:

* FLOWMAP_MAX does not exist. Use MAP_MAP instead.
* FLOWMAP_IS_SET does not exist. Use flowmap_is_set instead.

Signed-off-by: Simon Horman <simon.horman@netronome.com>
Acked-by: Jarno Rajahalme <jarno@ovn.org>
8 years agodp-packet: Remove unused helper dp_packet_to_string().
Simon Horman [Mon, 11 Jan 2016 05:00:39 +0000 (14:00 +0900)]
dp-packet: Remove unused helper dp_packet_to_string().

dp_packet_to_string() does not appear to be used.

Signed-off-by: Simon Horman <simon.horman@netronome.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
8 years agoofp-parse: Use xstrdup() instead of strdup().
Ben Pfaff [Mon, 11 Jan 2016 17:21:58 +0000 (09:21 -0800)]
ofp-parse: Use xstrdup() instead of strdup().

This avoids a null pointer dereference in the case of memory allocation
failure.

Found by inspection.

Signed-off-by: Ben Pfaff <blp@ovn.org>
Acked-by: Russell Bryant <russell@ovn.org>
8 years agoofproto-dpif-upcall: Document revalidator cycle.
Joe Stringer [Fri, 8 Jan 2016 00:16:25 +0000 (16:16 -0800)]
ofproto-dpif-upcall: Document revalidator cycle.

Add a series of comments to make it more clear what's happening for
individual ukeys being handled during revalidator dump/sweep cycle.

Signed-off-by: Joe Stringer <joe@ovn.org>
Acked-by: Jarno Rajahalme <jarno@ovn.org>
8 years agopoll: Suppress logging for pmd threads.
Ilya Maximets [Tue, 22 Dec 2015 14:26:47 +0000 (17:26 +0300)]
poll: Suppress logging for pmd threads.

'Unreasonably long poll interval's are reasonable for PMD threads.
Also reporting of high CPU usage is not necessary.

Signed-off-by: Ilya Maximets <i.maximets@samsung.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
8 years agoovn-northd: Only add ARP reply flows for logical ports that are up.
Numan Siddique [Mon, 21 Dec 2015 14:27:16 +0000 (19:57 +0530)]
ovn-northd: Only add ARP reply flows for logical ports that are up.

Or if the logical port is a router port.

Signed-off-by: Numan Siddique <nusiddiq@redhat.com>
[blp@ovn.org updated ovn-northd(8)]
Signed-off-by: Ben Pfaff <blp@ovn.org>
8 years agodatapath-windows: Add LSOv2 support for VXLAN
Alin Serdean [Fri, 11 Dec 2015 22:29:38 +0000 (22:29 +0000)]
datapath-windows: Add LSOv2 support for VXLAN

This patch adds LSO version 2 support for the windows datapath.
(https://msdn.microsoft.com/en-us/library/windows/hardware/ff568840%28v=vs.85%29.aspx)

Tested using psping and iperf3.

Signed-off-by: Alin Gabriel Serdean <aserdean@cloudbasesolutions.com>
Acked-by: Sairam Venugopal <vsairam@vmware.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
8 years agodatapath-windows: Fix bug small bug in GRE.
Alin Serdean [Fri, 11 Dec 2015 22:24:49 +0000 (22:24 +0000)]
datapath-windows: Fix bug small bug in GRE.

Allow GRE encapsulation to take place in the case we have a TCP payload
without LSO.

Signed-off-by: Alin Gabriel Serdean <aserdean@cloudbasesolutions.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
8 years agoofproto: Fix memory leak reported by valgrind.
William Tu [Tue, 5 Jan 2016 21:38:43 +0000 (13:38 -0800)]
ofproto: Fix memory leak reported by valgrind.

Test case 757: ofproto - table description (OpenFlow 1.4)
Call stacks:
    parse_ofp_table_vacancy (ofp-parse.c:896)
    parse_ofp_table_mod (ofp-parse.c:978)
    ofctl_mod_table (ovs-ofctl.c:2011)
    ovs_cmdl_run_command (command-line.c:121)
    main (ovs-ofctl.c:135)
Reason: return without freeing memory

Signed-off-by: William Tu <u9012063@gmail.com>
Signed-off-by: Daniele Di Proietto <diproiettod@vmware.com>
Co-authored-by: Daniele Di Proietto <diproiettod@vmware.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
8 years agorstp: Fix memory leak reported by valgrind.
William Tu [Tue, 5 Jan 2016 21:38:42 +0000 (13:38 -0800)]
rstp: Fix memory leak reported by valgrind.

test case: 1650 RSTP Single bridge, call stacks
    hmap_insert_at (hmap.h:235)
    rstp_port_set_port_number__ (rstp.c:744)
    rstp_add_port (rstp.c:1164)
    new_bridge (test-rstp.c:123)
    test_rstp_main (test-rstp.c:514)
    ovstest_wrapper_test_rstp_main__ (test-rstp.c:714)
    ovs_cmdl_run_command (command-line.c:121)
    main (ovstest.c:132)
fix it by adding hmap_destroy() at rstp_unref()

Signed-off-by: William Tu <u9012063@gmail.com>
Signed-off-by: Daniele Di Proietto <diproiettod@vmware.com>
Co-authored-by: Daniele Di Proietto <diproiettod@vmware.com>
Acked-by: Daniele Venturino <daniele.venturino@m3s.it>
Signed-off-by: Ben Pfaff <blp@ovn.org>
8 years agoovs-ofctl: Fix memory leak reported by valgrind.
William Tu [Tue, 5 Jan 2016 21:38:41 +0000 (13:38 -0800)]
ovs-ofctl: Fix memory leak reported by valgrind.

Reported by 348: ovs-ofctl parse-flows (skb_priority)
Reason: return without freeing memory

Signed-off-by: William Tu <u9012063@gmail.com>
Signed-off-by: Daniele Di Proietto <diproiettod@vmware.com>
Co-authored-by: Daniele Di Proietto <diproiettod@vmware.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
8 years agostream-ssl: Fix memory leak reported by valgrind.
William Tu [Thu, 7 Jan 2016 23:59:34 +0000 (15:59 -0800)]
stream-ssl: Fix memory leak reported by valgrind.

test case 1628: peer ca cert
    ASN1_item_dup
    do_ca_cert_bootstrap (stream-ssl.c:413)
    ssl_connect (stream-ssl.c:468)
    scs_connecting (stream.c:297)
    stream_connect (stream.c:320)
Fix by removing the X509_dup().

Signed-off-by: William Tu <u9012063@gmail.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
8 years agoovsdb-client: Fix memory leak reported by valgrind.
William Tu [Thu, 7 Jan 2016 23:53:09 +0000 (15:53 -0800)]
ovsdb-client: Fix memory leak reported by valgrind.

testc ase 1427: ovsdb-server combines updates on backlogged connections.
valgrind reports two leaks:
    unixctl_server_create (unixctl.c:250)
    do_monitor__ (ovsdb-client.c:918)
and
    json_create (json.c:1406)
    json_integer_create (json.c:262)
    json_clone (json.c:413)
    do_monitor__ (ovsdb-client.c:958)

Signed-off-by: William Tu <u9012063@gmail.com>
Acked-by: Andy Zhou <azhou@ovn.org>
Signed-off-by: Ben Pfaff <blp@ovn.org>
8 years agoovsdb-client: Fix memory leak reported by valgrind.
William Tu [Thu, 7 Jan 2016 23:53:08 +0000 (15:53 -0800)]
ovsdb-client: Fix memory leak reported by valgrind.

test case 1427: ovsdb-server combines updates on backlogged connections.
    ovsdb_column_set_add (column.c:233)
    add_column (ovsdb-client.c:730)
    parse_monitor_columns (ovsdb-client.c:787)
    add_monitored_table (ovsdb-client.c:872)
    do_monitor__ (ovsdb-client.c:945)

Reported-by: William Tu <u9012063@gmail.com>
Reported-at: http://openvswitch.org/pipermail/dev/2016-January/064161.html
Signed-off-by: Andy Zhou <azhou@ovn.org>
Signed-off-by: Ben Pfaff <blp@ovn.org>
8 years agotest-aa: Fix memory leak reported by valgrind.
William Tu [Thu, 7 Jan 2016 02:35:23 +0000 (18:35 -0800)]
test-aa: Fix memory leak reported by valgrind.

test case 1698: auto-attach - packet tests
Report several leaks at lldp_create_dummy(), the patch fixes the
following 3 leaks:
    {lldp_send (lldp.c:334), lldp_decode (lldp.c:374),
     lldp_create_dummy (ovs-lldp.c:890)}
    test_aa_send (test-aa.c:252)
    test_aa_main (test-aa.c:281)
Comments:
    1. Create a new function "lldp_destroy_dummy()" because
       many structures and its elements, ex: lldp_hardware and lldp_chassis,
       are from stack not heap (see test_aa_send). As a result, calling
       lldpd_cleanup() is incorrect.
    2. Remove lchassis->c_id = xmalloc(ETH_ADDR_LEN);
       because it is overwritten at test_aa_send()
    3. remove memcpy(&hw->h_lport.p_element.system_id.system_mac,
           lchassis->c_id, lchassis->c_id_len);
       because the source buf is empty

Signed-off-by: William Tu <u9012063@gmail.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
8 years agotest-ovsdb: Fix memory leak reported by valgrind.
William Tu [Wed, 6 Jan 2016 18:49:38 +0000 (10:49 -0800)]
test-ovsdb: Fix memory leak reported by valgrind.

Test case 1205: generate and apply diff -- set -- size (ovsdb-data.at:827)
Call stack:
    ovsdb_error_valist (ovsdb-error.c:40)
    ovsdb_error (ovsdb-error.c:55)
    do_diff_data (test-ovsdb.c:427)
    ovs_cmdl_run_command (command-line.c:121)
    main (test-ovsdb.c:72)
Fix by calling ovsdb_error_destroy() before ovs_fatal()

Signed-off-by: William Tu <u9012063@gmail.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
8 years agoovsdb-client: Fix memory leak reported by valgrind.
William Tu [Wed, 6 Jan 2016 18:49:37 +0000 (10:49 -0800)]
ovsdb-client: Fix memory leak reported by valgrind.

Test case 1508-1514: OVSDB -- ovsdb-server monitors, call stacks:
    ovsdb_schema_create (ovsdb.c:34)
    ovsdb_schema_from_json (ovsdb.c:196)
    fetch_schema (ovsdb-client.c:375)
    do_monitor__ (ovsdb-client.c:920)
    main (ovsdb-client.c:152)
Fix by adding ovsdb_schema_destroy().

Signed-off-by: William Tu <u9012063@gmail.com>
Signed-off-by: Daniele Di Proietto <diproiettod@vmware.com>
Co-authored-by: Daniele Di Proietto <diproiettod@vmware.com
Signed-off-by: Ben Pfaff <blp@ovn.org>
8 years agotest-netflow: Fix memory leak reported by valgrind.
William Tu [Wed, 6 Jan 2016 18:49:35 +0000 (10:49 -0800)]
test-netflow: Fix memory leak reported by valgrind.

Test case 890: ofproto-dpif - NetFlow flow expiration - IPv4 collector
Valgrind reports two leaks below:
    unixctl_server_create (unixctl.c:250)
    test_netflow_main (test-netflow.c:200)
    ovstest_wrapper_test_netflow_main__ (test-netflow.c:301)
    ovs_cmdl_run_command (command-line.c:121)
    main (ovstest.c:132)
and
    ofpbuf_init (ofpbuf.c:124)
    test_netflow_main (test-netflow.c:208)
    ovstest_wrapper_test_netflow_main__ (test-netflow.c:301)
    ovs_cmdl_run_command (command-line.c:121)
    main (ovstest.c:132)

Signed-off-by: William Tu <u9012063@gmail.com>
Signed-off-by: Daniele Di Proietto <diproiettod@vmware.com>
Co-authored-by: Daniele Di Proietto <diproiettod@vmware.com
Signed-off-by: Ben Pfaff <blp@ovn.org>
8 years agopython: ignore warnings from flake8 version 2.0
Lance Richardson [Fri, 8 Jan 2016 18:19:16 +0000 (13:19 -0500)]
python: ignore warnings from flake8 version 2.0

Ignore warnings emitted by flake8 version 2.0 (this is the version
currently provided in the CentOS/RHEL 7 EPEL repository).

Signed-off-by: Lance Richardson <lrichard@redhat.com>
[russell@ovn.org Updated AUTHORS file]
Signed-off-by: Russell Bryant <russell@ovn.org>
8 years agopython: Fix the TypeError exception seen when idl.Idl parses lock reply
Numan Siddique [Fri, 8 Jan 2016 06:29:47 +0000 (11:59 +0530)]
python: Fix the TypeError exception seen when idl.Idl parses lock reply

File "/usr/lib/python2.7/site-packages/ovs/db/idl.py", line 334,
in __parse_lock_notify
  self.__update_has_lock(self, new_has_lock)
TypeError: __update_has_lock() takes exactly 2 arguments (3 given)

Signed-off-by: Numan Siddique <nusiddiq@redhat.com>
Signed-off-by: Russell Bryant <russell@ovn.org>
8 years agoofproto-dpif-upcall: Simplify revalidator_sweep__().
Joe Stringer [Thu, 7 Jan 2016 19:47:47 +0000 (11:47 -0800)]
ofproto-dpif-upcall: Simplify revalidator_sweep__().

Broadly, there are two cases that are handled during revalidator_sweep__:
- Ukeys which had their corresponding datapath flows deleted during the
  most recent dump phase need to be deleted.
- If a flow for a ukey still exists in the datapath, the flow may need
  to be removed or updated. This depends on a variety of factors such as
  whether the datapath is being flushed, whether individual flows were
  recently dumped, and whether those flows are valid for the current
  revalidation generation.

Previously, the logic was written such that the first of these cases
would be handled under the "UKEY_KEEP" case to ensure that
revalidator_sweep__() will not attempt to delete flows that already
exist. In this case, ukey->flow_exists would be false, which would
trigger ukey cleanup.

While correct, this is misleading and difficult to follow. Since commit
83b03fe05e7a ("ofproto-dpif-upcall: Avoid double-delete of ukeys."),
this logic is no longer required to prevent double-deletion of such
flows, so we can now make this codepath more straightforward.

Signed-off-by: Joe Stringer <joe@ovn.org>
Co-authored-by: Jarno Rajahalme <jarno@ovn.org>
Acked-by: Jarno Rajahalme <jarno@ovn.org>
8 years agoofproto-dpif-upcall: Don't delete modified ukeys.
Joe Stringer [Thu, 7 Jan 2016 19:47:46 +0000 (11:47 -0800)]
ofproto-dpif-upcall: Don't delete modified ukeys.

If revalidation returns the result UKEY_DELETE, then both the ukey and
its corresponding flow should be deleted. However, if revalidation
returns UKEY_MODIFY, the ukey itself should be modified in-place and
should not be deleted.

Fix this by only applying the ukey deletion to ukeys whose datapath
operations delete a flow.

This may fix statistics accounting issues in rare cases involving
OpenFlow rule modification where actions are updated but flows remain
the same.

Found by inspection.

Signed-off-by: Joe Stringer <joe@ovn.org>
Acked-by: Jarno Rajahalme <jarno@ovn.org>
8 years agoBetter abstract OFPT_SET_CONFIG and OFPT_GET_CONFIG_REPLY, make stricter.
Ben Pfaff [Mon, 21 Dec 2015 23:39:10 +0000 (15:39 -0800)]
Better abstract OFPT_SET_CONFIG and OFPT_GET_CONFIG_REPLY, make stricter.

The OFPT_SET_CONFIG and OFPT_GET_CONFIG_REPLY messages, which have the
same format, have a 'flags' field in which OpenFlow defines some bits,
which change somewhat from one version to another, and does not define
others.  Until now, Open vSwitch has not abstracted these messages at all
and has ignored the bits that OpenFlow leaves undefined.  This commit
abstracts the messages in the same way as other OpenFlow messages and
validates in OFPT_SET_CONFIG messages that the undefined bits are set to
zero.

OpenFlow 1.1 and 1.2, but not OpenFlow 1.0, define a flag named
OFPC_INVALID_TTL_TO_CONTROLLER.  Open vSwitch has until now also
implemented this as an extension to OpenFlow 1.0, and this commit retains
that extension.

Reported-by: Manpreet Singh <er.manpreet25@gmail.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
Acked-by: Andy Zhou <azhou@ovn.org>
8 years agoofproto: Implement OFPT_QUEUE_GET_CONFIG_REQUEST for OFPP_ANY in OF1.1+.
Ben Pfaff [Thu, 7 Jan 2016 16:57:44 +0000 (08:57 -0800)]
ofproto: Implement OFPT_QUEUE_GET_CONFIG_REQUEST for OFPP_ANY in OF1.1+.

I was not previously aware that this feature was missing.

Reported-by: Minoru TAKAHASHI <takahashi.minoru7@gmail.com>
Reported-at: http://openvswitch.org/pipermail/discuss/2015-October/019229.html
Signed-off-by: Ben Pfaff <blp@ovn.org>
Acked-by: Andy Zhou <azhou@ovn.org>
8 years agoovs-ofctl: Generalize code for finding ports into general-purpose iterator.
Ben Pfaff [Wed, 4 Nov 2015 00:38:13 +0000 (16:38 -0800)]
ovs-ofctl: Generalize code for finding ports into general-purpose iterator.

The port_iterator will acquire another user in an upcoming commit.

Signed-off-by: Ben Pfaff <blp@ovn.org>
Acked-by: Andy Zhou <azhou@ovn.org>
8 years agoofproto-dpif-upcall: Avoid double-delete of ukeys.
Ben Pfaff [Wed, 6 Jan 2016 23:44:39 +0000 (15:44 -0800)]
ofproto-dpif-upcall: Avoid double-delete of ukeys.

revalidate_sweep__() has two cases where it calls ukey_delete() to
remove a ukey from the umap via cmap_remove().  The first case is a direct
call to ukey_delete(), when !flow_exists.  The second case is an indirect
call via push_ukey_ops(), when result != UKEY_KEEP.  If both of these
conditions are simultaneously true, however, the code would call
ukey_delete() twice, causing an assertion failure in the second call.  This
commit fixes the problem by eliminating one of the calls.

The version tested by Ben Warren differs from this version, see:
    http://openvswitch.org/pipermail/dev/2016-January/064117.html

Reported-by: Keith Holleman <keith.holleman@gmail.com>
Reported-at: http://openvswitch.org/pipermail/discuss/2015-December/019772.html
CC: Joe Stringer <joe@ovn.org>
VMware-BZ: #1579057
Signed-off-by: Ben Pfaff <blp@ovn.org>
Tested-by: Ben Warren <ben@skyportsystems.com>
8 years agopython: Ignore all D,H warnings from flake8.
Russell Bryant [Wed, 6 Jan 2016 16:50:21 +0000 (11:50 -0500)]
python: Ignore all D,H warnings from flake8.

A previous patch added the list of warnings emitted by the docstrings
and hacking plugins for flake8.  Switch to ignoring all warnings from
those plugins.  We can use --select to enable specific ones that we want
if needed later on.

Signed-off-by: Russell Bryant <russell@ovn.org>
Acked-by: Ben Pfaff <blp@ovn.org>
8 years agoAdd some more flake8 types to ignore list to fix the compilation errors
Numan Siddique [Wed, 6 Jan 2016 11:29:15 +0000 (16:59 +0530)]
Add some more flake8 types to ignore list to fix the compilation errors

with the flake8 check enabled, ovs compilation is failing. This
patch adds few more flake8 types to the igore list.  These warnings
come from the hacking and docstrings flake8 plugins.

Signed-off-by: Numan Siddique <nusiddiq@redhat.com>
[russell@ovn.org added comments, also ignore W503]
Signed-off-by: Russell Bryant <russell@ovn.org>
8 years agoofproto-dpif-rid: Fix memory leak in recirc_state.
Ben Pfaff [Wed, 6 Jan 2016 00:51:54 +0000 (16:51 -0800)]
ofproto-dpif-rid: Fix memory leak in recirc_state.

recirc_state_clone() copies the stack and actions and nothing ever freed
them.

CC: Jarno Rajahalme <jarno@ovn.org>
CC: Andy Zhou <azhou@ovn.org>
Reported-by: William Tu <u9012063@gmail.com>
Reported-at: http://openvswitch.org/pipermail/dev/2016-January/064040.html
Signed-off-by: Ben Pfaff <blp@ovn.org>
8 years agopython: Restrict line length to 79 chars.
Russell Bryant [Tue, 5 Jan 2016 23:19:52 +0000 (18:19 -0500)]
python: Restrict line length to 79 chars.

Resolve pep8 error:

  E501 line too long (80 > 79 characters)

Signed-off-by: Russell Bryant <russell@ovn.org>
Acked-by: Ben Pfaff <blp@ovn.org>
8 years agopython: Resolve some indentation warnings.
Russell Bryant [Tue, 5 Jan 2016 19:50:40 +0000 (14:50 -0500)]
python: Resolve some indentation warnings.

This patch resolves the following warnings from flake8:

 E111 indentation is not a multiple of four
 E112 expected an indented block
 E113 unexpected indentation

It's critical to have correct indentation in Python code, so it seemed
worth enabling these warnings.

Signed-off-by: Russell Bryant <russell@ovn.org>
Acked-by: Ben Pfaff <blp@ovn.org>
8 years agopython: Add missing Apache License headers.
Russell Bryant [Tue, 5 Jan 2016 19:34:22 +0000 (14:34 -0500)]
python: Add missing Apache License headers.

Signed-off-by: Russell Bryant <russell@ovn.org>
Acked-by: Ben Pfaff <blp@ovn.org>
8 years agopython: Inherit from object.
Russell Bryant [Sun, 13 Dec 2015 04:11:47 +0000 (23:11 -0500)]
python: Inherit from object.

class Vlog now inherits from "object".  This is a "new style" Python
class, which isn't new at all at this point.  This was introduced back
in Python 2.2, and some Python 2 code won't work as expected without it.

Signed-off-by: Russell Bryant <russell@ovn.org>
Acked-by: Ben Pfaff <blp@ovn.org>
8 years agopython: Remove unnecessary semicolons and slashes.
Russell Bryant [Tue, 22 Dec 2015 16:41:21 +0000 (11:41 -0500)]
python: Remove unnecessary semicolons and slashes.

Resolve the following flake8 errors:

  E703 statement ends with a semicolon
  E502 the backslash is redundant between brackets

Also document the reamining flake8 errors that are still ignored.

Signed-off-by: Russell Bryant <russell@ovn.org>
Acked-by: Ben Pfaff <blp@ovn.org>
8 years agopython: Resolve a deprecation warning.
Russell Bryant [Tue, 22 Dec 2015 16:30:32 +0000 (11:30 -0500)]
python: Resolve a deprecation warning.

Resolve the following deprecation warning.  This deprecation warning
advises to use an alternative syntax which is also compatible with
Python 3, where has_key() was removed.

  W601 .has_key() is deprecated, use 'in'

Also fix this related error:

  E713 test for membership should be 'not in'

Signed-off-by: Russell Bryant <russell@ovn.org>
Acked-by: Ben Pfaff <blp@ovn.org>
8 years agopython: Fix several pep8 whitespace errors.
Russell Bryant [Tue, 5 Jan 2016 23:16:20 +0000 (18:16 -0500)]
python: Fix several pep8 whitespace errors.

Fix the following pep8 errors:

  E201 whitespace after '('
  E203 whitespace before ','
  E222 multiple spaces after operator
  E225 missing whitespace around operator
  E226 missing whitespace around arithmetic operator
  E231 missing whitespace after ':'
  E241 multiple spaces after ':'
  E251 unexpected spaces around keyword / parameter equals
  E261 at least two spaces before inline comment
  E262 inline comment should start with '# '
  E265 block comment should start with '# '
  E271 multiple spaces after keyword

Signed-off-by: Russell Bryant <russell@ovn.org>
Acked-by: Ben Pfaff <blp@ovn.org>
8 years agopython: Resolve pep8 comparison errors.
Russell Bryant [Sat, 12 Dec 2015 17:54:31 +0000 (12:54 -0500)]
python: Resolve pep8 comparison errors.

Resolve pep8 errors:

  E711 comparison to None should be 'if cond is None:'

The reason comparing against None with "is None" is preferred over
"== None" is because a class can define its own equality operator and
produce bizarre unexpected behavior.  Using "is None" has a very
explicit meaning that can not be overridden.

  E721 do not compare types, use 'isinstance()'

This one is actually a mistake by the tool in most cases.
'from ovs.db import types' looks just like types from the Python stdlib.
In those cases, use the full ovs.db.types name.  Fix one case where it
actually was types from the stdlib.

Signed-off-by: Russell Bryant <russell@ovn.org>
Acked-by: Ben Pfaff <blp@ovn.org>
8 years agopython: Resolve pep8 blank line errors.
Russell Bryant [Sat, 12 Dec 2015 03:28:31 +0000 (22:28 -0500)]
python: Resolve pep8 blank line errors.

Resolve pep8 errors E302 and E303:

  E302 expected 2 blank lines, found 1
  E303 too many blank lines (3)

Signed-off-by: Russell Bryant <russell@ovn.org>
Acked-by: Ben Pfaff <blp@ovn.org>
8 years agopython: Fix invalid varable/function references.
Russell Bryant [Fri, 11 Dec 2015 21:16:10 +0000 (16:16 -0500)]
python: Fix invalid varable/function references.

This code referred to "rows" where it meant to refer to "fetched_rows".
The patch resolves flake8 error:

  F821 undefined name 'rows'

python/build/nroff.py used a function fatal() that was not defined,
which raised the same type of error.

Signed-off-by: Russell Bryant <russell@ovn.org>
Acked-by: Ben Pfaff <blp@ovn.org>
8 years agopython: Remove unused imports and variables.
Russell Bryant [Tue, 22 Dec 2015 15:43:24 +0000 (10:43 -0500)]
python: Remove unused imports and variables.

This resolves the following flake8 error types:

  F841 local variable 'e' is assigned to but never used
  F401 'exceptions' imported but unused

Signed-off-by: Russell Bryant <russell@ovn.org>
Acked-by: Ben Pfaff <blp@ovn.org>
8 years agopython: Run flake8 at build time.
Russell Bryant [Tue, 22 Dec 2015 01:24:34 +0000 (20:24 -0500)]
python: Run flake8 at build time.

If flake8 is installed, run it at build time.  Similar to most Makefile
targets, run it once and then only run again if the files change.

flake8 is set to ignore all error and warning types that currently occur.
Future patches will remove items from the ignore list as they are
resolved.

Signed-off-by: Russell Bryant <russell@ovn.org>
Acked-by: Ben Pfaff <blp@ovn.org>
8 years agoCONTRIBUTING: Add example Submitted-at header.
Russell Bryant [Mon, 4 Jan 2016 21:02:51 +0000 (16:02 -0500)]
CONTRIBUTING: Add example Submitted-at header.

Document a Submitted-at header to be used for GitHub pull request URLs,
or any other case where a patch was submitted somewhere other than the
OVS dev mailing list.

Signed-off-by: Russell Bryant <russell@ovn.org>
Acked-by: Ben Pfaff <blp@ovn.org>
8 years agoopenvswitch-switch.init: Redirect error to /dev/null.
Gurucharan Shetty [Tue, 5 Jan 2016 18:13:39 +0000 (10:13 -0800)]
openvswitch-switch.init: Redirect error to /dev/null.

The latest Open vSwitch kernel module from Upstream linux does not
list "version". During debian package installation, we would see
a non-harmful error in the log. This patch suppresses it.

Signed-off-by: Gurucharan Shetty <guru@ovn.org>
Acked-by: Ben Pfaff <blp@ovn.org>
8 years agoopenvswitch-switch.init: Redirect error to /dev/null.
Gurucharan Shetty [Tue, 5 Jan 2016 18:13:39 +0000 (10:13 -0800)]
openvswitch-switch.init: Redirect error to /dev/null.

The latest Open vSwitch kernel module from Upstream linux does not
list "version". During debian package installation, we would see
a non-harmful error in the log. This patch suppresses it.

Signed-off-by: Gurucharan Shetty <guru@ovn.org>
Acked-by: Ben Pfaff <blp@ovn.org>
8 years agodebian: Move ovs-lib to openvswitch-common.
Gurucharan Shetty [Tue, 5 Jan 2016 16:57:21 +0000 (08:57 -0800)]
debian: Move ovs-lib to openvswitch-common.

ovs-lib is used by both ovs-ctl and ovn-ctl. So it
is useful to move it to openvswitch-common

Signed-off-by: Gurucharan Shetty <guru@ovn.org>
Acked-by: Ben Pfaff <blp@ovn.org>
8 years agodebian: Add a package for OVN docker drivers.
Gurucharan Shetty [Wed, 16 Dec 2015 22:24:11 +0000 (14:24 -0800)]
debian: Add a package for OVN docker drivers.

Signed-off-by: Gurucharan Shetty <guru@ovn.org>
Acked-by: Ben Pfaff <blp@ovn.org>
8 years agodebian: Add a package for OVN central components.
Gurucharan Shetty [Wed, 16 Dec 2015 22:20:59 +0000 (14:20 -0800)]
debian: Add a package for OVN central components.

Signed-off-by: Gurucharan Shetty <guru@ovn.org>
Acked-by: Ben Pfaff <blp@ovn.org>
8 years agodebian: Add a package for host components.
Gurucharan Shetty [Wed, 16 Dec 2015 22:07:39 +0000 (14:07 -0800)]
debian: Add a package for host components.

Signed-off-by: Gurucharan Shetty <guru@ovn.org>
Acked-by: Ben Pfaff <blp@ovn.org>
8 years agodebian: Add a package for OVN common components.
Gurucharan Shetty [Tue, 15 Dec 2015 01:37:55 +0000 (17:37 -0800)]
debian: Add a package for OVN common components.

Signed-off-by: Gurucharan Shetty <guru@ovn.org>
Acked-by: Ben Pfaff <blp@ovn.org>
8 years agoofp-util: Rearrange ofputil_append_meter_config() to be clearer.
Ben Pfaff [Tue, 5 Jan 2016 01:13:53 +0000 (17:13 -0800)]
ofp-util: Rearrange ofputil_append_meter_config() to be clearer.

The code is easier to reason about with all of the assignments to the
members of 'reply' in one place.

Suggested-by: Andy Zhou <azhou@ovn.org>
Signed-off-by: Ben Pfaff <blp@ovn.org>
Acked-by: Justin Pettit <jpettit@ovn.org>
8 years agoofp-util: Avoid use-after-free error in ofputil_append_meter_config().
Ben Pfaff [Wed, 16 Dec 2015 06:51:29 +0000 (22:51 -0800)]
ofp-util: Avoid use-after-free error in ofputil_append_meter_config().

Reported-by: weizj <334965317@qq.com>
Reported-at: https://github.com/openvswitch/ovs/pull/97
Signed-off-by: Ben Pfaff <blp@ovn.org>
8 years agoodp-util: Fix memory leak reported by valgrind.
William Tu [Tue, 5 Jan 2016 00:18:41 +0000 (16:18 -0800)]
odp-util: Fix memory leak reported by valgrind.

Test case: OVS datapath key parsing and formatting (377)
Return without freeing buf:
    xmalloc(util.c:112)
    ofpbuf_init(ofpbuf.c:124)
    parse_odp_userspace_action(odp-util.c:987)
    parse_odp_action(odp-util.c:1552)
    odp_actions_from_string(odp-util.c:1721)
    parse_actions(test-odp.c:132)

Test case: OVS datapath actions parsing and formatting (380)
Exit withtou uninit in test-odp.c
    xrealloc(util.c:123)
    ofpbuf_resize__(ofpbuf.c:243)
    ofpbuf_put_uninit(ofpbuf.c:364)
    nl_msg_put_uninit(netlink.c:178)
    nl_msg_put_unspec_uninit(netlink.c:216)
    nl_msg_put_unspec(netlink.c:243)
    parse_odp_key_mask_attr(odp-util.c:3974)
    odp_flow_from_string(odp-util.c:4151)
    parse_keys(test-odp.c:49)
    test_odp_main(test-odp.c:237)
    ovstest_wrapper_test_odp_main__(test-odp.c:251)
    ovs_cmdl_run_command(command-line.c:121)
    main(ovstest.c:132)

Signed-off-by: William Tu <u9012063@gmail.com>
Signed-off-by: Daniele Di Proietto <diproiettod@vmware.com>
Co-authored-by: Daniele Di Proietto <diproiettod@vmware.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
8 years agoovs-ofctl: Fix memory leak reported by valgrind.
William Tu [Tue, 5 Jan 2016 00:18:40 +0000 (16:18 -0800)]
ovs-ofctl: Fix memory leak reported by valgrind.

Test case: ovs-ofctl replace-flows with --bundle(376) reports two leaks:
    ofpbuf_new(ofpbuf.c:151)
    ofpraw_alloc_xid(ofp-msgs.c:533)
    ofpraw_alloc(ofp-msgs.c:525)
    ofputil_encode_flow_mod(ofp-util.c:2290)
    bundle_flow_mod__(ovs-ofctl.c:1312)
    ofctl_flow_mod__(ovs-ofctl.c:1331)
    ofctl_flow_mod_file.isra.13(ovs-ofctl.c:1365)
    ovs_cmdl_run_command(command-line.c:121)
    main(ovs-ofctl.c:135)
and
    ofpraw_alloc(ofp-msgs.c:525)
    ofputil_encode_flow_mod(ofp-util.c:2290)
    fte_make_flow_mod(ovs-ofctl.c:2936)
    ofctl_replace_flows(ovs-ofctl.c:2981)
    ovs_cmdl_run_command(command-line.c:121)
    main(ovs-ofctl.c:135)

Signed-off-by: William Tu <u9012063@gmail.com>
Signed-off-by: Daniele Di Proietto <diproiettod@vmware.com>
Co-authored-by: Daniele Di Proietto <diproiettod@vmware.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
8 years agoovsdb-client: Fix memory leak reported by valgrind.
William Tu [Tue, 5 Jan 2016 00:18:39 +0000 (16:18 -0800)]
ovsdb-client: Fix memory leak reported by valgrind.

Free memory allocated from table_add_column and table_add_row.
Test case: vsctl-bashcomp - basic verification/argument completion(7,8)
Call stack is below:
    xrealloc (util.c:123)
    table_add_column (table.c:146) or table_add_row (table.c:172)
    do_list_tables (ovsdb-client.c:449)
    main (ovsdb-client.c:151)

Signed-off-by: William Tu <u9012063@gmail.com>
Signed-off-by: Daniele Di Proietto <diproiettod@vmware.com>
Co-authored-by: Daniele Di Proietto <diproiettod@vmware.com>
[blp@ovn.org removed an unneeded "if"]
Signed-off-by: Ben Pfaff <blp@ovn.org>
8 years agophysical: Improve treatment of localnet non-VLAN logical ports.
Ben Pfaff [Sun, 29 Nov 2015 19:48:43 +0000 (11:48 -0800)]
physical: Improve treatment of localnet non-VLAN logical ports.

Until now, the flow table treated localnet logical ports that have a VLAN
quite differently from those that don't.  The ones without a VLAN were
essentially trunk ports: any packets that came in, that weren't picked off
by a localnet port with a VLAN, were passed to the ones without a VLAN.
This wasn't the intended behavior.

This commit changes behavior to the intended behavior.  Now, localnet ports
without a specific VLAN only receive packets without a VLAN header or those
with VLAN ID 0 (with that header stripped off).

Found by inspection.

Signed-off-by: Ben Pfaff <blp@ovn.org>
Acked-by: Russell Bryant <russell@ovn.org>
8 years agoofp-actions: Rename ofpact_update_len() to ofpact_finish().
Ben Pfaff [Tue, 22 Dec 2015 20:39:55 +0000 (12:39 -0800)]
ofp-actions: Rename ofpact_update_len() to ofpact_finish().

It does more than just update the length now, so this is a more accurate
name.

Signed-off-by: Ben Pfaff <blp@ovn.org>
Acked-by: Russell Bryant <russell@ovn.org>
8 years agoofp-actions: Make composing actions harder to screw up.
Ben Pfaff [Wed, 23 Dec 2015 21:23:48 +0000 (13:23 -0800)]
ofp-actions: Make composing actions harder to screw up.

Until now, composing a fixed-length action with ofpact_put_<NAME>() failed
to append any padding required after the action.  This commit changes that
so that these calls now add padding.  This meant that the function
ofpact_pad(), which was until now required in various unintuitive places,
is no longer required, and removes it.

Variable-length actions still require calling ofpact_update_len() after
composition.  I don't see a way to avoid that.

Signed-off-by: Ben Pfaff <blp@ovn.org>
Acked-by: Russell Bryant <russell@ovn.org>
8 years agodatapath-windows: Fix subscribe/unsubscribe packets
Alin Serdean [Mon, 4 Jan 2016 23:04:11 +0000 (23:04 +0000)]
datapath-windows: Fix subscribe/unsubscribe packets

The policy of the subscribe packets is defined by the following:
    const NL_POLICY policy[] =  {
        [OVS_NL_ATTR_PACKET_PID] = {.type = NL_A_U32 },
        [OVS_NL_ATTR_PACKET_SUBSCRIBE] = {.type = NL_A_U8 }
        };
Switch the value of the join operation with the one from the policy.

Signed-off-by: Alin Gabriel Serdean <aserdean@cloudbasesolutions.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
8 years agonetlink-socket: Fix log message for subscribe/unsubscribe on Windows.
Alin Serdean [Mon, 4 Jan 2016 23:04:10 +0000 (23:04 +0000)]
netlink-socket: Fix log message for subscribe/unsubscribe on Windows.

The warning message was inverted on the performed operation.

Also use the error returned by nl_sock_subscribe_packet__.

Signed-off-by: Alin Gabriel Serdean <aserdean@cloudbasesolutions.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
8 years agoovn-northd: Can't use ct() for router ports.
l0310 [Wed, 2 Dec 2015 11:20:07 +0000 (19:20 +0800)]
ovn-northd: Can't use ct() for router ports.

This patch ensures that we do not attempt to use connection tracking for
logical ports with type=router.  This does not work as the traffic
through a logical router port is not symmetric since logical routers are
distributed.  The result was that traffic between logical ports on
different hypervisors that went through a logical router would fail if
ACLs were in use.

GitHub-PR: #92
Reported-at: https://bugs.launchpad.net/networking-ovn/+bug/1522022
Signed-off-by: l0310 <liw@dtdream.com>
[russell@ovn.org updated commit message, style tweaks]
Signed-off-by: Russell Bryant <russell@ovn.org>
8 years agonetdev-bsd: Destroy mutex on netdev_bsd_construct_system() error path.
xushengping [Thu, 24 Dec 2015 07:50:47 +0000 (15:50 +0800)]
netdev-bsd: Destroy mutex on netdev_bsd_construct_system() error path.

Signed-off-by: xushengping <shengping.xu@huawei.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
8 years agoofp-print: Fix memory leak at ofp_print_bundle_add().
William Tu [Thu, 24 Dec 2015 18:28:40 +0000 (10:28 -0800)]
ofp-print: Fix memory leak at ofp_print_bundle_add().

Call ds_put_and_free_cstr instead of ds_put_cstr to free msg.
Reported by test cases: 325, 326
    ofp_print_bundle_add (ofp-print.c:3027)
    ofp_to_string__ (ofp-print.c:3410)
    ofp_to_string (ofp-print.c:3465)
    ofp_print (ofp-print.c:3497)
    ofctl_ofp_print (ovs-ofctl.c:3818)
    ovs_cmdl_run_command (command-line.c:121)
    main (ovs-ofctl.c:135)

Signed-off-by: William Tu <u9012063@gmail.com>
Signed-off-by: Daniele Di Proietto <diproiettod@vmware.com>
Co-authored-by: Daniele Di Proietto <diproiettod@vmware.com>
[blp@ovn.org simplified the code slightly]
Signed-off-by: Ben Pfaff <blp@ovn.org>
Signed-off-by: Ben Pfaff <blp@ovn.org>
8 years agoUse initializers for struct ofputil_flow_mod instead of assignments.
Ben Pfaff [Mon, 4 Jan 2016 19:36:14 +0000 (11:36 -0800)]
Use initializers for struct ofputil_flow_mod instead of assignments.

A few bugs have been fixed lately that were related to struct
ofputil_flow_mod not being fully initialized in a few places.  This commit
changes several pieces of code from using individual assignments to fields
in struct ofputil_flow_mod, to using whole initializers or assignments to
a whole struct.  This should help prevent similar problems in the future.

CC: Ilya Maximets <i.maximets@samsung.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
Acked-by: Russell Bryant <russell@ovn.org>
8 years agotest-sflow: Fix memory leak in main function.
Ilya Maximets [Thu, 24 Dec 2015 10:22:53 +0000 (13:22 +0300)]
test-sflow: Fix memory leak in main function.

Reported by valgrind on test case 886.

 912 (24 direct, 888 indirect) bytes in 1 blocks are definitely lost
    at malloc
    by xmalloc (util.c:112)
    by unixctl_server_create (unixctl.c:250)
    by test_sflow_main (test-sflow.c:688)
    by ovstest_wrapper_test_sflow_main__ (test-sflow.c:786)
    by ovs_cmdl_run_command (command-line.c:121)
    by main (ovstest.c:132)

 1,500 bytes in 1 blocks are definitely lost
    at malloc
    by xmalloc (util.c:112)
    by ofpbuf_init (ofpbuf.c:124)
    by test_sflow_main (test-sflow.c:696)
    by ovstest_wrapper_test_sflow_main__ (test-sflow.c:786)
    by ovs_cmdl_run_command (command-line.c:121)
    by main (ovstest.c:132)

Signed-off-by: Ilya Maximets <i.maximets@samsung.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
8 years agoofproto: Fix using uninitialized delete_reason.
Ilya Maximets [Thu, 24 Dec 2015 07:57:44 +0000 (10:57 +0300)]
ofproto: Fix using uninitialized delete_reason.

replace_rule_finish() makes decision using uninitialized
for intrenal flow fm->delete_reason.
Reported by valgrind for test cases 886, 942 and 943.

 Conditional jump or move depends on uninitialised value(s)
    at rule_insert (ofproto-dpif.c:4134)
    by replace_rule_finish (ofproto.c:4831)
    by add_flow_finish (ofproto.c:4661)
    by modify_flows_finish (ofproto.c:4994)
    by ofproto_flow_mod_finish (ofproto.c:6821)
    by handle_flow_mod__ (ofproto.c:5323)
    by ofproto_dpif_add_internal_flow (ofproto-dpif.c:5680)
    by add_internal_miss_flow (ofproto-dpif.c:1385)
    by add_internal_flows (ofproto-dpif.c:1412)
    by construct (ofproto-dpif.c:1367)
    by ofproto_create (ofproto.c:577)
    by bridge_reconfigure (bridge.c:633)
    by bridge_run (bridge.c:2975)
    by main (ovs-vswitchd.c:120)
  Uninitialised value was created by a stack allocation
    at ofproto_dpif_add_internal_flow (ofproto-dpif.c:5658)

Signed-off-by: Ilya Maximets <i.maximets@samsung.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
8 years agoUpdate appveyor OpenSSL link
Alin Serdean [Mon, 4 Jan 2016 13:29:55 +0000 (13:29 +0000)]
Update appveyor OpenSSL link

The link of OpenSSL 1_0_2d is no longer available update it to the current
version.

Signed-off-by: Alin Gabriel Serdean <aserdean@cloudbasesolutions.com>
Signed-off-by: Gurucharan Shetty <guru@ovn.org>
8 years agoovs-sandbox: assign default value to ${MAKE}
qhjindev [Thu, 31 Dec 2015 13:19:10 +0000 (21:19 +0800)]
ovs-sandbox: assign default value  to ${MAKE}

When run ovs-sandbox directly from the tutorial directory (the second method
in Tutorial.md), the following result show up:

$ ./ovs-sandbox -b /media/sda6/network/ovs/build
./ovs-sandbox: line 304: install-man: command not found

The reason is that ${MAKE} is not set in the situation.

So change ${MAKE} to ${MAKE-make} to resolve the issue.

GitHub-PR: #104
Signed-off-by: Qinghua Jin <qhjin_dev@163.com>
Signed-off-by: Russell Bryant <russell@ovn.org>
8 years agotests: OVN localnet port test case.
Russell Bryant [Wed, 23 Dec 2015 16:29:33 +0000 (11:29 -0500)]
tests: OVN localnet port test case.

Add a test case for OVN localnet ports.  We set up two hypervisors
connected by a network.  We create two ports on each hypervisor and
attach them to this network using OVN localnet ports.  Two ports are on
the untagged network, and the other two are on VLAN 101.

Signed-off-by: Russell Bryant <russell@ovn.org>
Acked-by: Ben Pfaff <blp@ovn.org>
8 years agoovs-dev.py: Fix libcap-ng-dev dependency.
Joe Stringer [Wed, 23 Dec 2015 22:16:09 +0000 (14:16 -0800)]
ovs-dev.py: Fix libcap-ng-dev dependency.

Signed-off-by: Joe Stringer <joe@ovn.org>
Acked-by: Ben Pfaff <blp@ovn.org>
8 years agoMakefile.am: Fix Automake warning.
Ben Pfaff [Wed, 23 Dec 2015 22:24:32 +0000 (14:24 -0800)]
Makefile.am: Fix Automake warning.

The warning is as follows:

  Makefile.am:363: warning: .PHONY was already defined in condition TRUE,
    which includes condition VSTUDIO_DDK ...
  Makefile.am:200: ... '.PHONY' previously defined here

Signed-off-by: Ben Pfaff <blp@ovn.org>
8 years agoovs-ofctl: Document arp_op match field.
Ben Pfaff [Wed, 23 Dec 2015 21:20:02 +0000 (13:20 -0800)]
ovs-ofctl: Document arp_op match field.

Reported-by: ZHANG Zhiming <zhangzhiming@yunshan.net.cn>
Signed-off-by: Ben Pfaff <blp@ovn.org>
Acked-by: Justin Pettit <jpettit@ovn.org>
8 years agodatapath: ip4_dst_hoplimit compat code is needed prior to v2.6.38
Simon Horman [Fri, 18 Dec 2015 04:50:01 +0000 (20:50 -0800)]
datapath: ip4_dst_hoplimit compat code is needed prior to v2.6.38

ip4_dst_hoplimit was introduced in v2.6.38 rather than v2.6.39.

Fixes: e23775f20e1a ("datapath: Add support for lwtunnel")
Signed-off-by: Simon Horman <simon.horman@netronome.com>
Acked-by: Pravin B Shelar <pshelar@nicira.com>
8 years agoMakefile: Mark non-file targets as .PHONY.
Yin Lin [Wed, 23 Dec 2015 21:18:29 +0000 (13:18 -0800)]
Makefile: Mark non-file targets as .PHONY.

Some lately added targets (ovsext_make and thread-safety-check) are not
files but were not marked as .PHONY. This causes them to be rebuilt
unnecessarily during "make check" and "make install" process.

Signed-off-by: Yin Lin <linyi@vmware.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
8 years agodebian: Remove old PKI directory migration code
Ansis Atteka [Wed, 23 Dec 2015 02:23:42 +0000 (18:23 -0800)]
debian: Remove old PKI directory migration code

Open vSwitch 1.3 and older was creating certificates and private
key in /usr/share/openvswitch/pki.  However, since PKI directory
is mutable, then this was considered a bug and PKI directory was
moved to /var directory in Open vSwitch 1.4 Commit 14bd2d51 (debian:
Move PKI directory to FHS-compliant location.)

Note, that Ubuntu 12.04 already was shipping with Open vSwitch 1.4
and should have created (in case of fresh install) or moved (in
case of upgrade from Open vSwitch 1.3) this directory to the right
location.

So I am inclined to remove this code because the only reason for it
to exist would be, if someone would be upgrading from Open vSwitch
1.3 or older version directly to 2.5 without using any intermediary
upgrade releases.

Signed-Off-By: Ansis Atteka <aatteka@nicira.com>
Acked-by: Ben Pfaff <blp@ovn.org>
8 years agoovsdb-server: Fix memory leak using perf counter without initialization.
William Tu [Wed, 23 Dec 2015 18:58:15 +0000 (10:58 -0800)]
ovsdb-server: Fix memory leak using perf counter without initialization.

perf_counter_accumulate() is invoked without perf_counters_init() being
called first, which leads to a memory leak reported by Valgrind (test
cases 104, 106, and 107). A call trace is below:
    xmalloc (util.c:112)
    shash_add_nocopy__ (shash.c:109)
    shash_add_nocopy (shash.c:121)
    shash_add (shash.c:129)
    shash_add_once (shash.c:136)
    shash_add_assert (shash.c:146)
    perf_counter_init (perf-counter.c:86)
    perf_counter_accumulate (perf-counter.c:95)
    ovsdb_txn_commit (transaction.c:850)
    ovsdb_file_open__ (file.c:217)
    open_db (ovsdb-server.c:418)
    main (ovsdb-server.c:263)

Signed-off-by: William Tu <u9012063@gmail.com>
Signed-off-by: Daniele Di Proietto <diproiettod@vmware.com>
Co-authored-by: Daniele Di Proietto <diproiettod@vmware.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
8 years agosystem-traffic: Skip all vxlan tests if unsupported.
Joe Stringer [Wed, 23 Dec 2015 00:47:26 +0000 (16:47 -0800)]
system-traffic: Skip all vxlan tests if unsupported.

The vxlan tests require a new enough 'ip' tool to configure native VXLAN
tunnels on the host kernel (as well as a new enough kernel). If this
isn't available, simply skip the test. This commit makes the cases where
this is checked consistent.

Signed-off-by: Joe Stringer <joe@ovn.org>
Acked-by: Ben Pfaff <blp@ovn.org>
Acked-by: Russell Bryant <russell@ovn.org>
8 years agodatapath-windows: Reduce padding size in _OVS_PACKET_HDR_INFO.
Nithin Raju [Mon, 7 Dec 2015 23:13:03 +0000 (15:13 -0800)]
datapath-windows: Reduce padding size in _OVS_PACKET_HDR_INFO.

Fixes: efee3309 ("datapath-windows: Support for OVS_KEY_ATTR_SCTP attribute")
Signed-off-by: Nithin Raju <nithin@vmware.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
Acked-by: Sairam Venugopal <vsairam@vmware.com>
Acked-by: Alin Gabriel Serdean <aserdean@cloudbasesolutions.com>
8 years agoovs-benchmark: Fix memory leak.
Ben Pfaff [Wed, 23 Dec 2015 07:27:45 +0000 (23:27 -0800)]
ovs-benchmark: Fix memory leak.

This leak is not a real problem.

Reported-by: xushengping
Reported-at: https://github.com/openvswitch/ovs/pull/100
Signed-off-by: Ben Pfaff <blp@ovn.org>
8 years agoofp-actions: Add padding in ofpacts_pull_openflow_instructions()
William Tu [Fri, 11 Dec 2015 01:58:15 +0000 (17:58 -0800)]
ofp-actions: Add padding in ofpacts_pull_openflow_instructions()

ofpacts_pull_openflow_instructions() should fill 'ofpacts' with a list
of OpenFlow actions and each action (including the last one) should be
padded to OFP_ACTION_ALIGN(8) bytes.

In most of the cases this is taken care of (e.g. by ofpacts_decode), but
for the Goto-Table instruction (and Clear-Actions, based on a quick code
inspection), this wasn't the case.

This caused the copy operation in recirc_unroll_actions() to read two
extra bytes after an allocated area (not a big deal, but enough to
displease the AddressSanitizer).

Signed-off-by: William Tu <u9012063@gmail.com>
Signed-off-by: Daniele Di Proietto <diproiettod@vmware.com>
Co-authored-by: Daniele Di Proietto <diproiettod@vmware.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
8 years agotest-classifier: Use `in_port.ofp_port`, instead of `in_port`.
William Tu [Fri, 11 Dec 2015 01:58:13 +0000 (17:58 -0800)]
test-classifier: Use `in_port.ofp_port`, instead of `in_port`.

The test uses 16-bit ofp_port_t, however the struct flow member
`in_port` is 32-bit, causing a memcpy to read uninitialized data.
We should restrict the test to the `ofp_port` member of the `in_port`
union

Signed-off-by: William Tu <u9012063@gmail.com>
Signed-off-by: Daniele Di Proietto <diproiettod@vmware.com>
Co-authored-by: Daniele Di Proietto <diproiettod@vmware.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
8 years agoflow: Pass last field to miniflow_pad_to_64().
Simon Horman [Tue, 1 Dec 2015 06:03:16 +0000 (15:03 +0900)]
flow: Pass last field to miniflow_pad_to_64().

Make miniflow_pad_to_64() a little more robust with regards to updates to
struct flow by passing the last field, whose end should be considered for
padding, rather than the next field, whose start should be considered.

Signed-off-by: Simon Horman <simon.horman@netronome.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
8 years agoofproto: Remove flows from all tables upon group deletion.
Zoltán Balogh [Wed, 23 Dec 2015 01:10:40 +0000 (17:10 -0800)]
ofproto: Remove flows from all tables upon group deletion.

When a group is deleted, all flows which include a Group action with the ID
of the deleted group should be removed.  Until now, only flows in table 0
were removed.  This fixes the problem.

Signed-off-by: Zoltán Balogh <zoltan.balogh@ericsson.com>
[blp@ovn.org added a test]
Signed-off-by: Ben Pfaff <blp@ovn.org>
8 years agoofp-util: return BAD_TYPE for consistency at ofputil_decode_group_mod().
Flavio Leitner [Tue, 22 Dec 2015 17:02:31 +0000 (15:02 -0200)]
ofp-util: return BAD_TYPE for consistency at ofputil_decode_group_mod().

Code earlier in this function validated that gm->type is valid, so
the default case at the end of the function would be impossible, but
since the code can change or perhaps get copied, return the correct
error to keep consistency and avoid reintroducing the bug fixed by
commit 09d4b951636b ("ofp-util: Reject bad group type and command
with error instead of abort.")

Signed-off-by: Flavio Leitner <fbl@redhat.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
8 years agodpif-netdev: Avoid using uninitialized memory with tunnel options.
Jesse Gross [Wed, 9 Dec 2015 20:55:17 +0000 (12:55 -0800)]
dpif-netdev: Avoid using uninitialized memory with tunnel options.

When handling an upcall with the userspace datapath, it's currently
possible for a flow from a packet with no tunnel options to come back
with matches on the options. If that happens, dpif-netdev will
attempt to translate the wildcards provided by ofproto into the format
used by dpif. The translation requires use of the original wildcards
from the flow, which since they didn't exist, is uninitalized memory.

Matching on fields which don't actually exist is itself a bug. However,
this can occur when we attempt to set a tunnel option on the packet -
ofproto generates a match on the field in the original packet. This is
being fixed separately.

In other situations where we have a match on an unexpected field, we
simply ignore it. This happens with tunnel options with the kernel
datapath, non-tunnel fields that don't exist in the packet, and even
with Geneve where we do have some options but not the particular one
that was matched on. This brings the same behavior for this case and
avoids the possibility of accessing uninitialized memory.

Reported-by: Daniele Di Proietto <diproiettod@vmware.com>
Signed-off-by: Jesse Gross <jesse@kernel.org>
Acked-by: Daniele Di Proietto <diproiettod@vmware.com>