openvswitch
13 years agotest-openflowd: Remove.
Ben Pfaff [Mon, 24 Oct 2011 17:36:01 +0000 (10:36 -0700)]
test-openflowd: Remove.

Some users were still confused by its presence.

13 years agoofproto: Check for overlapping flows only in the target table.
Ben Pfaff [Wed, 19 Oct 2011 23:03:31 +0000 (16:03 -0700)]
ofproto: Check for overlapping flows only in the target table.

There's no reason to check for overlapping flows in table A if the flow
is going to be inserted into table B.

(I doubt anyone actually uses OFPFF_CHECK_OVERLAP though.)

13 years agoofproto-dpif: Fix htons() that should be ntohs().
Ben Pfaff [Mon, 24 Oct 2011 16:23:18 +0000 (09:23 -0700)]
ofproto-dpif: Fix htons() that should be ntohs().

Not a real bug since htons() and ntohs() do the same thing on all
interesting target platforms.

Found by sparse.

13 years agoovsdb-tool: Make "show-log" convert raw JSON to easier-to-read syntax.
Ben Pfaff [Thu, 6 Oct 2011 18:25:25 +0000 (11:25 -0700)]
ovsdb-tool: Make "show-log" convert raw JSON to easier-to-read syntax.

Now output that formerly looked like ["map", [["key1", "value1"], ["key2",
"value2"]]] is printed like {key1=value1, key2=value2}, which I find easier
to read.

13 years agoovsdb-tool: Add abbreviated UUIDs to "show-log" even when we have a name.
Ben Pfaff [Thu, 6 Oct 2011 18:23:54 +0000 (11:23 -0700)]
ovsdb-tool: Add abbreviated UUIDs to "show-log" even when we have a name.

The "show-log" command tries to give names to the rows to make it easier to
understand what's going on, but it's still important to see at least
partial UUIDs so that one can search the output for references to the rows
by UUID.

13 years agoDESIGN: Document multiple table support.
Ben Pfaff [Thu, 29 Sep 2011 18:34:03 +0000 (11:34 -0700)]
DESIGN: Document multiple table support.

Suggested-by: Justin Pettit <jpettit@nicira.com>
Suggested-by: Michael Mao <mmao@nicira.com>
13 years agoovs-bugtool: Improve how Open vSwitch log files are saved.
Ben Pfaff [Mon, 24 Oct 2011 16:14:12 +0000 (09:14 -0700)]
ovs-bugtool: Improve how Open vSwitch log files are saved.

This moves the OVS log files from the "network-status" capability, which
has a very small maximum size, to the "system-logs" capability, which is
much larger.  It ensures that the newest OVS log files are prioritized over
old versions of system log files (if we just added the OVS log files after
the existing file_output, then new OVS log files would only be included
*after* all archived system log files were added).

Bug #5443.

13 years agodatapath: Cleanup openvswitch.h formatting.
Jesse Gross [Sun, 23 Oct 2011 01:50:44 +0000 (18:50 -0700)]
datapath: Cleanup openvswitch.h formatting.

The userspace/kernel interface file had acquired a mixture of userspace
and kernel style, so this makes it use kernel style consistently.

Signed-off-by: Jesse Gross <jesse@nicira.com>
Acked-by: Ben Pfaff <blp@nicira.com>
13 years agodatapath: Define constants for versions of GENL families.
Jesse Gross [Sun, 23 Oct 2011 01:22:18 +0000 (18:22 -0700)]
datapath: Define constants for versions of GENL families.

Currently we hard code the versions of our GENL families to 1 but it's
nicer to have symbolic constants.

Signed-off-by: Jesse Gross <jesse@nicira.com>
Acked-by: Ben Pfaff <blp@nicira.com>
13 years agoovs-vswitchd: Add support for 802.1D STP.
Justin Pettit [Fri, 14 Oct 2011 16:48:17 +0000 (09:48 -0700)]
ovs-vswitchd: Add support for 802.1D STP.

Still alpha quality, since only tested for interoperability with Linux
bridge's STP implementation.

13 years agoofproto: Add function to set OpenFlow state and update controller.
Justin Pettit [Fri, 14 Oct 2011 22:45:14 +0000 (15:45 -0700)]
ofproto: Add function to set OpenFlow state and update controller.

This will be used in an upcoming commit.

13 years agoofproto: Mark 'ofproto' arg in is_mirror_output_bundle() as const.
Justin Pettit [Mon, 10 Oct 2011 23:44:28 +0000 (16:44 -0700)]
ofproto: Mark 'ofproto' arg in is_mirror_output_bundle() as const.

No changes are made to 'ofproto', so it's safe to mark the argument as
const.  This will be useful in a later commit.

13 years agoVarious bug fixes and cleanups to STP library.
Justin Pettit [Fri, 14 Oct 2011 16:48:43 +0000 (09:48 -0700)]
Various bug fixes and cleanups to STP library.

    - Don't apply endian conversions to flags, which are 8 bits.
    - Use #defines for default times for use outside library.
    - Clarify our behavior when in STP_DISABLED state.
    - Add "aux" member to STP port struct to be able to refer back to
      the owning port.
    - Define macros to print STP bridge and port ids.
    - New helper function to get port id.
    - New helper function to convert speed to cost.
    - New functions to describe current role of port.

13 years agoAdd back 802.1D Spanning Tree Protocol (STP) library code.
Justin Pettit [Tue, 20 Sep 2011 22:08:05 +0000 (15:08 -0700)]
Add back 802.1D Spanning Tree Protocol (STP) library code.

At one point, the OVS distribution contained an IEEE 802.1D Spanning
Tree Protocol (STP) library written by Ben Pfaff and based on the
802.1D-1998 reference code.  It was never integrated into ovs-vswitchd,
so it was removed as part of commit ba18611 (Remove vestigial support
for Spanning Tree Protocol.)

This commit reintroduces the library, cleans up a few spots, and makes
it build cleanly against new code.  A future commit will have
ovs-vswitchd use this library.

