Commit Graph
43 Commits
Author SHA1 Message Date
Ben Pfaff 6b617bac12 Move exported headers to include/openflow, private headers to lib/.
This makes it easier to install the headers, or to use them directly from
another software package with -I$(openflow)/include, without invading
the top-level include file namespace.
2008-10-29 15:15:45 -07:00
Ben Pfaff bb7c717c31 rconn: Never report being in failure mode while connected.
Change e10dfcf35, "rconn: Be pickier about what constitutes a successful
connection," caused rconn to consider the connection to have failed even
when we are actually connected until one of several message types was
received.  Unfortunately, that meant that "fail open" would intercept and
discard all messages sent by the controller until one of those messages
was received.  Thus, the controller would never receive a reply to its
feature_request, assume that the connection was busted, and disconnect.
This happened forever, of course.

Fixes bug #242.

Thanks to Reid for reporting this and Dan for help in diagnosis.
2008-10-13 13:56:26 -07:00
Ben Pfaff 0b99d8d4be rconn: Improve log message when peer closes connection. 2008-10-13 13:51:50 -07:00
Ben Pfaff e10dfcf357 rconn: Be pickier about what constitutes a successful connection.
When secchan is configured to "fail open" after failing to connect to
a controller for a period of time, it needs a heuristic for what
constitutes a successful connection.  Until now, that heuristic was
simply that when it received an OpenFlow message from the controller
(any OpenFlow message), it considered the connection successful.

However, this is no longer good enough, because NOX performs
admission control on connections after sending a number of OpenFlow
messages, in particular after doing OpenFlow version negotiation and
requesting the switch features (and receiving the reply).  Thus, this
commit adjusts the heuristic by only considering certain OpenFlow
messages to demonstrate that admission control checks have passed and
thus that the connection should be considered successful.

As a fallback, any connection that persists for 30 seconds or longer is
also considered successful.

An alternate and complementary approach (that this commit does not
implement) would be to use an OpenFlow error message to indicate why
the connection is closing.

Fixes bug #239.
2008-10-10 10:13:12 -07:00
Ben Pfaff cd13e4cbc5 Make rconn_disconnect() a no-op if already disconnected. 2008-10-09 15:53:05 -07:00
Ben Pfaff 03a3cc1e3d Fix failure to back off when vconn_open() fails immediately.
This typically would happen only with an entirely local vconn,
e.g. connecting to a Unix domain socket vconn.
2008-09-18 09:48:37 -07:00
Ben Pfaff f593e3ab70 Merge branch "partner", to simplify partner integration. 2008-09-15 15:31:36 -07:00
Ben Pfaff 9c1b16772c Implement OFPT_HELLO simple version negotiation. 2008-09-15 14:29:53 -07:00
Ben Pfaff 553dfa572d Break passive vconns out into separate pvconn routines and data structures.
There really was nothing in common between the active and passive vconns.
This arrangement makes more sense.
2008-09-15 14:29:53 -07:00
Ben Pfaff b5bcab1b47 Add ability to monitor both ends of secchan connections from dpctl. 2008-09-08 10:05:13 -07:00
Ben Pfaff c572b9a572 Fix typo in comment. 2008-09-04 14:24:45 -07:00
Ben Pfaff c5e61793e9 Drop unneeded inclusions of ofp-print.h. 2008-09-04 13:53:27 -07:00
Ben Pfaff eb0341e711 Rename utility functions to avoid partner namespace conflicts. 2008-09-04 13:53:27 -07:00
Ben Pfaff 2c775287e2 Rename struct queue to struct ofp_queue.
Fixes namespace conflict for partner development.
2008-09-04 13:53:26 -07:00
Ben Pfaff 5549180a54 Rename struct buffer to struct ofpbuf.
Fixes namespace conflict for partner development.
2008-09-04 13:53:26 -07:00
Ben Pfaff 686e34c8b7 Make the secchan report a few more switch-status items. 2008-08-28 14:25:05 -07:00
Ben Pfaff 394270a0e5 New header for saturating arithmetic. 2008-08-26 12:04:41 -07:00
Ben Pfaff b057b10a74 rconn: Add functions for reporting connection statistics. 2008-08-26 11:51:17 -07:00
Ben Pfaff 8f133305af rconn: Fix bug #100, "Inactivity time-out slow under heavy load."
The timeout() function returns a duration relative to the time at which the
current state was entered, but rconn_run_wait() was treating it as the
waiting time remaining.
2008-08-22 10:34:15 -07:00
Ben Pfaff 9bff3b7f01 rconn: Wake up immediately if we drain the send queue.
It is possible that some task is waiting for space to open up in the
send queue, so we need to give it a chance to run.
2008-08-13 11:30:31 -07:00
Ben Pfaff b749bdfaf5 rconn: Use rconn_send() to send echo requests.
There's no point in sending echo requests by hand.
2008-08-13 11:26:26 -07:00
Ben Pfaff cd3ac840dd rconn: Queue packets for tx only if connected.
Until now, the rconn code would queue up packets not just while connected
but also while connecting.  This is not just unnecessary, however, it
actually causes a problem in secchan: if the secchan receives packets
from nl:0 and tries to transmit them, then they will quickly fill up
the rconn's transmit buffer (it uses a 1-packet buffer), which causes
secchan to stop reading packets from nl:0 until the buffer frees up.
That cannot happen until the connection completes.  With in-band control,
however, the connection cannot complete until we receive and process
packet_in messages in our in-band hook.  Thus, we have a deadlock.

