sliver-openvswitch.git
13 years agoDebian: Update to standards version 3.9.1
Simon Horman [Thu, 19 Aug 2010 07:55:35 +0000 (16:55 +0900)]
Debian: Update to standards version 3.9.1

Signed-off-by: Simon Horman <horms@verge.net.au>
Signed-off-by: Ben Pfaff <blp@nicira.com>
13 years agoDebian: Add Ben Pfaff and Simon Horman the uploaders
Simon Horman [Thu, 19 Aug 2010 07:55:34 +0000 (16:55 +0900)]
Debian: Add Ben Pfaff and Simon Horman the uploaders

Signed-off-by: Simon Horman <horms@verge.net.au>
Signed-off-by: Ben Pfaff <blp@nicira.com>
13 years agoodp-util: Avoid branch in odp_actions_add().
Ben Pfaff [Wed, 4 Aug 2010 17:50:40 +0000 (10:50 -0700)]
odp-util: Avoid branch in odp_actions_add().

I have no idea why, but the test and branch in odp_actions_add() has always
bugged me.  This commit eliminates it.

13 years agouuid: Fix warnings carelessly introduced a few commits ago.
Ben Pfaff [Fri, 13 Aug 2010 16:58:29 +0000 (09:58 -0700)]
uuid: Fix warnings carelessly introduced a few commits ago.

Commit e251c8 "uuid: Break code to read /dev/urandom into a new module"
carelessly introduced a few warnings, which this commit fixes up.

13 years agoofproto: Add support for NXAST_RESUBMIT recursion.
Ben Pfaff [Fri, 13 Aug 2010 16:57:25 +0000 (09:57 -0700)]
ofproto: Add support for NXAST_RESUBMIT recursion.

CC: Teemu Koponen <koponen@nicira.com>
13 years agoRemove vestigial support for Spanning Tree Protocol.
Ben Pfaff [Thu, 12 Aug 2010 00:24:13 +0000 (17:24 -0700)]
Remove vestigial support for Spanning Tree Protocol.

Open vSwitch has never properly supported IEEE 802.1D Spanning Tree
Protocol (STP), but it has various bits and pieces that claim to support
it.  This commit deletes them, to reduce the amount of dead code in the
tree.  We can always reintroduce it later if it proves to be a good idea.

Bug #1175.

13 years agorandom: Get random seed from /dev/urandom.
Ben Pfaff [Thu, 12 Aug 2010 18:12:13 +0000 (11:12 -0700)]
random: Get random seed from /dev/urandom.

Even though this PRNG is not meant to be cryptographically secure, there is
no reason not to get a high-quality seed.

CC: Stephen Hemminger <shemminger@vyatta.com>
13 years agouuid: Break code to read /dev/urandom into a new module.
Ben Pfaff [Thu, 12 Aug 2010 22:47:25 +0000 (15:47 -0700)]
uuid: Break code to read /dev/urandom into a new module.

This code is useful for seeding other random number generators, so we might
as well make it a separate source file.

13 years agoutil: Make ovs_fatal() understand EOF also.
Ben Pfaff [Thu, 12 Aug 2010 18:05:07 +0000 (11:05 -0700)]
util: Make ovs_fatal() understand EOF also.

ovs_error() interprets EOF as "end of file" when printing an error message,
so ovs_fatal() might as well.

13 years agoWait for daemons to die in init.d script "stop" commands.
Ben Pfaff [Thu, 12 Aug 2010 17:18:19 +0000 (10:18 -0700)]
Wait for daemons to die in init.d script "stop" commands.

Sometimes it takes a moment for the OVS daemons to die.  When that happens,
the "start" half of "openvswitch restart" can fail when ovsdb-tool
runs, because ovsdb-server will still have the lock on the database if it
has not exited yet.  So this commit just makes the "stop" half wait for
the daemons to really die.

Bug #3369.

13 years agodaemon: Make sure that vlog is initialized when a process daemonizes.
Ben Pfaff [Thu, 12 Aug 2010 16:47:33 +0000 (09:47 -0700)]
daemon: Make sure that vlog is initialized when a process daemonizes.

If a process daemonizes itself, then it should be possible to control that
process's log levels with "ovs-appctl vlog/set" and related commands.  The
vlog_init() function registers those commands.  But vlog_init() doesn't
normally get called until the first log message is issued.  This can take a
while, especially for ovs-controller, where I first noticed the problem.

This commit fixes the problem by calling vlog_init() from
daemonize_start(), which always gets called as a process daemonizes.

13 years agodebian: Use dh_installmodules instead of calling "depmod" wrongly.
Ben Pfaff [Thu, 5 Aug 2010 17:59:26 +0000 (10:59 -0700)]
debian: Use dh_installmodules instead of calling "depmod" wrongly.

Until now, the postinst for kernel modules built by the Debian packaging
has simply run "depmod -a", which is wrong, since this command rebuilds
the dependencies for the *running* kernel, which is not necessarily the
kernel for which modules are being installed.

The dh_installmodules script automatically adds the correct invocation of
depmod to the postinst script, so this commit switches to using that
instead.

This commit moves the kernel modules from /lib/modules/$KVERS into the
"kernel" subdirectory of that directory because dh_installmodules does not
support modules that are directly in the $KVERS directory.

CC: Sajjad Lateef <slateef@nicira.com>
13 years agorandom: Implement a decent random number generator.
Ben Pfaff [Thu, 5 Aug 2010 17:23:36 +0000 (10:23 -0700)]
random: Implement a decent random number generator.

Until now this library has based its random number upon those returned
by libc's rand() function.  This has always bugged me--it is not a good
solution since rand() varies in quality so much.  This commit changes
the random library to use a simple but high-quality PRNG.

13 years agobridge: Don't pay attention to columns that vswitchd doesn't need.
Ben Pfaff [Wed, 11 Aug 2010 22:29:36 +0000 (15:29 -0700)]
bridge: Don't pay attention to columns that vswitchd doesn't need.

Not replicating unneeded columns has some value in avoiding CPU time and
bandwidth to the database.  In ovs-vswitchd, setting cur_cfg as write-only
also have great value in avoiding extra reconfiguration steps.  When
ovs-vsctl is used in its default mode this essentially avoids half of the
reconfigurations that ovs-vswitchd currently does.  What happens now is:

    1. ovs-vsctl updates the database and increments next_cfg.
    2. ovs-vswitchd notices the change to the database, reconfigures
       itself, then increments cur_cfg to match next_cfg.
    3. The database sends the change to cur_cfg back to ovs-vswitchd.
    4. ovs-vswitchd reconfigures itself a second time.

