sliver-openvswitch.git
13 years agoofproto-dpif: Get rid of effectively unused 'check_special' flag.
Ben Pfaff [Wed, 11 May 2011 18:03:25 +0000 (11:03 -0700)]
ofproto-dpif: Get rid of effectively unused 'check_special' flag.

Nothing ever sets this flag to false any longer, so there's no need to
store it or test its value.

Reported-by: Ethan Jackson <ethan@nicira.com>
13 years agoImplement basic multiple table support.
Ben Pfaff [Thu, 12 May 2011 16:58:01 +0000 (09:58 -0700)]
Implement basic multiple table support.

This implements basic multiple table support in ofproto and supporting
libraries and utilities. The design is the same as the one that has been
on the Open vSwitch "wdp" branch for a long time.  There is no support for
multiple tables in the software switch implementation (ofproto-dpif), only
a set of hooks for other switch implementations to use.

To allow controllers to add flows in a particular table, Open vSwitch adds
an OpenFlow 1.0 extension called NXT_FLOW_MOD_TABLE_ID.

13 years agoofproto: Drop ofproto_rule_lookup().
Ben Pfaff [Tue, 26 Apr 2011 21:25:00 +0000 (14:25 -0700)]
ofproto: Drop ofproto_rule_lookup().

There's no reason not to implement this trivial function in ofproto-dpif,
especially since it makes less sense once multiple table support is
implemented (which table should be searched?).

13 years agoPORTING: Describe usage of ovs_be<N>.
Ben Pfaff [Wed, 27 Apr 2011 19:20:01 +0000 (12:20 -0700)]
PORTING: Describe usage of ovs_be<N>.

13 years agoofproto: Fix number of reported tables in OFPT_FEATURES_REPLY message.
Ben Pfaff [Wed, 27 Apr 2011 18:29:50 +0000 (11:29 -0700)]
ofproto: Fix number of reported tables in OFPT_FEATURES_REPLY message.

This has been wrong for a long time.

13 years agoofproto: Make rule construction and destruction more symmetric.
Ben Pfaff [Wed, 11 May 2011 21:06:48 +0000 (14:06 -0700)]
ofproto: Make rule construction and destruction more symmetric.

Before, ->rule_construct() both created the rule and inserted into the
flow table, but ->rule_destruct() only destroyed the rule.  This makes
->rule_destruct() also remove the rule from the flow table.

13 years agoclassifier: Remove OF1.0 special case from classifier_find_rule_exactly().
Ben Pfaff [Tue, 26 Apr 2011 20:09:24 +0000 (13:09 -0700)]
classifier: Remove OF1.0 special case from classifier_find_rule_exactly().

This special case should never have actually triggered in practice, because
OpenFlow 1.0 cannot set up an exact-match rule as defined by
flow_wildcards_is_exact().  (OpenFlow 1.0 will always, for example,
wildcard all NXM registers.)

OVS implements this OF1.0 special case differently, by changing flow
priority to 65535 in cls_rule_from_match() if the flow is an exact match as
defined by OpenFlow 1.0.

13 years agoofproto: Remove unused coverage counters.
Ben Pfaff [Tue, 26 Apr 2011 19:47:39 +0000 (12:47 -0700)]
ofproto: Remove unused coverage counters.

These were mostly moved into ofproto-dpif.c, but the definitions weren't
deleted along with them.

13 years agoofproto: Update some comments.
Ben Pfaff [Wed, 11 May 2011 19:15:46 +0000 (12:15 -0700)]
ofproto: Update some comments.

13 years agoofproto: Eliminate reference to dpif_upcall from ofproto.
Ben Pfaff [Tue, 26 Apr 2011 19:31:12 +0000 (12:31 -0700)]
ofproto: Eliminate reference to dpif_upcall from ofproto.

The dpif_upcall structure is specific to the ofproto-dpif implementation.
The generic ofproto and connmgr interface have no business using it, so
this commit switches to using ofputil_packet_in instead.

13 years agoRemove unneeded #include directives.
Ben Pfaff [Tue, 26 Apr 2011 18:39:10 +0000 (11:39 -0700)]
Remove unneeded #include directives.

13 years agoofproto: Better document the ofproto_class interface.
Ben Pfaff [Tue, 26 Apr 2011 18:30:46 +0000 (11:30 -0700)]
ofproto: Better document the ofproto_class interface.

Also, make a few minor adjustments to the interface so that it makes a
little more sense.

13 years agoofproto: Break apart into generic and hardware-specific parts.
Ben Pfaff [Wed, 11 May 2011 19:13:10 +0000 (12:13 -0700)]
ofproto: Break apart into generic and hardware-specific parts.

In addition to the changes to ofproto, this commit changes all of the
instances of "struct flow" in the tree so that the "in_port" member is an
OpenFlow port number.  Previously, this member was an OpenFlow port number
in some cases and an ODP port number in other cases.

13 years agoofproto: Complete abstraction by adding enumeration and deletion functions.
Ben Pfaff [Mon, 9 May 2011 16:33:02 +0000 (09:33 -0700)]
ofproto: Complete abstraction by adding enumeration and deletion functions.

This eliminates the final reference from bridge.c directly into the dpif
layer, which will make it easier to change the implementation of ofproto
to support other lower layers.

