])
], [[#include <libyang/libyang.h>]])
+ac_ld_flag_save="$LDFLAGS"
+LDFLAGS="$LDFLAGS $libyang_LIBS"
+AC_CHECK_FUNC([ly_register_types], [
+ libyang_ext_builtin=true
+ AC_DEFINE([LIBYANG_EXT_BUILTIN], [1], [have ly_register_types()])
+], [
+ libyang_ext_builtin=false
+ AC_MSG_WARN([===== old libyang (before 0.16.74) detected =====])
+ AC_MSG_WARN([The available version of libyang does not seem to support])
+ AC_MSG_WARN([built-in YANG extension modules. This will cause "make check"])
+ AC_MSG_WARN([to fail and may create installation and version mismatch issues.])
+ AC_MSG_WARN([Support for the old mechanism will be removed at some point.])
+ AC_MSG_WARN([Please update libyang to version 0.16.74 or newer.])
+ AC_MSG_WARN([===== old libyang (before 0.16.74) detected =====])
+])
+AM_CONDITIONAL([LIBYANG_EXT_BUILTIN], [$libyang_ext_builtin])
+LDFLAGS="$ac_ld_flag_save"
+
dnl ---------------
dnl configuration rollbacks
dnl ---------------
Note: the libyang dev/devel packages need to be installed in addition
to the libyang core package in order to build FRR successfully.
+.. warning::
+ libyang ABI version 0.16.74 or newer will be required to build FRR in the
+ near future since it significantly eases build and installation
+ considerations. "0.16-r3" is equal to 0.16.105 and will work, "0.16-r2"
+ is equal to 0.16.52 and will stop working. The CI artifacts will be
+ updated shortly.
+
For example, for CentOS 7.x:
.. code-block:: shell
sudo apt install libpcre3-dev
sudo dpkg -i libyang-dev_0.16.46_amd64.deb libyang_0.16.46_amd64.deb
+.. note::
+ For Debian-based systems, the official libyang package requires recent
+ versions of swig (3.0.12) and debhelper (11) which are only available in
+ Debian buster (10). However, libyang packages built on Debian buster can
+ be installed on both Debian jessie (8) and Debian stretch (9), as well as
+ various Ubuntu systems. The python3-yang package will not work, but the
+ other packages (libyang-dev is the one needed for FRR) will.
+
Alternatively, libyang can be built and installed manually by following
the steps below:
Look for libyang plugins in `dir` [`prefix`/lib/frr/libyang_plugins].
Note that the FRR libyang plugins will be installed here.
+ This option is meaningless with libyang 0.16.74 or newer and will be
+ removed once support for older libyang versions is dropped.
+
When it's desired to run FRR without installing it in the system, it's possible
to configure it as follows to look for YANG modules and libyang plugins in the
compile directory:
#include "yang_translator.h"
#include "northbound.h"
+#include <libyang/user_types.h>
+
DEFINE_MTYPE(LIB, YANG_MODULE, "YANG module")
DEFINE_MTYPE(LIB, YANG_DATA, "YANG data structure")
zlog(priority, "libyang: %s", msg);
}
+#if CONFDATE > 20190401
+CPP_NOTICE("lib/yang: time to remove non-LIBYANG_EXT_BUILTIN support")
+#endif
+
+#ifdef LIBYANG_EXT_BUILTIN
+extern struct lytype_plugin_list frr_user_types[];
+#endif
+
void yang_init(void)
{
+#ifndef LIBYANG_EXT_BUILTIN
+CPP_NOTICE("lib/yang: deprecated libyang <0.16.74 extension loading in use!")
static char ly_plugin_dir[PATH_MAX];
const char *const *ly_loaded_plugins;
const char *ly_plugin;
snprintf(ly_plugin_dir, sizeof(ly_plugin_dir), "%s=%s",
"LIBYANG_USER_TYPES_PLUGINS_DIR", LIBYANG_PLUGINS_PATH);
putenv(ly_plugin_dir);
+#endif
/* Initialize libyang global parameters that affect all containers. */
ly_set_log_clb(ly_log_cb, 1);
ly_log_options(LY_LOLOG | LY_LOSTORE);
+#ifdef LIBYANG_EXT_BUILTIN
+ if (ly_register_types(frr_user_types, "frr_user_types")) {
+ flog_err(EC_LIB_LIBYANG_PLUGIN_LOAD,
+ "ly_register_types() failed");
+ exit(1);
+ }
+#endif
+
/* Initialize libyang container for native models. */
ly_native_ctx =
ly_ctx_new(YANG_MODELS_PATH, LY_CTX_DISABLE_SEARCHDIR_CWD);
ly_ctx_set_module_imp_clb(ly_native_ctx, yang_module_imp_clb, NULL);
ly_ctx_set_priv_dup_clb(ly_native_ctx, ly_dup_cb);
+#ifndef LIBYANG_EXT_BUILTIN
/* Detect if the required libyang plugin(s) were loaded successfully. */
ly_loaded_plugins = ly_get_loaded_plugins();
for (size_t i = 0; (ly_plugin = ly_loaded_plugins[i]); i++) {
"%s: failed to load frr_user_types.so", __func__);
exit(1);
}
+#endif
yang_translator_init();
}
#
# libyang user types
#
+
+if LIBYANG_EXT_BUILTIN
+lib_libfrr_la_SOURCES += yang/libyang_plugins/frr_user_types.c
+else
libyang_plugins_LTLIBRARIES += yang/libyang_plugins/frr_user_types.la
+endif
yang_libyang_plugins_frr_user_types_la_CFLAGS = $(WERROR)
yang_libyang_plugins_frr_user_types_la_LDFLAGS = -avoid-version -module -shared -export-dynamic