By not replicating cur_cfg we avoid step 3 and save a whole reconfiguration
step.

Also, now that the database contains interface statistics, this avoids
reconfiguring every time that statistics are updated.

13 years agoovsdb-idl: Make it possible to omit or pay less attention to columns.
Ben Pfaff [Wed, 11 Aug 2010 22:41:41 +0000 (15:41 -0700)]
ovsdb-idl: Make it possible to omit or pay less attention to columns.

ovs-vswitchd has no need to replicate some parts of the database.  In
particular, it doesn't need to replicate the bits that it never reads,
such as the external_ids column in the Open_vSwitch table.  This saves
some memory, CPU time, and bandwidth to the database.

Another type of column that benefits from special treatment is "write-only
columns", that is, those that ovs-vswitchd writes and keeps up-to-date but
never expects another client to write, such as the cur_cfg column in the
Open_vSwitch table.  If the IDL reports that the database has changed when
ovs-vswitchd updates such a column, then ovs-vswitchd reconfigures itself
for no reason, wasting CPU time.  This commit also adds support for such
columns.

13 years agostream-ssl: Enable SSL session caching.
Ben Pfaff [Wed, 11 Aug 2010 17:24:40 +0000 (10:24 -0700)]
stream-ssl: Enable SSL session caching.

13 years agostream-ssl: Remove unused 'connect_error' member.
Ben Pfaff [Mon, 9 Aug 2010 21:42:35 +0000 (14:42 -0700)]
stream-ssl: Remove unused 'connect_error' member.

Never read, never written.

13 years agovswitch: Fix speling error in documentation.
Ben Pfaff [Tue, 10 Aug 2010 21:35:36 +0000 (14:35 -0700)]
vswitch: Fix speling error in documentation.

13 years agodpif-netdev: Properly track whether there is a vlan header.
Ben Pfaff [Wed, 28 Jul 2010 00:00:54 +0000 (17:00 -0700)]
dpif-netdev: Properly track whether there is a vlan header.

It looks to me like the current dpif-netdev implementation doesn't handle
the case where a packet comes in without a VLAN and then is subjected to
multiple ODPAT_SET_VLAN_* operations.  dp_netdev_modify_vlan_tci() just
checks the flow key each time to see whether there's a VLAN, but it doesn't
update the flow key to note that there is now a VLAN.

One fix would be to update the flow key, but it's "const" these days.
Instead, add a check for whether the Ethernet type is ETH_TYPE_VLAN,
which should be equivalent.

13 years agodpif-netdev: Tolerate undersized packets.
Ben Pfaff [Tue, 10 Aug 2010 18:38:55 +0000 (11:38 -0700)]
dpif-netdev: Tolerate undersized packets.

Actions that modify packets need to tolerate packets that are too small.
Most of the actions already implicitly do this check, since they check for
appropriate values in the flow key that would only be there if the
corresponding data was present.  But actions to modify the Ethernet header
didn't have a guarantee that the packet was at least 14 bytes long, and
actions to modify the VLAN didn't have such a guarantee either, so this
adds appropriate checks.

Problem found by code inspection.

13 years agodatapath: Fix handling of 802.1Q and SNAP headers.
Ben Pfaff [Tue, 10 Aug 2010 18:35:46 +0000 (11:35 -0700)]
datapath: Fix handling of 802.1Q and SNAP headers.

The kernel and user datapaths have code that assumes that 802.1Q headers
are used only inside Ethernet II frames, not inside SNAP-encapsulated
frames.  But the kernel and user flow_extract() implementations would
interpret 802.1Q headers inside SNAP headers as being valid VLANs.  This
would cause packet corruption if any VLAN-related actions were to be taken,
so change the two flow_extract() implementations only to accept 802.1Q as
an Ethernet II frame type, not as a SNAP-encoded frame type.

802.1Q-2005 says that this is correct anyhow:

    Where the ISS instance used to transmit and receive tagged frames is
    provided by a media access control method that can support Ethernet
    Type encoding directly (e.g., is an IEEE 802.3 or IEEE 802.11 MAC) or
    is media access method independent (e.g., 6.6), the TPID is Ethernet
    Type encoded, i.e., is two octets in length and comprises solely the
    assigned Ethernet Type value.

    Where the ISS instance is provided by a media access method that
    cannot directly support Ethernet Type encoding (e.g., is an IEEE
    802.5 or FDDI MAC), the TPID is encoded according to the rule for
    a Subnetwork Access Protocol (Clause 10 of IEEE Std 802) that
    encapsulates Ethernet frames over LLC, and comprises the SNAP
    header (AA-AA-03) followed by the SNAP PID (00-00-00) followed by
    the two octets of the assigned Ethernet Type value.

All of the media that OVS handles supports Ethernet Type fields, so to me
that means that we don't have to handle 802.1Q-inside-SNAP.

On the other hand, we *do* have to handle SNAP-inside-802.1Q, because this
is actually allowed by the standards.  So this commit also adds that
support.

I verified that, with this change, both SNAP and Ethernet packets are
properly recognized both with and without 802.1Q encapsulation.

I was a bit surprised to find out that Linux does not accept
SNAP-encapsulated IP frames on Ethernet.

Here's a summary of how frames are handled before and after this commit:

Common cases
------------

       Ethernet
    +------------+
1.  |dst|src|TYPE|
    +------------+

       Ethernet       LLC         SNAP
    +------------+ +--------+ +-----------+
2.  |dst|src| len| |aa|aa|03| |000000|TYPE|
    +------------+ +--------+ +-----------+

       Ethernet       802.1Q
    +------------+ +---------+
3.  |dst|src|8100| |VLAN|TYPE|
    +------------+ +---------+

       Ethernet       802.1Q      LLC         SNAP
    +------------+ +---------+ +--------+ +-----------+
4.  |dst|src|8100| |VLAN| LEN| |aa|aa|03| |000000|TYPE|
    +------------+ +---------+ +--------+ +-----------+

Unusual cases
-------------

       Ethernet       LLC         SNAP         802.1Q
    +------------+ +--------+ +-----------+ +---------+
5.  |dst|src| len| |aa|aa|03| |000000|8100| |VLAN|TYPE|
    +------------+ +--------+ +-----------+ +---------+

       Ethernet       LLC
    +------------+ +--------+
6.  |dst|src| len| |xx|xx|xx|
    +------------+ +--------+

       Ethernet       LLC         SNAP
    +------------+ +--------+ +-----------+
7.  |dst|src| len| |aa|aa|03| |xxxxxx|xxxx|
    +------------+ +--------+ +-----------+

       Ethernet       802.1Q      LLC
    +------------+ +---------+ +--------+
