sliver-openvswitch.git
13 years agodocs: Make it clear that ovs-openflowd is an alternative to ovs-vswitchd.
Ben Pfaff [Thu, 14 Oct 2010 16:44:26 +0000 (09:44 -0700)]
docs: Make it clear that ovs-openflowd is an alternative to ovs-vswitchd.

Suggested-by: Vishal Swarankar <vishal.swarnkar@gmail.com>
13 years agoofproto: Fix implementation of OFPP_FLOOD.
Ben Pfaff [Thu, 14 Oct 2010 00:11:56 +0000 (17:11 -0700)]
ofproto: Fix implementation of OFPP_FLOOD.

Commit f1588b1fa1 "datapath: Remove implementation of port groups" removed
a "break" statement accidentally, which caused OFPP_FLOOD to send duplicate
packets and to ignore OFPPC_NO_FLOOD.

13 years agodebian: Make the init script's start command idempotent
Simon Horman [Wed, 13 Oct 2010 22:18:20 +0000 (07:18 +0900)]
debian: Make the init script's start command idempotent

Signed-off-by: Simon Horman <horms@verge.net.au>
Signed-off-by: Ben Pfaff <blp@nicira.com>
13 years agonetdev-vport: Actually destroy the vport when "destroy" is called
Justin Pettit [Wed, 13 Oct 2010 07:14:31 +0000 (00:14 -0700)]
netdev-vport: Actually destroy the vport when "destroy" is called

Commit 2b9d65 (netdev-vport: Merge in netdev-patch and netdev-tunnel.)
refactored the common parts of the netdev-patch and netdev-tunnel
sources into netdev-vport.  During the refactoring, the "destroy" method
didn't inherit the netdev_vport_do_ioctl(ODP_VPORT_DEL, ...) call, which
is needed to actually destroy the device in the kernel.  This commit
fixes that.

Bug #3267

13 years agonetflow: Back-out optimization that could lead to infinite loop
Justin Pettit [Tue, 12 Oct 2010 18:24:04 +0000 (11:24 -0700)]
netflow: Back-out optimization that could lead to infinite loop

Commit 924282 (netflow: Do 64-bit division less often.) attempted to
remove the 64-bit division used to break flow records with large byte
counts into multiple NetFlow records.  The calculation to determine the
number of records was incorrect and should have shifted "byte_delta" by
31 instead of 32.  This commit reverts the change (while keeping commit
f22a24 (netflow: Avoid (theoretically) looping 2**32 times.) ), since
the logic is more straight-forward than the optimized version.

Bug #3813

13 years agoofproto: Update flow context for resubmit on VLAN actions
Justin Pettit [Tue, 12 Oct 2010 07:01:37 +0000 (00:01 -0700)]
ofproto: Update flow context for resubmit on VLAN actions

Any modifications that happen to the packet are supposed to be reflected
in the flow context for a resubmitted lookup.  Commit 26233b (datapath:
Combine dl_vlan and dl_vlan_pcp.) broke this for OFPAT_SET_VLAN_VID and
OFPAT_SET_VLAN_PCP.  This corrects that behavior.

Bug #3808 (2/2)

13 years agoodp-util: Remove extraneous "set_tci(" from format_odp_action()
Justin Pettit [Tue, 12 Oct 2010 06:50:36 +0000 (23:50 -0700)]
odp-util: Remove extraneous "set_tci(" from format_odp_action()

The function format_odp_action(), which is used to format the output of
"ovs-dpctl dump-flows", printed "set_tci(" before printing a correct
"set_tci" with actual parameters.

Bug #3808 (1/2)

13 years agolib: ofp-parse segfaults if required argument isn't specified
Ethan Jackson [Fri, 8 Oct 2010 22:15:26 +0000 (22:15 +0000)]
lib: ofp-parse segfaults if required argument isn't specified

Running ovs-ofctl add-flow br0 "in_port=3 actions=resubmit" would
segfault instead of reporting an error.

13 years agodatapath: Fix build break in compat_query_flows().
Ben Pfaff [Mon, 11 Oct 2010 21:05:37 +0000 (14:05 -0700)]
datapath: Fix build break in compat_query_flows().

Commit a01ef04ce "datapath: Drop padding from struct odp_flow_key" removed
the "reserved" member from struct odp_flow_key but overlooked uses of that
member from 64-bit compatibility code.  This commit fixes up the problem.

Signed-off-by: Ben Pfaff <blp@nicira.com>
Acked-by: Jesse Gross <jesse@nicira.com>
13 years agodatapath: Fix typo in 64-bit compat header.
Ben Pfaff [Mon, 11 Oct 2010 21:04:10 +0000 (14:04 -0700)]
datapath: Fix typo in 64-bit compat header.

Commit f1588b1f "datapath: Remove implementation of port groups" added a
spurious "V" in the odp-compat.h header.  I failed to test-build that
commit on a 64-bit system and thus this broke the build on x86-64 and other
64-bit systems.

Signed-off-by: Ben Pfaff <blp@nicira.com>
Acked-by: Jesse Gross <jesse@nicira.com>
13 years agodatapath: fix flow used time stats
Hao Zheng [Fri, 8 Oct 2010 23:26:15 +0000 (16:26 -0700)]
datapath: fix flow used time stats

This commit fixes a problem where datapath flow used stats can report
incorrent value, thus may result in flow expirations being incorrect.
This happens when a kernel jiffies rollover occurs between the last time
a flow is hit and the flow stats is queried.

Acked-by: Jesse Gross <jesse@nicira.com>
Signed-off-by: Hao Zheng <hzheng@nicira.com>
13 years agodatapath: Always use GFP_ATOMIC to execute actions.
Ben Pfaff [Fri, 10 Sep 2010 18:16:31 +0000 (11:16 -0700)]
datapath: Always use GFP_ATOMIC to execute actions.

