summaryrefslogtreecommitdiffstats
path: root/ospf6d
diff options
context:
space:
mode:
authorDavid Schweizer <dschweizer@opensourcerouting.org>2022-01-12 12:30:59 +0100
committerDavid Schweizer <dschweizer@opensourcerouting.org>2022-01-12 12:30:59 +0100
commit8935a149e580ea91b3ef5941439f59f740f22e3a (patch)
tree96e876c8a27a1663ee16ab4bc8ae51a2b6ffd812 /ospf6d
parentMerge pull request #10355 from opensourcerouting/noisy-startup (diff)
downloadfrr-8935a149e580ea91b3ef5941439f59f740f22e3a.tar.xz
frr-8935a149e580ea91b3ef5941439f59f740f22e3a.zip
ospf6d: add LSA statistics to LSA database
Signed-off-by: David Schweizer <dschweizer@opensourcerouting.org>
Diffstat (limited to 'ospf6d')
-rw-r--r--ospf6d/ospf6_lsdb.c12
-rw-r--r--ospf6d/ospf6_lsdb.h1
2 files changed, 13 insertions, 0 deletions
diff --git a/ospf6d/ospf6_lsdb.c b/ospf6d/ospf6_lsdb.c
index 039c65d73..889ab16b1 100644
--- a/ospf6d/ospf6_lsdb.c
+++ b/ospf6d/ospf6_lsdb.c
@@ -92,6 +92,16 @@ static void _lsdb_count_assert(struct ospf6_lsdb *lsdb)
#define ospf6_lsdb_count_assert(t) ((void) 0)
#endif /*DEBUG*/
+static inline void ospf6_lsdb_stats_update(struct ospf6_lsa *lsa,
+ struct ospf6_lsdb *lsdb, int count)
+{
+ uint16_t stat = ntohs(lsa->header->type) & OSPF6_LSTYPE_FCODE_MASK;
+
+ if (stat >= OSPF6_LSTYPE_SIZE)
+ stat = OSPF6_LSTYPE_UNKNOWN;
+ lsdb->stats[stat] += count;
+}
+
void ospf6_lsdb_add(struct ospf6_lsa *lsa, struct ospf6_lsdb *lsdb)
{
struct prefix_ipv6 key;
@@ -112,6 +122,7 @@ void ospf6_lsdb_add(struct ospf6_lsa *lsa, struct ospf6_lsdb *lsdb)
if (!old) {
lsdb->count++;
+ ospf6_lsdb_stats_update(lsa, lsdb, 1);
if (OSPF6_LSA_IS_MAXAGE(lsa)) {
if (lsdb->hook_remove)
@@ -161,6 +172,7 @@ void ospf6_lsdb_remove(struct ospf6_lsa *lsa, struct ospf6_lsdb *lsdb)
node->info = NULL;
lsdb->count--;
+ ospf6_lsdb_stats_update(lsa, lsdb, -1);
if (lsdb->hook_remove)
(*lsdb->hook_remove)(lsa);
diff --git a/ospf6d/ospf6_lsdb.h b/ospf6d/ospf6_lsdb.h
index 9789e8c4e..07c331af6 100644
--- a/ospf6d/ospf6_lsdb.h
+++ b/ospf6d/ospf6_lsdb.h
@@ -29,6 +29,7 @@ struct ospf6_lsdb {
void *data; /* data structure that holds this lsdb */
struct route_table *table;
uint32_t count;
+ uint32_t stats[OSPF6_LSTYPE_SIZE];
void (*hook_add)(struct ospf6_lsa *);
void (*hook_remove)(struct ospf6_lsa *);
};