Since 6919992d8781 ("Datapath_Binding: Separate type column and sync
NB.UUID to SB."), a new type column is added to SB datapaths to
differentiate between datapath types (switch vs router). The same
commit also changed northd such that newly created SB datapaths have as
UUID the same value as the NB switch/router UUID. All SB.Datapath
records were also updated and their 'type' field populated
It also added a helper function, datapath_get_nb_uuid_and_type(), to
abstract out the extraction of a SB datapath's corresponding NB UUID and
type in the following way:
- if the SB.Datapath.type field has a value, the helper assumed that the
SB.Datapath.UUID is equal to the NB.Logical_Switch/Router.UUID so it
returned the 'type' value and the SB UUID
- else (for "old style") datapaths it extracted the NB UUID and type
from the SB.Datapath.external_ids (as used to be done before the
commit).
This creates an upgrade issue thoughi: older (already existing before
upgrade) SB datapaths are not immediately recreated and their 'type'
is set; so the NB UUID value returned by datapath_get_nb_uuid_and_type()
for these records is incorrect.
That stays like that until datapaths are finally recreated (due to other
events, e.g., full recompute of the datapath-sync nodes). All that time
the lflow manager will incorrectly determine that the existing lflows
that are stale. That's because the lflow manager uses
ovn_datapath_from_sbrec() which in turn relied on
datapath_get_nb_uuid_and_type() to determine the in-memory ovn_datapath
corresponding to the logical flow.
There's no need to avoid re-creating SB.Datapath bindings as soon as
ovn-northd determines that they're not using the new scheme. In order
to achieve that we add two sets of helpers:
a. one to be used by ovn-northd, ovn_datapath_get_nb_uuid_and_type()
which only parses the new type of datapaths (everything else, i.e.
old-style datapaths, will be considered stale)
b. one to be used by all other readers of SB datapaths (e.g.,
ovn-controller, ovn-ic), datapath_get_nb_uuid_and_type_legacy()
which relies on parsing external IDs (even in the new type of
datapaths external IDs are still populated with the NB UUID in order
to maintain backwards compatibility).
This ensures that all old-style datapaths are re-created in the first
iteration of northd that generates a SB transaction. The logical flows
and datapath groups are also re-created in the same transaction. This
essentially means that most likely ovn-controller will process these as
a single update generating an atomic bundle of OpenFlow changes thus
also avoiding traffic disruption.
Fixes: 6919992d8781 ("Datapath_Binding: Separate type column and sync NB.UUID
to SB.")
Reported-at:
https://mail.openvswitch.org/pipermail/ovs-dev/2025-August/425790.html
Reported-by: Ilya Maximets <[email protected]>
Signed-off-by: Dumitru Ceara <[email protected]>
---
lib/ovn-util.c | 27 ++++++++++-----------------
lib/ovn-util.h | 5 +++--
northd/en-datapath-sync.c | 3 ++-
northd/northd.c | 20 +++++++++++++++++++-
northd/northd.h | 4 ++++
5 files changed, 38 insertions(+), 21 deletions(-)
diff --git a/lib/ovn-util.c b/lib/ovn-util.c
index 8b583fa6d1..52144d25c2 100644
--- a/lib/ovn-util.c
+++ b/lib/ovn-util.c
@@ -1518,22 +1518,15 @@ put_load(uint64_t value, enum mf_field_id dst, size_t
ofs, size_t n_bits,
put_load_bytes(&n_value, 8, dst, ofs, n_bits, ofpacts);
}
+/* Fetch the NB UUID and type of the datapath using the "old style" of
+ * UUIDs being stored in external_ids, and key as datapath type. This only
+ * works with logical switches and logical routers. And should be used by
+ * all "non-writers" of SB datapath records (e.g., ovn-controller, ovn-ic).
+ */
bool
-datapath_get_nb_uuid_and_type(const struct sbrec_datapath_binding *sb,
- struct uuid *nb_uuid, const char **type)
-{
- if (sb->type && *sb->type) {
- /* New style. The UUID is propagated from the NB logical datapath
- * and the type is a direct column, so use those. */
- *nb_uuid = sb->header_.uuid;
- *type = sb->type;
- return true;
- }
-
- /* Old style. The UUID is stored in external_ids, and the key
- * corresponds to the datapath type. This only works with
- * logical switches and logical routers.
- */
+datapath_get_nb_uuid_and_type_legacy(const struct sbrec_datapath_binding *sb,
+ struct uuid *nb_uuid, const char **type)
+{
*type = "logical-switch";
if (smap_get_uuid(&sb->external_ids, *type, nb_uuid)) {
return true;
@@ -1552,7 +1545,7 @@ datapath_get_nb_uuid(const struct sbrec_datapath_binding
*sb,
struct uuid *nb_uuid)
{
const char *type;
- return datapath_get_nb_uuid_and_type(sb, nb_uuid, &type);
+ return datapath_get_nb_uuid_and_type_legacy(sb, nb_uuid, &type);
}
const char *
@@ -1560,7 +1553,7 @@ datapath_get_nb_type(const struct sbrec_datapath_binding
*sb)
{
const char *type;
struct uuid nb_uuid;
- datapath_get_nb_uuid_and_type(sb, &nb_uuid, &type);
+ datapath_get_nb_uuid_and_type_legacy(sb, &nb_uuid, &type);
return type;
}
diff --git a/lib/ovn-util.h b/lib/ovn-util.h
index 63beae3e5b..83efe6a410 100644
--- a/lib/ovn-util.h
+++ b/lib/ovn-util.h
@@ -552,8 +552,9 @@ void put_load(uint64_t value, enum mf_field_id dst, size_t
ofs, size_t n_bits,
#define _VFUNC(name, n) _VFUNC_(name, n)
#define VFUNC(func, ...) _VFUNC(func, __NARG__(__VA_ARGS__)) (__VA_ARGS__)
-bool datapath_get_nb_uuid_and_type(const struct sbrec_datapath_binding *sb,
- struct uuid *nb_uuid, const char **type);
+bool datapath_get_nb_uuid_and_type_legacy(
+ const struct sbrec_datapath_binding *,
+ struct uuid *nb_uuid, const char **type);
bool datapath_get_nb_uuid(const struct sbrec_datapath_binding *sb,
struct uuid *nb_uuid);
diff --git a/northd/en-datapath-sync.c b/northd/en-datapath-sync.c
index 3044f695d2..32b63f6eda 100644
--- a/northd/en-datapath-sync.c
+++ b/northd/en-datapath-sync.c
@@ -22,6 +22,7 @@
#include "en-global-config.h"
#include "datapath-sync.h"
#include "ovn-sb-idl.h"
+#include "northd.h"
#include "openvswitch/vlog.h"
#include "vec.h"
@@ -52,7 +53,7 @@ find_unsynced_datapath(const struct ovn_unsynced_datapath_map
**maps,
const char *type;
struct uuid nb_uuid;
- if (!datapath_get_nb_uuid_and_type(sb_dp, &nb_uuid, &type)) {
+ if (!ovn_datapath_get_nb_uuid_and_type(sb_dp, &nb_uuid, &type)) {
return NULL;
}
diff --git a/northd/northd.c b/northd/northd.c
index 3456e29183..12c120a2f9 100644
--- a/northd/northd.c
+++ b/northd/northd.c
@@ -609,6 +609,24 @@ ovn_datapath_find_by_key(struct hmap *datapaths, uint32_t
dp_key)
return NULL;
}
+/* Fetch the NB UUID and type of the datapath using the "new style" of
+ * UUIDs being synced from NB to SB and the type is a direct column.
+ */
+bool
+ovn_datapath_get_nb_uuid_and_type(const struct sbrec_datapath_binding *sb,
+ struct uuid *nb_uuid, const char **type)
+{
+ if (sb->type && *sb->type) {
+ *nb_uuid = sb->header_.uuid;
+ *type = sb->type;
+ return true;
+ }
+
+ *type = "";
+ *nb_uuid = UUID_ZERO;
+ return false;
+}
+
struct ovn_datapath *
ovn_datapath_from_sbrec(const struct hmap *ls_datapaths,
const struct hmap *lr_datapaths,
@@ -617,7 +635,7 @@ ovn_datapath_from_sbrec(const struct hmap *ls_datapaths,
const struct hmap *dps;
struct uuid key;
const char *type;
- if (!datapath_get_nb_uuid_and_type(sb, &key, &type)) {
+ if (!ovn_datapath_get_nb_uuid_and_type(sb, &key, &type)) {
return NULL;
}
diff --git a/northd/northd.h b/northd/northd.h
index 8f865e8b34..f42dbb7364 100644
--- a/northd/northd.h
+++ b/northd/northd.h
@@ -460,6 +460,10 @@ ovn_datapaths_find_by_index(const struct ovn_datapaths
*ovn_datapaths,
return ovn_datapaths->array[od_index];
}
+bool ovn_datapath_get_nb_uuid_and_type(const struct sbrec_datapath_binding *,
+ struct uuid *nb_uuid,
+ const char **type);
+
struct ovn_datapath *ovn_datapath_from_sbrec(
const struct hmap *ls_datapaths, const struct hmap *lr_datapaths,
const struct sbrec_datapath_binding *);
--
2.50.1
_______________________________________________
dev mailing list
[email protected]
https://mail.openvswitch.org/mailman/listinfo/ovs-dev