These functions run 99% of the time in atomic context and the benefit of
passing along the 'gfp' argument for the other 1% doesn't seem to outweigh
the cost.

Suggested-by: Stephen Hemminger <shemminger@vyatta.com>
Acked-by: Jesse Gross <jesse@nicira.com>
Signed-off-by: Ben Pfaff <blp@nicira.com>
13 years agodatapath: Drop padding from struct odp_flow_key.
Ben Pfaff [Fri, 10 Sep 2010 18:18:53 +0000 (11:18 -0700)]
datapath: Drop padding from struct odp_flow_key.

Breaking this out as a separate commit should make it easier to see what
needs to change later, if we need to reintroduce padding at some point.

Signed-off-by: Ben Pfaff <blp@nicira.com>
Acked-by: Jesse Gross <jesse@nicira.com>
13 years agodatapath: Combine dl_vlan and dl_vlan_pcp.
Ben Pfaff [Fri, 8 Oct 2010 23:26:21 +0000 (16:26 -0700)]
datapath: Combine dl_vlan and dl_vlan_pcp.

This allows eliminating padding from odp_flow_key, although actually doing
that is postponed until the next commit.

Signed-off-by: Ben Pfaff <blp@nicira.com>
Acked-by: Jesse Gross <jesse@nicira.com>
13 years agoflow: Get rid of flow_t typedef.
Ben Pfaff [Fri, 3 Sep 2010 18:30:02 +0000 (11:30 -0700)]
flow: Get rid of flow_t typedef.

When userspace and the kernel were using the same structure for flows,
flow_t was a useful way to indicate that a structure was really a userspace
flow instead of a kernel one, but now it's better to just write "struct
flow" for consistency, since OVS doesn't use typedefs for structs
elsewhere.

Acked-by: Jesse Gross <jesse@nicira.com>
13 years agoflow: Separate "flow_t" from "struct odp_flow_key".
Ben Pfaff [Mon, 11 Oct 2010 20:31:35 +0000 (13:31 -0700)]
flow: Separate "flow_t" from "struct odp_flow_key".

The "struct odp_flow_key" used in the kernel datapath is conceptually
separate from the "flow_t" used in userspace, but until now we have
used the latter as a typedef for the former for convenience.  This commit
separates them.  This makes it possible in upcoming commits to change
them independently.

This is cross-ported from the "wdp" branch, which has had it for months.

13 years agodatapath: Remove implementation of port groups.
Ben Pfaff [Fri, 8 Oct 2010 23:36:13 +0000 (16:36 -0700)]
datapath: Remove implementation of port groups.

The "port group" concept seems like a good one, but it has not been
used very much in userspace so far, so before we commit ourselves to
a frozen API that we must maintain forever, remove it.  We can always
add it back in later as a new kind of vport.

Signed-off-by: Ben Pfaff <blp@nicira.com>
13 years agonetdev-vport: Merge in netdev-patch and netdev-tunnel.
Ben Pfaff [Wed, 6 Oct 2010 22:35:53 +0000 (15:35 -0700)]
netdev-vport: Merge in netdev-patch and netdev-tunnel.

The only real difference between netdev-patch and netdev-tunnel is in their
parse_config() implementation.  That's a lot of extra code to maintain, for
questionable benefit.  This commit merges them into the netdev-vport code,
which was heretofore merely a collection of helper functions.

13 years agoofproto: Get rid of port_changed_cb.
Ben Pfaff [Fri, 1 Oct 2010 22:59:56 +0000 (15:59 -0700)]
ofproto: Get rid of port_changed_cb.

Jesse pointed out that port_changed_cb isn't a great interface.  It's only
around because, earlier, we had a lousy interface for monitoring netdev
status, so that we needed to pass along information obtained by ofproto
into the bridge.  But netdev_monitor is now sufficiently sophisticated that
the bridge can set up an independent netdev_monitor without any important
loss of efficiency.  Since this makes the code cleaner, this commit does
so.

13 years agovswitchd: Better tolerate changes in datapath ports.
Ben Pfaff [Tue, 28 Sep 2010 18:57:40 +0000 (11:57 -0700)]
vswitchd: Better tolerate changes in datapath ports.

Until now, a command that removed and added ports in a single change to
the database, e.g.:
ovs-vsctl del-port br0 vif1.0 -- add-port br0 vif2.0
typically failed, because of this sequence of events:

1. Bridge code removes vif1.0 from br0.
2. Bridge code adds vif2.0 to br0.
3. ofproto_run() receives kernel notification that vif1.0 was deleted, so
   it notifies the bridge by calling back to bridge_port_changed_ofhook_cb,
   which sees that it has an interface with the specified port number, and
   deletes it.  Oops--this is where the problem occurs.  For completeness:
4. ofproto_run() receives kernel notification that vif2.0 was added, so
   it notifies the bridge by calling back to ,
   which sees that it has no interface with the specified port number, and
   does nothing.

This commit fixes the problem by making bridge_port_changed_ofhook_cb() not
care about ports being dropped.  This is a corner case that we shouldn't
work too hard to care about, since it can only happen if an administrator
is meddling with datapaths using ovs-dpctl, and the consequences are simply
that packets directed to that device will take longer to be rerouted to
another device (it will take a while for the MAC learning table to time out
the entry).  Basically, the admin gets what he deserves.

Thanks to Jesse Gross for identifying the problem.

Bug #3671.