8.  |dst|src|8100| |VLAN| LEN| |xx|xx|xx|
    +------------+ +---------+ +--------+

       Ethernet       802.1Q      LLC         SNAP
    +------------+ +---------+ +--------+ +-----------+
9.  |dst|src|8100| |VLAN| LEN| |aa|aa|03| |xxxxxx|xxxx|
    +------------+ +---------+ +--------+ +-----------+

Behavior
--------

   ---------------  ---------------  -------------------------------------
       Before           After
     this commit      this commit
   dl_type dl_vlan  dl_type dl_vlan  Notes
   ------- -------  ------- -------  -------------------------------------
1.   TYPE    ffff     TYPE    ffff   no change
2.   TYPE    ffff     TYPE    ffff   no change
3.   TYPE    VLAN     TYPE    VLAN   no change
4.    LEN    VLAN     TYPE    VLAN   proposal fixes behavior
5.   TYPE    VLAN     8100    ffff   802.1Q says this is invalid framing
6.   05ff    ffff     05ff    ffff   no change
7.   05ff    ffff     05ff    ffff   no change
8.    LEN    VLAN     05ff    VLAN   proposal fixes behavior
9.    LEN    VLAN     05ff    VLAN   proposal fixes behavior

Signed-off-by: Ben Pfaff <blp@nicira.com>
13 years agovswitch: Clarify "arguments" versus "options".
Ben Pfaff [Fri, 6 Aug 2010 18:36:39 +0000 (11:36 -0700)]
vswitch: Clarify "arguments" versus "options".

Interface has an "options" column but some text referred to "arguments"
instead, which confused some readers.  Also be even more explicit about
syntax, since this also confused some readers.

CC: Dan Wendlandt <dan@nicira.com>
13 years agoofproto: Add support for remote "service controllers".
Ben Pfaff [Fri, 6 Aug 2010 23:49:20 +0000 (16:49 -0700)]
ofproto: Add support for remote "service controllers".

CC: Dan Wendlandt <dan@nicira.com>
13 years agoovs-openflowd: Fix support for multiple controllers.
Ben Pfaff [Fri, 6 Aug 2010 23:49:14 +0000 (16:49 -0700)]
ovs-openflowd: Fix support for multiple controllers.

The multiple controller support here has apparently never been tested.  I
still haven't tested it, but I fixed a few obvious problems in the source
code and in the manpage.

13 years agoofproto: Improve terminology.
Ben Pfaff [Thu, 5 Aug 2010 21:56:53 +0000 (14:56 -0700)]
ofproto: Improve terminology.

To me, "primary" and "service" connections seem like better terminology
than "controller" and "transient".

13 years agojson: Add extern "C" { ... } to headers.
Ben Pfaff [Fri, 6 Aug 2010 23:05:17 +0000 (16:05 -0700)]
json: Add extern "C" { ... } to headers.

This makes it easier for external C++ projects to import the header.

CC: Jeremy Stribling <strib@nicira.com>
13 years agoovs-pki: Create private keys with restricted permissions.
Ben Pfaff [Fri, 6 Aug 2010 17:24:13 +0000 (10:24 -0700)]
ovs-pki: Create private keys with restricted permissions.

OpenSSL will happily create private keys world-writable, but we probably
should not do that.

CC: Keith Amidon <keith@nicira.com>
13 years agoovs-pki: Create log directory if it does not exist.
Ben Pfaff [Fri, 6 Aug 2010 20:32:47 +0000 (13:32 -0700)]
ovs-pki: Create log directory if it does not exist.

Otherwise "ovs-pki init" can create the pkidir and then fail when it tries
to create the log file, if it is in a directory that does not exist.

13 years agoovs-pki: Consistently write error messages to stderr.
Ben Pfaff [Fri, 6 Aug 2010 17:22:29 +0000 (10:22 -0700)]
ovs-pki: Consistently write error messages to stderr.

13 years agovswitchd: Only re-learn from flows that output to OFPP_NORMAL.
Ben Pfaff [Fri, 6 Aug 2010 18:46:24 +0000 (11:46 -0700)]
vswitchd: Only re-learn from flows that output to OFPP_NORMAL.

Commit e96a4d8035 "bridge: Feed flow stats into learning table." started
feeding flow statistics back into the learning table, but it did not
distinguish between flows with and flows without an action that outputs to
OFPP_NORMAL.  Flows without such an action are not put into the learning
table initially, because bridge_normal_ofhook_cb() is not called for them,
but since that commit they have been put into the learning table when their
flows are reassessed.

This is inconsistent--flows without OFPP_NORMAL should either be learned
from all the time or never, not sometimes.  I can see valid arguments both
ways, but since it was always my intention not to learn from such flows,
this commit disables learning from them.

Problem found by code inspection.  I don't know of any observed bug that
this fixes.

13 years agotag: Be more precise about choosing tags to add, in tag_set_add().
Ben Pfaff [Fri, 6 Aug 2010 18:42:07 +0000 (11:42 -0700)]
tag: Be more precise about choosing tags to add, in tag_set_add().

It is not necessary to add a "tag" if all of the bits in it are already
present in some member of the set.  This commit adds that optimization.

13 years agotag: Use existing macro instead of constant.
Ben Pfaff [Tue, 3 Aug 2010 21:37:22 +0000 (14:37 -0700)]
tag: Use existing macro instead of constant.

N_TAG_BITS is always 32, currently, because tag_type is a typedef
for uint32_t, so this does not fix an actual bug.

13 years agovswitchd: Refresh SSL keys and certificates more frequently.
Ben Pfaff [Thu, 5 Aug 2010 16:58:58 +0000 (09:58 -0700)]
vswitchd: Refresh SSL keys and certificates more frequently.

Until now, the ovs-vswitchd main loop has refreshed keys and certificates
from their files only when the database changes.  This works fine if new
keys and certificates are installed with new file names, because the update
to the database to point to the new files will cause them to be read.  But
if the new keys and certificates are copied over the existing files, then
the delay until they are read is indefinite.

This commit fixes the problem by changing the SSL configuration so that it
is rechecked on every trip through the ovs-vswitchd main loop.

Bug #2921.

13 years agostream-ssl: Make changing keys and certificate at runtime reliable.
Ben Pfaff [Thu, 5 Aug 2010 16:24:00 +0000 (09:24 -0700)]
stream-ssl: Make changing keys and certificate at runtime reliable.

OpenSSL is picky about the order in which keys and certificates are
changed: you have to change the certificate first, then the key.  It
doesn't document this, but deep in the source code, in a function that sets
a new certificate, it has this comment:

    /* don't fail for a cert/key mismatch, just free
     * current private key (when switching to a different
     * cert & key, first this function should be used,
     * then ssl_set_pkey */

