diff options
| author | Igor Ryzhov <iryzhov@nfware.com> | 2022-02-06 21:46:13 +0300 | 
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-02-06 21:46:13 +0300 | 
| commit | 88386db620e1e31d99a158ea75ad460fe78e61e0 (patch) | |
| tree | bfe59f47978d64bcf35262730d9e794ee1a78cc8 /ospf6d | |
| parent | c1b7277445196f434f7e4d8f9da8f2acf54f6b7e (diff) | |
| parent | 0b11b56abd258a65786c99d18412149c5963ca19 (diff) | |
Merge pull request #10323 from opensourcerouting/ospf6-lsa-stats
ospf6d: LSA statistics
Diffstat (limited to 'ospf6d')
| -rw-r--r-- | ospf6d/ospf6_area.c | 5 | ||||
| -rw-r--r-- | ospf6d/ospf6_lsdb.c | 12 | ||||
| -rw-r--r-- | ospf6d/ospf6_lsdb.h | 1 | 
3 files changed, 18 insertions, 0 deletions
diff --git a/ospf6d/ospf6_area.c b/ospf6d/ospf6_area.c index a612f7d1b8..a0cb455798 100644 --- a/ospf6d/ospf6_area.c +++ b/ospf6d/ospf6_area.c @@ -455,6 +455,11 @@ void ospf6_area_show(struct vty *vty, struct ospf6_area *oa,  		json_object_int_add(json_area, "numberOfAreaScopedLsa",  				    oa->lsdb->count); +		json_object_object_add( +			json_area, "lsaStatistics", +			JSON_OBJECT_NEW_ARRAY(json_object_new_int, +					      oa->lsdb->stats, +					      OSPF6_LSTYPE_SIZE));  		/* Interfaces Attached */  		array_interfaces = json_object_new_array(); diff --git a/ospf6d/ospf6_lsdb.c b/ospf6d/ospf6_lsdb.c index 039c65d739..889ab16b11 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 9789e8c4e0..07c331af64 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 *);  };  | 