13 years agovswitchd: Only try to open netdev once.
Ben Pfaff [Tue, 28 Sep 2010 18:25:47 +0000 (11:25 -0700)]
vswitchd: Only try to open netdev once.

The previous commit arranged to always open the netdev for bridge ports
within the loop that adds new ports to datapaths.  So now the additional
attempt to open them within the following loop is superfluous and
presumably will always fail.  This commit drops it and merges two
iterations through bridge ports into a single one, since the first is now
trivial.

13 years agovswitchd: Support changing the type of a bridge port.
Ben Pfaff [Mon, 11 Oct 2010 17:28:28 +0000 (10:28 -0700)]
vswitchd: Support changing the type of a bridge port.

Until now, if the type of a bridge port changed in the database, then
ovs-vswitchd would report an error and keep it the same type.  This commit
changes the behavior to something more reasonable: the old datapath port is
deleted and replaced by a new datapath port of the correct type.

13 years agovswitchd: Make type of interface easier to determine.
Ben Pfaff [Mon, 11 Oct 2010 17:13:33 +0000 (10:13 -0700)]
vswitchd: Make type of interface easier to determine.

Suggested-by: Jesse Gross <jesse@nicira.com>
13 years agovswitchd: Create all interfaces at the same time.
Ben Pfaff [Mon, 27 Sep 2010 18:39:41 +0000 (11:39 -0700)]
vswitchd: Create all interfaces at the same time.

It seems inconsistent to create some early, some late.  I hope that
this helps to clarify what is happening.

13 years agovswitchd: Break set_up_iface() into two different functions.
Ben Pfaff [Mon, 27 Sep 2010 20:15:19 +0000 (13:15 -0700)]
vswitchd: Break set_up_iface() into two different functions.

set_up_iface() had two only loosely related purposes.  It's cleaner to use
two separate functions.

13 years agovswitchd: Drop redundant 'iface_cfg' parameter to set_up_iface().
Ben Pfaff [Mon, 27 Sep 2010 18:09:19 +0000 (11:09 -0700)]
vswitchd: Drop redundant 'iface_cfg' parameter to set_up_iface().

iface_cfg is also available as iface->cfg, so there's no benefit in also
passing it as a separate parameter.

Also, get rid of the one-liner reconfigure_iface() function that wasn't
helping with anything.

13 years agotunneling: Internal dev vport can be NULL.
Jesse Gross [Wed, 6 Oct 2010 02:14:21 +0000 (19:14 -0700)]
tunneling: Internal dev vport can be NULL.

Commit 4bee42 "tunnel: Correctly check for internal device." fixed
the call to internal_dev_get_vport() by first checking that the
device is in fact an internal device.  However, it also accidentally
removed the check ensuring that the vport itself was not NULL.  This
adds that check back by redoing the previous change in a more robust
manner.

Signed-off-by: Jesse Gross <jesse@nicira.com>
Acked-by: Ben Pfaff <blp@nicira.com>
13 years agonetdev: Enforce a floor "linux-htb" min-rate
Justin Pettit [Fri, 8 Oct 2010 21:18:28 +0000 (14:18 -0700)]
netdev: Enforce a floor "linux-htb" min-rate

13 years agonetdev: Don't divide by zero when "linux-htb" zero min-rate is used
Justin Pettit [Fri, 8 Oct 2010 20:50:16 +0000 (13:50 -0700)]
netdev: Don't divide by zero when "linux-htb" zero min-rate is used

A "min-rate" of zero for the "linux-htb" QoS type would cause a divide
by zero exception.  This patch prevents that by just returning zero.  A
later patch will try to enforce reasonable values for "min-rate".

Bug #3745

13 years agoclassifier: Add missing argument in CLASSIFIER_FOR_EACH_EXACT_RULE_SAFE
Justin Pettit [Fri, 8 Oct 2010 06:30:06 +0000 (23:30 -0700)]
classifier: Add missing argument in CLASSIFIER_FOR_EACH_EXACT_RULE_SAFE

The CLASSIFIER_FOR_EACH_EXACT_RULE_SAFE macro was missing its "MEMBER"
argument.  It doesn't currently cause any problems because no one uses
the macro.

13 years agoovs-openflowd: Don't segfault when no controllers specified
Justin Pettit [Fri, 8 Oct 2010 06:51:02 +0000 (23:51 -0700)]
ovs-openflowd: Don't segfault when no controllers specified

If no controllers are specified on the command-line, ovs-openflowd adds
a couple of its own.  The code that accounts for the controllers
correctly allocated space for them, but used the command-line count to
determine how many to set.  This led to a segfault when later code tried
to dereference them.

Reported-by: Derek Cormier <derek.cormier@lab.ntt.co.jp>
13 years agoofproto: Drop flows from datapath more quickly under heavy load.
Ben Pfaff [Thu, 7 Oct 2010 23:44:32 +0000 (16:44 -0700)]
ofproto: Drop flows from datapath more quickly under heavy load.

In normal operation it makes sense to keep track of all of the flows that
have been seen recently and to cache all of them in the kernel.  Under
unusual conditions, such as those caused by network scanning tools or by an
actual targeted DoS attack against the vswitch, the number of flows can
explode to extremely high numbers (hundreds of thousands or more).  In such
a situation the vswitch needs to guard against memory exhaustion by
expiring flows more quickly and more often.  This commit implements an
inexpensive technique for determining which flows should be dropped in such
a situation.

13 years agoclassifier: Introduce macros for iterating exact-match flows.
Ben Pfaff [Thu, 7 Oct 2010 17:36:02 +0000 (10:36 -0700)]
classifier: Introduce macros for iterating exact-match flows.

This special case of iterating through flows is easier and presumably
faster to implement using a macro.

