summaryrefslogtreecommitdiff
path: root/ospfd
diff options
context:
space:
mode:
authorhasso <hasso>2004-02-11 21:52:13 +0000
committerhasso <hasso>2004-02-11 21:52:13 +0000
commit2db3d05da3ac6b1ff9452a5f291bfc39a719d1c6 (patch)
tree41cceb234a9b0cfb6410574689cd800671456b55 /ospfd
parentcb05eb285f28524ada2df62c5522dcf47acb841b (diff)
Don't crash when attempting to read path->oi->ifp if oi doesn't exist any
more. I'm not sure if this read should be attempted at all, but I'm trying to keep code safe AND stable.
Diffstat (limited to 'ospfd')
-rw-r--r--ospfd/ChangeLog4
-rw-r--r--ospfd/ospf_interface.c17
-rw-r--r--ospfd/ospf_interface.h37
-rw-r--r--ospfd/ospf_zebra.c2
4 files changed, 43 insertions, 17 deletions
diff --git a/ospfd/ChangeLog b/ospfd/ChangeLog
index 9dafb96c..b2a5ad2e 100644
--- a/ospfd/ChangeLog
+++ b/ospfd/ChangeLog
@@ -1,3 +1,7 @@
+2004-02-11 Hasso Tepper <hasso@estpak.ee>
+ * ospf_interface.c, ospf_zebra.c: Don't attempt to read path->oi->ifp
+ if oi doesn't exist any more.
+
2004-02-11 Vadim Suraev <vadim.suraev@terayon.com>
* ospf_packet.c (ospf_ls_upd): Router should flush received network
LSA if it was originated with older router-id ([zebra 14710] #6).
diff --git a/ospfd/ospf_interface.c b/ospfd/ospf_interface.c
index 2afe19ec..2f94b43f 100644
--- a/ospfd/ospf_interface.c
+++ b/ospfd/ospf_interface.c
@@ -371,6 +371,23 @@ ospf_if_is_up (struct ospf_interface *oi)
}
struct ospf_interface *
+ospf_if_exists (struct ospf_interface *oic)
+{
+ listnode node;
+ struct ospf *ospf;
+ struct ospf_interface *oi;
+
+ ospf = ospf_lookup ();
+
+ for (node = listhead (ospf->oiflist); node; nextnode (node))
+ {
+ if (((oi = getdata (node)) != NULL) && (oi == oic))
+ return oi;
+ }
+ return NULL;
+}
+
+struct ospf_interface *
ospf_if_lookup_by_local_addr (struct ospf *ospf,
struct interface *ifp, struct in_addr address)
{
diff --git a/ospfd/ospf_interface.h b/ospfd/ospf_interface.h
index 6dc01aea..6f54618b 100644
--- a/ospfd/ospf_interface.h
+++ b/ospfd/ospf_interface.h
@@ -190,26 +190,32 @@ struct ospf_interface
u_int32_t discarded; /* discarded input count by error. */
u_int32_t state_change; /* Number of status change. */
- u_int full_nbrs;
+ u_int32_t full_nbrs;
};
/* Prototypes. */
char *ospf_if_name (struct ospf_interface *);
-struct ospf_interface *ospf_if_new ();
+struct ospf_interface *ospf_if_new (struct ospf *, struct interface *,
+ struct prefix *);
void ospf_if_cleanup (struct ospf_interface *);
void ospf_if_free (struct ospf_interface *);
int ospf_if_up (struct ospf_interface *);
int ospf_if_down (struct ospf_interface *);
int ospf_if_is_up (struct ospf_interface *);
+struct ospf_interface *ospf_if_exists (struct ospf_interface *);
struct ospf_interface *ospf_if_lookup_by_name (char *);
-struct ospf_interface *ospf_if_lookup_by_local_addr (struct interface *, struct in_addr);
-struct ospf_interface *ospf_if_lookup_by_prefix (struct prefix_ipv4 *);
-struct ospf_interface *ospf_if_addr_local (struct in_addr src);
-struct ospf_interface *ospf_if_lookup_recv_interface (struct in_addr src);
-struct ospf_interface *ospf_if_is_configured (struct in_addr *);
-
-struct ospf_if_params *ospf_lookup_if_params (struct interface *, struct in_addr);
+struct ospf_interface *ospf_if_lookup_by_local_addr (struct ospf *,
+ struct interface *,
+ struct in_addr);
+struct ospf_interface *ospf_if_lookup_by_prefix (struct ospf *,
+ struct prefix_ipv4 *);
+struct ospf_interface *ospf_if_addr_local (struct in_addr);
+struct ospf_interface *ospf_if_lookup_recv_if (struct ospf *, struct in_addr);
+struct ospf_interface *ospf_if_is_configured (struct ospf *, struct in_addr *);
+
+struct ospf_if_params *ospf_lookup_if_params (struct interface *,
+ struct in_addr);
struct ospf_if_params *ospf_get_if_params (struct interface *, struct in_addr);
void ospf_del_if_params (struct ospf_if_params *);
void ospf_free_if_params (struct interface *, struct in_addr);
@@ -224,22 +230,21 @@ int ospf_if_is_enable (struct ospf_interface *);
int ospf_if_get_output_cost (struct ospf_interface *);
void ospf_if_recalculate_output_cost (struct interface *);
-struct ospf_interface *ospf_vl_new (struct ospf_vl_data *);
+struct ospf_interface *ospf_vl_new (struct ospf *, struct ospf_vl_data *);
struct ospf_vl_data *ospf_vl_data_new (struct ospf_area *, struct in_addr);
struct ospf_vl_data *ospf_vl_lookup (struct ospf_area *, struct in_addr);
void ospf_vl_data_free (struct ospf_vl_data *);
-void ospf_vl_add (struct ospf_vl_data *);
-void ospf_vl_delete (struct ospf_vl_data *);
+void ospf_vl_add (struct ospf *, struct ospf_vl_data *);
+void ospf_vl_delete (struct ospf *, struct ospf_vl_data *);
void ospf_vl_up_check (struct ospf_area *, struct in_addr, struct vertex *);
-void ospf_vl_unapprove ();
-void ospf_vl_shut_unapproved ();
+void ospf_vl_unapprove (struct ospf *);
+void ospf_vl_shut_unapproved (struct ospf *);
int ospf_full_virtual_nbrs (struct ospf_area *);
int ospf_vls_in_area (struct ospf_area *);
struct crypt_key *ospf_crypt_key_lookup (list, u_char);
struct crypt_key *ospf_crypt_key_new ();
void ospf_crypt_key_add (list, struct crypt_key *);
-int ospf_crypt_key_delete (list, u_char key_id);
-
+int ospf_crypt_key_delete (list, u_char);
#endif /* _ZEBRA_OSPF_INTERFACE_H */
diff --git a/ospfd/ospf_zebra.c b/ospfd/ospf_zebra.c
index ea90c845..06916aee 100644
--- a/ospfd/ospf_zebra.c
+++ b/ospfd/ospf_zebra.c
@@ -429,7 +429,7 @@ ospf_zebra_delete (struct prefix_ipv4 *p, struct ospf_route *or)
nexthop = &path->nexthop;
api.nexthop = &nexthop;
}
- else if (path->oi->ifp)
+ else if (ospf_if_exists(path->oi) && (path->oi->ifp))
{
SET_FLAG (api.message, ZAPI_MESSAGE_NEXTHOP);
api.ifindex_num = 1;