Browse Source

Merge pull request #10437 from neheb/yang

libyang: Update to 1.0-r4
lilik-openwrt-22.03
Rosen Penev 5 years ago
committed by GitHub
parent
commit
c1b6b03108
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 12 additions and 1280 deletions
  1. +12
    -28
      libs/libyang/Makefile
  2. +0
    -1030
      libs/libyang/patches/001-user-types-CHANGE-convert-internal-types-to-canonical
  3. +0
    -222
      libs/libyang/patches/002-bugfix_for_freeing_user_type_unions

+ 12
- 28
libs/libyang/Makefile View File

@ -8,20 +8,20 @@
include $(TOPDIR)/rules.mk
PKG_NAME:=libyang
PKG_VERSION:=0.16-r3
PKG_RELEASE:=4
PKG_LICENSE:=GPL-2.0-or-later
PKG_MAINTAINER:=Mislav Novakovic <mislav.novakovic@sartura.hr>
PKG_VERSION:=1.0-r4
PKG_RELEASE:=1
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
PKG_SOURCE_URL:=https://codeload.github.com/CESNET/libyang/tar.gz/v$(PKG_VERSION)?
PKG_HASH:=4745460dedc4ba17d8bcfc39ad9ba0d1b91bbe82b55b9417a090390909ba8ca5
PKG_HASH:=411f0c675b0858f8deabc0545e33fbd791ff7c7a5b7d2c27e347e3973d5b8ae4
CMAKE_INSTALL:=1
PKG_MAINTAINER:=Mislav Novakovic <mislav.novakovic@sartura.hr>
PKG_LICENSE:=BSD-3-Clause
PKG_LICENSE_FILES:=LICENSE
CMAKE_INSTALL:=1
PKG_BUILD_PARALLEL:=1
PKG_INSTALL:=1
CMAKE_BINARY_SUBDIR:=build
include $(INCLUDE_DIR)/package.mk
include $(INCLUDE_DIR)/cmake.mk
@ -30,7 +30,7 @@ define Package/libyang
SECTION:=libs
CATEGORY:=Libraries
TITLE:=YANG data modeling language library
URL:=$(PKG_SOURCE_URL)
URL:=https://github.com/CESNET/libyang
DEPENDS:=+libpcre +libpthread
endef
@ -38,7 +38,7 @@ define Package/yanglint
SECTION:=utils
CATEGORY:=Utilities
TITLE:=YANG data modeling language utility
URL:=$(PKG_SOURCE_URL)
URL:=https://github.com/CESNET/libyang
DEPENDS:=+libyang
endef
@ -47,23 +47,7 @@ define Package/libyang/description
The library is used e.g. in libnetconf2, Netopeer2 or sysrepo projects.
endef
TARGET_LDFLAGS += -lm
CMAKE_OPTIONS += \
-DCMAKE_INSTALL_PREFIX:PATH=/usr \
-DENABLE_LYD_PRIV:BOOL=ON \
-DCMAKE_BUILD_TYPE:STRING=Release
define Build/InstallDev
$(INSTALL_DIR) $(1)/usr/lib
$(CP) $(PKG_INSTALL_DIR)/usr/lib/libyang.so* $(1)/usr/lib/
$(INSTALL_DIR) $(1)/usr/include/libyang
$(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/include/libyang/* $(1)/usr/include/libyang/
$(INSTALL_DIR) $(1)/usr/lib/pkgconfig
$(INSTALL_CONF) $(PKG_INSTALL_DIR)/usr/lib/pkgconfig/libyang.pc $(1)/usr/lib/pkgconfig/
endef
CMAKE_OPTIONS += -DENABLE_LYD_PRIV:BOOL=ON
define Package/libyang/install
$(INSTALL_DIR) $(1)/usr/lib
@ -78,7 +62,7 @@ endef
define Package/yanglint/install
$(INSTALL_DIR) $(1)/usr/bin
$(INSTALL_BIN) $(PKG_BUILD_DIR)/yanglint $(1)/usr/bin/
$(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/yanglint $(1)/usr/bin/
endef
$(eval $(call BuildPackage,libyang))


+ 0
- 1030
libs/libyang/patches/001-user-types-CHANGE-convert-internal-types-to-canonical
File diff suppressed because it is too large
View File


+ 0
- 222
libs/libyang/patches/002-bugfix_for_freeing_user_type_unions View File

@ -1,222 +0,0 @@
Index: libyang-0.16-r3/src/parser.c
===================================================================
--- libyang-0.16-r3.orig/src/parser.c
+++ libyang-0.16-r3/src/parser.c
@@ -1210,7 +1210,7 @@ lyp_parse_value(struct lys_type *type, c
unsigned int i, j;
int64_t num;
uint64_t unum, uind, u = 0;
- const char *ptr, *value = *value_, *itemname;
+ const char *ptr, *value = *value_, *itemname, *old_val_str;
struct lys_type_bit **bits = NULL;
struct lys_ident *ident;
lyd_val *val, old_val;
@@ -1245,7 +1245,8 @@ lyp_parse_value(struct lys_type *type, c
/* fully clear the value */
if (store) {
- lyd_free_value(*val, *val_type, *val_flags, type, &old_val, &old_val_type, &old_val_flags);
+ old_val_str = lydict_insert(ctx, *value_, 0);
+ lyd_free_value(*val, *val_type, *val_flags, type, old_val_str, &old_val, &old_val_type, &old_val_flags);
*val_flags &= ~LY_VALUE_UNRES;
}
@@ -1907,7 +1908,7 @@ lyp_parse_value(struct lys_type *type, c
if (store) {
/* erase possible present and invalid value data */
- lyd_free_value(*val, *val_type, *val_flags, t, NULL, NULL, NULL);
+ lyd_free_value(*val, *val_type, *val_flags, t, *value_, NULL, NULL, NULL);
memset(val, 0, sizeof(lyd_val));
}
}
@@ -1946,7 +1947,8 @@ lyp_parse_value(struct lys_type *type, c
/* free backup */
if (store) {
- lyd_free_value(old_val, old_val_type, old_val_flags, type, NULL, NULL, NULL);
+ lyd_free_value(old_val, old_val_type, old_val_flags, type, old_val_str, NULL, NULL, NULL);
+ lydict_remove(ctx, old_val_str);
}
return type;
@@ -1956,6 +1958,7 @@ error:
*val = old_val;
*val_type = old_val_type;
*val_flags = old_val_flags;
+ lydict_remove(ctx, old_val_str);
}
return NULL;
}
Index: libyang-0.16-r3/src/parser.h
===================================================================
--- libyang-0.16-r3.orig/src/parser.h
+++ libyang-0.16-r3/src/parser.h
@@ -267,10 +267,10 @@ int lytype_store(const struct lys_module
/**
* @brief Free a user type stored value.
*
- * @param[in] mod Module of the type.
- * @param[in] type_name Type (typedef) name.
+ * @param[in] type Type of the value.
* @param[in] value Value union to free.
+ * @param[in] value_str String value of the value.
*/
-void lytype_free(const struct lys_module *mod, const char *type_name, lyd_val value);
+void lytype_free(const struct lys_type *type, lyd_val value, const char *value_str);
#endif /* LY_PARSER_H_ */
Index: libyang-0.16-r3/src/plugins.c
===================================================================
--- libyang-0.16-r3.orig/src/plugins.c
+++ libyang-0.16-r3/src/plugins.c
@@ -603,11 +603,40 @@ lytype_store(const struct lys_module *mo
}
void
-lytype_free(const struct lys_module *mod, const char *type_name, lyd_val value)
+lytype_free(const struct lys_type *type, lyd_val value, const char *value_str)
{
struct lytype_plugin_list *p;
+ struct lys_node_leaf sleaf;
+ struct lyd_node_leaf_list leaf;
+ struct lys_module *mod;
- p = lytype_find(mod->name, mod->rev_size ? mod->rev[0].date : NULL, type_name);
+ assert(type->der && type->der->module);
+
+ mod = type->der->module;
+ memset(&sleaf, 0, sizeof sleaf);
+ memset(&leaf, 0, sizeof leaf);
+
+ if (type->base == LY_TYPE_UNION) {
+ /* create a fake schema node */
+ sleaf.module = mod;
+ sleaf.name = "fake-leaf";
+ sleaf.type = *type;
+ sleaf.nodetype = LYS_LEAF;
+
+ /* and a fake data node */
+ leaf.schema = (struct lys_node *)&sleaf;
+ leaf.value = value;
+ leaf.value_str = value_str;
+
+ /* find the original type */
+ type = lyd_leaf_type(&leaf);
+ if (!type) {
+ LOGINT(mod->ctx);
+ return;
+ }
+ }
+
+ p = lytype_find(mod->name, mod->rev_size ? mod->rev[0].date : NULL, type->der->name);
if (!p) {
LOGINT(mod->ctx);
return;
Index: libyang-0.16-r3/src/resolve.c
===================================================================
--- libyang-0.16-r3.orig/src/resolve.c
+++ libyang-0.16-r3/src/resolve.c
@@ -3630,7 +3630,7 @@ check_default(struct lys_type *type, con
}
cleanup:
- lyd_free_value(node.value, node.value_type, node.value_flags, type, NULL, NULL, NULL);
+ lyd_free_value(node.value, node.value_type, node.value_flags, type, node.value_str, NULL, NULL, NULL);
lydict_remove(ctx, node.value_str);
if (tpdf && node.schema) {
free((char *)node.schema->name);
@@ -7923,7 +7923,7 @@ resolve_union(struct lyd_node_leaf_list
if (store) {
lyd_free_value(leaf->value, leaf->value_type, leaf->value_flags, &((struct lys_node_leaf *)leaf->schema)->type,
- NULL, NULL, NULL);
+ leaf->value_str, NULL, NULL, NULL);
memset(&leaf->value, 0, sizeof leaf->value);
}
@@ -8012,7 +8012,7 @@ resolve_union(struct lyd_node_leaf_list
/* erase possible present and invalid value data */
if (store) {
- lyd_free_value(leaf->value, leaf->value_type, leaf->value_flags, t, NULL, NULL, NULL);
+ lyd_free_value(leaf->value, leaf->value_type, leaf->value_flags, t, leaf->value_str, NULL, NULL, NULL);
memset(&leaf->value, 0, sizeof leaf->value);
}
}
Index: libyang-0.16-r3/src/tree_data.c
===================================================================
--- libyang-0.16-r3.orig/src/tree_data.c
+++ libyang-0.16-r3/src/tree_data.c
@@ -2442,7 +2442,7 @@ lyd_merge_node_update(struct lyd_node *t
NULL, trg_leaf, NULL, NULL, 1, src_leaf->dflt, 0);
} else {
lyd_free_value(trg_leaf->value, trg_leaf->value_type, trg_leaf->value_flags,
- &((struct lys_node_leaf *)trg_leaf->schema)->type, NULL, NULL, NULL);
+ &((struct lys_node_leaf *)trg_leaf->schema)->type, trg_leaf->value_str, NULL, NULL, NULL);
trg_leaf->value = src_leaf->value;
}
src_leaf->value = (lyd_val)0;
@@ -2492,7 +2492,7 @@ lyd_merge_node_update(struct lyd_node *t
lydict_remove(ctx, trg_leaf->value_str);
trg_leaf->value_str = lydict_insert(ctx, src_leaf->value_str, 0);
lyd_free_value(trg_leaf->value, trg_leaf->value_type, trg_leaf->value_flags,
- &((struct lys_node_leaf *)trg_leaf->schema)->type, NULL, NULL, NULL);
+ &((struct lys_node_leaf *)trg_leaf->schema)->type, trg_leaf->value_str, NULL, NULL, NULL);
trg_leaf->value_type = src_leaf->value_type;
trg_leaf->dflt = src_leaf->dflt;
@@ -5866,7 +5866,7 @@ lyd_free_attr(struct ly_ctx *ctx, struct
lydict_remove(ctx, attr->name);
type = lys_ext_complex_get_substmt(LY_STMT_TYPE, attr->annotation, NULL);
assert(type);
- lyd_free_value(attr->value, attr->value_type, attr->value_flags, *type, NULL, NULL, NULL);
+ lyd_free_value(attr->value, attr->value_type, attr->value_flags, *type, attr->value_str, NULL, NULL, NULL);
lydict_remove(ctx, attr->value_str);
free(attr);
}
@@ -5975,8 +5975,8 @@ lyd_insert_attr(struct lyd_node *parent,
}
void
-lyd_free_value(lyd_val value, LY_DATA_TYPE value_type, uint8_t value_flags, struct lys_type *type, lyd_val *old_val,
- LY_DATA_TYPE *old_val_type, uint8_t *old_val_flags)
+lyd_free_value(lyd_val value, LY_DATA_TYPE value_type, uint8_t value_flags, struct lys_type *type, const char *value_str,
+ lyd_val *old_val, LY_DATA_TYPE *old_val_type, uint8_t *old_val_flags)
{
if (old_val) {
*old_val = value;
@@ -5988,8 +5988,7 @@ lyd_free_value(lyd_val value, LY_DATA_TY
/* otherwise the value is correctly freed */
if (value_flags & LY_VALUE_USER) {
- assert(type->der && type->der->module);
- lytype_free(type->der->module, type->der->name, value);
+ lytype_free(type, value, value_str);
} else {
switch (value_type) {
case LY_TYPE_BITS:
@@ -6062,7 +6061,7 @@ _lyd_free_node(struct lyd_node *node)
case LYS_LEAFLIST:
leaf = (struct lyd_node_leaf_list *)node;
lyd_free_value(leaf->value, leaf->value_type, leaf->value_flags, &((struct lys_node_leaf *)leaf->schema)->type,
- NULL, NULL, NULL);
+ leaf->value_str, NULL, NULL, NULL);
lydict_remove(leaf->schema->module->ctx, leaf->value_str);
break;
default:
Index: libyang-0.16-r3/src/tree_internal.h
===================================================================
--- libyang-0.16-r3.orig/src/tree_internal.h
+++ libyang-0.16-r3/src/tree_internal.h
@@ -496,8 +496,8 @@ int lyd_get_unique_default(const char* u
int lyd_build_relative_data_path(const struct lys_module *module, const struct lyd_node *node, const char *schema_id,
char *buf);
-void lyd_free_value(lyd_val value, LY_DATA_TYPE value_type, uint8_t value_flags, struct lys_type *type, lyd_val *old_val,
- LY_DATA_TYPE *old_val_type, uint8_t *old_val_flags);
+void lyd_free_value(lyd_val value, LY_DATA_TYPE value_type, uint8_t value_flags, struct lys_type *type,
+ const char *value_str, lyd_val *old_val, LY_DATA_TYPE *old_val_type, uint8_t *old_val_flags);
int lyd_list_equal(struct lyd_node *node1, struct lyd_node *node2, int with_defaults);

Loading…
Cancel
Save