13 years agoofproto: Improve abstraction by using OpenFlow port numbers in interface.
Ben Pfaff [Mon, 9 May 2011 16:24:39 +0000 (09:24 -0700)]
ofproto: Improve abstraction by using OpenFlow port numbers in interface.

Until now, ofproto has used a mix of datapath and OpenFlow port numbers in
its client interface.  This commit changes it to use OpenFlow port numbers
exclusively, to raise the level of abstraction.

Most of this commit boils down to simple search-and-replace with a few
call to ofp_port_to_odp_port() sprinkled in.  The addition of ofproto_port
is one exception.  An ofproto_port is almost the same as a dpif_port; the
difference is just that its port number is an OpenFlow port number instead
of a datapath port number.

13 years agoofproto: Improve abstraction by adding function ofproto_parse_name().
Ben Pfaff [Mon, 11 Apr 2011 22:08:19 +0000 (15:08 -0700)]
ofproto: Improve abstraction by adding function ofproto_parse_name().

This means that ovs-ofctl and ovs-openflowd don't have to use the dpif
layer at all, making it easier to change the ofproto implementation.

13 years agodpif: Make dp_parse_name() normalize its returned type.
Ben Pfaff [Mon, 11 Apr 2011 22:07:07 +0000 (15:07 -0700)]
dpif: Make dp_parse_name() normalize its returned type.

This means that callers don't have to be concerned with a NULL return value
or unnormalized type.

13 years agodpif: Improve abstraction by making 'run' and 'wait' functions per-dpif.
Ben Pfaff [Fri, 6 May 2011 22:04:29 +0000 (15:04 -0700)]
dpif: Improve abstraction by making 'run' and 'wait' functions per-dpif.

Until now, the dp_run() and dp_wait() functions had to be called at the top
level of the program because they applied to every open dpif.  By replacing
them by functions that take a specific dpif as an argument, we can call
them only from ofproto, which is currently the correct layer to deal with
dpifs.

13 years agobridge: Move packet processing functionality into ofproto.
Ben Pfaff [Wed, 11 May 2011 19:26:06 +0000 (12:26 -0700)]
bridge: Move packet processing functionality into ofproto.

Until now, packet processing in ovs-vswitchd has been split between two
components: ofproto, for basic OpenFlow functionality, and bridge, for
OFPP_NORMAL processing.  This architecture will not work as Open vSwitch
starts to support a wider variety of underlying hardware, because it
imposes a model in which the bridge needs to be able to look at every
exact-match flow within a OpenFlow flow, which most hardware doesn't
support.

Therefore, this commit moves all of the packet processing code in
bridge into ofproto, as preparation for generalizing further.

13 years agoofproto: Update ports immediately upon ofproto_port_add() too.
Ben Pfaff [Wed, 20 Apr 2011 22:22:26 +0000 (15:22 -0700)]
ofproto: Update ports immediately upon ofproto_port_add() too.

I don't see a reason to defer this.

13 years agoofproto: Add a pointer to the owning ofproto to struct ofport.
Ben Pfaff [Wed, 4 May 2011 17:38:27 +0000 (10:38 -0700)]
ofproto: Add a pointer to the owning ofproto to struct ofport.

This streamlines a few function calling interfaces.

13 years agoofproto: Initialize ports immediately upon ofproto creation.
Ben Pfaff [Wed, 20 Apr 2011 22:13:46 +0000 (15:13 -0700)]
ofproto: Initialize ports immediately upon ofproto creation.

I don't see why we should delay initializing the ports to the first call
of ofproto_run1().  We originally did initialize the ports in
ofproto_create(), but back in January 2010 Jesse moved the call into
ofproto_run1() in commit 149f577a "netdev: Fully handle netdev lifecycle
through refcounting."  The commit message doesn't explain why this
particular change was made, so I can only assume that it was important at
the time.  Now, however, everything seems to work fine with initialization
done in the most logical place.

13 years agodpif: Better log unusual errors in dpif_port_query_by_name().
Ben Pfaff [Thu, 7 Apr 2011 21:43:14 +0000 (14:43 -0700)]
dpif: Better log unusual errors in dpif_port_query_by_name().

Logging these unusual errors at a low level means that we can remove a
bit of higher-level code from ofproto.

The ofproto change also changes behavior for these error cases, from doing
nothing to removing the port, but I think that's OK.  I've never noticed
this log message.

13 years agohmapx: New data structure.
Ben Pfaff [Fri, 8 Apr 2011 00:10:48 +0000 (17:10 -0700)]
hmapx: New data structure.

13 years agobond: New function bond_slave_set_netdev().
Ben Pfaff [Wed, 4 May 2011 17:26:58 +0000 (10:26 -0700)]
bond: New function bond_slave_set_netdev().

To be used by an upcoming change.

13 years agoofproto: Add 'name' field to struct ofproto and use hmap instead of shash.
Ben Pfaff [Fri, 8 Apr 2011 19:35:38 +0000 (12:35 -0700)]
ofproto: Add 'name' field to struct ofproto and use hmap instead of shash.

It's slightly inconvenient to call into dpif_name() just to get the name
of an ofproto.  Furthermore, we're already keeping a copy of the ofproto's
name around, in the 'name' field of its shash_node.  It seems easier all
around if we just keep the name right in the struct ofproto and use an
hmap instead of a shash.

