2
0
mirror of https://github.com/openvswitch/ovs synced 2025-08-31 14:25:26 +00:00
Commit Graph

3105 Commits

Author SHA1 Message Date
Ben Pfaff
d84d4b88d2 Fix incorrect byte order annotations.
These are not actual bugs, just deceptive use of the wrong function or
type.

Found by sparse.
2011-05-16 13:40:47 -07:00
Ben Pfaff
5eba3806a3 openflow: Change types from uint<N>_t to ovs_be<N>.
I've been reluctant in the past to make wholesale changes to openflow.h
because it would be a divergence from upstream that would make comparisons
and merges more difficult.  But, in practice, no one does such comparisons
and no merges happen (because OpenFlow 1.0 is not changing).  I'd still be
inclined to resist, except that in this series I'm adding actual checking
for byte order conventions (as opposed to just documentation).
2011-05-16 13:40:47 -07:00
Ben Pfaff
dbba996be2 Convert remaining network-byte-order "uint<N>_t"s into "ovs_be<N>"s.
I looked at almost every uint<N>_t in the tree to determine whether it was
really in network byte order, and converted the ones that were.

The only remaining ones, modulo my mistakes, are in openflow.h.  I'm not
sure whether we should convert those, because there might be some value
in remaining close to upstream for this header.
2011-05-16 13:40:47 -07:00
Ben Pfaff
118c46769f ofproto: Maintain ofp_phy_port for each ofport in network byte order.
It's rather confusing to have an instance of a whole structure in an
unexpected byte order.  This commit gets rid of that oddity.
2011-05-16 13:40:47 -07:00
Ben Pfaff
e3c1773370 Consistently write null pointer constants as NULL instead of 0.
Found with sparse.
2011-05-16 13:40:47 -07:00
Ben Pfaff
1102893de4 ofproto: Drop duplicate "const" in parameter declaration.
Found by sparse.
2011-05-16 13:40:47 -07:00
Ben Pfaff
d3d8f1f7e5 Add missing "static" keywords.
Found by sparse.
2011-05-16 13:40:47 -07:00
Ben Pfaff
805e8f4e27 Remove unnecessary #include directives. 2011-05-16 13:40:47 -07:00
Ben Pfaff
9219e45404 ofproto: Fix ofproto_send_packet() treatment of vlan_tci parameter.
ofproto_send_packet() seems very confused about whether vlan_tci is in
host or network byte order.  But the callers always pass 0 anyway, so we
might as well remove it.
2011-05-16 13:40:46 -07:00
Ben Pfaff
c5530655f3 stream-ssl: Fix call to accept().
GCC and glibc conspire to allow struct sockaddr_in * to be passed in
place of struct sockaddr *, but that's non-standard and we're better
off not taking advantage of it.

Found by sparse.
2011-05-16 13:40:46 -07:00
Ben Pfaff
35fe11834c tests: Check ovs-openflowd log output instead of ignoring it.
ovs-openflowd outputs a number of log messages that we don't want to
suppress.  We do want to know if it logs anything that we don't expect.
So this commit starts checking the log output, discarding any normal,
expected messages.

Reviewed-by: Simon Horman <horms@verge.net.au>
2011-05-13 14:45:53 -07:00
Ben Pfaff
488d734d6e netdev-linux: Open AF_PACKET socket only when it is needed.
Only a privileged process can open a raw AF_PACKET socket, so netdev-linux
will fail to initialize if run as non-root and you get a cascade of error
messages, like this:

netdev_linux|ERR|failed to create packet socket: Operation not permitted
netdev|ERR|failed to initialize system network device class: Operation not permitted
netdev|ERR|failed to initialize internal network device class: Operation not permitted
netdev|ERR|failed to initialize tap network device class: Operation not permitted

But in fact the AF_PACKET socket is not needed for most operations (only
for sending packets) and it is never needed for testing with the "dummy"
datapath and network device, so we can avoid logging all of these errors
by opening the packet socket only on demand, as this commit does.

Reviewed-by: Simon Horman <horms@verge.net.au>
2011-05-13 14:45:53 -07:00
Ben Pfaff
bd3932826b netdev-linux: Only call set_nonblocking() if socket creation succeeds.
Reviewed-by: Simon Horman <horms@verge.net.au>
2011-05-13 14:45:53 -07:00
Ben Pfaff
1c0b7503af ofp-util: Revise OpenFlow 1.0 ofp_match normalization.
For a long time, Open vSwitch has "normalized" OpenFlow 1.0 flows in a
funny way: it tries to change fields that are wildcarded into fields
that are exact-match.  For example, the normalize_match() function
knows that if dl_type is wildcarded, then all of the L3 and L4 fields
will always be extracted as 0, so it sets those fields to exact-match
and their values to 0.

