summaryrefslogtreecommitdiff
path: root/ospfd/ospf_lsa.c
diff options
context:
space:
mode:
authorpaul <paul>2005-11-20 14:54:12 +0000
committerpaul <paul>2005-11-20 14:54:12 +0000
commitc24d602e82d31a2fcbccb4cc3b66f8d0a79d5f22 (patch)
tree55abf96bbb7899029d542b0714e666159484dbb2 /ospfd/ospf_lsa.c
parentb29800a676b7c3cf00d8a4086b7783ccb7e2f29f (diff)
2005-11-20 Paul Jakma <paul.jakma@sun.com>
* ospf_abr.c: (ospf_abr_announce_network_to_area) check returned LSA of ospf_summary_lsa_refresh and print warning if it failed. (ospf_abr_announce_network_to_area) similar (ospf_abr_announce_rtr_to_area) similar * ospf_lsa.c: (ospf_router_lsa_new) check LSA returned is valid. (ospf_router_lsa_originate) similar (ospf_router_lsa_refresh, ospf_network_lsa_new) similar (ospf_summary_lsa_new) Check ID is valid. (ospf_summary_lsa_originate) ditto, and check returned LSA from previous function is !NULL. (ospf_summary_lsa_refresh) check ospf_summary_lsa_new return is !NULL. (ospf_summary_asbr_lsa_new) ID valid check. (ospf_summary_asbr_lsa_originate) similar.
Diffstat (limited to 'ospfd/ospf_lsa.c')
-rw-r--r--ospfd/ospf_lsa.c75
1 files changed, 69 insertions, 6 deletions
diff --git a/ospfd/ospf_lsa.c b/ospfd/ospf_lsa.c
index 31b9a4f1..ff018fd4 100644
--- a/ospfd/ospf_lsa.c
+++ b/ospfd/ospf_lsa.c
@@ -830,7 +830,12 @@ ospf_router_lsa_new (struct ospf_area *area)
lsah->length = htons (length);
/* Now, create OSPF LSA instance. */
- new = ospf_lsa_new ();
+ if ( (new = ospf_lsa_new ()) == NULL)
+ {
+ zlog_err ("%s: Unable to create new lsa", __func__);
+ return NULL;
+ }
+
new->area = area;
SET_FLAG (new->flags, OSPF_LSA_SELF);
@@ -849,7 +854,11 @@ ospf_router_lsa_originate (struct ospf_area *area)
struct ospf_lsa *new;
/* Create new router-LSA instance. */
- new = ospf_router_lsa_new (area);
+ if ( (new = ospf_router_lsa_new (area)) == NULL)
+ {
+ zlog_err ("%s: ospf_router_lsa_new returned NULL", __func__);
+ return NULL;
+ }
/* Sanity check. */
if (new->data->adv_router.s_addr == 0)
@@ -893,7 +902,12 @@ ospf_router_lsa_refresh (struct ospf_lsa *lsa)
ospf_ls_retransmit_delete_nbr_area (area, lsa);
/* Create new router-LSA instance. */
- new = ospf_router_lsa_new (area);
+ if ( (new = ospf_router_lsa_new (area)) == NULL)
+ {
+ zlog_err ("%s: ospf_router_lsa_new returned NULL", __func__);
+ return NULL;
+ }
+
new->data->ls_seqnum = lsa_seqnum_increment (lsa);
ospf_lsa_install (area->ospf, NULL, new);
@@ -1075,7 +1089,12 @@ ospf_network_lsa_new (struct ospf_interface *oi)
lsah->length = htons (length);
/* Create OSPF LSA instance. */
- new = ospf_lsa_new ();
+ if ( (new = ospf_lsa_new ()) == NULL)
+ {
+ zlog_err ("%s: ospf_lsa_new returned NULL", __func__);
+ return NULL;
+ }
+
new->area = oi->area;
SET_FLAG (new->flags, OSPF_LSA_SELF);
@@ -1242,6 +1261,15 @@ ospf_summary_lsa_new (struct ospf_area *area, struct prefix *p,
struct lsa_header *lsah;
int length;
+ if (id.s_addr == 0xffffffff)
+ {
+ /* Maybe Link State ID not available. */
+ if (IS_DEBUG_OSPF (lsa, LSA_GENERATE))
+ zlog_debug ("LSA[Type%d]: Link ID not available, can't originate",
+ OSPF_SUMMARY_LSA);
+ return NULL;
+ }
+
if (IS_DEBUG_OSPF (lsa, LSA_GENERATE))
zlog_debug ("LSA[Type3]: Create summary-LSA instance");
@@ -1282,8 +1310,18 @@ ospf_summary_lsa_originate (struct prefix_ipv4 *p, u_int32_t metric,
id = ospf_lsa_unique_id (area->ospf, area->lsdb, OSPF_SUMMARY_LSA, p);
+ if (id.s_addr == 0xffffffff)
+ {
+ /* Maybe Link State ID not available. */
+ if (IS_DEBUG_OSPF (lsa, LSA_GENERATE))
+ zlog_debug ("LSA[Type%d]: Link ID not available, can't originate",
+ OSPF_SUMMARY_LSA);
+ return NULL;
+ }
+
/* Create new summary-LSA instance. */
- new = ospf_summary_lsa_new (area, (struct prefix *) p, metric, id);
+ if ( !(new = ospf_summary_lsa_new (area, (struct prefix *) p, metric, id)))
+ return NULL;
/* Instlal LSA to LSDB. */
new = ospf_lsa_install (area->ospf, NULL, new);
@@ -1318,7 +1356,10 @@ ospf_summary_lsa_refresh (struct ospf *ospf, struct ospf_lsa *lsa)
p.prefixlen = ip_masklen (sl->mask);
new = ospf_summary_lsa_new (lsa->area, &p, GET_METRIC (sl->metric),
sl->header.id);
-
+
+ if (!new)
+ return NULL;
+
new->data->ls_seqnum = lsa_seqnum_increment (lsa);
/* Re-calculate checksum. */
@@ -1369,6 +1410,15 @@ ospf_summary_asbr_lsa_new (struct ospf_area *area, struct prefix *p,
struct lsa_header *lsah;
int length;
+ if (id.s_addr == 0xffffffff)
+ {
+ /* Maybe Link State ID not available. */
+ if (IS_DEBUG_OSPF (lsa, LSA_GENERATE))
+ zlog_debug ("LSA[Type%d]: Link ID not available, can't originate",
+ OSPF_ASBR_SUMMARY_LSA);
+ return NULL;
+ }
+
if (IS_DEBUG_OSPF (lsa, LSA_GENERATE))
zlog_debug ("LSA[Type3]: Create summary-LSA instance");
@@ -1409,8 +1459,19 @@ ospf_summary_asbr_lsa_originate (struct prefix_ipv4 *p, u_int32_t metric,
id = ospf_lsa_unique_id (area->ospf, area->lsdb, OSPF_ASBR_SUMMARY_LSA, p);
+ if (id.s_addr == 0xffffffff)
+ {
+ /* Maybe Link State ID not available. */
+ if (IS_DEBUG_OSPF (lsa, LSA_GENERATE))
+ zlog_debug ("LSA[Type%d]: Link ID not available, can't originate",
+ OSPF_ASBR_SUMMARY_LSA);
+ return NULL;
+ }
+
/* Create new summary-LSA instance. */
new = ospf_summary_asbr_lsa_new (area, (struct prefix *) p, metric, id);
+ if (!new)
+ return NULL;
/* Install LSA to LSDB. */
new = ospf_lsa_install (area->ospf, NULL, new);
@@ -1445,6 +1506,8 @@ ospf_summary_asbr_lsa_refresh (struct ospf *ospf, struct ospf_lsa *lsa)
p.prefixlen = ip_masklen (sl->mask);
new = ospf_summary_asbr_lsa_new (lsa->area, &p, GET_METRIC (sl->metric),
sl->header.id);
+ if (!new)
+ return NULL;
new->data->ls_seqnum = lsa_seqnum_increment (lsa);