13 years agoofproto: Iterate through exact-match rules first during expiration.
Ben Pfaff [Wed, 29 Sep 2010 20:04:03 +0000 (13:04 -0700)]
ofproto: Iterate through exact-match rules first during expiration.

A wildcarded flow is idle only if all of its subrules have expired because
they were idle, so unless we expire exact-match rules first it is possible
that a wildcarded flow fails to expire as soon as it should.

(The current implementation of classifier_for_each() iterates through
exact-match rules before wildcarded rules, but nothing in the interface
guarantees that.)

13 years agoofproto: Drop unneeded poll_immediate_wake().
Ben Pfaff [Wed, 29 Sep 2010 19:54:05 +0000 (12:54 -0700)]
ofproto: Drop unneeded poll_immediate_wake().

This poll_immediate_wake() is unnecessary because netflow_run() is always
called afterward within the same poll loop.  It's better to delete it, to
avoid wasting CPU.

13 years agoofproto: Fix effective memory leak for uninstallable flows.
Ben Pfaff [Thu, 30 Sep 2010 17:13:47 +0000 (10:13 -0700)]
ofproto: Fix effective memory leak for uninstallable flows.

In one or two corner cases, flows cannot be installed because every packet
in the flow must be processed by userspace.  The code to expire rules was
ignoring these uninstallable rules, and thus they would never get freed,
even after they became idle.  This commit fixes the problem.

13 years agoofproto: Factor conditional out of loop in send_flow_removed().
Ben Pfaff [Thu, 7 Oct 2010 17:08:21 +0000 (10:08 -0700)]
ofproto: Factor conditional out of loop in send_flow_removed().

13 years agoofproto: Group functions related to flow expiration together.
Ben Pfaff [Wed, 6 Oct 2010 21:39:56 +0000 (14:39 -0700)]
ofproto: Group functions related to flow expiration together.

This should be a purely stylistic change, with no effect on behavior.

This commit changes the callback pointer passed to the
classifier_for_each() from a pointer to an ofproto to a pointer to a
structure that includes an ofproto.  Future commits planned will add
more members to this new structure.

13 years agoofproto: Avoid wasting memory malloc()'ing empty action sets for subrules.
Ben Pfaff [Wed, 6 Oct 2010 21:21:47 +0000 (14:21 -0700)]
ofproto: Avoid wasting memory malloc()'ing empty action sets for subrules.

GNU libc treats malloc(0) as malloc(1).  Subrules always have an n_actions
of 0, so this code was wasting time and memory for subrules.  This commit
stops doing that.

Also audits and fixes some very pedantic potential problems with null
pointers; e.g. the C standard says that NULL may not be compared with the
< operator, even if both arguments are null, and it also says that a null
pointer may not be passed to memcpy() or memcmp(), even if the length is
zero.

13 years agonetdev: Pass class structure, instead of type, to "create" function.
Ben Pfaff [Fri, 24 Sep 2010 17:54:42 +0000 (10:54 -0700)]
netdev: Pass class structure, instead of type, to "create" function.

This opens up the possibility of storing private data at a relative offset
to the class structure, instead of having to keep a separate table.

13 years agonetdev-vport: Fix typo in comment.
Ben Pfaff [Fri, 24 Sep 2010 17:55:57 +0000 (10:55 -0700)]
netdev-vport: Fix typo in comment.

Must have been a stray s/gre/patch/ in this file's history.

13 years agodatapath: Force our include directory to be first.
Jesse Gross [Wed, 6 Oct 2010 01:09:00 +0000 (18:09 -0700)]
datapath: Force our include directory to be first.

XenServer puts our header files in the standard system search path
by default.  This is normally OK, except when we introduce new things
which aren't in those headers.  Since the system picks up the older files
first this leads to undefined sysmbols.

Signed-off-by: Jesse Gross <jesse@nicira.com>
13 years agoxenserver: ovs-external-ids log to file instead of syslog
Ethan Jackson [Fri, 1 Oct 2010 02:29:27 +0000 (02:29 +0000)]
xenserver: ovs-external-ids log to file instead of syslog

ovs-external-ids was crashing on startup because it was brought up
before /dev/log exists.  The simplest solution to this problem is
to have it log to /var/log/openvswitch/ovs-external-ids.log .  This
is consistent with vswitchd and ovsdb-server.

Signed-off-by: Ethan Jackson <ethan@nicira.com>
13 years agotunnel: Correctly check for internal device.
Jesse Gross [Sat, 2 Oct 2010 02:21:08 +0000 (19:21 -0700)]
tunnel: Correctly check for internal device.

With header caching we check to see if the next device in the stack
is an OVS device and, if so, cache that flow as well.  However, the
test for this called internal_dev_get_vport() assuming that it would
return NULL if the device is not an internal device.  It doesn't,
however, it just returns the offset from the device where the vport
data structure would be if it were an internal device.  This changes
it to explicitly check for an internal device first to avoid a panic.

Bug #3470

Reported-by: Ram Jothikumar <rjothikumar@nicira.com>
Signed-off-by: Jesse Gross <jesse@nicira.com>
Reviewed-by: Justin Pettit <jpettit@nicira.com>
13 years agoAdd Nicira extension for modifying queue without transmitting
Justin Pettit [Sat, 2 Oct 2010 07:27:23 +0000 (00:27 -0700)]
Add Nicira extension for modifying queue without transmitting

The OpenFlow OFPAT_ENQUEUE action sets a queue id and outputs the packet
in one shot.  There are times in which the queue should be set, but the
output port is not yet known.  This commit adds the NXAST_SET_QUEUE and
NXAST_POP_QUEUE Nicira extension actions to modify the queue
configuration without requiring a port argument.