13 years agoofproto: Rename ofproto_iface_*() functions to ofproto_port_*().
Ben Pfaff [Tue, 5 Apr 2011 23:34:09 +0000 (16:34 -0700)]
ofproto: Rename ofproto_iface_*() functions to ofproto_port_*().

This makes ofproto use the term "port" consistently for a single
purpose (which is unfortunately different from the term "interface"
used in the OVS database, but at least it is now internally
consistent).

13 years agoofproto: Move private definitions to separate header.
Ben Pfaff [Thu, 14 Apr 2011 20:16:47 +0000 (13:16 -0700)]
ofproto: Move private definitions to separate header.

13 years agobridge: Reorder configuration.
Ben Pfaff [Fri, 8 Apr 2011 20:50:21 +0000 (13:50 -0700)]
bridge: Reorder configuration.

This loses the bridge_run_one() before iface_configure_cfm(), which means
that CFM configuration can now take two reconfigurations in a row.  That's
a regression that we had earlier, which had been fixed previously by commit
392730c42bb "bridge: Run once before configuring CFM".  It will, however,
be fixed again in a later commit.

13 years agodpif: New function dpif_normalize_type().
Ben Pfaff [Tue, 5 Apr 2011 19:52:58 +0000 (12:52 -0700)]
dpif: New function dpif_normalize_type().

This allows dpif types to be compared.

13 years agobridge: Factor code out of bridge_reconfigure().
Ben Pfaff [Wed, 4 May 2011 17:20:04 +0000 (10:20 -0700)]
bridge: Factor code out of bridge_reconfigure().

This is almost entirely code motion.  I only made minor style changes as
I moved code around.

13 years agobridge: Get rid of bridge_get_all_ifaces(), bridge_fetch_dp_ifaces().
Ben Pfaff [Wed, 4 May 2011 17:18:23 +0000 (10:18 -0700)]
bridge: Get rid of bridge_get_all_ifaces(), bridge_fetch_dp_ifaces().

The bridge_get_all_ifaces() function is rather odd.  It creates an shash
index over the "struct iface"s within a bridge, but there's already an
index over them (the 'iface_by_name' hmap in struct bridge) that the
iface_lookup() function searches.  The only value it adds is to put the
names of bond fake ifaces into the index, but that's hardly worth it.  We
can just search the existing hash table as needed, instead.

The bridge_fetch_dp_ifaces() function is also odd.  It fetches the entire
mapping from port number to name from the dpif again, although this has
already been done twice already.  We can just merge this in with the second
iteration.

This commit makes both of those changes.

13 years agobridge: Change all_bridges from list to hmap (indexed by name).
Ben Pfaff [Mon, 4 Apr 2011 21:11:16 +0000 (14:11 -0700)]
bridge: Change all_bridges from list to hmap (indexed by name).

This is more convenient for looking up a bridge by name.  That makes
reconfiguration a little bit simpler, because there is no longer a need to
build a temporary index of existing bridges.  I don't see any downsides.

13 years agobridge: Eliminate direct dependencies on dpif.
Ben Pfaff [Wed, 4 May 2011 17:15:31 +0000 (10:15 -0700)]
bridge: Eliminate direct dependencies on dpif.

The 'ofp_portp' argument of the new function ofproto_port_add() is always
set to NULL in this commit, but a future commit will use nonnull values.

13 years agobridge: Change 'iface_by_name' from shash to hmap.
Ben Pfaff [Fri, 1 Apr 2011 18:42:25 +0000 (11:42 -0700)]
bridge: Change 'iface_by_name' from shash to hmap.

This avoids having duplicate copies of interface names (inside the shash)
and it isn't any harder to work with.

13 years agoConvert remaining network-byte-order "uint<N>_t"s into "ovs_be<N>"s.
Ben Pfaff [Tue, 29 Mar 2011 21:42:20 +0000 (14:42 -0700)]
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.

13 years agoofproto: Maintain ofp_phy_port for each ofport in network byte order.
Ben Pfaff [Tue, 29 Mar 2011 21:11:39 +0000 (14:11 -0700)]
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.

13 years agoofproto: Group struct cfm forward declaration with the rest of them.
Ben Pfaff [Tue, 29 Mar 2011 20:10:34 +0000 (13:10 -0700)]
ofproto: Group struct cfm forward declaration with the rest of them.

13 years agoofproto: Make ofproto_send_packet() static.
Ben Pfaff [Thu, 14 Apr 2011 20:17:09 +0000 (13:17 -0700)]
ofproto: Make ofproto_send_packet() static.

It's not used outside of ofproto.c any longer.

13 years agobridge: Use bridge name, instead of dpif name, in log messages.
Ben Pfaff [Tue, 29 Mar 2011 19:23:06 +0000 (12:23 -0700)]
bridge: Use bridge name, instead of dpif name, in log messages.

This reduces the number of direct references to the dpif, which
future commits will eliminate from the bridge code.

13 years agobridge: Inline iterate_and_prune_ifaces() and remove it.
Ben Pfaff [Tue, 29 Mar 2011 18:32:25 +0000 (11:32 -0700)]
bridge: Inline iterate_and_prune_ifaces() and remove it.

The main reason that iterate_and_prune_ifaces() existed was because it was
somewhat inconvenient to iterate across all of the interfaces, especially
if anything needed to be deleted.  Now that we've switched from arrays to
lists and hmaps, it's a bit easier, and certainly it's easier to read code
when there aren't any callbacks involved, so inline what this was doing.

