Show sums of checksums in "show ip ospf" output. Okayed by Paul and James
R. Leu (author of original idea).
diff --git a/ospfd/ChangeLog b/ospfd/ChangeLog
index 6bbeb9d..e4519a8 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 <ajschorr@alumni.princeton.edu>
diff --git a/ospfd/ospf_lsa.c b/ospfd/ospf_lsa.c
index b237adb..fbc56e1 100644
--- a/ospfd/ospf_lsa.c
+++ b/ospfd/ospf_lsa.c
@@ -2654,14 +2654,14 @@
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 46d8d70..4c6ed64 100644
--- a/ospfd/ospf_lsdb.c
+++ b/ospfd/ospf_lsdb.c
@@ -97,6 +97,7 @@
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 @@
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 @@
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 @@
return lsdb->type[type].count_self;
}
+unsigned int
+ospf_lsdb_checksum (struct ospf_lsdb *lsdb, int type)
+{
+ return lsdb->type[type].checksum;
+}
+
unsigned long
ospf_lsdb_isempty (struct ospf_lsdb *lsdb)
{
return (lsdb->total == 0);
}
-
-struct ospf_lsa *
-foreach_lsa (struct route_table *table, void *p_arg, int int_arg,
- int (*callback) (struct ospf_lsa *, void *, int))
-{
- 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;
-}
diff --git a/ospfd/ospf_lsdb.h b/ospfd/ospf_lsdb.h
index 34344b3..8ae66a1 100644
--- a/ospfd/ospf_lsdb.h
+++ b/ospfd/ospf_lsdb.h
@@ -30,6 +30,7 @@
{
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 @@
};
/* 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 @@
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 264e441..b4c12ff 100644
--- a/ospfd/ospf_vty.c
+++ b/ospfd/ospf_vty.c
@@ -2428,7 +2428,29 @@
/* 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 @@
"(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);