cascardo/ovs.git
8 years agoconnmgr: Generalize ofproto_packet_in to ofproto_async_msg.
Ben Pfaff [Tue, 19 Jan 2016 04:12:30 +0000 (20:12 -0800)]
connmgr: Generalize ofproto_packet_in to ofproto_async_msg.

An upcoming commit will add another kind of asynchronous message that
should be handled in the same way as packet-ins.

Signed-off-by: Ben Pfaff <blp@ovn.org>
8 years agoopenflow: Better abstract handling of packet-in messages.
Ben Pfaff [Wed, 20 Jan 2016 17:57:16 +0000 (09:57 -0800)]
openflow: Better abstract handling of packet-in messages.

Packet-in messages have been a bit of a mess.  First, their abstraction
in the form of struct ofputil_packet_in has some fields that are used
in a clear way for incoming and outgoing packet-ins, and others
(packet_len, total_len, buffer_id) have have confusing meanings or
usage pattern depending on their direction.

Second, it's very confusing how a packet-in has both a reason (OFPR_*)
and a miss type (OFPROTO_PACKET_IN_*) and how those add up to the
actual reason that is used "on the wire" for each OpenFlow version (and
even whether the packet-in is sent at all!).

Finally, there's all kind of low-level detail randomly scattered between
connmgr, ofproto-dpif-xlate, and ofp-util.

This commit attempts to clear up some of the confusion.  It simplifies
the struct ofputil_packet_in abstraction by removing the members that
didn't have a clear and consistent meaning between incoming and outgoing
packet-ins.  It gets rid of OFPROTO_PACKET_IN_*, instead adding a couple
of nonstandard OFPR_* reasons that add up to what OFPROTO_PACKET_IN_*
was meant to say (in what I hope is a clearer way).  And it consolidates
the tricky parts into ofp-util, where I hope it will be easier to
understand all in one place.

Signed-off-by: Ben Pfaff <blp@ovn.org>
Acked-by: Jarno Rajahalme <jarno@ovn.org>
8 years agopktbuf: Move from 'ofproto' to 'lib'.
Ben Pfaff [Fri, 15 Jan 2016 04:08:07 +0000 (20:08 -0800)]
pktbuf: Move from 'ofproto' to 'lib'.

An upcoming commit will use this library from ofp-util instead of ofproto.

Signed-off-by: Ben Pfaff <blp@ovn.org>
Acked-by: Jarno Rajahalme <jarno@ovn.org>
8 years agofail-open: Drop some of the weirder special cases.
Ben Pfaff [Fri, 15 Jan 2016 04:10:43 +0000 (20:10 -0800)]
fail-open: Drop some of the weirder special cases.

I don't have any real evidence that these special cases make a difference
in real-world cases.  The messages for the commits that add them are not
clear about the reasons for them.  I seem to recall that they were only
tested with the dummy controller inside OVS, which isn't very good evidence
for real controllers.  Finally, they cut across layers in nasty ways and
make it hard to better abstract packet-ins and packet buffering.

If these solve real problems then we can reconsider after some reports
come in.

Signed-off-by: Ben Pfaff <blp@ovn.org>
Acked-by: Jarno Rajahalme <jarno@ovn.org>
8 years agoopenflow: Get rid of struct ofp13_packet_in.
Ben Pfaff [Fri, 15 Jan 2016 01:00:57 +0000 (17:00 -0800)]
openflow: Get rid of struct ofp13_packet_in.

It's actually harder to parse OF1.2/OF1.3 "packet-in" messages when
ofp13_packet_in is involved than when the code just realizes that
ofp13_packet_in = ofp12_packet_in + cookie.

Signed-off-by: Ben Pfaff <blp@ovn.org>
Acked-by: Jarno Rajahalme <jarno@ovn.org>
8 years agoofp-print: Decode and print all async config messages the same way.
Ben Pfaff [Fri, 15 Jan 2016 06:16:34 +0000 (22:16 -0800)]
ofp-print: Decode and print all async config messages the same way.

We have a single function to decode all of these messages, so there's no
reason to do it two different ways for printing.

Signed-off-by: Ben Pfaff <blp@ovn.org>
Acked-by: Jarno Rajahalme <jarno@ovn.org>
8 years agoofp-util: Add function to encode OFPT_SET_ASYNC messages.
Ben Pfaff [Fri, 8 Jan 2016 22:49:32 +0000 (14:49 -0800)]
ofp-util: Add function to encode OFPT_SET_ASYNC messages.

