ofproto-dpif: Verify backer in ofport_get_peer().
authorEthan Jackson <ethan@nicira.com>
Wed, 12 Jun 2013 21:09:57 +0000 (14:09 -0700)
committerEthan Jackson <ethan@nicira.com>
Wed, 12 Jun 2013 22:29:00 +0000 (15:29 -0700)
This marginally simplifies the code, and removes a reference to
dpif_backer from ofproto-dpif-xlate.

Signed-off-by: Ethan Jackson <ethan@nicira.com>
ofproto/ofproto-dpif-xlate.c
ofproto/ofproto-dpif.c

index eb41993..7d3a7c4 100644 (file)
@@ -816,7 +816,6 @@ compose_output_action__(struct xlate_ctx *ctx, uint16_t ofp_port,
     if (netdev_vport_is_patch(ofport->up.netdev)) {
         struct ofport_dpif *peer = ofport_get_peer(ofport);
         struct flow old_flow = ctx->xin->flow;
-        const struct ofproto_dpif *peer_ofproto;
         enum slow_path_reason special;
         struct ofport_dpif *in_port;
 
@@ -825,12 +824,6 @@ compose_output_action__(struct xlate_ctx *ctx, uint16_t ofp_port,
             return;
         }
 
-        peer_ofproto = ofproto_dpif_cast(peer->up.ofproto);
-        if (peer_ofproto->backer != ctx->ofproto->backer) {
-            xlate_report(ctx, "Patch port peer on a different datapath");
-            return;
-        }
-
         ctx->ofproto = ofproto_dpif_cast(peer->up.ofproto);
         flow->in_port = peer->up.ofp_port;
         flow->metadata = htonll(0);
index 3033aac..a51b60d 100644 (file)
@@ -2737,6 +2737,7 @@ struct ofport_dpif *
 ofport_get_peer(const struct ofport_dpif *ofport_dpif)
 {
     const struct ofproto_dpif *ofproto;
+    const struct dpif_backer *backer;
     const char *peer;
 
     peer = netdev_vport_patch_peer(ofport_dpif->up.netdev);
@@ -2744,11 +2745,16 @@ ofport_get_peer(const struct ofport_dpif *ofport_dpif)
         return NULL;
     }
 
+    backer = ofproto_dpif_cast(ofport_dpif->up.ofproto)->backer;
     HMAP_FOR_EACH (ofproto, all_ofproto_dpifs_node, &all_ofproto_dpifs) {
         struct ofport *ofport;
 
+        if (ofproto->backer != backer) {
+            continue;
+        }
+
         ofport = shash_find_data(&ofproto->up.port_by_name, peer);
-        if (ofport && ofport->ofproto->ofproto_class == &ofproto_dpif_class) {
+        if (ofport) {
             return ofport_dpif_cast(ofport);
         }
     }