diff options
author | Joakim Tjernlund <Joakim.Tjernlund@transmode.se> | 2008-11-04 13:37:29 +0000 |
---|---|---|
committer | Paul Jakma <paul@quagga.net> | 2009-06-25 12:23:27 +0100 |
commit | f65431380428c3cb8eb5c0a0ac93debc30717a3f (patch) | |
tree | 343c4b39fa516c0fc3a0640c9a8f9536c5b21d5f /ospfd | |
parent | dc26699a80eb7b40fb1c9026496cde2b80bf1335 (diff) |
[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().
Diffstat (limited to 'ospfd')
-rw-r--r-- | ospfd/ospf_lsa.c | 23 |
1 files changed, 5 insertions, 18 deletions
diff --git a/ospfd/ospf_lsa.c b/ospfd/ospf_lsa.c index 3c9c73a3..18eed79e 100644 --- a/ospfd/ospf_lsa.c +++ b/ospfd/ospf_lsa.c @@ -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. */ |