13 years agopackets.h: Fix STP destination MAC address.
Justin Pettit [Sat, 8 Oct 2011 01:24:12 +0000 (18:24 -0700)]
packets.h: Fix STP destination MAC address.

13 years agoofproto: Fix comment describing ofport_modified().
Justin Pettit [Fri, 14 Oct 2011 22:48:05 +0000 (15:48 -0700)]
ofproto: Fix comment describing ofport_modified().

13 years agoovs-vsctl: Fix small formatting error in man page.
Justin Pettit [Wed, 5 Oct 2011 07:13:56 +0000 (00:13 -0700)]
ovs-vsctl: Fix small formatting error in man page.

13 years agoofproto-dpif: Update bundle when OFPPC_NO_FLOOD changed.
Justin Pettit [Mon, 17 Oct 2011 17:27:35 +0000 (10:27 -0700)]
ofproto-dpif: Update bundle when OFPPC_NO_FLOOD changed.

When the OFPPC_NO_FLOOD flag is toggled on the port, the "floodable"
member of the bundle was not updated.  This would cause OFPP_NORMAL to
not include the proper ports when flooding.  With this commit,
OFPPC_NO_FLOOD changes will cause the floodable members to be
recalculated.

Found by inspection.

13 years agodatapath: Use kfree_skb() only on error paths.
Ben Pfaff [Fri, 21 Oct 2011 23:38:35 +0000 (16:38 -0700)]
datapath: Use kfree_skb() only on error paths.

Signed-off-by: Ben Pfaff <blp@nicira.com>
Acked-by: Jesse Gross <jesse@nicira.com>
13 years agodatapath: Fix uninitialized variable warning.
Jesse Gross [Fri, 21 Oct 2011 22:19:33 +0000 (15:19 -0700)]
datapath: Fix uninitialized variable warning.

Commit 4edb9ae90e4092f5f56b9d914d2b88783c49860d "datapath: Refactor
actions in terms of match fields." introduced a spurious warning
because the compiler thinks a value might not have been assigned to
'err'.  In practice this can't happen because we've already validated
the actions.

CC: Pravin B Shelar <pshelar@nicira.com>
Signed-off-by: Jesse Gross <jesse@nicira.com>
Acked-by: Pravin B Shelar <pshelar@nicira.com>
13 years agovport-capwap: Fix use-after-free on error path.
Ben Pfaff [Fri, 21 Oct 2011 22:34:25 +0000 (15:34 -0700)]
vport-capwap: Fix use-after-free on error path.

I originally meant just to fix the use of kfree_skb() instead of
consume_skb() on the success path, but then I realized that the failure
path returned an skb that it had just freed.

Signed-off-by: Ben Pfaff <blp@nicira.com>
Acked-by: Jesse Gross <jesse@nicira.com>
13 years agoImplement new fragment handling policy.
Ben Pfaff [Thu, 20 Oct 2011 04:33:44 +0000 (21:33 -0700)]
Implement new fragment handling policy.

Until now, OVS has handled IP fragments more awkwardly than necessary.  It
has not been possible to match on L4 headers, even in fragments with offset
0 where they are actually present.  This means that there was no way to
implement ACLs that treat, say, different TCP ports differently, on
fragmented traffic; instead, all decisions for fragment forwarding had to
be made on the basis of L2 and L3 headers alone.

This commit improves the situation significantly.  It is still not possible
to match on L4 headers in fragments with nonzero offset, because that
information is simply not present in such fragments, but this commit adds
the ability to match on L4 headers for fragments with zero offset.  This
means that it becomes possible to implement ACLs that drop such "first
fragments" on the basis of L4 headers.  In practice, that effectively
blocks even fragmented traffic on an L4 basis, because the receiving IP
stack cannot reassemble a full packet when the first fragment is missing.

This commit works by adding a new "fragment type" to the kernel flow match
and making it available through OpenFlow as a new NXM field named
NXM_NX_IP_FRAG.  Because OpenFlow 1.0 explicitly says that the L4 fields
are always 0 for IP fragments, it adds a new OpenFlow fragment handling
mode that fills in the L4 fields for "first fragments".  It also enhances
ovs-ofctl to allow users to configure this new fragment handling mode and
to parse the new field.

Signed-off-by: Ben Pfaff <blp@nicira.com>
Bug #7557.

13 years agodatapath: Refactor actions in terms of match fields.
Pravin B Shelar [Fri, 21 Oct 2011 21:38:54 +0000 (14:38 -0700)]
datapath: Refactor actions in terms of match fields.

Almost all current actions can be expressed in the form of
push/pop/set <field>, where field is one of the match fields. We can
create three base actions and take a field. This has both a nice
symmetry and avoids inconsistencies where we can match on the vlan
TPID but not set it.
Following patch converts all actions to this new format.

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

13 years agodatapath: Update supported kernel check.
Pravin B Shelar [Fri, 21 Oct 2011 21:17:38 +0000 (14:17 -0700)]
datapath: Update supported kernel check.

Signed-off-by: Pravin Shelar <pshelar@nicira.com>
Acked-by: Jesse Gross <jesse@nicira.com>
13 years agotunnel: Handle hh_cache access for Linux kernel 3.1
Pravin B Shelar [Fri, 21 Oct 2011 21:16:59 +0000 (14:16 -0700)]
tunnel: Handle hh_cache access for Linux kernel 3.1

From 3.1 kernel, struct dst_entry no longer has direct ref to hh_cache.
Following patch handles this case.

Signed-off-by: Pravin Shelar <pshelar@nicira.com>
Acked-by: Jesse Gross <jesse@nicira.com>
13 years agotunnel: hh_cache access cleanup
Pravin B Shelar [Fri, 21 Oct 2011 21:16:04 +0000 (14:16 -0700)]
tunnel: hh_cache access cleanup

Following patch cleanup hh_cache access by avoiding hh pointer fetching
most of time. Now hh is read and checked at beginning of function. All
hh->hh_len access are done inside hh_lock.
This is required cleanup for next patch which adds support for kernel
3.1.

