Skip to content

Commit

Permalink
interfaces-plugin: remove sr_copy_config() call from plugin cleanup c…
Browse files Browse the repository at this point in the history
…allback
  • Loading branch information
zinccyy committed Oct 31, 2022
1 parent dee97eb commit 2a9fb2d
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 24 deletions.
20 changes: 6 additions & 14 deletions src/interfaces/src/plugin.c
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ int sr_plugin_init_cb(sr_session_ctx_t* running_session, void** private_data)
},
{
IETF_INTERFACES_YANG_MODULE,
//depends on if-mib feature
// depends on if-mib feature
INTERFACES_INTERFACES_INTERFACE_IF_INDEX_YANG_PATH,
srpc_feature_status_hash_check(ctx->features.ietf_interfaces_features, "if-mib") ? interfaces_subscription_operational_interfaces_interface_if_index : NULL,
},
Expand Down Expand Up @@ -181,31 +181,31 @@ int sr_plugin_init_cb(sr_session_ctx_t* running_session, void** private_data)
},
{
IETF_INTERFACES_YANG_MODULE,
//depends on carrier-delay feature
// depends on carrier-delay feature
INTERFACES_INTERFACES_INTERFACE_CARRIER_DELAY_CARRIER_TRANSITIONS_YANG_PATH,
srpc_feature_status_hash_check(ctx->features.ietf_if_extensions_features, "carrier-delay") ? interfaces_subscription_operational_interfaces_interface_carrier_delay_carrier_transitions : NULL,
},
{
IETF_INTERFACES_YANG_MODULE,
//depends on carrier-delay feature
// depends on carrier-delay feature
INTERFACES_INTERFACES_INTERFACE_CARRIER_DELAY_TIMER_RUNNING_YANG_PATH,
srpc_feature_status_hash_check(ctx->features.ietf_if_extensions_features, "carrier-delay") ? interfaces_subscription_operational_interfaces_interface_carrier_delay_timer_running : NULL,
},
{
IETF_INTERFACES_YANG_MODULE,
//depends on dampening feature
// depends on dampening feature
INTERFACES_INTERFACES_INTERFACE_DAMPENING_PENALTY_YANG_PATH,
srpc_feature_status_hash_check(ctx->features.ietf_if_extensions_features, "dampening") ? interfaces_subscription_operational_interfaces_interface_dampening_penalty : NULL,
},
{
IETF_INTERFACES_YANG_MODULE,
//depends on dampening feature
// depends on dampening feature
INTERFACES_INTERFACES_INTERFACE_DAMPENING_SUPPRESSED_YANG_PATH,
srpc_feature_status_hash_check(ctx->features.ietf_if_extensions_features, "dampening") ? interfaces_subscription_operational_interfaces_interface_dampening_suppressed : NULL,
},
{
IETF_INTERFACES_YANG_MODULE,
//depends on dampening feature
// depends on dampening feature
INTERFACES_INTERFACES_INTERFACE_DAMPENING_TIME_REMAINING_YANG_PATH,
srpc_feature_status_hash_check(ctx->features.ietf_if_extensions_features, "dampening") ? interfaces_subscription_operational_interfaces_interface_dampening_time_remaining : NULL,
},
Expand Down Expand Up @@ -355,16 +355,8 @@ int sr_plugin_init_cb(sr_session_ctx_t* running_session, void** private_data)

