From a4454ac67c6d38740914d157f73b5083f6912172 Mon Sep 17 00:00:00 2001 From: Ethan Jackson Date: Fri, 14 Dec 2012 19:34:13 -0800 Subject: [PATCH] ofproto-dpif: Don't output to nonexistent ports. In older versions of Open vSwitch, one could reasonably predict that the datapath port number would be the same as the OpenFlow port number even for ports which may not exist yet. With the single datapath model, it's no possible longer to make this prediction. Therefore, instead of attempting to, this code simply drops packets which output to a nonexistent port. Signed-off-by: Ethan Jackson --- ofproto/ofproto-dpif.c | 34 +++++++++++++++------------------- 1 file changed, 15 insertions(+), 19 deletions(-) diff --git a/ofproto/ofproto-dpif.c b/ofproto/ofproto-dpif.c index d1064bc5a..d5155cf62 100644 --- a/ofproto/ofproto-dpif.c +++ b/ofproto/ofproto-dpif.c @@ -5384,28 +5384,24 @@ compose_output_action__(struct action_xlate_ctx *ctx, uint16_t ofp_port, uint32_t odp_port = ofp_port_to_odp_port(ctx->ofproto, ofp_port); ovs_be16 flow_vlan_tci = ctx->flow.vlan_tci; uint8_t flow_nw_tos = ctx->flow.nw_tos; + struct priority_to_dscp *pdscp; uint32_t out_port; - if (ofport) { - struct priority_to_dscp *pdscp; - - if (ofport->up.pp.config & OFPUTIL_PC_NO_FWD) { - xlate_report(ctx, "OFPPC_NO_FWD set, skipping output"); - return; - } else if (check_stp && !stp_forward_in_state(ofport->stp_state)) { - xlate_report(ctx, "STP not in forwarding state, skipping output"); - return; - } + if (!ofport) { + xlate_report(ctx, "Nonexistent output port"); + return; + } else if (ofport->up.pp.config & OFPUTIL_PC_NO_FWD) { + xlate_report(ctx, "OFPPC_NO_FWD set, skipping output"); + return; + } else if (check_stp && !stp_forward_in_state(ofport->stp_state)) { + xlate_report(ctx, "STP not in forwarding state, skipping output"); + return; + } - pdscp = get_priority(ofport, ctx->flow.skb_priority); - if (pdscp) { - ctx->flow.nw_tos &= ~IP_DSCP_MASK; - ctx->flow.nw_tos |= pdscp->dscp; - } - } else { - /* We may not have an ofport record for this port, but it doesn't hurt - * to allow forwarding to it anyhow. Maybe such a port will appear - * later and we're pre-populating the flow table. */ + pdscp = get_priority(ofport, ctx->flow.skb_priority); + if (pdscp) { + ctx->flow.nw_tos &= ~IP_DSCP_MASK; + ctx->flow.nw_tos |= pdscp->dscp; } out_port = vsp_realdev_to_vlandev(ctx->ofproto, odp_port, -- 2.47.0