Skip to content

so4 #2415

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 99 commits into from
Jul 28, 2025
Merged

so4 #2415

merged 99 commits into from
Jul 28, 2025

Conversation

Roytak
Copy link
Collaborator

@Roytak Roytak commented Jul 18, 2025

libyang SO4 Notable Changes - serialization, context management, and API refinements

API Changes

Context Options upgraded from u16 to u32

Extension Data Callback (ly_ext_data_clb) parent parameter added

lyplg_type_lypath_free context parameter removed

lyplg_type_validate_patterns context parameter added

Plugin Pointers Replaced by Handles: Pointers to plugins within public lysc_* structs have been replaced by opaque handles plugin_ref

New APIs

Printed Context Support:

  • ly_ctx_compiled_size: Returns the size of a compiled context.

  • ly_ctx_compiled_print: Serializes (prints) a compiled context.

  • ly_ctx_new_printed: Deserializes (creates) a new context from a printed representation.

  • ly_ctx_is_printed: Checks if a context was created from a printed representation.

Context Management:

  • ly_ctx_free_parsed: Allows explicit freeing of parsed modules within a context.

Plugin Information Retrieval:

  • lysc_get_type_plugin: Retrieves a type plugin using its handle from public lysc_* structs.

  • lysc_get_ext_plugin: Retrieves an extension plugin using its handle from public lysc_* structs.

  • (Internal alternatives: LYSC_GET_TYPE_PLG and LYSC_GET_EXT_PLG)

Schema Mount Contexts Serialization Helpers:

  • lyplg_ext_schema_mount_create_shared_context: Creates a shared context before serialization of schema mount contexts.

  • lyplg_ext_schema_mount_destroy_shared_contexts: Destroys shared contexts after deserialization.

  • lyplg_ext_schema_mount_destroy_inline_contexts: Destroys inline contexts.

Type Plugin Value Printing:

  • lyplg_type_print_val: Converts a canonical value to a specific format using a type plugin.

Data Parsing:

  • lyd_parse_op: New parse options parameter added.

  • lyd_parse_ext_op: New parse options parameter added.

Other Changes:

  • Printed (Serializable/Deserializable) Context Support

  • New Context Options:

    • LY_CTX_LYB_HASHES: Generates hashes for all schema nodes

    • LY_CTX_STATIC_PLUGINS_ONLY: Restricts context to only use static/global plugins, disallowing user-defined type/extension plugins.

  • Context Modules Set Renamed from list to modules

  • Distinct Dictionaries for Schema and Data: Schema and data dictionaries are now separate per context => string pointers from data and schema dictionaries can no longer be directly compared.

    • lysdict_* functions are now internal and operate on the schema dictionary.

    • lydict_* functions are public API and operate on the data dictionary.

  • Private and Shared Runtime Data of Each context:

    • Private Data: Context-specific and thread-specific. Currently, only errors are stored here.

    • Shared Data: Context-specific but reference-counted, allowing sharing between printed contexts created from the same memory address. Data dictionary, patterns, etc., requires synchronization when accessed.

  • Lazy Pattern Compilation: Patterns are now stored in a context's hashtable instead of lysc_pattern and can be compiled lazily only when needed

  • Canonical Default Values: Default values are now stored in their canonical form.

Testing Improvements:

  • Added new tests for freeing parsed and printed contexts

michalvasko and others added 30 commits July 21, 2025 09:08
Simplifies freeing compiled ext instances without
the need for s dedicated context.
Because it causes issues and they cannot be
serialized.
So that it can be mapped and shared between processes.
Roytak added 12 commits July 21, 2025 09:31
Hash the address of the pattern instead of the pattern itself
Moved pcre2 pattern code from pattern struct to a hash table inside a
context. The reason being the usability of patterns inside printed
contexts.

pcre2 lib is dynamically loaded and a printed pattern code
contains pointers to e.g. malloc(), which caused issues with printed
contexts.

This way such codes are serialized and deserialized whenever they are
needed, which is portable in the same sense as a printed context.
@michalvasko michalvasko merged commit 879f3e5 into CESNET:so4-clone Jul 28, 2025
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants