From faf3b46d5bc54508d81a97c2aa2ba1b4fdcba2c9 Mon Sep 17 00:00:00 2001 From: Mateo Cindric Date: Mon, 31 Oct 2022 21:19:54 +0000 Subject: [PATCH] interfaces-plugin: fix neighbor loading issues --- .../api/interfaces/interface/ipv4/load.c | 2 +- .../api/interfaces/interface/ipv6/load.c | 2 +- src/interfaces/src/plugin/startup/load.c | 78 +++++++++---------- 3 files changed, 41 insertions(+), 41 deletions(-) diff --git a/src/interfaces/src/plugin/api/interfaces/interface/ipv4/load.c b/src/interfaces/src/plugin/api/interfaces/interface/ipv4/load.c index a0641b40..dbecfd2c 100644 --- a/src/interfaces/src/plugin/api/interfaces/interface/ipv4/load.c +++ b/src/interfaces/src/plugin/api/interfaces/interface/ipv4/load.c @@ -128,7 +128,7 @@ int interfaces_interface_ipv4_load_neighbor(interfaces_ctx_t* ctx, interfaces_in SRPC_SAFE_CALL_ERR(error, rtnl_neigh_alloc_cache(nl_ctx->socket, &nl_ctx->neigh_cache), error_out); // get link iterator - SRPC_SAFE_CALL_PTR(neigh_iter, (struct rtnl_neigh*)nl_cache_get_first(nl_ctx->addr_cache), error_out); + SRPC_SAFE_CALL_PTR(neigh_iter, (struct rtnl_neigh*)nl_cache_get_first(nl_ctx->neigh_cache), error_out); // iterate links while (neigh_iter) { diff --git a/src/interfaces/src/plugin/api/interfaces/interface/ipv6/load.c b/src/interfaces/src/plugin/api/interfaces/interface/ipv6/load.c index c467fd93..a204546e 100644 --- a/src/interfaces/src/plugin/api/interfaces/interface/ipv6/load.c +++ b/src/interfaces/src/plugin/api/interfaces/interface/ipv6/load.c @@ -121,7 +121,7 @@ int interfaces_interface_ipv6_load_neighbor(interfaces_ctx_t* ctx, interfaces_in SRPC_SAFE_CALL_ERR(error, rtnl_neigh_alloc_cache(nl_ctx->socket, &nl_ctx->neigh_cache), error_out); // get link iterator - SRPC_SAFE_CALL_PTR(neigh_iter, (struct rtnl_neigh*)nl_cache_get_first(nl_ctx->addr_cache), error_out); + SRPC_SAFE_CALL_PTR(neigh_iter, (struct rtnl_neigh*)nl_cache_get_first(nl_ctx->neigh_cache), error_out); // iterate links while (neigh_iter) { diff --git a/src/interfaces/src/plugin/startup/load.c b/src/interfaces/src/plugin/startup/load.c index 0be82f13..b571a19b 100644 --- a/src/interfaces/src/plugin/startup/load.c +++ b/src/interfaces/src/plugin/startup/load.c @@ -85,50 +85,50 @@ static int interfaces_startup_load_interface(void* priv, sr_session_ctx_t* sessi int error = 0; interfaces_ctx_t* ctx = (interfaces_ctx_t*)priv; interfaces_interface_hash_element_t* interface_head = NULL; - // interfaces_interface_hash_element_t *iter = NULL, *tmp = NULL; + interfaces_interface_hash_element_t *iter = NULL, *tmp = NULL; - // interfaces_interface_ipv4_address_element_t* v4_addr_iter = NULL; - // interfaces_interface_ipv6_address_element_t* v6_addr_iter = NULL; + interfaces_interface_ipv4_address_element_t* v4_addr_iter = NULL; + interfaces_interface_ipv6_address_element_t* v6_addr_iter = NULL; - // interfaces_interface_ipv4_neighbor_element_t* v4_neigh_iter = NULL; - // interfaces_interface_ipv6_neighbor_element_t* v6_neigh_iter = NULL; + interfaces_interface_ipv4_neighbor_element_t* v4_neigh_iter = NULL; + interfaces_interface_ipv6_neighbor_element_t* v6_neigh_iter = NULL; SRPC_SAFE_CALL_ERR(error, interfaces_load_interface(ctx, &interface_head), error_out); - // HASH_ITER(hh, interface_head, iter, tmp) - // { - // SRPLG_LOG_INF(PLUGIN_NAME, "Name: %s", iter->interface.name); - // SRPLG_LOG_INF(PLUGIN_NAME, "Type: %s", iter->interface.type); - // SRPLG_LOG_INF(PLUGIN_NAME, "Enabled: %d", iter->interface.enabled); - - // // v4 - // SRPLG_LOG_INF(PLUGIN_NAME, "v4 MTU: %d", iter->interface.ipv4.mtu); - // SRPLG_LOG_INF(PLUGIN_NAME, "v4 Enabled: %d", iter->interface.ipv4.enabled); - // SRPLG_LOG_INF(PLUGIN_NAME, "v4 Forwarding: %d", iter->interface.ipv4.forwarding); - - // LL_FOREACH(iter->interface.ipv4.address, v4_addr_iter) - // { - // SRPLG_LOG_INF(PLUGIN_NAME, "v4 Address : %s/%d", v4_addr_iter->address.ip, v4_addr_iter->address.subnet.prefix_length); - // } - // LL_FOREACH(iter->interface.ipv4.neighbor, v4_neigh_iter) - // { - // SRPLG_LOG_INF(PLUGIN_NAME, "v4 Neighbor : %s : %s", v4_neigh_iter->neighbor.ip, v4_neigh_iter->neighbor.link_layer_address); - // } - - // // v6 - // SRPLG_LOG_INF(PLUGIN_NAME, "v6 MTU: %d", iter->interface.ipv6.mtu); - // SRPLG_LOG_INF(PLUGIN_NAME, "v6 Enabled: %d", iter->interface.ipv6.enabled); - // SRPLG_LOG_INF(PLUGIN_NAME, "v6 Forwarding: %d", iter->interface.ipv6.forwarding); - - // LL_FOREACH(iter->interface.ipv6.address, v6_addr_iter) - // { - // SRPLG_LOG_INF(PLUGIN_NAME, "v6 Address : %s/%d", v6_addr_iter->address.ip, v6_addr_iter->address.prefix_length); - // } - // LL_FOREACH(iter->interface.ipv6.neighbor, v6_neigh_iter) - // { - // SRPLG_LOG_INF(PLUGIN_NAME, "v6 Neighbor : %s : %s", v6_neigh_iter->neighbor.ip, v6_neigh_iter->neighbor.link_layer_address); - // } - // } + HASH_ITER(hh, interface_head, iter, tmp) + { + SRPLG_LOG_INF(PLUGIN_NAME, "Name: %s", iter->interface.name); + SRPLG_LOG_INF(PLUGIN_NAME, "Type: %s", iter->interface.type); + SRPLG_LOG_INF(PLUGIN_NAME, "Enabled: %d", iter->interface.enabled); + + // v4 + SRPLG_LOG_INF(PLUGIN_NAME, "v4 MTU: %d", iter->interface.ipv4.mtu); + SRPLG_LOG_INF(PLUGIN_NAME, "v4 Enabled: %d", iter->interface.ipv4.enabled); + SRPLG_LOG_INF(PLUGIN_NAME, "v4 Forwarding: %d", iter->interface.ipv4.forwarding); + + LL_FOREACH(iter->interface.ipv4.address, v4_addr_iter) + { + SRPLG_LOG_INF(PLUGIN_NAME, "v4 Address : %s/%d", v4_addr_iter->address.ip, v4_addr_iter->address.subnet.prefix_length); + } + LL_FOREACH(iter->interface.ipv4.neighbor, v4_neigh_iter) + { + SRPLG_LOG_INF(PLUGIN_NAME, "v4 Neighbor : %s : %s", v4_neigh_iter->neighbor.ip, v4_neigh_iter->neighbor.link_layer_address); + } + + // v6 + SRPLG_LOG_INF(PLUGIN_NAME, "v6 MTU: %d", iter->interface.ipv6.mtu); + SRPLG_LOG_INF(PLUGIN_NAME, "v6 Enabled: %d", iter->interface.ipv6.enabled); + SRPLG_LOG_INF(PLUGIN_NAME, "v6 Forwarding: %d", iter->interface.ipv6.forwarding); + + LL_FOREACH(iter->interface.ipv6.address, v6_addr_iter) + { + SRPLG_LOG_INF(PLUGIN_NAME, "v6 Address : %s/%d", v6_addr_iter->address.ip, v6_addr_iter->address.prefix_length); + } + LL_FOREACH(iter->interface.ipv6.neighbor, v6_neigh_iter) + { + SRPLG_LOG_INF(PLUGIN_NAME, "v6 Neighbor : %s : %s", v6_neigh_iter->neighbor.ip, v6_neigh_iter->neighbor.link_layer_address); + } + } goto out;