cascardo/ovs.git
10 years agovlan-splinter: Fix inverted logic bug. v1.9.3
Alex Wang [Tue, 23 Jul 2013 01:15:49 +0000 (18:15 -0700)]
vlan-splinter: Fix inverted logic bug.

When "other-config:enable-vlan-splinters=true" is set, the existing
vlans with ip address must be retained. The bug actually does the
opposite and retains the vlans without ip address. This commit fixes
it.

Reported-by: Roman Sokolkov <rsokolkov@gmail.com>
Signed-off-by: Alex Wang <alexw@nicira.com>
Signed-off-by: Ben Pfaff <blp@nicira.com>
10 years agoofproto: Convert units correctly in ofport_open().
Ben Pfaff [Wed, 4 Sep 2013 20:37:56 +0000 (13:37 -0700)]
ofproto: Convert units correctly in ofport_open().

netdev_features_to_bps() returns a speed in bps, but struct
ofputil_phy_port's curr_speed and max_speed are in kbps, so a conversion
is necessary.  This commit fixes the problem.

Reported-by: Benjamin Lunsky <benjamin.lunsky@netronome.com>
Tested-by: Benjamin Lunsky <benjamin.lunsky@netronome.com>
Signed-off-by: Ben Pfaff <blp@nicira.com>
10 years agoDeclare the version as "1.9.3".
Justin Pettit [Fri, 30 Aug 2013 00:03:27 +0000 (17:03 -0700)]
Declare the version as "1.9.3".

Signed-off-by: Justin Pettit <jpettit@nicira.com>
Acked-by: Ben Pfaff <blp@nicira.com>
10 years agopackets: Introduce IPv6 headers not aligned on a 32-bit boundary.
Ben Pfaff [Thu, 15 Aug 2013 18:07:24 +0000 (11:07 -0700)]
packets: Introduce IPv6 headers not aligned on a 32-bit boundary.

This fixes the same problem for IPv6 headers treated for other headers in
the previous commit.

Signed-off-by: Ben Pfaff <blp@nicira.com>
10 years agopackets: Do not assume that IPv4, TCP, or ARP headers are 32-bit aligned.
Ben Pfaff [Thu, 15 Aug 2013 17:47:39 +0000 (10:47 -0700)]
packets: Do not assume that IPv4, TCP, or ARP headers are 32-bit aligned.

Ethernet headers are 14 bytes long, so when the beginning of such a header
is 32-bit aligned, the following data is misaligned.  The usual trick to
fix that is to start the Ethernet header on an odd-numbered 16-bit
boundary.  That trick works OK for Open vSwitch, but there are two
problems:

   - OVS doesn't use that trick everywhere.  Maybe it should, but it's
     difficult to make sure that it does consistently because the CPUs
     most commonly used with OVS don't care about misalignment, so we
     only find problems when porting.

   - Some protocols (GRE, VXLAN) don't use that trick, so in such a case
     one can properly align the inner or outer L3/L4/L7 but not both.  (OVS
     userspace doesn't directly deal with such protocols yet, so this is
     just future-proofing.)

   - OpenFlow uses the alignment trick in a few places but not all of them.

This commit starts the adoption of what I hope will be a more robust way
to avoid misalignment problems and the resulting bus errors on RISC
architectures.  Instead of trying to ensure that 32-bit quantities are
always aligned, we always read them as if they were misaligned.  To ensure
that they are read this way, we change their types from 32-bit types to
pairs of 16-bit types.  (I don't know of any protocols that offset the
next header by an odd number of bytes, so a 16-bit alignment assumption
seems OK.)

The same would be necessary for 64-bit types in protocol headers, but we
don't yet have any protocol definitions with 64-bit types.

IPv6 protocol headers need the same treatment, but for those we rely on
structs provided by system headers, so I'll leave them for an upcoming
patch.

Signed-off-by: Ben Pfaff <blp@nicira.com>
10 years agoofproto: Remove obsolete comment and assertion.
Ben Pfaff [Wed, 14 Aug 2013 23:26:05 +0000 (16:26 -0700)]
ofproto: Remove obsolete comment and assertion.

At one time, the ofproto-dpif implementation of the 'rule_execute' member
function required, indirectly, at least struct(ofp10_packet_in) bytes of
headroom in the packet passed into it.  (This allowed constructing an
OFPT_PACKET_IN without allocating and copying a new ofpbuf.)  This
restriction has long been lifted, but rule_execute() had not yet caught
up.  This commit updates it.

Signed-off-by: Ben Pfaff <blp@nicira.com>
10 years agoofproto-dpif: Destroy bundle after moving its last port out.
Ben Pfaff [Wed, 14 Aug 2013 00:44:14 +0000 (17:44 -0700)]
ofproto-dpif: Destroy bundle after moving its last port out.

When the ofp_port argument to bundle_add_port() refers to an ofport_dpif
that already belongs to some other bundle, bundle_add_port() removed
the port from the other bundle, correctly, with bundle_del_port().
If the other bundle now contained no ports, however, this violated the
invariant that a bundle always contains at least one port.

Normally, this would get fixed up when the other bundle was processed
later during reconfiguration.  I haven't quite zeroed in on the exact
case where this is not true, but segfaults have happened here in
production, in particular when port adds and deletes happen simultaneously
and the new port reuses the OpenFlow port number of one of the deleted
ports.  It seems that the duplicate port number allows some port to rip
away the new port from its bundle without destroying that bundle.  I
suspect, therefore, that there is still a more subtle bug here, but I
hope that this will fix the segfault.

Bug #18967.
Signed-off-by: Ben Pfaff <blp@nicira.com>
10 years agodebian: Fix build with old versions of dpkg-buildflags.
Ben Pfaff [Tue, 13 Aug 2013 19:54:35 +0000 (12:54 -0700)]
debian: Fix build with old versions of dpkg-buildflags.

dpkg-buildflags has not always supported --export=configure, but commit
6c2d4c8780 (debian: Apply hardening options to build.) used it
unconditionally, causing the build to fail on old Debian distributions.
This fixes the problem.

Signed-off-by: Ben Pfaff <blp@nicira.com>
10 years agoovs-ofctl: Avoid groff warning due to too-long line.
Ben Pfaff [Mon, 12 Aug 2013 22:11:35 +0000 (15:11 -0700)]
ovs-ofctl: Avoid groff warning due to too-long line.

Avoids these warnings from groff:

<standard input>:1037: warning [p 14, 6.0i]: cannot adjust line
<standard input>:1037: warning [p 14, 6.2i]: can't break line

Found by lintian.

Signed-off-by: Ben Pfaff <blp@nicira.com>
10 years agodebian: Apply hardening options to build.
Ben Pfaff [Mon, 12 Aug 2013 22:10:39 +0000 (15:10 -0700)]
debian: Apply hardening options to build.

Debian now encourages building every program with various GCC hardening
options.  This commit implements that recommendation for Open vSwitch.

See https://wiki.debian.org/Hardening for details.

Found by lintian.

Signed-off-by: Ben Pfaff <blp@nicira.com>
10 years agonetlink-socket: Don't bother logging SO_RCVBUFFORCE failure as non-root.
Ben Pfaff [Fri, 17 Aug 2012 22:40:03 +0000 (15:40 -0700)]
netlink-socket: Don't bother logging SO_RCVBUFFORCE failure as non-root.

Some Open vSwitch utilities can do useful work when they are not run as
root.  Without this commit, these utilities will log a warning on failure
to use the SO_RCVBUFFORCE socket option if they open any Netlink sockets.
This will always happen, it does not report anything unexpected or
fixable as non-root, and sometimes it makes users wonder if something is
wrong, so there is no benefit to logging it.  This commit drops it in that
case.

Signed-off-by: Ben Pfaff <blp@nicira.com>
10 years agotests: Tolerate init process pid != 1.
James Page [Thu, 20 Jun 2013 21:31:52 +0000 (22:31 +0100)]
tests: Tolerate init process pid != 1.