Suggested-by: Jesse Gross <jesse@nicira.com>
Signed-off-by: Pravin Shelar <pshelar@nicira.com>
Acked-by: Jesse Gross <jesse@nicira.com>
13 years agoofproto-dpif: Increase recursion limit.
Ben Pfaff [Wed, 19 Oct 2011 20:18:30 +0000 (13:18 -0700)]
ofproto-dpif: Increase recursion limit.

Requested-by: Pankaj Thakkar <thakkar@nicira.com>
Bug #7874.

13 years agotest-lockfile: Provide better diagnostics on failure.
Ben Pfaff [Thu, 29 Sep 2011 17:39:49 +0000 (10:39 -0700)]
test-lockfile: Provide better diagnostics on failure.

We spotted one failure of the "lock_timeout_runs_out" test several builds
ago, but there weren't enough diagnostics to track it down and I couldn't
reproduce it.

This commit should make the failure easier to understand if it recurs.

CC: Michael Hu <mhu@nicira.com>
13 years agoofp-util: Avoid misaligned memory access in ofputil_encode_packet_in().
Ben Pfaff [Tue, 18 Oct 2011 21:00:57 +0000 (14:00 -0700)]
ofp-util: Avoid misaligned memory access in ofputil_encode_packet_in().

Reported-by: Murphy McCauley <murphy.mccauley@gmail.com>
13 years agoofp-parse: Validate range of table, priority, and timeout values.
Ben Pfaff [Tue, 27 Sep 2011 23:58:55 +0000 (16:58 -0700)]
ofp-parse: Validate range of table, priority, and timeout values.

Otherwise, "table=257" (e.g.) was silently accepted but had a surprising
effect.

Bug #7445.
Reported-by: Michael Mao <mmao@nicira.com>
13 years agovlog: Skip reopening a log file if it would have no effect.
Ben Pfaff [Fri, 14 Oct 2011 18:37:24 +0000 (11:37 -0700)]
vlog: Skip reopening a log file if it would have no effect.

Avoids redundant "closing log file"/"opened log file" messages in log files.

Reported-by: Reid Price <reid@nicira.com>
Bug #7750.

13 years agoofproto-dpif: Make OFPAT_ENQUEUE to input port do nothing.
Ben Pfaff [Sun, 9 Oct 2011 22:52:21 +0000 (15:52 -0700)]
ofproto-dpif: Make OFPAT_ENQUEUE to input port do nothing.

This makes OFPAT_ENQUEUE consistent with OFPAT_OUTPUT for the purpose of
sending a packet back out the input port: both only do it if the port is
given as OFPP_IN_PORT.

Found by inspection.

13 years agolearn: Correct example in nicira-ext.h and add examples as test cases.
Ben Pfaff [Tue, 27 Sep 2011 20:35:09 +0000 (13:35 -0700)]
learn: Correct example in nicira-ext.h and add examples as test cases.

13 years agolearn: Check learn actions after parsing in learn_parse().
Ben Pfaff [Tue, 27 Sep 2011 20:12:04 +0000 (13:12 -0700)]
learn: Check learn actions after parsing in learn_parse().

learn_parse() and learn_check() are supposed to apply the same checks, but
they are implemented very differently.  It seems best to have learn_parse()
actually call learn_check() just to be sure.

This would have caught the bug fixed in the previous commit, because
the tests actually contain instances of "learn" actions that trigger the
bug, but the tests only parsed the actions without ever doing anything
that checked them (like sending them to ovs-vswitchd over OpenFlow).

13 years agolearn: Allow read-only fields to be matched.
Ben Pfaff [Tue, 27 Sep 2011 20:10:58 +0000 (13:10 -0700)]
learn: Allow read-only fields to be matched.

nxm_dst_check() requires a writable field.  Since NX_LEARN_DST_MATCH only
matches on a field and doesn't write to a field, use nxm_src_check() for
that case instead.

Bug #7507.
Reported-by: Michael Mao <mmao@nicira.com>
13 years agonx-match: Improve log message for errors parsing NX flow matches.
Ben Pfaff [Tue, 27 Sep 2011 20:03:00 +0000 (13:03 -0700)]
nx-match: Improve log message for errors parsing NX flow matches.

13 years agoovsdb: Remove dead Python-related code.
Ben Pfaff [Tue, 18 Oct 2011 16:29:54 +0000 (09:29 -0700)]
ovsdb: Remove dead Python-related code.

Initial versions of commit 8cdf034974 "python: Implement write support in
Python IDL for OVSDB" converted the OVSDB schemas to Python code so that
their Python clients could just import them.  The final version instead
read the schemas from a file, but I forgot to remove some code that
generated the Python schema modules.  This commit removes that code.

Reported-by: Ethan Jackson <ethan@nicira.com>
13 years agodatapath: Fix tunnel reconfiguration that does not change key data.
Ben Pfaff [Mon, 17 Oct 2011 18:32:23 +0000 (11:32 -0700)]
datapath: Fix tunnel reconfiguration that does not change key data.

Without this commit, a pair of commands like
    ovs-dpctl add-if br0 gre0,type=gre,remote_ip=192.168.5.2,csum=true
    ovs-dpctl set-if br0 gre0,csum=false
would result in a csum of "true" for gre0, that is, the second command
would silently have no effect.  This could also happen when the key data
(such as remote_ip) changed but the port hash just happened to have the
same value.

This also fixes a small kernel memory leak in this case.

An upcoming commit implements the "ovs-dpctl set-if" command mentioned
above.

Signed-off-by: Ben Pfaff <blp@nicira.com>
Acked-by: Jesse Gross <jesse@nicira.com>
13 years agodatapath: Reject attempts to change vport type with OVS_VPORT_CMD_SET.
Ben Pfaff [Mon, 17 Oct 2011 18:03:22 +0000 (11:03 -0700)]
datapath: Reject attempts to change vport type with OVS_VPORT_CMD_SET.

Until now this has just silently failed, but it seems to me like we should
actively reject it.