This was the only remaining caller of iterate_and_prune_ifaces() so this
removes that function as well as the callback.

13 years agobridge: Avoid extra iteration through all "struct iface"s.
Ben Pfaff [Wed, 4 May 2011 17:12:03 +0000 (10:12 -0700)]
bridge: Avoid extra iteration through all "struct iface"s.

There's no reason to do these separately as far as I can see.

13 years agomac-learning: Avoid unnecessary call to free().
Ben Pfaff [Fri, 8 Apr 2011 20:19:56 +0000 (13:19 -0700)]
mac-learning: Avoid unnecessary call to free().

13 years agomac-learning: Change mac_learning_set_flood_vlans() to not take ownership.
Ben Pfaff [Wed, 6 Apr 2011 22:31:22 +0000 (15:31 -0700)]
mac-learning: Change mac_learning_set_flood_vlans() to not take ownership.

These new semantics are less efficient in the case where the flood_vlans
actually changed, but that should be very rare.

There are no advantages to this change on its own, but upcoming commits
will add multiple layers between the code supplying the flood_vlans and
actually calling mac_learning_set_flood_vlans().  Consistency in this
multilayered interface seems valuable, and the rest of it does not transfer
ownership from the caller to the callee.

13 years agovlan-bitmap: New data structure.
Ben Pfaff [Fri, 8 Apr 2011 20:19:33 +0000 (13:19 -0700)]
vlan-bitmap: New data structure.

13 years agobridge: Move logic for flushing flows and standalone mode into connmgr.
Ben Pfaff [Fri, 8 Apr 2011 20:44:38 +0000 (13:44 -0700)]
bridge: Move logic for flushing flows and standalone mode into connmgr.

This improves the abstraction behind ofproto and connmgr.

Some of this could even go into fail_open, but I'm not sure that it would
make anything easier to understand.

13 years agoovs-controller: Honor --wildcard option.
Ben Pfaff [Tue, 26 Apr 2011 00:08:09 +0000 (17:08 -0700)]
ovs-controller: Honor --wildcard option.

This option was documented but ignored.

13 years agotests: Add ovs-openflowd to programs that need valgrind wrappers.
Ben Pfaff [Thu, 21 Apr 2011 23:38:05 +0000 (16:38 -0700)]
tests: Add ovs-openflowd to programs that need valgrind wrappers.

The tests run ovs-openflowd so "make check-valgrind" should run it under
valgrind.

13 years agobridge: Remove slaves from the bond before closing their netdevs.
Ben Pfaff [Thu, 21 Apr 2011 23:37:38 +0000 (16:37 -0700)]
bridge: Remove slaves from the bond before closing their netdevs.

A bond slave has a pointer to its iface's netdev, so we don't want it to
keep that pointer after the bridge closes the netdev.

This is becoming a bit of a mess so perhaps we need reference counting for
netdevs (although Jesse didn't like the idea when I proposed it before).

13 years agobond: Be more careful about adding and removing netdevs in the monitor.
Ben Pfaff [Thu, 21 Apr 2011 23:34:51 +0000 (16:34 -0700)]
bond: Be more careful about adding and removing netdevs in the monitor.

The code was careless about updating the netdev_monitor.  Newly added
slaves weren't added to the monitor until the next bond_reconfigure() call,
and netdevs were never removed from the monitor.

13 years agoofproto: Adjust netdev_monitor when switching netdevs.
Ben Pfaff [Thu, 21 Apr 2011 23:25:41 +0000 (16:25 -0700)]
ofproto: Adjust netdev_monitor when switching netdevs.

This fixes a segfault in the "ofproto - mod-port" test.  The segfault
should not occur--there must be a bug in the netdev_monitor or possibly
the netdev_dummy implementation--but the netdev_monitor_remove() and
netdev_monitor_add() calls are definitely wanted here in any case to ensure
that the new netdev, not the old one, is what gets monitored.

13 years agobridge: Tolerate missing Port and Interface records for local port.
Ben Pfaff [Wed, 13 Apr 2011 18:10:44 +0000 (11:10 -0700)]
bridge: Tolerate missing Port and Interface records for local port.

Until now, ovs-vswitchd has been unable to configure IP addresses and
routes for bridges whose Bridge records lack a Port and an Interface
record for the bridge's local port (e.g. OFPP_LOCAL, the port with the
same name as the bridge itself).  When such a bridge was reconfigured,
ovs-vswitchd would output a log message that worried people.

This commit fixes the internal limitation that led to the message being
printed.

Bug #5385.

13 years agoofproto: Rework and fix bugs in port change detection.
Ben Pfaff [Wed, 20 Apr 2011 20:48:11 +0000 (13:48 -0700)]
ofproto: Rework and fix bugs in port change detection.

The OpenFlow port change detection code in update_port() is supposed to
send out an OFPT_PORT_STATUS message whenever an OpenFlow port is added or
removed or changes in some way.  This commit fixes a number of bugs that
have persisted until now.

