]> git.puffer.fish Git - mirror/frr.git/commitdiff
Show sums of checksums in "show ip ospf" output. Okayed by Paul and James
authorhasso <hasso>
Wed, 22 Dec 2004 16:16:02 +0000 (16:16 +0000)
committerhasso <hasso>
Wed, 22 Dec 2004 16:16:02 +0000 (16:16 +0000)
R. Leu (author of original idea).

ospfd/ChangeLog
ospfd/ospf_lsa.c
ospfd/ospf_lsdb.c
ospfd/ospf_lsdb.h
ospfd/ospf_vty.c

index 6bbeb9ddf8c78c952c486d7d0093a653fb95717f..e4519a812f92a71979d4b958d472c217ee419e9e 100644 (file)
@@ -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>
 
index b237adbc6e16c9d2bae1c0de855e1c174078f275..fbc56e157c78228ebd5d6aaa0b69df0e4b3984af 100644 (file)
@@ -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)
     {
index 46d8d70500a890375451333124d5b7ca87f8a79a..4c6ed64ebe0a8e0012ebde73e71b8d64ceaba0f1 100644 (file)
@@ -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);
 }
index 34344b3b499ee3a087f2657b3f649d0bd41d4382..8ae66a1573c00ab0e9608bb26c38b2879870b5a6 100644 (file)
@@ -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 */
index 264e4414100192de0df20ad8c3020522f71e3da5..b4c12ffbd49a56c53546d3f5df406a56f5846c8d 100644 (file)
@@ -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);