Signed-off-by: Ben Pfaff <blp@nicira.com>
Acked-by: Jesse Gross <jesse@nicira.com>
13 years agoofproto-dpif: Fix in-band action for sFlow.
Pravin B Shelar [Tue, 18 Oct 2011 18:15:43 +0000 (11:15 -0700)]
ofproto-dpif: Fix in-band action for sFlow.

        Use compose_output_action() API to generate OUTPUT action so
that sFlow can record output port.

13 years agotypes: Fix endianness check.
Ben Pfaff [Tue, 18 Oct 2011 16:46:57 +0000 (09:46 -0700)]
types: Fix endianness check.

The Linux headers only check endianness if __CHECK_ENDIAN__ is declared.
We want that, so turn it on.

13 years agodatapath: Assert IFF_TX_SKB_SHARING on internal devices.
Jesse Gross [Wed, 21 Sep 2011 02:09:50 +0000 (19:09 -0700)]
datapath: Assert IFF_TX_SKB_SHARING on internal devices.

Linux 3.1 adds a flag to check whether it's OK for shared skbs to
be transmitted on devices.  This generally isn't a problem for
hardware devices but software devices such as OVS that hold state
in the skb need to clear the flag, which is enabled by default.

Signed-off-by: Jesse Gross <jesse@nicira.com>
Acked-by: Ben Pfaff <blp@nicira.com>
13 years agodatapath: Add version check for struct netdev_ops.
Jesse Gross [Wed, 21 Sep 2011 02:12:32 +0000 (19:12 -0700)]
datapath: Add version check for struct netdev_ops.

Linux 3.1 drops the symbol HAVE_NET_DEVICE_OPS that lets us know
whether struct netdev_ops is present.  As a result, we need to
replace it with an explicit version check.

Signed-off-by: Jesse Gross <jesse@nicira.com>
Acked-by: Ben Pfaff <blp@nicira.com>
13 years agobridge: Allow specially named "unix:" controllers.
Ben Pfaff [Tue, 18 Oct 2011 15:57:37 +0000 (08:57 -0700)]
bridge: Allow specially named "unix:" controllers.

Some users want to use Unix domain socket controllers, so this relaxes the
restriction.

Requested-by: Jari Sundell <sundell.software@gmail.com>
13 years agovswitchd: New column "link_resets".
Ethan Jackson [Fri, 14 Oct 2011 19:49:57 +0000 (12:49 -0700)]
vswitchd: New column "link_resets".

An interface's 'link_resets' column represents the number of times
Open vSwitch has observed its link_state change.

13 years agonetdev-linux: Maintain carrier flag constantly.
Ethan Jackson [Sat, 15 Oct 2011 01:13:04 +0000 (18:13 -0700)]
netdev-linux: Maintain carrier flag constantly.

Before this patch, the carrier of a linux device was only updated
if requested by a caller.  This patch updates it whenever it
changes.

13 years agovswitchd: Update link_state instantly.
Ethan Jackson [Sat, 15 Oct 2011 00:29:35 +0000 (17:29 -0700)]
vswitchd: Update link_state instantly.

With this patch, instead of updating an interface's link_state once
every 5 seconds, it's updated immediately when changed.  To avoid
stressing the database, these updates are rate limited to once per
second.

13 years agovswitchd: Cleanup rate limited DB writes.
Ethan Jackson [Sat, 15 Oct 2011 00:20:25 +0000 (17:20 -0700)]
vswitchd: Cleanup rate limited DB writes.

The code to write the 'lacp_current' flag to the database was
unnecessarily complicated.  Future patches will directly benefit
from this refactoring.

13 years agovswitchd: Remove iface_get_carrier().
Ethan Jackson [Fri, 14 Oct 2011 22:17:19 +0000 (15:17 -0700)]
vswitchd: Remove iface_get_carrier().

It has only one caller, and doesn't improve the code's readability.

13 years agortnetlink-link: Expose carrier changes.
Ethan Jackson [Fri, 14 Oct 2011 22:39:49 +0000 (15:39 -0700)]
rtnetlink-link: Expose carrier changes.

This will be used in a future commit.

13 years agobond: Demote active-backup WARN to DBG.
Ben Pfaff [Mon, 17 Oct 2011 19:22:34 +0000 (12:22 -0700)]
bond: Demote active-backup WARN to DBG.

This log message comes up for packets that are flooded through the network.
If the upstream switch doesn't realize that an active-backup bond is in
use, and there is significant packet flooding in the network, then we will
get a lot of these messages.

(This message doesn't get logged for multicast or broadcast packets since
they get dropped earlier in the function.)

Reported-by: Eivind Bulie Haanaes
Bug-report: http://forums.citrix.com/thread.jspa?messageID=1589125
CC: Paul Fazzone <pfazzone@nicira.com>
13 years agobridge: Forbid '/' in bridge names to prevent arbitrary directory access.
Ben Pfaff [Fri, 14 Oct 2011 17:17:41 +0000 (10:17 -0700)]
bridge: Forbid '/' in bridge names to prevent arbitrary directory access.

13 years agodatapath: Simplify tnl_find_port().
Ben Pfaff [Fri, 14 Oct 2011 22:33:49 +0000 (15:33 -0700)]
datapath: Simplify tnl_find_port().

It's only called when we want a best-match now, so there's no need to pass
in any flags that indicate the desired type of match.

Signed-off-by: Ben Pfaff <blp@nicira.com>
Acked-by: Jesse Gross <jesse@nicira.com>
13 years agodatapath: Avoid confusing tunnels that have different types.
Ben Pfaff [Fri, 14 Oct 2011 21:33:11 +0000 (14:33 -0700)]
datapath: Avoid confusing tunnels that have different types.

Without this change, the following commands succeed:
    # ovs-dpctl add-if br1 gre1,type=gre,remote_ip=1.2.3.4,local_ip=2.3.4.5
    # ovs-dpctl add-if br1 gre0,type=gre,remote_ip=1.2.3.4
but if they are run in the opposite order, they fail with:
    ovs-dpctl: adding gre1 to br1 failed (File exists)

This fixes the problem.

