Commit Graph

388 Commits

Author SHA1 Message Date
Ben Pfaff eca2aeb329 Implement OFPC_FRAG_DROP fragment handling policy. 2008-08-07 10:34:37 -07:00
Ben Pfaff 2a6dc4f319 Reduce redundancy in datapath code. 2008-08-07 10:34:37 -07:00
Ben Pfaff 844a4678aa Maintain userspace switch configuration in host byte order.
This makes it easier to work with and makes the code more like the
kernel switch.
2008-08-07 10:23:06 -07:00
Ben Pfaff 6ca5840e48 Fix memory leak when OFPP_TABLE is used for a packet that matches no flow. 2008-08-07 10:23:06 -07:00
Ben Pfaff d7f1e2b535 Drop controller-bound traffic that arrives on the controller's port.
Before, if a hub connected a number of OpenFlow switches and the controller,
then in-band control traffic from one of the OpenFlow switches would be
seen by each of the other switches and forwarded up to the controller as
an ofp_packet_in message.  That message would then be seen by all of the
other OpenFlow switches and also forwarded, and so on in an infinite loop.

This change prevents this situation by keeping secchan from forwarding
ofp_packet_in messages for a packet destined to the controller that
arrives on the port where the controller is located.

This code has at least two weaknesses.  First, if the controller's port
changes, then the flows set up to drop packets will not be deleted.  This
should not be a major problem: if this inadvertently kills a switch's
connection to the controller, then the switch will realize it after it
stops receiving data and re-connect.  Its new connection will have new
flow data and therefore its packets will not be dropped.

Second, the notion of the "controller's port" does not take into account
the possibility of loops in the network topology.  We need spanning tree
protocol for that.
2008-08-07 10:10:11 -07:00
Justin Pettit 5caaf64f20 Properly track table match counts. 2008-08-06 01:58:15 -07:00
Ben Pfaff ca477c1000 Fix typo in comment. 2008-08-05 10:50:09 -07:00
Ben Pfaff 4c4238cacf Mark functions not used in other source files static. 2008-08-04 14:47:27 -07:00
Ben Pfaff bf13819340 Make it easier for the compiler to optimize IP_IS_FRAGMENT. 2008-08-04 14:46:01 -07:00
Ben Pfaff 35aa1a919a Fix bug in flow_extract() for extracting VLAN from short packet. 2008-08-04 14:46:01 -07:00
Ben Pfaff ef7e8993ff Don't accept incomplete TCP headers when extracting flows in kernel.
This makes the kernel and the userspace implementations of flow
extraction behave the same way regarding headers.
2008-08-04 14:46:01 -07:00
Ben Pfaff b0a11b7a5a Don't try to extract UDP/TCP port numbers from IP fragments. 2008-08-04 14:45:59 -07:00
Ben Pfaff 0b8dc43d6d Fix typo in comment. 2008-08-04 14:45:17 -07:00
Ben Pfaff 7b30178058 dhcp: Make client signal a change if renewing yields different options.
This allows the secchan to connect to a new controller if the DHCP server
starts announcing a new vconn without invalidating old leases.
2008-07-30 15:46:38 -07:00
Ben Pfaff 245f96aebc dhcp: Make dhcp_option_to_string() act sensibly with null or empty options.
Also, update ofp-switch-setup to parse the new syntax.
2008-07-30 15:46:38 -07:00
Ben Pfaff aa26396ed5 dhcp: New function dhcp_option_equals(). 2008-07-30 15:46:38 -07:00
Ben Pfaff e3eaf2b79c Clean up secchan code. 2008-07-30 15:46:38 -07:00
Ben Pfaff 2d4b692ecd netdev: Let netdev_get_in4(), netdev_get_in6() take null pointer argument.
Some callers want to just test whether the device has an address assigned
and don't care about the particular address, so this simplifies those
callers slightly.
2008-07-30 15:46:38 -07:00
Ben Pfaff bb55cf014a Debian: Listen on Unix domain socket for management connections. 2008-07-30 15:46:36 -07:00
Ben Pfaff bab6bdbe58 vconn: Implement Unix domain socket vconn.
These are useful for local management connections because, unlike TCP
sockets, they are subject to regular file system permissions.
2008-07-30 15:45:21 -07:00
Ben Pfaff 5680957f84 Move unix socket helper functions into socket-util.
This makes them available for use by the upcoming vconn_unix.
2008-07-30 15:45:05 -07:00
Ben Pfaff 6ed1440acc vconn: Use vconn_stream to factor out code from vconn_tcp. 2008-07-30 15:45:04 -07:00
Ben Pfaff 85a2e91f5f vconn: Introduce infrastructure for stream socket-based vconns. 2008-07-30 15:44:22 -07:00
Ben Pfaff b803dfadd1 vconn: Allow vconns to delegate to underlying implementations. 2008-07-30 15:43:57 -07:00
Ben Pfaff 22b8fc08fb Fix typo in comment. 2008-07-30 15:43:10 -07:00
Natasha Gude cef6834a20 IP_ARGS takes address of nw_addr 2008-07-30 14:41:47 -07:00
Justin Pettit 0a3d4ba3a4 Don't allow the learning switch to send packets back out the incoming port.
The learning switch functionality included in OpenFlow will send packets
out the port they arrived on if the learned destination is from that port.
This causes problems when newer switches flood packets for destinations they
don't know and OpenFlow reinjects packets back into the network.  The correct
behavior is to just drop the packet.
2008-07-30 00:22:52 -07:00
Ben Pfaff 5147d00489 rconn: Reconnect reliably when underlying vconn reports error.
When a vconn reports an error, the rconn would not reliably reconnect.
In particular, if the error was reported after the call to rconn_run()
but before rconn_run_wait() was called, then the state's "run" routine
would not set min_timeout properly, leading to a potentially arbitrarily
long wait (depending on what other events were going on in) until the
state's "run" routine was called again.