On Ubuntu Saucy based desktops, upstart runs with user sessions
enabled which means that the init process under which a daemon
might run is not always pid = 1.

Instead of checking for pid = 1, check to ensure that the parent
pid of the monitor is not the pid of the shell that started it.

Signed-off-by: James Page <james.page@ubuntu.com>
Signed-off-by: Ben Pfaff <blp@nicira.com>
10 years agoodp-util: Use proper formatting for ODP port number.
Jarno Rajahalme [Fri, 14 Jun 2013 14:09:34 +0000 (17:09 +0300)]
odp-util: Use proper formatting for ODP port number.

Signed-off-by: Jarno Rajahalme <jarno.rajahalme@nsn.com>
Signed-off-by: Ben Pfaff <blp@nicira.com>
10 years agoofproto: Fix use of uninitialized local variable.
Jarno Rajahalme [Fri, 14 Jun 2013 14:09:33 +0000 (17:09 +0300)]
ofproto: Fix use of uninitialized local variable.

Also make the table id arithmetic less confusing.

Signed-off-by: Jarno Rajahalme <jarno.rajahalme@nsn.com>
Signed-off-by: Ben Pfaff <blp@nicira.com>
10 years agoovsdb-idlc: Write a new-line at the end of "annotate" output.
Ben Pfaff [Mon, 10 Jun 2013 17:25:29 +0000 (10:25 -0700)]
ovsdb-idlc: Write a new-line at the end of "annotate" output.

Some tools do not like text files that lack a trailing new-line.  In
particular, Debian's dpkg-source utility complains about a missing new-line
in the file generated by ovsdb-idlc:

    dpkg-source: warning: file
    openvswitch-1.9.2+git20130605/lib/vswitch-idl.ovsidl has no final
    newline (either original or modified version)

This commit fixes the problem.

Signed-off-by: Ben Pfaff <blp@nicira.com>
Acked-by: Ethan Jackson <ethan@nicira.com>
10 years agoofproto-dpif: Do not give stats to rules bypassed by "drop" frag policy.
Ben Pfaff [Wed, 5 Jun 2013 17:49:56 +0000 (10:49 -0700)]
ofproto-dpif: Do not give stats to rules bypassed by "drop" frag policy.

When the OFPC_FRAG_DROP policy is in effect, IP fragments are supposed to
be dropped before they reach the flow table.  Open vSwitch properly dropped
IP fragments in this case, but still accounted them to the packet and byte
counters for the flow that they would have hit if the OFPC_FRAG_NX_MATCh
policy had been in effect.

Reported-by: love you <thunder.love07@gmail.com>
Signed-off-by: Ben Pfaff <blp@nicira.com>
Acked-by: Ethan Jackson <ethan@nicira.com>
10 years agoofproto-dpif: Don't count misses in OpenFlow table stats.
Jesse Gross [Sat, 25 May 2013 00:01:34 +0000 (17:01 -0700)]
ofproto-dpif: Don't count misses in OpenFlow table stats.

Originally no rule existed for packets that did not match an
OpenFlow flow and therefore every packet with a rule could be
counted as a hit. However, newer versions of OVS have hidden
miss rules so this is no longer true. To return the correct
table stats, this subtracts packets that hit the miss rule
from the total and removes the separate counter.

Reported-by: love you <thunder.love07@gmail.com>
Signed-off-by: Jesse Gross <jesse@nicira.com>
10 years agopackets: Fix typo in reserved multicast Ethernet addresses.
Ben Pfaff [Tue, 28 May 2013 23:05:34 +0000 (16:05 -0700)]
packets: Fix typo in reserved multicast Ethernet addresses.

The reserved multicast Ethernet addresses begin with 01:80:c2, not
01:08:c2.

Reported-by: Padmanabhan Krishnan <kprad1@yahoo.com>
Signed-off-by: Ben Pfaff <blp@nicira.com>
Acked-by: Ethan Jackson <ethan@nicira.com>
10 years agoAlways use valid ids pointer in dec_ttl_cnt_ids_from_openflow()
Simon Horman [Mon, 3 Jun 2013 05:46:30 +0000 (14:46 +0900)]
Always use valid ids pointer in dec_ttl_cnt_ids_from_openflow()

Always update the ids pointer after calling ofpbuf_put()
to ensure that it is valid when accessed.

During testing a case came up where the call to ofpbuf_put() in the
for (i = 0; i < ids->n_controllers; i++) loop would cause the underlying
buffer to be reallocated. This resulted in ids->n_controllers being an
incorrect value, the loop continuing on longer than desired and finally a
segmentation fault.

Reported-by: Joe Stringer <joe@wand.net.nz>
Signed-off-by: Simon Horman <horms@verge.net.au>
Signed-off-by: Ben Pfaff <blp@nicira.com>
10 years agodebian: Don't fail ovs-controller restart if daemon not running.
Gurucharan Shetty [Wed, 29 May 2013 00:18:12 +0000 (17:18 -0700)]
debian: Don't fail ovs-controller restart if daemon not running.

Reported-by: Maxime Brun <m.brun@alphalink.fr>
Signed-off-by: Gurucharan Shetty <gshetty@nicira.com>
10 years agoovs-xapi-sync: Handle exceptions from XAPI for get_single_bridge_id.
Gurucharan Shetty [Thu, 23 May 2013 23:14:19 +0000 (16:14 -0700)]
ovs-xapi-sync: Handle exceptions from XAPI for get_single_bridge_id.

There are possibilities when records disappear underneath ovs-xapi-sync.
In this particular case, when VLAN network was deleted, the corresponding
record in bridge's external_ids:xs_network_ids column was not deleted by
xenserver.  In situations like that handle the exceptions cleanly.

Bug #17390.
Signed-off-by: Gurucharan Shetty <gshetty@nicira.com>
10 years agoovs-xapi-sync: Handle multiple xs-network-uuids for xs 6.1.
Gurucharan Shetty [Sun, 19 May 2013 07:05:09 +0000 (00:05 -0700)]
ovs-xapi-sync: Handle multiple xs-network-uuids for xs 6.1.

For xenservers with version less than 6.1, interface reconfiguration
happened through interface-reconfigure scripts in this repo. In cases
where there were multiple xs-network-uuids for a single bridge,
interface-reconfigure script would add the network uuid associated
with the non-VLAN network as the first record. ovs-xapi-sync would
just blindly use the first record to create the bridge-id

But it looks like for xenserver 6.1, interface-reconfigure script
is no longer used and xenserver natively writes the xs-network-uuids.
So, in ovs-xapi-sync we no longer can copy the first value in
xs-network-uuids as bridge-id. This commit fetches the PIF record
for each xs-network-uuids and the network that does not have a VLAN
associated with it is copied over to bridge-id.

Bug #17090.
Signed-off-by: Gurucharan Shetty <gshetty@nicira.com>
10 years agodatapath: Fix compilation with Linux kernel 3.7.
Pravin B Shelar [Mon, 13 May 2013 22:53:06 +0000 (15:53 -0700)]
datapath: Fix compilation with Linux kernel 3.7.

Definition of __sum16 and __wsum is moved to uapi header.
Following patch adds check in config script for second possible
header.

Signed-off-by: Pravin B Shelar <pshelar@nicira.com>
Acked-by: Jesse Gross <jesse@nicira.com>
10 years agoofproto-dpif: Make fin_timeout work when governor kicks in.
Ben Pfaff [Sun, 12 May 2013 21:53:51 +0000 (14:53 -0700)]
ofproto-dpif: Make fin_timeout work when governor kicks in.

The xlate_actions() call in handle_flow_miss_without_facet() didn't
implement fin_timeout properly because tcp_flags wasn't getting set.

I have not tested that this fixes the problem, but it seems "obviously
correct".

Bug #16506.
Reported-by: Ying Chen <yingchen@vmware.com>
Signed-off-by: Ben Pfaff <blp@nicira.com>
Signed-off-by: Ethan Jackson <ethan@nicira.com>
Acked-by: Ethan Jackson <ethan@nicira.com>
10 years agoflow: Fix IPv6 fragment packet handling
Takashi Kawaguchi [Thu, 9 May 2013 17:39:34 +0000 (02:39 +0900)]
flow: Fix IPv6 fragment packet handling

