datapath: add skb mark matching and set action
[openvswitch] / lib / learning-switch.c
index e4287c4e31f605a690bf3ff0cc4865d2ba5433af..5df05f35c9b38843dc2f0c016df3a8fd5d920133 100644 (file)
@@ -200,15 +200,19 @@ lswitch_handshake(struct lswitch *sw)
                 error = rconn_send(sw->rconn, msg, NULL);
             }
         }
+        if (protocol & usable_protocols) {
+            for (i = 0; !error && i < sw->n_default_flows; i++) {
+                msg = ofputil_encode_flow_mod(&sw->default_flows[i], protocol);
+                error = rconn_send(sw->rconn, msg, NULL);
+            }
 
-        for (i = 0; !error && i < sw->n_default_flows; i++) {
-            msg = ofputil_encode_flow_mod(&sw->default_flows[i], protocol);
-            error = rconn_send(sw->rconn, msg, NULL);
-        }
-
-        if (error) {
-            VLOG_INFO_RL(&rl, "%s: failed to queue default flows (%s)",
-                         rconn_get_name(sw->rconn), strerror(error));
+            if (error) {
+                VLOG_INFO_RL(&rl, "%s: failed to queue default flows (%s)",
+                             rconn_get_name(sw->rconn), strerror(error));
+            }
+        } else {
+            VLOG_INFO_RL(&rl, "%s: failed to set usable protocol",
+                         rconn_get_name(sw->rconn));
         }
     }
     sw->protocol = protocol;
@@ -535,7 +539,8 @@ process_packet_in(struct lswitch *sw, const struct ofp_header *oh)
 
     /* Extract flow data from 'opi' into 'flow'. */
     ofpbuf_use_const(&pkt, pi.packet, pi.packet_len);
-    flow_extract(&pkt, 0, pi.fmd.tun_id, pi.fmd.in_port, &flow);
+    flow_extract(&pkt, 0, 0, NULL, pi.fmd.in_port, &flow);
+    flow.tunnel.tun_id = pi.fmd.tun_id;
 
     /* Choose output port. */
     out_port = lswitch_choose_destination(sw, &flow);
@@ -575,7 +580,9 @@ process_packet_in(struct lswitch *sw, const struct ofp_header *oh)
         /* The output port is known, or we always flood everything, so add a
          * new flow. */
         memset(&fm, 0, sizeof fm);
-        cls_rule_init(&flow, &sw->wc, 0, &fm.cr);
+        match_init(&fm.match, &flow, &sw->wc);
+        ofputil_normalize_match_quiet(&fm.match);
+        fm.priority = 0;
         fm.table_id = 0xff;
         fm.command = OFPFC_ADD;
         fm.idle_timeout = sw->max_idle;
@@ -589,13 +596,13 @@ process_packet_in(struct lswitch *sw, const struct ofp_header *oh)
 
         /* If the switch didn't buffer the packet, we need to send a copy. */
         if (pi.buffer_id == UINT32_MAX && out_port != OFPP_NONE) {
-            queue_tx(sw, ofputil_encode_packet_out(&po));
+            queue_tx(sw, ofputil_encode_packet_out(&po, sw->protocol));
         }
     } else {
         /* We don't know that MAC, or we don't set up flows.  Send along the
          * packet without setting up a flow. */
         if (pi.buffer_id != UINT32_MAX || out_port != OFPP_NONE) {
-            queue_tx(sw, ofputil_encode_packet_out(&po));
+            queue_tx(sw, ofputil_encode_packet_out(&po, sw->protocol));
         }
     }
 }