This isn't used yet but it will be in future commits.

This also looks forward to supporting Open vSwitch extensions to OAM_*,
which will be coming up soon.

Signed-off-by: Ben Pfaff <blp@ovn.org>
Acked-by: Jarno Rajahalme <jarno@ovn.org>
8 years agoofp-util: Fix OF1.4+ version of ofputil_decode_set_async_config().
Ben Pfaff [Tue, 19 Jan 2016 00:00:34 +0000 (16:00 -0800)]
ofp-util: Fix OF1.4+ version of ofputil_decode_set_async_config().

The OF1.0 through OF1.3 "set async config" set the whole configuration,
OF1.4+ only update parts of it piecemeal, but the decoding function always
set the whole configuration.  This commit fixes the problem by changing the
interface to require the caller to provide an initial state.  (It would
be possible to simply make it mutate existing state in-place, but that
interface seems a little more error-prone.)

Found by inspection.

Signed-off-by: Ben Pfaff <blp@ovn.org>
Acked-by: Jarno Rajahalme <jarno@ovn.org>
8 years agoofp-util: Rewrite async config encoding and decoding to be table-driven.
Ben Pfaff [Wed, 20 Jan 2016 17:46:09 +0000 (09:46 -0800)]
ofp-util: Rewrite async config encoding and decoding to be table-driven.

The encoding and decoding of the OpenFlow and Open vSwitch async config
messages was, until now, a collection of disjoint code that had a lot of
redundancy.  This commit changes it all to be driven using a single central
table.

This rewrite fixes a bug in the OF1.4+ version of the code, which until
now assumed that every TLV in an OF1.4+ asynchronous configuration message
was exactly 8 bytes long, and reported an error if any was a different
length.  This invariant is true of all the standard TLVs already defined,
but it won't be true of any experimenter TLVs (and won't necessarily be
true of any new standard TLVs), so this commit changes it to be more
tolerant.

The OFPACPT_* constants are no longer useful (they are encoded directly
in the table and do not need to be anywhere else), so this removes them.

This commit also adds support for experimenter async config messages.
We don't have any yet but an upcoming commit will add one.

Signed-off-by: Ben Pfaff <blp@ovn.org>
Acked-by: Jarno Rajahalme <jarno@ovn.org>
8 years agoofp-util: Define struct ofputil_async_cfg to hold async message config.
Ben Pfaff [Fri, 15 Jan 2016 05:03:23 +0000 (21:03 -0800)]
ofp-util: Define struct ofputil_async_cfg to hold async message config.

This seems a little better than a pair of bare arrays.

Signed-off-by: Ben Pfaff <blp@ovn.org>
Acked-by: Jarno Rajahalme <jarno@ovn.org>
8 years agoofp-util: New function ofputil_async_msg_type_to_string().
Ben Pfaff [Thu, 7 Jan 2016 20:04:56 +0000 (12:04 -0800)]
ofp-util: New function ofputil_async_msg_type_to_string().

An upcoming commit will add another user.

Signed-off-by: Ben Pfaff <blp@ovn.org>
Acked-by: Jarno Rajahalme <jarno@ovn.org>
8 years agoopenflow: Implement OF1.4+ OFPMP_QUEUE_DESC multipart message.
Ben Pfaff [Tue, 19 Jan 2016 00:00:05 +0000 (16:00 -0800)]
openflow: Implement OF1.4+ OFPMP_QUEUE_DESC multipart message.

OpenFlow 1.0 through 1.3 have a message OFPT_QUEUE_GET_CONFIG_REQUEST and
its corresponding reply, for fetching a description of the queues
configured on a given port.  OpenFlow 1.4 changes this message to a
multipart message OFPMP_QUEUE_DESC, which Open vSwitch has not until now
implemented.  This commit adds an implemntation of that message.  Because
the message is a replacement for the former one, this commit implements it
using the same ofp-util functions as the former message, so that the client
code doesn't have to distinguish a difference between versions.

The ovs-ofctl command queue-get-config was previously undocumented (due
only to an oversight).  This commit corrects that and documents the new
feature available with OpenFlow 1.4.

Signed-off-by: Ben Pfaff <blp@ovn.org>
Acked-by: Jarno Rajahalme <jarno@ovn.org>
8 years agoopenflow: Remove unused (and not useful) property headers.
Ben Pfaff [Wed, 20 Jan 2016 17:23:57 +0000 (09:23 -0800)]
openflow: Remove unused (and not useful) property headers.