IPv6 fragmented packet (except first fragment) will not be handled
correctly. When extracting packet at parse_ipv6(), although nw_frag
should have both of FLOW_NW_FRAG_ANY and FLOW_NW_FRAG_LATER for
later fragment, only FLOW_NW_FRAG_LATER is set.

Signed-off-by: Takashi Kawaguchi <kawaguchi-takashi@mxd.nes.nec.co.jp>
Signed-off-by: Ken Ajiro <ajiro@mxw.nes.nec.co.jp>
Signed-off-by: Jesse Gross <jesse@nicira.com>
10 years agoovsdb-client: Fix recently introduced svec_sort() bug.
Justin Pettit [Tue, 7 May 2013 04:30:26 +0000 (21:30 -0700)]
ovsdb-client: Fix recently introduced svec_sort() bug.

Commit 66980be9 (ovsdb-client: Avoid assertion with multiple databases.)
passed in a pointer to an svec pointer, when it should have just been an
svec pointer.  This corrects the bug.

Signed-off-by: Justin Pettit <jpettit@nicira.com>
10 years agoovsdb-client: Avoid assertion with multiple databases.
Justin Pettit [Mon, 6 May 2013 19:43:48 +0000 (12:43 -0700)]
ovsdb-client: Avoid assertion with multiple databases.

When using ovsdb-client with an ovsdb-server with multiple databases, an
assertion could trigger due to them being returned in non-sorted order.
This commit changes the fetch_dbs() function to always return databases
in sorted order, since both callers are expecting that behavior.

Bug #16882

Signed-off-by: Justin Pettit <jpettit@nicira.com>
Reported-by: Spiro Kourtessis <spiro@vmware.com>
10 years agoovsdb: Allow recovery from transient write errors in log implementation.
Ben Pfaff [Fri, 1 Mar 2013 19:16:24 +0000 (11:16 -0800)]
ovsdb: Allow recovery from transient write errors in log implementation.

Until now, the OVSDB data journaling implementation has made write errors
"sticky", so that a single write error persists as long as ovsdb-server is
alive.  However, some kinds of write errors (such as ENOSPC) can be
transient in practice.  I don't know of a good reason to make such errors
sticky, so this commit makes the journaling code retry writes even after
an error occurs, allowing ovsdb-server to recover from transient errors.

Reported-by: likunyun <kunyunli@hotmail.com>
Signed-off-by: Ben Pfaff <blp@nicira.com>
Acked-by: Ethan Jackson <ethan@nicira.com>
10 years agodatapath: Account for RHEL6.4 backports in compat layer
Thomas Graf [Fri, 26 Apr 2013 10:03:11 +0000 (12:03 +0200)]
datapath: Account for RHEL6.4 backports in compat layer

Explicitly check the availability of several kernel API functions
instead of relying on the kernel version to account for Red Hat
Enterprise Linux backports.

Signed-off-by: Thomas Graf <tgraf@redhat.com>
Signed-off-by: Jesse Gross <jesse@nicira.com>
(cherry picked from commit 42d5dd9595cce35a8825a20be7d71a3a8f6f5640)

Conflicts:
datapath/linux/compat/include/asm/percpu.h
datapath/linux/compat/include/linux/netdevice.h

10 years agodatapath: Use openvswitch_handle_frame hook in >=RHEL6.4 to live side by side with...
Thomas Graf [Fri, 26 Apr 2013 10:03:10 +0000 (12:03 +0200)]
datapath: Use openvswitch_handle_frame hook in >=RHEL6.4 to live side by side with bridging

Due to the missing register rx_handler API in the kernel RHEL6 is
based on, the datapath currently falls back to using the bridging
hook with the consequence that bridging and OVS cannot be used in
parallel on any RHEL6 release.

For this purpose, >=RHEL6.4 releases provide a special rx frame hook
to be used by OVS. It captures frames at the same location in the
stack as the rx_handler would do in more recent kernel releases. In
order to store the vport pointer, the net_device's ax25_ptr field is
utilized under the assumption that an AX25 device will never be
attached to an OVS bridge.

Signed-off-by: Thomas Graf <tgraf@redhat.com>
Signed-off-by: Jesse Gross <jesse@nicira.com>
(cherry picked from commit f285d3e715512571c4b2f92a4d1c65022bbcc9d5)

Conflicts:
datapath/vport-netdev.c

11 years agopython/ovs/poller.py: workaround an eventlet bug
YAMAMOTO Takashi [Tue, 16 Apr 2013 06:56:31 +0000 (15:56 +0900)]
python/ovs/poller.py: workaround an eventlet bug

Signed-off-by: YAMAMOTO Takashi <yamamoto@valinux.co.jp>
Signed-off-by: Ben Pfaff <blp@nicira.com>
11 years agoDeclare the version as "1.9.2".
Justin Pettit [Sat, 30 Mar 2013 01:56:25 +0000 (18:56 -0700)]
Declare the version as "1.9.2".

Signed-off-by: Justin Pettit <jpettit@nicira.com>
11 years agorhel: Add depmod.d conf file for rhel6 kmod package.
Gurucharan Shetty [Sun, 31 Mar 2013 01:32:25 +0000 (18:32 -0700)]
rhel: Add depmod.d conf file for rhel6 kmod package.

It looks like for Centos6.4, there is an upstream openvswitch
kernel module already installed. When we try to install kmod-openvswitch
package from this tree's pre-1.10 branches, we get the following warning:
"brcompat.ko needs unknown symbol ovs_dp_ioctl_hook".

Also, after installing the kmod-openvswitch package, if we run
"modprobe openvswitch", the upstream kernel module gets loaded.
We should instead load the kernel module compiled from this tree.

This patch fixes both the above issues.

Bug #15829.
Signed-off-by: Gurucharan Shetty <gshetty@nicira.com>
11 years agoDeclare the version as "1.9.1".
Justin Pettit [Fri, 15 Mar 2013 00:28:52 +0000 (17:28 -0700)]
Declare the version as "1.9.1".

Signed-off-by: Justin Pettit <jpettit@nicira.com>
11 years agodatapath: Check for Centos 6.4 backports.
Jesse Gross [Tue, 12 Mar 2013 18:34:29 +0000 (11:34 -0700)]
datapath: Check for Centos 6.4 backports.

Centos 6.4 backported a number of additional functions so our existing
versions started causing conflicts.

Reported-by: Denis Iskandarov <d.iskandarov@gmail.com>
Signed-off-by: Jesse Gross <jesse@nicira.com>
11 years agodatapath: Reduce loop limit by one to 4.
Jesse Gross [Tue, 12 Mar 2013 19:36:03 +0000 (12:36 -0700)]
datapath: Reduce loop limit by one to 4.

We currently allow five trips through the kernel datapath
before dropping the packet to protect the stack.  However, there
have been a few reports recently involving tunneling that this is
still too much.  Although it's not a complete solution, this reduces
the limit by one to balance safety in common situations with
flexibility.

Bug #15477

Reported-by: Paul Ingram <paul@nicira.com>
Reported-by: 謝秉融 <faithfulman@gmail.com>
Signed-off-by: Jesse Gross <jesse@nicira.com>
Acked-by: Pravin B Shelar <pshelar@nicira.com>
11 years agoconnmgr: Fix memory leak in ofconn monitor table.
Ben Pfaff [Fri, 18 Jan 2013 23:17:15 +0000 (15:17 -0800)]
connmgr: Fix memory leak in ofconn monitor table.

Signed-off-by: Ben Pfaff <blp@nicira.com>
Acked-by: Ethan Jackson <ethan@nicira.com>
11 years agoovsdb: Fix memory leak.
Ben Pfaff [Thu, 24 Jan 2013 19:33:35 +0000 (11:33 -0800)]
ovsdb: Fix memory leak.

