Ben Pfaff [Thu, 28 Oct 2010 04:17:27 +0000 (21:17 -0700)]
ofproto: Use ovs_be<N> types in appropriate places.
There are many more places in OVS where using these types would be an
improvement, but the ofproto code is extra confusing because it uses
a mix of byte orders.
Ben Pfaff [Tue, 26 Oct 2010 22:24:26 +0000 (15:24 -0700)]
flow: Use ovs_be<N> types in appropriate places.
There are many more places in OVS where using these types would be an
improvement, but the flow code is particularly confusing because it uses
a mix of byte orders.
Jesse Gross [Wed, 27 Oct 2010 22:29:16 +0000 (15:29 -0700)]
netdev: Fix carrier status for down interfaces.
Currently netdev_get_carrier() returns both a carrier status and
an error code. However, usage of the error code was inconsistent:
most callers either ignored it or didn't perform their task if an
error occured, which prevented bond rebalancing. This makes the
handling consistent by translating an error into a down status in
the netdev library.
Ben Pfaff [Wed, 27 Oct 2010 16:29:08 +0000 (09:29 -0700)]
daemon: Don't call a normal exit from the monitor a "crash".
When the monitored child is killed with SIGTERM, the monitoring process
currently logs a message like "1 crashes: pid 12345 died, killed by
signal 15 (Terminated), exiting". This counts the SIGTERM as a crash, even
though it's intentional.
This commit changes the log message to omit the "%d crashes" part on normal
termination.
Justin Pettit [Tue, 26 Oct 2010 21:54:13 +0000 (14:54 -0700)]
ofproto: Add coverage counter for reinit_ports()
The reinit_ports() function is an interesting enough case that it would
be good to know if we're hitting it often. This adds a
"ofproto_reinit_ports" coverage counter.
Justin Pettit [Tue, 26 Oct 2010 00:26:44 +0000 (17:26 -0700)]
ovs-external-ids: Better handle VIFs from recently resumed VMs
XAPI doesn't provide a way to look up a VIF entry based on the name, so
we have to locate it by other methods. Previously, we were breaking up
the name into the domid and device number. Unfortunately, it can take
XAPI a few seconds to update the domid of the VM, when resuming from a
suspend. Since we have the VIF UUID, we can just look up the needed
information directly based on that.
Jesse Gross [Mon, 18 Oct 2010 22:30:20 +0000 (15:30 -0700)]
datapath: Add loop detection for RT kernels.
Our normal loop detection requires disabling preemption while
packet processing takes place. On RT kernels this isn't acceptable
and interacts badly with spinlocks, so we can't use it. This
takes advantage of some extra space that is added to struct
task_struct on RT kernels (and the knowledge that we will always
have a valid task_struct) to store the loop counter for a given
thread. Since we can't make these assumptions on non-RT kernels,
we continue to use the previous method of loop detection there.
Signed-off-by: Jesse Gross <jesse@nicira.com> Acked-by: Ben Pfaff <blp@nicira.com>
Jesse Gross [Mon, 18 Oct 2010 22:36:59 +0000 (15:36 -0700)]
datapath: #define local_bh_disable to preempt_disable on RT.
We use local_bh_disable() to mean that we don't want to get
preempted or interrupted and normally it covers both situations.
However, on RT kernels local_bh_disable() becomes a no-op because
bottom halves aren't interrupts any more. We still want the
behavior of disabling preemption so #define them to be the same
on these kernels.
Signed-off-by: Jesse Gross <jesse@nicira.com> Acked-by: Ben Pfaff <blp@nicira.com>
Ben Pfaff [Fri, 22 Oct 2010 20:42:40 +0000 (13:42 -0700)]
vswitchd: Reset ofport columns of invalid interfaces to -1.
Until now, when ovs-vswitchd dropped interfaces because of duplicate names,
it would not write -1 to the ofport column in the OVSDB record for the
interface, which made it appear that the interface was still active (if
it had been before). This commit fixes the problem.
This commit also sets ofport to -1 for interfaces that cannot be created
for other reasons.
Ben Pfaff [Fri, 22 Oct 2010 21:46:30 +0000 (14:46 -0700)]
ovs-vsctl: Check for dirty reads within transactions.
OVSDB is transactional but it does not implement any form of locking. This
means that read-modify-write operations must verify that the values that
they read are still in place before writing. This commit adds such
checking.
Ben Pfaff [Fri, 22 Oct 2010 17:19:13 +0000 (10:19 -0700)]
vswitch: Make unique "name" columns immutable, to simplify transactions.
OVSDB has transactions but not locking, so a transaction that must
maintain an invariant must check that the starting state is what it
expects. For example, to add a bridge a client must verify that the new
bridge's name does not conflict with any existing bridge's name, given
that the set of bridges might have changed. One way to do that is for
the client to verify that that the set of bridges is the same and that none
of the bridges has been renamed to the new bridge's name. By making
bridge names immutable, the latter part of the check can be omitted.
Mirror names are not required to be unique so this commit does not make
them immutable.
Ethan Jackson [Thu, 21 Oct 2010 22:28:36 +0000 (22:28 +0000)]
netdev-linux: Make queue 0 the default QOS policy
This patch defines, by convention, queue 0 as the default queue in
a particular QOS. Thus, if queue 0 is defined, all traffic going
through the relevant interface will be enqueued in it. If queue 0
is not defined then ovs will send the traffic directly through the
interface without applying any policy to it.
Ben Pfaff [Thu, 21 Oct 2010 18:28:00 +0000 (11:28 -0700)]
tests: Update expected test result to match "ovsdb-client dump" changes.
Commit 06036898849 "ovsdb-client: Make "dump" print table names in default
output format too" changed the output format of "ovsdb-client dump" without
updating the tests that depended on that output format. This commit
updates the expected test results to match.
Ben Pfaff [Thu, 21 Oct 2010 17:48:56 +0000 (10:48 -0700)]
ovsdb-client: Make "dump" print table names in default output format too.
The "dump" command printed table names in CSV and HTML output formats but
they were omitted in the default tabular form. This commit corrects the
discrepancy.
Justin Pettit [Tue, 19 Oct 2010 22:58:35 +0000 (15:58 -0700)]
ovs-vswitchd: Add ability to disable in-band on a bridge
In-band control is always enabled when a manager is configured. Some
applications wish to control all the flows within a bridge, and in-band
control can override that wish. Depending on how the network is
configured, this can lead to loops as the in-band control rules try to
learn where to send traffic.
This commit adds a "disable-in-band" key to the "other_config" column of
bridge tables. If set to "true", in-band will be disabled regardless of
manager or controller configuration.
Justin Pettit [Mon, 18 Oct 2010 05:43:14 +0000 (22:43 -0700)]
ovs-monitor-ipsec: Add ability to traverse NATs
Stable versions of ipsec-tools have a bug that prevents our using
transport mode through a NAT box. Even though the bug has been fixed
for years, it is only available in the 0.8 alpha release of ipsec-tools.
This commit modifies our configuration to allow NAT traversal with that
version of ipsec-tools.
NB: An official package for this version of ipsec-tools is not yet
available on Debian, so we're requiring a custom version number.
Sajjad Lateef [Fri, 15 Oct 2010 20:41:46 +0000 (13:41 -0700)]
Create /etc/openvswitch dir when package is installed.
Earlier, the /etc/openvswitch directory would get installed as part of
the init script's start sequence. However, as newer packages are added,
including some that create files in this directory during their init
script sequences, a race condition may occur.
This change ensures that the directory /etc/openvswitch is created even
before the init scripts execute. Thus, the race condition is avoided.
Ethan Jackson [Wed, 13 Oct 2010 22:12:12 +0000 (22:12 +0000)]
vswitchd: Bubble no-flood configuration up to bridge
When bridge.c decides to flood a packet as the result of a "normal"
flow action, it now checks whether each port is configured to
receive flood packets.
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.
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.
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.
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.
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.
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>
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>
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.
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>
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.
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.
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.
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.
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.
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.
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.
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.
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>
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".
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.
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.
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.
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.)
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.
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.
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.
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.
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.
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.
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.
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>
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.
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.
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.