On Tue, Nov 24, 2026 at 12:07 AM Rosemarie O'Riorden <[email protected]> wrote:
> It's helpful to know if a binary is compiled with or without sanitizers. > So append " ASAN" and/or " UBSAN" to the binary version when OVN was > configured with either sanitizer. > > Example compiled with both sanitizers: > $ ovn-controller --version > ovn-controller 26.09.90 ASAN UBSAN > > Or just one: > $ ovn-northd --version > ovn-northd 26.09.90 UBSAN > > This can be tested with the following command, and removing and adding > the sanitizers: > $ printf \ > '#include "include/ovn/version.h"\nOVN_PACKAGE_VERSION_DISPLAY\n' | > gcc -fsanitize=address,undefined -E - | tail -n 1 > > A new macro, OVN_PACKAGE_VERSION_DISPLAY, had to be created because > otherwise northd_internal_version would be affected. And the test [0] > was edited to make sure that the internal version never has spaces in > it, and therefore is not being generated by the new macro which is only > for --version. > > And as you can see, the internal version is unchanged: > $ ovn-sbctl get SB_Global . options:northd_internal_version > "26.09.90-21.13.0-81.16" > > Also, --with-version-suffix does not interfere. The sanitizer suffixes > always follow the entire version string. > > Also reformat the version suffix comment in acinclude.m4 to be in line > with the other functions. And add quotes around shell variable in [0]. > > [0] "check ovn-northd and ovn-controller version pinning" > > Signed-off-by: Rosemarie O'Riorden <[email protected]> > --- > v2: > - Introduced in v2. > v3: > - Move from acinclude.m4 to version.h.in. > - Only append to version string. > - Use spaces instead of dashes, and capitals instead of lowercase. > v4: > - Add OVN_PACKAGE_VERSION_DISPLAY so "ASAN"/"UBSAN" are only displayed > with > --version and do not become part of the internal version string. > - Add a check to the failing test to make sure the internal version string > never has spaces. > --- > acinclude.m4 | 2 ++ > include/ovn/version.h.in | 19 +++++++++++++++++++ > lib/ovn-util.h | 2 +- > tests/ovn.at | 3 ++- > 4 files changed, 24 insertions(+), 2 deletions(-) > > diff --git a/acinclude.m4 b/acinclude.m4 > index 82070dc52..c2acda881 100644 > --- a/acinclude.m4 > +++ b/acinclude.m4 > @@ -389,6 +389,8 @@ AC_DEFUN([OVN_ENABLE_VIF_PLUG], [ > fi > ]) > > +dnl OVN_CHECK_VERSION_SUFFIX > +dnl > dnl Append a version suffix. > AC_DEFUN([OVN_CHECK_VERSION_SUFFIX], [ > AC_ARG_WITH([version-suffix], > diff --git a/include/ovn/version.h.in b/include/ovn/version.h.in > index 5f88931b7..581687640 100644 > --- a/include/ovn/version.h.in > +++ b/include/ovn/version.h.in > @@ -18,9 +18,28 @@ > #ifndef OVN_VERSION_H > #define OVN_VERSION_H 1 > > +#ifndef __has_feature > +#define __has_feature(x) 0 > +#endif > +#if __has_feature(address_sanitizer) || defined(__SANITIZE_ADDRESS__) > +#define ASAN_SUFFIX " ASAN" > +#else > +#define ASAN_SUFFIX "" > +#endif > +#if __has_feature(undefined_behavior_sanitizer) > +#define UBSAN_SUFFIX " UBSAN" > +#else > +#define UBSAN_SUFFIX "" > +#endif > + > #define OVN_PACKAGE_STRING "@PACKAGE_STRING@" > #define OVN_PACKAGE_VERSION "@PACKAGE_VERSION@@VERSION_SUFFIX@" > > +/* For --version to display ASAN/UBSAN if compiled with sanitizers. > + * Do not use for internal version. */ > +#define OVN_PACKAGE_VERSION_DISPLAY \ > + OVN_PACKAGE_VERSION ASAN_SUFFIX UBSAN_SUFFIX > + > #define OVN_LIB_VERSION @LT_CURRENT@ > #define OVN_LIB_REVISION @LT_REVISION@ > #define OVN_LIB_AGE @LT_AGE@ > diff --git a/lib/ovn-util.h b/lib/ovn-util.h > index d8daef598..f90fb130e 100644 > --- a/lib/ovn-util.h > +++ b/lib/ovn-util.h > @@ -25,7 +25,7 @@ > #include "include/ovn/version.h" > > #define ovn_set_program_name(name) \ > - ovs_set_program_name(name, OVN_PACKAGE_VERSION) > + ovs_set_program_name(name, OVN_PACKAGE_VERSION_DISPLAY) > > #define ovn_print_version(MIN_OFP, MAX_OFP) \ > ovs_print_version(MIN_OFP, MAX_OFP) > diff --git a/tests/ovn.at b/tests/ovn.at > index 6b191624c..bf04b56c5 100644 > --- a/tests/ovn.at > +++ b/tests/ovn.at > @@ -34233,8 +34233,9 @@ wait_row_count Port_Binding 1 logical_port=sw0-p2 > chassis=$ch > > northd_version=$(ovn-sbctl get SB_Global . > options:northd_internal_version | sed s/\"//g) > echo "northd version = $northd_version" > -AT_CHECK([grep -c $northd_version hv1/ovn-controller.log], [0], [1 > +AT_CHECK([grep -c "$northd_version" hv1/ovn-controller.log], [0], [1 > ]) > +AT_CHECK([echo "$northd_version" | grep -q "\s"], [1]) > > # Stop ovn-northd so that we can modify the northd_version. > as northd > -- > 2.56.0 > > Thank you Rosemarie, applied to main. Regards, Ales _______________________________________________ dev mailing list [email protected] https://mail.openvswitch.org/mailman/listinfo/ovs-dev