Brilliant, guys, thanks a lot.

Bug #2921.

13 years agodatapath: Detect and suppress flows that are implicated in loops.
Ben Pfaff [Tue, 3 Aug 2010 21:40:29 +0000 (14:40 -0700)]
datapath: Detect and suppress flows that are implicated in loops.

In-kernel loops need to be suppressed; otherwise, they cause high CPU
consumption, even to the point that the machine becomes unusable.  Ideally
these flows should never be added to the Open vSwitch flow table, but it
is fairly easy for a buggy controller to create them given the menagerie
of tunnels, patches, etc. that OVS makes available.

Commit ecbb6953b "datapath: Add loop checking" did the initial work
toward suppressing loops, by dropping packets that recursed more than 5
times.  This at least prevented the kernel stack from overflowing and
thereby OOPSing the machine.  But even with this commit, it is still
possible to waste a lot of CPU time due to loops.  The problem is not
limited to 5 recursive calls per packet: any packet can be sent to
multiple destinations, which in turn can themselves be sent to multiple
destinations, and so on.  We have actually seen in practice a case where
each packet was, apparently, sent to at least 2 destinations per hop, so
that each packet actually consumed CPU time for 2**5 == 32 packets,
possibly more.

This commit takes loop suppression a step further, by clearing the actions
of flows that are implicated in loops.  Thus, after the first packet in
such a flow, later packets for either the "root" flow or for flows that
it ends up looping through are simply discarded, saving a huge amount of
CPU time.

This version of the commit just clears the actions from the flows that a
part of the loop.  Probably, there should be some additional action to tell
ovs-vswitchd that a loop has been detected, so that it can in turn inform
the controller one way or another.

My test case was this:

ovs-controller -H --max-idle=permanent punix:/tmp/controller
ovs-vsctl -- \
    set-controller br0 unix:/tmp/controller -- \
    add-port br0 patch00 -- \
    add-port br0 patch01 -- \
    add-port br0 patch10 -- \
    add-port br0 patch11 -- \
    add-port br0 patch20 -- \
    add-port br0 patch21 -- \
    add-port br0 patch30 -- \
    add-port br0 patch31 -- \
    set Interface patch00 type=patch options:peer=patch01 -- \
    set Interface patch01 type=patch options:peer=patch00 -- \
    set Interface patch10 type=patch options:peer=patch11 -- \
    set Interface patch11 type=patch options:peer=patch10 -- \
    set Interface patch20 type=patch options:peer=patch21 -- \
    set Interface patch21 type=patch options:peer=patch20 -- \
    set Interface patch30 type=patch options:peer=patch31 -- \
    set Interface patch31 type=patch options:peer=patch30

followed by sending a single "ping" packet from an attached Ethernet
port into the bridge.  After this, without this commit the vswitch
userspace and kernel consume 50-75% of the machine's CPU (in my KVM
test setup on a single physical host); with this commit, some CPU is
consumed initially but it converges on 0% quickly.

A more challenging test sends a series of packets in multiple flows;
I used "hping3" with its default options.  Without this commit, the
vswitch consumes 100% of the machine's CPU, most of which is in the
kernel.  With this commit, the vswitch consumes "only" 33-50% CPU,
most of which is in userspace, so the machine is more responsive.

A refinement on this commit would be to pass the loop counter down to
userspace as part of the odp_msg struct and then back up as part of
the ODP_EXECUTE command arguments.  This would, presumably, reduce
the CPU requirements, since it would allow loop detection to happen
earlier, during initial setup of flows, instead of just on the second
and subsequent packets of flows.

13 years agodatapath: Inline flow_cast().
Ben Pfaff [Fri, 23 Jul 2010 20:05:25 +0000 (13:05 -0700)]
datapath: Inline flow_cast().

This function is both trivial and on the packet processing fast path, so
expand it inline.

13 years agodatapath: Don't track IP TOS value two different ways.
Ben Pfaff [Tue, 27 Jul 2010 17:02:07 +0000 (10:02 -0700)]
datapath: Don't track IP TOS value two different ways.

Originally, the datapath didn't care about IP TOS at all.  Then, to support
NetFlow, we made it keep track of the last-seen IP TOS value on a per-flow
basis.  Then, to support OpenFlow 1.0, we added a nw_tos field to
odp_flow_key.  We don't need both methods, so this commit drops the
NetFlow-specific tracking.

This introduces a small kernel ABI break: upgrading the kernel module
without upgrading the OVS userspace will mean that NetFlow records will
all show an IP TOS value of 0.  I don't consider that to be a serious
problem.

13 years agoINSTALL.Linux: Improve suggested ovsdb-server invocation.
Ben Pfaff [Mon, 2 Aug 2010 23:04:47 +0000 (16:04 -0700)]
INSTALL.Linux: Improve suggested ovsdb-server invocation.

ovsdb-server should ordinarily connect to managers specified in the
database itself, as well as use the SSL configuration specified in the
database, but the suggested ovsdb-server command line didn't do that.
This commit adds all the relevant arguments that the XenServer integration
passes by default.

Reported-by: Hao Zheng <hzheng@nicira.com>
13 years agoINSTALL.KVM: Fix typo.
Ben Pfaff [Thu, 29 Jul 2010 16:29:04 +0000 (09:29 -0700)]
INSTALL.KVM: Fix typo.

/etc/ifdown is written /etc/ovs-ifdown elsewhere, so this is probably just
a typo here.

CC: Dan Wendlandt <dan@nicira.com>
13 years agovswitch: Add external_ids column to every table.
Ben Pfaff [Wed, 28 Jul 2010 21:10:43 +0000 (14:10 -0700)]
vswitch: Add external_ids column to every table.

It seems potentially useful for system integrators to have this available,
and doesn't cost much.

13 years agovswitch: Clarify and expand purpose of external_ids columns.
Ben Pfaff [Wed, 28 Jul 2010 21:10:13 +0000 (14:10 -0700)]
vswitch: Clarify and expand purpose of external_ids columns.

Until now we have intended external_ids for use by external frameworks, but
only for storing "identifiers" such as UUIDs and names.  But there's no
reason that frameworks can't use it for whatever purposes they like.  This
commit rewords the text describing the external_ids columns to be more
expansive.

CC: Peter Balland <peter@nicira.com>
13 years agoxenserver: Add "reload" and "force-reload" support to init script.
Ben Pfaff [Mon, 2 Aug 2010 22:21:27 +0000 (15:21 -0700)]
xenserver: Add "reload" and "force-reload" support to init script.