Fixes bug #90, "Sometimes secchan has to go into fail-open mode to connect."
2008-08-13 11:21:49 -07:00
Ben Pfaff 903d0940fb Drop rconn's responsibility for limiting the tx queue.
Now it helps clients track the number of in-flight messages, but lets the
clients do the limiting themselves.  This will come in handy for packet-in
rate limiting (in an upcoming commit), in which we want to track in-flight
packet-in messages separately from other in-flight messages.
2008-08-12 15:21:30 -07:00
Ben Pfaff b3b28afb7b Use signal-based timekeeping functions throughout the source base. 2008-08-12 15:21:30 -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
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 f730dded18 Move Autoconf's macro definitions into config.h.
This makes "make" output slightly more readable.
2008-07-21 15:05:53 -07:00
Ben Pfaff d838ee2e03 vconn: Make errors in vconn names non-fatal errors.
This prevents bad vconn names obtained via discovery from killing
the secure channel.
2008-07-18 14:16:40 -07:00
Ben Pfaff c57a8d1089 rconn: Add questionability. 2008-07-18 14:07:03 -07:00
Ben Pfaff b8769714c1 rconn: Rewrite to use explicit state machine. 2008-07-18 14:07:03 -07:00
Ben Pfaff 453084ed49 rconn: Push detection of send errors into try_send().
Thereby, we correct a bug in do_send(), one of the callers of try_send(),
which was not checking the try_send() return value.
2008-07-18 14:07:03 -07:00
Ben Pfaff b0533159ba rconn: Time out connection attempts when the backoff deadline passes.
Otherwise, the TCP/IP implementation is responsible for connection
attempt backoff, but we want to have some control over it ourselves.
In particular we want to initially back off faster and to log a
message upon connection attempt retransmission, to make it easier
to see what has happened from the log.
2008-07-18 14:07:03 -07:00
Ben Pfaff 06aa679e95 rconn: Log when a connection attempt starts.
This makes it easier to see what happened by viewing the log.
2008-07-18 14:07:03 -07:00
Ben Pfaff e334e4e0e7 rconn: Add new max_backoff argument to rconn_new().
This allows the caller more control over reconnection backoff.
2008-07-18 14:07:03 -07:00
Ben Pfaff 2bc1162f6f Fix behavior when system date is negative.
Previously we set a few timers to expire at a time_t of 0, i.e.
immediately.  But if the system date is set incorrectly to a date
before 1970, then these timers will essentially never expire.
Set them to expire at TIME_MIN instead.
2008-07-18 13:24:16 -07:00
Ben Pfaff 4532f9cdfb New function rconn_get_ip(). 2008-07-18 13:23:23 -07:00
Ben Pfaff d6ef9d8ade Fix typo in comment. 2008-07-03 14:11:03 -07:00
Ben Pfaff bebf175930 Make the secure channel and controller send out keepalives.
It can happen that the secure channel thinks that it is connected
to the controller, but in fact the connection has dropped.  For
example, a switch intermediate between the secure channel and the
controller could have a flow inserted, due to a malfunction, that
causes packets in one direction or the other to be dropped.  When
this happens, the Linux kernel's TCP implementation will continue
retransmitting packets for somewhere between 13 and 30 minutes,
depending on the connection's retransmission timeout (according
to linux/Documentation/networking/ip-sysctl.txt) with the default
Linux settings.

We want to detect the lost connection and re-connect much faster
than that.  We use OpenFlow echo request and reply messages: if
no message is received from the controller for N seconds, we
send out an echo request.  If no reply (actually, any message at
all) is received for an additional N seconds, then we assume
that the connection has been lost, and reconnect.
2008-07-01 11:14:45 -07:00
Ben Pfaff 7b351ea076 Factor learning switch out of controller into library.
This prepares for adding "fail-open" support to the secchan, which
will require the secchan to act as a learning switch.
2008-06-09 10:27:49 -07:00
Ben Pfaff b2f43905ea Make in-band communication work. 2008-05-28 10:46:54 -07:00
Ben Pfaff 3b9c97ee01 Implement new statistics format in kernel and userspace switches.
This change really cuts the muster!
2008-05-01 17:04:44 -07:00
Ben Pfaff 1daf19850e Initialize rconn "connected" member.
Found by valgrind.
2008-05-01 17:02:31 -07:00
Ben Pfaff 14da11884d Rename controller_connection to rconn and use it in secchan also.
Also, clean up code and add comments.
2008-04-04 16:20:55 -07:00