Signed-off-by: Ben Pfaff <blp@nicira.com>
Acked-by: Ethan Jackson <ethan@nicira.com>
11 years agodatapath: Fix circular dependency between bug.h and kernel.h.
Jesse Gross [Wed, 6 Mar 2013 08:10:01 +0000 (00:10 -0800)]
datapath: Fix circular dependency between bug.h and kernel.h.

In Linux 3.4 the definition for BUILD_BUG_ON_NOT_POWER_OF_2 was
moved from kernel.h to bug.h.  On various kernels these header
files include each other in various orders (often through a
long chain of other header files), which can create circular
dependency issues.  Since we not longer need this definition,
this simply removes the backport.

Reported-by: Palo Andi <andi@dis.uniroma1.it>
Signed-off-by: Jesse Gross <jesse@nicira.com>
Conflicts:
datapath/linux/Modules.mk

11 years agonetdev-linux: Fix netdev_linux_send() return value in corner case.
Ben Pfaff [Tue, 26 Feb 2013 20:35:40 +0000 (12:35 -0800)]
netdev-linux: Fix netdev_linux_send() return value in corner case.

A negative 'sock' means there was an error but netdev_linux_send() returns
a positive errno value on error.

Signed-off-by: Ben Pfaff <blp@nicira.com>
11 years agonx-match: Correct writing of value and length in set_field_to_ofast()
Simon Horman [Wed, 27 Feb 2013 07:12:16 +0000 (16:12 +0900)]
nx-match: Correct writing of value and length in set_field_to_ofast()

ofpbuf_put_* may reallocate the underlying buffer of the ofpbuf and
thus writing data after a ofpbuf_put_* call must write to memory
relative to the pointer returned by the call.

Prior to this change the length and trailing value would not be written to
the set_field action if ofpbuf_put_* may reallocated the underlying buffer.

Also make use of ofpbuf_put_zero() to avoid calling memset() directly.

Tested-by: Simon Horman <horms@verge.net.au>
Signed-off-by: Simon Horman <horms@verge.net.au>
Signed-off-by: Ben Pfaff <blp@nicira.com>
11 years agoSet dates for 1.9.0 release. v1.9.0
Justin Pettit [Tue, 26 Feb 2013 19:24:20 +0000 (11:24 -0800)]
Set dates for 1.9.0 release.

This also sets the dates for 1.8.0, even though it was an internal-only
release.

Signed-off-by: Justin Pettit <jpettit@nicira.com>
11 years agodatapath: fix the calculation of checksum for vlan header
Cong Wang [Sat, 23 Feb 2013 03:22:41 +0000 (19:22 -0800)]
datapath: fix the calculation of checksum for vlan header

In vlan_insert_tag(), we insert a 4-byte VLAN header _after_
mac header:

        memmove(skb->data, skb->data + VLAN_HLEN, 2 * ETH_ALEN);
        ...
        veth->h_vlan_proto = htons(ETH_P_8021Q);
        ...
        veth->h_vlan_TCI = htons(vlan_tci);

so after it, we should recompute the checksum to include these 4 bytes.
skb->data still points to the mac header, therefore VLAN header is at
(2 * ETH_ALEN = 12) bytes after it, not (ETH_HLEN = 14) bytes.

This can also be observed via tcpdump:

         0x0000:  ffff ffff ffff 5254 005d 6f6e 8100 000a
         0x0010:  0806 0001 0800 0604 0001 5254 005d 6f6e
         0x0020:  c0a8 026e 0000 0000 0000 c0a8 0282

Similar for __pop_vlan_tci(), the vlan header we remove is the one
overwritten in:

memmove(skb->data + VLAN_HLEN, skb->data, 2 * ETH_ALEN);

Therefore the VLAN_HLEN = 4 bytes after 2 * ETH_ALEN is the part
we want to sub from checksum.

Cc: David S. Miller <davem@davemloft.net>
Cc: Jesse Gross <jesse@nicira.com>
Signed-off-by: Cong Wang <amwang@redhat.com>
Signed-off-by: Jesse Gross <jesse@nicira.com>
11 years agoofp-msgs: ensure that l2 is set in ofpmp_reserve()
Ben Pfaff [Tue, 12 Feb 2013 23:49:12 +0000 (15:49 -0800)]
ofp-msgs: ensure that l2 is set in ofpmp_reserve()

Ensure that the buffer returned by ofpmp_reserve() has buf->l2 set
as this may be required by nxm_reg_load_to_nxast() when generating
the reply to an stats request

This problem was observed when dumping a large number of flows
with set_field actions using ovs-ofctl dump-flows.

Signed-off-by: Ben Pfaff <blp@nicira.com>
Co-authored-by: Simon Horman <horms@verge.net.au>
Signed-off-by: Simon Horman <horms@verge.net.au>
11 years agodatapath: Fix ovs_vport_cmd_del return value on success
Rich Lane [Fri, 8 Feb 2013 17:11:28 +0000 (09:11 -0800)]
datapath: Fix ovs_vport_cmd_del return value on success

If the pointer does not represent an error then the PTR_ERR macro may still
return a nonzero value. The fix is the same as in ovs_vport_cmd_set.

Signed-off-by: Rich Lane <rlane@bigswitch.com>
Signed-off-by: Jesse Gross <jesse@nicira.com>
11 years agoNEWS: Rearrange announcements related to 1.9.
Justin Pettit [Tue, 5 Feb 2013 08:02:16 +0000 (00:02 -0800)]
NEWS: Rearrange announcements related to 1.9.

Suggested-by: Ben Pfaff <blp@nicira.com>
Signed-off-by: Justin Pettit <jpettit@nicira.com>
11 years agotunneling: Don't send ICMP messages if no tunnel port is found.
Jesse Gross [Fri, 1 Feb 2013 23:34:10 +0000 (15:34 -0800)]
tunneling: Don't send ICMP messages if no tunnel port is found.

Some tunnel code in OVS (for example, CAPWAP) uses the skb->cb to
store information while processing packets.  However, if we don't
find an appropriate tunnel port on receive, then we send an ICMP
port unreachable message, which calls back into the IP stack.  The
stack assumes that skb->cb will still contain valid information
about from the IP layer, including any IP options.  As a result,
icmp_echo_options() can read the garbage values from OVS and
overwrite data on the stack, panicing the machine.

This simply stops sending ICMP messages when ports are not found.
Many people find them confusing and flow based tunneling will
never send them (since it always finds a port) so it solves both
problems at once.

Bug #14880

Reported-by: Deepesh Govindan <dgovindan@nicira.com>
Signed-off-by: Jesse Gross <jesse@nicira.com>
Acked-by: Kyle Mestery <kmestery@cisco.com>
Conflicts:

datapath/vport-vxlan.c

11 years agoofp-parse: Ignore "idle_age" and "hard_age" when parsing a flow string.
Justin Pettit [Fri, 1 Feb 2013 08:11:32 +0000 (00:11 -0800)]
ofp-parse: Ignore "idle_age" and "hard_age" when parsing a flow string.

It should be possible to feed to output of "ovs-ofctl dump-flows" to
"ovs-ofctl add-flows".  However, some of the metadata needs to be
ignored.  "idle_age" and "hard_age" was recently added to the output of
"ovs-ofctl dump-flows", but they were not ignored like the other
metadata.  This commit ignores them.

Signed-off-by: Justin Pettit <jpettit@nicira.com>
11 years agoovsdb-tool: Fix memory leak on error path in "show-log" implementation.
Ben Pfaff [Thu, 24 Jan 2013 22:23:45 +0000 (14:23 -0800)]
ovsdb-tool: Fix memory leak on error path in "show-log" implementation.

Found by Coverity.

Signed-off-by: Ben Pfaff <blp@nicira.com>
Acked-by: Ethan Jackson <ethan@nicira.com>
11 years agoovsdb-idl: Fix memory leak on error path.
Ben Pfaff [Thu, 24 Jan 2013 22:19:20 +0000 (14:19 -0800)]
ovsdb-idl: Fix memory leak on error path.

Found by Coverity.