I can't easily find anything that documents what commands Fedora init
scripts should support, but many of them support "reload" and
"force-reload". This commit adds support for them to the XenServer init
scripts.  (The Debian init scripts already had support.)

Debian does document that reload and force-reload should be supported:
http://www.debian.org/doc/debian-policy/ch-opersys.html#s-writing-init

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

13 years agodatapath: Remove netdev_alloc_skb_ip_align() compat code.
Jesse Gross [Mon, 2 Aug 2010 18:43:22 +0000 (11:43 -0700)]
datapath: Remove netdev_alloc_skb_ip_align() compat code.

We don't actually use this function anymore so there isn't a
point in having a configure test for it.

13 years agodatapath: Fix build with backported netdev_alloc_skb_ip_align()
Alexey I. Froloff [Mon, 2 Aug 2010 10:20:37 +0000 (14:20 +0400)]
datapath: Fix build with backported netdev_alloc_skb_ip_align()

Signed-off-by: Alexey I. Froloff <raorn@altlinux.org>
13 years agodatapath: Clean-up previous undefined symbol commit
Justin Pettit [Sun, 1 Aug 2010 00:09:31 +0000 (17:09 -0700)]
datapath: Clean-up previous undefined symbol commit

The previous commit still had some issues with the
"set_normalized_timespec" symbol being undefined.  Here we just replace
it.  We can search for a more elegant solution later if necessary.

13 years agodatapath: Fix undefined symbol "set_normalized_timespec"
Justin Pettit [Sat, 31 Jul 2010 23:05:20 +0000 (16:05 -0700)]
datapath: Fix undefined symbol "set_normalized_timespec"

The commit "datapath: Don't query time for every packet." (6bfafa55)
introduced the use of "set_normalized_timespec".  Unfortunately, older
kernels don't export the symbol.  This implements the function on those
older kernels.

13 years agovswitchd: Don't act as learning switch in secure mode with no controllers
Justin Pettit [Fri, 16 Jul 2010 06:37:35 +0000 (23:37 -0700)]
vswitchd: Don't act as learning switch in secure mode with no controllers

Don't act as a learning switch when the fail-mode is "secure" and no
controllers are defined.  This allows the bridge to come up in a state
where it won't pass any traffic until a controller has told it to do so.

13 years agovswitchd: Move fail-mode config to Bridge table
Justin Pettit [Fri, 16 Jul 2010 03:56:43 +0000 (20:56 -0700)]
vswitchd: Move fail-mode config to Bridge table

Configuration of the fail-mode was an attribute of the Controller table.
However, it makes more sense as an attribute of the Bridge table, since
the behavior defines what a bridge should do if it can't connect to
*any* controller.  This commit makes the move.

13 years agovswitchd: Remove default controller config from Open_vSwitch table
Justin Pettit [Thu, 15 Jul 2010 21:53:36 +0000 (14:53 -0700)]
vswitchd: Remove default controller config from Open_vSwitch table

An OpenFlow controller is normally associated with a bridge.  It was
possible to define a default controller in the Open_vSwitch table that
would be used if one was not associated with a bridge.  This was seldom
used and mostly just caused confusion.  This commit removes that
support, so an OpenFlow controller must always be associated with a
bridge.

13 years agolearning-switch: Avoid violating C aliasing rules initializing actions.
Ben Pfaff [Fri, 30 Jul 2010 21:51:35 +0000 (14:51 -0700)]
learning-switch: Avoid violating C aliasing rules initializing actions.

The C standard says that an object that is declared of one particular type
must not be accessed through a pointer to another type, with a few notable
exceptions.  This code was violating those rules, and GCC 4.4 complains
about it.  This commit fixes the problem by using one of the exceptions:
it's always OK to access an object as an array of character type (which is
what memcpy() does implicitly).

Reported-by: Justin Pettit <jpettit@nicira.com>
13 years agosflow: Avoid "unused parameter" warnings from GCC 4.4.
Ben Pfaff [Fri, 30 Jul 2010 21:47:29 +0000 (14:47 -0700)]
sflow: Avoid "unused parameter" warnings from GCC 4.4.

With GCC -Wno-unused by itself isn't enough to avoid "unused parameter"
warnings, since we also use -Wunused-parameter.  We also need to check for
and use -Wno-unused-parameter.

13 years agoovs-ofctl: Add support for OpenFlow enqueue action.
Ben Pfaff [Fri, 30 Jul 2010 22:39:56 +0000 (15:39 -0700)]
ovs-ofctl: Add support for OpenFlow enqueue action.

13 years agovport-internal: Set vport to NULL when detaching.
Jesse Gross [Thu, 29 Jul 2010 22:59:36 +0000 (15:59 -0700)]
vport-internal: Set vport to NULL when detaching.

'struct net_device' is refcounted and can stick around for quite a
while if someone is still holding a reference to it.  However, we
free the vport that it is attached to in the next RCU grace period
after detach.  This assigns the vport to NULL on detach and adds
appropriate checks.

13 years agovport: Make dp_port->vport always valid.
Jesse Gross [Thu, 29 Jul 2010 22:59:31 +0000 (15:59 -0700)]
vport: Make dp_port->vport always valid.

When we detached a vport we would assign NULL to dp_port->vport
before calling synchronize_rcu().  However, since vports have a
longer lifetime than dp_ports there were no checks before
dereferencing dp_port->vport.  This changes the behavior to
match the assumption by not assigning NULL during detach.  This
avoids a potential NULL pointer dereference in do_output() among
other places.

13 years agodatapath: Remove dead code.
Jesse Gross [Thu, 29 Jul 2010 21:42:17 +0000 (14:42 -0700)]
datapath: Remove dead code.

Several blocks of code were either no longer being called or had
been "#if 0"'d out for a long time.  This removes them.

13 years agodatapath: Remove redundant checks on SKBs.
Jesse Gross [Fri, 30 Jul 2010 02:01:02 +0000 (19:01 -0700)]
datapath: Remove redundant checks on SKBs.

On vport ingress we already check for shared SKBs but then later
warn in several other places.  In a similar vein, we check every
packet to see if it is LRO but only certain vports can produce
these packets.  Remove and consolidate checks to the places where
they are needed.

13 years agoovs-controller: Add ability to define default flows
Justin Pettit [Wed, 28 Jul 2010 22:18:25 +0000 (15:18 -0700)]
ovs-controller: Add ability to define default flows

Add support for the --with-flows option, which allows default flows to
be read from a file and pushed to connecting switches.

