Commit Graph
290 Commits
Author SHA1 Message Date
Ben Pfaff 16c4a745d7 Change netdev_get_in4() to re-check the IP address on each call.
As part of implementing switch stats, secchan wants to report the
IP address currently configured on an interface.  Caching it for
all time defeats that purpose.
2008-08-26 11:51:17 -07:00
Ben Pfaff 12e6e0e2dd New functions ds_truncate(), ds_last(). 2008-08-26 11:51:17 -07:00
Ben Pfaff 0415ee1ac9 New function ds_put_printable().
Use the function in dhcp_option_to_string().
2008-08-26 11:51:17 -07:00
Justin Pettit f1c6daebf3 Send PORT_STATUS messages on port and link changes. Add ability to remotely enable and disable a port through the PORT_MOD message. 2008-08-22 12:47:54 -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 95eb308262 Un-learn the port on which a MAC is located after some time.
Otherwise, we can send frames the wrong port indefinitely, if the device
in question does not itself initiate sending data.
2008-08-22 10:30:29 -07:00
Ben Pfaff 3dcacb2268 Allow and use shorthands such as "ip" or "tcp" for specifying flows. 2008-08-18 14:26:50 -07:00
Ben Pfaff 1aa7f822ed Make ofp_packet_in() print the flow corresponding to the buffer also. 2008-08-18 14:26:50 -07:00
Ben Pfaff 9630e41005 Implement subnet mask matching in OpenFlow. 2008-08-18 14:26:50 -07:00
Justin Pettit a71357e8f7 Fix dump-flows to be usable by add-flows.
Some of the fields when printing a flow are hex, but they don't have a
preceeding "0x".  When one tries to import them, they're treated as decimal
and weird results occur.  Bug 27.
2008-08-17 23:17:07 -07:00
Justin Pettit d6a1e67a8d Add stats message that allows querying description of components in OpenFlow. 2008-08-16 09:43:05 -07:00
Justin Pettit b41a6a0a6d Added new interface statistics. 2008-08-14 23:12:37 -07:00
Ben Pfaff 9159ab1402 Fix vlogconf EINTR error returns.
Bug #111.
2008-08-14 16:18:46 -07:00
Ben Pfaff 3b0470d419 Use proper byte order for dl_type of 802.2, non-SNAP frames. 2008-08-14 11:06:18 -07:00
Justin Pettit 0226bbc742 Switch to new packet-out format and add OFPP_IN_PORT.
The original packet-out format allowed multiple actions to be specified for
buffered packets, but only a destination port for messages including data.
This change makes packet-out more consistent by allowing multiple actions
regardless of how the packet is stored.

This change also disallows sending packets through the incoming port without
explicitly using the OFPP_IN_PORT virtual port.
2008-08-14 00:07:18 -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 72984bb5e9 Make discovery happen faster.
This reduces the initial delay before sending DHCPDISCOVER from
1...10 seconds to 1...3 seconds.
2008-08-12 16:10:01 -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 a837a38209 Implement signal-driven time tracking.
Checking the current time only when a periodic timer expires allows us
to reduce the number of system calls to obtain the current time to 10 per
second (from an arbitrary number) plus one per poll loop.

This fixes poll_block() to properly handle being interrupted.
Otherwise, a timeout longer than the interval between signals will never
complete (because it will restart from the beginning after every
signal).
2008-08-12 15:21:30 -07:00
Ben Pfaff b67da66b07 Make fatal-signal more willing to share signals with other handlers. 2008-08-12 14:24:22 -07:00
Ben Pfaff 57fb2fe378 Set up flow to drop packets that come in on their output port.
Commit 0a3d4ba3a, "Don't allow the learning switch to send packets back
out the incoming port," drops packets that come in on their incoming port,
but it does not set up a flow to drop those packets.  If we are connected
to a hub, then this can be very expensive, since we can continue to get
many packets in that flow and have to drop them in secchan one by one.  So
now we set up a flow to drop them for us.
2008-08-08 15:39:20 -07:00
Ben Pfaff 37dc29f930 Make vconn_open() consistently set *vconnp to NULL on failure.
Fixes issue #80.
2008-08-07 15:37:44 -07:00
Ben Pfaff 7bee00fad9 Implement OpenFlow hard timeouts.
This updates the OpenFlow protocol version and changes the names of
structure members, so any software that uses OpenFlow will need to be
updated to match.
2008-08-07 15:19:31 -07:00
Ben Pfaff 1c6aac2d04 Fix formatting of flow matches in ofp-print:
Print a comma after wildcard matches as well as exact matches.
2008-08-07 13:29:10 -07:00
Ben Pfaff eca2aeb329 Implement OFPC_FRAG_DROP fragment handling policy. 2008-08-07 10:34:37 -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
Ben Pfaff 4c4238cacf Mark functions not used in other source files static. 2008-08-04 14:47:27 -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 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 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 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
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
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 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