]> git.puffer.fish Git - mirror/frr.git/commitdiff
[ospfd] Fix a few LSA performance "bugs"
authorJoakim Tjernlund <Joakim.Tjernlund@transmode.se>
Tue, 4 Nov 2008 13:37:29 +0000 (13:37 +0000)
committerPaul Jakma <paul@quagga.net>
Thu, 25 Jun 2009 11:23:27 +0000 (12:23 +0100)
ospf_lsa_install() will calculate LSA checksum so no
need to do it before calling ospf_lsa_install().

Set the OSPF_LSA_SELF_CHECKED flag on own LSA's to
save ospf_lsa_is_self_originated() some work.

Do not memset() memory that is about to overwritten
with memcpy().

ospfd/ospf_lsa.c

index 3c9c73a3b9d0c213e1e22ee14ec55dc184274c8e..18eed79e72d89de159427bd4222d8283e70f57c3 100644 (file)
@@ -201,7 +201,6 @@ ospf_lsa_new ()
   struct ospf_lsa *new;
 
   new = XCALLOC (MTYPE_OSPF_LSA, sizeof (struct ospf_lsa));
-  memset (new, 0, sizeof (struct ospf_lsa));
 
   new->flags = 0;
   new->lock = 1;
@@ -822,7 +821,7 @@ ospf_router_lsa_new (struct ospf_area *area)
     }
   
   new->area = area;
-  SET_FLAG (new->flags, OSPF_LSA_SELF);
+  SET_FLAG (new->flags, OSPF_LSA_SELF | OSPF_LSA_SELF_CHECKED);
 
   /* Copy LSA data to store, discard stream. */
   new->data = ospf_lsa_data_new (length);
@@ -1081,7 +1080,7 @@ ospf_network_lsa_new (struct ospf_interface *oi)
     }
   
   new->area = oi->area;
-  SET_FLAG (new->flags, OSPF_LSA_SELF);
+  SET_FLAG (new->flags, OSPF_LSA_SELF | OSPF_LSA_SELF_CHECKED);
 
   /* Copy LSA to store. */
   new->data = ospf_lsa_data_new (length);
@@ -1275,7 +1274,7 @@ ospf_summary_lsa_new (struct ospf_area *area, struct prefix *p,
   /* Create OSPF LSA instance. */
   new = ospf_lsa_new ();
   new->area = area;
-  SET_FLAG (new->flags, OSPF_LSA_SELF);
+  SET_FLAG (new->flags, OSPF_LSA_SELF | OSPF_LSA_SELF_CHECKED);
 
   /* Copy LSA to store. */
   new->data = ospf_lsa_data_new (length);
@@ -1346,9 +1345,6 @@ ospf_summary_lsa_refresh (struct ospf *ospf, struct ospf_lsa *lsa)
     return NULL;
   
   new->data->ls_seqnum = lsa_seqnum_increment (lsa);
-  
-  /* Re-calculate checksum. */
-  ospf_lsa_checksum (new->data);
 
   ospf_lsa_install (ospf, NULL, new);
   
@@ -1424,7 +1420,7 @@ ospf_summary_asbr_lsa_new (struct ospf_area *area, struct prefix *p,
   /* Create OSPF LSA instance. */
   new = ospf_lsa_new ();
   new->area = area;
-  SET_FLAG (new->flags, OSPF_LSA_SELF);
+  SET_FLAG (new->flags, OSPF_LSA_SELF | OSPF_LSA_SELF_CHECKED);
 
   /* Copy LSA to store. */
   new->data = ospf_lsa_data_new (length);
@@ -1495,9 +1491,6 @@ ospf_summary_asbr_lsa_refresh (struct ospf *ospf, struct ospf_lsa *lsa)
     return NULL;
   
   new->data->ls_seqnum = lsa_seqnum_increment (lsa);
-  
-  /* Re-calculate checksum. */
-  ospf_lsa_checksum (new->data);
 
   ospf_lsa_install (ospf, NULL, new);
   
@@ -1724,7 +1717,7 @@ ospf_external_lsa_new (struct ospf *ospf,
   /* Now, create OSPF LSA instance. */
   new = ospf_lsa_new ();
   new->area = NULL;
-  SET_FLAG (new->flags, OSPF_LSA_SELF|OSPF_LSA_APPROVED);
+  SET_FLAG (new->flags, OSPF_LSA_SELF | OSPF_LSA_APPROVED | OSPF_LSA_SELF_CHECKED);
 
   /* Copy LSA data to store, discard stream. */
   new->data = ospf_lsa_data_new (length);
@@ -1811,8 +1804,6 @@ ospf_install_flood_nssa (struct ospf *ospf,
            return;
          }
        }
-      /* Re-calculate checksum. */
-      ospf_lsa_checksum (new->data);
 
       /* install also as Type-7 */
       ospf_lsa_install (ospf, NULL, new);   /* Remove Old, Lock New = 2 */
@@ -1862,7 +1853,6 @@ ospf_lsa_translated_nssa_new (struct ospf *ospf,
 
   /* add translated flag, checksum and lock new lsa */
   SET_FLAG (new->flags, OSPF_LSA_LOCAL_XLT); /* Translated from 7  */   
-  ospf_lsa_checksum (new->data);
   new = ospf_lsa_lock (new);
   
   return new; 
@@ -2416,9 +2406,6 @@ ospf_external_lsa_refresh (struct ospf *ospf, struct ospf_lsa *lsa,
   
   new->data->ls_seqnum = lsa_seqnum_increment (lsa);
 
-  /* Re-calculate checksum. */
-  ospf_lsa_checksum (new->data);
-
   ospf_lsa_install (ospf, NULL, new);  /* As type-5. */
 
   /* Flood LSA through AS. */