13 years agolearning-switch: Add ability to define default flows
Justin Pettit [Wed, 28 Jul 2010 22:18:14 +0000 (15:18 -0700)]
learning-switch: Add ability to define default flows

Add an argument to the function to create a learning switch, which
defines default flows to be pushed down to connecting switches.  It does
nothing to enforce that they remain intact.  It only pushes flows on
switch connection.

13 years agoofp-parse: Break string-to-openflow parsing into library functions
Justin Pettit [Wed, 28 Jul 2010 22:14:28 +0000 (15:14 -0700)]
ofp-parse: Break string-to-openflow parsing into library functions

An upcoming commit will add the ability to load OpenFlow rules into
ovs-controller.  Break out string-to-openflow parsing so that
ovs-ofctl and ovs-controller can use the same code.

13 years agodatapath: Catch missed formatting changes.
Jesse Gross [Fri, 30 Jul 2010 01:15:14 +0000 (18:15 -0700)]
datapath: Catch missed formatting changes.

A few functions were missed in the change to move the return type
onto the same line as the arguments.

13 years agodatapath: Don't query time for every packet.
Jesse Gross [Fri, 16 Jul 2010 02:22:07 +0000 (19:22 -0700)]
datapath: Don't query time for every packet.

Rather than actually query the time every time a packet comes through,
just store the current jiffies and convert it to actual time when
requested.  GRE is the primary beneficiary of this because the traffic
travels through the datapath twice.  This change reduces CPU utilization
3-4% with GRE.

13 years agovlog: Fix logic error in update_min_level().
Ben Pfaff [Fri, 23 Jul 2010 22:27:38 +0000 (15:27 -0700)]
vlog: Fix logic error in update_min_level().

Commit 480ce8ab "vlog: Make the vlog module catalog program-specific."
accidentally inverted the logic in this function, which broke the "-v"
to various OVS programs as well as other mechanisms to set logging to
non-default levels.

13 years agovlog: Make the vlog module catalog program-specific.
Ben Pfaff [Fri, 16 Jul 2010 17:53:14 +0000 (10:53 -0700)]
vlog: Make the vlog module catalog program-specific.

Until now, the collection of vlog modules supported by a given OVS program
was not specific to that program.  That means that, for example, even
though ovs-dpctl does not have anything to do with jsonrpc, it still has
a vlog module for it.  This is confusing, at best.

This commit fixes the problem on some systems, in particular on ones that
use GCC and the GNU linker.  It uses the feature of the GNU linker
described in its manual as:

    If an orphaned section's name is representable as a C identifier then
    the linker will automatically see PROVIDE two symbols: __start_SECNAME
    and __end_SECNAME, where SECNAME is the name of the section.  These
    indicate the start address and end address of the orphaned section
    respectively.

Systems that don't support these features retain the earlier behavior.

This commit also fixes the annoyance that modifying lib/vlog-modules.def
causes all sources files that #include "vlog.h" to recompile.

13 years agovlog: Introduce VLOG_DEFINE_THIS_MODULE for declaring vlog module in use.
Ben Pfaff [Fri, 16 Jul 2010 18:02:49 +0000 (11:02 -0700)]
vlog: Introduce VLOG_DEFINE_THIS_MODULE for declaring vlog module in use.

Adding a macro to define the vlog module in use adds a level of
indirection, which makes it easier to change how the vlog module must be
defined.  A followup commit needs to do that, so getting these widespread
changes out of the way first should make that commit easier to review.

13 years agovlog: Remove explicit calls to vlog_init().
Ben Pfaff [Fri, 16 Jul 2010 18:11:44 +0000 (11:11 -0700)]
vlog: Remove explicit calls to vlog_init().

This is no longer necessary.

13 years agovlog: Make vlog initialize itself when necessary.
Ben Pfaff [Fri, 16 Jul 2010 18:23:31 +0000 (11:23 -0700)]
vlog: Make vlog initialize itself when necessary.

It's more convenient if clients don't have to initialize modules
explicitly.

The most important part of this change is to initialize the default
log levels statically.  Previously, by initializing log levels only
from vlog_init(), all the log levels appeared to be VLL_EMER (0) if
vlog_init() was accidentally not called at all.  This was not intended
behavior, so this commit fixes it.

This commit also fixes up a few test programs whose tests accidentally
depended on this behavior, by making them explicitly turn off log
messages that were implicitly turned off before.

13 years agotimeval: Make time_init() static and remove calls to it.
Ben Pfaff [Wed, 21 Jul 2010 22:42:22 +0000 (15:42 -0700)]
timeval: Make time_init() static and remove calls to it.

Since the timeval module now initializes itself on-demand, there is no
longer any need to initialize it explicitly, or to provide an interface to
do so.

13 years agotimeval: Make timeval module initialize itself.
Ben Pfaff [Wed, 21 Jul 2010 22:43:30 +0000 (15:43 -0700)]
timeval: Make timeval module initialize itself.

It's more convenient if clients don't have to initialize modules
explicitly.

13 years agotimeval: Integrate CLOCK_MONOTONIC detection into time_init().
Ben Pfaff [Fri, 16 Jul 2010 17:41:16 +0000 (10:41 -0700)]
timeval: Integrate CLOCK_MONOTONIC detection into time_init().

I don't see a reason that set_up_monotonic() should be separate from
time_init().  Doing all the time initialization in one place seems
reasonable, so this commit makes that change.

13 years agodebian: Check for accurate Debian changelog version at build time too.
Ben Pfaff [Wed, 21 Jul 2010 22:38:23 +0000 (15:38 -0700)]
debian: Check for accurate Debian changelog version at build time too.

When we increment the Open vSwitch version number, we tend to forget to
update it in debian/changelog at the same time.  Right now this gets
fixed up automatically at "make dist" time, but it's even better if we can
always have it be correct in the repository.  This commit should help with
that, by making both "make" and "make dist" refuse to proceed if the
version number is out of sync.

13 years agotests: Disable profiling for "wait-until must wait" test.
Ben Pfaff [Thu, 15 Jul 2010 17:50:33 +0000 (10:50 -0700)]
tests: Disable profiling for "wait-until must wait" test.

This test tends to break when run with lcov profiling since the lcov
wrapper script can't synchronize access to profiling data across all the
ovs-vsctl instances running in parallel.

13 years agonetdev-linux: Avoid minor number 0 in traffic control.
Ben Pfaff [Fri, 16 Jul 2010 22:50:57 +0000 (15:50 -0700)]
netdev-linux: Avoid minor number 0 in traffic control.

Linux traffic control handles with minor number 0 refer to qdiscs, not
to classes.  This commit deals with this by using a conversion function:
OpenFlow queue 0 maps to minor 1, queue 1 to minor 2, and so on.

