[PATCH] Add statistics to the OSPF interface object
Kenth Eriksson
kenth.eriksson at infinera.com
Thu Sep 5 16:28:17 CEST 2019
For now only OSPF authentication drops...
Signed-off-by: Kenth Eriksson <kenth.eriksson at infinera.com>
---
proto/ospf/iface.c | 1 +
proto/ospf/ospf.h | 6 ++++++
proto/ospf/packet.c | 4 ++++
3 files changed, 11 insertions(+)
diff --git a/proto/ospf/iface.c b/proto/ospf/iface.c
index 6e7e498f..988c0b70 100644
--- a/proto/ospf/iface.c
+++ b/proto/ospf/iface.c
@@ -1404,4 +1404,5 @@ ospf_iface_info(struct ospf_iface *ifa)
cli_msg(-1015, "\tBackup designated router (ID): %R", ifa->bdrid);
cli_msg(-1015, "\tBackup designated router (IP): %I", ifa->bdrip);
}
+ cli_msg(-1015, "\tAuthentication drops: %u", ifa->stats.drop_auth);
}
diff --git a/proto/ospf/ospf.h b/proto/ospf/ospf.h
index 8318ee95..e13e4bb2 100644
--- a/proto/ospf/ospf.h
+++ b/proto/ospf/ospf.h
@@ -273,6 +273,11 @@ struct ospf_area
struct fib rtr; /* Routing tables for routers */
};
+struct ospf_iface_stats
+{
+ u32 drop_auth; /* Drops due to authentication fail */
+};
+
struct ospf_iface
{
node n;
@@ -316,6 +321,7 @@ struct ospf_iface
u8 instance_id; /* Used to differentiate between more OSPF
instances on one interface */
u8 autype; /* Authentication type (OSPF_AUTH_*) */
+ struct ospf_iface_stats stats;/* Interface statistics */
u8 type; /* OSPF view of type (OSPF_IT_*) */
u8 strictnbma; /* Can I talk with unknown neighbors? */
u8 stub; /* Inactive interface */
diff --git a/proto/ospf/packet.c b/proto/ospf/packet.c
index 599f3094..7c6c328e 100644
--- a/proto/ospf/packet.c
+++ b/proto/ospf/packet.c
@@ -214,6 +214,7 @@ ospf_pkt_checkauth2(struct ospf_neighbor *n, struct ospf_iface *ifa, struct ospf
if (n && (rcv_csn < n->csn))
// DROP("lower sequence number", rcv_csn);
{
+ ifa->stats.drop_auth++;
/* We want to report both new and old CSN */
LOG_PKT_AUTH("Authentication failed for nbr %R on %s - "
"lower sequence number (rcv %u, old %u)",
@@ -245,6 +246,7 @@ ospf_pkt_checkauth2(struct ospf_neighbor *n, struct ospf_iface *ifa, struct ospf
}
drop:
+ ifa->stats.drop_auth++;
LOG_PKT_AUTH("Authentication failed for nbr %R on %s - %s (%u)",
(n ? n->rid : ntohl(pkt->routerid)), ifa->ifname, err_dsc, err_val);
@@ -327,6 +329,7 @@ ospf_pkt_checkauth3(struct ospf_neighbor *n, struct ospf_iface *ifa, struct ospf
u64 rcv_csn = get_u64(&auth->csn);
if (n && (rcv_csn <= n->csn64[pt]))
{
+ ifa->stats.drop_auth++;
/* We want to report both new and old CSN */
LOG_PKT_AUTH("Authentication failed for nbr %R on %s - "
"lower sequence number (rcv %u, old %u)",
@@ -358,6 +361,7 @@ ospf_pkt_checkauth3(struct ospf_neighbor *n, struct ospf_iface *ifa, struct ospf
return 1;
drop:
+ ifa->stats.drop_auth++;
LOG_PKT_AUTH("Authentication failed for nbr %R on %s - %s (%u)",
(n ? n->rid : ntohl(pkt->routerid)), ifa->ifname, err_dsc, err_val);
--
2.21.0
More information about the Bird-users
mailing list