These are all just copies of the otherwise generic ofp_prop_header or
ofp_prop_experimenter.

Signed-off-by: Ben Pfaff <blp@ovn.org>
Acked-by: Jarno Rajahalme <jarno@ovn.org>
8 years agoofp-prop: New function ofpprop_put_zeros().
Ben Pfaff [Wed, 20 Jan 2016 17:20:08 +0000 (09:20 -0800)]
ofp-prop: New function ofpprop_put_zeros().

This will have additional users in later commits.

Signed-off-by: Ben Pfaff <blp@ovn.org>
Acked-by: Jarno Rajahalme <jarno@ovn.org>
8 years agoofp-prop: Add helpers for u8, be64/u64, flag, and UUID properties.
Ben Pfaff [Wed, 20 Jan 2016 17:13:59 +0000 (09:13 -0800)]
ofp-prop: Add helpers for u8, be64/u64, flag, and UUID properties.

These will have users in upcoming commits.  Unlike the previously
added helpers, there isn't any existing code that can immediately
use them.

Signed-off-by: Ben Pfaff <blp@ovn.org>
Acked-by: Jarno Rajahalme <jarno@ovn.org>
8 years agoofp-prop: Add generic functions for working with 16- and 32-bit properties.
Ben Pfaff [Wed, 20 Jan 2016 17:05:15 +0000 (09:05 -0800)]
ofp-prop: Add generic functions for working with 16- and 32-bit properties.

These will see increasing use in upcoming commits.

Signed-off-by: Ben Pfaff <blp@ovn.org>
Acked-by: Jarno Rajahalme <jarno@ovn.org>
8 years agoofp-prop: Add support for experimenter properties.
Ben Pfaff [Wed, 20 Jan 2016 16:56:13 +0000 (08:56 -0800)]
ofp-prop: Add support for experimenter properties.

Signed-off-by: Ben Pfaff <blp@ovn.org>
Acked-by: Jarno Rajahalme <jarno@ovn.org>
8 years agoofp-prop: New module for working with OpenFlow 1.3+ properties.
Ben Pfaff [Tue, 29 Dec 2015 14:44:16 +0000 (06:44 -0800)]
ofp-prop: New module for working with OpenFlow 1.3+ properties.

Several OpenFlow 1.3+ messages use TLV-based properties that take a
common form.  Until now, ofp-util has had some static functions for
dealing with properties.  Because properties will start to be needed
outside of ofp-util, this commit breaks them out into a new library,
renaming them to begin with ofpprop_.

The following commit will add a few new interfaces that add new
functionality.

Signed-off-by: Ben Pfaff <blp@ovn.org>
8 years agoofp-errors: Add extension error codes for OF1.3+ property errors.
Ben Pfaff [Mon, 18 Jan 2016 23:06:54 +0000 (15:06 -0800)]
ofp-errors: Add extension error codes for OF1.3+ property errors.

Upcoming commits will introduce uses of the "property" message formats,
which are used in OF1.3 and especially in OF1.4+, in Nicira extension
messages for earlier versions of OpenFlow.  Thus, it's best to also
support the appropriate error codes in those versions of OpenFlow, so that
errors can be reported in a useful way.

Signed-off-by: Ben Pfaff <blp@ovn.org>
Acked-by: Jarno Rajahalme <jarno@ovn.org>
8 years agoofp-util: Improve function to emit a bitmap property.
Ben Pfaff [Wed, 20 Jan 2016 16:22:43 +0000 (08:22 -0800)]
ofp-util: Improve function to emit a bitmap property.

The callers had some common code that could be reasonably encapsulated, so
this commit does so.

Signed-off-by: Ben Pfaff <blp@ovn.org>
Acked-by: Jarno Rajahalme <jarno@ovn.org>
8 years agoofp-actions: Append in ofpacts_pull_openflow_actions(), instead of replace.
Ben Pfaff [Mon, 18 Jan 2016 22:13:16 +0000 (14:13 -0800)]
ofp-actions: Append in ofpacts_pull_openflow_actions(), instead of replace.

An upcoming commit will have a need to parse actions incrementally, so this
change makes that easier to do.