13 years agonetdev-linux: Dump all queues, not just direct children of the root.
Ben Pfaff [Fri, 16 Jul 2010 22:47:23 +0000 (15:47 -0700)]
netdev-linux: Dump all queues, not just direct children of the root.

A netdev-linux traffic control implementation has to dump all of a port's
traffic classes in a couple of different situations.  start_queue_dump()
is supposed to do that.  But it was specifying TC_H_ROOT as tcm_parent,
which only dumped classes that were direct children of the root.  This
commit changes tcm_parent to 0, which obtains all traffic classes
regardless of parent.

13 years agodpif-linux: Translate queues to priorities correctly.
Ben Pfaff [Fri, 16 Jul 2010 22:39:40 +0000 (15:39 -0700)]
dpif-linux: Translate queues to priorities correctly.

The TC_H_MAKE macro does not shift the major number into position.

13 years agodpif: Abstract translation from OpenFlow queue ID into ODP priority value.
Ben Pfaff [Tue, 20 Jul 2010 18:23:21 +0000 (11:23 -0700)]
dpif: Abstract translation from OpenFlow queue ID into ODP priority value.

When the QoS code was integrated, I didn't yet know how to abstract the
translation from a queue ID in an OpenFlow OFPAT_ENQUEUE action into a
priority value for an ODP ODPAT_SET_PRIORITY action.  This commit is a
first attempt that works OK for Linux, so far.  It's possible that in fact
this translation needs the 'netdev' as an argument too, but it's not needed
yet.

13 years agoAdd pretty-printers for QoS related OpenFlow and ODP actions.
Ben Pfaff [Fri, 16 Jul 2010 22:30:09 +0000 (15:30 -0700)]
Add pretty-printers for QoS related OpenFlow and ODP actions.

13 years agoovs-controller: Add support for OpenFlow queues.
Ben Pfaff [Fri, 16 Jul 2010 00:08:17 +0000 (17:08 -0700)]
ovs-controller: Add support for OpenFlow queues.

Before, ovs-controller always sent packets using OFPAT_OUTPUT, which always
uses the default OpenFlow queue.  To help me debug the Open vSwitch QoS
implementation, I want to be able to send packets on other queues, so
this commit adds that feature.

13 years agolearning-switch: Add support for OpenFlow queues.
Ben Pfaff [Tue, 20 Jul 2010 18:18:24 +0000 (11:18 -0700)]
learning-switch: Add support for OpenFlow queues.

Before, an lswitch always sent packets using OFPAT_OUTPUT, which always
uses the default OpenFlow queue.  To help me debug the Open vSwitch QoS
implementation, I want to be able to send packets on other queues, so
this commit adds that feature.

13 years agolearning-switch: Break packet-in processing into two steps.
Ben Pfaff [Tue, 20 Jul 2010 18:10:45 +0000 (11:10 -0700)]
learning-switch: Break packet-in processing into two steps.

13 years agolearning-switch: Refactor wildcards calculation.
Ben Pfaff [Thu, 15 Jul 2010 23:20:37 +0000 (16:20 -0700)]
learning-switch: Refactor wildcards calculation.

There's no need to calculate the wildcards to use for each flow, since it
is a constant across every flow.  In my opinion this also makes
process_packet_in() a little easier to understand, since it deletes a few
lines of code from a relatively complicated function.

13 years agolearning-switch: Reserved addresses are destinations, not sources.
Ben Pfaff [Thu, 15 Jul 2010 23:02:46 +0000 (16:02 -0700)]
learning-switch: Reserved addresses are destinations, not sources.

A switch is not supposed to forward packets directed to MAC addresses
01:80:c2:00:00:0x.  This code was instead dropping packets *from* those
addresses.

(This code is only used by ovs-controller, so the bug is not a big deal.)

13 years agoovs-vsctl: Fix unitialized variables.
Jesse Gross [Fri, 16 Jul 2010 01:04:10 +0000 (18:04 -0700)]
ovs-vsctl: Fix unitialized variables.

The compiler pointed out two variables that it thought were used
without being initialized.  The first was just a spurious warning
but the second could result in an unitialized pointer being freed.
This fixes both of those issues.

13 years agoovs-vsctl: Do not allow record names to be abbreviated.
Ben Pfaff [Thu, 15 Jul 2010 00:04:22 +0000 (17:04 -0700)]
ovs-vsctl: Do not allow record names to be abbreviated.

It's pretty risky to allow record names to be abbreviated.  If eth1 through
eth20 all exist, and then someone deletes eth1, then until now an ovs-vsctl
command that mentioned eth1 would actually use eth10.  This is too much of
a caveat to let loose on unsuspecting scripts, so this commit removes that
functionality.

13 years agoxenserver: Kill bond slaves' dhclients when bringing up bond master.
Ben Pfaff [Fri, 16 Jul 2010 16:22:23 +0000 (09:22 -0700)]
xenserver: Kill bond slaves' dhclients when bringing up bond 

This fixes the converse of the problem addressed by commit fe19e820
"xenserver: Kill bond master's dhclient when bringing up bond slave".  In
that commit's log message, I claimed that the converse was not a problem,
but I was wrong.  I must have screwed up in testing, because it really is
a problem.  This commit fixes it.

Signed-off-by: Ben Pfaff <blp@nicira.com>
Acked-by: Ian Campbell <Ian.Campbell@citrix.com>
CC: Dominic Curran <dominic.curran@citrix.com>
Reported-by: Michael Mao <mmao@nicira.com>
Bug #2668.

13 years agodoc: Make explicit that ovs-vswitchd is the preferred switch.
Jesse Gross [Thu, 15 Jul 2010 20:47:59 +0000 (13:47 -0700)]
doc: Make explicit that ovs-vswitchd is the preferred switch.

Many people who are looking for an OpenFlow switch assume that
the only way to do it is using ovs-openflowd.  Sometimes they also
run ovs-vswitchd at the same time.  Try to clarify that neither
of these are necessary and ovs-vswitchd can handle OpenFlow by
itself and is the preferred method of doing so.

13 years agodatapath: Don't update flow key when applying actions.
Jesse Gross [Thu, 15 Jul 2010 03:15:53 +0000 (20:15 -0700)]
datapath: Don't update flow key when applying actions.

Currently the flow key is updated to match an action that is applied
to a packet but these field are never looked at again.  Not only is
this a waste of time it also makes optimizations involving caching
the flow key more difficult.

13 years agodatapath: Don't set tunnel_id in a function.
Jesse Gross [Thu, 15 Jul 2010 02:42:57 +0000 (19:42 -0700)]
datapath: Don't set tunnel_id in a function.