Signed-off-by: Ben Pfaff <blp@nicira.com>
Acked-by: Ethan Jackson <ethan@nicira.com>
11 years agometa-flow: Add missing "break" to mf_set_wild().
Ben Pfaff [Thu, 24 Jan 2013 21:41:10 +0000 (13:41 -0800)]
meta-flow: Add missing "break" to mf_set_wild().

Found by Coverity.

Signed-off-by: Ben Pfaff <blp@nicira.com>
Acked-by: Ethan Jackson <ethan@nicira.com>
11 years agometa-flow: Avoid null pointer dereference in mf_format_frag_string().
Ben Pfaff [Thu, 24 Jan 2013 21:39:23 +0000 (13:39 -0800)]
meta-flow: Avoid null pointer dereference in mf_format_frag_string().

The 'maskp' parameter to this function can be NULL, but the function
always dereferenced it.  This commit fixes the problem.

This commit also fixes the order in which the value and mask were adjusted
to correctly discard 1-bits outside of FLOW_NW_FRAG_MASK.

Found by Coverity.

Signed-off-by: Ben Pfaff <blp@nicira.com>
Acked-by: Ethan Jackson <ethan@nicira.com>
11 years agoworker: Don't have worker abort when parent dies.
Justin Pettit [Sat, 26 Jan 2013 02:12:01 +0000 (18:12 -0800)]
worker: Don't have worker abort when parent dies.

Depending on how forcefully the parent process is killed, the worker
could abort when trying to read or write on their shared socket.  This
changes those errors from VLOG_ABORT to VLOG_FATAL so that a core isn't
generated.

Bug #14821

Reported-by: Amey Bhide <abhide@nicira.com>
Signed-off-by: Justin Pettit <jpettit@nicira.com>
11 years agoofproto: Properly refresh rule modified time when nothing else changes.
Ben Pfaff [Fri, 25 Jan 2013 23:07:36 +0000 (15:07 -0800)]
ofproto: Properly refresh rule modified time when nothing else changes.

In Open vSwitch, a "modify" or "modify_strict" flow_mod is supposed to
refresh the flow's last-modified time even if nothing else changes, because
this interpretation makes the "learn" action more useful.  As commit
308881afb (ofproto: Reinterpret meaning of OpenFlow hard timeouts with
OFPFC_MODIFY.) notes:

    I finally found a good use for hard timeouts in OpenFlow, but they
    require a slight reinterpretation of the meaning of hard timeouts.
    Until now, a hard timeout meant that a flow would be removed the
    specified number of seconds after a flow was created.  Intervening
    modifications with OFPFC_MODIFY(_STRICT) had no effect on the hard
    timeout; the flow would still be deleted the specified number of
    seconds after its original creation.

    This commit changes the effect of OFPFC_MODIFY(_STRICT).  Now,
    modifying a flow resets its hard timeout counter.  A flow will time out
    the specified number of seconds after creation or after the last time
    it is modified, whichever comes later.

However, commit 080437614b (ofproto: Represent flow cookie changes as
operations too.) broke this behavior because it incorrectly optimized out
"modify" operations that didn't change the flow's actions or flow cookie.
This commit fixes the problem, and adds a test to prevent future
regression.

Thanks to Amar Padmanabhan <amar@nicira.com> for helping to track this
down.

Bug #14841.
Reported-by: Hiroshi Tanaka <htanaka@vmware.com>
CC: Amar Padmanabhan <amar@nicira.com>
Signed-off-by: Ben Pfaff <blp@nicira.com>
11 years agodatapath: Clear struct ovs_key_ipv4_tunnel padding.
Pravin B Shelar [Sat, 26 Jan 2013 02:09:07 +0000 (18:09 -0800)]
datapath: Clear struct ovs_key_ipv4_tunnel padding.

Following patch memset ovs_key_ipv4_tunnel padding area so that
packets from a flow would be mapped to same flow in kernel datapath
flow table.

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

11 years agolinux: Increase accuracy of ingress_policing_rate at low rates
Thomas Graf [Fri, 25 Jan 2013 19:13:55 +0000 (20:13 +0100)]
linux: Increase accuracy of ingress_policing_rate at low rates

The current method of calculating the ingress policer rate
can lead to inaccuracy if ingress_policing_rate is set to
a smallish values because the rate is divided by 8 first
which causes rounding errors.

Signed-off-by: Thomas Graf <tgraf@redhat.com>
Signed-off-by: Ben Pfaff <blp@nicira.com>
11 years agorhel: Add OVSREQUIRES to automatically bring up OpenFlow interface dependencies
Thomas Graf [Fri, 25 Jan 2013 16:31:56 +0000 (17:31 +0100)]
rhel: Add OVSREQUIRES to automatically bring up OpenFlow interface dependencies

The use of OpenFlow controllers may require for a subset of
the network (typically the management network intrerface) to be
brought up before the openvswitch service is started.

The newly introduced key "OVSREQUIRES" allows to specify a
list of interfaces that need the be brought up before the
openvswitch service is autostarted. It is also possible to
build a chain of bridge dependencies.

TYPE=OVSBridge
OVSREQURIES="em1"
[...]

A special UPPEDSTACK var that is passed along avoids getting
lost in dependency loops.

Signed-off-by: Thomas Graf <tgraf@redhat.com>
Signed-off-by: Ben Pfaff <blp@nicira.com>
11 years agorhel: Automatically start openvswitch service before bringing an ovs interface up...
Thomas Graf [Fri, 25 Jan 2013 14:06:57 +0000 (15:06 +0100)]
rhel: Automatically start openvswitch service before bringing an ovs interface up or down

This patch modifies the ifup/ifdown scripts to automatically
start the openvswitch service before ovs-vsctl is invoked thus
not making it mandatory to auto-start openvswitch on boot.

Signed-off-by: Thomas Graf <tgraf@redhat.com>
Signed-off-by: Ben Pfaff <blp@nicira.com>
11 years agodpif-linux: Report dropped lost messages at WARN level.
Justin Pettit [Fri, 25 Jan 2013 22:29:41 +0000 (14:29 -0800)]
dpif-linux: Report dropped lost messages at WARN level.

Messages about packets being lost are logged at level WARN, but when
they were generated at a high rate, those consolidated messages were
logged at ERR.  This changes to consolidated messages to be logged at
WARN, too.

Thanks to Ben Pfaff for quickly suggesting the culprit.

Bug #14783

Reported-by: James Schmidt <jschmidt@nicira.com>
Signed-off-by: Justin Pettit <jpettit@nicira.com>
11 years agoovsdb: Fix double-free in ovsdb_jsonrpc_session_close().
Ben Pfaff [Thu, 24 Jan 2013 20:27:53 +0000 (12:27 -0800)]
ovsdb: Fix double-free in ovsdb_jsonrpc_session_close().

ovsdb_session_destroy() was called twice but it should only be called once.

This double-free is unlikely to cause problems in practice because it only
triggers if there were ever more than two outstanding requests in the
session at a time (because the only data being freed is an hmap, which
does not allocate any heap memory unless the hmap has more than two
elements).

Signed-off-by: Ben Pfaff <blp@nicira.com>
Acked-by: Ethan Jackson <ethan@nicira.com>
11 years agohash: Correct implementation of mhash_finish().
Ben Pfaff [Fri, 14 Dec 2012 21:43:54 +0000 (13:43 -0800)]
hash: Correct implementation of mhash_finish().

With rotates instead of shifts, the upper and lower 16 bits of the returned
hash are always the same.

I noticed this while working on replacing Jenkins hash by murmurhash,
because some of the database unit tests started failing, e.g. "row
hashing (scalars)".

Signed-off-by: Ben Pfaff <blp@nicira.com>
Acked-by: Ethan Jackson <ethan@nicira.com>
11 years agodatapath: Return correct error code when dumping flow actions.
Jesse Gross [Mon, 21 Jan 2013 11:59:17 +0000 (03:59 -0800)]
datapath: Return correct error code when dumping flow actions.

