From: Numan Siddique <num...@ovn.org> Some of the OF flows added by physical.c in tables LOCAL_OUTPUT, CHECK_LOOPBACK, SAVE_INPORT can store the port binding uuid as flow cookie because these flows matches on port binding key in the MFF_LOG_OUTPORT field. Whereas right now it stores 0 as cookie.
This patch stores the port binding uuid as cookie for these flows. When a port binding is deleted, the port binding handler for flow_output engine node flood removes the flows with the port binding uuid and such flows wont get removed. Right now this is not a problem because deleting a port binding also triggers in physical_run() being called and it recomputes all the physical flows. This patch is required for an upcoming patch which do not call physical_run() for port binding deletes. Signed-off-by: Numan Siddique <num...@ovn.org> --- controller/physical.c | 44 ++++++++++++++++++++++++------------------- 1 file changed, 25 insertions(+), 19 deletions(-) diff --git a/controller/physical.c b/controller/physical.c index e70efc71d..17ca5afbb 100644 --- a/controller/physical.c +++ b/controller/physical.c @@ -739,20 +739,23 @@ put_replace_router_port_mac_flows(struct ovsdb_idl_index } static void -put_local_common_flows(uint32_t dp_key, uint32_t port_key, - uint32_t parent_port_key, +put_local_common_flows(uint32_t dp_key, + const struct sbrec_port_binding *pb, + const struct sbrec_port_binding *parent_pb, const struct zone_ids *zone_ids, struct ofpbuf *ofpacts_p, struct ovn_desired_flow_table *flow_table) { struct match match; - /* Table 33, priority 100. + uint32_t port_key = pb->tunnel_key; + + /* Table 38, priority 100. * ======================= * * Implements output to local hypervisor. Each flow matches a * logical output port on the local hypervisor, and resubmits to - * table 34. + * table 39. */ match_init_catchall(&match); @@ -774,12 +777,13 @@ put_local_common_flows(uint32_t dp_key, uint32_t port_key, } } - /* Resubmit to table 34. */ + /* Resubmit to table 39. */ put_resubmit(OFTABLE_CHECK_LOOPBACK, ofpacts_p); - ofctrl_add_flow(flow_table, OFTABLE_LOCAL_OUTPUT, 100, 0, - &match, ofpacts_p, hc_uuid); + ofctrl_add_flow(flow_table, OFTABLE_LOCAL_OUTPUT, 100, + pb->header_.uuid.parts[0], &match, ofpacts_p, + &pb->header_.uuid); - /* Table 34, Priority 100. + /* Table 39, Priority 100. * ======================= * * Drop packets whose logical inport and outport are the same @@ -791,8 +795,9 @@ put_local_common_flows(uint32_t dp_key, uint32_t port_key, 0, MLF_ALLOW_LOOPBACK); match_set_reg(&match, MFF_LOG_INPORT - MFF_REG0, port_key); match_set_reg(&match, MFF_LOG_OUTPORT - MFF_REG0, port_key); - ofctrl_add_flow(flow_table, OFTABLE_CHECK_LOOPBACK, 100, 0, - &match, ofpacts_p, hc_uuid); + ofctrl_add_flow(flow_table, OFTABLE_CHECK_LOOPBACK, 100, + pb->header_.uuid.parts[0], &match, ofpacts_p, + &pb->header_.uuid); /* Table 64, Priority 100. * ======================= @@ -806,7 +811,7 @@ put_local_common_flows(uint32_t dp_key, uint32_t port_key, * table 65 for logical-to-physical translation, then restore * the port number. * - * If 'parent_port_key' is set, then the 'port_key' represents a nested + * If 'parent_pb' is not NULL, then the 'pb' represents a nested * container. * * Note:We can set in_port to 0 too. But if recirculation happens @@ -815,7 +820,7 @@ put_local_common_flows(uint32_t dp_key, uint32_t port_key, * in_port is 0. * */ - bool nested_container = parent_port_key ? true: false; + bool nested_container = parent_pb ? true: false; match_init_catchall(&match); ofpbuf_clear(ofpacts_p); match_set_metadata(&match, htonll(dp_key)); @@ -829,8 +834,9 @@ put_local_common_flows(uint32_t dp_key, uint32_t port_key, put_load(ofp_to_u16(OFPP_NONE), MFF_IN_PORT, 0, 16, ofpacts_p); put_resubmit(OFTABLE_LOG_TO_PHY, ofpacts_p); put_stack(MFF_IN_PORT, ofpact_put_STACK_POP(ofpacts_p)); - ofctrl_add_flow(flow_table, OFTABLE_SAVE_INPORT, 100, 0, - &match, ofpacts_p, hc_uuid); + ofctrl_add_flow(flow_table, OFTABLE_SAVE_INPORT, 100, + pb->header_.uuid.parts[0], &match, ofpacts_p, + &pb->header_.uuid); if (nested_container) { /* It's a nested container and when the packet from the nested @@ -852,7 +858,8 @@ put_local_common_flows(uint32_t dp_key, uint32_t port_key, match_init_catchall(&match); ofpbuf_clear(ofpacts_p); match_set_metadata(&match, htonll(dp_key)); - match_set_reg(&match, MFF_LOG_OUTPORT - MFF_REG0, parent_port_key); + match_set_reg(&match, MFF_LOG_OUTPORT - MFF_REG0, + parent_pb->tunnel_key); match_set_reg_masked(&match, MFF_LOG_FLAGS - MFF_REG0, MLF_NESTED_CONTAINER, MLF_NESTED_CONTAINER); @@ -941,7 +948,7 @@ consider_port_binding(struct ovsdb_idl_index *sbrec_port_binding_by_name, } struct zone_ids binding_zones = get_zone_ids(binding, ct_zones); - put_local_common_flows(dp_key, port_key, 0, &binding_zones, + put_local_common_flows(dp_key, binding, NULL, &binding_zones, ofpacts_p, flow_table); match_init_catchall(&match); @@ -1141,10 +1148,9 @@ consider_port_binding(struct ovsdb_idl_index *sbrec_port_binding_by_name, */ struct zone_ids zone_ids = get_zone_ids(binding, ct_zones); - uint32_t parent_port_key = parent_port ? parent_port->tunnel_key : 0; - /* Pass the parent port tunnel key if the port is a nested + /* Pass the parent port binding if the port is a nested * container. */ - put_local_common_flows(dp_key, port_key, parent_port_key, &zone_ids, + put_local_common_flows(dp_key, binding, parent_port, &zone_ids, ofpacts_p, flow_table); /* Table 0, Priority 150 and 100. -- 2.31.1 _______________________________________________ dev mailing list d...@openvswitch.org https://mail.openvswitch.org/mailman/listinfo/ovs-dev