Skip to content

Commit

Permalink
binding.c: Missing local_datapath update in runtime_data port_binding…
Browse files Browse the repository at this point in the history
… handler.

When handling port_binding changes, it is possible that new
local_datapaths are added, and the fields of the local_datapath, such as
localnet_port, external_ports, etc. need to be updated for the newly
added local_datapaths.

This problem doesn't happen in most cases because the changes that
trigger the new local_datapath addition usually trigger recomputes,
but it may not always be the case. If recompute is not triggered,
local_datapaths are not properly updated and will result in missing OVS
flows. This is more likely to happen when we delay patch interface
deletion in the future, or if we implement patch interface I-P.

Signed-off-by: Han Zhou <[email protected]>
Acked-by: Dumitru Ceara <[email protected]>
  • Loading branch information
hzhou8 committed Aug 19, 2022
1 parent 46135d0 commit 50b3af8
Showing 1 changed file with 38 additions and 0 deletions.
38 changes: 38 additions & 0 deletions controller/binding.c
Original file line number Diff line number Diff line change
Expand Up @@ -2887,6 +2887,44 @@ binding_handle_port_binding_changes(struct binding_ctx_in *b_ctx_in,
sset_destroy(&postponed_ports);
cleanup_claimed_port_timestamps();

if (handled) {
/* There may be new local datapaths added by the above handling, so go
* through each port_binding of newly added local datapaths to update
* related local_datapaths if needed. */
struct shash bridge_mappings =
SHASH_INITIALIZER(&bridge_mappings);
add_ovs_bridge_mappings(b_ctx_in->ovs_table,
b_ctx_in->bridge_table,
&bridge_mappings);
struct tracked_datapath *t_dp;
HMAP_FOR_EACH (t_dp, node, b_ctx_out->tracked_dp_bindings) {
if (t_dp->tracked_type != TRACKED_RESOURCE_NEW) {
continue;
}
struct sbrec_port_binding *target =
sbrec_port_binding_index_init_row(
b_ctx_in->sbrec_port_binding_by_datapath);
sbrec_port_binding_index_set_datapath(target, t_dp->dp);

SBREC_PORT_BINDING_FOR_EACH_EQUAL (pb, target,
b_ctx_in->sbrec_port_binding_by_datapath) {
enum en_lport_type lport_type = get_lport_type(pb);
if (lport_type == LP_LOCALNET) {
update_ld_localnet_port(pb, &bridge_mappings,
b_ctx_out->egress_ifaces,
b_ctx_out->local_datapaths);
} else if (lport_type == LP_EXTERNAL) {
update_ld_external_ports(pb, b_ctx_out->local_datapaths);
} else if (pb->n_additional_chassis) {
update_ld_multichassis_ports(pb,
b_ctx_out->local_datapaths);
}
}
sbrec_port_binding_index_destroy_row(target);
}
shash_destroy(&bridge_mappings);
}

if (handled && qos_map_ptr && set_noop_qos(b_ctx_in->ovs_idl_txn,
b_ctx_in->port_table,
b_ctx_in->qos_table,
Expand Down

0 comments on commit 50b3af8

Please sign in to comment.