[ospfd] Fix a few LSA performance "bugs"
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().
diff --git a/ospfd/ospf_lsa.c b/ospfd/ospf_lsa.c
index 3c9c73a..18eed79 100644
--- a/ospfd/ospf_lsa.c
+++ b/ospfd/ospf_lsa.c
@@ -201,7 +201,6 @@
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 @@
}
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 @@
}
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 @@
/* 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 @@
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 @@
/* 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 @@
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 @@
/* 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 @@
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 @@
/* 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 @@
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. */