We don't need a function to set a variable.  In practice it will
almost certainly get inlined but this makes it easier to read.

13 years agogre: Use struct for parsing GRE header.
Jesse Gross [Thu, 15 Jul 2010 01:45:45 +0000 (18:45 -0700)]
gre: Use struct for parsing GRE header.

GRE is a somewhat annoying protocol because the header is variable
length.  However, it does have a few fields that are always present
so we can make the parsing seem less magical by using a struct for
those fields instead of building it up field by field.

13 years agogre: Wait for an RCU grace period before freeing port.
Jesse Gross [Thu, 15 Jul 2010 01:35:58 +0000 (18:35 -0700)]
gre: Wait for an RCU grace period before freeing port.

We currently remove ports from the GRE hash table and then immediately
free the ports.  Since received packets could be using that port this
can lead to a crash (the port has already been detached from the
datapath so this can't happen for transmitted packets).  As a result
we need to wait for an RCU grace period to elapse before actually
freeing the port.

In an ideal world we would actually remove the port from the hash
table in a hypothetical gre_detach() function since this is one of
the purposes of detaching.  However, we also use the hash table to
look for collisions in the lookup criteria and don't want to allow
two identical ports to exist.  It doesn't matter though because we
aren't blocking on the freeing of resources.

13 years agovport: Use DEFINE_PER_CPU instead of dynamically allocating loop counter.
Jesse Gross [Thu, 15 Jul 2010 02:59:41 +0000 (19:59 -0700)]
vport: Use DEFINE_PER_CPU instead of dynamically allocating loop counter.

DEFINE_PER_CPU is simpler and faster than alloc_percpu() so use it
for the loop counter, which is already statically defined.

13 years agodatapath: Put return type on same line as arguments for functions.
Jesse Gross [Thu, 15 Jul 2010 02:27:18 +0000 (19:27 -0700)]
datapath: Put return type on same line as arguments for functions.

In some places we would put the return type on the same line as
the rest of the function definition and other places we wouldn't.
Reformat everything to match kernel style.

13 years agovport: Use EBUSY to represent already attached device.
Jesse Gross [Thu, 15 Jul 2010 02:02:10 +0000 (19:02 -0700)]
vport: Use EBUSY to represent already attached device.

We currently use EEXIST to represent both a device that is already
attached and for GRE devices that are the same as another one.
Instead use EBUSY for already attached devices to disambiguate the
two situations.

13 years agodatapath: Make checksum offsets unsigned.
Jesse Gross [Thu, 15 Jul 2010 02:46:23 +0000 (19:46 -0700)]
datapath: Make checksum offsets unsigned.

The offsets for checksum offsets should always be positive so make
that explicit by using unsigned ints.  This helps bug checks that
test if the offsets are greater than their upper limits.

13 years agoovs-vsctl: Make --help capitalization and spelling more consistent.
Ben Pfaff [Wed, 14 Jul 2010 23:36:42 +0000 (16:36 -0700)]
ovs-vsctl: Make --help capitalization and spelling more consistent.

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

13 years agoTests: Fix nonportable \" escape in printf(1) invocation.
Ben Pfaff [Wed, 14 Jul 2010 23:29:33 +0000 (16:29 -0700)]
Tests: Fix nonportable \" escape in printf(1) invocation.

The \" escape is not part of POSIX, but it is a common extension.  The
dash shell's built-in "printf" implementation does not include this
extension, which caused the testsuite to be generated incorrectly if it
is used as the default shell (as it is on newer versions of Debian and
Ubuntu).

However, there's no reason to use a backslash here at all, so just omit
it.

13 years agoofpbuf: Implement unsupported feature in ofpbuf_trim().
Ben Pfaff [Wed, 14 Jul 2010 17:05:53 +0000 (10:05 -0700)]
ofpbuf: Implement unsupported feature in ofpbuf_trim().

Until now, ofpbuf_trim() has not handled the case where the ofpbuf has
nonzero headroom.  This causes an assertion failure when pinsched_send()
queues a packet to be sent later, because such packets have been
guaranteed to have nonzero headroom since commit 43253595 "ofproto: Avoid
buffer copy in OFPT_PACKET_IN path."  This commit fixes the problem by
implementing the until-now unsupported case.

This commit factors code out of ofpbuf_prealloc_tailroom() into two new
functions, ofpbuf_rebase__() and ofpbuf_resize_tailroom__(), and uses the
latter to implement both ofpbuf_prealloc_tailroom() and ofpbuf_trim().
ofpbuf_rebase__() isn't used on its own at all, but it seems potentially
useful so I made it an independent function.

Reported-by: Tom Everman <teverman@google.com>
13 years agodatapath: Make our checksumming more closely match skb_checksum_help().
Jesse Gross [Mon, 12 Jul 2010 23:02:12 +0000 (16:02 -0700)]
datapath: Make our checksumming more closely match skb_checksum_help().

Our code that handles checksumming does essentially the same thing
as skb_checksum_help() except it folds the process into copying to
userspace.  This makes the two functions more closely resemble
each other in structure, including adding a couple of BUG() checks.
This should have no functional change but makes comparision easier
when debugging.

13 years agogre: Fix headroom calculation.
Jesse Gross [Tue, 13 Jul 2010 00:40:38 +0000 (17:40 -0700)]
gre: Fix headroom calculation.

If we need to make a copy we add a little bit extra to the headroom
that we think we need in order to avoid future copies.  Previously we
would always just allocate max(headroom, 64) which is generally
enough space.  However, if we are using IPsec our expected headroom
is large and there is no extra.  Instead, it is better to just tack on
a few extra bytes so we'll always have a cushion.

13 years agodatapath: Move over-MTU checking into vport_send().
Jesse Gross [Mon, 12 Jul 2010 20:27:57 +0000 (13:27 -0700)]
datapath: Move over-MTU checking into vport_send().

We currently check for packets that are over the MTU in do_output().
There is a one-to-one correlation between this function and
vport_send() so move the MTU check there for consistency with
other error checking.

13 years agodatapath: Add loop checking.
Jesse Gross [Mon, 12 Jul 2010 20:13:17 +0000 (13:13 -0700)]
datapath: Add loop checking.

New types of vports such as patch and GRE make it possible to
connect multiple (or the same) datapaths together, which introduces
the possibility of loops on a single machine.  Local loops are
even worse than network loops because they will quickly crash the
machine once the kernel stack is exhausted.  This adds loop
checking within the OVS datapath that will drop packets that have
been seen more than 5 times.

CC: Paul Ingram <paul@nicira.com>