Skip to content

Commit

Permalink
northd: Preserve datapath tunnel id data in en_northd engine node.
Browse files Browse the repository at this point in the history
This is required to add I-P for logical switch and logical router
inserts.

Signed-off-by: Numan Siddique <[email protected]>
  • Loading branch information
numansiddique committed Dec 6, 2024
1 parent a099f58 commit 8cedbda
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 9 deletions.
19 changes: 10 additions & 9 deletions northd/northd.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -1029,29 +1030,28 @@ 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;
}
}

/* 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. */
Expand All @@ -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) {
Expand Down Expand Up @@ -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);
}

Expand Down Expand Up @@ -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);
}

Expand Down Expand Up @@ -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);
Expand Down
1 change: 1 addition & 0 deletions northd/northd.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 8cedbda

Please sign in to comment.