summaryrefslogtreecommitdiffstats
path: root/zebra/interface.c
diff options
context:
space:
mode:
Diffstat (limited to 'zebra/interface.c')
-rw-r--r--zebra/interface.c79
1 files changed, 69 insertions, 10 deletions
diff --git a/zebra/interface.c b/zebra/interface.c
index 184b42a0..329547b4 100644
--- a/zebra/interface.c
+++ b/zebra/interface.c
@@ -48,8 +48,7 @@ if_zebra_new_hook (struct interface *ifp)
{
struct zebra_if *zebra_if;
- zebra_if = XMALLOC (MTYPE_TMP, sizeof (struct zebra_if));
- memset (zebra_if, 0, sizeof (struct zebra_if));
+ zebra_if = XCALLOC (MTYPE_TMP, sizeof (struct zebra_if));
zebra_if->multicast = IF_ZEBRA_MULTICAST_UNSPEC;
zebra_if->shutdown = IF_ZEBRA_SHUTDOWN_UNSPEC;
@@ -103,6 +102,7 @@ if_zebra_delete_hook (struct interface *ifp)
route_table_finish (zebra_if->ipv4_subnets);
XFREE (MTYPE_TMP, zebra_if);
+ ifp->info = NULL;
}
return 0;
@@ -274,7 +274,7 @@ if_addr_wakeup (struct interface *ifp)
/* Address check. */
if (p->family == AF_INET)
{
- if (! if_is_up (ifp))
+ if (! if_is_operative (ifp))
{
/* XXX: WTF is it trying to set flags here?
* caller has just gotten a new interface, has been
@@ -311,7 +311,7 @@ if_addr_wakeup (struct interface *ifp)
#ifdef HAVE_IPV6
if (p->family == AF_INET6)
{
- if (! if_is_up (ifp))
+ if (! if_is_operative (ifp))
{
/* XXX: See long comment above */
if_set_flags (ifp, IFF_UP | IFF_RUNNING);
@@ -379,7 +379,7 @@ if_delete_update (struct interface *ifp)
zebra_if = ifp->info;
- if (if_is_up(ifp))
+ if (if_is_operative(ifp))
{
zlog_err ("interface %s index %d is still up while being deleted.",
ifp->name, ifp->ifindex);
@@ -484,6 +484,53 @@ if_delete_update (struct interface *ifp)
ifp->ifindex = IFINDEX_INTERNAL;
}
+/* Interfaces can only be renamed when DOWN */
+void
+if_rename (struct interface *ifp, const char *name)
+{
+ struct interface *oifp;
+
+ UNSET_FLAG (ifp->status, ZEBRA_INTERFACE_ACTIVE);
+ zebra_interface_delete_update (ifp);
+ listnode_delete (iflist, ifp);
+
+ /* rename overlaps earlier interface */
+ oifp = if_lookup_by_name(name);
+ if (oifp)
+ {
+ if (oifp->ifindex != IFINDEX_INTERNAL)
+ {
+ zlog_err ("interface %s rename to %s overlaps with index %d",
+ ifp->name, name, oifp->ifindex);
+ if_delete_update (oifp);
+ }
+ else if (IS_ZEBRA_DEBUG_KERNEL)
+ zlog_debug ("interface %s index %d superseded by rename of %s",
+ oifp->name, oifp->ifindex, ifp->name);
+
+ listnode_delete (iflist, oifp);
+ XFREE (MTYPE_IF, oifp);
+ }
+
+ strncpy(ifp->name, name, INTERFACE_NAMSIZ);
+ ifp->name[INTERFACE_NAMSIZ] = 0;
+ listnode_add_sort (iflist, ifp);
+
+ zebra_interface_add_update (ifp);
+
+ SET_FLAG (ifp->status, ZEBRA_INTERFACE_ACTIVE);
+
+ if (ifp->connected)
+ {
+ struct connected *ifc;
+ struct listnode *node;
+ for (ALL_LIST_ELEMENTS_RO (ifp->connected, node, ifc))
+ zebra_interface_address_add_update (ifp, ifc);
+ }
+
+ rib_update();
+}
+
/* Interface is up. */
void
if_up (struct interface *ifp)
@@ -538,15 +585,25 @@ if_down (struct interface *ifp)
if (p->family == AF_INET)
connected_down_ipv4 (ifp, ifc);
+ }
+ }
+
+ /* Examine all static routes which direct to the interface. */
+ rib_update ();
+
#ifdef HAVE_IPV6
- else if (p->family == AF_INET6)
+ if (ifp->connected)
+ {
+ for (ALL_LIST_ELEMENTS (ifp->connected, node, next, ifc))
+ {
+ p = ifc->address;
+ if (p->family == AF_INET6)
connected_down_ipv6 (ifp, ifc);
-#endif /* HAVE_IPV6 */
}
}
- /* Examine all static routes which direct to the interface. */
rib_update ();
+#endif /* HAVE_IPV6 */
}
void
@@ -822,6 +879,7 @@ if_dump_vty (struct vty *vty, struct interface *ifp)
#endif /* HAVE_NET_RT_IFLIST */
}
+#if 0
/* Check supported address family. */
static int
if_supported_family (int family)
@@ -834,6 +892,7 @@ if_supported_family (int family)
#endif /* HAVE_IPV6 */
return 0;
}
+#endif
/* Wrapper hook point for zebra daemon so that ifindex can be set
* DEFUN macro not used as extract.pl HAS to ignore this
@@ -1205,7 +1264,7 @@ ip_address_install (struct vty *vty, struct interface *ifp,
&& CHECK_FLAG (ifp->status, ZEBRA_INTERFACE_ACTIVE))
{
/* Some system need to up the interface to set IP address. */
- if (! if_is_up (ifp))
+ if (! if_is_operative (ifp))
{
if_set_flags (ifp, IFF_UP | IFF_RUNNING);
if_refresh (ifp);
@@ -1398,7 +1457,7 @@ ipv6_address_install (struct vty *vty, struct interface *ifp,
&& CHECK_FLAG (ifp->status, ZEBRA_INTERFACE_ACTIVE))
{
/* Some system need to up the interface to set IP address. */
- if (! if_is_up (ifp))
+ if (! if_is_operative (ifp))
{
if_set_flags (ifp, IFF_UP | IFF_RUNNING);
if_refresh (ifp);