First, if a port with a given name is removed from the datapath and a new
port with the same name but a different port number is added to the
datapath, then update_port() would report this as a port "modify" change.
Reporting this as a "modify" seems likely to confuse controllers, which
have no reason to realize that the old port was deleted and may not
understand why a port that has not been reported as added would be
modified.  (This scenario is more likely than before, because the Linux
datapath implementation no longer quickly reuses port numbers.  This
problem has actually been reported in testing.)  This commit fixes the
problem by changing update_port() to report a "delete" of the old port
followed by an "add" of the new port.

Second, suppose that a datapath initially has "eth1" on port 1 and "eth2"
on port 2.  Then, "eth1" gets removed and "eth2" is reassigned to port 1.
If update_port() is first passed "eth2", then the old implementation would
have sent out an OpenFlow "modify" notification instead of "delete"
followed by "add", which is the same as the previous scenario.  But as a
further wrinkle, it would have failed to remove "eth1", which meant that we
ended up with two "ofports" with port number 1!  This commit fixes this
problem too.

Reported-by: David Tsai <dtsai@nicira.com>
Bug #5466.
NIC-372.

13 years agoofproto: Consistently use netdev's name instead of ofp_phy_port name.
Ben Pfaff [Wed, 20 Apr 2011 20:03:45 +0000 (13:03 -0700)]
ofproto: Consistently use netdev's name instead of ofp_phy_port name.

There are at least two ways to get an ofport's name: from the netdev using
netdev_get_name() or from the ofp_phy_port's 'name' member.  Some code used
one, some used the other.  This switches all relevant code to use only
netdev_get_name(), because the 'name' member in ofp_phy_port is
fixed-length and thus a long name could be truncated.

This isn't a problem under Linux since the maximum length of a network
device's name under Linux is the same as the field width in ofp_phy_port.

13 years agosocket-util: Use portable solution for setting Unix socket permissions.
Ben Pfaff [Thu, 21 Apr 2011 16:22:39 +0000 (09:22 -0700)]
socket-util: Use portable solution for setting Unix socket permissions.

Requested-by: Jesse Gross <jesse@nicira.com>
13 years agobond: BM_STABLE consistent hashing.
Ethan Jackson [Wed, 20 Apr 2011 22:53:58 +0000 (15:53 -0700)]
bond: BM_STABLE consistent hashing.

This patch converts stable bonds from modulo n based hashing to
Highest Random Weight based hashing.  This hashing strategy only
redistributes 1/n_slaves traffic when a slave is enabled or
disabled.  It also turns out to have a vastly simpler
implementation.

13 years agobond: New flag "bond_revalidate".
Ethan Jackson [Wed, 20 Apr 2011 23:01:28 +0000 (16:01 -0700)]
bond: New flag "bond_revalidate".

Used in future patches.

13 years agoINSTALL.Linux: Mention that SSL options require building with SSL support.
Ben Pfaff [Fri, 8 Apr 2011 19:40:49 +0000 (12:40 -0700)]
INSTALL.Linux: Mention that SSL options require building with SSL support.

Reported-by: Aaron Rosen <arosen@clemson.edu>
13 years agobond: Revalidate no_slaves_tag when revalidating everything.
Ethan Jackson [Wed, 20 Apr 2011 01:02:53 +0000 (18:02 -0700)]
bond: Revalidate no_slaves_tag when revalidating everything.

13 years agobond: Give stable bonds one tag.
Ethan Jackson [Wed, 20 Apr 2011 00:19:25 +0000 (17:19 -0700)]
bond: Give stable bonds one tag.

Stable bonds require all flows to be revalidated when anything
changes.  Instead of giving each slave a tag, and ORing them
together.  This commit creates one tag representing the entire
bond.  This will cause less false positives when deciding which
flows to revalidate.

13 years agobridge: Avoid memory leak from RSPAN mirrors in bridge_destroy().
Ben Pfaff [Mon, 11 Apr 2011 18:22:39 +0000 (11:22 -0700)]
bridge: Avoid memory leak from RSPAN mirrors in bridge_destroy().

Mirrors that output to ports will be destroyed when their output ports are
destroyed, but mirrors that output to VLANs ("RSPAN" mirrors) don't get
automatically destroyed like this and we need to take care of them in a
separate loop.

13 years agobond: bond_stb_enable_slave() never triggered.
Ethan Jackson [Tue, 19 Apr 2011 21:11:23 +0000 (14:11 -0700)]
bond: bond_stb_enable_slave() never triggered.

bond_stb_enable_slave() depended on bond->stb_slaves being
nonnull.  However, bond_stb_enable_slave() is responsible for
initializing this parameter.  Thus none of it's logic ever ran.

13 years agolacp: Implement custom timing mode.
Ethan Jackson [Mon, 18 Apr 2011 19:22:12 +0000 (12:22 -0700)]
lacp: Implement custom timing mode.

With this patch, the LACP module may be manually configured to use
an arbitrary transmission rate set in the database.

13 years agolacp: Remove LACP_[FAST|SLOW]_TIME_RX macros.
Ethan Jackson [Mon, 18 Apr 2011 19:48:59 +0000 (12:48 -0700)]
lacp: Remove LACP_[FAST|SLOW]_TIME_RX macros.

The receive rate for a LACP packets is simply 3 times the
transmission rate.  It doesn't make sense to maintain separate
macros for these values especially since future patches will allow
arbitrary transmission rates.

13 years agolacp: Move LACP packet data to lacp header file.
Ethan Jackson [Mon, 18 Apr 2011 19:33:14 +0000 (12:33 -0700)]
lacp: Move LACP packet data to lacp header file.

