From 8cedbda08672a61f3c8cbce817c65331ea21b8ef Mon Sep 17 00:00:00 2001 From: Numan Siddique Date: Thu, 24 Oct 2024 21:30:56 -0400 Subject: [PATCH] northd: Preserve datapath tunnel id data in en_northd engine node. This is required to add I-P for logical switch and logical router inserts. Signed-off-by: Numan Siddique --- northd/northd.c | 19 ++++++++++--------- northd/northd.h | 1 + 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/northd/northd.c b/northd/northd.c index 3a488ff3d7..fc14e8ef3c 100644 --- a/northd/northd.c +++ b/northd/northd.c @@ -1020,7 +1020,8 @@ build_datapaths(struct ovsdb_idl_txn *ovnsb_txn, const struct sbrec_datapath_binding_table *sbrec_dp_table, struct ovn_datapaths *ls_datapaths, struct ovn_datapaths *lr_datapaths, - struct ovs_list *lr_list) + struct ovs_list *lr_list, + struct hmap *dp_tnlids) { struct ovs_list sb_only, nb_only, both; @@ -1029,18 +1030,17 @@ build_datapaths(struct ovsdb_idl_txn *ovnsb_txn, datapaths, &sb_only, &nb_only, &both, lr_list); /* Assign explicitly requested tunnel ids first. */ - struct hmap dp_tnlids = HMAP_INITIALIZER(&dp_tnlids); struct ovn_datapath *od; LIST_FOR_EACH (od, list, &both) { - ovn_datapath_assign_requested_tnl_id(&dp_tnlids, od); + ovn_datapath_assign_requested_tnl_id(dp_tnlids, od); } LIST_FOR_EACH (od, list, &nb_only) { - ovn_datapath_assign_requested_tnl_id(&dp_tnlids, od); + ovn_datapath_assign_requested_tnl_id(dp_tnlids, od); } /* Keep nonconflicting tunnel IDs that are already assigned. */ LIST_FOR_EACH (od, list, &both) { - if (!od->tunnel_key && ovn_add_tnlid(&dp_tnlids, od->sb->tunnel_key)) { + if (!od->tunnel_key && ovn_add_tnlid(dp_tnlids, od->sb->tunnel_key)) { od->tunnel_key = od->sb->tunnel_key; } } @@ -1048,10 +1048,10 @@ build_datapaths(struct ovsdb_idl_txn *ovnsb_txn, /* Assign new tunnel ids where needed. */ uint32_t hint = 0; LIST_FOR_EACH_SAFE (od, list, &both) { - ovn_datapath_allocate_key(datapaths, &dp_tnlids, od, &hint); + ovn_datapath_allocate_key(datapaths, dp_tnlids, od, &hint); } LIST_FOR_EACH_SAFE (od, list, &nb_only) { - ovn_datapath_allocate_key(datapaths, &dp_tnlids, od, &hint); + ovn_datapath_allocate_key(datapaths, dp_tnlids, od, &hint); } /* Sync tunnel ids from nb to sb. */ @@ -1066,7 +1066,6 @@ build_datapaths(struct ovsdb_idl_txn *ovnsb_txn, ovn_datapath_update_external_ids(od); sbrec_datapath_binding_set_tunnel_key(od->sb, od->tunnel_key); } - ovn_destroy_tnlids(&dp_tnlids); /* Delete southbound records without northbound matches. */ LIST_FOR_EACH_SAFE (od, list, &sb_only) { @@ -18890,6 +18889,7 @@ northd_init(struct northd_data *data) ovs_list_init(&data->lr_list); sset_init(&data->svc_monitor_lsps); hmap_init(&data->svc_monitor_map); + hmap_init(&data->dp_tnlids); init_northd_tracked_data(data); } @@ -18956,6 +18956,7 @@ northd_destroy(struct northd_data *data) &data->lr_list); sset_destroy(&data->svc_monitor_lsps); + ovn_destroy_tnlids(&data->dp_tnlids); destroy_northd_tracked_data(data); } @@ -19044,7 +19045,7 @@ ovnnb_db_run(struct northd_input *input_data, input_data->nbrec_logical_router_table, input_data->sbrec_datapath_binding_table, &data->ls_datapaths, - &data->lr_datapaths, &data->lr_list); + &data->lr_datapaths, &data->lr_list, &data->dp_tnlids); build_lb_datapaths(input_data->lbs, input_data->lbgrps, &data->ls_datapaths, &data->lr_datapaths, &data->lb_datapaths_map, &data->lb_group_datapaths_map); diff --git a/northd/northd.h b/northd/northd.h index d60c944df4..198b9f2270 100644 --- a/northd/northd.h +++ b/northd/northd.h @@ -165,6 +165,7 @@ struct northd_data { struct ovs_list lr_list; struct sset svc_monitor_lsps; struct hmap svc_monitor_map; + struct hmap dp_tnlids; /* Change tracking data. */ struct northd_tracked_data trk_data;