]> git.proxmox.com Git - mirror_frr.git/blobdiff - lib/yang.c
Merge pull request #5625 from qlyoung/fix-zapi-ipset-name-nullterm
[mirror_frr.git] / lib / yang.c
index 2a2c155deede2928e979ad95a5d43d1c2c832ee2..d153f755305a49a77f399bc7517b7f4130b7c394 100644 (file)
@@ -27,8 +27,8 @@
 
 #include <libyang/user_types.h>
 
-DEFINE_MTYPE(LIB, YANG_MODULE, "YANG module")
-DEFINE_MTYPE(LIB, YANG_DATA, "YANG data structure")
+DEFINE_MTYPE_STATIC(LIB, YANG_MODULE, "YANG module")
+DEFINE_MTYPE_STATIC(LIB, YANG_DATA, "YANG data structure")
 
 /* libyang container. */
 struct ly_ctx *ly_native_ctx;
@@ -595,7 +595,7 @@ struct yang_data *yang_data_list_find(const struct list *list,
 /* Make libyang log its errors using FRR logging infrastructure. */
 static void ly_log_cb(LY_LOG_LEVEL level, const char *msg, const char *path)
 {
-       int priority;
+       int priority = LOG_ERR;
 
        switch (level) {
        case LY_LLERR:
@@ -605,10 +605,9 @@ static void ly_log_cb(LY_LOG_LEVEL level, const char *msg, const char *path)
                priority = LOG_WARNING;
                break;
        case LY_LLVRB:
+       case LY_LLDBG:
                priority = LOG_DEBUG;
                break;
-       default:
-               return;
        }
 
        if (path)
@@ -617,13 +616,16 @@ static void ly_log_cb(LY_LOG_LEVEL level, const char *msg, const char *path)
                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_debugging_set(bool enable)
+{
+       if (enable) {
+               ly_verb(LY_LLDBG);
+               ly_verb_dbg(0xFF);
+       } else {
+               ly_verb(LY_LLERR);
+               ly_verb_dbg(0);
+       }
+}
 
 struct ly_ctx *yang_ctx_new_setup(void)
 {
@@ -650,31 +652,10 @@ struct ly_ctx *yang_ctx_new_setup(void)
 
 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;
-       bool found_ly_frr_types = false;
-
-       /* Tell libyang where to find its plugins. */
-       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 = yang_ctx_new_setup();
        if (!ly_native_ctx) {
@@ -682,22 +663,6 @@ CPP_NOTICE("lib/yang: deprecated libyang <0.16.74 extension loading in use!")
                exit(1);
        }
 
-#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++) {
-               if (strmatch(ly_plugin, "frr_user_types")) {
-                       found_ly_frr_types = true;
-                       break;
-               }
-       }
-       if (!found_ly_frr_types) {
-               flog_err(EC_LIB_LIBYANG_PLUGIN_LOAD,
-                        "%s: failed to load frr_user_types.so", __func__);
-               exit(1);
-       }
-#endif
-
        yang_translator_init();
 }