Justin Pettit [Wed, 11 Feb 2009 23:23:23 +0000 (15:23 -0800)]
Check wildcards for in_port != out_port output validation. (udatapath)
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.
Ben Pfaff [Fri, 6 Feb 2009 23:07:38 +0000 (15:07 -0800)]
vswitchd: Avoid 100% CPU when secchan dies too many times.
vswitchd restarts secchan when necessary, but it limits the maximum number
of tries to avoid wasting CPU when secchan repeatedly dies. Unfortunately,
when this happens it also throws vswitchd into a busy-wait by calling
process_wait() on the dead secchan process, because it doesn't clear out
the process from the bridge structure.
This commit clears out the secchan process from the bridge structure, so
that we don't attempt to wait on it any longer, and should fix the busy-wait
problem.
Ben Pfaff [Wed, 4 Feb 2009 18:54:32 +0000 (10:54 -0800)]
poll-loop: Add support for logging the reason for wakeups.
It is useful to log the reason for wakeups, to debug why a program is
waking up more often than it should (for example, consuming 100% CPU load
for no apparent reason). This adds that logging at DBG level in the
poll loop.
Ben Pfaff [Tue, 3 Feb 2009 18:27:22 +0000 (10:27 -0800)]
Don't define skb_copy_{to,from}_linear_data_offset if it is available.
Linux 2.6.22 introduced functions skb_copy_from_linear_data_offset()
and skb_copy_to_linear_data_offset(). In earlier versions we defined them.
But Xen backports these functions, so this became a duplicate definition.
So check for them at configure time instead of depending on the kernel
version number.
Ben Pfaff [Mon, 2 Feb 2009 17:55:32 +0000 (09:55 -0800)]
datapath: Fix up checksum on Xen before forwarding to controller.
On Xen, the datapath can receive a packet that lacks a correct checksum
from a VM, because the VMs expect to use the host's hardware TX
checksumming. Until now, we haven't fixed up the checksum before we sent
the packet to the controller. The controller doesn't normally verify
the checksum (nor can it in general, since it doesn't necessarily get the
entire packet), so that part isn't a problem.
The problem here is in the buffered packet. fwd_save_skb() makes a copy
(not a clone) of the packet, but skb_copy() doesn't make a copy of the
skbuff's proto_csum_blank, which is what dev_queue_xmit() uses (via
skb_checksum_setup()) to decide whether checksumming needs to be forced.
Thus, the buffered packet is transmitted with a bad checksum.
A partial solution would be to copy proto_csum_blank from the original
skb into the buffered copy, or to make the buffers use clones instead of
copies (they really should do this anyhow). But this would still send
a bad checksum to the controller. So instead we do the full checksum
calculation before we send the packet to the controller.
This change affects only Xen. This situation cannot occur without Xen,
because any packets that arrive on physical interfaces must already have
correct checksums.
Justin Pettit [Mon, 26 Jan 2009 21:42:16 +0000 (13:42 -0800)]
Fix build issues with recent SNAT changes on older kernels.
Recent changes that fixed fragmented packets for SNAT-enabled builds
used calls not implemented in older kernels. These changes add those
calls to the compatibility layer and clean up a few warnings in those
older kernel builds.
Justin Pettit [Mon, 26 Jan 2009 20:45:56 +0000 (12:45 -0800)]
Move veth.c to Linux 2.6 compatibility directory.
The veth driver is only available on more recent kernels. veth.c
contains a port to 2.6.18. Since this is only needed for 2.6.18, the
source is being moved to the compatibility directory.
Justin Pettit [Mon, 26 Jan 2009 09:05:39 +0000 (01:05 -0800)]
For SNAT, don't store the pre-fragment L2 header before actions are applied.
The IP fragment code doesn't always write the L2 header when generating
new fragments. This problem was fixed in an earlier commit.
Unfortunately, we stored the pre-fragment L2 header when the packet
first arrived--before other packet modifications were applied. This
meant that the results of any OpenFlow L2 modification actions were lost.
This patch pushes the storage of the L2 header until right before the
packet is transmitted (and possibly refragmented).
Justin Pettit [Sat, 24 Jan 2009 01:30:16 +0000 (17:30 -0800)]
Move setting Nicira datapath ID out of kernel.
When generating the datapath id/mac address for an OpenFlow device, the
kernel checks the DMI for a suitable one in a Nicira UUID. If one is
not found, then a random address is generated. This patch makes it so
that a random address is always generated. The DMI Nicira UUID check is
now done in the init script, which overrides the random address
generated when the datapath was created. Ripping code out of the kernel
is good.
Ben Pfaff [Mon, 19 Jan 2009 18:53:03 +0000 (10:53 -0800)]
Fix minor bug in flow_extract().
We were treating 802.2 frames that were too short to have a SNAP header as
if they had a dl_type of 0, when really they were supposed to have a
dl_type of OFP_DL_TYPE_NOT_ETH_TYPE.
This bug probably didn't affect anything in practice, because it is very
unusual to have a 802.2 frame that is too short to have a SNAP header,
because any frame that goes over a physical wire will be padded out so
that it is longer than that.
Ben Pfaff [Wed, 7 Jan 2009 17:28:19 +0000 (09:28 -0800)]
Make port status change messages reliable.
Until now, port status change messages were sent out by the datapath
implementations and simply relayed by secchan. In the kernel
implementation, they were unreliable because they were sent out over the
multicast socket used for packet-in events: if many packet-in messages
arrived and filled up that socket's receive buffer, then any subsequent
port status change messages were dropped.
This change moves port status change detection from the datapath
implementations into secchan, making them reliable, by using a
netdev_monitor.
(An alternate implementation would have been to detect the socket
receive buffer overflow and poll the network devices. The current
implementation was chosen because it removes code from the datapaths,
which is the direction we want to move in for the future.)
Ben Pfaff [Wed, 7 Jan 2009 01:26:12 +0000 (17:26 -0800)]
netdev: Make carrier status available in device flags.
Before, network device carrier status was available only through
netdev_get_link_status(). However, Linux makes it available in network
device flags, so we might as well use it.
Ben Pfaff [Wed, 14 Jan 2009 23:35:12 +0000 (15:35 -0800)]
netdev: New function netdev_nodev_get_flags().
An upcoming change will move detection of netdev flags changes into
secchan. That change will require polling the flags for many network
devices. Opening and closing that many network devices, or keeping
around fds for them, is a waste of time (or fds).
But it's easy to get flags for any number of netdevs from a single file
descriptor, so add a function to do this.
Ben Pfaff [Wed, 7 Jan 2009 01:06:48 +0000 (17:06 -0800)]
Make nl_policy_parse() compatible with non-Generic Netlink packets.
Some packets that are not Generic Netlink packets nevertheless use its
attribute format. By making the caller pass in the offset to the
attributes we can support these packet formats too.
(Another approach would be to make the caller pull off the headers.)
Ben Pfaff [Tue, 6 Jan 2009 20:55:14 +0000 (12:55 -0800)]
Add lookup3-based hash for bytes, and remove FNV hash entirely.
The lookup3 hash is superior to FNV. This change makes OpenFlow use
lookup3 exclusively, by adding a variant of it that can hash arbitrary
byte sequences.
Ben Pfaff [Mon, 19 Jan 2009 23:19:40 +0000 (15:19 -0800)]
Add support for dynamic library symbols to ofp-parse-leaks.
In adding support for the leak checker to NOX, it became clear that we
needed to support fetching symbols for dynamically loaded libraries,
because most of NOX is in fact in such libraries. This adds that support.
Justin Pettit [Wed, 21 Jan 2009 02:22:49 +0000 (18:22 -0800)]
Fix fragment issue for large IP packets when SNAT action enabled.
The Netfilter code automatically reassembles IP fragments. We need to
explicitly have them refragmented before transmitting. (Bug #823)
(cherry picked from commit dfc7aa676ab44db7a49284a80798c7be5369db85)
Ben Pfaff [Wed, 21 Jan 2009 00:28:38 +0000 (16:28 -0800)]
Improve handling of unexpected 'status' in process_status_msg().
This function was getting passed -1 as 'status' due to a bug elsewhere,
and it was outputting ", core dumped" as the result, which clearly isn't
very helpful. This improves the situation.
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).