Currently, if there isn't enough space to store the actions in a
flow during a dump we return -ENOMEM.  However, the standard error
in this situation is -EMSGSIZE so this changes the behavior to match.
This issue was introduced in 354d4c98a8cdaae3525848f564e58a9016bcd3af
 (datapath: Fix nelink attribute size for flow.).

Signed-off-by: Jesse Gross <jesse@nicira.com>
Acked-by: Ben Pfaff <blp@nicira.com>
11 years agodatapath: Don't dump partial action lists in flows.
Ben Pfaff [Mon, 21 Jan 2013 11:59:16 +0000 (03:59 -0800)]
datapath: Don't dump partial action lists in flows.

After commit 9b405f1aa8d175dc63ad3ffe5d0fe05d5ee09162 (datapath: More
flexible kernel/userspace tunneling attribute.), it was possible for a
flow dump to return a partial action list.  It's better to return no
action list at all in this situation since then userspace will know
that it should request the full thing if it wants rather than have
incorrect results.  Therefore, this prevents those partial lists in
situations where we have a very large number of actions.

Signed-off-by: Ben Pfaff <blp@nicira.com>
Signed-off-by: Jesse Gross <jesse@nicira.com>
11 years agoRevert "datapath: Avoid null deref when GSO is for verifying header integrity only."
Jesse Gross [Mon, 21 Jan 2013 13:23:32 +0000 (05:23 -0800)]
Revert "datapath: Avoid null deref when GSO is for verifying header integrity only."

This reverts commit 00c7faf3e5b7d4020e995a1429cf94313f197171.

In general, it should not be possible have a NULL return value from
skb_gso_segment() since we're not actually trying to verify the
header integrity.  No other callers with similar needs have NULL
checks.  The actual cause of the problem was LRO packets, which
OVS isn't equipped to handle.  The commit
33e031e99cc630baf1b0cb9256710dee7d9ab66d (datapath: Move LRO check
from transmit to receive.) solves that problem by fixing the LRO
check.  In order to avoid possibly masking any other problems, this
reverts the GSO check which should no longer be needed.

Signed-off-by: Jesse Gross <jesse@nicira.com>
11 years agodatapath: Move LRO check from transmit to receive.
Jesse Gross [Mon, 21 Jan 2013 13:13:32 +0000 (05:13 -0800)]
datapath: Move LRO check from transmit to receive.

Commit 24b019f808211a95078efd916064af0975ca5733 (datapath: Disable
LRO from userspace instead of the kernel.) accidentally moved the
check for LRO packets from the receive path to transmit.  Since
this check is supposed to protect OVS (and other parts of the system)
from packets that it cannot handle it is obviously not useful on
egress.  Therefore, this commit moves it back to the receive side.

The primary problem that this caused is upcalls to userspace tried
to segment the packet even though no segmentation information is
available.  This would later cause NULL pointer dereferences when
skb_gso_segment() did nothing.

Bug #14772

Signed-off-by: Jesse Gross <jesse@nicira.com>
Acked-by: Ben Pfaff <blp@nicira.com>
11 years agodatapath: Avoid null deref when GSO is for verifying header integrity only.
Ben Pfaff [Mon, 21 Jan 2013 22:29:15 +0000 (14:29 -0800)]
datapath: Avoid null deref when GSO is for verifying header integrity only.

skb_gso_segment() has the following comment:

 *    It may return NULL if the skb requires no segmentation.  This is
 *    only possible when GSO is used for verifying header integrity.

Somehow queue_gso_packets() has never hit this case before, but some
failures have suddenly been reported.  This commit should fix the problem.

Additional commentary by Jesse: We shouldn't normally be hitting this case
because we're actually trying to do GSO, not header validation.  However, I
guess the guest/backend must be generating a packet with an MSS, which
tricks us into thinking that it's GSO, but no GSO is actually requested.
In the case of the bridge, header validation does take place so the
situation is handled already.  It seems not ideal that the network backend
doesn't sanitize these packets but it's probably good that we handle
it in any case.

Bug #14772.
Reported-by: Deepesh Govindan <dgovindan@vmware.com>
Signed-off-by: Ben Pfaff <blp@nicira.com>
Acked-by: Jesse Gross <jesse@nicira.com>
11 years agodatapath: Fix nelink attribute size for flow.
Pravin B Shelar [Mon, 21 Jan 2013 07:15:07 +0000 (23:15 -0800)]
datapath: Fix nelink attribute size for flow.

Following patch fixes flow buffer size calculation to allocate
sufficient memory for all nested attributes in new tunnel
attribute.

Signed-off-by: Pravin B Shelar <pshelar@nicira.com>
Acked-by: Ben Pfaff <blp@nicira.com>
Bug #14767

11 years agodatapath: Fix Flow dump operation.
Pravin B Shelar [Mon, 21 Jan 2013 07:14:36 +0000 (23:14 -0800)]
datapath: Fix Flow dump operation.

Following patch adds null check while inserting new netlink attribute.
This was introduced by commit 9b405f1aa8d175d (datapath: More
flexible kernel/userspace tunneling attribute.)

Signed-off-by: Pravin B Shelar <pshelar@nicira.com>
Acked-by: Ben Pfaff <blp@nicira.com>
Bug #14767

11 years agodatapath: More flexible kernel/userspace tunneling attribute.
Pravin B Shelar [Sat, 19 Jan 2013 02:03:15 +0000 (18:03 -0800)]
datapath: More flexible kernel/userspace tunneling attribute.

Following patch breaks down single ipv4_tunnel netlink attribute into
individual member attributes. It will help when we extend tunneling
parameters in future.

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

11 years agodatapath: support Linux 3.8 kernel
James Page [Wed, 16 Jan 2013 11:19:21 +0000 (11:19 +0000)]
datapath: support Linux 3.8 kernel

Add Linux 3.8 kernel to the range of supported kernel versions.

Signed-off-by: James Page <james.page@ubuntu.com>
[jesse: Update NEWS and FAQ]
Signed-off-by: Jesse Gross <jesse@nicira.com>
Conflicts:

FAQ

11 years agolinux/Makefile.main.in, acinclude: preparation for linux 3.7.0+
Isaku Yamahata [Fri, 7 Dec 2012 03:37:02 +0000 (12:37 +0900)]
linux/Makefile.main.in, acinclude: preparation for linux 3.7.0+

The version.h is moved from include/linux/version.h to
include/generated/uapi/linux/version.h.
So check both pathes.

Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp>
Signed-off-by: Jesse Gross <jesse@nicira.com>
11 years agoworker: Do not use poll_block() in worker_send_iovec().
Ben Pfaff [Fri, 11 Jan 2013 01:22:24 +0000 (17:22 -0800)]
worker: Do not use poll_block() in worker_send_iovec().

The following call stack was possible:

    poll_block()
        -> vlog
            -> worker_send_iovec()
                -> poll_block()

which caused corruption because poll_block() is not reentrant.

Bug #14616.
Signed-off-by: Ben Pfaff <blp@nicira.com>
Acked-by: Ethan Jackson <ethan@nicira.com>
11 years agovlog: Avoid calling worker_request() reentrantly.
Ben Pfaff [Fri, 11 Jan 2013 01:14:03 +0000 (17:14 -0800)]
vlog: Avoid calling worker_request() reentrantly.

The following call stack was possible:

    vlog
        -> worker_request()
            -> poll_block()
                -> vlog
                     -> worker_request()

which caused problems because worker_request() is not reentrant.  In a
little more detail, the second worker_request() shoves its RPC protocol
data into the middle of the first.  This means that, first, you get
some binary crud in the log (the header for the second RPC).  And,
second, text from the first RPC log message gets treated by the worker
as the subsequent RPC's header.  That, in turn, typically causes the
worker to try to xmalloc() a huge number of bytes (0x20000000 or more,
since "space" has ASCII value 0x20), which causes the worker to die
with "virtual memory exhausted".  The main process then dies because
the worker's death closes the socket it uses to communicate with it
("connection reset").