CC: Jeremy Stribling <strib@nicira.com>
CC: Keith Amidon <keith@nicira.com>
13 years agonetflow: Avoid (theoretically) looping 2**32 times.
Ben Pfaff [Wed, 1 Sep 2010 19:45:24 +0000 (12:45 -0700)]
netflow: Avoid (theoretically) looping 2**32 times.

If the netflow byte counter is UINT64_MAX, or at any rate much larger than
UINT32_MAX, netflow_expire() could loop for a very long time.  This commit
avoids that case.

This is only a theoretical bug fix.  I don't know of any actual bug that
would cause a counter to be that high.

13 years agonetflow: Do 64-bit division less often.
Ben Pfaff [Wed, 1 Sep 2010 19:43:11 +0000 (12:43 -0700)]
netflow: Do 64-bit division less often.

64-bit division is expensive.  Usually we can avoid it entirely, as done by
this patch.

13 years agoINSTALL.Linux: Describe how to upgrade the Open vSwitch database.
Ben Pfaff [Thu, 26 Aug 2010 21:53:04 +0000 (14:53 -0700)]
INSTALL.Linux: Describe how to upgrade the Open vSwitch database.

Suggested-by: Parham Kiani <pkiani@essex.ac.uk>
13 years agoovs-controller: Improve QoS abilities.
Ben Pfaff [Fri, 1 Oct 2010 20:41:40 +0000 (13:41 -0700)]
ovs-controller: Improve QoS abilities.

This makes it a little easier to test Open vSwitch QoS features using
ovs-controller, by making it possible to assign queues on the basis of
input port, instead of just allowing a single queue for a whole switch.

CC: Michael Mao <mmao@nicira.com>
13 years agolearning-switch: Introduce struct for configuration.
Ben Pfaff [Thu, 23 Sep 2010 21:12:09 +0000 (14:12 -0700)]
learning-switch: Introduce struct for configuration.

This should make extensions easier.

13 years agoovs-controller: Make --with-flows read the file only once, at startup.
Ben Pfaff [Thu, 23 Sep 2010 21:08:13 +0000 (14:08 -0700)]
ovs-controller: Make --with-flows read the file only once, at startup.

A couple of people have reported that ovs-controller --with-flows is
confusing.  This seems to be because it doesn't read the file with the
flows until the first connection from a switch.  Then, if the file has a
syntax error, it exits.

This commit changes the behavior so that it reads the file immediately at
startup instead.

13 years agoofp-parse: Add test.
Ben Pfaff [Fri, 1 Oct 2010 20:08:14 +0000 (13:08 -0700)]
ofp-parse: Add test.

13 years agoofp-print: Make output easier to read.
Ben Pfaff [Fri, 1 Oct 2010 20:05:59 +0000 (13:05 -0700)]
ofp-print: Make output easier to read.

13 years agoofp-parse: Factor out duplicated code into new functions.
Ben Pfaff [Thu, 23 Sep 2010 20:19:49 +0000 (13:19 -0700)]
ofp-parse: Factor out duplicated code into new functions.

13 years agoofp-parse: Properly byteswap in_port.
Ben Pfaff [Fri, 1 Oct 2010 20:05:23 +0000 (13:05 -0700)]
ofp-parse: Properly byteswap in_port.

13 years agoofproto: Only dump queue statistics if the queue really exists.
Ben Pfaff [Thu, 16 Sep 2010 22:41:14 +0000 (15:41 -0700)]
ofproto: Only dump queue statistics if the queue really exists.

Without this commit, "ovs-ofctl queue-stats br0 ALL 1" will print something
like the following if port 3 has queue 1 but none of the other ports do:

    stats_reply (xid=0x7b378): flags=none type=5(queue)
     4 queues
      port 0 queue 1: bytes=?, pkts=?, errors=?
      port 1 queue 1: bytes=?, pkts=?, errors=?
      port 2 queue 1: bytes=?, pkts=?, errors=?
      port 3 queue 1: bytes=0, pkts=0, errors=0

With this commit, it will print the following instead, which seems more
useful:

   stats_reply (xid=0x3ada1): flags=none type=5(queue)
    1 queues
     port 3 queue 1: bytes=0, pkts=0, errors=0

13 years agonetdev-linux: Fix off-by-one error dumping queue stats.
Ben Pfaff [Thu, 16 Sep 2010 22:38:10 +0000 (15:38 -0700)]
netdev-linux: Fix off-by-one error dumping queue stats.

Linux kernel queue numbers are one greater than OpenFlow queue numbers, for
HTB anyhow.  The code to dump queues wasn't compensating for this, so this
commit fixes it up.

13 years agoovs-ofctl: Add "queue-stats" command to print queue stats.
Ben Pfaff [Thu, 16 Sep 2010 22:36:57 +0000 (15:36 -0700)]
ovs-ofctl: Add "queue-stats" command to print queue stats.

13 years agoSwitch many macros from using CONTAINER_OF to using OBJECT_CONTAINING.
Ben Pfaff [Fri, 17 Sep 2010 17:33:10 +0000 (10:33 -0700)]
Switch many macros from using CONTAINER_OF to using OBJECT_CONTAINING.

These macros require one fewer argument by switching, which makes code
that uses them shorter and more readable.

13 years agoutil: New macro OBJECT_CONTAINING.
Ben Pfaff [Mon, 19 Jul 2010 20:46:52 +0000 (13:46 -0700)]
util: New macro OBJECT_CONTAINING.

This macro is a variant on CONTAINER_OF that takes an object pointer
instead of a type name as its second argument.  In the following commit
this will simplify many users of CONTAINER_OF.