Signed-off-by: Ben Pfaff <blp@ovn.org>
Acked-by: Jarno Rajahalme <jarno@ovn.org>
8 years agoovs-ofctl: Merge dump_stats_transaction() into dump_transaction().
Ben Pfaff [Thu, 24 Dec 2015 23:44:31 +0000 (15:44 -0800)]
ovs-ofctl: Merge dump_stats_transaction() into dump_transaction().

The callers call dump_stats_transaction() for OFPST_* messages and
dump_transaction() for other messages, but the callee can easily
distinguish the two types, so this commit eliminates the difference for the
callers to simplify use.

This will be more valuable in an upcoming commit in which a single
ofputil_encode_*() function can produce an OFPT_* request for some
OpenFlow versions and an OFPST_* request for others.  (Specifically, OF1.4
changes OFPT_QUEUE_GET_CONFIG_REQUEST into OFPST_QUEUE_DESC.)

Also merges dump_trivial_stats_transaction() into
dump_trivial_transaction() for the same reason.

Signed-off-by: Ben Pfaff <blp@ovn.org>
Acked-by: Jarno Rajahalme <jarno@ovn.org>
8 years agonetdev-dummy: Add a dummy queue.
Ben Pfaff [Wed, 20 Jan 2016 16:16:09 +0000 (08:16 -0800)]
netdev-dummy: Add a dummy queue.

Until now it's been pretty hard to properly test any of the queue support,
because the dummy network device doesn't have any queues.  By adding one
queue to the dummy network device (queue 0), we can get slightly higher
confidence that OVS queue support works correctly.  I suppose we could do
even better if we made the dummy network device support modifying the
queues, but that's a job for another day.

Signed-off-by: Ben Pfaff <blp@ovn.org>
8 years agoopenflow: Rename OF0.1-1.3 queue property constants.
Ben Pfaff [Wed, 20 Jan 2016 16:05:20 +0000 (08:05 -0800)]
openflow: Rename OF0.1-1.3 queue property constants.

At first glance, OF1.4 queue properties look a lot like those for OF1.0
to OF1.3, but in fact their different padding makes them incompatible.  In
addition, OF1.4 switches from using regular OpenFlow messages to request
queue properties, to using multipart messages.  Thus, we really need to
use separate code to deal with OF1.4 queues.