Bug #14616.
Signed-off-by: Ben Pfaff <blp@nicira.com>
Acked-by: Ethan Jackson <ethan@nicira.com>
11 years agoofproto-dpif-governor: Fix small memory leak.
Ben Pfaff [Wed, 26 Dec 2012 20:32:34 +0000 (12:32 -0800)]
ofproto-dpif-governor: Fix small memory leak.

Signed-off-by: Ben Pfaff <blp@nicira.com>
Acked-by: Ethan Jackson <ethan@nicira.com>
11 years agoofp-util: Fix uninitialized bytes in OF1.0 and OF1.1 table stats replies.
Ben Pfaff [Fri, 21 Dec 2012 22:11:29 +0000 (14:11 -0800)]
ofp-util: Fix uninitialized bytes in OF1.0 and OF1.1 table stats replies.

Also, use ovs_strlcpy() instead of strcpy() just to be a teensy bit safer.

Found by valgrind.

Bug #14357.
Signed-off-by: Ben Pfaff <blp@nicira.com>
Acked-by: Ethan Jackson <ethan@nicira.com>
11 years agometa-flow: Fix uninitialized data parsing tnl_flags in mf_parse().
Ben Pfaff [Fri, 21 Dec 2012 22:01:43 +0000 (14:01 -0800)]
meta-flow: Fix uninitialized data parsing tnl_flags in mf_parse().

Also, add an assertion that the field is the expected size.

This bug was introduced in commit 2fdf762a006f (vswitchd: Log all tunnel
parameters of given flow.)

Found by valgrind.

Bug #14357.
Signed-off-by: Ben Pfaff <blp@nicira.com>
Acked-by: Ethan Jackson <ethan@nicira.com>
11 years agorconn: Avoid memory leak in rconn_send_with_limit() on queue overflow.
Ben Pfaff [Fri, 4 Jan 2013 21:48:19 +0000 (13:48 -0800)]
rconn: Avoid memory leak in rconn_send_with_limit() on queue overflow.

Bug #14357.
Reported-by: Luca Giraudo <lgiraudo@nicira.com>
Signed-off-by: Ben Pfaff <blp@nicira.com>
11 years agoMake OVS_TUNNEL_ATTR_DST_IPV4 optional to allow configuration of null_ports.
Jarno Rajahalme [Sat, 29 Dec 2012 06:58:40 +0000 (08:58 +0200)]
Make OVS_TUNNEL_ATTR_DST_IPV4 optional to allow configuration of null_ports.

Signed-off-by: Jarno Rajahalme <jarno.rajahalme@nsn.com>
[jesse: correct return type of get_u32_or_zero()]
Signed-off-by: Jesse Gross <jesse@nicira.com>
Conflicts:

datapath/tunnel.c
include/openvswitch/tunnel.h
lib/netdev-vport.c

11 years agodatapath: Initialize tunnel_key pad member.
Jesse Gross [Mon, 31 Dec 2012 20:28:41 +0000 (12:28 -0800)]
datapath: Initialize tunnel_key pad member.

When a packet is received on a tunnel the pad member is currently
left uninitialized.  This didn't previously cause problems because
userspace didn't interprete the IPV4_TUNNEL attribute and blindly
copied back the uninitialized data.  However, now that userspace
knows how to serialize this attribute it was zeroing it out, which
prevented flows that had been previously installed from being
deleted.  In addition to zeroing out the padding on packet reception,
it also does the same thing on flow setup since we should be ignoring
the value.

Reported-by: Anand Krishnamurthy <krishnamurt4@wisc.edu>
Reported-by: Saul St. John <sstjohn@cs.wisc.edu>
Signed-off-by: Jesse Gross <jesse@nicira.com>
Acked-by: Ben Pfaff <blp@nicira.com>
Conflicts:

datapath/flow.c

11 years agobrcompat: Mark ovs-brcompat as deprecated.
Pravin B Shelar [Thu, 27 Dec 2012 21:30:59 +0000 (13:30 -0800)]
brcompat: Mark ovs-brcompat as deprecated.

Signed-off-by: Pravin B Shelar <pshelar@nicira.com>
bug #14341

11 years agoovs-ctl: Exit, instead of resuming, after handling fatal signals.
Ben Pfaff [Wed, 26 Dec 2012 20:45:34 +0000 (12:45 -0800)]
ovs-ctl: Exit, instead of resuming, after handling fatal signals.

When I wrote the "trap" calls in ovs-ctl, I had the mistaken notion that
"trap $cmd $signal" would execute $cmd and then exit when $signal was
caught.  This is incorrect.  Instead, it executes $cmd and then resumes
executing the shell script.

On the other hand, "trap $cmd 0" does by itself what I wanted: it causes
the shell to execute $cmd and then exits due to the signal.  So this commit
changes the offending traps to use this form.

Bug #14290.
Signed-off-by: Ben Pfaff <blp@nicira.com>
Acked-by: Kyle Mestery <kmestery@cisco.com>
11 years agodatapath: linux2.7 s/pid/portid/g
Isaku Yamahata [Wed, 19 Dec 2012 08:43:10 +0000 (17:43 +0900)]
datapath: linux2.7 s/pid/portid/g

the following up of 15e473046cb6e5d18a4d0057e61d76315230382b
This patch replaces pid with portid under datapath/linux/compat

Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp>
Signed-off-by: Jesse Gross <jesse@nicira.com>
11 years agodatapath: support Linux 3.7
Isaku Yamahata [Wed, 19 Dec 2012 08:43:09 +0000 (17:43 +0900)]
datapath: support Linux 3.7

datapath: backport 15e473046cb6e5d18a4d0057e61d76315230382b

Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp>
[jesse: fix kernel version in error message]
Signed-off-by: Jesse Gross <jesse@nicira.com>
11 years agometa-flow: Correctly byteswap skb_priority/skb_mark for mf_value.
Ben Pfaff [Tue, 18 Dec 2012 23:54:29 +0000 (15:54 -0800)]
meta-flow: Correctly byteswap skb_priority/skb_mark for mf_value.

Fixes the following sparse warnings:

meta-flow.c:947:21: warning: incorrect type in assignment (different base types)
meta-flow.c:947:21:    expected restricted __be32 [usertype] be32
meta-flow.c:947:21:    got unsigned int const [unsigned] [usertype] skb_priority
meta-flow.c:951:21: warning: incorrect type in assignment (different base types)
meta-flow.c:951:21:    expected restricted __be32 [usertype] be32
meta-flow.c:951:21:    got unsigned int const [unsigned] [usertype] skb_mark

Signed-off-by: Ben Pfaff <blp@nicira.com>
11 years agovswitchd: log skb_mark and skb_priority
Ansis Atteka [Thu, 29 Nov 2012 22:36:49 +0000 (14:36 -0800)]
vswitchd: log skb_mark and skb_priority

This patch adds logging support for skb_mark and skb_priority.

Acked-by: Jesse Gross <jesse@nicira.com>
Signed-off-by: Ansis Atteka <aatteka@nicira.com>
Conflicts:

lib/ofp-util.c
tests/ofproto-dpif.at

11 years agometa-flow: Fix and simplify mf_get_mask().
Ben Pfaff [Tue, 18 Dec 2012 17:45:02 +0000 (09:45 -0800)]
meta-flow: Fix and simplify mf_get_mask().

This function can be implemented as a trivial wrapper around
mf_get_value(), which I hadn't noticed before, so it's better to do it
that way.  Also, examining the code that is removed, it had some bugs in
it (for example, all MFF_TUN_* fields were treated as if they were
MFF_TUN_ID) which mf_get_value() does not have, so this fixes bugs too.

Signed-off-by: Ben Pfaff <blp@nicira.com>
11 years agodatapath: Zero out key when looking up null ports.
Jesse Gross [Mon, 17 Dec 2012 20:07:07 +0000 (12:07 -0800)]
datapath: Zero out key when looking up null ports.

When we are searching for a tunnel port to receive traffic on,
everything should be zeroed out by the time that we get to null
ports since they are wildcarded.  However, if certain other ports
also exist (primarily multicast ports with keys) then this might
not be the case and the key can be set.