13 years agoofp-util: Properly handle "tun_id"s in tun_id_from_cookie flows.
Ben Pfaff [Mon, 18 Apr 2011 17:11:43 +0000 (10:11 -0700)]
ofp-util: Properly handle "tun_id"s in tun_id_from_cookie flows.

Just setting the tun_id field isn't enough--it's also necessary to set
the tun_id_mask.  Otherwise the call to cls_rule_zero_wildcarded_fields()
at the end of ofputil_cls_rule_from_match() will zero out the tun_id again.

This was broken by commit 8368c090cab "Implement arbitrary bitwise masks
for tun_id field" back in January.  (This makes me wonder whether we can
drop support for tun_id_from_cookie now.)

Reported-by: Dan Wendlandt <dan@nicira.com>
13 years agosocket-util: Properly set socket permissions in make_unix_socket().
Ben Pfaff [Mon, 18 Apr 2011 18:24:50 +0000 (11:24 -0700)]
socket-util: Properly set socket permissions in make_unix_socket().

Under Linux, at least, bind and fchmod interact for Unix sockets in a way
that surprised me.  Calling fchmod() on a Unix socket successfully sets the
permissions for the socket's own inode.  But that has no effect on any
inode that has already been created in the file system by bind(), because
that inode is not the same as the one for the Unix socket itself.

However, if you bind() *after* calling fchmod(), then the bind() takes the
permissions for the new inode from the Unix socket inode, which has the
desired effect.

This also adds a more portable fallback for non-Linux systems.

Reported-by: YAMAMOTO Takashi <yamamoto@valinux.co.jp>
13 years agobridge: LACP port ID and system ID in database.
Ethan Jackson [Sat, 16 Apr 2011 00:03:37 +0000 (17:03 -0700)]
bridge: LACP port ID and system ID in database.

Extremely advanced users may want fine grained control over the
LACP port and system IDs of a bond.  This would be extremely
unusual for the average user, so this patch puts the configuration
parameters in other_config of the relevant tables.

13 years agolacp: New "strict" lacp mode.
Ethan Jackson [Mon, 18 Apr 2011 22:13:34 +0000 (15:13 -0700)]
lacp: New "strict" lacp mode.

When LACP negotiations are unsuccessful, OVS falls back to standard
balance-slb bonding.  In some cases, users may want to require
successful LACP negotiations for any slaves to be enabled at all.
This patch implements a new "strict" mode which disables all slaves
when LACP negotiations are unsuccessful.

13 years agolacp: Update attached status more often.
Ethan Jackson [Mon, 18 Apr 2011 22:32:30 +0000 (15:32 -0700)]
lacp: Update attached status more often.

The attached status of slaves should be updated when certain global
configuration settings change, or when a slave is destroyed.

13 years agovlog: Fix VLOG and VLOG_RL macros' treatment of LEVEL argument.
Ben Pfaff [Thu, 7 Apr 2011 21:39:36 +0000 (14:39 -0700)]
vlog: Fix VLOG and VLOG_RL macros' treatment of LEVEL argument.

These macros expanded the LEVEL argument without protecting it with
parentheses, which meant that an argument like 'cond ? VLL_DBG : VLL_WARN'
did not have the desired effect (and caused a GCC warning).

This commit fixes the problem and avoids expanding LEVEL more than once,
too.

13 years agobridge: Fix VLAN selection mirroring logic.
Ben Pfaff [Fri, 8 Apr 2011 19:52:23 +0000 (12:52 -0700)]
bridge: Fix VLAN selection mirroring logic.

The logic here did not make sense.  A packet arriving on a port is mirrored
if the port is a mirroring source port AND (not OR) the packet is in one of
the VLANs that is mirrored.

This test has been here since the mirroring code was introduced.  It seems
to me that it was never correct.

13 years agobridge: Reintroduce log message that was lost (and wrong).
Ben Pfaff [Tue, 29 Mar 2011 18:16:31 +0000 (11:16 -0700)]
bridge: Reintroduce log message that was lost (and wrong).

Setting the 'mac' in the Interface record for a bridge's local port has
always been ineffective, but the log message was suppressed because of a
check at too high of a level.  This commit fixes the problem.  It also
fixes the wording of the log message, which has been obsolete since the
introduction of the database.

Finally, it seems better to check for the local port before checking for a
multicast address, so this reverses the order of the checks.

13 years agodaemon: Reduce log level of "pid file is stale" message.
Ben Pfaff [Tue, 5 Apr 2011 19:17:08 +0000 (12:17 -0700)]
daemon: Reduce log level of "pid file is stale" message.

This message will appear repeatedly when ovs-vswitchd is running, if there
is any stale pidfile in /var/run/openvswitch, because ovs-vswitchd reads
all of the pidfiles in that directory periodically to update statistics.

13 years agobridge: Initialize mirrors' uuid member.
Ben Pfaff [Tue, 5 Apr 2011 21:17:55 +0000 (14:17 -0700)]
bridge: Initialize mirrors' uuid member.

Otherwise mirrors get destroyed and re-created on every reconfiguration.

13 years agoofproto: Avoid memory leak in classifier on destruction.
Ben Pfaff [Tue, 5 Apr 2011 22:58:06 +0000 (15:58 -0700)]
ofproto: Avoid memory leak in classifier on destruction.

