summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ospfd/ChangeLog15
-rw-r--r--ospfd/ospf_abr.c39
-rw-r--r--ospfd/ospf_lsa.c75
3 files changed, 122 insertions, 7 deletions
diff --git a/ospfd/ChangeLog b/ospfd/ChangeLog
index 08a3fcb5..d202e29c 100644
--- a/ospfd/ChangeLog
+++ b/ospfd/ChangeLog
@@ -18,6 +18,21 @@
timer needed.
* ospf_zebra.c: (ospf_router_id_update_zebra) call
ospf_router_id_update directly, not via timer.
+ * 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.
2005-11-16 Andrew J. Schorr <ajschorr@alumni.princeton.edu>
diff --git a/ospfd/ospf_abr.c b/ospfd/ospf_abr.c
index 2d47efec..8f365da7 100644
--- a/ospfd/ospf_abr.c
+++ b/ospfd/ospf_abr.c
@@ -748,6 +748,19 @@ ospf_abr_announce_network_to_area (struct prefix_ipv4 *p, u_int32_t cost,
"refreshing summary");
set_metric (old, cost);
lsa = ospf_summary_lsa_refresh (area->ospf, old);
+
+ if (!lsa)
+ {
+ char buf[INET_ADDRSTRLEN + 3]; /* ipv4 and /XX */
+
+ prefix2str ((struct prefix *) p, buf, sizeof(buf));
+ zlog_warn ("%s: Could not refresh %s to %s",
+ __func__,
+ buf,
+ inet_ntoa (area->area_id));
+ return;
+ }
+
SET_FLAG (lsa->flags, OSPF_LSA_APPROVED);
/* This will flood through area. */
}
@@ -760,6 +773,18 @@ ospf_abr_announce_network_to_area (struct prefix_ipv4 *p, u_int32_t cost,
lsa = ospf_summary_lsa_originate ( (struct prefix_ipv4 *)p, cost, area);
/* This will flood through area. */
+ if (!lsa)
+ {
+ char buf[INET_ADDRSTRLEN + 3]; /* ipv4 and /XX */
+
+ prefix2str ((struct prefix *)p, buf, sizeof(buf));
+ zlog_warn ("%s: Could not originate %s to %s",
+ __func__,
+ buf,
+ inet_ntoa (area->area_id));
+ return;
+ }
+
SET_FLAG (lsa->flags, OSPF_LSA_APPROVED);
if (IS_DEBUG_OSPF_EVENT)
zlog_debug ("ospf_abr_announce_network_to_area(): "
@@ -1117,10 +1142,22 @@ ospf_abr_announce_rtr_to_area (struct prefix_ipv4 *p, u_int32_t cost,
}
else
lsa = ospf_summary_asbr_lsa_originate (p, cost, area);
-
+ if (!lsa)
+ {
+ char buf[INET_ADDRSTRLEN + 3]; /* ipv4 and /XX */
+
+ prefix2str ((struct prefix *)p, buf, sizeof(buf));
+ zlog_warn ("%s: Could not refresh/originate %s to %s",
+ __func__,
+ buf,
+ inet_ntoa (area->area_id));
+ return;
+ }
+
if (IS_DEBUG_OSPF_EVENT)
zlog_debug ("ospf_abr_announce_rtr_to_area(): "
"flooding new version of summary");
+
/*
zlog_info ("ospf_abr_announce_rtr_to_area(): creating new summary");
lsa = ospf_summary_asbr_lsa (p, cost, area, old); */
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);