void sr_plugin_cleanup_cb(sr_session_ctx_t* running_session, void* private_data)
{
int error = 0;

interfaces_ctx_t* ctx = (interfaces_ctx_t*)private_data;

// save current running configuration into startup for next time when the plugin starts
error = sr_copy_config(ctx->startup_session, IETF_INTERFACES_YANG_MODULE, SR_DS_RUNNING, 0);
if (error) {
SRPLG_LOG_ERR(PLUGIN_NAME, "sr_copy_config() error (%d): %s", error, sr_strerror(error));
}

if (ctx->oper_ctx.nl_ctx.link_cache) {
nl_cache_put(ctx->oper_ctx.nl_ctx.link_cache);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ int interfaces_interface_ipv4_change_forwarding_init(void* priv)

int interfaces_interface_ipv4_change_forwarding(void* priv, sr_session_ctx_t* session, const srpc_change_ctx_t* change_ctx)
{
int error = 0;
// int error = 0;
const char* node_name = LYD_NAME(change_ctx->node);
const char* node_value = lyd_get_value(change_ctx->node);

Expand Down
18 changes: 9 additions & 9 deletions src/interfaces/src/plugin/api/interfaces/load.c
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ static char* interfaces_get_interface_type(struct rtnl_link* link, char* name)
const char* path_to_sys = "/sys/class/net/";
int type_id = 0;

SRPC_SAFE_CALL(read_from_sys_file(path_to_sys, name, &type_id), error_out);
SRPC_SAFE_CALL_ERR(error, read_from_sys_file(path_to_sys, name, &type_id), error_out);

switch (type_id) {
case ARPHRD_ETHER:
Expand Down Expand Up @@ -229,18 +229,18 @@ static int interfaces_add_link(interfaces_interface_hash_element_t** if_hash, in
interfaces_interface_hash_element_t* new_if_hash_elem = interfaces_interface_hash_element_new();
interfaces_interface_hash_element_set_name(&new_if_hash_elem, interface->name);

SRPC_SAFE_CALL(interfaces_interface_hash_add_element(if_hash, new_if_hash_elem), error_out);
SRPC_SAFE_CALL_ERR(error, interfaces_interface_hash_add_element(if_hash, new_if_hash_elem), error_out);

if (interface->description != NULL) {
SRPC_SAFE_CALL(interfaces_interface_hash_element_set_description(&new_if_hash_elem, interface->description), error_out);
SRPC_SAFE_CALL_ERR(error, interfaces_interface_hash_element_set_description(&new_if_hash_elem, interface->description), error_out);
}

if (interface->type != NULL) {
SRPC_SAFE_CALL(interfaces_interface_hash_element_set_type(&new_if_hash_elem, interface->type), error_out);
SRPC_SAFE_CALL_ERR(error, interfaces_interface_hash_element_set_type(&new_if_hash_elem, interface->type), error_out);
}

if (interface->parent_interface != NULL) {
SRPC_SAFE_CALL(interfaces_interface_hash_element_set_parent_interface(&new_if_hash_elem, interface->parent_interface), error_out);
SRPC_SAFE_CALL_ERR(error, interfaces_interface_hash_element_set_parent_interface(&new_if_hash_elem, interface->parent_interface), error_out);
}

interfaces_interface_hash_element_set_enabled(&new_if_hash_elem, interface->enabled);
Expand Down Expand Up @@ -281,7 +281,7 @@ static int interfaces_interfaces_worker(interfaces_ctx_t* ctx, struct nl_sock* s
error = interfaces_parse_link(ctx, socket, cache, link, &interface);
switch (error) {
case interfaces_load_success:
SRPC_SAFE_CALL(interfaces_add_link(if_hash, &interface), error_out);
SRPC_SAFE_CALL_ERR(error, interfaces_add_link(if_hash, &interface), error_out);
break;
case interfaces_load_continue:
break;
Expand Down Expand Up @@ -318,11 +318,11 @@ int interfaces_load_interface(interfaces_ctx_t* ctx, interfaces_interface_hash_e
goto error_out;
}

SRPC_SAFE_CALL(nl_connect(socket, NETLINK_ROUTE), error_out);
SRPC_SAFE_CALL_ERR(error, nl_connect(socket, NETLINK_ROUTE), error_out);

SRPC_SAFE_CALL(rtnl_link_alloc_cache(socket, AF_UNSPEC, &cache), error_out);
SRPC_SAFE_CALL_ERR(error, rtnl_link_alloc_cache(socket, AF_UNSPEC, &cache), error_out);

SRPC_SAFE_CALL(interfaces_interfaces_worker(ctx, socket, cache, if_hash), error_out);
SRPC_SAFE_CALL_ERR(error, interfaces_interfaces_worker(ctx, socket, cache, if_hash), error_out);

goto out;
error_out:
Expand Down

0 comments on commit 2a9fb2d

Please sign in to comment.