Signed-off-by: Ben Pfaff <blp@nicira.com>
Acked-by: Jesse Gross <jesse@nicira.com>
13 years agodatapath: Factor out repeated tnl_vport_to_vport() calls.
Ben Pfaff [Fri, 14 Oct 2011 21:28:49 +0000 (14:28 -0700)]
datapath: Factor out repeated tnl_vport_to_vport() calls.

This is a code cleanup only.

Signed-off-by: Ben Pfaff <blp@nicira.com>
Acked-by: Jesse Gross <jesse@nicira.com>
13 years agoofproto-dpif: Batch interacting with the dpif on flow miss operations.
Ben Pfaff [Fri, 14 Oct 2011 20:55:32 +0000 (13:55 -0700)]
ofproto-dpif: Batch interacting with the dpif on flow miss operations.

This improves "ovs-benchmark rate" performance in my testing by about 24%.

A quick experiment shows that there may still be some headroom for batching
flow deletions on facet expiration, up to perhaps 10% additional
improvement.

13 years agoofproto-dpif: Separate facet creation and action translation.
Ben Pfaff [Tue, 27 Sep 2011 22:58:53 +0000 (15:58 -0700)]
ofproto-dpif: Separate facet creation and action translation.

This will allow for some optimization in an upcoming commit.

13 years agoofproto-dpif: Factor controller optimization out of execute_odp_actions().
Ben Pfaff [Tue, 27 Sep 2011 22:34:39 +0000 (15:34 -0700)]
ofproto-dpif: Factor controller optimization out of execute_odp_actions().

An upcoming commit will use this code separately from
execute_odp_actions(), so this prepares for that.

13 years agoofproto-dpif: Break send_packet_in() into two separate functions.
Ben Pfaff [Tue, 27 Sep 2011 22:22:22 +0000 (15:22 -0700)]
ofproto-dpif: Break send_packet_in() into two separate functions.

It's been more or less convenient to pass a dpif_upcall to send_packet_in()
in the past, because most callers had one handy.  But an upcoming commit
won't have such easy access, so this commit breaks send_packet_in() into
two functions for the different types of packets to send to the controller,
each of which takes appropriate parameters instead of dpif_upcall.

13 years agodpif: New function dpif_operate() and dpif-linux implementation.
Ben Pfaff [Tue, 27 Sep 2011 22:08:50 +0000 (15:08 -0700)]
dpif: New function dpif_operate() and dpif-linux implementation.

This will be used in an upcoming commit.

13 years agonetlink-socket: New function nl_sock_transact_multiple().
Ben Pfaff [Fri, 14 Oct 2011 20:55:00 +0000 (13:55 -0700)]
netlink-socket: New function nl_sock_transact_multiple().

This will be used in an upcoming commit.

13 years agosocket-util: New function get_socket_rcvbuf().
Ben Pfaff [Fri, 14 Oct 2011 20:30:29 +0000 (13:30 -0700)]
socket-util: New function get_socket_rcvbuf().

This will be used in an upcoming commit.

13 years agodpif-linux: Only ask datapath to echo back results when they will be used.
Ben Pfaff [Tue, 27 Sep 2011 23:07:23 +0000 (16:07 -0700)]
dpif-linux: Only ask datapath to echo back results when they will be used.

A fair number of datapath flow operations optionally report back results
to the requester based on whether NLM_F_ECHO is set in the request.  When
userspace isn't going to use those results anyway, it wastes memory to
store them and a system call to retrieve them.

This commit omits the NLM_F_ECHO bit in cases where the caller isn't going
to use the results.

(NLM_F_ECHO has no effect on operations whose entire purpose is to retrieve
data, e.g. "get" and "dump" operations, so we need not bother to set it
for those.)

This improves "ovs-benchmark rate" results in my testing by about 4%.

13 years agoofproto-dpif: Move DHCP in-band control special case into xlate_actions().
Ben Pfaff [Tue, 27 Sep 2011 22:19:30 +0000 (15:19 -0700)]
ofproto-dpif: Move DHCP in-band control special case into xlate_actions().

This eliminates an extra round trip to the kernel for this special case
and keeps all the flow translation logic in one place.

13 years agonetlink: New macros for the sizes of Netlink attributes.
Ben Pfaff [Mon, 26 Sep 2011 19:59:23 +0000 (12:59 -0700)]
netlink: New macros for the sizes of Netlink attributes.

I was feeling tempted in some code to just guess "hey, 32 bytes ought to
be big enough" and so on, but really it seems better to just have a
convenient way to measure.

13 years agonetlink: New functions for putting attributes at the beginning of a buffer.
Ben Pfaff [Mon, 26 Sep 2011 19:57:41 +0000 (12:57 -0700)]
netlink: New functions for putting attributes at the beginning of a buffer.

These are really just copies of the corresponding "put" functions.  An
upcoming commit will introduce a user of nl_msg_push_u32().  I thought I
might as well create all of these while I was at it.

13 years agoofproto-dpif: Revalidate tagged packets, too, in facet_lookup_valid().
Ben Pfaff [Tue, 27 Sep 2011 22:32:18 +0000 (15:32 -0700)]
ofproto-dpif: Revalidate tagged packets, too, in facet_lookup_valid().

I don't see a reason that we should only revalidate facets if we're
revalidating every facet.

13 years agoofproto-dpif: Properly re-translate uninstallable facets in rule_execute().
Ben Pfaff [Tue, 27 Sep 2011 23:24:15 +0000 (16:24 -0700)]
ofproto-dpif: Properly re-translate uninstallable facets in rule_execute().

If the facet is not installable then every packet requires separate
translation, but the existing code didn't do that.

13 years agodpif-linux: Fix build with certain 64-bit kernel/userspace combinations.
Ben Pfaff [Fri, 14 Oct 2011 16:39:48 +0000 (09:39 -0700)]
dpif-linux: Fix build with certain 64-bit kernel/userspace combinations.

