summaryrefslogtreecommitdiffstats
path: root/zebra/interface.c
diff options
context:
space:
mode:
Diffstat (limited to 'zebra/interface.c')
-rw-r--r--zebra/interface.c83
1 files changed, 76 insertions, 7 deletions
diff --git a/zebra/interface.c b/zebra/interface.c
index 184b42a0..c096d611 100644
--- a/zebra/interface.c
+++ b/zebra/interface.c
@@ -41,6 +41,11 @@
#include "zebra/debug.h"
#include "zebra/irdp.h"
+#ifdef RTADV
+/* Order is intentional. Matches RFC4191. This array is also used for
+ command matching, so only modify with care. */
+const char *rtadv_pref_strs[] = { "medium", "high", "INVALID", "low", 0 };
+#endif /* RTADV */
/* Called when new interface is added. */
static int
@@ -48,8 +53,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;
@@ -76,6 +80,7 @@ if_zebra_new_hook (struct interface *ifp)
rtadv->HomeAgentPreference = 0;
rtadv->HomeAgentLifetime = RTADV_ADV_DEFAULT_LIFETIME;
rtadv->AdvIntervalOption = 0;
+ rtadv->DefaultPreference = RTADV_PREF_MEDIUM;
rtadv->AdvPrefixList = list_new ();
}
@@ -103,6 +108,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;
@@ -484,6 +490,54 @@ 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)
+ {
+ ifp->status |= oifp->status; /* inherit config bits */
+ 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 +592,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
@@ -623,6 +687,9 @@ nd_dump_vty (struct vty *vty, struct interface *ifp)
VTY_NEWLINE);
vty_out (vty, " ND router advertisements live for %d seconds%s",
rtadv->AdvDefaultLifetime, VTY_NEWLINE);
+ vty_out (vty, " ND router advertisement default router preference is "
+ "%s%s", rtadv_pref_strs[rtadv->DefaultPreference],
+ VTY_NEWLINE);
if (rtadv->AdvManagedFlag)
vty_out (vty, " Hosts use DHCP to obtain routable addresses.%s",
VTY_NEWLINE);
@@ -822,6 +889,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 +902,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
@@ -1514,7 +1583,6 @@ if_config_write (struct vty *vty)
{
struct listnode *node;
struct interface *ifp;
- char buf[BUFSIZ];
for (ALL_LIST_ELEMENTS_RO (iflist, node, ifp))
{
@@ -1544,10 +1612,11 @@ if_config_write (struct vty *vty)
{
if (CHECK_FLAG (ifc->conf, ZEBRA_IFC_CONFIGURED))
{
+ char buf[INET6_ADDRSTRLEN];
p = ifc->address;
vty_out (vty, " ip%s address %s/%d",
p->family == AF_INET ? "" : "v6",
- inet_ntop (p->family, &p->u.prefix, buf, BUFSIZ),
+ inet_ntop (p->family, &p->u.prefix, buf, sizeof(buf)),
p->prefixlen);
if (ifc->label)