The reason for this was originally that exact-match flows were much
cheaper for Open vSwitch to implement, because they could be implemented
with a hash table, whereas other kinds of flows had to be implemented
with an expensive linear search.  But these days Open vSwitch has a
smarter classifier in which wildcarded flows have minimal cost.  Also,
it is no longer possible for OpenFlow 1.0 to specify truly exact-match
flows, because Open vSwitch supports fields for which OpenFlow 1.0
cannot specify values and therefore will always be wildcarded.

Now, it no longer makes sense to do this transformation, so this commit
removes it.  Presumably, this will be less surprising for users.

Reviewed-by: Simon Horman <horms@verge.net.au>
2011-05-13 14:45:52 -07:00
Ben Pfaff
34276a5790 ofp-util: Simplify OpenFlow 1.0 ofp_match normalization.
The normalize_match() function does more work than really needed.  It goes
to some trouble to zero out fields that are wildcarded.  This is not
necessary, because cls_rule_from_match() will take care of it later.

Also make normalize_match() private to ofp-util.c, since it has no other
users now and I don't expect more later.

Reviewed-by: Simon Horman <horms@verge.net.au>
2011-05-13 14:45:52 -07:00
Ben Pfaff
f1f41fb6b9 ofp-util: Don't warn for different forms of nw_{src,dst} wildcards.
OpenFlow 1.0 uses a 6-bit field to express the number of wildcarded bits
in the nw_src and nw_dst field.  Any value 32 or greater in these fields
(binary 1xxxxx) means that all of the bits are wildcarded.  That means
that there are 32 different ways to express a wildcarded nw_src or nw_dst.
At least two of those seem sensible (100000 and 111111) so we shouldn't
warn about one of them.

This fixes the problem by ORing with 100000 instead of 111111, so that any
already-correct wildcarded mask won't be affected.

This fix allows us to update some tests.

Reviewed-by: Simon Horman <horms@verge.net.au>
2011-05-13 14:45:52 -07:00
Ben Pfaff
bc9dcfb371 lockfile: Don't warn if successful lock takes a little time.
This code issues a warning if obtaining a lock takes even 1 millisecond.
That's far too aggressive.  There's no need to warn if we have to wait
a few milliseconds.  This function already warns elsewhere if locking takes
more than 1 second, which is much more reasonable.

This change allows us to test ovsdb-server stderr output more carefully.
Before now, the tests had to ignore what ovsdb-server writes to stderr
because sometimes it would log a warning that locking took 1 ms (or so).

Reviewed-by: Simon Horman <horms@verge.net.au>
2011-05-13 14:43:44 -07:00
Ben Pfaff
7fcfe998c5 tests: Check test output more carefully.
It's better to check output than to ignore it, because ignoring
output can fail to detect real bugs later if the output changes.

Reviewed-by: Simon Horman <horms@verge.net.au>
2011-05-13 14:43:12 -07:00
Ben Pfaff
f89ffb0e2f poll-loop: Make wakeup logging more portable and easier to understand.
Until now, when the poll_loop module's log level was turned up to "debug",
it would log a backtrace of the call stack for the event that caused poll()
to wake up in poll_block().  This was pretty useful from time to time to
find out why ovs-vswitchd was using more CPU than expected, because we
could find out what was causing it to wake up.

But there were some issues.  One is simply that the backtrace was printed
as a series of hexadecimal numbers, so GDB or another debugger was needed
to translate it into human-readable format.  Compiler optimizations meant
that even the human-readable backtrace wasn't, in my experience, as helpful
as it could have been.  And, of course, one needed to have the binary to
interpret the backtrace.  When the backtrace couldn't be interpreted or
wasn't meaningful, there was essentially nothing to fall back on.

This commit changes the way that "debug" logging for poll_block() wakeups
works.  Instead of logging a backtrace, it logs the source code file name
and line number of the call to a poll_loop function, using __FILE__ and
__LINE__.  This is by itself much more meaningful than a sequence of
hexadecimal numbers, since no additional interpretation is necessary.  It
can be useful even if the Open vSwitch version is only approximately known.

