Skip to content

Commit

Permalink
interfaces-plugin: fix neighbor loading issues
Browse files Browse the repository at this point in the history
  • Loading branch information
zinccyy committed Oct 31, 2022
1 parent 6ce174b commit faf3b46
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 41 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
78 changes: 39 additions & 39 deletions src/interfaces/src/plugin/startup/load.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down

0 comments on commit faf3b46

Please sign in to comment.