]> git.proxmox.com Git - mirror_frr.git/blobdiff - eigrpd/eigrp_interface.c
*: make consistent & update GPLv2 file headers
[mirror_frr.git] / eigrpd / eigrp_interface.c
index 18573caa004ae8fe4192c8be3de6e54c00cded5f..d7e6092383397d14163e8bd846eccf5a5bcd8239 100644 (file)
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  * General Public License for more details.
  *
- * You should have received a copy of the GNU General Public License
- * along with GNU Zebra; see the file COPYING.  If not, write to the Free
- * Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
- * 02111-1307, USA.
+ * You should have received a copy of the GNU General Public License along
+ * with this program; see the file COPYING; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
 #include <zebra.h>
@@ -106,9 +105,9 @@ eigrp_if_new (struct eigrp *eigrp, struct interface *ifp, struct prefix *p)
   /* Initialize lists */
   for (i = 0; i < EIGRP_FILTER_MAX; i++)
     {
-         ei->list[i] = NULL;
-         ei->prefix[i] = NULL;
-         ei->routemap[i] = NULL;
+      ei->list[i] = NULL;
+      ei->prefix[i] = NULL;
+      ei->routemap[i] = NULL;
     }
 
   return ei;
@@ -138,7 +137,6 @@ eigrp_if_table_lookup (struct interface *ifp, struct prefix *prefix)
 int
 eigrp_if_delete_hook (struct interface *ifp)
 {
-
   struct route_node *rn;
 
   route_table_finish (IF_OIFS (ifp));
@@ -222,7 +220,6 @@ eigrp_new_if_params (void)
   UNSET_IF_PARAM (eip, auth_keychain);
   UNSET_IF_PARAM (eip, auth_type);
 
-
   return eip;
 }
 
@@ -278,7 +275,7 @@ eigrp_if_up (struct eigrp_interface *ei)
   /* Set multicast memberships appropriately for new state. */
   eigrp_if_set_multicast (ei);
 
-  thread_add_event (master, eigrp_hello_timer, ei, (1));
+  thread_add_event(master, eigrp_hello_timer, ei, (1), NULL);
 
   /*Prepare metrics*/
   metric.bandwith = eigrp_bandwidth_to_scaled (EIGRP_IF_PARAM (ei,bandwidth));
@@ -401,7 +398,7 @@ eigrp_if_set_multicast (struct eigrp_interface *ei)
       /* The interface should belong to the EIGRP-all-routers group. */
       if (!EI_MEMBER_CHECK (ei, MEMBER_ALLROUTERS)
           && (eigrp_if_add_allspfrouters (ei->eigrp, ei->address,
-              ei->ifp->ifindex) >= 0))
+                                          ei->ifp->ifindex) >= 0))
         /* Set the flag only if the system call to join succeeded. */
         EI_MEMBER_JOINED (ei, MEMBER_ALLROUTERS);
     }
@@ -413,10 +410,10 @@ eigrp_if_set_multicast (struct eigrp_interface *ei)
           /* Only actually drop if this is the last reference */
           if (EI_MEMBER_COUNT (ei, MEMBER_ALLROUTERS) == 1)
             eigrp_if_drop_allspfrouters (ei->eigrp, ei->address,
-                ei->ifp->ifindex);
+                                         ei->ifp->ifindex);
           /* Unset the flag regardless of whether the system call to leave
-           the group succeeded, since it's much safer to assume that
-           we are not a member. */
+             the group succeeded, since it's much safer to assume that
+             we are not a member. */
           EI_MEMBER_LEFT (ei, MEMBER_ALLROUTERS);
         }
     }