In addition to the file and line, this commit adds, for wakeups caused by
file descriptors, information about the file descriptor itself: what kind
of file it is (regular file, directory, socket, etc.), the name of the file
(on Linux only), and the local and remote endpoints for socket file
descriptors.

Here are a few examples of the new output format:

932-ms timeout at ../ofproto/in-band.c:507
[POLLIN] on fd 20 (192.168.0.20:35388<->192.168.0.3:6633) at ../lib/stream-fd.c:149
[POLLIN] on fd 7 (FIFO pipe:[48049]) at ../lib/fatal-signal.c:168
2011-05-13 14:38:15 -07:00
Ben Pfaff
0e6644c388 backtrace: Make backtrace_capture() work on more systems.
The backtrace_capture() implementation only worked properly with GNU C on
systems that have a simple stack frame with a frame pointer.  Notably,
the x86-64 ABI by default has no frame pointer, so this failed on x86-64.

However, glibc has a function named backtrace() that does what we want.
This commit tests for this function and uses it when it is present, fixing
x86-64 backtraces.
2011-05-13 14:37:14 -07:00
Ethan Jackson
498b2a5a68 cfm: Clarify cfm_create() documentation.
Reported-by: Ben Pfaff <blp@nicira.com>
2011-05-13 13:09:27 -07:00
Ethan Jackson
70e3e6af07 cfm: Always log on CCM reception.
This commit causes the CFM library to log at debug level when valid
CCMs are received.
2011-05-13 13:09:27 -07:00
Ethan Jackson
dd986e09fd cfm: Replace recv_time with a flag.
This makes the code more obviously correct in my opinion.

This patch also removes timer_enabled_at() along with its only
user.
2011-05-13 13:09:27 -07:00
Ethan Jackson
aa7f115843 cfm: No longer keep track of bad CCMs.
According to the 802.1ag specification, reception of a CCM from an
unexpected source should trigger a fault. This patch causes the CFM
module to simply warn instead.  There are several reasons for this
change outlined below.

  - Faults can cause controllers to make potentially expensive
    changes to the network topology.
  - Faults can be maliciously triggered by crafting invalid CCMs.
  - With this patch, cfm->fault and rmp->fault are only updated in
    cfm_run() making the code easier to debug and reason about.
2011-05-13 13:09:27 -07:00
Ethan Jackson
5e80932275 cfm: No longer trigger fault upon unexpected ccm_interval.
According to the 802.1ag specification, when a CCM is received
which advertises a misconfigured transmission interval, a fault
should be triggered.  This patch goes against the spec by simply
warning when this happens.  This is done for several reasons.

  - Faults can cause controllers to make potentially expensive
    changes in the network topology.
  - Faults can be maliciously triggered by crafting invalid CCMs.
  - Reducing the number of places in the code where rmp->fault and
    cfm->fault are changed makes the code easier to debug and
    reason about.
2011-05-13 13:09:27 -07:00
Ben Pfaff
e3f55cb8b2 bridge: Keep default Ethernet address stable between runs.
In some circumstances the bridge can't find a stable physical Ethernet
address to use, so until now it has just picked a random Ethernet address.
In these circumstances, therefore, the bridge Ethernet address would change
from one ovs-vswitchd run to another.  But OVS does have a stable
identifier for a bridge: its UUID.  This commit changes to use that as the
default bridge Ethernet address.

The datapath ID is sometimes derived from the bridge Ethernet address, so
this change also makes the bridge Ethernet address more stable.

CC: Natasha Gude <natasha@nicira.com>
Bug #5594.
2011-05-12 13:26:57 -07:00
Jesse Gross
2db65bf72c datapath: Pull data into linear area only on demand.
We currently always pull 64 bytes of data (if it exists) into the
skb linear data area when parsing flows.  The theory behind this
is that the data should always be there and it's enough to parse
common flows.  However, this causes a number of problems in
different situations.  The first is that it is not enough to handle
IPv6 so we must pull additional data anyways.  However, the main
problem is that GRO typically allocates a new skb and puts just the
headers in there.  For a typical TCP/IPv4 packet there are 54 bytes
of headers, which means that we must possibly reallocate and copy
on every packet.  In addition, GRO creates frag_lists with this
specific geometry in order to allow later segmentation if the packet
is forwarded to a device that does not support frag_lists.  When
we pull additional data it changes the geometry and causes later
problems for the device.  This patch instead incrementally pulls
data, which avoids these problems.

