]> git.puffer.fish Git - mirror/frr.git/commitdiff
ospfd: Change struct ospf_path *oi to ifindex.
authorJoakim Tjernlund <Joakim.Tjernlund@transmode.se>
Mon, 27 Jul 2009 10:42:34 +0000 (12:42 +0200)
committerPaul Jakma <paul@quagga.net>
Mon, 3 Aug 2009 15:52:30 +0000 (16:52 +0100)
* global: In struct ospf_path, change struct ospf_interface *oi to int
  ifindex.  It is unsafe to reference *oi as an ospf interface can be
  deleted under your feet. Use a weak reference instead.

ospfd/ospf_abr.c
ospfd/ospf_ase.c
ospfd/ospf_route.c
ospfd/ospf_route.h
ospfd/ospf_spf.c
ospfd/ospf_vty.c
ospfd/ospf_zebra.c

index 88636f1a41d1d5dc4cefec4f428edc379e6cf7e4..7e32195b38513bf422f809ec6f86feaafbcc3001 100644 (file)
@@ -814,15 +814,12 @@ ospf_abr_nexthops_belong_to_area (struct ospf_route *or,
 {
   struct listnode *node, *nnode;
   struct ospf_path *path;
+  struct ospf_interface *oi;
 
-  for (ALL_LIST_ELEMENTS (or->paths, node, nnode, path))
-    {
-      struct ospf_interface *oi = path->oi;
-
-      if (oi != NULL)
-        if (oi->area == area)
-          return 1;
-    }
+  for (ALL_LIST_ELEMENTS_RO (or->paths, node, path))
+    for (ALL_LIST_ELEMENTS_RO (area->oiflist, nnode, oi))
+      if (oi->ifp && oi->ifp->ifindex == path->ifindex)
+       return 1;
 
   return 0;
 }
index 044f97c6652a4a00d012f747fa437427e7e4f339..7bddf3f4db2a17d549463ca4f1855ce280dd9182 100644 (file)
@@ -135,6 +135,7 @@ ospf_ase_complete_direct_routes (struct ospf_route *ro, struct in_addr nexthop)
 {
   struct listnode *node;
   struct ospf_path *op;
+  struct interface *ifp;
 
   for (ALL_LIST_ELEMENTS_RO (ro->paths, node, op))
     if (op->nexthop.s_addr == 0)
@@ -593,7 +594,7 @@ ospf_ase_route_match_same (struct route_table *rt, struct prefix *prefix,
        
        if (! IPV4_ADDR_SAME (&op->nexthop, &newop->nexthop))
         return 0;
-       if (op->oi->ifp->ifindex != newop->oi->ifp->ifindex)
+       if (op->ifindex != newop->ifindex)
         return 0;
      }
    return 1;
index 0829e8ea010649330d63b56331085bf1d3e8b7bb..267237b8f57ca366c93683122ff93d6c84cb34c5 100644 (file)
@@ -165,7 +165,7 @@ ospf_route_match_same (struct route_table *rt, struct prefix_ipv4 *prefix,
 
               if (! IPV4_ADDR_SAME (&op->nexthop, &newop->nexthop))
                 return 0;
-              if (op->oi->ifp->ifindex != newop->oi->ifp->ifindex)
+              if (op->ifindex != newop->ifindex)
                 return 0;
             }
           return 1;
@@ -640,7 +640,7 @@ ospf_intra_add_stub (struct route_table *rt, struct router_lsa_link *link,
 
          path = ospf_path_new ();
          path->nexthop.s_addr = 0;
-         path->oi = oi;
+         path->ifindex = oi->ifp->ifindex;
          listnode_add (or->paths, path);
        }
       else
@@ -788,7 +788,8 @@ ospf_path_exist (struct list *plist, struct in_addr nexthop,
   struct ospf_path *path;
 
   for (ALL_LIST_ELEMENTS (plist, node, nnode, path))
-    if (IPV4_ADDR_SAME (&path->nexthop, &nexthop) && path->oi == oi)
+    if (IPV4_ADDR_SAME (&path->nexthop, &nexthop) &&
+       path->ifindex == oi->ifp->ifindex)
       return 1;
 
   return 0;
@@ -815,7 +816,7 @@ ospf_route_copy_nexthops_from_vertex (struct ospf_route *to,
            {
              path = ospf_path_new ();
              path->nexthop = nexthop->router;
-             path->oi = nexthop->oi;
+             path->ifindex = nexthop->oi->ifp->ifindex;
              listnode_add (to->paths, path);
            }
        }
@@ -834,7 +835,7 @@ ospf_path_lookup (struct list *plist, struct ospf_path *path)
       continue;
     if (!IPV4_ADDR_SAME (&op->adv_router, &path->adv_router))
       continue;
-    if (op->oi->ifp->ifindex != path->oi->ifp->ifindex)
+    if (op->ifindex != path->ifindex)
       continue;
     return op;
   }
index 0d37436dbd199d7931daa7ff7bde791283c49557..17ab68e5d63d8941d6fded86c2b88b4a60e757fc 100644 (file)
@@ -39,7 +39,7 @@ struct ospf_path
 {
   struct in_addr nexthop;
   struct in_addr adv_router;
-  struct ospf_interface *oi;
+  unsigned int ifindex;
 };
 
 /* Below is the structure linked to every
index 12afe5d99745c7396e752f08fb9a80a3c3557dc7..956684357059385afb76c0eb2933ed7df7fbc843 100644 (file)
@@ -1077,13 +1077,14 @@ ospf_rtrs_print (struct route_table *rtrs)
                 {
                   if (IS_DEBUG_OSPF_EVENT)
                     zlog_debug ("   directly attached to %s\r\n",
-                               IF_NAME (path->oi));
+                               ifindex2ifname (path->ifindex));
                 }
               else
                 {
                   if (IS_DEBUG_OSPF_EVENT)
                     zlog_debug ("   via %s, %s\r\n",
-                               inet_ntoa (path->nexthop), IF_NAME (path->oi));
+                               inet_ntoa (path->nexthop),
+                               ifindex2ifname (path->ifindex));
                 }
             }
         }
index 2e4b6078836c26cd0f9a704a87db14b35c7e7dac..7c3dec8cea03bb0fe36bfeaa97e212c436ffeb33 100644 (file)
@@ -7138,15 +7138,15 @@ show_ip_ospf_route_network (struct vty *vty, struct route_table *rt)
         if (or->type == OSPF_DESTINATION_NETWORK)
           for (ALL_LIST_ELEMENTS (or->paths, pnode, pnnode, path))
             {
-              if (path->oi != NULL && ospf_if_exists(path->oi))
+              if (if_lookup_by_index(path->ifindex))
                 {
                   if (path->nexthop.s_addr == 0)
                     vty_out (vty, "%24s   directly attached to %s%s",
-                             "", path->oi->ifp->name, VTY_NEWLINE);
+                             "", ifindex2ifname (path->ifindex), VTY_NEWLINE);
                   else
                     vty_out (vty, "%24s   via %s, %s%s", "",
-                             inet_ntoa (path->nexthop), path->oi->ifp->name,
-                             VTY_NEWLINE);
+                             inet_ntoa (path->nexthop),
+                            ifindex2ifname (path->ifindex), VTY_NEWLINE);
                 }
             }
       }
@@ -7188,15 +7188,17 @@ show_ip_ospf_route_router (struct vty *vty, struct route_table *rtrs)
                   
                   for (ALL_LIST_ELEMENTS_RO (or->paths, pnode, path))
                     {
-                     if (path->oi != NULL && ospf_if_exists(path->oi))
+                     if (if_lookup_by_index(path->ifindex))
                        {
                          if (path->nexthop.s_addr == 0)
                            vty_out (vty, "%24s   directly attached to %s%s",
-                                    "", path->oi->ifp->name, VTY_NEWLINE);
+                                    "", ifindex2ifname (path->ifindex),
+                                    VTY_NEWLINE);
                          else
                            vty_out (vty, "%24s   via %s, %s%s", "",
                                     inet_ntoa (path->nexthop),
-                                    path->oi->ifp->name, VTY_NEWLINE);
+                                    ifindex2ifname (path->ifindex),
+                                    VTY_NEWLINE);
                        }
                     }
           }
@@ -7235,14 +7237,15 @@ show_ip_ospf_route_external (struct vty *vty, struct route_table *rt)
 
         for (ALL_LIST_ELEMENTS (er->paths, pnode, pnnode, path))
           {
-            if (path->oi != NULL && ospf_if_exists(path->oi))
+            if (if_lookup_by_index(path->ifindex))
               {
                 if (path->nexthop.s_addr == 0)
                   vty_out (vty, "%24s   directly attached to %s%s",
-                           "", path->oi->ifp->name, VTY_NEWLINE);
+                           "", ifindex2ifname (path->ifindex), VTY_NEWLINE);
                 else
                   vty_out (vty, "%24s   via %s, %s%s", "",
-                           inet_ntoa (path->nexthop), path->oi->ifp->name,
+                           inet_ntoa (path->nexthop),
+                          ifindex2ifname (path->ifindex),
                            VTY_NEWLINE);
               }
            }
index 8f624a4d29a832ca01a6f15cc63c6fd39cd87069..52b23fe83f6db74f4b67d2fe605f2afd693b00ca 100644 (file)
@@ -378,8 +378,8 @@ ospf_zebra_add (struct prefix_ipv4 *p, struct ospf_route *or)
           else
             {
               stream_putc (s, ZEBRA_NEXTHOP_IFINDEX);
-              if (path->oi)
-                stream_putl (s, path->oi->ifp->ifindex);
+              if (path->ifindex)
+                stream_putl (s, path->ifindex);
               else
                 stream_putl (s, 0);
             }
@@ -439,11 +439,11 @@ ospf_zebra_delete (struct prefix_ipv4 *p, struct ospf_route *or)
               nexthop = &path->nexthop;
               api.nexthop = &nexthop;
             }
-          else if (ospf_if_exists(path->oi) && (path->oi->ifp))
+          else if (if_lookup_by_index(path->ifindex))
             {
               SET_FLAG (api.message, ZAPI_MESSAGE_NEXTHOP);
               api.ifindex_num = 1;
-              api.ifindex = &path->oi->ifp->ifindex;
+              api.ifindex = &path->ifindex;
             }
           else if ( IS_DEBUG_OSPF(zebra,ZEBRA_REDISTRIBUTE) )
             {