13 years agoofproto: Use hash table instead of sparse array for ofports.
Ben Pfaff [Mon, 19 Jul 2010 19:57:22 +0000 (12:57 -0700)]
ofproto: Use hash table instead of sparse array for ofports.

The main advantage of a sparse array over a hash table is that it can be
iterated in numerical order.  But the OVS implementation of sparse arrays
is quite expensive in terms of memory: on a 32-bit system, a sparse array
with exactly 1 nonnull element has 512 bytes of overhead.  In this case,
the sparse array's property of iteration in numerical order is not
important, so this commit converts it to a hash table to save memory.

13 years agosflow: Use hash table instead of sparse array for sflow ports.
Ben Pfaff [Mon, 19 Jul 2010 18:43:05 +0000 (11:43 -0700)]
sflow: Use hash table instead of sparse array for sflow ports.

The main advantage of a sparse array over a hash table is that it can be
iterated in numerical order.  But the OVS implementation of sparse arrays
is quite expensive in terms of memory: on a 32-bit system, a sparse array
with exactly 1 nonnull element has 512 bytes of overhead.  In this case,
the sparse array's property of iteration in numerical order is not
important, so this commit converts it to a hash table to save memory.

13 years agobridge: Use hash table instead of sparse array for bridge ports.
Ben Pfaff [Mon, 19 Jul 2010 18:23:05 +0000 (11:23 -0700)]
bridge: Use hash table instead of sparse array for bridge ports.

The main advantage of a sparse array over a hash table is that it can be
iterated in numerical order.  But the OVS implementation of sparse arrays
is quite expensive in terms of memory: on a 32-bit system, a sparse array
with exactly 1 nonnull element has 512 bytes of overhead.  In this case,
the sparse array's property of iteration in numerical order is not
important, so this commit converts it to a hash table to save memory.

13 years agohmap: New function hmap_clear().
Ben Pfaff [Mon, 19 Jul 2010 18:22:10 +0000 (11:22 -0700)]
hmap: New function hmap_clear().

13 years agonetdev-linux: Use hash table instead of sparse array for QoS classes.
Ben Pfaff [Mon, 19 Jul 2010 18:21:59 +0000 (11:21 -0700)]
netdev-linux: Use hash table instead of sparse array for QoS classes.

The main advantage of a sparse array over a hash table is that it can be
iterated in numerical order.  But the OVS implementation of sparse arrays
is quite expensive in terms of memory: on a 32-bit system, a sparse array
with exactly 1 nonnull element has 512 bytes of overhead.  In this case,
the sparse array's property of iteration in numerical order is not
important, so this commit converts it to a hash table to save memory.

13 years agoovs-vsctl: Reduce log level for "Called as..." for read-only invocations.
Ben Pfaff [Wed, 1 Sep 2010 20:42:33 +0000 (13:42 -0700)]
ovs-vsctl: Reduce log level for "Called as..." for read-only invocations.

When ovs-vsctl is not actually going to modify the database, it is less
interesting in the log, so we might as well only log it at "debug" level.

Suggested-by: Neil McKee <neil.mckee@inmon.com>
13 years agoovs-vsctl: Factor out and optimize searching for a command by name.
Ben Pfaff [Wed, 1 Sep 2010 20:41:09 +0000 (13:41 -0700)]
ovs-vsctl: Factor out and optimize searching for a command by name.

The following commit will introduce a new function that wants to do this
a lot, so we might as well do it efficiently.

13 years agodebian: openvswitch-common ethtool should not be required
Ethan Jackson [Tue, 28 Sep 2010 18:58:00 +0000 (11:58 -0700)]
debian: openvswitch-common ethtool should not be required

The ethtool package is only used to help ovs-bugtool create bug
reports and does not prevent the script from running if it's
missing. Making it a requirement for installation is a bit
draconian.

13 years agodebian: Restart ovs-monitor-ipsec when --monitor specified
Justin Pettit [Tue, 28 Sep 2010 01:48:25 +0000 (18:48 -0700)]
debian: Restart ovs-monitor-ipsec when --monitor specified

The OVS Python daemon library will restart a process when started with
"--monitor" that exits with RESTART_EXIT_CODE.  Have ovs-monitor-ipsec
exit with this code when an uncaught exception occurs.

13 years agodebian: Create ovs-monitor-ipsec rundir if it doesn't exist
Justin Pettit [Tue, 28 Sep 2010 01:33:56 +0000 (18:33 -0700)]
debian: Create ovs-monitor-ipsec rundir if it doesn't exist

Reported-by: Sajjad Lateef <slateef@nicira.com>
13 years agodebian: Added a manpage for ovs-bugtool
Ethan Jackson [Thu, 23 Sep 2010 06:45:58 +0000 (23:45 -0700)]
debian: Added a manpage for ovs-bugtool

Added a manpage for the ovs-bugtool script.

13 years agotests: Test that children restart with special exit code
Ethan Jackson [Thu, 23 Sep 2010 04:59:02 +0000 (21:59 -0700)]
tests: Test that children restart with special exit code

Added a test which checks that the python daemon code properly
restarts child processes which exit with RESTART_EXIT_CODE.

13 years agotests: Remove trailing whitespace from python daemon tests
Ethan Jackson [Thu, 23 Sep 2010 05:48:42 +0000 (22:48 -0700)]
tests: Remove trailing whitespace from python daemon tests

Removes the trailing whitespace from the testing code related to
daemonizing in Python.

13 years agoxenserver: monitor-external-ids should run with --monitor
Ethan Jackson [Wed, 22 Sep 2010 19:40:39 +0000 (12:40 -0700)]
xenserver: monitor-external-ids should run with --monitor