OF1.0, OF1.1, and OF1.2 all have slightly different queue config reply
messages, but only OF1.0 and OF1.2 had tests, so this adds tests.  (There
is no test for OF1.3 because it's the same as OF1.2.)

Signed-off-by: Ben Pfaff <blp@ovn.org>
Acked-by: Jarno Rajahalme <jarno@ovn.org>
8 years agoofp-print: Improve formatting of queue stat requests and port_mods.
Ben Pfaff [Thu, 24 Dec 2015 23:29:26 +0000 (15:29 -0800)]
ofp-print: Improve formatting of queue stat requests and port_mods.

Without this, OFPST_QUEUE requests are formatted as:
    OFPST_QUEUE request:port=LOCAL queue=5
With this commit, OFPST_QUEUE requests are formatted as:
    OFPST_QUEUE request: port=LOCAL queue=5
which looks better.

Similarly for OFPT_PORT_MOD.

Signed-off-by: Ben Pfaff <blp@ovn.org>
Acked-by: Jarno Rajahalme <jarno@ovn.org>
8 years agopinsched: Remove obsolete ofpbuf_trim().
Ben Pfaff [Tue, 5 Jan 2016 19:42:51 +0000 (11:42 -0800)]
pinsched: Remove obsolete ofpbuf_trim().

This call to ofpbuf_trim() comes from a time when the packets passed to
pinsched came directly from a dpif.  For some time now that's no longer
true--now they are messages generated by ofputil_encode_packet_in(), which
generally are well sized and do not benefit from trimming.

This is not a bug fix--the code is equally correct either way, it's only
the rationale for trimming that's obsolete.

Signed-off-by: Ben Pfaff <blp@ovn.org>
Acked-by: Jarno Rajahalme <jarno@ovn.org>
8 years agoopenflow-1.2: Remove unused struct definition.
Ben Pfaff [Wed, 6 Jan 2016 21:56:29 +0000 (13:56 -0800)]
openflow-1.2: Remove unused struct definition.

Experimenter stats are handled by code in ofp-msgs, and this struct isn't
good for anything.

Signed-off-by: Ben Pfaff <blp@ovn.org>
Acked-by: Jarno Rajahalme <jarno@ovn.org>
8 years agoofp-util: Improve formatting of comment.
Ben Pfaff [Thu, 7 Jan 2016 20:03:28 +0000 (12:03 -0800)]
ofp-util: Improve formatting of comment.

Signed-off-by: Ben Pfaff <blp@ovn.org>
Acked-by: Jarno Rajahalme <jarno@ovn.org>
8 years agoofp-msgs: Fix comments.
Ben Pfaff [Thu, 24 Dec 2015 23:47:56 +0000 (15:47 -0800)]
ofp-msgs: Fix comments.

ofpbuf used to have members named 'frame' and 'l3' but now they're 'header'
and 'msg'.

Signed-off-by: Ben Pfaff <blp@ovn.org>
Acked-by: Jarno Rajahalme <jarno@ovn.org>
8 years agoofp-msgs: Fix definitions of OF1.4 OFPT_GET_ASYNC_REPLY and OFPT_SET_ASYNC.
Ben Pfaff [Wed, 6 Jan 2016 21:38:20 +0000 (13:38 -0800)]
ofp-msgs: Fix definitions of OF1.4 OFPT_GET_ASYNC_REPLY and OFPT_SET_ASYNC.

The structures declared in ofp-msgs.h for messages definitions should not
include an OpenFlow header (its presence is implied), but the definition of
these messages did.  This commit fixes the definitions.

The visible bug was really minor here: messages of these kinds without any
TLVs would be rejected by the OpenFlow parser.  But OVS never sends these
messages without TLVs, so probably no one ever noticed this.  (Also, the
OVS support for OF1.4 is still incomplete and experimental.)

Signed-off-by: Ben Pfaff <blp@ovn.org>
Acked-by: Jarno Rajahalme <jarno@ovn.org>
8 years agolearning-switch: Use "if"s instead of "switch" to reduce maintenance.
Ben Pfaff [Mon, 18 Jan 2016 22:49:47 +0000 (14:49 -0800)]
learning-switch: Use "if"s instead of "switch" to reduce maintenance.

This code only cares about a very few kinds of OpenFlow messages, and it's
unlikely that it will care about new ones, so replace the "switch" by "if"
statements so that GCC won't complain about every new message.

Signed-off-by: Ben Pfaff <blp@ovn.org>
Acked-by: Jarno Rajahalme <jarno@ovn.org>
8 years agoofproto: Fix memory leak and memory exhaustion bugs in group_mod.
Ben Pfaff [Thu, 14 Jan 2016 06:15:09 +0000 (22:15 -0800)]
ofproto: Fix memory leak and memory exhaustion bugs in group_mod.

In handle_group_mod() cases where adding a group failed, nothing freed the
list of buckets, causing a leak.  The same was true in every case of
modifying a group.  This commit fixes the problem by changing add_group()
to never steal or free the buckets (modify_group() already acted this way)
and then making handle_group_mod() always free the buckets when it's done.

This approach might at first raise objections, because it makes add_group()
copy the buckets instead of just take the existing ones.  But it actually
fixes a worse problem too: when OF1.4+ REQUESTFORWARD is enabled, the
group_mod is reused for the request forwarding.  Until now, for a group_mod
that adds a new group and that has some buckets, the previous stealing of
buckets in add_group() meant that the group_mod's buckets were no longer
valid; in practice, the list of buckets became linked in a way that
iteration never terminated, which caused memory to be exhausted while
composing the requestforward message.  By making add_group() no longer
modify the group_mod, we also fix this problem.

The requestforward test in the testsuite did not find the latter problem
because it only added a group without any buckets.  This commit also
updates the testsuite to include a bucket in its group_mod, which would
have found the problem.

Found by pain and suffering.

Signed-off-by: Ben Pfaff <blp@ovn.org>
Acked-by: Jarno Rajahalme <jarno@ovn.org>
8 years agoofproto: Wildcard TTL on IP tunnels
Haggai Eran [Thu, 14 Jan 2016 11:29:08 +0000 (13:29 +0200)]
ofproto: Wildcard TTL on IP tunnels

There is no need to set the mask on the outer header IP TTL [1]. The only requirement
is that the TTL will be non-zero. Clear the mask in tnl_wc_init().

[1] OVS VXLAN decap rule has full match on TTL for the outer headers?
    http://www.spinics.net/lists/netdev/msg351961.html

Cc: Jesse Gross <jesse@kernel.org>
Cc: Joe Stringer <joe@ovn.org>
Signed-off-by: Haggai Eran <haggaie@mellanox.com>
Signed-off-by: Jesse Gross <jesse@kernel.org>
8 years agoodp-util: Accept fields with zero mask
Haggai Eran [Thu, 14 Jan 2016 11:29:07 +0000 (13:29 +0200)]
odp-util: Accept fields with zero mask

It is possible to pass some fields to the kernel with a zero mask, but
ovs-dpctl doesn't currently allow it. Change the code to allow it to
mimic what vswitchd is allowed to do.

Signed-off-by: Haggai Eran <haggaie@mellanox.com>
Signed-off-by: Jesse Gross <jesse@kernel.org>
8 years agoovn-tutorial: fix a typo
William Tu [Sun, 17 Jan 2016 01:23:15 +0000 (17:23 -0800)]
ovn-tutorial: fix a typo

switch_in_pre_acl -> switch_out_pre_acl

Signed-off-by: William Tu <u9012063@gmail.com>
Signed-off-by: Russell Bryant <russell@ovn.org>
8 years agotests: Update ovn localnet test case.
Russell Bryant [Thu, 14 Jan 2016 20:36:17 +0000 (15:36 -0500)]
tests: Update ovn localnet test case.

The OVN localnet port test case did not cover having 2 ports on the same
network and on the same hypervisor.  It also turns out that this case is
broken.  Update the test case to demonstrate the problem.  A solution
should be able to uncomment these additional test_packet lines and have
the test case still pass.

Reported-at: http://openvswitch.org/pipermail/dev/2016-January/064413.html
Signed-off-by: Russell Bryant <russell@ovn.org>
Acked-by: Han Zhou <zhouhan@gmail.com>
8 years agoovn: Use assigned Geneve class.
Jesse Gross [Thu, 14 Jan 2016 22:25:17 +0000 (14:25 -0800)]
ovn: Use assigned Geneve class.

The most recent version of the Geneve draft included an option
class assignment for OVN:
https://tools.ietf.org/html/draft-ietf-nvo3-geneve-01

As a result, we can stop using the experimental class and switch to
the allocated one (0x0102).

Signed-off-by: Jesse Gross <jesse@kernel.org>
Acked-by: Ben Pfaff <blp@ovn.org>
8 years agodatapath: STT: Fix nf-hook softlockup.
Pravin B Shelar [Thu, 14 Jan 2016 00:42:10 +0000 (16:42 -0800)]
datapath: STT: Fix nf-hook softlockup.

nf-hook is not unregistered on STT device delete, But when
second time it was created it nf-hook is again registered.
which causes following softlockup.
Following patch fixes it by registering nf-hook only on very
first stt device.

---8<---

BUG: soft lockup - CPU#1 stuck for 22s! [ovs-vswitchd:11293]
RIP: 0010:[<ffffffffa0e48308>]  [<ffffffffa0e48308>] nf_ip_hook+0xf8/0x180 [openvswitch]
Stack:
 <IRQ>
 [<ffffffff8163bf60>] ? ip_rcv_finish+0x350/0x350
 [<ffffffff8163572a>] nf_iterate+0x9a/0xb0
 [<ffffffff8163bf60>] ? ip_rcv_finish+0x350/0x350
 [<ffffffff816357bc>] nf_hook_slow+0x7c/0x120
 [<ffffffff8163bf60>] ? ip_rcv_finish+0x350/0x350
 [<ffffffff8163c343>] ip_local_deliver+0x73/0x80
 [<ffffffff8163bc8d>] ip_rcv_finish+0x7d/0x350
 [<ffffffff8163c5e8>] ip_rcv+0x298/0x3d0
 [<ffffffff81605f26>] __netif_receive_skb_core+0x696/0x880
 [<ffffffff81606128>] __netif_receive_skb+0x18/0x60
 [<ffffffff81606cce>] process_backlog+0xae/0x180
 [<ffffffff81606512>] net_rx_action+0x152/0x270
 [<ffffffff8106accc>] __do_softirq+0xec/0x300
 [<ffffffff81710a1c>] do_softirq_own_stack+0x1c/0x30

Fixes: fee43fa2 ("datapath: Fix deadlock on STT device destroy.")
Signed-off-by: Pravin B Shelar <pshelar@nicira.com>
Tested-by: Joe Stringer <joe@ovn.org>
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>