Skip to content

Commit 4fa1ef4

Browse files
authored
PCD-8825: ignoring PF9 build/patch numbers don't count as a mismatch (#20)
1 parent d8446f6 commit 4fa1ef4

1 file changed

Lines changed: 43 additions & 3 deletions

File tree

controller/ovn-controller.c

Lines changed: 43 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5140,8 +5140,38 @@ pflow_lflow_output_sb_chassis_handler(struct engine_node *node,
51405140
return true;
51415141
}
51425142

5143+
/* PF9 start */
5144+
/* Returns a newly allocated string with the PF9-specific ".pf9.<...>"
5145+
* build sub-version stripped out of an OVN internal version string, e.g.
5146+
* "24.03.6.pf9.2026.4.0.385-20.33.0-76.8" -> "24.03.6-20.33.0-76.8".
5147+
* If no ".pf9" marker is found, returns an unmodified copy. The caller
5148+
* must free the returned value. */
5149+
static char *
5150+
ovn_version_base(const char *version)
5151+
{
5152+
const char *pf9_marker = strstr(version, ".pf9");
5153+
if (!pf9_marker) {
5154+
return xstrdup(version);
5155+
}
5156+
5157+
const char *suffix = strchr(pf9_marker, '-');
5158+
size_t prefix_len = pf9_marker - version;
5159+
size_t suffix_len = suffix ? strlen(suffix) : 0;
5160+
5161+
char *base = xmalloc(prefix_len + suffix_len + 1);
5162+
memcpy(base, version, prefix_len);
5163+
if (suffix) {
5164+
memcpy(base + prefix_len, suffix, suffix_len);
5165+
}
5166+
base[prefix_len + suffix_len] = '\0';
5167+
return base;
5168+
}
5169+
/* PF9 end */
5170+
51435171
/* Returns false if the northd internal version stored in SB_Global
5144-
* and ovn-controller internal version don't match.
5172+
* and ovn-controller internal version don't match, ignoring the
5173+
* PF9-specific ".pf9.<...>" build sub-version on either side so that
5174+
* differing PF9 build/patch numbers don't count as a mismatch.
51455175
*/
51465176
static bool
51475177
check_northd_version(struct ovsdb_idl *ovs_idl, struct ovsdb_idl *ovnsb_idl,
@@ -5169,13 +5199,23 @@ check_northd_version(struct ovsdb_idl *ovs_idl, struct ovsdb_idl *ovnsb_idl,
51695199
const char *northd_version =
51705200
smap_get_def(&sb->options, "northd_internal_version", "");
51715201

5172-
if (strcmp(northd_version, version)) {
5202+
/* PF9 start */
5203+
char *version_base = ovn_version_base(version);
5204+
char *northd_version_base = ovn_version_base(northd_version);
5205+
bool mismatch = strcmp(northd_version_base, version_base);
5206+
5207+
if (mismatch) {
51735208
static struct vlog_rate_limit rl = VLOG_RATE_LIMIT_INIT(1, 1);
51745209
VLOG_WARN_RL(&rl, "controller version - %s mismatch with northd "
5175-
"version - %s", version, northd_version);
5210+
"version - %s", version_base, northd_version_base);
5211+
free(version_base);
5212+
free(northd_version_base);
51765213
version_mismatch = true;
51775214
return false;
51785215
}
5216+
free(version_base);
5217+
free(northd_version_base);
5218+
/* PF9 end */
51795219

51805220
/* If there used to be a mismatch and ovn-northd got updated, force a
51815221
* full recompute.

0 commit comments

Comments
 (0)