forked from Mirror/frr
Show sums of checksums in "show ip ospf" output. Okayed by Paul and James
R. Leu (author of original idea).
This commit is contained in:
parent
16f6511e94
commit
fe71a97da2
|
@ -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>
|
||||
|
||||
|
|
|
@ -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)
|
||||
{
|
||||
|
|
|
@ -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 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;
|
||||
}
|
||||
|
|
|
@ -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 */
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in a new issue