ofproto_flush_flows() flushes the flow table but then it reintroduces flows
required by fail-open or in-band.  These are then leaked when the
classifier is destroyed a little later.

This fixes the problem by not reintroducing these flows when ofproto is
being destroyed.

13 years agobond: Fix ugly warnings at slave registration.
Ethan Jackson [Mon, 18 Apr 2011 23:17:46 +0000 (16:17 -0700)]
bond: Fix ugly warnings at slave registration.

Before this patch, when a slave was registered for this first time
the following warning would display.

interface (null): enabled

This is because the slave was enabled before having its name
configured.

13 years agobond: Properly indent appctl output.
Ethan Jackson [Mon, 18 Apr 2011 23:14:58 +0000 (16:14 -0700)]
bond: Properly indent appctl output.

13 years agobridge: Report lacp_slave_is_current() in the database.
Ethan Jackson [Wed, 13 Apr 2011 23:06:50 +0000 (16:06 -0700)]
bridge: Report lacp_slave_is_current() in the database.

Whether or not a given slave is current with its LACP protocol
messages can be very interesting to a controller.  If an interface
is not current, it usually indicates a connectivity problem or
misconfiguration of some sort.

13 years agobridge: Generalize CFM rate limiter.
Ethan Jackson [Fri, 15 Apr 2011 19:57:30 +0000 (12:57 -0700)]
bridge: Generalize CFM rate limiter.

In future patches, lacp status will need to be written to the
database in a rate limited manner.  It doesn't make sense to run
two parallel rate limiters.  This patch renames the CFM rate
limiter to something more generic.

13 years agolacp: New function lacp_slave_is_current().
Ethan Jackson [Wed, 13 Apr 2011 22:44:37 +0000 (15:44 -0700)]
lacp: New function lacp_slave_is_current().

Used in future patches.

13 years agobridge: Properly test for out-of-range values.
Ben Pfaff [Fri, 15 Apr 2011 16:40:50 +0000 (09:40 -0700)]
bridge: Properly test for out-of-range values.

This code was trying to check for priorities greater than UINT16_MAX and
reset them, but it assigned the value to a uint16_t before it checked it,
which of course hid the problem.

Fixes the following GCC warning:

vswitchd/bridge.c:3034: warning: comparison is always false due to limited
range of data type

Reported-by: YAMAMOTO Takashi <yamamoto@valinux.co.jp>
13 years agoAvoid warnings about comparisons that are always true.
Ben Pfaff [Fri, 15 Apr 2011 16:39:08 +0000 (09:39 -0700)]
Avoid warnings about comparisons that are always true.

The range of "enum" types varies from one ABI to another.  If the enums
being tested in these functions happen to be 16 bits wide, then GCC may
issue a warning because, in such a case, the comparison is always true.

Using an int instead of a uint16_t avoids that particular problem and
should suppress the warning.

Fixes the following reported warnings:

lib/ofp-print.c:240: warning: comparison is always true due to limited
range of data type
lib/ofp-util.c:1973: warning: comparison is always false due to limited
range of data type

Reported-by: YAMAMOTO Takashi <yamamoto@valinux.co.jp>
13 years agoFix calls to ctype functions.
Ben Pfaff [Fri, 15 Apr 2011 16:31:36 +0000 (09:31 -0700)]
Fix calls to ctype functions.

The ctype functions often need casts to be fully C standards compliant.
Here's the full explanation that I used to post to comp.lang.c from time
to time when the issue came up:

    With the to*() and is*() functions, you should be careful to cast
    `char' arguments to `unsigned char' before calling them.  Type `char'
    may be signed or unsigned, depending on your compiler or its
    configuration.  If `char' is signed, then some characters have
    negative values; however, the arguments to is*() and to*() functions
    must be nonnegative (or EOF).  Casting to `unsigned char' fixes this
    problem by forcing the character to the corresponding positive value.

This fixes the following warnings from some version of GCC:

lib/ofp-parse.c:828: warning: array subscript has type 'char'
lib/ofp-print.c:617: warning: array subscript has type 'char'

Reported-by: YAMAMOTO Takashi <yamamoto@valinux.co.jp>
13 years agobridge: Destroy bond when port is destroyed.
Ethan Jackson [Fri, 15 Apr 2011 18:06:02 +0000 (11:06 -0700)]
bridge: Destroy bond when port is destroyed.

13 years agobond: Completely pull LACP module out of bond.
Ethan Jackson [Thu, 14 Apr 2011 23:50:26 +0000 (16:50 -0700)]
bond: Completely pull LACP module out of bond.

The bonding code only needs to know whether a given slave may be
enabled, and whether LACP has been negotiated on the bond.  Instead
of passing in the LACP handle and letting the bond query this
information.  This patch passes in the information directly.

13 years agobond: Create new 'stable_id' parameter.
Ethan Jackson [Fri, 15 Apr 2011 00:37:29 +0000 (17:37 -0700)]
bond: Create new 'stable_id' parameter.

For BM_STABLE bonds, instead of choosing the sort key in the
qsort() comparator, this patch makes it a configuration setting of
each slave.  This will help wrest LACP out of the bonding code
further in future patches.

