Ben Pfaff [Wed, 21 Jan 2009 00:06:59 +0000 (16:06 -0800)]
process: Avoid stealing pclose()'s exit status.
When we use popen() and pclose(), pclose() wants to return the process's
exit status, but it can't if the SIGCHLD handler gets it first. So,
instead of asking for any child process exit status in sigchld_handler(),
only ask for the exit status of registered PIDs.
Keith Amidon [Tue, 13 Jan 2009 23:30:40 +0000 (15:30 -0800)]
Reopen log file in addition to reading conf file when vswitchd receives sighup
This only reopens the vswitchd log file. The child secchan processes
for each bridge are not requested to do the same thing. Since secchan
in general logs very little data, rotating those files isn't being
done right now, so this is probably okay. At some point we should
probably correct it however.
Ben Pfaff [Fri, 16 Jan 2009 18:37:13 +0000 (10:37 -0800)]
vswitchd: Reduce flow idle time when flow table grows large.
This change halves the number of steady-state flows in the flow table
for hping3 --faster --quiet, from over 5000 to less than 2500. It does
cause some oscillation in flow table size, because there is a harsh step
function in idle time when the flow table goes from 1000 to 1001 flows,
from 2001 to 2002 flows, and from 4003 to 4004 flows, but I doubt that is
a problem. (If it is, we can introduce some randomness.)
Ben Pfaff [Fri, 16 Jan 2009 18:23:51 +0000 (10:23 -0800)]
vswitchd: Don't reset idle timer when updating flows.
When a flow was revalidated, we would use a OFPFC_ADD flow_mod message to
change the flow's actions. However, this resets the idle-timer countdown.
In extreme circumstances, such as when VMs are being continuously migrated,
this meant that completely idle flows would never expire, because their
idle timers would keep getting reset more often than every 5 seconds, and
so the flow table would keep growing, never shrinking.
Now, when we revalidate an existing flow and update its actions, we use
an OFPFC_MODIFY_STRICT flow_mod message, which also updates actions but
does not reset the idle-timer countdown.
Ben Pfaff [Fri, 16 Jan 2009 18:11:04 +0000 (10:11 -0800)]
Revert "brcompat: Don't re-read configuration file from inside bridge code."
This reverts commit 2b34f542b1015b69c589bc4fa324d236cd35dd5f, because
not re-reading the config file from phy_port_changed() meant that, later,
the next time we modified the config file we would do it based on the
older version, not the version that we just wrote out.
Ben Pfaff [Fri, 16 Jan 2009 18:08:51 +0000 (10:08 -0800)]
vswitchd: Delete flows on a deleted interface when revalidating.
When an interface is deleted from a datapath by an entity other than
vswitchd (e.g. by a vif being deleted), we would revalidate all the
flows and change them to drop packets. But that's a waste of flow
table space. This commit changes the behavior in this case to delete
those flows entirely.
This commit is complicated by the need to deal gracefully with flows
on datapath interfaces that we don't know about, e.g. from the local port
if the local port is not part of the bridge or from interfaces added to
a datapath by an external mechanism (e.g. added with "dpctl addif"
manually). We don't want to delete those flows, even though they resemble
the ones that we do want to delete, because they potentially save us from
processing a lot of packet-in messages that we don't care about. So we
mark those flows with a new "need_drop" flag.
Ben Pfaff [Fri, 16 Jan 2009 00:08:00 +0000 (16:08 -0800)]
brcompat: Don't re-read configuration file from inside bridge code.
brc_modify_config() re-reads the configuration files by calling cfg_read(),
but we don't want to do that when we're deep inside the bridge code, in
the call to brc_modify_config() from phy_port_changed(). So only call
cfg_read() from the callers of brc_modify_config() that are in brcompat.c.
Also, each cfg_read() call was followed by a call to bridge_reconfigure(),
which is what reconfigure() in vswitchd.c does, so just use that function
instead of open-coding the pair of calls.
This should not have caused a real problem, because no pointers into
configuration data are retained by bridge code, but it still seems like
the "correct" way to do things.
Ben Pfaff [Thu, 15 Jan 2009 22:31:55 +0000 (14:31 -0800)]
vconn: Ignore async messages before version negotiation completes.
The kernel can send a packet_in or other asynchronous message to
the secchan before the version negotiation step is finished, which
causes the secchan to drop the connection and try again. This commit
fixes the problem.
Justin Pettit [Wed, 14 Jan 2009 22:52:59 +0000 (14:52 -0800)]
Check wildcards for in_port != out_port output validation.
OpenFlow requires that traffic that is to be sent out the interface it
came in on use the OFPP_IN_PORT virtual port. The action validation
code that enforces this ignored the wildcards field, which meant it was
using the garbage 'in_port' value for this check.
root [Wed, 14 Jan 2009 01:30:08 +0000 (17:30 -0800)]
Allow controller to set MAC address to use in ARP responses for SNAT IPs.
This allows the controller to set a MAC address to use in response to
an ARP request for the NAT IP address on a non-NAT interface. This is
useful if a NAT'd device needs to communicate with a non-NAT'd device,
when they are on the same interface on the OpenFlow switch. When the
non-NAT'd device requests the MAC address of the NAT IP address, the
switch responds with the supplied MAC address (often the L3 router
behind it). This allows communication in both directions to bounce off
the L3 router and not confuse controller.
Ben Pfaff [Fri, 9 Jan 2009 21:28:12 +0000 (13:28 -0800)]
Make dpctl accept an arbitrary number of actions.
This cleanup has been wanted for a while.
As a side effect, this change deletes some dead code pointed out by Chris
Eagle via Fortify: many of the deleted comparisons against act_len were
never true because of the sizes of the objects invovled.
Ben Pfaff [Fri, 9 Jan 2009 01:10:34 +0000 (17:10 -0800)]
netdev: Fix file descriptor leak.
This could be important since it leaks a file descriptor on every
netdev_open(), but only if an IPv6 address is configured on the network
device (which is rare and indicates an error condition for OpenFlow).
Justin Pettit [Fri, 9 Jan 2009 23:41:42 +0000 (15:41 -0800)]
Add datapath device name to printk's.
To aid debugging, this prints the datapath device name to printk
messages. Not doing this wasn't a big deal when only a single datapath
was running, but it's very confusing when there are multiple.
Ben Pfaff [Fri, 9 Jan 2009 23:18:36 +0000 (15:18 -0800)]
vswitchd: Delete 'ifaces' pointer to interface when deleting interface.
Otherwise we dereference a dangling pointer to the interface when we
look up the interface by datapath port index, causing a segfault.
Introduced in commit 150ac45, "vswitchd: Eliminate "can't forward to bad
port" when interfaces disappear," which deletes an interface that is known
to be in the datapath port index table.
Ben Pfaff [Fri, 9 Jan 2009 20:51:19 +0000 (12:51 -0800)]
vswitchd: Eliminate "can't forward to bad port" when interfaces disappear.
When an interface was deleted from a datapath by a process other than
vswitchd (which is not supposed to happen), vswitchd would not realize it
and would continue to set up flows for that interface (and leave in place
existing flows). This caused the kernel to complain "can't forward to bad
port" for each packet on these flows.
Xen triggered this by destroying vifs that were on vswitchd-controlled
datapaths (which removes them from any datapath that they are on).
This fixes the problem, by making vswitchd notice when interfaces
disappear and fixing up the flow table.
Justin Pettit [Fri, 9 Jan 2009 01:16:33 +0000 (17:16 -0800)]
Add support for sysfs and ethtool.
Add support for sysfs when the bridge compatibility module is running.
Currently, this only works for 2.6.18 kernels. Working on all kernels
should be fixed soon. Also, add ethtool support to the datapath device.
Ben Pfaff [Thu, 8 Jan 2009 22:58:35 +0000 (14:58 -0800)]
Remove 'wait' parameter from dpif_send_openflow().
The 'wait' parameter had no effect (it was not implemented) and it was
only ever set to false. It's easier to simply remove it than to
implement an unneeded feature.
Ben Pfaff [Thu, 8 Jan 2009 20:25:18 +0000 (12:25 -0800)]
datapath: Fix deadlock in switch port removal.
dp_del_switch_port() cancels the port_task and waits for
it to finish, but the port_task requires the RTNL lock
to complete, which dp_del_switch_port() holds, thus a
deadlock.
This commit fixes the problem, by deleting the port_task
entirely and moving its work into secchan.
Ben Pfaff [Thu, 8 Jan 2009 00:57:05 +0000 (16:57 -0800)]
datapath: Avoid deadlock on dp_mutex versus kthread_stop().
When a datapath is deleted, del_dp() acquires dp_mutex and uses
kthread_stop() to wait for the dp_task to die. Meanwhile, dp_task may
be waiting to acquire dp_mutex and won't die until it does so.
This commit fixes the problem by sending SIGKILL to dp_task before
call kthread_stop() and making dp_task give up if it receives a signal.
Ben Pfaff [Wed, 7 Jan 2009 23:19:09 +0000 (15:19 -0800)]
datapath: Fix deadlock in network device notifier.
When a network device that is part of a datapath is destroyed, the
notifier handler in dp_device_event() calls dp_del_switch_port() to
delete the switch port. dp_del_switch_port() then calls rtnl_lock()
to drop the device's promiscuous count. But the RTNL lock has already
been taken at this point, so taking it recursively deadlocks.
The obvious fix is for dp_del_switch_port()'s caller to take the RTNL
lock for it, if it is not already taken. This, however, causes a
different deadlock, as dp_del_switch_port() needs dp_mutex and that
means that we are nesting dp_mutex and the RTNL both ways.
The fix used here is to always nest dp_mutex inside the RTNL lock and
never vice versa.
=============================================
[ INFO: possible recursive locking detected ]
---------------------------------------------
tunctl/2934 is trying to acquire lock:
(rtnl_mutex){--..}, at: [<c029667d>] mutex_lock+0x1c/0x1f
but task is already holding lock:
(rtnl_mutex){--..}, at: [<c029667d>] mutex_lock+0x1c/0x1f
other info that might help us debug this:
1 lock held by tunctl/2934:
#0: (rtnl_mutex){--..}, at: [<c029667d>] mutex_lock+0x1c/0x1f
Problem identified with this script (in conjunction with the brcompat
module):
#! /bin/sh
brctl delbr a
brctl delbr b
brctl delbr c
set -x
stress () {
bridge=$1
shift
while true; do
brctl addbr $bridge; brctl show
for iface
do
case $iface in
tap*) tunctl -t $iface ;;
esac
brctl addif $bridge $iface
done
for iface
do
brctl delif $bridge $iface
case $iface in
tap*) tunctl -d $iface ;;
esac
done
brctl delbr $bridge; brctl show
done
}
stress a tap0 tap1 tap2 &
stress b tap3 tap4 tap5 &
trap 'killall stress-brctl' 0 SIGINT
wait