Ben Pfaff [Fri, 6 Mar 2009 21:30:09 +0000 (13:30 -0800)]
flow: Properly translate port numbers in flow_from_match().
The OpenFlow and datapath port numbers for the local port are different.
We were translating them in one direction (in flow_to_match()) but not
in the other (in flow_from_match()).
This fixes a performance problem (we were setting up the wrong flow).
Ben Pfaff [Fri, 6 Mar 2009 18:58:13 +0000 (10:58 -0800)]
netdev: Don't log a warning for unsupported ethtool operations.
Plenty of devices don't support ethtool, and we don't use ethtool for
anything essential, so there's no point in logging a warning here.
Ben Pfaff [Fri, 6 Mar 2009 18:57:30 +0000 (10:57 -0800)]
dpif: Don't log a warning in dpifmon_poll() for missing device.
We were using dpif_port_query_by_name() here to see whether the device is
part of the datapath, so there's no point in logging a warning if it isn't.
Ben Pfaff [Fri, 6 Mar 2009 17:52:08 +0000 (09:52 -0800)]
secchan: Fix use-after-free by allocating rule actions as separate blocks.
The ofproto code tried to cleverly save memory and time by allocating
rule actions as a flexible array member at the end of "struct rule". When
the actions changed, this required a realloc() call. Unfortunately, there
are sometimes pointers to rules (e.g. the "super" pointer from subrules)
that were not getting adjusted to point to the new location.
It's better to just allocate actions separately, so fix it by doing that.
Justin Pettit [Fri, 6 Mar 2009 08:34:37 +0000 (00:34 -0800)]
Cleanup .gitignore for 2.4 datapath builds.
Justin Pettit [Fri, 6 Mar 2009 08:34:01 +0000 (00:34 -0800)]
More files for git to ignore for 2.6 datapath builds.
Justin Pettit [Fri, 6 Mar 2009 08:24:45 +0000 (00:24 -0800)]
Cleanup files for git to ignore in datapath linux-2.6 build directory.
Justin Pettit [Fri, 6 Mar 2009 08:01:25 +0000 (00:01 -0800)]
Only build SSL components if build configured with HAVE_OPENSSL.
Justin Pettit [Fri, 6 Mar 2009 08:01:00 +0000 (00:01 -0800)]
Add limits.h for UINT_MAX definition.
Ben Pfaff [Fri, 6 Mar 2009 01:34:42 +0000 (17:34 -0800)]
secchan: Correctly maintain rule's number of actions.
We were reallocating memory properly but not updating the "n_actions"
member, which sometimes led to reading past the end of a block.
This problem possibly caused segfaults, since the OpenFlow->ODP action
translation code assumes that OpenFlow actions are prevalidated, and
random memory is not necessarily valid OpenFlow actions :-)
Spotted by Valgrind.
Ben Pfaff [Fri, 6 Mar 2009 01:00:46 +0000 (17:00 -0800)]
dpif: Suppress spurious error from Valgrind.
Ben Pfaff [Fri, 6 Mar 2009 00:59:49 +0000 (16:59 -0800)]
Add header for interacting with Valgrind, where it is available.
Ben Pfaff [Thu, 5 Mar 2009 23:09:00 +0000 (15:09 -0800)]
netdev: Fall back to /proc/net/dev on kernels that don't support RTM_GETLINK.
RTM_GETLINK is the best way to get network device statistics, but it was
only enabled in all kernels in 2.6.19. So now test for support at startup
and fall back to reading /proc/net/dev if RTM_GETLINK does not work.
Ben Pfaff [Thu, 5 Mar 2009 21:57:35 +0000 (13:57 -0800)]
dpif: Make it harder to randomly corrupt memory.
Ben Pfaff [Thu, 5 Mar 2009 21:57:17 +0000 (13:57 -0800)]
secchan: Initialize odp_flow members in other places that they were missed.
This might fix more memory corruption of the same form as commit
60822fb1,
"secchan: Fix random memory corruption due to uninitialized pointer."
Ben Pfaff [Thu, 5 Mar 2009 21:43:26 +0000 (13:43 -0800)]
secchan: Fix memory leaks.
Ben Pfaff [Thu, 5 Mar 2009 21:36:37 +0000 (13:36 -0800)]
secchan: Revalidate subrules when adding a wildcarded rule without displacement.
Natasha noticed that adding a rule would not properly change the
destinations of already-established flows. This should fix the problem.
Ben Pfaff [Thu, 5 Mar 2009 21:13:30 +0000 (13:13 -0800)]
datapath: Fix querying the local port by name.
Before, this would return an ENOENT error.
Ben Pfaff [Thu, 5 Mar 2009 21:07:31 +0000 (13:07 -0800)]
vswitchd: Start adding ports at index 1, since index 0 is reserved.
Otherwise we get a spurious error message (although we do go on to try the
next port, so the message isn't a big deal).
Ben Pfaff [Thu, 5 Mar 2009 21:06:45 +0000 (13:06 -0800)]
dpif: Improve logging messages, to ease debugging.
Ben Pfaff [Thu, 5 Mar 2009 20:30:36 +0000 (12:30 -0800)]
vswitchd: Integrate secchan into vswitchd.
This change means that vswitchd is now a single process that manages all
of the datapaths, instead of a parent process and any number of secchan
subprocesses.
It may be better to fork off processes that each manage a few bridges, to
take advantage of multiple cores. Perhaps this is upcoming.
There are numerous new configuration file directives that are, sadly, not
yet documented.
Ben Pfaff [Thu, 5 Mar 2009 20:29:02 +0000 (12:29 -0800)]
ofproto: Make ofproto_set_controller() able to disconnect from controller.
The vswitch wants to do this.
Ben Pfaff [Thu, 5 Mar 2009 20:28:36 +0000 (12:28 -0800)]
ofproto: Change semantics of configuration parameters.
Before, a value of 0 meant "no change". Now, it means "use the default
value". This turns out to be more useful.
Ben Pfaff [Thu, 5 Mar 2009 20:27:46 +0000 (12:27 -0800)]
vconn-ssl: Log all errors when trying to create a connection, not just the first.
This will, I hope, help administrators to see whether just one setting or
all of them are unconfigured.
Ben Pfaff [Thu, 5 Mar 2009 20:26:22 +0000 (12:26 -0800)]
socket-util: New function guess_netmask().
Ben Pfaff [Thu, 5 Mar 2009 20:26:07 +0000 (12:26 -0800)]
rconn: Tolerate negative argument in rconn_set_max_backoff().
This argument is likely to come directly from the user, so it helps callers
if they don't have to validate carefully.
Ben Pfaff [Thu, 5 Mar 2009 20:25:10 +0000 (12:25 -0800)]
more cfg fixes
Ben Pfaff [Thu, 5 Mar 2009 20:24:56 +0000 (12:24 -0800)]
executer: Make default dir part of executer.c, not main.c.
That way the vswitch can get the default without having to know it too.
Ben Pfaff [Thu, 5 Mar 2009 20:23:13 +0000 (12:23 -0800)]
vswitchd: Remove stray debug printf().
Ben Pfaff [Thu, 5 Mar 2009 19:13:49 +0000 (11:13 -0800)]
cfg: Fix behavior of cfg_get(0, "a") when a key "a.b" exists.
The intent of cfg_get_*(0, "a") is to get the first value of a key with
the exact name "a", but in the presence of a key with a longer name, e.g.
"a.b", it would return the value of that key instead.
This file really needs a unit test! I'm really not certain that
the fix didn't break other things (e.g. cfg_has_section()).
Ben Pfaff [Thu, 5 Mar 2009 19:01:45 +0000 (11:01 -0800)]
dpif: Don't rely on caller to keep dpif arg valid, in dpifmon_create().
dpifmon_create() stored away the dpif pointer that it was passed and
continued to use it, but ofproto_create() didn't keep that dpif in a
constant place in memory, so dpifmon_poll() would randomly fail with
errors like "Bad file descriptor". Having the dpifmon keep its own
fd to a dpif is more reliable.
Additional possible fix to Dan's problem.
Ben Pfaff [Thu, 5 Mar 2009 18:46:33 +0000 (10:46 -0800)]
dpif: Fix uninitialized memory accesses.
Found by Valgrind.
This may fix some problems found by Dan.
Ben Pfaff [Thu, 5 Mar 2009 01:42:35 +0000 (17:42 -0800)]
ofp-print: Use ntohs() for 16-bit field, not ntohl().
Noticed by Natasha.
Ben Pfaff [Thu, 5 Mar 2009 01:34:04 +0000 (17:34 -0800)]
secchan: Remove obsolete debug printf()s.
Ben Pfaff [Thu, 5 Mar 2009 01:32:53 +0000 (17:32 -0800)]
secchan: Flush datapath flow table when initializing the switch.
The switch can't recover the entire OpenFlow state from the datapath, so
it has the choice of either guessing at some missing information (which
seems undesirable) or just flushing the table. The latter is easier, so
do that.
Ben Pfaff [Thu, 5 Mar 2009 01:30:59 +0000 (17:30 -0800)]
vswitchd: Log details of unexpected flows, to aid debugging.
Ben Pfaff [Thu, 5 Mar 2009 01:30:20 +0000 (17:30 -0800)]
vlog: Add functions for testing a rate-limit without emitting a message.
This allows clients to avoid doing work to construct a rate-limited
message until they know that the message will actually be displayed.
Ben Pfaff [Thu, 5 Mar 2009 01:16:16 +0000 (17:16 -0800)]
classifier: Tolerate old==new in cls_rule_moved().
The primary purpose of cls_rule_moved() is to deal gracefully with memory
blocks that have been realloc()'d. realloc() can return the original
memory block so it's best to tolerate that instead of assert-failing.
Ben Pfaff [Wed, 4 Mar 2009 18:04:23 +0000 (10:04 -0800)]
secchan: Make ofproto reconfigurable after it is created.
This will allow vswitchd to reconfigure the ofprotos that it instantiates
based on changes in the vswitchd configuration file.
Ben Pfaff [Wed, 4 Mar 2009 17:57:13 +0000 (09:57 -0800)]
vconn: New function pvconn_get_name().
Ben Pfaff [Wed, 4 Mar 2009 17:57:01 +0000 (09:57 -0800)]
New function svec_clone().
Ben Pfaff [Wed, 4 Mar 2009 17:56:47 +0000 (09:56 -0800)]
rconn: Add new function rconn_reconnect().
Ben Pfaff [Wed, 4 Mar 2009 17:56:34 +0000 (09:56 -0800)]
rconn: Add new functions for getting/setting basic rconn parameters.
Ben Pfaff [Thu, 5 Mar 2009 00:55:15 +0000 (16:55 -0800)]
classifier: Remove classifier_for_each_with_wildcards().
This function is now unused, and it seems unlikely that a new user will
appear, so remove it.
Ben Pfaff [Thu, 5 Mar 2009 00:54:42 +0000 (16:54 -0800)]
secchan: Use classifier_for_each() instead of secchan_for_each_with_wildcards().
The classifier_for_each() function now provides what we actually needed
from secchan_for_each_with_wildcards(), and the interface is more sensible
to boot.
Ben Pfaff [Thu, 5 Mar 2009 00:48:39 +0000 (16:48 -0800)]
secchan: Fix random memory corruption due to uninitialized pointer.
The kernel returns flow stats and actions to userspace on flow deletion.
By not initializing the odp_flow's "actions" or "n_actions" members we
caused it to use whatever happened to be in that space on the stack, which
caused random memory corruption.
(There is no need to initialize the "stats" member, since it is not read,
only written, by the kernel, but by doing so we quiet valgrind.)
Ben Pfaff [Wed, 4 Mar 2009 23:47:47 +0000 (15:47 -0800)]
secchan: Fix another use-after-free bug.
Ben Pfaff [Wed, 4 Mar 2009 23:08:57 +0000 (15:08 -0800)]
secchan: Fix segfault due to access-after-free in expiration.
classifier_for_each() keeps a pointer to the *next* rule to be visited, so
that the rule currently be visited can be deleted. That means that if
the callback frees the next rule to be visited, then we get an
access-after-free error.
In particular, this was occurring when expire_rule() expired a superflow
whose
Ben Pfaff [Wed, 4 Mar 2009 22:55:20 +0000 (14:55 -0800)]
secchan: Fix segfault when subrules are invalidated.
The subrules were being freed, but not removed from the classifier, so a
segfault would occur later when they were accessed during a lookup or
traversal.
Thanks to Dan and Natasha for the report and testcases.
Ben Pfaff [Wed, 4 Mar 2009 22:53:07 +0000 (14:53 -0800)]
secchan: Fix read-after-free error in OFPT_FLOW_MOD implementation.
Found via valgrind.
Ben Pfaff [Wed, 4 Mar 2009 22:52:18 +0000 (14:52 -0800)]
secchan: Fix segfault at startup due to uninitialized br_name member.
Ben Pfaff [Wed, 4 Mar 2009 21:20:47 +0000 (13:20 -0800)]
classifier: Test classifier_for_each_match().
Ben Pfaff [Wed, 4 Mar 2009 21:18:44 +0000 (13:18 -0800)]
classifier: Test exact-match flows also in test_many_rules_in_different_tables().
Ben Pfaff [Wed, 4 Mar 2009 21:08:45 +0000 (13:08 -0800)]
classifier: Style fix for test-classifier.
Line was too long.
Ben Pfaff [Wed, 4 Mar 2009 21:08:18 +0000 (13:08 -0800)]
classifier: In testing, don't put cls_rule at beginning of test_rule.
If we put cls_rule at the beginning of struct test_rule, then a cast is
sufficient to convert a pointer between the two, but we want to make sure
that we don't ever take that shortcut, because it is not valid in general.
Ben Pfaff [Wed, 4 Mar 2009 20:32:19 +0000 (12:32 -0800)]
classifier: Add tests for classifier_count(), classifier_count_exact().
Ben Pfaff [Wed, 4 Mar 2009 20:25:29 +0000 (12:25 -0800)]
classifier: Add tests for classifier_lookup_wild(), classifier_lookup_exact().
Ben Pfaff [Wed, 4 Mar 2009 21:26:19 +0000 (13:26 -0800)]
classifier: Allow classifier_for_each_match() callback to free the rule.
classifier_for_each_match() would segfault if the callback passed in
deleted and freed the rule in question, because it accessed the rule after
calling the callback. This commit should fix the problem.
Thanks to Natasha for reporting the problem.
Keith Amidon [Wed, 4 Mar 2009 18:58:53 +0000 (10:58 -0800)]
Work around header type clashes in Xen builds
Keith Amidon [Wed, 4 Mar 2009 18:58:31 +0000 (10:58 -0800)]
Remove unneeded header file that was breaking builds for Xen.
Ben Pfaff [Wed, 4 Mar 2009 18:16:04 +0000 (10:16 -0800)]
Distribute needed file that had been forgotten (fixes "make dist").
Ben Pfaff [Tue, 3 Mar 2009 22:24:12 +0000 (14:24 -0800)]
rconn: Make queued packet counting harder to screw up.
The semantics of the 'n_queued' parameter to rconn_send() and
rconn_send_with_limit() were too easy to screw up: if the memory area in
which the passed-in data lived was destroyed before the rconn was
destroyed, then rconn_destroy() (or simply flushing out the transmission
queue) would access invalid memory or, worse, decrement a random integer
in reused memory. It was possible to avoid this by destroying the rconn
before destroying the queue count data area, but this is difficult to
remember and not always possible in the general case.
This commit changes to using a reference-counted structure, which is harder
to get wrong.
Ben Pfaff [Tue, 3 Mar 2009 22:03:18 +0000 (14:03 -0800)]
datapath: Fix build on Linux 2.6.18 through 2.6.28.
Ben Pfaff [Tue, 3 Mar 2009 19:44:24 +0000 (11:44 -0800)]
vswitchd: Choose the bridge local port MAC address intelligently.
Fixes bug #928, "We should have a consistent model for representing the
nic/mac address to xenserver."
Ben Pfaff [Tue, 3 Mar 2009 19:34:52 +0000 (11:34 -0800)]
datapath: Allow datapath device MAC address to be changed while it is up.
vswitchd wants to do this, and I don't see a reason to disallow it.
Ben Pfaff [Tue, 3 Mar 2009 20:37:51 +0000 (12:37 -0800)]
netdev: New function netdev_nodev_set_etheraddr().
Ben Pfaff [Fri, 27 Feb 2009 23:48:39 +0000 (15:48 -0800)]
vswitch: Fix connection to a remote controller.
Without this change, vswitchd will kill secchan almost as soon as it
starts it, because it fails to recognize that it is connecting to a remote
controller instead of to vswitchd.
Ben Pfaff [Tue, 3 Mar 2009 21:39:23 +0000 (13:39 -0800)]
datapath: Fix build on 2.6.18 (both upstream and RHEL/Xen variants).
Ben Pfaff [Tue, 3 Mar 2009 01:30:32 +0000 (17:30 -0800)]
secchan: Make it possible to destroy an ofproto.
Ben Pfaff [Tue, 3 Mar 2009 00:52:55 +0000 (16:52 -0800)]
secchan: Implement OFPP_TABLE and NXAST_RESUBMIT actions.
Ben Pfaff [Tue, 3 Mar 2009 00:33:01 +0000 (16:33 -0800)]
secchan: Fix subrule revalidation.
When revalidating a subrule, we need to only match rules with wildcards.
Otherwise, a subrule will always match itself and we will explode.
Ben Pfaff [Mon, 2 Mar 2009 22:27:10 +0000 (14:27 -0800)]
secchan: Make secchan into a library.
Ben Pfaff [Mon, 2 Mar 2009 22:30:17 +0000 (14:30 -0800)]
datapath: Remove stray debugging printk.
Ben Pfaff [Mon, 2 Mar 2009 22:19:51 +0000 (14:19 -0800)]
vswitchd: Fix typo in comment.
Ben Pfaff [Mon, 2 Mar 2009 22:16:48 +0000 (14:16 -0800)]
secchan: Fix logging of datapath ID.
ofproto was logging the datapath ID passed in as part of its settings, but
that's allowed to be 0. Instead, it needs to log the datapath ID that is
actually in use.
Ben Pfaff [Mon, 2 Mar 2009 22:13:36 +0000 (14:13 -0800)]
vswitchd: Fix bad assumption about byte order of flow_t's "in_port".
In the big restructuring of secchan and the datapath, the "in_port"
member was changed from network byte order to host byte order, but vswitchd
hadn't quite caught up. This fixes the problem.
With this commit, at least the most basic use of vswitchd now works again.
Ben Pfaff [Mon, 2 Mar 2009 22:12:26 +0000 (14:12 -0800)]
vswitchd: Fix segfault when packet received on unknown port.
This problem and its fixed are independent of the recent secchan
restructuring (even though it turned out to be a good way to trigger it).
Ben Pfaff [Mon, 2 Mar 2009 22:09:19 +0000 (14:09 -0800)]
vswitchd: Don't pass --monitor to secchan.
The --monitor option was deleted from secchan, because it was intended for
monitoring the OpenFlow connection between secchan and the kernel. Since
secchan no longer uses OpenFlow to talk to the kernel, the option made
no sense.
Ben Pfaff [Mon, 2 Mar 2009 20:36:33 +0000 (12:36 -0800)]
netdev: Remove netdev_monitor, which is no longer used.
secchan now uses the dpifmon interface instead, which is more suited to
its purpose.
Ben Pfaff [Mon, 2 Mar 2009 21:42:44 +0000 (13:42 -0800)]
Refactor the OpenFlow implementation.
This new implementation has an architecture that is much more suited to
eventually getting pushed upstream into the Linux kernel, because it does
not do any OpenFlow processing in the kernel. Rather, we define a new
"datapath protocol" that secchan uses, via ioctl calls, to set up the
flow table in the kernel.
This implementation also should have much better performance with flows
that contain wildcards, since it uses a flow classifier that should be
much better than linear search in the cases that we suspect are important.
This release does contain some feature regressions; see the new file
MISSING at the root of the tree for more information. We will be fixing
these regressions over the next weeks and months.
This has not been tested much. It needs plenty of testing and QA before it
will be suitable for any kind of production environment. The vswitchd
changes, in particular, have not been tested at all and thus vswitchd is
likely to be broken.
Ben Pfaff [Mon, 2 Mar 2009 19:13:14 +0000 (11:13 -0800)]
vconn: Make check_ofp_message() return value more useful.
Ben Pfaff [Mon, 2 Mar 2009 19:12:33 +0000 (11:12 -0800)]
vconn: New function normalize_match().
Ben Pfaff [Mon, 2 Mar 2009 19:12:06 +0000 (11:12 -0800)]
vconn: New functions for validating and iterating over OpenFlow actions.
Ben Pfaff [Mon, 2 Mar 2009 20:51:08 +0000 (12:51 -0800)]
openflow.h: Add new error types and codes.
Ben Pfaff [Mon, 2 Mar 2009 20:50:54 +0000 (12:50 -0800)]
Add new "union ofp_action" to make working with actions easier.
Ben Pfaff [Mon, 2 Mar 2009 19:09:13 +0000 (11:09 -0800)]
vconn: New function check_ofp_packet_out().
Ben Pfaff [Mon, 2 Mar 2009 19:08:16 +0000 (11:08 -0800)]
New macro PORT_ARRAY_FOR_EACH.
Ben Pfaff [Mon, 2 Mar 2009 19:07:53 +0000 (11:07 -0800)]
vconn: Distinguish between parse errors and other messages in rate-limiting.
The vconn code wants to rate-limit errors, which there's not too much
point in reporting a lot of, from the log of all OpenFlow messages, which
are very important if we really want to log them at all. So use a
different rate-limiter for each category.
Ben Pfaff [Mon, 2 Mar 2009 18:49:40 +0000 (10:49 -0800)]
netdev: New function netdev_nodev_get_etheraddr().
Ben Pfaff [Mon, 2 Mar 2009 18:48:00 +0000 (10:48 -0800)]
netdev: New function netdev_set_advertisements().
The new implementation of the switch needs to do this from userspace.
Ben Pfaff [Mon, 2 Mar 2009 18:47:26 +0000 (10:47 -0800)]
netdev: Don't cache network device features.
The new implementation of secchan wants to get updates of network device
features by keeping a network device open for each port and checking its
features when notified of a port status change. This wouldn't work, since
the features were cached once at startup. This commit makes the netdev
code check the actual devices features on each call.
Also, generalizes do_ethtool() to be useful for other kinds of ethtool
operations.
Ben Pfaff [Mon, 2 Mar 2009 20:43:47 +0000 (12:43 -0800)]
netdev: Avoid some system calls in the common case in netdev_open().
The new secchan opens one netdev per OpenFlow port. We should be able to
handle this in the common case without one file descriptor per netdev
(because most netdev operations can be performed using a single AF_INET
socket). This change starts along that path by moving the operations
that are required only to receive netdev packets out of the common path.
Ben Pfaff [Mon, 2 Mar 2009 18:35:18 +0000 (10:35 -0800)]
netdev: Set *flagsp to 0 if flags cannot be obtained.
This interface is more convenient for some clients.
Ben Pfaff [Mon, 2 Mar 2009 20:41:25 +0000 (12:41 -0800)]
netdev: New function netdev_get_stats().
Ben Pfaff [Mon, 2 Mar 2009 18:52:05 +0000 (10:52 -0800)]
netdev: Fix typo in comment.
Ben Pfaff [Mon, 2 Mar 2009 18:30:00 +0000 (10:30 -0800)]
New function time_timeval().
Ben Pfaff [Mon, 2 Mar 2009 19:37:58 +0000 (11:37 -0800)]
Implement a flow classifier, plus tests.
Ben Pfaff [Mon, 2 Mar 2009 19:44:50 +0000 (11:44 -0800)]
New function and data structure for handling flow wildcards.
Ben Pfaff [Mon, 2 Mar 2009 21:42:04 +0000 (13:42 -0800)]
Generalize conversions between struct flow and struct ofp_match.
Ben Pfaff [Sat, 28 Feb 2009 00:54:38 +0000 (16:54 -0800)]
hash: Make hash function pieces available to other modules.
This way, modules that want to implement hash functions on their own terms,
for performance (e.g. the classifier), do not have to duplicate the code.