]> git.puffer.fish Git - mirror/frr.git/commitdiff
ospfd: Make ospf_if_lookup_recv_if() find the right unnumbered i/f
authorJoakim Tjernlund <Joakim.Tjernlund@transmode.se>
Mon, 27 Jul 2009 10:42:30 +0000 (12:42 +0200)
committerPaul Jakma <paul@quagga.net>
Tue, 28 Jul 2009 17:47:43 +0000 (18:47 +0100)
This function will return the interface for the first matching
remote address for PtP i/f's. That won't work for multiple
unnumbered i/f's as these may all have the same address.

Pass in the struct interface pointer, ifp, to find the
correct set of oi's to search in. This also reduces the
size of the search list, making it faster.

* ospfd/ospf_interface.c: Add struct interface * param to
  ospf_if_lookup_recv_if() to select the right list to search in.
* ospfd/ospf_interface.h: ditto.
* ospfd/ospf_packet.c: Pass new ifp argument to ospf_if_lookup_recv_if()

ospfd/ospf_interface.c
ospfd/ospf_interface.h
ospfd/ospf_packet.c

index 4eccee76725d75b61459ef6d12c77c0c2462ee46..afe3acf133e817636c9e40769fcec32421995924 100644 (file)
@@ -439,11 +439,12 @@ ospf_if_lookup_by_prefix (struct ospf *ospf, struct prefix_ipv4 *p)
   return NULL;
 }
 
-/* determine receiving interface by source of packet */
+/* determine receiving interface by ifp and source address */
 struct ospf_interface *
-ospf_if_lookup_recv_if (struct ospf *ospf, struct in_addr src)
+ospf_if_lookup_recv_if (struct ospf *ospf, struct in_addr src,
+                       struct interface *ifp)
 {
-  struct listnode *node;
+  struct route_node *rn;
   struct prefix_ipv4 addr;
   struct ospf_interface *oi, *match;
 
@@ -453,11 +454,16 @@ ospf_if_lookup_recv_if (struct ospf *ospf, struct in_addr src)
 
   match = NULL;
 
-  for (ALL_LIST_ELEMENTS_RO (ospf->oiflist, node, oi))
+  for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn))
     {
+      oi = rn->info;
+
+      if (!oi) /* oi can be NULL for PtP aliases */
+       continue;
+
       if (oi->type == OSPF_IFTYPE_VIRTUALLINK)
        continue;
-      
+
       if (if_is_loopback (oi->ifp))
         continue;
 
index 0fc4ccba83d3a27be819952c56761bb1a1e894e1..ab0b758078f52715cac2b3db9e0bd59d93003946 100644 (file)
@@ -252,7 +252,8 @@ extern struct ospf_interface *ospf_if_table_lookup (struct interface *,
                                                    struct prefix *);
 extern struct ospf_interface *ospf_if_addr_local (struct in_addr);
 extern struct ospf_interface *ospf_if_lookup_recv_if (struct ospf *,
-                                                     struct in_addr);
+                                                     struct in_addr,
+                                                     struct interface *);
 extern struct ospf_interface *ospf_if_is_configured (struct ospf *,
                                                     struct in_addr *);
 
index 7ebf114eebc01eea1aba5b9dee0ae14b06b8b390..effef390da82a6d3a87ad05247975db6f3a6dd80 100644 (file)
@@ -2373,7 +2373,7 @@ ospf_read (struct thread *thread)
   ospfh = (struct ospf_header *) STREAM_PNT (ibuf);
 
   /* associate packet with ospf interface */
-  oi = ospf_if_lookup_recv_if (ospf, iph->ip_src);
+  oi = ospf_if_lookup_recv_if (ospf, iph->ip_src, ifp);
 
   /* If incoming interface is passive one, ignore it. */
   if (oi && OSPF_IF_PASSIVE_STATUS (oi) == OSPF_IF_PASSIVE)
@@ -2419,7 +2419,7 @@ ospf_read (struct thread *thread)
           return 0;
         }
     }
-    
+
   /* else it must be a local ospf interface, check it was received on 
    * correct link 
    */