Signed-off-by: Jesse Gross <jesse@nicira.com>
CC: Ian Campbell <Ian.Campbell@citrix.com>
2011-05-11 11:37:17 -07:00
Justin Pettit
f8d17df2b2 xenserver: Fix bugs related to using xe-switch-network-backend in spec file.
Commit daf2ebb (xenserver: Use xe-switch-network-stack in RPM spec
file.) changed the spec file to use xe-switch-network-backend instead of
directly modifying "/etc/xensource/network.conf".  It incorrectly
assumed that the command was in the search path.  It also didn't take
into account that the command will remove the "openvswitch" service with
chkconfig.  This commit fixes those errors.

Signed-off-by: Justin Pettit <jpettit@nicira.com>
2011-05-11 09:40:39 -07:00
Ben Pfaff
bf8f2167fd stream-ssl: Improve messages when configuring SSL if it is unsupported.
Previously, if --private-key or another option that requires SSL support
was used, but OVS was built without OpenSSL support, then OVS would fail
with an error message that the specified option was not supported.  This
confused users because it made them think that the option had been removed:
    http://openvswitch.org/pipermail/discuss/2011-April/005034.html

This commit improves the error message: OVS will now report that it was
built without SSL support.  This should be make the problem clear to users.

Reported-by: Aaron Rosen <arosen@clemson.edu>
Feature #5325.
2011-05-10 09:17:37 -07:00
Ben Pfaff
be55976089 INSTALL.XenServer: Document Open vSwitch boot process on XenServer.
Inspired by a conversation with David Erickson <derickso@stanford.edu>.
2011-05-10 09:15:44 -07:00
Ben Pfaff
6d5abe9434 ovs-vsctl: Issue warning for likely erroneous "get" commands.
Suggested-by: Reid Price <reid@nicira.com>
Feature #5527.
2011-05-10 09:10:16 -07:00
Ethan Jackson
daa8bd2bf8 bridge: Don't configure QoS without Queues.
It doesn't make sense to create a QoS object without any queues.
Before this patch, OVS would configure the QoS object and as a
result drop all traffic going through the affected interface.  With
this patch, OVS will simply clear QoS configuration on the
interface.

Bug #5583.
2011-05-06 17:04:41 -07:00
Ethan Jackson
6f1435fc8f ofproto: Resubmit statistics improperly account during failover.
In some cases, when a facet's actions change because it resubmits
into a different rule, it will account all packets it as accrued
in the datapath to the new rule.  Due to the algorithm we are
using, it is acceptable for a facet to miscount at most 1 second
worth of packets in this manner.  This patch implements the proper
behavior.

Generally speaking, when a facet is facet_put__() into the
datapath, the kernel returns the old flow's statistics so they may
be accounted for in user space.  These statistics are generally
pushed down to the relevant facet's resubmit children.  Before this
patch, facet_put__() did not compensate for the fact that many of
the statistics in the datapath may have been already pushed.
Thus the entire packet count stored in the datapath would be pushed
to its children instead of simply the packets which have accrued
since the last accounting.  This patch fixes the behavior by
subtracting already accounted for packets from the statistics
returned by the datapath.
2011-05-06 16:55:51 -07:00
Ethan Jackson
cc8d12f936 lacp: New "lacp-heartbeat" mode.
This commit creates a new heartbeat mode for LACP.  This mode
treats LACP as a protocol simply for monitoring link status.  It
strips out most of the sanity checks built into the protocol.
Addition of this mode makes "lacp-force-aggregatable" and
"lacp-strict" options obsolete so they are removed.
2011-05-06 13:48:41 -07:00
Ethan Jackson
632e2b95c9 bond: Create new "bond-stable-id".
Stable bonding mode needs an ID to guarantee consistent slave
selection decisions across ovs-vswitchd instances.  Before this
patch, we used the lacp-port-id for this purpose.  However, LACP
places restrictions on how lacp-port-ids can be allocated which may
be inconvenient.  This patch creates a special purpose
bond-stable-id other_config setting which allows users to tweak
this value directly.
2011-05-06 13:48:41 -07:00
Ethan Jackson
75135fa0b5 bond: Convert stb_id to 32bit parameter.
The 16 bits currently in use is artificially restrictive.
2011-05-06 13:48:41 -07:00
Justin Pettit
752f2093e1 xenserver: Better document scriplet action in RPM spec file. 2011-05-05 00:46:19 -07:00
Justin Pettit
daf2ebb30c xenserver: Use xe-switch-network-stack in RPM spec file.
The proper way to switch the networking back-end is to use the
"xe-switch-network-stack" command rather than directly modifying
"/etc/xensource/network.conf".  Use that method in the spec file.
2011-05-05 00:45:27 -07:00
Ben Pfaff
d93ca2a0fd ofp-util: Fix validation of OFPAT_SET_VLAN_PCP actions.
Found by sparse.
2011-05-04 15:47:27 -07:00
Ben Pfaff
946350dce6 DESIGN: Move in-band control design discussion here.
It seems more likely that interested users and administrators will be able
to find it here.
2011-05-04 13:46:21 -07:00
Ben Pfaff
2ba7924fd6 ovs-tcpundump: Document that ovs-appctl sends ofproto/trace command.
Suggested-by: Reid Price <reid@nicira.com>
Bug #5538.
2011-05-04 09:58:30 -07:00
Ben Pfaff
49b2c2d00e xenserver: Don't remove network.dbcache on uninstall.
network.dbcache was introduced by Open vSwitch for its own purposes, but
it has now migrated into the base install of XenServer, which uses it
whether Open vSwitch is installed or not, so we should no longer remove it
on package uninstall.

