]> git.puffer.fish Git - mirror/frr.git/commitdiff
Don't crash when attempting to read path->oi->ifp if oi doesn't exist any
authorhasso <hasso>
Wed, 11 Feb 2004 21:52:13 +0000 (21:52 +0000)
committerhasso <hasso>
Wed, 11 Feb 2004 21:52:13 +0000 (21:52 +0000)
more. I'm not sure if this read should be attempted at all, but I'm trying
to keep code safe AND stable.

ospfd/ChangeLog
ospfd/ospf_interface.c
ospfd/ospf_interface.h
ospfd/ospf_zebra.c

index 9dafb96c09a324a1ff97a9deb1445999a235c3cb..b2a5ad2ed524581911c07c0f20f4110375cb0f34 100644 (file)
@@ -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).
index 2afe19ec3f50b50fca436970ccc89a0c5f9fad10..2f94b43fff6fb11e65bb8fedc4cfb7697fa638e6 100644 (file)
@@ -370,6 +370,23 @@ ospf_if_is_up (struct ospf_interface *oi)
   return if_is_up (oi->ifp);
 }
 
+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)
index 6dc01aea439c4cf3f5144e1711e92a212c5db0c5..6f54618bad6e965eebe47f4797188af786c15c12 100644 (file)
@@ -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 */
index ea90c845f4e385016dfe90ca6a8991593b3d73df..06916aee8188aed5fc244c89a47d13ad4700dbd3 100644 (file)
@@ -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;