summaryrefslogtreecommitdiff
path: root/zebra/interface.c
diff options
context:
space:
mode:
Diffstat (limited to 'zebra/interface.c')
-rw-r--r--zebra/interface.c400
1 files changed, 184 insertions, 216 deletions
diff --git a/zebra/interface.c b/zebra/interface.c
index 524183a434..c60cb8dcbc 100644
--- a/zebra/interface.c
+++ b/zebra/interface.c
@@ -14,10 +14,9 @@
* 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>
@@ -190,6 +189,7 @@ if_unlink_per_ns (struct interface *ifp)
{
ifp->node->info = NULL;
route_unlock_node(ifp->node);
+ ifp->node = NULL;
}
/* Look up an interface by identifier within a NS */
@@ -210,6 +210,23 @@ if_lookup_by_index_per_ns (struct zebra_ns *ns, u_int32_t ifindex)
return ifp;
}
+/* Look up an interface by name within a NS */
+struct interface *
+if_lookup_by_name_per_ns (struct zebra_ns *ns, const char *ifname)
+{
+ struct route_node *rn;
+ struct interface *ifp;
+
+ for (rn = route_top (ns->if_table); rn; rn = route_next (rn))
+ {
+ ifp = (struct interface *)rn->info;
+ if (ifp && strcmp (ifp->name, ifname) == 0)
+ return (ifp);
+ }
+
+ return NULL;
+}
+
const char *
ifindex2ifname_per_ns (struct zebra_ns *zns, unsigned int ifindex)
{
@@ -439,7 +456,6 @@ if_addr_wakeup (struct interface *ifp)
* from the kernel has been received.
* It will also be added to the interface's subnet list then. */
}
-#ifdef HAVE_IPV6
if (p->family == AF_INET6)
{
if (! if_is_up (ifp))
@@ -461,7 +477,6 @@ if_addr_wakeup (struct interface *ifp)
/* The address will be advertised to zebra clients when the notification
* from the kernel has been received. */
}
-#endif /* HAVE_IPV6 */
}
}
}
@@ -693,6 +708,7 @@ if_delete_update (struct interface *ifp)
for setting ifindex to IFINDEX_INTERNAL after processing the
interface deletion message. */
ifp->ifindex = IFINDEX_INTERNAL;
+ ifp->node = NULL;
/* if the ifp is in a vrf, move it to default so vrf can be deleted if desired */
if (ifp->vrf_id)
@@ -721,7 +737,7 @@ if_handle_vrf_change (struct interface *ifp, vrf_id_t vrf_id)
zebra_interface_vrf_update_del (ifp, vrf_id);
/* update VRF */
- if_update_vrf (ifp, ifp->name, strlen (ifp->name), vrf_id);
+ if_update (ifp, ifp->name, strlen (ifp->name), vrf_id);
/* Send out notification on interface VRF change. */
/* This is to issue an ADD, if needed. */
@@ -758,6 +774,7 @@ if_nbr_ipv6ll_to_ipv4ll_neigh_update (struct interface *ifp,
struct in6_addr *address,
int add)
{
+ struct zebra_vrf *zvrf = vrf_info_lookup(ifp->vrf_id);
char buf[16] = "169.254.0.1";
struct in_addr ipv4_ll;
char mac[6];
@@ -766,6 +783,7 @@ if_nbr_ipv6ll_to_ipv4ll_neigh_update (struct interface *ifp,
ipv6_ll_address_to_mac(address, (u_char *)mac);
kernel_neigh_update (add, ifp->ifindex, ipv4_ll.s_addr, mac, 6);
+ zvrf->neigh_updates++;
}
static void
@@ -1062,12 +1080,10 @@ if_dump_vty (struct vty *vty, struct interface *ifp)
return;
}
- vty_out (vty, " index %d metric %d mtu %d ",
- ifp->ifindex, ifp->metric, ifp->mtu);
-#ifdef HAVE_IPV6
+ vty_out (vty, " index %d metric %d mtu %d speed %u ",
+ ifp->ifindex, ifp->metric, ifp->mtu, ifp->speed);
if (ifp->mtu6 != ifp->mtu)
vty_out (vty, "mtu6 %d ", ifp->mtu6);
-#endif
vty_out (vty, "%s flags: %s%s", VTY_NEWLINE,
if_flag_dump (ifp->flags), VTY_NEWLINE);
@@ -1111,7 +1127,7 @@ if_dump_vty (struct vty *vty, struct interface *ifp)
int i;
struct if_link_params *iflp = ifp->link_params;
vty_out(vty, " Traffic Engineering Link Parameters:%s", VTY_NEWLINE);
- if (IS_PARAM_SET(iflp, LP_TE))
+ if (IS_PARAM_SET(iflp, LP_TE_METRIC))
vty_out(vty, " TE metric %u%s",iflp->te_metric, VTY_NEWLINE);
if (IS_PARAM_SET(iflp, LP_MAX_BW))
vty_out(vty, " Maximum Bandwidth %g (Byte/s)%s", iflp->max_bw, VTY_NEWLINE);
@@ -1241,39 +1257,6 @@ if_dump_vty (struct vty *vty, struct interface *ifp)
#endif /* HAVE_NET_RT_IFLIST */
}
-/* Wrapper hook point for zebra daemon so that ifindex can be set
- * DEFUN macro not used as extract.pl HAS to ignore this
- * See also interface_cmd in lib/if.c
- */
-DEFUN_NOSH (zebra_interface,
- zebra_interface_cmd,
- "interface IFNAME",
- "Select an interface to configure\n"
- "Interface's name\n")
-{
- int ret;
-
- /* Call lib interface() */
- if ((ret = interface_cmd.func (self, vty, argc, argv)) != CMD_SUCCESS)
- return ret;
-
- VTY_DECLVAR_CONTEXT (interface, ifp);
-
- if (ifp->ifindex == IFINDEX_INTERNAL)
- /* Is this really necessary? Shouldn't status be initialized to 0
- in that case? */
- UNSET_FLAG (ifp->status, ZEBRA_INTERFACE_ACTIVE);
-
- return ret;
-}
-
-ALIAS (zebra_interface,
- zebra_interface_vrf_cmd,
- "interface IFNAME " VRF_CMD_STR,
- "Select an interface to configure\n"
- "Interface's name\n"
- VRF_CMD_HELP_STR)
-
static void
interface_update_stats (void)
{
@@ -1295,10 +1278,12 @@ struct cmd_node interface_node =
};
/* Show all interfaces to vty. */
-DEFUN (show_interface, show_interface_cmd,
- "show interface",
+DEFUN (show_interface,
+ show_interface_cmd,
+ "show interface [vrf NAME]",
SHOW_STR
- "Interface status and configuration\n")
+ "Interface status and configuration\n"
+ VRF_CMD_HELP_STR)
{
struct listnode *node;
struct interface *ifp;
@@ -1306,8 +1291,8 @@ DEFUN (show_interface, show_interface_cmd,
interface_update_stats ();
- if (argc > 0)
- VRF_GET_ID (vrf_id, argv[0]);
+ if (argc > 2)
+ VRF_GET_ID (vrf_id, argv[3]->arg);
/* All interface print. */
for (ALL_LIST_ELEMENTS_RO (vrf_iflist (vrf_id), node, ifp))
@@ -1316,16 +1301,11 @@ DEFUN (show_interface, show_interface_cmd,
return CMD_SUCCESS;
}
-ALIAS (show_interface,
- show_interface_vrf_cmd,
- "show interface " VRF_CMD_STR,
- SHOW_STR
- "Interface status and configuration\n"
- VRF_CMD_HELP_STR)
/* Show all interfaces to vty. */
-DEFUN (show_interface_vrf_all, show_interface_vrf_all_cmd,
- "show interface " VRF_ALL_CMD_STR,
+DEFUN (show_interface_vrf_all,
+ show_interface_vrf_all_cmd,
+ "show interface vrf all",
SHOW_STR
"Interface status and configuration\n"
VRF_ALL_CMD_HELP_STR)
@@ -1348,25 +1328,26 @@ DEFUN (show_interface_vrf_all, show_interface_vrf_all_cmd,
DEFUN (show_interface_name_vrf,
show_interface_name_vrf_cmd,
- "show interface IFNAME " VRF_CMD_STR,
+ "show interface IFNAME vrf NAME",
SHOW_STR
"Interface status and configuration\n"
"Interface name\n"
VRF_CMD_HELP_STR)
{
+ int idx_ifname = 2;
+ int idx_name = 4;
struct interface *ifp;
vrf_id_t vrf_id = VRF_DEFAULT;
interface_update_stats ();
- if (argc > 1)
- VRF_GET_ID (vrf_id, argv[1]);
+ VRF_GET_ID (vrf_id, argv[idx_name]->arg);
/* Specified interface print. */
- ifp = if_lookup_by_name_vrf (argv[0], vrf_id);
+ ifp = if_lookup_by_name (argv[idx_ifname]->arg, vrf_id);
if (ifp == NULL)
{
- vty_out (vty, "%% Can't find interface %s%s", argv[0],
+ vty_out (vty, "%% Can't find interface %s%s", argv[idx_ifname]->arg,
VTY_NEWLINE);
return CMD_WARNING;
}
@@ -1376,13 +1357,15 @@ DEFUN (show_interface_name_vrf,
}
/* Show specified interface to vty. */
-DEFUN (show_interface_name_vrf_all, show_interface_name_vrf_all_cmd,
- "show interface IFNAME " VRF_ALL_CMD_STR,
+DEFUN (show_interface_name_vrf_all,
+ show_interface_name_vrf_all_cmd,
+ "show interface IFNAME [vrf all]",
SHOW_STR
"Interface status and configuration\n"
"Interface name\n"
VRF_ALL_CMD_HELP_STR)
{
+ int idx_ifname = 2;
struct vrf *vrf;
struct interface *ifp;
int found = 0;
@@ -1393,7 +1376,7 @@ DEFUN (show_interface_name_vrf_all, show_interface_name_vrf_all_cmd,
RB_FOREACH (vrf, vrf_name_head, &vrfs_by_name)
{
/* Specified interface print. */
- ifp = if_lookup_by_name_vrf (argv[0], vrf->vrf_id);
+ ifp = if_lookup_by_name (argv[idx_ifname]->arg, vrf->vrf_id);
if (ifp)
{
if_dump_vty (vty, ifp);
@@ -1403,18 +1386,13 @@ DEFUN (show_interface_name_vrf_all, show_interface_name_vrf_all_cmd,
if (!found)
{
- vty_out (vty, "%% Can't find interface %s%s", argv[0], VTY_NEWLINE);
+ vty_out (vty, "%% Can't find interface %s%s", argv[idx_ifname]->arg, VTY_NEWLINE);
return CMD_WARNING;
}
return CMD_SUCCESS;
}
-ALIAS (show_interface_name_vrf_all, show_interface_name_cmd,
- "show interface IFNAME",
- SHOW_STR
- "Interface status and configuration\n"
- "Interface name\n")
static void
if_show_description (struct vty *vty, vrf_id_t vrf_id)
@@ -1458,32 +1436,26 @@ if_show_description (struct vty *vty, vrf_id_t vrf_id)
DEFUN (show_interface_desc,
show_interface_desc_cmd,
- "show interface description",
+ "show interface description [vrf NAME]",
SHOW_STR
"Interface status and configuration\n"
- "Interface description\n")
+ "Interface description\n"
+ VRF_CMD_HELP_STR)
{
vrf_id_t vrf_id = VRF_DEFAULT;
- if (argc > 0)
- VRF_GET_ID (vrf_id, argv[0]);
+ if (argc > 3)
+ VRF_GET_ID (vrf_id, argv[4]->arg);
if_show_description (vty, vrf_id);
return CMD_SUCCESS;
}
-ALIAS (show_interface_desc,
- show_interface_desc_vrf_cmd,
- "show interface description " VRF_CMD_STR,
- SHOW_STR
- "Interface status and configuration\n"
- "Interface description\n"
- VRF_CMD_HELP_STR)
DEFUN (show_interface_desc_vrf_all,
show_interface_desc_vrf_all_cmd,
- "show interface description " VRF_ALL_CMD_STR,
+ "show interface description vrf all",
SHOW_STR
"Interface status and configuration\n"
"Interface description\n"
@@ -1560,7 +1532,7 @@ DEFUN (linkdetect,
{
VTY_DECLVAR_CONTEXT (interface, ifp);
int if_was_operative;
-
+
if_was_operative = if_is_no_ptm_operative(ifp);
SET_FLAG(ifp->status, ZEBRA_INTERFACE_LINKDETECTION);
@@ -1653,14 +1625,15 @@ DEFUN (no_shutdown_if,
DEFUN (bandwidth_if,
bandwidth_if_cmd,
- "bandwidth <1-100000>",
+ "bandwidth (1-100000)",
"Set bandwidth informational parameter\n"
"Bandwidth in megabits\n")
{
+ int idx_number = 1;
VTY_DECLVAR_CONTEXT (interface, ifp);
unsigned int bandwidth;
-
- bandwidth = strtol(argv[0], NULL, 10);
+
+ bandwidth = strtol(argv[idx_number]->arg, NULL, 10);
/* bandwidth range is <1-100000> */
if (bandwidth < 1 || bandwidth > 100000)
@@ -1680,9 +1653,10 @@ DEFUN (bandwidth_if,
DEFUN (no_bandwidth_if,
no_bandwidth_if_cmd,
- "no bandwidth",
+ "no bandwidth [(1-100000)]",
NO_STR
- "Set bandwidth informational parameter\n")
+ "Set bandwidth informational parameter\n"
+ "Bandwidth in megabits\n")
{
VTY_DECLVAR_CONTEXT (interface, ifp);
@@ -1695,12 +1669,6 @@ DEFUN (no_bandwidth_if,
return CMD_SUCCESS;
}
-ALIAS (no_bandwidth_if,
- no_bandwidth_if_val_cmd,
- "no bandwidth <1-100000>",
- NO_STR
- "Set bandwidth informational parameter\n"
- "Bandwidth in megabits\n")
struct cmd_node link_params_node =
{
@@ -1744,6 +1712,8 @@ link_param_cmd_set_float (struct interface *ifp, float *field,
static void
link_param_cmd_unset (struct interface *ifp, uint32_t type)
{
+ if (ifp->link_params == NULL)
+ return;
/* Unset field */
UNSET_PARAM(ifp->link_params, type);
@@ -1753,7 +1723,7 @@ link_param_cmd_unset (struct interface *ifp, uint32_t type)
zebra_interface_parameters_update (ifp);
}
-DEFUN (link_params,
+DEFUN_NOSH (link_params,
link_params_cmd,
"link-params",
LINK_PARAMS_STR)
@@ -1764,7 +1734,7 @@ DEFUN (link_params,
return CMD_SUCCESS;
}
-DEFUN (exit_link_params,
+DEFUN_NOSH (exit_link_params,
exit_link_params_cmd,
"exit-link-params",
"Exit from Link Params configuration mode\n")
@@ -1825,18 +1795,19 @@ DEFUN (no_link_params_enable,
/* STANDARD TE metrics */
DEFUN (link_params_metric,
link_params_metric_cmd,
- "metric <0-4294967295>",
+ "metric (0-4294967295)",
"Link metric for MPLS-TE purpose\n"
"Metric value in decimal\n")
{
+ int idx_number = 1;
VTY_DECLVAR_CONTEXT (interface, ifp);
struct if_link_params *iflp = if_link_params_get (ifp);
u_int32_t metric;
- VTY_GET_ULONG("metric", metric, argv[0]);
+ VTY_GET_ULONG("metric", metric, argv[idx_number]->arg);
/* Update TE metric if needed */
- link_param_cmd_set_uint32 (ifp, &iflp->te_metric, LP_TE | LP_TE_METRIC, metric);
+ link_param_cmd_set_uint32 (ifp, &iflp->te_metric, LP_TE_METRIC, metric);
return CMD_SUCCESS;
}
@@ -1850,7 +1821,7 @@ DEFUN (no_link_params_metric,
VTY_DECLVAR_CONTEXT (interface, ifp);
/* Unset TE Metric */
- link_param_cmd_unset(ifp, LP_TE | LP_TE_METRIC);
+ link_param_cmd_unset(ifp, LP_TE_METRIC);
return CMD_SUCCESS;
}
@@ -1861,12 +1832,13 @@ DEFUN (link_params_maxbw,
"Maximum bandwidth that can be used\n"
"Bytes/second (IEEE floating point format)\n")
{
+ int idx_bandwidth = 1;
VTY_DECLVAR_CONTEXT (interface, ifp);
struct if_link_params *iflp = if_link_params_get (ifp);
float bw;
- if (sscanf (argv[0], "%g", &bw) != 1)
+ if (sscanf (argv[idx_bandwidth]->arg, "%g", &bw) != 1)
{
vty_out (vty, "link_params_maxbw: fscanf: %s%s", safe_strerror (errno),
VTY_NEWLINE);
@@ -1905,11 +1877,12 @@ DEFUN (link_params_max_rsv_bw,
"Maximum bandwidth that may be reserved\n"
"Bytes/second (IEEE floating point format)\n")
{
+ int idx_bandwidth = 1;
VTY_DECLVAR_CONTEXT (interface, ifp);
struct if_link_params *iflp = if_link_params_get (ifp);
float bw;
- if (sscanf (argv[0], "%g", &bw) != 1)
+ if (sscanf (argv[idx_bandwidth]->arg, "%g", &bw) != 1)
{
vty_out (vty, "link_params_max_rsv_bw: fscanf: %s%s", safe_strerror (errno),
VTY_NEWLINE);
@@ -1933,25 +1906,27 @@ DEFUN (link_params_max_rsv_bw,
DEFUN (link_params_unrsv_bw,
link_params_unrsv_bw_cmd,
- "unrsv-bw <0-7> BANDWIDTH",
+ "unrsv-bw (0-7) BANDWIDTH",
"Unreserved bandwidth at each priority level\n"
"Priority\n"
"Bytes/second (IEEE floating point format)\n")
{
+ int idx_number = 1;
+ int idx_bandwidth = 2;
VTY_DECLVAR_CONTEXT (interface, ifp);
struct if_link_params *iflp = if_link_params_get (ifp);
int priority;
float bw;
/* We don't have to consider about range check here. */
- if (sscanf (argv[0], "%d", &priority) != 1)
+ if (sscanf (argv[idx_number]->arg, "%d", &priority) != 1)
{
vty_out (vty, "link_params_unrsv_bw: fscanf: %s%s", safe_strerror (errno),
VTY_NEWLINE);
return CMD_WARNING;
}
- if (sscanf (argv[1], "%g", &bw) != 1)
+ if (sscanf (argv[idx_bandwidth]->arg, "%g", &bw) != 1)
{
vty_out (vty, "link_params_unrsv_bw: fscanf: %s%s", safe_strerror (errno),
VTY_NEWLINE);
@@ -1979,11 +1954,12 @@ DEFUN (link_params_admin_grp,
"Administrative group membership\n"
"32-bit Hexadecimal value (e.g. 0xa1)\n")
{
+ int idx_bitpattern = 1;
VTY_DECLVAR_CONTEXT (interface, ifp);
struct if_link_params *iflp = if_link_params_get (ifp);
unsigned long value;
- if (sscanf (argv[0], "0x%lx", &value) != 1)
+ if (sscanf (argv[idx_bitpattern]->arg, "0x%lx", &value) != 1)
{
vty_out (vty, "link_params_admin_grp: fscanf: %s%s",
safe_strerror (errno), VTY_NEWLINE);
@@ -2013,24 +1989,27 @@ DEFUN (no_link_params_admin_grp,
/* RFC5392 & RFC5316: INTER-AS */
DEFUN (link_params_inter_as,
link_params_inter_as_cmd,
- "neighbor A.B.C.D as <1-4294967295>",
+ "neighbor A.B.C.D as (1-4294967295)",
"Configure remote ASBR information (Neighbor IP address and AS number)\n"
"Remote IP address in dot decimal A.B.C.D\n"
"Remote AS number\n"
"AS number in the range <1-4294967295>\n")
{
+ int idx_ipv4 = 1;
+ int idx_number = 3;
+
VTY_DECLVAR_CONTEXT (interface, ifp);
struct if_link_params *iflp = if_link_params_get (ifp);
struct in_addr addr;
u_int32_t as;
- if (!inet_aton (argv[0], &addr))
+ if (!inet_aton (argv[idx_ipv4]->arg, &addr))
{
vty_out (vty, "Please specify Router-Addr by A.B.C.D%s", VTY_NEWLINE);
return CMD_WARNING;
}
- VTY_GET_ULONG("AS number", as, argv[1]);
+ VTY_GET_ULONG("AS number", as, argv[idx_number]->arg);
/* Update Remote IP and Remote AS fields if needed */
if (IS_PARAM_UNSET(iflp, LP_RMT_AS)
@@ -2073,78 +2052,77 @@ DEFUN (no_link_params_inter_as,
/* RFC7471: OSPF Traffic Engineering (TE) Metric extensions & draft-ietf-isis-metric-extensions-07.txt */
DEFUN (link_params_delay,
link_params_delay_cmd,
- "delay <0-16777215>",
+ "delay (0-16777215) [min (0-16777215) max (0-16777215)]",
"Unidirectional Average Link Delay\n"
- "Average delay in micro-second as decimal (0...16777215)\n")
+ "Average delay in micro-second as decimal (0...16777215)\n"
+ "Minimum delay\n"
+ "Minimum delay in micro-second as decimal (0...16777215)\n"
+ "Maximum delay\n"
+ "Maximum delay in micro-second as decimal (0...16777215)\n")
{
+ /* Get and Check new delay values */
+ u_int32_t delay = 0, low = 0, high = 0;
+ VTY_GET_ULONG("delay", delay, argv[1]->arg);
+ if (argc == 6)
+ {
+ VTY_GET_ULONG("minimum delay", low, argv[3]->arg);
+ VTY_GET_ULONG("maximum delay", high, argv[5]->arg);
+ }
+
VTY_DECLVAR_CONTEXT (interface, ifp);
struct if_link_params *iflp = if_link_params_get (ifp);
- u_int32_t delay = 0, low = 0, high = 0;
u_int8_t update = 0;
- /* Get and Check new delay values */
- VTY_GET_ULONG("delay", delay, argv[0]);
- switch (argc)
- {
- case 1:
- /* Check new delay value against old Min and Max delays if set */
- if (IS_PARAM_SET(iflp, LP_MM_DELAY)
- && (delay <= iflp->min_delay || delay >= iflp->max_delay))
- {
- vty_out (vty, "Average delay should be comprise between Min (%d) and Max (%d) delay%s",
- iflp->min_delay, iflp->max_delay, VTY_NEWLINE);
- return CMD_WARNING;
- }
- /* Update delay if value is not set or change */
- if (IS_PARAM_UNSET(iflp, LP_DELAY)|| iflp->av_delay != delay)
- {
- iflp->av_delay = delay;
- SET_PARAM(iflp, LP_DELAY);
- update = 1;
- }
- /* Unset Min and Max delays if already set */
- if (IS_PARAM_SET(iflp, LP_MM_DELAY))
- {
- iflp->min_delay = 0;
- iflp->max_delay = 0;
- UNSET_PARAM(iflp, LP_MM_DELAY);
- update = 1;
- }
- break;
- case 2:
- vty_out (vty, "You should specify both Minimum and Maximum delay with Average delay%s",
- VTY_NEWLINE);
- return CMD_WARNING;
- break;
- case 3:
- VTY_GET_ULONG("minimum delay", low, argv[1]);
- VTY_GET_ULONG("maximum delay", high, argv[2]);
- /* Check new delays value coherency */
- if (delay <= low || delay >= high)
- {
- vty_out (vty, "Average delay should be comprise between Min (%d) and Max (%d) delay%s",
- low, high, VTY_NEWLINE);
- return CMD_WARNING;
- }
- /* Update Delays if needed */
- if (IS_PARAM_UNSET(iflp, LP_DELAY)
- || IS_PARAM_UNSET(iflp, LP_MM_DELAY)
- || iflp->av_delay != delay
- || iflp->min_delay != low
- || iflp->max_delay != high)
- {
- iflp->av_delay = delay;
- SET_PARAM(iflp, LP_DELAY);
- iflp->min_delay = low;
- iflp->max_delay = high;
- SET_PARAM(iflp, LP_MM_DELAY);
- update = 1;
- }
- break;
- default:
- return CMD_WARNING;
- break;
- }
+ if (argc == 2)
+ {
+ /* Check new delay value against old Min and Max delays if set */
+ if (IS_PARAM_SET(iflp, LP_MM_DELAY)
+ && (delay <= iflp->min_delay || delay >= iflp->max_delay))
+ {
+ vty_out (vty, "Average delay should be comprise between Min (%d) and Max (%d) delay%s",
+ iflp->min_delay, iflp->max_delay, VTY_NEWLINE);
+ return CMD_WARNING;
+ }
+ /* Update delay if value is not set or change */
+ if (IS_PARAM_UNSET(iflp, LP_DELAY)|| iflp->av_delay != delay)
+ {
+ iflp->av_delay = delay;
+ SET_PARAM(iflp, LP_DELAY);
+ update = 1;
+ }
+ /* Unset Min and Max delays if already set */
+ if (IS_PARAM_SET(iflp, LP_MM_DELAY))
+ {
+ iflp->min_delay = 0;
+ iflp->max_delay = 0;
+ UNSET_PARAM(iflp, LP_MM_DELAY);
+ update = 1;
+ }
+ }
+ else
+ {
+ /* Check new delays value coherency */
+ if (delay <= low || delay >= high)
+ {
+ vty_out (vty, "Average delay should be comprise between Min (%d) and Max (%d) delay%s",
+ low, high, VTY_NEWLINE);
+ return CMD_WARNING;
+ }
+ /* Update Delays if needed */
+ if (IS_PARAM_UNSET(iflp, LP_DELAY)
+ || IS_PARAM_UNSET(iflp, LP_MM_DELAY)
+ || iflp->av_delay != delay
+ || iflp->min_delay != low
+ || iflp->max_delay != high)
+ {
+ iflp->av_delay = delay;
+ SET_PARAM(iflp, LP_DELAY);
+ iflp->min_delay = low;
+ iflp->max_delay = high;
+ SET_PARAM(iflp, LP_MM_DELAY);
+ update = 1;
+ }
+ }
/* force protocols to update LINK STATE due to parameters change */
if (update == 1 && if_is_operative (ifp))
@@ -2153,16 +2131,6 @@ DEFUN (link_params_delay,
return CMD_SUCCESS;
}
-ALIAS (link_params_delay,
- link_params_delay_mm_cmd,
- "delay <0-16777215> min <0-16777215> max <0-16777215>",
- "Unidirectional Average Link Delay (optionally Minimum and Maximum delays)\n"
- "Average delay in micro-second as decimal (0...16777215)\n"
- "Minimum delay\n"
- "Minimum delay in micro-second as decimal (0...16777215)\n"
- "Maximum delay\n"
- "Maximum delay in micro-second as decimal (0...16777215)\n")
-
DEFUN (no_link_params_delay,
no_link_params_delay_cmd,
"no delay",
@@ -2188,15 +2156,16 @@ DEFUN (no_link_params_delay,
DEFUN (link_params_delay_var,
link_params_delay_var_cmd,
- "delay-variation <0-16777215>",
+ "delay-variation (0-16777215)",
"Unidirectional Link Delay Variation\n"
"delay variation in micro-second as decimal (0...16777215)\n")
{
+ int idx_number = 1;
VTY_DECLVAR_CONTEXT (interface, ifp);
struct if_link_params *iflp = if_link_params_get (ifp);
u_int32_t value;
- VTY_GET_ULONG("delay variation", value, argv[0]);
+ VTY_GET_ULONG("delay variation", value, argv[idx_number]->arg);
/* Update Delay Variation if needed */
link_param_cmd_set_uint32 (ifp, &iflp->delay_var, LP_DELAY_VAR, value);
@@ -2224,11 +2193,12 @@ DEFUN (link_params_pkt_loss,
"Unidirectional Link Packet Loss\n"
"percentage of total traffic by 0.000003% step and less than 50.331642%\n")
{
+ int idx_percentage = 1;
VTY_DECLVAR_CONTEXT (interface, ifp);
struct if_link_params *iflp = if_link_params_get (ifp);
float fval;
- if (sscanf (argv[0], "%g", &fval) != 1)
+ if (sscanf (argv[idx_percentage]->arg, "%g", &fval) != 1)
{
vty_out (vty, "link_params_pkt_loss: fscanf: %s%s", safe_strerror (errno),
VTY_NEWLINE);
@@ -2264,11 +2234,12 @@ DEFUN (link_params_res_bw,
"Unidirectional Residual Bandwidth\n"
"Bytes/second (IEEE floating point format)\n")
{
+ int idx_bandwidth = 1;
VTY_DECLVAR_CONTEXT (interface, ifp);
struct if_link_params *iflp = if_link_params_get (ifp);
float bw;
- if (sscanf (argv[0], "%g", &bw) != 1)
+ if (sscanf (argv[idx_bandwidth]->arg, "%g", &bw) != 1)
{
vty_out (vty, "link_params_res_bw: fscanf: %s%s", safe_strerror (errno),
VTY_NEWLINE);
@@ -2310,11 +2281,12 @@ DEFUN (link_params_ava_bw,
"Unidirectional Available Bandwidth\n"
"Bytes/second (IEEE floating point format)\n")
{
+ int idx_bandwidth = 1;
VTY_DECLVAR_CONTEXT (interface, ifp);
struct if_link_params *iflp = if_link_params_get (ifp);
float bw;
- if (sscanf (argv[0], "%g", &bw) != 1)
+ if (sscanf (argv[idx_bandwidth]->arg, "%g", &bw) != 1)
{
vty_out (vty, "link_params_ava_bw: fscanf: %s%s", safe_strerror (errno),
VTY_NEWLINE);
@@ -2356,11 +2328,12 @@ DEFUN (link_params_use_bw,
"Unidirectional Utilised Bandwidth\n"
"Bytes/second (IEEE floating point format)\n")
{
+ int idx_bandwidth = 1;
VTY_DECLVAR_CONTEXT (interface, ifp);
struct if_link_params *iflp = if_link_params_get (ifp);
float bw;
- if (sscanf (argv[0], "%g", &bw) != 1)
+ if (sscanf (argv[idx_bandwidth]->arg, "%g", &bw) != 1)
{
vty_out (vty, "link_params_use_bw: fscanf: %s%s", safe_strerror (errno),
VTY_NEWLINE);
@@ -2544,8 +2517,9 @@ DEFUN (ip_address,
"Set the IP address of an interface\n"
"IP address (e.g. 10.0.0.1/8)\n")
{
+ int idx_ipv4_prefixlen = 2;
VTY_DECLVAR_CONTEXT (interface, ifp);
- return ip_address_install (vty, ifp, argv[0], NULL, NULL);
+ return ip_address_install (vty, ifp, argv[idx_ipv4_prefixlen]->arg, NULL, NULL);
}
DEFUN (no_ip_address,
@@ -2556,8 +2530,9 @@ DEFUN (no_ip_address,
"Set the IP address of an interface\n"
"IP Address (e.g. 10.0.0.1/8)")
{
+ int idx_ipv4_prefixlen = 3;
VTY_DECLVAR_CONTEXT (interface, ifp);
- return ip_address_uninstall (vty, ifp, argv[0], NULL, NULL);
+ return ip_address_uninstall (vty, ifp, argv[idx_ipv4_prefixlen]->arg, NULL, NULL);
}
@@ -2571,8 +2546,10 @@ DEFUN (ip_address_label,
"Label of this address\n"
"Label\n")
{
+ int idx_ipv4_prefixlen = 2;
+ int idx_line = 4;
VTY_DECLVAR_CONTEXT (interface, ifp);
- return ip_address_install (vty, ifp, argv[0], NULL, argv[1]);
+ return ip_address_install (vty, ifp, argv[idx_ipv4_prefixlen]->arg, NULL, argv[idx_line]->arg);
}
DEFUN (no_ip_address_label,
@@ -2585,12 +2562,13 @@ DEFUN (no_ip_address_label,
"Label of this address\n"
"Label\n")
{
+ int idx_ipv4_prefixlen = 3;
+ int idx_line = 5;
VTY_DECLVAR_CONTEXT (interface, ifp);
- return ip_address_uninstall (vty, ifp, argv[0], NULL, argv[1]);
+ return ip_address_uninstall (vty, ifp, argv[idx_ipv4_prefixlen]->arg, NULL, argv[idx_line]->arg);
}
#endif /* HAVE_NETLINK */
-#ifdef HAVE_IPV6
static int
ipv6_address_install (struct vty *vty, struct interface *ifp,
const char *addr_str, const char *peer_str,
@@ -2749,8 +2727,9 @@ DEFUN (ipv6_address,
"Set the IP address of an interface\n"
"IPv6 address (e.g. 3ffe:506::1/48)\n")
{
+ int idx_ipv6_prefixlen = 2;
VTY_DECLVAR_CONTEXT (interface, ifp);
- return ipv6_address_install (vty, ifp, argv[0], NULL, NULL, 0);
+ return ipv6_address_install (vty, ifp, argv[idx_ipv6_prefixlen]->arg, NULL, NULL, 0);
}
DEFUN (no_ipv6_address,
@@ -2761,10 +2740,10 @@ DEFUN (no_ipv6_address,
"Set the IP address of an interface\n"
"IPv6 address (e.g. 3ffe:506::1/48)\n")
{
+ int idx_ipv6_prefixlen = 3;
VTY_DECLVAR_CONTEXT (interface, ifp);
- return ipv6_address_uninstall (vty, ifp, argv[0], NULL, NULL, 0);
+ return ipv6_address_uninstall (vty, ifp, argv[idx_ipv6_prefixlen]->arg, NULL, NULL, 0);
}
-#endif /* HAVE_IPV6 */
static int
link_params_config_write (struct vty *vty, struct interface *ifp)
@@ -2778,7 +2757,7 @@ link_params_config_write (struct vty *vty, struct interface *ifp)
vty_out (vty, " link-params%s", VTY_NEWLINE);
vty_out(vty, " enable%s", VTY_NEWLINE);
- if (IS_PARAM_SET(iflp, LP_TE) && IS_PARAM_SET(iflp, LP_TE_METRIC))
+ if (IS_PARAM_SET(iflp, LP_TE_METRIC) && iflp->te_metric != ifp->metric)
vty_out(vty, " metric %u%s",iflp->te_metric, VTY_NEWLINE);
if (IS_PARAM_SET(iflp, LP_MAX_BW) && iflp->max_bw != iflp->default_bw)
vty_out(vty, " max-bw %g%s", iflp->max_bw, VTY_NEWLINE);
@@ -2918,23 +2897,15 @@ zebra_if_init (void)
/* Install configuration write function. */
install_node (&interface_node, if_config_write);
install_node (&link_params_node, NULL);
+ if_cmd_init ();
install_element (VIEW_NODE, &show_interface_cmd);
- install_element (VIEW_NODE, &show_interface_vrf_cmd);
install_element (VIEW_NODE, &show_interface_vrf_all_cmd);
- install_element (VIEW_NODE, &show_interface_name_cmd);
install_element (VIEW_NODE, &show_interface_name_vrf_cmd);
install_element (VIEW_NODE, &show_interface_name_vrf_all_cmd);
+
install_element (ENABLE_NODE, &show_interface_desc_cmd);
- install_element (ENABLE_NODE, &show_interface_desc_vrf_cmd);
install_element (ENABLE_NODE, &show_interface_desc_vrf_all_cmd);
- install_element (CONFIG_NODE, &zebra_interface_cmd);
- install_element (CONFIG_NODE, &zebra_interface_vrf_cmd);
- install_element (CONFIG_NODE, &no_interface_cmd);
- install_element (CONFIG_NODE, &no_interface_vrf_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);
@@ -2943,13 +2914,10 @@ zebra_if_init (void)
install_element (INTERFACE_NODE, &no_shutdown_if_cmd);
install_element (INTERFACE_NODE, &bandwidth_if_cmd);
install_element (INTERFACE_NODE, &no_bandwidth_if_cmd);
- install_element (INTERFACE_NODE, &no_bandwidth_if_val_cmd);
install_element (INTERFACE_NODE, &ip_address_cmd);
install_element (INTERFACE_NODE, &no_ip_address_cmd);
-#ifdef HAVE_IPV6
install_element (INTERFACE_NODE, &ipv6_address_cmd);
install_element (INTERFACE_NODE, &no_ipv6_address_cmd);
-#endif /* HAVE_IPV6 */
#ifdef HAVE_NETLINK
install_element (INTERFACE_NODE, &ip_address_label_cmd);
install_element (INTERFACE_NODE, &no_ip_address_label_cmd);
@@ -2959,6 +2927,7 @@ zebra_if_init (void)
install_element(LINK_PARAMS_NODE, &link_params_enable_cmd);
install_element(LINK_PARAMS_NODE, &no_link_params_enable_cmd);
install_element(LINK_PARAMS_NODE, &link_params_metric_cmd);
+ install_element(LINK_PARAMS_NODE, &no_link_params_metric_cmd);
install_element(LINK_PARAMS_NODE, &link_params_maxbw_cmd);
install_element(LINK_PARAMS_NODE, &link_params_max_rsv_bw_cmd);
install_element(LINK_PARAMS_NODE, &link_params_unrsv_bw_cmd);
@@ -2968,7 +2937,6 @@ zebra_if_init (void)
install_element(LINK_PARAMS_NODE, &no_link_params_inter_as_cmd);
install_element(LINK_PARAMS_NODE, &link_params_delay_cmd);
install_element(LINK_PARAMS_NODE, &no_link_params_delay_cmd);
- install_element(LINK_PARAMS_NODE, &link_params_delay_mm_cmd);
install_element(LINK_PARAMS_NODE, &link_params_delay_var_cmd);
install_element(LINK_PARAMS_NODE, &no_link_params_delay_var_cmd);
install_element(LINK_PARAMS_NODE, &link_params_pkt_loss_cmd);