From 462abef297c6f536e3f58de565681bcf124ea107 Mon Sep 17 00:00:00 2001 From: Ethan Jackson Date: Wed, 12 Jun 2013 14:09:57 -0700 Subject: [PATCH] ofproto-dpif: Verify backer in ofport_get_peer(). This marginally simplifies the code, and removes a reference to dpif_backer from ofproto-dpif-xlate. Signed-off-by: Ethan Jackson --- 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 eb4199389..7d3a7c418 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 3033aac36..a51b60de4 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); } } -- 2.43.0