[ovs-dev] [backer v2 2/3] ofproto-dpif: Verify backer in ofport_get_peer().

Ethan Jackson ethan at nicira.com
Wed Jun 12 21:45:48 UTC 2013


This marginally simplifies the code, and removes a reference to
dpif_backer from ofproto-dpif-xlate.

Signed-off-by: Ethan Jackson <ethan at nicira.com>
---
 ofproto/ofproto-dpif-xlate.c |    7 -------
 ofproto/ofproto-dpif.c       |    8 +++++++-
 2 files changed, 7 insertions(+), 8 deletions(-)

diff --git a/ofproto/ofproto-dpif-xlate.c b/ofproto/ofproto-dpif-xlate.c
index eb41993..7d3a7c4 100644
--- a/ofproto/ofproto-dpif-xlate.c
+++ b/ofproto/ofproto-dpif-xlate.c
@@ -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);
diff --git a/ofproto/ofproto-dpif.c b/ofproto/ofproto-dpif.c
index 3033aac..a51b60d 100644
--- a/ofproto/ofproto-dpif.c
+++ b/ofproto/ofproto-dpif.c
@@ -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);
         }
     }
-- 
1.7.9.5




More information about the dev mailing list