summaryrefslogtreecommitdiffstats
path: root/src/vnet
diff options
context:
space:
mode:
Diffstat (limited to 'src/vnet')
-rw-r--r--src/vnet/adj/adj.c8
-rw-r--r--src/vnet/ip/ip.api12
-rw-r--r--src/vnet/ip/ip_api.c11
-rw-r--r--src/vnet/ip/ip_neighbor.c14
-rw-r--r--src/vnet/ip/ip_neighbor.h3
5 files changed, 40 insertions, 8 deletions
diff --git a/src/vnet/adj/adj.c b/src/vnet/adj/adj.c
index 90e7e60a329..a06a12210bc 100644
--- a/src/vnet/adj/adj.c
+++ b/src/vnet/adj/adj.c
@@ -22,7 +22,10 @@
#include <vnet/fib/fib_node_list.h>
/* Adjacency packet/byte counters indexed by adjacency index. */
-vlib_combined_counter_main_t adjacency_counters;
+vlib_combined_counter_main_t adjacency_counters = {
+ .name = "adjacency",
+ .stat_segment_name = "/net/adjacency",
+};
/*
* the single adj pool
@@ -64,7 +67,8 @@ adj_alloc (fib_protocol_t proto)
/* Validate adjacency counters. */
vlib_validate_combined_counter(&adjacency_counters,
adj_get_index(adj));
-
+ vlib_zero_combined_counter(&adjacency_counters,
+ adj_get_index(adj));
fib_node_init(&adj->ia_node,
FIB_NODE_TYPE_ADJ);
diff --git a/src/vnet/ip/ip.api b/src/vnet/ip/ip.api
index 71ad1c189c1..5cd0dfaac54 100644
--- a/src/vnet/ip/ip.api
+++ b/src/vnet/ip/ip.api
@@ -120,12 +120,15 @@ define ip_neighbor_dump
/** \brief IP neighboors dump response
@param context - sender context which was passed in the request
@param sw_if_index - The interface used to reach the neighbor
+ @param stats_index - An index in the stats segment that can be used to read
+ the counters for this neighbour.
@param is_static - [1|0] to indicate if neighbor is statically configured
@param is_ipv6 - [1|0] to indicate if address family is ipv[6|4]
*/
define ip_neighbor_details {
u32 context;
u32 sw_if_index;
+ u32 stats_index;
u8 is_static;
u8 is_ipv6;
u8 mac_address[6];
@@ -146,7 +149,7 @@ define ip_neighbor_details {
@param mac_address - l2 address of the neighbor
@param dst_address - ip4 or ip6 address of the neighbor
*/
-autoreply define ip_neighbor_add_del
+define ip_neighbor_add_del
{
u32 client_index;
u32 context;
@@ -160,6 +163,13 @@ autoreply define ip_neighbor_add_del
u8 dst_address[16];
};
+define ip_neighbor_add_del_reply
+{
+ u32 context;
+ i32 retval;
+ u32 stats_index;
+};
+
/** \brief Set the ip flow hash config for a fib request
@param client_index - opaque cookie to identify the sender
@param context - sender context, to match reply w/ request
diff --git a/src/vnet/ip/ip_api.c b/src/vnet/ip/ip_api.c
index 5dbc02d5c59..b0a7e82949b 100644
--- a/src/vnet/ip/ip_api.c
+++ b/src/vnet/ip/ip_api.c
@@ -659,6 +659,7 @@ vl_api_ip_neighbor_add_del_t_handler (vl_api_ip_neighbor_add_del_t * mp,
ip46_address_t ip = ip46_address_initializer;
vl_api_ip_neighbor_add_del_reply_t *rmp;
ip_neighbor_flags_t flags;
+ u32 stats_index = ~0;
int rv = 0;
VALIDATE_SW_IF_INDEX (mp);
@@ -678,14 +679,20 @@ vl_api_ip_neighbor_add_del_t_handler (vl_api_ip_neighbor_add_del_t * mp,
if (mp->is_add)
rv = ip_neighbor_add (&ip, mp->is_ipv6, mp->mac_address,
- ntohl (mp->sw_if_index), flags);
+ ntohl (mp->sw_if_index), flags, &stats_index);
else
rv = ip_neighbor_del (&ip, mp->is_ipv6, ntohl (mp->sw_if_index));
stats_dsunlock ();
BAD_SW_IF_INDEX_LABEL;
- REPLY_MACRO (VL_API_IP_NEIGHBOR_ADD_DEL_REPLY);
+
+ /* *INDENT-OFF* */
+ REPLY_MACRO2 (VL_API_IP_NEIGHBOR_ADD_DEL_REPLY,
+ ({
+ rmp->stats_index = htonl (stats_index);
+ }));
+ /* *INDENT-ON* */
}
void
diff --git a/src/vnet/ip/ip_neighbor.c b/src/vnet/ip/ip_neighbor.c
index 2edd737aa07..f5a816d5a18 100644
--- a/src/vnet/ip/ip_neighbor.c
+++ b/src/vnet/ip/ip_neighbor.c
@@ -50,8 +50,12 @@ static ip_neighbor_scan_config_t ip_neighbor_scan_conf;
int
ip_neighbor_add (const ip46_address_t * ip,
u8 is_ip6,
- const u8 * mac, u32 sw_if_index, ip_neighbor_flags_t flags)
+ const u8 * mac,
+ u32 sw_if_index,
+ ip_neighbor_flags_t flags, u32 * stats_index)
{
+ fib_protocol_t fproto;
+ vnet_link_t linkt;
int rv;
/*
@@ -66,7 +70,8 @@ ip_neighbor_add (const ip46_address_t * ip,
(flags & IP_NEIGHBOR_FLAG_STATIC),
(flags &
IP_NEIGHBOR_FLAG_NO_ADJ_FIB));
-
+ fproto = FIB_PROTOCOL_IP6;
+ linkt = VNET_LINK_IP6;
}
else
{
@@ -82,8 +87,13 @@ ip_neighbor_add (const ip46_address_t * ip,
(flags & IP_NEIGHBOR_FLAG_STATIC),
(flags &
IP_NEIGHBOR_FLAG_NO_ADJ_FIB));
+ fproto = FIB_PROTOCOL_IP4;
+ linkt = VNET_LINK_IP4;
}
+ if (0 == rv && stats_index)
+ *stats_index = adj_nbr_find (fproto, linkt, ip, sw_if_index);
+
return (rv);
}
diff --git a/src/vnet/ip/ip_neighbor.h b/src/vnet/ip/ip_neighbor.h
index b865862c06e..9eeebdb1555 100644
--- a/src/vnet/ip/ip_neighbor.h
+++ b/src/vnet/ip/ip_neighbor.h
@@ -45,7 +45,8 @@ typedef enum ip_neighbor_flags_t_
extern int ip_neighbor_add (const ip46_address_t * ip,
u8 is_ip6,
const u8 * mac,
- u32 sw_if_index, ip_neighbor_flags_t flags);
+ u32 sw_if_index,
+ ip_neighbor_flags_t flags, u32 * stats_index);
extern int ip_neighbor_del (const ip46_address_t * ip,
u8 is_ip6, u32 sw_if_index);