The init script starts monitor-external-ids with --monitor when
configured to do so.  Also made changes to guarantee that --monitor
actually restarts ovs-external-ids.

Signed-off-by: Ethan Jackson <ethan@nicira.com>
13 years agoxenserver: Added additional logging to ovs-external-ids
Ethan Jackson [Wed, 22 Sep 2010 22:38:17 +0000 (15:38 -0700)]
xenserver: Added additional logging to ovs-external-ids

Added additional logging for debug-ability and migrated to python
logging module.

Signed-off-by: Ethan Jackson <ethan@nicira.com>
13 years agovswitch: Consistently use spaces instead of tabs in vswitch.xml
Justin Pettit [Thu, 23 Sep 2010 23:32:13 +0000 (16:32 -0700)]
vswitch: Consistently use spaces instead of tabs in vswitch.xml

13 years agonetdev: Cleanup minor comment formatting issues.
Justin Pettit [Thu, 23 Sep 2010 22:11:39 +0000 (15:11 -0700)]
netdev: Cleanup minor comment formatting issues.

13 years agovswitch: Disable header-caching when IPsec is enabled
Justin Pettit [Thu, 23 Sep 2010 23:25:25 +0000 (16:25 -0700)]
vswitch: Disable header-caching when IPsec is enabled

Header caching speeds up sending tunneled traffic by bypassing the Linux
IP stack.  This also causes it to bypass IPsec processing, which will
break connectivity.  This commit disables header caching when IPsec is
enabled.

13 years agodebian: Use DODTIME instead of DIETIME in init scripts
Justin Pettit [Thu, 23 Sep 2010 20:37:58 +0000 (13:37 -0700)]
debian: Use DODTIME instead of DIETIME in init scripts

Brad pointed out that openvswitch-ipsec init script defined the variable
DIETIME but attempted to use it as DODTIME.  This commit uses DODTIME,
since it's the name used by the openvswitch-switch init script.  The
openvswitch-controller init script had the same issue.

As suggested by Ben, the "s" suffixes are removed from sleep commands,
since they are a GNU extension.

Reported-by: Brad Hall <brad@nicira.com>
13 years agoxenserver: Rename monitor-external-ids -> ovs-external-ids
Ethan Jackson [Wed, 22 Sep 2010 01:03:07 +0000 (18:03 -0700)]
xenserver: Rename monitor-external-ids -> ovs-external-ids

Renamed the monitor-external-ids script ovs-external-ids.
Hopefully this will make it clearer who owns it when someone does
ps xa.

Also removed trailing whitespace from ovs-external-ids.

Signed-off-by: Ethan Jackson <ethan@nicira.com>
13 years agodebian: Support two locations for ethtool
Ethan Jackson [Thu, 23 Sep 2010 00:29:12 +0000 (17:29 -0700)]
debian: Support two locations for ethtool

The ethtool binary recently moved from /usr/sbin to /sbin.  This
change falls back to /usr/sbin/ethtool if /sbin/ethtool does not
exist.

13 years agoAdd missing file to distribution.
Ben Pfaff [Thu, 23 Sep 2010 18:56:36 +0000 (11:56 -0700)]
Add missing file to distribution.

13 years agovswitchd: Rename IFACE_STATS_INTERVAL, iface_stats_timer.
Ben Pfaff [Thu, 23 Sep 2010 17:21:40 +0000 (10:21 -0700)]
vswitchd: Rename IFACE_STATS_INTERVAL, iface_stats_timer.

These are more than interface stats now so the names should be more
generic.

Suggested-by: Justin Pettit <jpettit@nicira.com>
13 years agoovs-vswitchd: Export system stats through Open_vSwitch table.
Ben Pfaff [Wed, 22 Sep 2010 23:45:30 +0000 (16:45 -0700)]
ovs-vswitchd: Export system stats through Open_vSwitch table.

This is intended to provide controllers enough information to determine
whether a switch is overloaded or busted, to enable them to spread load
fairly across a group of switches.

Feature #2421.

CC: Peter Balland <peter@nicira.com>
13 years agoovsdb-doc: Implement new <option>, <ol> tags.
Ben Pfaff [Wed, 22 Sep 2010 23:34:05 +0000 (16:34 -0700)]
ovsdb-doc: Implement new <option>, <ol> tags.

13 years agoovsdb-data: New function ovsdb_datum_from_shash().
Ben Pfaff [Thu, 23 Sep 2010 16:43:46 +0000 (09:43 -0700)]
ovsdb-data: New function ovsdb_datum_from_shash().

13 years agoshash: New function shash_steal().
Ben Pfaff [Thu, 23 Sep 2010 16:42:30 +0000 (09:42 -0700)]
shash: New function shash_steal().

13 years agodaemon: Fix behavior of read_pidfile() for our own pidfile.
Ben Pfaff [Thu, 23 Sep 2010 16:39:47 +0000 (09:39 -0700)]
daemon: Fix behavior of read_pidfile() for our own pidfile.

Opening a file descriptor and then closing it always discards any locks
held on the underlying file, even if the file is still open as another file
descriptor.  This meant that calling read_pidfile() on the process's own
pidfile would discard the lock and make other OVS processes think that the
process had died.  This commit fixes the problem.

13 years agodaemon: Report number of crashes on monitor process command line.
Ben Pfaff [Tue, 21 Sep 2010 21:27:02 +0000 (14:27 -0700)]
daemon: Report number of crashes on monitor process command line.

13 years agovlog: Add VLOG_WARN_ONCE() and similar macros.
Ben Pfaff [Mon, 13 Sep 2010 20:29:57 +0000 (13:29 -0700)]
vlog: Add VLOG_WARN_ONCE() and similar macros.

