ofproto-dpif: Correct endian problem in recv_upcalls()

Use nl_attr_get_u32() instead of nl_attr_get_be32() to parse nla
so that the decoded value which is passed to mhash_add()
is host byte order as mhash_add() expects.

This resolves a minor regression introduced by
10e576406c7444ef ("ofproto-dpif: Move special upcall handling into
ofproto-dpif-upcall.").

I do not expect this change has any runtime implications.

Detected using sparse.

Cc: Ethan Jackson <ethan@nicira.com>
Cc: Ben Pfaff <blp@nicira.com>
Signed-off-by: Simon Horman <horms@verge.net.au>
Signed-off-by: Ben Pfaff <blp@nicira.com>
rhel: fix the exit status of the openvswitch init script.

This is a fix for a request to make sure that the openvswitch status command
in rhel based distros gives a useful exit status. That was fixed in

commit 5e0c05bc058c78a11be6747f62e6ad88e5d06b70
debian: Fix exit status of openvswitch-switch init script "status" command

Signed-off-by: Duffie Cooley <dcooley@nicira.com>
Signed-off-by: Ben Pfaff <blp@nicira.com>
coverage: Reimplement the "ovs-appctl coverage/show" command.

This commit changes the "ovs-appctl coverage/show" command to show the
the averaged per-second rates for the last few seconds, the last minute
and the last hour, and the total counts of all of the coverage counters.

Signed-off-by: Alex Wang <alexw@nicira.com>
Signed-off-by: Ethan Jackson <ethan@nicira.com>
Acked-by: Ethan Jackson <ethan@nicira.com>
ofproto-dpif: Compute the subfacet add/del rate using coverage counters.

So far, the subfacet rates (e.g. add rate, del rate) are computed by
exponential moving averaging function in ofproto-dpif.c.  This commit
replaces that logic with coverage counters.  And the rates can be
checked by running "ovs-appctl coverage/show" command.

Signed-off-by: Alex Wang <alexw@nicira.com>
Signed-off-by: Ethan Jackson <ethan@nicira.com>
Acked-by: Ethan Jackson <ethan@nicira.com>
datapath: Fix vxlan gso with vlan.

To use ovs-gso-compatibility we need to record inner skb offset.
In case of vxlan it is done before vlan header is pushed which
gives wrong inner packet to ovs-gso.
Following patch reset skb offsets after inner skb is completely built.

Signed-off-by: Pravin B Shelar <pshelar@nicira.com>
Acked-by: Jesse Gross <jesse@nicira.com>
Don't differentiate between TCP and SSL ports for OpenFlow and OVSDB.

The OVS code has always made a distinction between the unencrypted (TCP)
and SSL port numbers for the OpenFlow and OVSDB protocols.  The default
port numbers for both protocols has changed, and there continues to be
no distinction between the unencrypted and SSL versions.  This
commit removes the distinction in port numbers.  A future patch will
recognize the change in default port number.

Signed-off-by: Justin Pettit <jpettit@nicira.com>
Acked-by: Ben Pfaff <blp@nicira.com>
ovsdb: Define official port number.

Signed-off-by: Justin Pettit <jpettit@nicira.com>
Acked-by: Ben Pfaff <blp@nicira.com>
ofproto: Define official OpenFlow port number.

Signed-off-by: Justin Pettit <jpettit@nicira.com>
Acked-by: Ben Pfaff <blp@nicira.com>
stream: Log a warning when the default OpenFlow or OVSDB port is used.

Both OpenFlow and OVSDB have new IANA-assigned port numbers.  We still
default to the original values (6633 and 6632, respectively), but this
commit logs a warning.  In the future, we will switch to the official
values (6653 and 6640, respectively).

Signed-off-by: Justin Pettit <jpettit@nicira.com>
Acked-by: Ben Pfaff <blp@nicira.com>
ovs-dpctl, ofproto/trace: Show and handle the in_port name in flows.

With this commit, whenever the verbosity is enabled with '-m'
option, the ovs-dpctl dump-flows command will display the flows with
in_port field showing the name instead of a port number.

Conversely, one can also use a name in the in_port field with del-flow,
add-flow and mod-flow commands of ovs-dpctl. One should also be able
to use the port name when supplying the datapath flow as an input
to ofproto/trace command.

Signed-off-by: Gurucharan Shetty <gshetty@nicira.com>
Acked-by: Ben Pfaff <blp@nicira.com>
ovs-lib: Return the exit status of ovs-ctl in ovs_ctl().

commit 46528f78e5c(debian, rhel, xenserver: Ability to collect ovs-ctl logs)
made changes in the startup scripts such that the o/p of ovs-ctl is logged
into ovs-ctl.log. But it had an unintended consequence that the exit status
of ovs-ctl was no longer returned. We would always return success(the exit
status of tee).

With this commit, we return the exit status of ovs-ctl instead of tee.
Code referenced from: (line wrapped).
http://unix.stackexchange.com/questions/14270/\
get-exit-status-of-process-thats-piped-to-another/70675#70675)

Signed-off-by: Gurucharan Shetty <gshetty@nicira.com>
Signed-off-by: Duffie Cooley <dcooley@nicira.com>
Acked-by: Ben Pfaff <blp@nicira.com>
ofproto-dpif-upcall: reduce number of wakeup

If a queue length is long (ie. non-0), the consumer thread should
already be busy working on the queue.  there's no need to wake it
up repeatedly.

Signed-off-by: YAMAMOTO Takashi <yamt@mwd.biglobe.ne.jp>
Signed-off-by: Ben Pfaff <blp@nicira.com>
ofproto-dpif-upcall: Remove dead code from recv_upcalls().

Signed-off-by: Ben Pfaff <blp@nicira.com>
util: use gcc builtins to better check array sizes

GCC provides two useful builtin functions that can help
to improve array size checking during compilation.

This patch contains no functional changes, but it makes
it easier to detect mistakes.

Signed-off-by: Flavio Leitner <fbl@redhat.com>
Signed-off-by: Ben Pfaff <blp@nicira.com>
signals: Don't assume that sys_siglist is an array.

Found by commit 878f1972909b3 (util: use gcc builtins to better check array
sizes).

Signed-off-by: YAMAMOTO Takashi <yamt@mwd.biglobe.ne.jp>
Signed-off-by: Ben Pfaff <blp@nicira.com>
datapath: Restructure datapath.c and flow.c

Over the time datapath.c and flow.c has became pretty large files.
Following patch restructures functionality of component into three
different components:

flow.c: contains flow extract.
flow_netlink.c: netlink flow api.
flow_table.c: flow table api.

Diffstat is showing wrong count. This patch mostly restructures code
without changing logic.

Signed-off-by: Pravin B Shelar <pshelar@nicira.com>
Acked-by: Jesse Gross <jesse@nicira.com>
datapath: Move mega-flow list out of rehashing struct.

ovs-flow rehash does not touch mega flow list. Following patch
moves it dp struct datapath.  Avoid one extra indirection for
accessing mega-flow list head on every packet receive.

Signed-off-by: Pravin B Shelar <pshelar@nicira.com>
Acked-by: Jesse Gross <jesse@nicira.com>
datapath: Simplify mega-flow APIs.

Hides mega-flow implementation in flow_table.c rather than
datapath.c.

Signed-off-by: Pravin B Shelar <pshelar@nicira.com>
Acked-by: Jesse Gross <jesse@nicira.com>