summaryrefslogtreecommitdiffstats
path: root/zebra/interface.c
diff options
context:
space:
mode:
Diffstat (limited to 'zebra/interface.c')
-rw-r--r--zebra/interface.c152
1 files changed, 99 insertions, 53 deletions
diff --git a/zebra/interface.c b/zebra/interface.c
index 5629ebb3..f2374316 100644
--- a/zebra/interface.c
+++ b/zebra/interface.c
@@ -147,7 +147,7 @@ if_addr_wakeup (struct interface *ifp)
zebra_interface_address_add_update (ifp, ifc);
- if (if_is_up(ifp))
+ if (if_is_operative(ifp))
connected_up_ipv4 (ifp, ifc);
}
#ifdef HAVE_IPV6
@@ -170,7 +170,7 @@ if_addr_wakeup (struct interface *ifp)
zebra_interface_address_add_update (ifp, ifc);
- if (if_is_up(ifp))
+ if (if_is_operative(ifp))
connected_up_ipv6 (ifp, ifc);
}
#endif /* HAVE_IPV6 */
@@ -182,6 +182,14 @@ if_addr_wakeup (struct interface *ifp)
void
if_add_update (struct interface *ifp)
{
+ struct zebra_if *if_data;
+
+ if_data = ifp->info;
+ if (if_data->multicast == IF_ZEBRA_MULTICAST_ON)
+ if_set_flags (ifp, IFF_MULTICAST);
+ else if (if_data->multicast == IF_ZEBRA_MULTICAST_OFF)
+ if_unset_flags (ifp, IFF_MULTICAST);
+
zebra_interface_add_update (ifp);
if (! CHECK_FLAG (ifp->status, ZEBRA_INTERFACE_ACTIVE))
@@ -326,16 +334,16 @@ if_down (struct interface *ifp)
void
if_refresh (struct interface *ifp)
{
- if (if_is_up (ifp))
+ if (if_is_operative (ifp))
{
if_get_flags (ifp);
- if (! if_is_up (ifp))
+ if (! if_is_operative (ifp))
if_down (ifp);
}
else
{
if_get_flags (ifp);
- if (if_is_up (ifp))
+ if (if_is_operative (ifp))
if_up (ifp);
}
}
@@ -471,8 +479,22 @@ if_dump_vty (struct vty *vty, struct interface *ifp)
struct connected *connected;
listnode node;
- vty_out (vty, "Interface %s%s", ifp->name,
- VTY_NEWLINE);
+ vty_out (vty, "Interface %s is ", ifp->name);
+ if (if_is_up(ifp)) {
+ vty_out (vty, "up, line protocol ");
+
+ if (CHECK_FLAG(ifp->status, ZEBRA_INTERFACE_LINKDETECTION)) {
+ if (if_is_running(ifp))
+ vty_out (vty, "is up%s", VTY_NEWLINE);
+ else
+ vty_out (vty, "is down%s", VTY_NEWLINE);
+ } else {
+ vty_out (vty, "detection is disabled%s", VTY_NEWLINE);
+ }
+ } else {
+ vty_out (vty, "down%s", VTY_NEWLINE);
+ }
+
if (ifp->desc)
vty_out (vty, " Description: %s%s", ifp->desc,
VTY_NEWLINE);
@@ -652,36 +674,6 @@ DEFUN_NOSH (zebra_interface,
return ret;
}
-DEFUN (no_zebra_interface,
- no_zebra_interface_cmd,
- "no interface IFNAME",
- "Delete a pseudo interface's configuration\n"
- "Interface's name\n")
-{
- struct interface *ifp;
-
- ifp = if_lookup_by_name(argv[0]);
-
- if (ifp == NULL)
- {
- vty_out (vty, "Inteface %s does not exist%s",
- argv[0],
- VTY_NEWLINE);
- return CMD_WARNING;
- }
-
- if (CHECK_FLAG (ifp->status, ZEBRA_INTERFACE_ACTIVE))
- {
- vty_out(vty, "Only inactive interfaces can be deleted%s", VTY_NEWLINE);
- return CMD_WARNING;
- }
-
- /* Delete interface */
- if_delete(ifp);
-
- return CMD_SUCCESS;
-}
-
struct cmd_node interface_node =
{
INTERFACE_NODE,
@@ -739,16 +731,19 @@ DEFUN (multicast,
struct zebra_if *if_data;
ifp = (struct interface *) vty->index;
- ret = if_set_flags (ifp, IFF_MULTICAST);
- if (ret < 0)
+ if (CHECK_FLAG (ifp->status, ZEBRA_INTERFACE_ACTIVE))
{
- vty_out (vty, "Can't set multicast flag%s", VTY_NEWLINE);
- return CMD_WARNING;
+ ret = if_set_flags (ifp, IFF_MULTICAST);
+ if (ret < 0)
+ {
+ vty_out (vty, "Can't set multicast flag%s", VTY_NEWLINE);
+ return CMD_WARNING;
+ }
+ if_refresh (ifp);
}
- if_refresh (ifp);
if_data = ifp->info;
if_data->multicast = IF_ZEBRA_MULTICAST_ON;
-
+
return CMD_SUCCESS;
}
@@ -763,19 +758,65 @@ DEFUN (no_multicast,
struct zebra_if *if_data;
ifp = (struct interface *) vty->index;
- ret = if_unset_flags (ifp, IFF_MULTICAST);
- if (ret < 0)
+ if (CHECK_FLAG (ifp->status, ZEBRA_INTERFACE_ACTIVE))
{
- vty_out (vty, "Can't unset multicast flag%s", VTY_NEWLINE);
- return CMD_WARNING;
+ ret = if_unset_flags (ifp, IFF_MULTICAST);
+ if (ret < 0)
+ {
+ vty_out (vty, "Can't unset multicast flag%s", VTY_NEWLINE);
+ return CMD_WARNING;
+ }
+ if_refresh (ifp);
}
- if_refresh (ifp);
if_data = ifp->info;
if_data->multicast = IF_ZEBRA_MULTICAST_OFF;
return CMD_SUCCESS;
}
+DEFUN (linkdetect,
+ linkdetect_cmd,
+ "link-detect",
+ "Enable link detection on interface\n")
+{
+ struct interface *ifp;
+ int if_was_operative;
+
+ ifp = (struct interface *) vty->index;
+ if_was_operative = if_is_operative(ifp);
+ SET_FLAG(ifp->status, ZEBRA_INTERFACE_LINKDETECTION);
+
+ /* When linkdetection is enabled, if might come down */
+ if (!if_is_operative(ifp) && if_was_operative) if_down(ifp);
+
+ /* FIXME: Will defer status change forwarding if interface
+ does not come down! */
+
+ return CMD_SUCCESS;
+}
+
+
+DEFUN (no_linkdetect,
+ no_linkdetect_cmd,
+ "no link-detect",
+ NO_STR
+ "Disable link detection on interface\n")
+{
+ struct interface *ifp;
+ int if_was_operative;
+
+ ifp = (struct interface *) vty->index;
+ if_was_operative = if_is_operative(ifp);
+ UNSET_FLAG(ifp->status, ZEBRA_INTERFACE_LINKDETECTION);
+
+ /* Interface may come up after disabling link detection */
+ if (if_is_operative(ifp) && !if_was_operative) if_up(ifp);
+
+ /* FIXME: see linkdetect_cmd */
+
+ return CMD_SUCCESS;
+}
+
DEFUN (shutdown_if,
shutdown_if_cmd,
"shutdown",
@@ -845,7 +886,7 @@ DEFUN (bandwidth_if,
ifp->bandwidth = bandwidth;
/* force protocols to recalculate routes due to cost change */
- if (if_is_up (ifp))
+ if (if_is_operative (ifp))
zebra_interface_up_update (ifp);
return CMD_SUCCESS;
@@ -864,7 +905,7 @@ DEFUN (no_bandwidth_if,
ifp->bandwidth = 0;
/* force protocols to recalculate routes due to cost change */
- if (if_is_up (ifp))
+ if (if_is_operative (ifp))
zebra_interface_up_update (ifp);
return CMD_SUCCESS;
@@ -957,7 +998,7 @@ ip_address_install (struct vty *vty, struct interface *ifp, char *addr_str,
zebra_interface_address_add_update (ifp, ifc);
/* If interface is up register connected route. */
- if (if_is_up(ifp))
+ if (if_is_operative(ifp))
connected_up_ipv4 (ifp, ifc);
}
@@ -1165,7 +1206,7 @@ ipv6_address_install (struct vty *vty, struct interface *ifp, char *addr_str,
zebra_interface_address_add_update (ifp, ifc);
/* If interface is up register connected route. */
- if (if_is_up(ifp))
+ if (if_is_operative(ifp))
connected_up_ipv6 (ifp, ifc);
}
@@ -1301,6 +1342,9 @@ if_config_write (struct vty *vty)
if (ifp->bandwidth != 0)
vty_out(vty, " bandwidth %u%s", ifp->bandwidth, VTY_NEWLINE);
+ if (CHECK_FLAG(ifp->status, ZEBRA_INTERFACE_LINKDETECTION))
+ vty_out(vty, " link-detect%s", VTY_NEWLINE);
+
for (addrnode = listhead (ifp->connected); addrnode; nextnode (addrnode))
{
ifc = getdata (addrnode);
@@ -1357,12 +1401,14 @@ zebra_if_init ()
install_element (VIEW_NODE, &show_interface_cmd);
install_element (ENABLE_NODE, &show_interface_cmd);
install_element (CONFIG_NODE, &zebra_interface_cmd);
- install_element (CONFIG_NODE, &no_zebra_interface_cmd);
+ install_element (CONFIG_NODE, &no_interface_cmd);
install_default (INTERFACE_NODE);
install_element (INTERFACE_NODE, &interface_desc_cmd);
install_element (INTERFACE_NODE, &no_interface_desc_cmd);
install_element (INTERFACE_NODE, &multicast_cmd);
install_element (INTERFACE_NODE, &no_multicast_cmd);
+ install_element (INTERFACE_NODE, &linkdetect_cmd);
+ install_element (INTERFACE_NODE, &no_linkdetect_cmd);
install_element (INTERFACE_NODE, &shutdown_if_cmd);
install_element (INTERFACE_NODE, &no_shutdown_if_cmd);
install_element (INTERFACE_NODE, &bandwidth_if_cmd);