From fe71a97da23e2282bc92f647227d5c97c73e3bc8 Mon Sep 17 00:00:00 2001 From: hasso Date: Wed, 22 Dec 2004 16:16:02 +0000 Subject: Show sums of checksums in "show ip ospf" output. Okayed by Paul and James R. Leu (author of original idea). --- ospfd/ChangeLog | 6 ++++++ ospfd/ospf_lsa.c | 8 ++++---- ospfd/ospf_lsdb.c | 24 +++++++++--------------- ospfd/ospf_lsdb.h | 9 +++++---- ospfd/ospf_vty.c | 35 +++++++++++++++++++++++++++++++---- 5 files changed, 55 insertions(+), 27 deletions(-) (limited to 'ospfd') diff --git a/ospfd/ChangeLog b/ospfd/ChangeLog index 6bbeb9dd..e4519a81 100644 --- a/ospfd/ChangeLog +++ b/ospfd/ChangeLog @@ -3,6 +3,12 @@ * ospf_dump.c: Show debug configuration in vtysh. * ospf_vty.c: Fix "show ip ospf" output. Router can't be elected in any case if it's configured as "translate-never". + * ospf_lsdb.[ch]: New function to calculate sum of checksums. + * ospf_vty.c: Bugfix to show really number of AS external LSAs, not + number of all LSAs with AS scope, this includes opaque as LSAs as + well, show this number separately. Show numbers and sums of + checksums for each type of LSAs. + * ospf_lsa.c: Calculate checksum before putting LSA into database. 2004-12-15 Andrew J. Schorr diff --git a/ospfd/ospf_lsa.c b/ospfd/ospf_lsa.c index b237adbc..fbc56e15 100644 --- a/ospfd/ospf_lsa.c +++ b/ospfd/ospf_lsa.c @@ -2654,14 +2654,14 @@ ospf_lsa_install (struct ospf *ospf, struct ospf_interface *oi, if (old != NULL) ospf_discard_from_db (ospf, lsdb, lsa); - /* Insert LSA to LSDB. */ - ospf_lsdb_add (lsdb, lsa); - lsa->lsdb = lsdb; - /* Calculate Checksum if self-originated?. */ if (IS_LSA_SELF (lsa)) ospf_lsa_checksum (lsa->data); + /* Insert LSA to LSDB. */ + ospf_lsdb_add (lsdb, lsa); + lsa->lsdb = lsdb; + /* Do LSA specific installation process. */ switch (lsa->data->type) { diff --git a/ospfd/ospf_lsdb.c b/ospfd/ospf_lsdb.c index 46d8d705..4c6ed64e 100644 --- a/ospfd/ospf_lsdb.c +++ b/ospfd/ospf_lsdb.c @@ -97,6 +97,7 @@ ospf_lsdb_add (struct ospf_lsdb *lsdb, struct ospf_lsa *lsa) if (IS_LSA_SELF (lsa)) lsdb->type[lsa->data->type].count_self++; lsdb->type[lsa->data->type].count++; + lsdb->type[lsa->data->type].checksum += ntohs(lsa->data->checksum); lsdb->total++; } else @@ -131,6 +132,7 @@ ospf_lsdb_delete (struct ospf_lsdb *lsdb, struct ospf_lsa *lsa) if (IS_LSA_SELF (lsa)) lsdb->type[lsa->data->type].count_self--; lsdb->type[lsa->data->type].count--; + lsdb->type[lsa->data->type].checksum -= ntohs(lsa->data->checksum); lsdb->total--; rn->info = NULL; route_unlock_node (rn); @@ -161,6 +163,7 @@ ospf_lsdb_delete_all (struct ospf_lsdb *lsdb) if (IS_LSA_SELF (lsa)) lsdb->type[i].count_self--; lsdb->type[i].count--; + lsdb->type[i].checksum -= ntohs(lsa->data->checksum); lsdb->total--; rn->info = NULL; route_unlock_node (rn); @@ -277,23 +280,14 @@ ospf_lsdb_count_self (struct ospf_lsdb *lsdb, int type) return lsdb->type[type].count_self; } -unsigned long -ospf_lsdb_isempty (struct ospf_lsdb *lsdb) +unsigned int +ospf_lsdb_checksum (struct ospf_lsdb *lsdb, int type) { - return (lsdb->total == 0); + return lsdb->type[type].checksum; } -struct ospf_lsa * -foreach_lsa (struct route_table *table, void *p_arg, int int_arg, - int (*callback) (struct ospf_lsa *, void *, int)) +unsigned long +ospf_lsdb_isempty (struct ospf_lsdb *lsdb) { - struct route_node *rn; - struct ospf_lsa *lsa; - - for (rn = route_top (table); rn; rn = route_next (rn)) - if ((lsa = rn->info) != NULL) - if (callback (lsa, p_arg, int_arg)) - return lsa; - - return NULL; + return (lsdb->total == 0); } diff --git a/ospfd/ospf_lsdb.h b/ospfd/ospf_lsdb.h index 34344b3b..8ae66a15 100644 --- a/ospfd/ospf_lsdb.h +++ b/ospfd/ospf_lsdb.h @@ -30,6 +30,7 @@ struct ospf_lsdb { unsigned long count; unsigned long count_self; + unsigned int checksum; struct route_table *db; } type[OSPF_MAX_LSA]; unsigned long total; @@ -42,8 +43,9 @@ struct ospf_lsdb }; /* Macros. */ -#define LSDB_LOOP(T,N,L) \ - for ((N) = route_top ((T)); ((N)); ((N)) = route_next ((N))) \ +#define LSDB_LOOP(T,N,L) \ + if ((T) != NULL) \ + for ((N) = route_top ((T)); ((N)); ((N)) = route_next ((N))) \ if (((L) = (N)->info)) #define ROUTER_LSDB(A) ((A)->lsdb->type[OSPF_ROUTER_LSA].db) @@ -76,8 +78,7 @@ struct ospf_lsa *ospf_lsdb_lookup_by_id_next (struct ospf_lsdb *, u_char, unsigned long ospf_lsdb_count_all (struct ospf_lsdb *); unsigned long ospf_lsdb_count (struct ospf_lsdb *, int); unsigned long ospf_lsdb_count_self (struct ospf_lsdb *, int); +unsigned int ospf_lsdb_checksum (struct ospf_lsdb *, int); unsigned long ospf_lsdb_isempty (struct ospf_lsdb *); -struct ospf_lsa *foreach_lsa (struct route_table *, void *, int, - int (*callback) (struct ospf_lsa *, void *, int)); #endif /* _ZEBRA_OSPF_LSDB_H */ diff --git a/ospfd/ospf_vty.c b/ospfd/ospf_vty.c index 264e4414..b4c12ffb 100644 --- a/ospfd/ospf_vty.c +++ b/ospfd/ospf_vty.c @@ -2428,7 +2428,29 @@ show_ip_ospf_area (struct vty *vty, struct ospf_area *area) /* Show number of LSA. */ vty_out (vty, " Number of LSA %ld%s", area->lsdb->total, VTY_NEWLINE); - + vty_out (vty, " Number of router LSA %ld. Checksum Sum 0x%08x%s", + ospf_lsdb_count (area->lsdb, OSPF_ROUTER_LSA), + ospf_lsdb_checksum (area->lsdb, OSPF_ROUTER_LSA), VTY_NEWLINE); + vty_out (vty, " Number of network LSA %ld. Checksum Sum 0x%08x%s", + ospf_lsdb_count (area->lsdb, OSPF_NETWORK_LSA), + ospf_lsdb_checksum (area->lsdb, OSPF_NETWORK_LSA), VTY_NEWLINE); + vty_out (vty, " Number of summary LSA %ld. Checksum Sum 0x%08x%s", + ospf_lsdb_count (area->lsdb, OSPF_SUMMARY_LSA), + ospf_lsdb_checksum (area->lsdb, OSPF_SUMMARY_LSA), VTY_NEWLINE); + vty_out (vty, " Number of ASBR summary LSA %ld. Checksum Sum 0x%08x%s", + ospf_lsdb_count (area->lsdb, OSPF_ASBR_SUMMARY_LSA), + ospf_lsdb_checksum (area->lsdb, OSPF_ASBR_SUMMARY_LSA), VTY_NEWLINE); + vty_out (vty, " Number of NSSA LSA %ld. Checksum Sum 0x%08x%s", + ospf_lsdb_count (area->lsdb, OSPF_AS_NSSA_LSA), + ospf_lsdb_checksum (area->lsdb, OSPF_AS_NSSA_LSA), VTY_NEWLINE); +#ifdef HAVE_OPAQUE_LSA + vty_out (vty, " Number of opaque link LSA %ld. Checksum Sum 0x%08x%s", + ospf_lsdb_count (area->lsdb, OSPF_OPAQUE_LINK_LSA), + ospf_lsdb_checksum (area->lsdb, OSPF_OPAQUE_LINK_LSA), VTY_NEWLINE); + vty_out (vty, " Number of opaque area LSA %ld. Checksum Sum 0x%08x%s", + ospf_lsdb_count (area->lsdb, OSPF_OPAQUE_AREA_LSA), + ospf_lsdb_checksum (area->lsdb, OSPF_OPAQUE_AREA_LSA), VTY_NEWLINE); +#endif /* HAVE_OPAQUE_LSA */ vty_out (vty, "%s", VTY_NEWLINE); } @@ -2489,9 +2511,14 @@ DEFUN (show_ip_ospf, "(injecting external routing information)%s", VTY_NEWLINE); /* Show Number of AS-external-LSAs. */ - vty_out (vty, " Number of external LSA %ld%s", - ospf_lsdb_count_all (ospf->lsdb), VTY_NEWLINE); - + vty_out (vty, " Number of external LSA %ld. Checksum Sum 0x%08x%s", + ospf_lsdb_count (ospf->lsdb, OSPF_AS_EXTERNAL_LSA), + ospf_lsdb_checksum (ospf->lsdb, OSPF_AS_EXTERNAL_LSA), VTY_NEWLINE); +#ifdef HAVE_OPAQUE_LSA + vty_out (vty, " Number of opaque AS LSA %ld. Checksum Sum 0x%08x%s", + ospf_lsdb_count (ospf->lsdb, OSPF_OPAQUE_AS_LSA), + ospf_lsdb_checksum (ospf->lsdb, OSPF_OPAQUE_AS_LSA), VTY_NEWLINE); +#endif /* HAVE_OPAQUE_LSA */ /* Show number of areas attached. */ vty_out (vty, " Number of areas attached to this router: %d%s%s", listcount (ospf->areas), VTY_NEWLINE, VTY_NEWLINE); -- cgit v1.2.1