]> git.proxmox.com Git - mirror_frr.git/blobdiff - ospfd/ospf_interface.c
Merge branch 'cmaster' of ssh://stash.cumulusnetworks.com:7999/quag/quagga into cmaster
[mirror_frr.git] / ospfd / ospf_interface.c
index dc0787d562753aa23df6e1e1ea1d325eaf17a880..628091963edfed7a779166411a67c9b965e2f44f 100644 (file)
@@ -31,6 +31,8 @@
 #include "command.h"
 #include "stream.h"
 #include "log.h"
+#include "zclient.h"
+#include "bfd.h"
 
 #include "ospfd/ospfd.h"
 #include "ospfd/ospf_spf.h"
@@ -49,7 +51,7 @@
 #include "ospfd/ospf_snmp.h"
 #endif /* HAVE_SNMP */
 
-\f
+
 int
 ospf_if_get_output_cost (struct ospf_interface *oi)
 {
@@ -334,7 +336,7 @@ ospf_if_free (struct ospf_interface *oi)
   XFREE (MTYPE_OSPF_IF, oi);
 }
 
-\f
+
 /*
 *  check if interface with given address is configured and
 *  return it if yes.  special treatment for PtP networks.
@@ -353,7 +355,12 @@ ospf_if_is_configured (struct ospf *ospf, struct in_addr *address)
   for (ALL_LIST_ELEMENTS (ospf->oiflist, node, nnode, oi))
     if (oi->type != OSPF_IFTYPE_VIRTUALLINK)
       {
-        if (oi->type == OSPF_IFTYPE_POINTOPOINT)
+        if (CHECK_FLAG(oi->connected->flags, ZEBRA_IFA_UNNUMBERED))
+          {
+            if (htonl(oi->ifp->ifindex) == address->s_addr)
+              return oi;
+          }
+        else if (oi->type == OSPF_IFTYPE_POINTOPOINT)
          {
            /* special leniency: match if addr is anywhere on peer subnet */
            if (prefix_match(CONNECTED_PREFIX(oi->connected),
@@ -392,6 +399,21 @@ ospf_if_exists (struct ospf_interface *oic)
   return NULL;
 }
 
+/* Lookup OSPF interface by router LSA posistion */
+struct ospf_interface *
+ospf_if_lookup_by_lsa_pos (struct ospf_area *area, int lsa_pos)
+{
+  struct listnode *node;
+  struct ospf_interface *oi;
+
+  for (ALL_LIST_ELEMENTS_RO (area->oiflist, node, oi))
+    {
+      if (lsa_pos >= oi->lsa_pos_beg && lsa_pos < oi->lsa_pos_end)
+       return oi;
+    }
+  return NULL;
+}
+
 struct ospf_interface *
 ospf_if_lookup_by_local_addr (struct ospf *ospf,
                              struct interface *ifp, struct in_addr address)
@@ -462,8 +484,10 @@ ospf_if_lookup_recv_if (struct ospf *ospf, struct in_addr src,
       if (if_is_loopback (oi->ifp))
         continue;
 
-      if (prefix_match (CONNECTED_PREFIX(oi->connected),
-                       (struct prefix *) &addr))
+      if (CHECK_FLAG(oi->connected->flags, ZEBRA_IFA_UNNUMBERED))
+        match = oi;
+      else if (prefix_match (CONNECTED_PREFIX(oi->connected),
+                             (struct prefix *) &addr))
        {
          if ( (match == NULL) || 
               (match->address->prefixlen < oi->address->prefixlen)
@@ -474,7 +498,7 @@ ospf_if_lookup_recv_if (struct ospf *ospf, struct in_addr src,
 
   return match;
 }
-\f
+
 void
 ospf_if_stream_set (struct ospf_interface *oi)
 {
@@ -503,7 +527,7 @@ ospf_if_stream_unset (struct ospf_interface *oi)
     }
 }
 
-\f
+
 static struct ospf_if_params *
 ospf_new_if_params (void)
 {
@@ -538,6 +562,7 @@ void
 ospf_del_if_params (struct ospf_if_params *oip)
 {
   list_delete (oip->auth_crypt);
+  bfd_info_free(&(oip->bfd_info));
   XFREE (MTYPE_OSPF_IF_PARAMS, oip);
 }
 
@@ -801,13 +826,16 @@ ospf_if_down (struct ospf_interface *oi)
     return 0;
 
   OSPF_ISM_EVENT_EXECUTE (oi, ISM_InterfaceDown);
+  /* delete position in router LSA */
+  oi->lsa_pos_beg = 0;
+  oi->lsa_pos_end = 0;
   /* Shutdown packet reception and sending */
   ospf_if_stream_unset (oi);
 
   return 1;
 }
 
-\f
+
 /* Virtual Link related functions. */
 
 struct ospf_vl_data *
@@ -858,6 +886,11 @@ ospf_vl_new (struct ospf *ospf, struct ospf_vl_data *vl_data)
 
   snprintf (ifname, sizeof(ifname), "VLINK%d", vlink_count);
   vi = if_create (ifname, strnlen(ifname, sizeof(ifname)));
+  /*
+   * if_create sets ZEBRA_INTERFACE_LINKDETECTION
+   * virtual links don't need this.
+   */
+  UNSET_FLAG (vi->status, ZEBRA_INTERFACE_LINKDETECTION);
   co = connected_new ();
   co->ifp = vi;
   listnode_add (vi->connected, co);
@@ -995,7 +1028,7 @@ ospf_vl_set_params (struct ospf_vl_data *vl_data, struct vertex *v)
   struct ospf_interface *voi;
   struct listnode *node;
   struct vertex_parent *vp = NULL;
-  int i;
+  unsigned int i;
   struct router_lsa *rl;
 
   voi = vl_data->vl_oi;
@@ -1176,7 +1209,7 @@ ospf_vls_in_area (struct ospf_area *area)
   return c;
 }
 
-\f
+
 struct crypt_key *
 ospf_crypt_key_new ()
 {
@@ -1236,8 +1269,7 @@ void
 ospf_if_init ()
 {
   /* Initialize Zebra interface data structure. */
-  if_init ();
-  om->iflist = iflist;
+  om->iflist = vrf_iflist (VRF_DEFAULT);
   if_add_hook (IF_NEW_HOOK, ospf_if_new_hook);
   if_add_hook (IF_DELETE_HOOK, ospf_if_delete_hook);
 }