Using SIL Priority

There are several extensions and API functions that control how the server will invoke the SIL code and process data in edit requests.

Note

  • Use of SIL Priority is not recommended!

  • Use Commit Completeness callbacks if possible to apply and commit system resources after the phase is complete, so edit callback order does not matter.

SIL Invocation Order (sil-priority)

It is possible for the client to send several edits within a single <edit-config> or <copy-config> request.

Sometimes it is useful to make sure certain data structures are validated and processed before other data structures.

The sil-priority extension can be used to control the order that edits are processed. This extension is defined in section 12.2 “Built-in YANG Language Extensions”.

The SIL priority can also be set at run-time with an API function. This allows SIL priority to be setup in platform-specific ways, without needing to alter the YANG file for this purpose.

status_t agt_cb_set_sil_priority(const xmlChar *defpath, uint8 sil_priority)

Set the desired SIL priority with a callback instead of using the YANG extension for this purpose.

Parameters
  • defpath -- Xpath with default (or no) prefixes

  • sil_priority -- = SIL priority value to use (1..255)

Returns

status

Example: Set the SIL priority to 30 for the /interfaces/interface list.

status_t res =
  agt_cb_set_sil_priority((const xmlChar *)"/if:interfaces/if:interface",
                          30);

Reverse SIL priority for Delete Operations (sil-prio-reverse-for-deletes)

It is possible for the client to send several edits within a single <edit-config> request. Sometimes it is useful to make sure certain data structures are validated and processed before other data structures. The "sil-priority" extension can be used to control the order of the edits and how they are processed.

In a case where you set "sil-priority" for multiple specific objects and want the order to be reversed during the DELETE operations there is a netconfd-pro configuration parameter "sil-prio-reverse-for-deletes".

  • If set to "true" the "sil-prio-reverse-for-deletes" parameter for netconfd-pro dictates that the SIL priority for DELETE operations will be reversed. This parameter can be used to delete leafref nodes with referenced by node in reverse order.

  • If 'false' then the SIL priority will not be reversed. The default is "false".

When the parameter is set to "true" the server will invoke callbacks for the specific objects with "sil-priority" configured in reverse order.

The "sil-prio-reverse-for-deletes" parameter has following facts that should be noted:

  • It will NOT change the "sil-priority" of the specific objects, it will instead reverse the "sil-priority" and the server will invoke the callbacks in reverse order

  • This parameter will reverse "sil-priority" only if the edit operation is DELETE or REMOVE

  • The server will not reverse the "sil-priority" for EDIT2 MERGE mode with mixed edits (if there is delete and other operations). Since the real operation is in the children objects and the server invokes a single callback for all the children edits at once.

Please note that the EDIT2 MERGE edits will not change on the invocation order if the callbacks have mixed operations on children (if there are delete on one child and other edit operation on second child), they will not be reversed anyhow.

The EDIT2 MERGE mode combines multiple edits in one callback and the server invoke just one callback for all the edits. Hence, the server has no control of when it should reverse the priority for this callback in case of mixed children operations. The priority in this case will remain the same and the server will warn a user with following warning:

SIL priority for object 'uint16-leaf' set to 100.100

Warning: Cannot reverse SIL priority for EDIT2 child 'test:uint16-leaf'

However, in case the EDIT2 MERGE mode has only delete or remove operations on children the priority for this callback will be reversed.

It is recommended to use EDIT1 callbacks to fully control the reverse priority behavior. Or as an alternative it is recommended to avoid the EDIT2 MERGE mode with mixed operations if you want to reverse the priority of the edits.

Also, the server will reverse the edits priorities in case the EDIT2 children edit is the edit to delete or remove the default node. And if there are no other children edits with not equal to remove or delete, or merge edit operation in case of default node removal.

Deletion of Child Nodes (sil-delete-children-first)

If the client deletes a container of list entries, then the server will normally only invoke the SIL callback for deletion for the container. It may be easier to allow the server to use the SIL callbacks for the child list nodes, to delete a data structure “bottom-up”.

Use the sil-delete-children-first extension to force the server to delete all the child nodes before deleting the parent container.

The sil-delete-children-first extension can be used in any parent node (container or list) and can be used to force the server to invoke the SIL callback for any child node (container, list, leaf, leaf-list, anyxml).

Suppress leafref Validation

Leafref validation involves searching all the “pointed at” leaf instances to make sure that the leafref leaf being validated contains one of the values actually in use. An instance is required to exist for the leafref to be valid.

YANG 1.0 does not support the “require-instance” sub-statement for a leafref definition. In order to force the server to skip this validation step, use the 'agt_cb_skip_leafref_validation' API function.

status_t agt_cb_skip_leafref_validation(const xmlChar *defpath)

Set a previously registered callback as a node that the server should skip leafref validation in order to save processing time.

Parameters

defpath -- Xpath with default (or no) prefixes

Returns

status

In the following example, the path /t641-1:B/t641-1:BB/t641-1:fd-mode represents a leafref leaf that will be treated as if the “require-instance false” statement was present in the YANG definition:

Inside SIL init function:

res = agt_cb_register_callback(
    y_test_fd641_1_M_test_fd641_1,
    (const xmlChar *)"/t641-1:B/t641-1:BB/t641-1:fd-mode",
    y_test_fd641_1_R_test_fd641_1,
    test_fd641_1_B_BB_fd_mode_edit);
if (res != NO_ERR) {
    return res;
}

res = agt_cb_skip_leafref_validation(
    (const xmlChar *)"/t641-1:B/t641-1:BB/t641-1:fd-mode");
if (res != NO_ERR) {
    return res;
}