Unix 64-bit ABIs have two 64-bit types: "long" and "long long".  Either of
these is a reasonable choice for uint64_t (the userspace type) and for
__u64 (the kernel type).  Unfortunately, kernel and userspace don't
necessarily agree on the choice, and in fact the choice varies across
kernel versions and architectures.

Now that OVS is actually using kernel types in its kernel header, this
can make a difference: when __u64 and uint64_t differ, passing a pointer
to __u64 to OVS function get_unaligned_u64() yields a compiler warning
or error.

This commit fixes up the problems of this type found in OVS, by making
get_unaligned_u64() accept all 64-bit unsigned integer types, not just
whichever one happens to be uint64_t.  I didn't do the same thing for
put_unaligned_u64() because it is less likely to be a problem in
practice: usually, when userspace writes to kernel data structures it
does so with copies that it knows to be aligned, so that it's not
necessary to use put_unaligned_u64().

This problem won't occur for uint8_t, uint16_t, or uint32_t, since there is
only one reasonable choice of type for each.  It won't occur for ovs_be<N>
because OVS always defines those as aliases for the kernel's __be<N> types
when those are available.

This compiled cleanly for me in Scientific Linux 6.0 x86-64.

Reported-by: Pravin Shelar <pshelar@nicira.com>
13 years agoFix broken build in XenServer DDK 5.6.100-39265p.
Ben Pfaff [Thu, 13 Oct 2011 21:38:13 +0000 (14:38 -0700)]
Fix broken build in XenServer DDK 5.6.100-39265p.

Avoids errors like the following:

In file included from ./include/openvswitch/types.h:21,
                 from ./lib/vconn.h:21,
                 from tests/test-vconn.c:18:
/usr/include/sys/types.h:52: error: conflicting types for 'ino_t'
/usr/include/linux/types.h:14: error: previous declaration of 'ino_t' was here
/usr/include/sys/types.h:62: error: conflicting types for 'dev_t'
/usr/include/linux/types.h:13: error: previous declaration of 'dev_t' was here
/usr/include/sys/types.h:67: error: conflicting types for 'gid_t'
/usr/include/linux/types.h:27: error: previous declaration of 'gid_t' was here
/usr/include/sys/types.h:72: error: conflicting types for 'mode_t'
/usr/include/linux/types.h:15: error: previous declaration of 'mode_t' was here
/usr/include/sys/types.h:77: error: conflicting types for 'nlink_t'
/usr/include/linux/types.h:16: error: previous declaration of 'nlink_t' was here
/usr/include/sys/types.h:82: error: conflicting types for 'uid_t'
/usr/include/linux/types.h:26: error: previous declaration of 'uid_t' was here
/usr/include/sys/types.h:90: error: conflicting types for 'off_t'
/usr/include/linux/types.h:17: error: previous declaration of 'off_t' was here

13 years agoofproto-dpif: Avoid bad pointer dereference in execute_odp_actions().
Ben Pfaff [Thu, 13 Oct 2011 17:16:59 +0000 (10:16 -0700)]
ofproto-dpif: Avoid bad pointer dereference in execute_odp_actions().

execute_odp_actions() can be passed a zero-length set of actions, in which
case it may not dereference its 'odp_actions' parameter at all, but in fact
it did do so.  In at least one corner case, odp_actions can be NULL, so
that this caused a segfault.

Introduced in commit 98403001ec "datapath: Move Netlink PID for userspace
actions from flows to actions."

Reported-by: Pravin Shelar <pshelar@nicira.com>
13 years agodatapath-protocol: Rename to <linux/openvswitch.h>.
Ben Pfaff [Wed, 5 Oct 2011 17:50:58 +0000 (10:50 -0700)]
datapath-protocol: Rename to <linux/openvswitch.h>.

Signed-off-by: Ben Pfaff <blp@nicira.com>
Acked-by: Jesse Gross <jesse@nicira.com>
Bug #7559.

13 years agodatapath-protocol: Use Linux kernel types directly.
Ben Pfaff [Wed, 5 Oct 2011 17:42:34 +0000 (10:42 -0700)]
datapath-protocol: Use Linux kernel types directly.

We want datapath-protocol.h to be acceptable as a Linux kernel header, so
it must use Linux kernel types and must not have references to Open vSwitch
symbols or header files.  This commit primarily makes that change to
datapath-protocol.h.

At the same time, at least for now we also want datapath-protocol.h to be
usable on non-Linux platforms, so we need some kind of compatiblity.  Thus,
this commit also introduces a <linux/types.h> header file that defines the
necessary Linux kernel types on non-Linux platforms.

In turn, this requires openvswitch/types.h to use the Linux types directly
for ovs_be<N>; otherwise, sparse complains because now __be<N> and
ovs_be<N> are incompatible from its perspective, so this commit makes that
change too.

I don't have a non-Linux kernel platform readily available, so I only
tested the non-Linux part of the linux/types.h substitute by forcing that
case to be triggered with #if 0.  It worked, except for errors in actual
Linux kernel headers included explicitly from OVS source files, so I think
it's likely to work in practice.

Bug #7559.
Signed-off-by: Ben Pfaff <blp@nicira.com>
Acked-by: Jesse Gross <jesse@nicira.com>
13 years agodatapath-protocol: Rename enums for consistency.
Ben Pfaff [Wed, 5 Oct 2011 16:59:51 +0000 (09:59 -0700)]
datapath-protocol: Rename enums for consistency.

Most of the enum tags in this file are lowercased versions of the uppercase
enum prefixes (or slightly less abbreviated versions, e.g. "dp" becomes
"datapath").  This commit fixes up the others for consistency.

Signed-off-by: Ben Pfaff <blp@nicira.com>
Acked-by: Jesse Gross <jesse@nicira.com>
13 years agodatapath-protocol: Remove socket header #include.
Ben Pfaff [Wed, 5 Oct 2011 15:34:17 +0000 (08:34 -0700)]
datapath-protocol: Remove socket header #include.

It's not needed.

Signed-off-by: Ben Pfaff <blp@nicira.com>
Acked-by: Jesse Gross <jesse@nicira.com>
Bug #7559.

13 years agodatapath-protocol: Remove #include <linux/netlink.h>.
Ben Pfaff [Tue, 4 Oct 2011 22:30:40 +0000 (15:30 -0700)]
datapath-protocol: Remove #include <linux/netlink.h>.

Bug #7559.
Signed-off-by: Ben Pfaff <blp@nicira.com>
Acked-by: Jesse Gross <jesse@nicira.com>
13 years agodatapath: Require explicit upcall_pid for new datapaths and vports.
Ben Pfaff [Wed, 12 Oct 2011 18:04:10 +0000 (11:04 -0700)]
datapath: Require explicit upcall_pid for new datapaths and vports.

This increases consistency with the OVS_ACTION_ATTR_USERSPACE action, which
also requires an explicit pid.

Suggested-by: Jesse Gross <jesse@nicira.com>
Signed-off-by: Ben Pfaff <blp@nicira.com>
Acked-by: Jesse Gross <jesse@nicira.com>
13 years agodatapath: Move Netlink PID for userspace actions from flows to actions.
Ben Pfaff [Wed, 12 Oct 2011 23:24:54 +0000 (16:24 -0700)]
datapath: Move Netlink PID for userspace actions from flows to actions.

Commit b063d9f06 "datapath: Use unicast Netlink sockets for upcalls" that
switched from multicast to unicast Netlink for sending upcalls added a
Netlink PID to each kernel flow, used by OVS_ACTION_ATTR_USERSPACE actions
within the flow as target.

This commit drops this per-flow PID in favor of a per-action PID, because
that is more flexible.  It does not yet make use of this additional
flexibility, so behavior should not change.

Signed-off-by: Ben Pfaff <blp@nicira.com>
Acked-by: Jesse Gross <jesse@nicira.com>
Bug #7559.

13 years agodpif-linux: Avoid unaligned accesses to vport stats sent by the datapath.
Ben Pfaff [Tue, 11 Oct 2011 19:24:41 +0000 (12:24 -0700)]
dpif-linux: Avoid unaligned accesses to vport stats sent by the datapath.

Reported-by: Jesse Gross <jesse@nicira.com>
13 years agodpif-linux: Use get_32aligned_u64() in an appropriate place.
Ben Pfaff [Tue, 4 Oct 2011 22:25:14 +0000 (15:25 -0700)]
dpif-linux: Use get_32aligned_u64() in an appropriate place.

13 years agovswitch.xml: Correct CAPWAP minimum Linux kernel version.
Ben Pfaff [Wed, 12 Oct 2011 20:20:31 +0000 (13:20 -0700)]
vswitch.xml: Correct CAPWAP minimum Linux kernel version.

13 years agoovs-vsctl: Update man page description of controller support.
Justin Pettit [Wed, 12 Oct 2011 18:09:47 +0000 (11:09 -0700)]
ovs-vsctl: Update man page description of controller support.

ovs-vswitchd supports passive OpenFlow connections, but that was not
indicated in the documentation.  Add that information as well as a
description of Primary (active) and Service (passive) control
connections.

13 years agoovs-vsctl: Print warning for invalid controller and manager targets.
Justin Pettit [Wed, 12 Oct 2011 07:03:10 +0000 (00:03 -0700)]
ovs-vsctl: Print warning for invalid controller and manager targets.

13 years agoovs.db.types: Consistently use commas in formatting large numbers.
Ben Pfaff [Wed, 12 Oct 2011 17:20:37 +0000 (10:20 -0700)]
ovs.db.types: Consistently use commas in formatting large numbers.

Suggested-by: Justin Pettit <jpettit@nicira.com>
13 years agovswitchd: Document constraints on keys.
Ben Pfaff [Tue, 4 Oct 2011 17:31:59 +0000 (10:31 -0700)]
vswitchd: Document constraints on keys.

Suggested-by: Justin Pettit <jpettit@nicira.com>
13 years agometa-flow: Fix mf_get_value() retrieval of register values.
Ben Pfaff [Tue, 11 Oct 2011 13:58:49 +0000 (06:58 -0700)]
meta-flow: Fix mf_get_value() retrieval of register values.

13 years agocfm: New 'cfm_opstate' setting.
Ethan Jackson [Fri, 7 Oct 2011 05:43:05 +0000 (22:43 -0700)]
cfm: New 'cfm_opstate' setting.

In some cases, a controller may want to take an interface down for
forwarding purposes, but avoid completely deconfiguring CFM and
thus lose all connectivity monitoring.  The new 'cfm_opstate'
setting is a way to achieve this behavior.

13 years agocfm: Show extended mode in cfm/show appctl command.
Ethan Jackson [Sun, 9 Oct 2011 22:03:53 +0000 (15:03 -0700)]
cfm: Show extended mode in cfm/show appctl command.

13 years agovswitch.xml: Annotate 'false' keyword in CFM documentation.
Ethan Jackson [Sun, 9 Oct 2011 21:35:47 +0000 (14:35 -0700)]
vswitch.xml: Annotate 'false' keyword in CFM documentation.

13 years agodpif-netdev: Implement OVS_ACTION_ATTR_SAMPLE action.
Ben Pfaff [Tue, 11 Oct 2011 18:07:14 +0000 (11:07 -0700)]
dpif-netdev: Implement OVS_ACTION_ATTR_SAMPLE action.

OVS_ACTION_ATTR_SAMPLE has never been implemented in dpif-netdev.  This
commit implements it and adds a cast to enum ovs_action_type in the switch
statement that checks the action type, so that GCC complains if we forget
to add a case for a new action type.

I had to assign the return value of nl_attr_type() to a temporary variable,
because "switch ((enum ovs_action_type) nl_attr_type(a))" provoked a GCC
warning that I've never seen before:

../lib/dpif-netdev.c:1260: warning: cast from function call of type 'int'
     to non-matching type 'enum ovs_action_type'

13 years agodpif-netdev: Simplify code by removing dpif_netdev_validate_actions().
Ben Pfaff [Wed, 5 Oct 2011 16:04:50 +0000 (09:04 -0700)]
dpif-netdev: Simplify code by removing dpif_netdev_validate_actions().

