summaryrefslogtreecommitdiffstats
path: root/src/vnet/ip
diff options
context:
space:
mode:
authorNeale Ranns <neale.ranns@cisco.com>2018-09-28 05:00:57 -0700
committerDamjan Marion <dmarion@me.com>2018-10-01 17:02:18 +0000
commit14260393c096b270ef318d74b481911c7def0496 (patch)
tree29bbd213ea550254b15131684e34032b4b8ab9e7 /src/vnet/ip
parent5df628bb8a30b69f223a7c8b017dcba770c87e43 (diff)
Add adjacency counters to the stats segment
Change-Id: I6b59df939c9daf40e261d73d19f500bd90abe6ff Signed-off-by: Neale Ranns <neale.ranns@cisco.com>
Diffstat (limited to 'src/vnet/ip')
-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
4 files changed, 34 insertions, 6 deletions
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);