13 years agobond: Give bridge control over LACP module.
Ethan Jackson [Thu, 14 Apr 2011 00:58:26 +0000 (17:58 -0700)]
bond: Give bridge control over LACP module.

Before this patch, the bonding code had taken over responsibility
for running the LACP module.  However, the bonding code only needs
the LACP module for some basic status queries.  LACP and bonding
are actually logically parallel modules and do not really have a
parent child relationship.  Furthermore, we need to be able to run
LACP on non-bonded interfaces which the existing approach
prevented.  This patch gives control of the LACP module back to the
bridge.

13 years agolacp: Remove enabled flag.
Ethan Jackson [Thu, 14 Apr 2011 22:24:18 +0000 (15:24 -0700)]
lacp: Remove enabled flag.

The enabled flag in the LACP module was only used to set the
Collecting and Distributing flags in the LACP protocol.  It was
intended to be set by the bonding code to mimic its enabled flag.

The spec is relatively vague on the precise meaning of these flags,
and most implementations do something completely different with
them.  For these reasons, it seems acceptable to remove the enabled
flag for the sake of simplicity.  A slave is now Collecting and
Distributing if it is attached, or LACP couldn't be negotiated.

13 years agovswitchd: Document how to disable inactivity probes.
Ben Pfaff [Thu, 14 Apr 2011 17:22:21 +0000 (10:22 -0700)]
vswitchd: Document how to disable inactivity probes.

This has always been implemented but it was not documented until now.

Reported-by: Alex Yip <alex@nicira.com>
13 years agobond: New bonding mode "stable".
Ethan Jackson [Tue, 12 Apr 2011 21:15:46 +0000 (14:15 -0700)]
bond: New bonding mode "stable".

Stable bonds attempt to assign a given flow to the same slave
consistently.

13 years agobond: New function bond_is_balanced().
Ethan Jackson [Tue, 12 Apr 2011 20:39:32 +0000 (13:39 -0700)]
bond: New function bond_is_balanced().

As new bond modes are added, it will be nice to have the logic
indicating whether or not a given bond mode requires rebalancing in
one place.

13 years agolacp: New function lacp_slave_get_port_id().
Ethan Jackson [Wed, 13 Apr 2011 21:55:19 +0000 (14:55 -0700)]
lacp: New function lacp_slave_get_port_id().

Will be used in future commits.

13 years agobond: Use bond_enable_slave at slave registration.
Ethan Jackson [Tue, 12 Apr 2011 22:15:32 +0000 (15:15 -0700)]
bond: Use bond_enable_slave at slave registration.

Slave registration should go through the normal slave enabling
facilities instead of doing it by hand.  Before this patch, newly
created slaves would have no tag associated with them.
Furthermore, any further changes to how slaves are enabled would
not be picked up by the registration code.

13 years agobond: Reset bond_entry's during massive flow revalidations.
Ethan Jackson [Wed, 13 Apr 2011 20:56:37 +0000 (13:56 -0700)]
bond: Reset bond_entry's during massive flow revalidations.

When all flows in a bond are revalidated, stale bond_entry's can
cause incorrect load balancing.  These issues will naturally
resolve themselves overtime.  However, it's better to deal with
them immediately.

13 years agobond: Revalidate flows when bond_is_tcp_hash() changes;
Ethan Jackson [Wed, 13 Apr 2011 01:28:04 +0000 (18:28 -0700)]
bond: Revalidate flows when bond_is_tcp_hash() changes;

If LACP causes the return of bond_is_tcp_hash to change for
whatever reason, all flows should be revalidated because they will
have a different hash result.

13 years agobond: Reconfigure flows when bond mode changes.
Ethan Jackson [Wed, 13 Apr 2011 00:53:24 +0000 (17:53 -0700)]
bond: Reconfigure flows when bond mode changes.

Changes in the bonding mode can cause drastic changes in flow
assignments to slaves.  This commit causes all flows in a bridge
to be revalidated when bond_reconfigure() changes its bonding mode.
This approach is a bit aggressive, but bond reconfiguration
shouldn't happen often.

13 years agoconfigure: Add option --enable-Werror to add -Werror to CFLAGS.
Ben Pfaff [Tue, 12 Apr 2011 18:43:11 +0000 (11:43 -0700)]
configure: Add option --enable-Werror to add -Werror to CFLAGS.

-Werror is useful for development, but it screws up configure because it's
impossible to guess what new warnings compilers will add in the future.
This commit adds a new configure option to add CFLAGS after the configure
checks are done.

The use of AC_CONFIG_COMMANDS_PRE is based on Eric Blake's suggestion on
the autoconf mailing list: "AC_CONFIG_COMMANDS_PRE probably fits the bill
as the ideal macro to use for guaranteeing that you inject your shell code
at the last possible moment."

Requested-by: Andrew Evans <aevans@nicira.com>
13 years agoxenserver: Fix typo in RPM install message.
Ethan Jackson [Tue, 12 Apr 2011 20:20:13 +0000 (13:20 -0700)]
xenserver: Fix typo in RPM install message.

13 years agoxenserver: Don't openvswitch-xapi-update in bridge mode.
Ethan Jackson [Tue, 12 Apr 2011 01:33:06 +0000 (18:33 -0700)]
xenserver: Don't openvswitch-xapi-update in bridge mode.

This commit causes the init scripts not to call the
openvswitch-cfg-update plugin when in bridge mode.