Signed-off-by: Ben Pfaff <blp@nicira.com>
Reported-by: Bob Ball <bob.ball@citrix.com>
2011-05-04 09:37:21 -07:00
Ben Pfaff
a16a9d0392 ovs-brcompatd: Document bug.
Reported-by: Gregor Schaffrath <grsch@net.t-labs.tu-berlin.de>
2011-05-04 09:36:50 -07:00
Ben Pfaff
6741622072 xenserver: Use .../extra not .../kernel/extra for kernel modules.
On XenServer, depmod.conf causes modules in /lib/modules/$(uname -r)/extra
to take priority over standard modules.  Unfortunately, we were installing
our modules in /lib/modules/$(uname -r)/kernel/extra, which isn't special.
This commit fixes the problem.

Signed-off-by: Ben Pfaff <blp@nicira.com>
Reported-by: Bob Ball <bob.ball@citrix.com>
2011-05-03 11:27:17 -07:00
Ethan Jackson
002c42961c vswitchd: Update schema version number.
Quite a few changes to LACP and bonding have gone in recently which
allowed additional other_config parameters on ports and interfaces.
These changes should have updated the vswitch.ovsschema version
number.

Requested-by: Jeremy Stribling <strib@nicira.com>
2011-05-02 16:35:07 -07:00
Ben Pfaff
032aa6a354 ovs-dpctl: Add -s option to print packet and byte counters. 2011-05-02 09:33:12 -07:00
Ben Pfaff
d39808227b netdev-linux: New functions for converting netdev stats formats.
An upcoming commit will introduce another function that needs to convert
between rtnl_link_stats64 and netdev_stats, so it seemed best to just add
functions to do the conversion.
2011-05-02 09:33:12 -07:00
Andrew Evans
dc432c2e81 tunneling: Add DF inherit and default flags to set of public tunnel flags.
Signed-off-by: Andrew Evans <aevans@nicira.com>
Acked-by: Jesse Gross <jesse@nicira.com>
2011-05-01 10:18:45 -07:00
Andrew Evans
66409d1bcc tunneling: Add df_default and df_inherit tunnel options.
Split existing pmtud tunnel option's functionality into three. Existing pmtud
option still exists, but now governs only whether datapath sends ICMP frag
needed messages. New df_inherit option controls whether DF bit is copied from
packet inner header to outer tunnel header. New df_default option controls
whether DF bit is set if inner packet isn't IP or if df_inherit is disabled.

Suggested-by: Jesse Gross <jesse@nicira.com>
Signed-off-by: Andrew Evans <aevans@nicira.com>
Feature #5456.
2011-04-29 17:05:58 -07:00
Ethan Jackson
8522b38386 dpif-linux: Recycle leaked ports.
When ports are deleted from the datapath they need to be added to
an LRU list maintained in dpif-linux so they may be reallocated.
When using vswitchd to delete the ports this happens automatically.
However, if a port is deleted directly from the datapath it is
never reclaimed by dpif-linux.  If this happens often, eventually
no ports will be available for allocation and dpif-linux will fall
back to using the old, kernel implemented, allocation strategy.

This commit fixes the problem by automatically reclaiming ports
missing from the datapath whenever the list of ports in the
datapath is dumped.

Bug #2140.
2011-04-29 16:06:31 -07:00