summaryrefslogtreecommitdiff
path: root/usr.sbin/eigrpd
diff options
context:
space:
mode:
Diffstat (limited to 'usr.sbin/eigrpd')
-rw-r--r--usr.sbin/eigrpd/control.c5
-rw-r--r--usr.sbin/eigrpd/eigrpd.h27
-rw-r--r--usr.sbin/eigrpd/eigrpe.c19
-rw-r--r--usr.sbin/eigrpd/eigrpe.h3
-rw-r--r--usr.sbin/eigrpd/packet.c44
5 files changed, 90 insertions, 8 deletions
diff --git a/usr.sbin/eigrpd/control.c b/usr.sbin/eigrpd/control.c
index 61ba96f59e6..ff5a1f03bd1 100644
--- a/usr.sbin/eigrpd/control.c
+++ b/usr.sbin/eigrpd/control.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: control.c,v 1.2 2015/12/05 15:49:01 claudio Exp $ */
+/* $OpenBSD: control.c,v 1.3 2015/12/13 18:55:53 renato Exp $ */
/*
* Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org>
@@ -278,6 +278,9 @@ control_dispatch_imsg(int fd, short event, void *bula)
case IMSG_CTL_SHOW_NBR:
eigrpe_nbr_ctl(c);
break;
+ case IMSG_CTL_SHOW_STATS:
+ eigrpe_stats_ctl(c);
+ break;
case IMSG_CTL_LOG_VERBOSE:
if (imsg.hdr.len != IMSG_HEADER_SIZE +
sizeof(verbose))
diff --git a/usr.sbin/eigrpd/eigrpd.h b/usr.sbin/eigrpd/eigrpd.h
index 473501b8cf0..a2d1db7dae8 100644
--- a/usr.sbin/eigrpd/eigrpd.h
+++ b/usr.sbin/eigrpd/eigrpd.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: eigrpd.h,v 1.5 2015/10/21 03:52:12 renato Exp $ */
+/* $OpenBSD: eigrpd.h,v 1.6 2015/12/13 18:55:53 renato Exp $ */
/*
* Copyright (c) 2015 Renato Westphal <renato@openbsd.org>
@@ -71,6 +71,7 @@ enum imsg_type {
IMSG_CTL_SHOW_INTERFACE,
IMSG_CTL_SHOW_NBR,
IMSG_CTL_SHOW_TOPOLOGY,
+ IMSG_CTL_SHOW_STATS,
IMSG_CTL_FIB_COUPLE,
IMSG_CTL_FIB_DECOUPLE,
IMSG_CTL_IFACE,
@@ -252,6 +253,23 @@ struct redistribute {
};
SIMPLEQ_HEAD(redist_list, redistribute);
+struct eigrp_stats {
+ uint32_t hellos_sent;
+ uint32_t hellos_recv;
+ uint32_t updates_sent;
+ uint32_t updates_recv;
+ uint32_t queries_sent;
+ uint32_t queries_recv;
+ uint32_t replies_sent;
+ uint32_t replies_recv;
+ uint32_t acks_sent;
+ uint32_t acks_recv;
+ uint32_t squeries_sent;
+ uint32_t squeries_recv;
+ uint32_t sreplies_sent;
+ uint32_t sreplies_recv;
+};
+
/* eigrp instance */
struct eigrp {
TAILQ_ENTRY(eigrp) entry;
@@ -270,6 +288,7 @@ struct eigrp {
struct rde_nbr *rnbr_summary;
struct rt_tree topology;
uint32_t seq_num;
+ struct eigrp_stats stats;
};
/* eigrp_conf */
@@ -399,6 +418,12 @@ struct ctl_show_topology_req {
uint16_t flags;
};
+struct ctl_stats {
+ int af;
+ uint16_t as;
+ struct eigrp_stats stats;
+};
+
/* parse.y */
struct eigrpd_conf *parse_config(char *, int);
int cmdline_symset(char *);
diff --git a/usr.sbin/eigrpd/eigrpe.c b/usr.sbin/eigrpd/eigrpe.c
index f40dcd65267..df9f1d61536 100644
--- a/usr.sbin/eigrpd/eigrpe.c
+++ b/usr.sbin/eigrpd/eigrpe.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: eigrpe.c,v 1.9 2015/12/05 15:49:01 claudio Exp $ */
+/* $OpenBSD: eigrpe.c,v 1.10 2015/12/13 18:55:53 renato Exp $ */
/*
* Copyright (c) 2015 Renato Westphal <renato@openbsd.org>
@@ -690,3 +690,20 @@ eigrpe_nbr_ctl(struct ctl_conn *c)
imsg_compose_event(&c->iev, IMSG_CTL_END, 0, 0, -1, NULL, 0);
}
+
+void
+eigrpe_stats_ctl(struct ctl_conn *c)
+{
+ struct eigrp *eigrp;
+ struct ctl_stats sctl;
+
+ TAILQ_FOREACH(eigrp, &econf->instances, entry) {
+ sctl.af = eigrp->af;
+ sctl.as = eigrp->as;
+ memcpy(&sctl.stats, &eigrp->stats, sizeof(sctl.stats));
+ imsg_compose_event(&c->iev, IMSG_CTL_SHOW_STATS, 0,
+ 0, -1, &sctl, sizeof(struct ctl_stats));
+ }
+
+ imsg_compose_event(&c->iev, IMSG_CTL_END, 0, 0, -1, NULL, 0);
+}
diff --git a/usr.sbin/eigrpd/eigrpe.h b/usr.sbin/eigrpd/eigrpe.h
index 434c26d6159..360578cfe1b 100644
--- a/usr.sbin/eigrpd/eigrpe.h
+++ b/usr.sbin/eigrpd/eigrpe.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: eigrpe.h,v 1.3 2015/10/05 01:59:33 renato Exp $ */
+/* $OpenBSD: eigrpe.h,v 1.4 2015/12/13 18:55:53 renato Exp $ */
/*
* Copyright (c) 2015 Renato Westphal <renato@openbsd.org>
@@ -85,6 +85,7 @@ void eigrpe_orig_local_route(struct eigrp_iface *,
struct if_addr *, int);
void eigrpe_iface_ctl(struct ctl_conn *, unsigned int);
void eigrpe_nbr_ctl(struct ctl_conn *);
+void eigrpe_stats_ctl(struct ctl_conn *);
/* interface.c */
struct iface *if_new(struct eigrpd_conf *, struct kif *);
diff --git a/usr.sbin/eigrpd/packet.c b/usr.sbin/eigrpd/packet.c
index 05a57f6db1e..9dfa9e08ed8 100644
--- a/usr.sbin/eigrpd/packet.c
+++ b/usr.sbin/eigrpd/packet.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: packet.c,v 1.4 2015/10/10 05:03:39 renato Exp $ */
+/* $OpenBSD: packet.c,v 1.5 2015/12/13 18:55:53 renato Exp $ */
/*
* Copyright (c) 2015 Renato Westphal <renato@openbsd.org>
@@ -190,15 +190,43 @@ send_packet(struct eigrp_iface *ei, struct nbr *nbr, uint32_t flags,
switch (eigrp->af) {
case AF_INET:
- send_packet_v4(iface, nbr, buf);
+ if (send_packet_v4(iface, nbr, buf) < 0)
+ return (-1);
break;
case AF_INET6:
- send_packet_v6(iface, nbr, buf);
+ if (send_packet_v6(iface, nbr, buf) < 0)
+ return (-1);
break;
default:
fatalx("send_packet: unknown af");
}
+ switch (eigrp_hdr->opcode) {
+ case EIGRP_OPC_HELLO:
+ if (ntohl(eigrp_hdr->ack_num) == 0)
+ ei->eigrp->stats.hellos_sent++;
+ else
+ ei->eigrp->stats.acks_sent++;
+ break;
+ case EIGRP_OPC_UPDATE:
+ ei->eigrp->stats.updates_sent++;
+ break;
+ case EIGRP_OPC_QUERY:
+ ei->eigrp->stats.queries_sent++;
+ break;
+ case EIGRP_OPC_REPLY:
+ ei->eigrp->stats.replies_sent++;
+ break;
+ case EIGRP_OPC_SIAQUERY:
+ ei->eigrp->stats.squeries_sent++;
+ break;
+ case EIGRP_OPC_SIAREPLY:
+ ei->eigrp->stats.sreplies_sent++;
+ break;
+ default:
+ break;
+ }
+
return (0);
}
@@ -402,23 +430,31 @@ recv_packet(int af, union eigrpd_addr *src, union eigrpd_addr *dest,
/* switch EIGRP packet type */
switch (eigrp_hdr->opcode) {
case EIGRP_OPC_HELLO:
- if (ntohl(eigrp_hdr->ack_num) == 0)
+ if (ntohl(eigrp_hdr->ack_num) == 0) {
recv_hello(ei, src, nbr, tp);
+ ei->eigrp->stats.hellos_recv++;
+ } else
+ ei->eigrp->stats.acks_recv++;
break;
case EIGRP_OPC_UPDATE:
recv_update(nbr, &rinfo_list, ntohl(eigrp_hdr->flags));
+ ei->eigrp->stats.updates_recv++;
break;
case EIGRP_OPC_QUERY:
recv_query(nbr, &rinfo_list, 0);
+ ei->eigrp->stats.queries_recv++;
break;
case EIGRP_OPC_REPLY:
recv_reply(nbr, &rinfo_list, 0);
+ ei->eigrp->stats.replies_recv++;
break;
case EIGRP_OPC_SIAQUERY:
recv_query(nbr, &rinfo_list, 1);
+ ei->eigrp->stats.squeries_recv++;
break;
case EIGRP_OPC_SIAREPLY:
recv_reply(nbr, &rinfo_list, 1);
+ ei->eigrp->stats.sreplies_recv++;
break;
default:
log_debug("%s: unknown EIGRP packet type, interface %s",