Don't allow the learning switch to send packets back out the incoming port.
authorJustin Pettit <jpettit@nicira.com>
Wed, 30 Jul 2008 06:43:58 +0000 (23:43 -0700)
committerJustin Pettit <jpettit@nicira.com>
Wed, 30 Jul 2008 07:22:52 +0000 (00:22 -0700)
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.

lib/learning-switch.c

index b477e70..e3b4df5 100644 (file)
@@ -223,7 +223,11 @@ process_packet_in(struct lswitch *sw, struct rconn *rconn,
         out_port = mac_learning_lookup(sw->ml, flow.dl_dst);
     }
 
-    if (sw->max_idle >= 0 && (!sw->ml || out_port != OFPP_FLOOD)) {
+    if (in_port == out_port) {
+        /* The input port and output port match, so just drop the packet 
+         * by returning. */
+        return;
+    } else if (sw->max_idle >= 0 && (!sw->ml || out_port != OFPP_FLOOD)) {
         /* The output port is known, or we always flood everything, so add a
          * new flow. */
         queue_tx(sw, rconn, make_add_simple_flow(&flow, ntohl(opi->buffer_id),