@@ -436,6 +433,9 @@ eigrp_default_iftype (struct interface *ifp)
 void
 eigrp_if_free (struct eigrp_interface *ei, int source)
 {
+  struct prefix_ipv4 dest_addr;
+  struct eigrp_prefix_entry *pe;
+  struct eigrp *eigrp = eigrp_lookup ();
 
   if (source == INTERFACE_DOWN_BY_VTY)
     {
@@ -443,6 +443,14 @@ eigrp_if_free (struct eigrp_interface *ei, int source)
       eigrp_hello_send(ei,EIGRP_HELLO_GRACEFUL_SHUTDOWN, NULL);
     }
 
+  dest_addr.family = AF_INET;
+  dest_addr.prefix = ei->connected->address->u.prefix4;
+  dest_addr.prefixlen = ei->connected->address->prefixlen;
+  apply_mask_ipv4(&dest_addr);
+  pe = eigrp_topology_table_lookup_ipv4 (eigrp->topology_table, &dest_addr);
+  if (pe)
+    eigrp_prefix_entry_delete (eigrp->topology_table, pe);
+
   eigrp_if_down (ei);
 
   list_delete (ei->nbrs);
@@ -473,7 +481,7 @@ eigrp_delete_from_if (struct interface *ifp, struct eigrp_interface *ei)
 }
 
 /* Simulate down/up on the interface.  This is needed, for example, when
- the MTU changes. */
  the MTU changes. */
 void
 eigrp_if_reset (struct interface *ifp)
 {
@@ -493,7 +501,7 @@ eigrp_if_reset (struct interface *ifp)
 
 struct eigrp_interface *
 eigrp_if_lookup_by_local_addr (struct eigrp *eigrp, struct interface *ifp,
-    struct in_addr address)
+                               struct in_addr address)
 {
   struct listnode *node;
   struct eigrp_interface *ei;
@@ -524,26 +532,26 @@ eigrp_if_lookup_by_local_addr (struct eigrp *eigrp, struct interface *ifp,
 struct eigrp_interface *
 eigrp_if_lookup_by_name (struct eigrp *eigrp, const char *if_name)
 {
-       struct eigrp_interface *ei;
-       struct listnode *node;
-
-       /* iterate over all eigrp interfaces */
-       for (ALL_LIST_ELEMENTS_RO (eigrp->eiflist, node, ei))
-       {
-               /* compare int name with eigrp interface's name */
-               if(strcmp(ei->ifp->name, if_name) == 0)
-               {
-                       return ei;
-               }
-       }
-
-       return NULL;
+  struct eigrp_interface *ei;
+  struct listnode *node;
+
+  /* iterate over all eigrp interfaces */
+  for (ALL_LIST_ELEMENTS_RO (eigrp->eiflist, node, ei))
+    {
+      /* compare int name with eigrp interface's name */
+      if(strcmp(ei->ifp->name, if_name) == 0)
+        {
+          return ei;
+        }
+    }
+
+  return NULL;
 }
 
 /* determine receiving interface by ifp and source address */
 struct eigrp_interface *
 eigrp_if_lookup_recv_if (struct eigrp *eigrp, struct in_addr src,
-    struct interface *ifp)
+                         struct interface *ifp)
 {
   struct route_node *rn;
   struct prefix_ipv4 addr;
@@ -566,7 +574,7 @@ eigrp_if_lookup_recv_if (struct eigrp *eigrp, struct in_addr src,
         continue;
 
       if (prefix_match (CONNECTED_PREFIX (ei->connected),
-          (struct prefix *) &addr))
+                        (struct prefix *) &addr))
         {
           if ((match == NULL)
               || (match->address->prefixlen < ei->address->prefixlen))
@@ -580,22 +588,21 @@ eigrp_if_lookup_recv_if (struct eigrp *eigrp, struct in_addr src,
 u_int32_t
 eigrp_bandwidth_to_scaled (u_int32_t bandwidth)
 {
-  u_int64_t temp_bandwidth = (256ull * 10000000) / bandwidth;
+  uint64_t temp_bandwidth = (256ull * 10000000) / bandwidth;
 
   temp_bandwidth =
-      temp_bandwidth < EIGRP_MAX_METRIC ? temp_bandwidth : EIGRP_MAX_METRIC;
+    temp_bandwidth < EIGRP_MAX_METRIC ? temp_bandwidth : EIGRP_MAX_METRIC;
 
   return (u_int32_t) temp_bandwidth;
-
 }
 
 u_int32_t
 eigrp_scaled_to_bandwidth (u_int32_t scaled)
 {
-  u_int64_t temp_scaled = scaled * (256ull * 10000000);
+  uint64_t temp_scaled = scaled * (256ull * 10000000);
 
   temp_scaled =
-      temp_scaled < EIGRP_MAX_METRIC ? temp_scaled : EIGRP_MAX_METRIC;
+    temp_scaled < EIGRP_MAX_METRIC ? temp_scaled : EIGRP_MAX_METRIC;
 
   return (u_int32_t) temp_scaled;
 }