13 years agodebian: additional copyright update for xenserver/
Ben Pfaff [Thu, 23 Sep 2010 18:20:10 +0000 (11:20 -0700)]
debian: additional copyright update for xenserver/

Signed-off-by: Simon Horman <horms@verge.net.au>
Signed-off-by: Ben Pfaff <blp@nicira.com>
13 years agodebian: update copyright for xenserver/
Simon Horman [Thu, 23 Sep 2010 01:55:15 +0000 (10:55 +0900)]
debian: update copyright for xenserver/

Further to the recent work done by Ben Pfaff and Ian Campbell to
clarify the license of all the files in xenserver/ the debian/copyright.in
file seems to need updating.

Signed-off-by: Simon Horman <horms@verge.net.au>
Signed-off-by: Ben Pfaff <blp@nicira.com>
13 years agoxenserver: Only put the primary XenServer UUID in default bridge-id
Ethan Jackson [Wed, 22 Sep 2010 06:57:13 +0000 (23:57 -0700)]
xenserver: Only put the primary XenServer UUID in default bridge-id

This patch defensively guarantees that the first id in
xs-network-uuids will belong to the primary network (as opposed to
a vlan).  Given that the primary network id comes first, it parses
xs-network-ids and only copies the primary id to bridge-id when
monitor-external-ids is run.

Feature #3647

Signed-off-by: Ethan Jackson <ethan@nicira.com>
Reviewed-by: Ben Pfaff <blp@nicira.com>
13 years agovswitch: Reference ipsec_local_ip and ipsec_psk with underscores
Justin Pettit [Thu, 23 Sep 2010 05:52:04 +0000 (22:52 -0700)]
vswitch: Reference ipsec_local_ip and ipsec_psk with underscores

The GRE-over-IPsec the documentation describes "ipsec-local-ip" and
"ipsec-psk" when they actually use underscores.

13 years agodebian: Add support for GRE-over-IPsec
Justin Pettit [Fri, 17 Sep 2010 02:19:11 +0000 (19:19 -0700)]
debian: Add support for GRE-over-IPsec

The ovs-monitor-ipsec daemon monitors the Interface table for GRE
entries.  If an entry specifies other-config parameters "ipsec-local-ip"
and ("ipsec-psk" or "ipsec-cert"), it will create the appropriate
security associations so that all GRE traffic to the remote host will be
encrypted.  In order for the two GRE tunnels to communicate, both sides
need to be configured for IPsec with appropriate authentication.

Currently, ovs-monitor-ipsec does not support certificate authentication
or ensure that an interface is actually attached to a bridge.  Both of
these issues will be addressed in a forthcoming patch.

NB: While GRE-over-IPsec should work on any system with a relatively
recent racoon and setkey, it has only been tested on Debian.  As such,
only Debian packaging has been provided.

13 years agodebian: Allow automake versions greater than or equal to 1.10
Justin Pettit [Thu, 16 Sep 2010 22:37:16 +0000 (15:37 -0700)]
debian: Allow automake versions greater than or equal to 1.10

13 years agotunneling: Allow disabling tunnel header caching.
Jesse Gross [Mon, 30 Aug 2010 22:34:04 +0000 (15:34 -0700)]
tunneling: Allow disabling tunnel header caching.

Tunnel header caching significantly improves performance by bypassing
much of the transmit path.  However, in some special cases or for
debugging it may be desirable to traverse the entire IP stack.  This
exposes that as an option (default is to enable header caching).

Signed-off-by: Jesse Gross <jesse@nicira.com>
Reviewed-by: Ben Pfaff <blp@nicira.com>
13 years agodatapath: Add tunnel header caching.
Jesse Gross [Fri, 27 Aug 2010 20:55:02 +0000 (13:55 -0700)]
datapath: Add tunnel header caching.

On the transmit path we generate essentially the same tunnel header
for every packet to a given destination.  However, each packet must
have the headers assembled in pieces, lookup the destination in the
routing table, and lookup the flow in OVS.  This avoids that extra
work by caching all of the header and output path information and
only rebuilding it when something actually changes.

This optimization reduces CPU load on transmit by approximately 13%.

Signed-off-by: Jesse Gross <jesse@nicira.com>
Reviewed-by: Ben Pfaff <blp@nicira.com>
13 years agodatapath: Backport workqueue functions.
Jesse Gross [Tue, 31 Aug 2010 22:38:25 +0000 (15:38 -0700)]
datapath: Backport workqueue functions.

An upcoming commit will use some workqueue functions that weren't
available on earlier kernels, so this backports those functions.
The backporting uses timers instead of delayed work queues because
the earlier versions of work queues have some unsafe corner cases.
In addition, this removes some unused work queue backporting code
that is no longer used because it is potentially unsafe.

Note that this commit changes the behavior of work queues: normally
they run in process context but the backported version runs in
softirq context.

Signed-off-by: Jesse Gross <jesse@nicira.com>
Reviewed-by: Ben Pfaff <blp@nicira.com>
13 years agodatapath: Move is_frag out of struct ovs_skb_cb.
Jesse Gross [Sun, 29 Aug 2010 21:28:58 +0000 (14:28 -0700)]
datapath: Move is_frag out of struct ovs_skb_cb.

is_frag is only used for communication between two functions, which
means that it doesn't really need to be in the SKB CB.  This wouldn't
necessarily be a problem except that there are also a number of other
paths that lead to this being uninitialized.  This isn't a problem
now but uninitialized memory seems dangerous and there isn't much
upside.

Signed-off-by: Jesse Gross <jesse@nicira.com>
Reviewed-by: Ben Pfaff <blp@nicira.com>