dpif_netdev_validate_actions() existed for three reasons.  First, it checked
that the actions were well-formed and valid.  This isn't really necessary,
because the actions are built internally by ofproto-dpif and will always be
well-formed.  (If not, that's a bug in ofproto-dpif.)  Second, it checks
whether the actions will modify (mutate) the data in the packet and reports
that to the caller, which can use it to optimize what it does.  However,
the only caller that used this was dpif_netdev_execute(), which is not a
fast-path (if dpif-netdev can be said to have a fast path at all).

Third, dpif_netdev_validate_actions() rejects certain actions that
dpif-netdev does not implement: OVS_ACTION_ATTR_SET_TUNNEL,
OVS_ACTION_ATTR_SET_PRIORITY, and OVS_ACTION_ATTR_POP_PRIORITY.  However,
this doesn't really seem necessary to me.  First, dpif-netdev can't support
tunnels in any case, so OVS_ACTION_ATTR_SET_TUNNEL shouldn't come up.
Second, the priority actions just aren't important enough to worry about;
they only affect QoS, which isn't really important with dpif-netdev since
it's going to be slow anyway.

So this commit just drops dpif_netdev_validate_actions() entirely.

13 years agonetlink: New macros NL_NESTED_FOR_EACH, NL_NESTED_FOR_EACH_UNSAFE.
Ben Pfaff [Wed, 5 Oct 2011 16:36:11 +0000 (09:36 -0700)]
netlink: New macros NL_NESTED_FOR_EACH, NL_NESTED_FOR_EACH_UNSAFE.

Upcoming commits will introduce more users.

13 years agoopenflow: Delete icmp_type and icmp_code macros.
Ben Pfaff [Wed, 5 Oct 2011 18:06:12 +0000 (11:06 -0700)]
openflow: Delete icmp_type and icmp_code macros.

These macros caused trouble if datapath-protocol.h was included before
openflow.h.  Later references to the icmp_type and icmp_code members of
struct ovs_key_icmp caused compiler errors, because the macros caused them
to try to refer to nonexistent tp_src and tp_dst members in those
structures.

13 years agoovs-bugtool: Add -s to "ovs-dpctl show" command, to show vport statistics.
Ben Pfaff [Mon, 10 Oct 2011 17:29:49 +0000 (10:29 -0700)]
ovs-bugtool: Add -s to "ovs-dpctl show" command, to show vport statistics.

It would be nice to include this in xen-bugtool output too but that would
require Citrix to patch xen-bugtool directly.

Bug #7628.
Reported-by: Ethan Jackson <ethan@nicira.com>
13 years agocfm: Send properly formatted CCMs.
Ben Pfaff [Fri, 7 Oct 2011 22:43:43 +0000 (15:43 -0700)]
cfm: Send properly formatted CCMs.

Wireshark complained that Open vSwitch-generated CFM messages were
malformed.  Upon looking at the standard, I spotted that Open vSwitch
failed to include the final, required "End TLV" byte with value 0.

This commit adds the End TLV byte to generated CCMs but still accepts
the truncated messages for backward compatibility.

13 years agodpif-linux: Don't reset kernel upcall_pids unintentionally.
Ben Pfaff [Fri, 7 Oct 2011 23:41:36 +0000 (16:41 -0700)]
dpif-linux: Don't reset kernel upcall_pids unintentionally.

Commit b063d9f0 "datapath: Use unicast Netlink sockets for upcalls" that
introduced an 'upcall_pid' member into struct dpif_linux_vport, struct
dpif_linux_dp, and struct dpif_linux_flow neglected to do so only if the
member was nonzero.  This caused every datapath, vport, and flow operation
to supply an upcall_pid.  In particular, the netdev_set_config() called at
startup when a vport already existed caused the upcall_pid for that vport
to be reset to 0, which in turn caused all packets received on the vport to
be dropped instead of forwarded to ovs-vswitchd.

Reported-by: Shih-Hao Li <shli@nicira.com>
Bug #7714.

13 years agovswitch.ovsschema: Mark more CFM columns ephemeral.
Ben Pfaff [Thu, 6 Oct 2011 18:36:05 +0000 (11:36 -0700)]
vswitch.ovsschema: Mark more CFM columns ephemeral.

I spotted these being logged to the database.  That doesn't match up with
our usual model, so mark them ephemeral.

13 years agodatapath: Remove RT kernel support.
Pravin B Shelar [Fri, 7 Oct 2011 04:52:39 +0000 (21:52 -0700)]
datapath: Remove RT kernel support.

Following patch removes RT kernel support. This allows us to cleanup
the loop detection.
Along with this BH is now disabled while running execute_actions()
for packet from user-space.
As a result we can simplify the stats code as entire send and receive
path runs in BH context on all supported platforms.

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

13 years agodatapath: Fix recv path for CONFIG_PREEMPT_RCU.
Pravin B Shelar [Fri, 7 Oct 2011 02:45:09 +0000 (19:45 -0700)]
datapath: Fix recv path for CONFIG_PREEMPT_RCU.

        In case CONFIG_PREEMPT_RCU, rcu grace period waits only for RCU
read-side critical sections that are delimited by rcu_read_lock() and
rcu_read_unlock(). internal_dev_xmit() is called in
rcu_read_lock_bh context. Therefore we need to explicitly take rcu
lock to prevent race with call_rcu() in PREEMPT_RCU case.

Signed-off-by: Pravin B Shelar <pshelar@nicira.com>
Acked-by: Jesse Gross <jesse@nicira.com>
13 years agoovs-monitor-ipsec: Fix use_ssl_cert option implementation.
Ben Pfaff [Thu, 6 Oct 2011 21:54:30 +0000 (14:54 -0700)]
ovs-monitor-ipsec: Fix use_ssl_cert option implementation.

I skipped writing a unit test for this feature on the first go-around, and
of course that meant it didn't work.

Bug #7693.
Reported-by: Michael Hu <mhu@nicira.com>