@@ -149,8 +149,8 @@ parse_route_from_sbrec_route(struct hmap *parsed_routes_out,
const struct hmap *lr_datapaths,
const struct sbrec_learned_route *route)
{
- const struct ovn_datapath *od = ovn_datapath_from_sbrec(
- NULL, lr_datapaths, route->datapath);
+ const struct ovn_datapath *od = ovn_datapath_from_sbrec_(
+ lr_datapaths, route->datapath);
if (!od || ovn_datapath_is_stale(od)) {
return NULL;
@@ -236,8 +236,8 @@ find_learned_route(const struct sbrec_learned_route *learned_route,
const struct ovn_datapaths *lr_datapaths,
const struct hmap *routes)
{
- const struct ovn_datapath *od = ovn_datapath_from_sbrec(
- NULL, &lr_datapaths->datapaths, learned_route->datapath);
+ const struct ovn_datapath *od = ovn_datapath_from_sbrec_(
+ &lr_datapaths->datapaths, learned_route->datapath);
if (!od) {
return NULL;
}
@@ -273,8 +273,7 @@ build_mcast_groups(struct multicast_igmp_data *data,
}
/* If the datapath value is stale, purge the group. */
- od = ovn_datapath_from_sbrec(ls_datapaths, NULL,
- sb_igmp->datapath);
+ od = ovn_datapath_from_sbrec_(ls_datapaths, sb_igmp->datapath);
if (!od || ovn_datapath_is_stale(od)) {
sbrec_igmp_group_delete(sb_igmp);
@@ -577,12 +577,30 @@ ovn_datapath_find_by_key(struct hmap *datapaths, uint32_t dp_key)
return NULL;
}
+struct ovn_datapath *
+ovn_datapath_from_sbrec_(const struct hmap *datapaths,
+ const struct sbrec_datapath_binding *sb)
+{
+ struct uuid key;
+
+ if (!uuid_from_string(&key, sb->nb_uuid)) {
+ /* This was inserted by something other than ovn-northd. */
+ return NULL;
+ }
+
+ struct ovn_datapath *od = ovn_datapath_find_(datapaths, &key);
+ if (od && (od->sb == sb)) {
+ return od;
+ }
+
+ return NULL;
+}
+
struct ovn_datapath *
ovn_datapath_from_sbrec(const struct hmap *ls_datapaths,
const struct hmap *lr_datapaths,
const struct sbrec_datapath_binding *sb)
{
- struct uuid key;
const struct hmap *dps;
if (!strcmp(sb->type, "logical-switch")) {
@@ -593,15 +611,7 @@ ovn_datapath_from_sbrec(const struct hmap *ls_datapaths,
return NULL;
}
- if (!uuid_from_string(&key, sb->nb_uuid)) {
- return NULL;
- }
- struct ovn_datapath *od = ovn_datapath_find_(dps, &key);
- if (od && (od->sb == sb)) {
- return od;
- }
-
- return NULL;
+ return ovn_datapath_from_sbrec_(dps, sb);
}
static bool
@@ -2027,8 +2037,7 @@ join_logical_ports(
struct shash_node *node;
SHASH_FOR_EACH (node, &paired_lrps->paired_router_ports) {
struct ovn_paired_logical_router_port *slrp = node->data;
- od = ovn_datapath_from_sbrec(ls_datapaths, lr_datapaths,
- slrp->router->sb);
+ od = ovn_datapath_from_sbrec_(lr_datapaths, slrp->router->sb);
if (!od) {
/* This can happen if the router is not enabled */
continue;
@@ -2047,10 +2056,10 @@ join_logical_ports(
SHASH_FOR_EACH (node, &paired_lsps->paired_switch_ports) {
struct ovn_paired_logical_switch_port *slsp = node->data;
- od = ovn_datapath_from_sbrec(ls_datapaths, lr_datapaths,
- slsp->sw->sb);
+ od = ovn_datapath_from_sbrec_(ls_datapaths, slsp->sw->sb);
ovs_assert(od);
+
join_logical_ports_lsp(ls_ports, od, slsp->nb, slsp->sb,
slsp->nb->name, queue_id_bitmap,
tag_alloc_table);
@@ -3133,7 +3142,7 @@ cleanup_mac_bindings(
const struct sbrec_mac_binding *b;
SBREC_MAC_BINDING_TABLE_FOR_EACH_SAFE (b, sbrec_mac_binding_table) {
const struct ovn_datapath *od =
- ovn_datapath_from_sbrec(NULL, lr_datapaths, b->datapath);
+ ovn_datapath_from_sbrec_(lr_datapaths, b->datapath);
if (!od || ovn_datapath_is_stale(od) ||
!ovn_port_find(lr_ports, b->logical_port)) {
@@ -18456,7 +18465,7 @@ build_ip_mcast(struct ovsdb_idl_txn *ovnsb_txn,
const struct sbrec_ip_multicast *sb;
SBREC_IP_MULTICAST_TABLE_FOR_EACH_SAFE (sb, sbrec_ip_multicast_table) {
- od = ovn_datapath_from_sbrec(ls_datapaths, NULL, sb->datapath);
+ od = ovn_datapath_from_sbrec_(ls_datapaths, sb->datapath);
if (!od || ovn_datapath_is_stale(od)) {
sbrec_ip_multicast_delete(sb);
}
@@ -445,6 +445,9 @@ struct ovn_datapath *ovn_datapath_from_sbrec(
const struct hmap *ls_datapaths, const struct hmap *lr_datapaths,
const struct sbrec_datapath_binding *);
+struct ovn_datapath *ovn_datapath_from_sbrec_(
+ const struct hmap *datapaths, const struct sbrec_datapath_binding *);
+
static inline bool
ovn_datapath_is_stale(const struct ovn_datapath *od)
{
The ovn_datapath_from_sbrec() function requires two hmaps to be passed in. It needs the hmap of logical_switches and the hmap of logical_routers. In many cases, there is only a single northbound type that we care to try to find. In this commit, we add a new version of ovn_datapath_from_sbrec() that takes a single hmap. This works because in the previous commit, we changed the southbound external_ids key to be consistent across datapath types. Since there are several places in the code that passed NULL as one of the hmap arguments to ovn_datapath_from_sbrec(), these have been converted to use ovn_datapath_from_sbrec_() instead. Signed-off-by: Mark Michelson <mmichels@redhat.com> --- northd/en-learned-route-sync.c | 8 +++---- northd/en-multicast.c | 3 +-- northd/northd.c | 41 +++++++++++++++++++++------------- northd/northd.h | 3 +++ 4 files changed, 33 insertions(+), 22 deletions(-)