The fix is to have a separate per-state "timeout" routine to compute
when the state needs to be re-entered.

This commit was tested using the following change to randomly inject
errors:

@@ -554,11 +554,16 @@
 static int
 try_send(struct rconn *rc)
 {
     int retval = 0;
     struct buffer *next = rc->txq.head->next;
-    retval = vconn_send(rc->vconn, rc->txq.head);
+    if (!random_range(1000)) {
+        fprintf(stderr, "injecting ECONNRESET\n");
+        retval = ECONNRESET;
+    } else {
+        retval = vconn_send(rc->vconn, rc->txq.head);
+    }
     if (retval) {
         if (retval != EAGAIN) {
             disconnect(rc, retval);
         }
         return retval;
2008-07-28 17:31:18 -07:00
Justin Pettit 15c94784de Export the "dp_mutex" symbol, since it's needed by the hardware tables. 2008-07-28 16:08:37 -07:00
Ben Pfaff 94f903ab6b Drop unnecessary conditional and incorrect comment.
'controller_relay' is always non-null (but in an earlier revision of
the code that was never pushed to the repository, this was not the case.)
2008-07-28 15:07:24 -07:00
Ben Pfaff f873bed057 Be slightly pickier about going into fail-open mode.
Before, the amount of time disconnected was measured relative to the
last time we connected, that is, the last time connect(2) succeeded.
Thus, if we were connected for a long time, and then disconnected,
we would immediately go into fail-open mode.

This change make the disconnected time relative to the last OpenFlow
message received.  Thus, if we are connected for a long time and
receive plenty of packets, and then disconnect, there will still be
an opportunity to reconnect before failing open.
2008-07-28 07:08:38 -07:00
Ben Pfaff f12a593617 Avert GCC false-positive warning. 2008-07-28 10:11:58 -07:00
Ben Pfaff be25fa83e8 Merge branch 'locking' 2008-07-24 16:07:32 -07:00
Ben Pfaff fcb73d77bf Don't invoke Debconf from openflow-switch postinst.
This was in there because at one time it seemed desirable to configure
from the postinst, but that idea was abandoned.  Now Debconf seems to
be screwing something up somehow, so we might as well not run it at all,
since it wasn't doing anything useful.
2008-07-23 17:21:58 -07:00
Ben Pfaff 50acf79953 vlog: Reduce syslog level of VLL_EMER messages to LOG_ALERT.
The LOG_EMERG log level sprayed these messages across every xterm and
console in the system, which was excessive.
2008-07-23 17:04:24 -07:00
Ben Pfaff 42c89afbde vlog: Send multi-line log messages to syslog() one line at a time.
syslogd swallows new-lines, which makes multi-line messages otherwise
difficult to read.
2008-07-23 17:04:21 -07:00
Ben Pfaff 17778ffd72 Verify OpenFlow version number in vconn_recv(). 2008-07-23 17:04:15 -07:00
Ben Pfaff 9eb21b5b43 Fix kdist_clean target in debian/rules.
This fixes "module-assistant auto-install openflow-datapath" for
bootstrapping from a clean environment.  (Use "m-a -f purge
openflow-datapath" to test that it works starting from an un-clean
environment.)
2008-07-23 16:42:05 -07:00
Ben Pfaff 635f9e6299 Update Debconf templates PO file. 2008-07-23 14:57:22 -07:00
Ben Pfaff 228617736a Don't log messages to the console by default in Debian package. 2008-07-23 14:55:04 -07:00
Ben Pfaff 28318b5fdf Be less picky about precise name of process in init script.
The previous version always printed ERROR because for whatever reason
we were comparing "/usr/sbin/secchan" against "secchan", which of
course failed.
2008-07-23 14:55:04 -07:00
Ben Pfaff d72616d544 Only generate private key and certificate request if ssl enabled.
Generating them unconditionally caused a problem with the init script:
the script required there to be a certificate for the private key if
the private key existed, but we do want to allow TCP-only configurations
and always having a private key prevented that.

Also, give the user advice on how to deal with this problem when it
arises in the init script.
2008-07-23 14:55:04 -07:00
Ben Pfaff 5fed6531b9 Enable secchan, ofp-discover to update /etc/resolv.conf.
This way it becomes possible to more reliably refer to the controller
and the PKI server using hostnames.
2008-07-23 14:30:59 -07:00
Ben Pfaff df3a28bf74 Support controller discovery in Debian packages. 2008-07-23 13:12:23 -07:00
Ben Pfaff a1255475a4 New utility ofp-kill.
Needed for controller discovery in upcoming revision of ofp-switch-setup.
2008-07-23 13:12:23 -07:00
Ben Pfaff a412f49bb0 New function make_pidfile_name().
The upcoming ofp-kill utility wants to use this.
2008-07-23 13:12:23 -07:00
Ben Pfaff 7fbf6abfb0 secchan: Improve logging when rejecting a controller vconn. 2008-07-23 13:12:23 -07:00
Ben Pfaff dae8a4a83c Lock pidfiles with fcntl and create them atomically.
This makes it possible to verify that the program that created the
pidfile is still running.
2008-07-23 13:12:23 -07:00
Ben Pfaff 32c18a40af New program ofp-discover. 2008-07-23 13:12:21 -07:00
Ben Pfaff 85a31d495b Add SIGALRM to blockable fatal signals.
We use SIGALRM to limit runtime of dpctl and ofp-discover.  There is no
reason that we should not clean up after it in the same way as any other
catchable signal.  In particular, ofp-discover wants to restore network
device flags on timeout.
2008-07-23 13:12:17 -07:00