summaryrefslogtreecommitdiffstats
path: root/vrrpd
diff options
context:
space:
mode:
authorQuentin Young <qlyoung@cumulusnetworks.com>2019-02-22 19:51:38 +0100
committerQuentin Young <qlyoung@cumulusnetworks.com>2019-05-17 02:27:08 +0200
commit6332c77f98481d94c9243cbe6ffb57d131cf9d6a (patch)
tree770cf57eabbf0b347a20e92d20e67198a1771db3 /vrrpd
parentvrrpd: follow frrouting json conventions (diff)
downloadfrr-6332c77f98481d94c9243cbe6ffb57d131cf9d6a.tar.xz
frr-6332c77f98481d94c9243cbe6ffb57d131cf9d6a.zip
vrrpd: add statistics collection
Collect and display the following: - Advertisement Tx/Rx - GARP Tx/Rx - NDISC Tx/Rx - # transitions Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
Diffstat (limited to 'vrrpd')
-rw-r--r--vrrpd/vrrp.c6
-rw-r--r--vrrpd/vrrp.h12
-rw-r--r--vrrpd/vrrp_arp.c2
-rw-r--r--vrrpd/vrrp_ndisc.c2
-rw-r--r--vrrpd/vrrp_vty.c37
5 files changed, 59 insertions, 0 deletions
diff --git a/vrrpd/vrrp.c b/vrrpd/vrrp.c
index da6f5ba4d..89de0525d 100644
--- a/vrrpd/vrrp.c
+++ b/vrrpd/vrrp.c
@@ -604,6 +604,8 @@ static void vrrp_send_advertisement(struct vrrp_router *r)
zlog_warn(VRRP_LOGPFX VRRP_LOGPFX_VRID
"Failed to send VRRP Advertisement: %s",
r->vr->vrid, safe_strerror(errno));
+ } else {
+ ++r->stats.adver_tx_cnt;
}
}
@@ -690,6 +692,8 @@ static int vrrp_recv_advertisement(struct vrrp_router *r, struct ipaddr *src,
r->vr->vrid, family2str(r->family), pkt->hdr.naddr,
r->addrs->count);
+ ++r->stats.adver_rx_cnt;
+
int addrcmp;
switch (r->fsm.state) {
@@ -1270,6 +1274,8 @@ static void vrrp_change_state(struct vrrp_router *r, int to)
zlog_info(VRRP_LOGPFX VRRP_LOGPFX_VRID "%s -> %s", r->vr->vrid,
vrrp_state_names[r->fsm.state], vrrp_state_names[to]);
r->fsm.state = to;
+
+ ++r->stats.trans_cnt;
}
/*
diff --git a/vrrpd/vrrp.h b/vrrpd/vrrp.h
index 45f4e4ecb..94cd1ca3f 100644
--- a/vrrpd/vrrp.h
+++ b/vrrpd/vrrp.h
@@ -141,6 +141,18 @@ struct vrrp_router {
int state;
} fsm;
+ struct {
+ /* Total number of advertisements sent and received */
+ uint32_t adver_tx_cnt;
+ uint32_t adver_rx_cnt;
+ /* Total number of gratuitous ARPs sent */
+ uint32_t garp_tx_cnt;
+ /* Total number of unsolicited Neighbor Advertisements sent */
+ uint32_t una_tx_cnt;
+ /* Total number of state transitions */
+ uint32_t trans_cnt;
+ } stats;
+
struct thread *t_master_down_timer;
struct thread *t_adver_timer;
struct thread *t_read;
diff --git a/vrrpd/vrrp_arp.c b/vrrpd/vrrp_arp.c
index 018f0d769..006f31a95 100644
--- a/vrrpd/vrrp_arp.c
+++ b/vrrpd/vrrp_arp.c
@@ -147,6 +147,8 @@ void vrrp_garp_send(struct vrrp_router *r, struct in_addr *v4)
zlog_warn(VRRP_LOGPFX VRRP_LOGPFX_VRID
"Error sending gratuitous ARP on %s for %s",
r->vr->vrid, ifp->name, astr);
+ else
+ ++r->stats.garp_tx_cnt;
}
void vrrp_garp_send_all(struct vrrp_router *r)
diff --git a/vrrpd/vrrp_ndisc.c b/vrrpd/vrrp_ndisc.c
index 7b3fdde7c..6813506d1 100644
--- a/vrrpd/vrrp_ndisc.c
+++ b/vrrpd/vrrp_ndisc.c
@@ -187,6 +187,8 @@ int vrrp_ndisc_una_send(struct vrrp_router *r, struct ipaddr *ip)
"Error sending unsolicited Neighbor Advertisement on %s for %s",
r->vr->vrid, ifp->name, ipbuf);
ret = -1;
+ } else {
+ ++r->stats.una_tx_cnt;
}
return ret;
diff --git a/vrrpd/vrrp_vty.c b/vrrpd/vrrp_vty.c
index 4fe65b2ce..426aac4cd 100644
--- a/vrrpd/vrrp_vty.c
+++ b/vrrpd/vrrp_vty.c
@@ -300,6 +300,8 @@ DEFPY(vrrp_autoconfigure,
return CMD_SUCCESS;
}
+/* clang-format on */
+
/*
* Build JSON representation of VRRP instance.
*
@@ -320,8 +322,10 @@ static struct json_object *vrrp_build_json(struct vrrp_vrouter *vr)
struct ipaddr *ip;
struct json_object *j = json_object_new_object();
struct json_object *v4 = json_object_new_object();
+ struct json_object *v4_stats = json_object_new_object();
struct json_object *v4_addrs = json_object_new_array();
struct json_object *v6 = json_object_new_object();
+ struct json_object *v6_stats = json_object_new_object();
struct json_object *v6_addrs = json_object_new_array();
prefix_mac2str(&vr->v4->vmac, ethstr4, sizeof(ethstr4));
@@ -345,6 +349,13 @@ static struct json_object *vrrp_build_json(struct vrrp_vrouter *vr)
json_object_int_add(v4, "skewTime", vr->v4->skew_time);
json_object_int_add(v4, "masterDownInterval",
vr->v4->master_down_interval);
+ /* v4 stats */
+ json_object_int_add(v4_stats, "adverTx", vr->v4->stats.adver_tx_cnt);
+ json_object_int_add(v4_stats, "adverRx", vr->v4->stats.adver_rx_cnt);
+ json_object_int_add(v4_stats, "garpTx", vr->v4->stats.garp_tx_cnt);
+ json_object_int_add(v4_stats, "transitions", vr->v4->stats.trans_cnt);
+ json_object_object_add(v4, "stats", v4_stats);
+ /* v4 addrs */
if (vr->v4->addrs->count) {
for (ALL_LIST_ELEMENTS_RO(vr->v4->addrs, ln, ip)) {
inet_ntop(vr->v4->family, &ip->ipaddr_v4, ipstr,
@@ -367,6 +378,14 @@ static struct json_object *vrrp_build_json(struct vrrp_vrouter *vr)
json_object_int_add(v6, "skewTime", vr->v6->skew_time);
json_object_int_add(v6, "masterDownInterval",
vr->v6->master_down_interval);
+ /* v6 stats */
+ json_object_int_add(v6_stats, "adverTx", vr->v6->stats.adver_tx_cnt);
+ json_object_int_add(v6_stats, "adverRx", vr->v6->stats.adver_rx_cnt);
+ json_object_int_add(v6_stats, "neighborAdverTx",
+ vr->v6->stats.una_tx_cnt);
+ json_object_int_add(v6_stats, "transitions", vr->v6->stats.trans_cnt);
+ json_object_object_add(v6, "stats", v6_stats);
+ /* v6 addrs */
if (vr->v6->addrs->count) {
for (ALL_LIST_ELEMENTS_RO(vr->v6->addrs, ln, ip)) {
inet_ntop(vr->v6->family, &ip->ipaddr_v6, ipstr,
@@ -435,6 +454,22 @@ static void vrrp_show(struct vty *vty, struct vrrp_vrouter *vr)
ttable_add_row(tt, "%s|%" PRIu16 " cs",
"Master Advertisement Interval (v6)",
vr->v6->master_adver_interval);
+ ttable_add_row(tt, "%s|%" PRIu32, "Advertisements Tx (v4)",
+ vr->v4->stats.adver_tx_cnt);
+ ttable_add_row(tt, "%s|%" PRIu32, "Advertisements Tx (v6)",
+ vr->v6->stats.adver_tx_cnt);
+ ttable_add_row(tt, "%s|%" PRIu32, "Advertisements Rx (v4)",
+ vr->v4->stats.adver_rx_cnt);
+ ttable_add_row(tt, "%s|%" PRIu32, "Advertisements Rx (v6)",
+ vr->v6->stats.adver_rx_cnt);
+ ttable_add_row(tt, "%s|%" PRIu32, "Gratuitous ARP Tx (v4)",
+ vr->v4->stats.garp_tx_cnt);
+ ttable_add_row(tt, "%s|%" PRIu32, "Neigh. Adverts Tx (v6)",
+ vr->v6->stats.una_tx_cnt);
+ ttable_add_row(tt, "%s|%" PRIu32, "State transitions (v4)",
+ vr->v4->stats.trans_cnt);
+ ttable_add_row(tt, "%s|%" PRIu32, "State transitions (v6)",
+ vr->v6->stats.trans_cnt);
ttable_add_row(tt, "%s|%" PRIu16 " cs", "Skew Time (v4)",
vr->v4->skew_time);
ttable_add_row(tt, "%s|%" PRIu16 " cs", "Skew Time (v6)",
@@ -472,6 +507,8 @@ static void vrrp_show(struct vty *vty, struct vrrp_vrouter *vr)
ttable_del(tt);
}
+/* clang-format off */
+
DEFPY(vrrp_vrid_show,
vrrp_vrid_show_cmd,
"show vrrp [interface INTERFACE$ifn] [(1-255)$vrid] [json$json]",