Signed-off-by: Jesse Gross <jesse@nicira.com>
Acked-by: Kyle Mestery <kmestery@cisco.com>
11 years agometa-flow: Don't allow negative port numbers.
Justin Pettit [Fri, 14 Dec 2012 00:22:55 +0000 (16:22 -0800)]
meta-flow: Don't allow negative port numbers.

If a negative number is supplied, the parsing code used to convert it
into a signed one.  We ran into an incident where a third-party script
was attempting to get the OpenFlow port number for an interface, but got
-1 from the database, since the number had not yet been assigned.  This
was converted to 65535, which maps to OFPP_NONE and all flows with
ingress port OFPP_NONE were modified.  This commit disallows negative
port numbers to help prevent broken integration scripts from disturbing
the flow table.

Issue #14036

Signed-off-by: Justin Pettit <jpettit@nicira.com>
11 years agoofp-util: Fix typo in invalid port range error message.
Justin Pettit [Thu, 13 Dec 2012 22:41:36 +0000 (14:41 -0800)]
ofp-util: Fix typo in invalid port range error message.

Signed-off-by: Justin Pettit <jpettit@nicira.com>
11 years agodaemon: Start monitor process, not daemon process, in new session.
Ben Pfaff [Thu, 13 Dec 2012 22:01:23 +0000 (14:01 -0800)]
daemon: Start monitor process, not daemon process, in new session.

To keep control+C and other signals in the initiating session from killing
the monitor process, we need to put the monitor process into its own
session.  However, until this point, we've only done that for the daemon
processes that the monitor started, which means that control+C would kill
the monitor but not the daemons that it launched.

I don't know of a benefit to putting the monitor and daemon processes in
different sessions, as opposed to one new session for both of them, so
this change does the latter.

daemonize_post_detach() is called from one additional context where we'd
want to be in a new session, the worker_start() function, but that function
is documented as to be called after daemonize_start(), in which case we
will (after this commit) already have called setsid(), so no additional
change is required there.

Bug #14280.
Reported-by: Gordon Good <ggood@nicira.com>
Signed-off-by: Ben Pfaff <blp@nicira.com>
11 years agoovs-ctl: Don't run "ovs-save save-flows" on fake bridges.
Justin Pettit [Sat, 1 Dec 2012 02:58:09 +0000 (18:58 -0800)]
ovs-ctl: Don't run "ovs-save save-flows" on fake bridges.

Previously, ovs-ctl would determine which bridges to run "ovs-save
save-flows" on by running "ovs-vsctl list-br".  In addition to real
bridges, that command also returns fake bridges.  An error is returned
when "ovs-save save-flows" is run on a fake bridge.  By using the newly
added "--real" flag to "ovs-vsctl list-br", we can get rid of that
unnecessary warning.

Signed-off-by: Justin Pettit <jpettit@nicira.com>
11 years agoovs-vsctl: Add "--real" and "--fake" options to "list-br".
Justin Pettit [Sat, 1 Dec 2012 02:50:18 +0000 (18:50 -0800)]
ovs-vsctl: Add "--real" and "--fake" options to "list-br".

By default, "ovs-vsctl list-br" returns all bridges, real or fake.  This
commit adds "--real" and "--fake" options that limit the output to only
bridges of that type.  This will be useful in a future commit that needs
to perform actions only on bridges of a particular type.

Signed-off-by: Justin Pettit <jpettit@nicira.com>
11 years agobond: Fix segfault sending learning packets with LACP disabled.
Ben Pfaff [Thu, 29 Nov 2012 17:32:28 +0000 (09:32 -0800)]
bond: Fix segfault sending learning packets with LACP disabled.

It is essentially an invalid configuration to disable LACP but request TCP
balancing: in this configuration, the bond drops all packets.  But
may_send_learning_packets() would still indicate that learning packets
should be sent, so bond_compose_learning_packet() would try to choose an
output slave for those packets, which would be NULL (because all packets
are dropped), which would cause a segfault upon dereference.

This commit fixes the problem by making may_send_learning_packets() no
longer indicate that learning packets should be sent.

I tested this issue by modifying bond_should_send_learning_packets() to
always return true if may_send_learning_packets() returns true, and then
introducing the invalid configuration described above.  Without this comit,
ovs-vswitchd segfaults quickly; with this commit, it does not.

Bug #14090.
Reported-by: Kiran Shanbhog <kiran@vmware.com>
Signed-off-by: Ben Pfaff <blp@nicira.com>
11 years agodatapath: Use RCU callback when detaching netdevices.
Jesse Gross [Wed, 28 Nov 2012 20:15:49 +0000 (12:15 -0800)]
datapath: Use RCU callback when detaching netdevices.

Currently, each time a device is detached from an OVS datapath
we call synchronize RCU before freeing associated data structures.
However, if a bridge is deleted (which detaches all ports) when
many devices are connected then there can be a long delay.  This
switches to use call_rcu() to group the cost together.

Reported-by: Justin Pettit <jpettit@nicira.com>
Signed-off-by: Jesse Gross <jesse@nicira.com>
11 years agoflow: use rule priority in match_format() function
Ansis Atteka [Mon, 26 Nov 2012 23:40:48 +0000 (15:40 -0800)]
flow: use rule priority in match_format() function

The flow_format() function was incorrectly passing skb_priority
to the match_format() function. match_format() function instead
expects rule priority.

This issue was introduced with aa6c9932f2937fa9a2140ec1737668eb9105b0b5
(Change logging format for flows to that accepted by ofproto/trace).

Signed-off-by: Ansis Atteka <aatteka@nicira.com>
Conflicts:

tests/ofp-print.at
tests/ofproto-dpif.at
tests/ofproto.at

11 years agopython/ovs/stream: Fix Stream.connect() retval for incomplete connection.
Ben Pfaff [Thu, 22 Nov 2012 06:09:55 +0000 (22:09 -0800)]
python/ovs/stream: Fix Stream.connect() retval for incomplete connection.

If the loop condition in Stream.connect() was false, which is especially
likely for TCP connections, then Stream.connect() would return None,
which violates its documented behavior.  This commit fixes the problem.

Reported-by: Isaku Yamahata <yamahata@valinux.co.jp>
Tested-by: Isaku Yamahata <yamahata@valinux.co.jp>
Signed-off-by: Ben Pfaff <blp@nicira.com>
11 years agovswitchd: Log all tunnel parameters of given flow.
Pravin B Shelar [Thu, 22 Nov 2012 03:11:35 +0000 (19:11 -0800)]
vswitchd: Log all tunnel parameters of given flow.

Signed-off-by: Pravin B Shelar <pshelar@nicira.com>
11 years agodatapath: add skb mark matching and set action
Ansis Atteka [Tue, 13 Nov 2012 17:19:36 +0000 (19:19 +0200)]
datapath: add skb mark matching and set action

This patch adds support for skb mark matching and set action.

Acked-by: Jesse Gross <jesse@nicira.com>
Signed-off-by: Ansis Atteka <aatteka@nicira.com>
Conflicts:

datapath/flow.c
lib/dpif-netdev.c
lib/flow.h
lib/odp-util.c
ofproto/ofproto-dpif.c

11 years agoovs-appctl: fix help message for ofproto/trace command
Ansis Atteka [Tue, 20 Nov 2012 21:40:12 +0000 (13:40 -0800)]
ovs-appctl: fix help message for ofproto/trace command

The usage message for this command was wrong, because it did not
specify priority as one of its arguments.

Signed-off-by: Ansis Atteka <aatteka@nicira.com>
11 years agoovs-ctl.in: increase the limit of fd
Cong Wang [Wed, 14 Nov 2012 12:58:18 +0000 (20:58 +0800)]
ovs-ctl.in: increase the limit of fd

We can't create more than 248 bridges with the current limit 5000,
so increase it to 6000 so that at least 256+ bridges could be created.

Cc: Ben Pfaff <blp@nicira.com>
Signed-off-by: Cong Wang <xiyou.wangcong@gmail.com>
Signed-off-by: Ben Pfaff <blp@nicira.com>