summaryrefslogtreecommitdiff
path: root/zebra/interface.c
diff options
context:
space:
mode:
Diffstat (limited to 'zebra/interface.c')
-rw-r--r--zebra/interface.c86
1 files changed, 36 insertions, 50 deletions
diff --git a/zebra/interface.c b/zebra/interface.c
index 9d1f70609b..53ae1d2089 100644
--- a/zebra/interface.c
+++ b/zebra/interface.c
@@ -385,8 +385,7 @@ int if_subnet_delete(struct interface *ifp, struct connected *ifc)
rn = route_node_lookup(zebra_if->ipv4_subnets, &cp);
if (!(rn && rn->info)) {
flog_warn(EC_ZEBRA_REMOVE_ADDR_UNKNOWN_SUBNET,
- "Trying to remove an address from an unknown subnet."
- " (please report this bug)");
+ "Trying to remove an address from an unknown subnet. (please report this bug)");
return -1;
}
route_unlock_node(rn);
@@ -400,8 +399,7 @@ int if_subnet_delete(struct interface *ifp, struct connected *ifc)
if (!listnode_lookup(addr_list, ifc)) {
flog_warn(
EC_ZEBRA_REMOVE_UNREGISTERED_ADDR,
- "Trying to remove an address from a subnet where it is not"
- " currently registered. (please report this bug)");
+ "Trying to remove an address from a subnet where it is not currently registered. (please report this bug)");
return -1;
}
@@ -618,8 +616,7 @@ void if_add_update(struct interface *ifp)
if (if_data->shutdown == IF_ZEBRA_SHUTDOWN_ON) {
if (IS_ZEBRA_DEBUG_KERNEL) {
zlog_debug(
- "interface %s vrf %s(%u) index %d is shutdown. "
- "Won't wake it up.",
+ "interface %s vrf %s(%u) index %d is shutdown. Won't wake it up.",
ifp->name, VRF_LOGNAME(zvrf->vrf),
ifp->vrf_id, ifp->ifindex);
}
@@ -1625,14 +1622,12 @@ static void if_dump_vty(struct vty *vty, struct interface *ifp)
#ifdef HAVE_PROC_NET_DEV
/* Statistics print out using proc file system. */
vty_out(vty,
- " %lu input packets (%lu multicast), %lu bytes, "
- "%lu dropped\n",
+ " %lu input packets (%lu multicast), %lu bytes, %lu dropped\n",
ifp->stats.rx_packets, ifp->stats.rx_multicast,
ifp->stats.rx_bytes, ifp->stats.rx_dropped);
vty_out(vty,
- " %lu input errors, %lu length, %lu overrun,"
- " %lu CRC, %lu frame\n",
+ " %lu input errors, %lu length, %lu overrun, %lu CRC, %lu frame\n",
ifp->stats.rx_errors, ifp->stats.rx_length_errors,
ifp->stats.rx_over_errors, ifp->stats.rx_crc_errors,
ifp->stats.rx_frame_errors);
@@ -1645,8 +1640,7 @@ static void if_dump_vty(struct vty *vty, struct interface *ifp)
ifp->stats.tx_dropped);
vty_out(vty,
- " %lu output errors, %lu aborted, %lu carrier,"
- " %lu fifo, %lu heartbeat\n",
+ " %lu output errors, %lu aborted, %lu carrier, %lu fifo, %lu heartbeat\n",
ifp->stats.tx_errors, ifp->stats.tx_aborted_errors,
ifp->stats.tx_carrier_errors, ifp->stats.tx_fifo_errors,
ifp->stats.tx_heartbeat_errors);
@@ -1658,8 +1652,7 @@ static void if_dump_vty(struct vty *vty, struct interface *ifp)
#ifdef HAVE_NET_RT_IFLIST
/* Statistics print out using sysctl (). */
vty_out(vty,
- " input packets %llu, bytes %llu, dropped %llu,"
- " multicast packets %llu\n",
+ " input packets %llu, bytes %llu, dropped %llu, multicast packets %llu\n",
(unsigned long long)ifp->stats.ifi_ipackets,
(unsigned long long)ifp->stats.ifi_ibytes,
(unsigned long long)ifp->stats.ifi_iqdrops,
@@ -1669,8 +1662,7 @@ static void if_dump_vty(struct vty *vty, struct interface *ifp)
(unsigned long long)ifp->stats.ifi_ierrors);
vty_out(vty,
- " output packets %llu, bytes %llu,"
- " multicast packets %llu\n",
+ " output packets %llu, bytes %llu, multicast packets %llu\n",
(unsigned long long)ifp->stats.ifi_opackets,
(unsigned long long)ifp->stats.ifi_obytes,
(unsigned long long)ifp->stats.ifi_omcasts);
@@ -1709,7 +1701,7 @@ struct cmd_node interface_node = {
#endif
/* Show all interfaces to vty. */
DEFPY(show_interface, show_interface_cmd,
- "show interface [vrf NAME$vrf_name] [brief$brief]",
+ "show interface vrf NAME$vrf_name [brief$brief]",
SHOW_STR
"Interface status and configuration\n"
VRF_CMD_HELP_STR
@@ -1717,15 +1709,15 @@ DEFPY(show_interface, show_interface_cmd,
{
struct vrf *vrf;
struct interface *ifp;
- vrf_id_t vrf_id = VRF_DEFAULT;
interface_update_stats();
- if (vrf_name)
- VRF_GET_ID(vrf_id, vrf_name, false);
+ vrf = vrf_lookup_by_name(vrf_name);
+ if (!vrf) {
+ vty_out(vty, "%% VRF %s not found\n", vrf_name);
+ return CMD_WARNING;
+ }
- /* All interface print. */
- vrf = vrf_lookup_by_id(vrf_id);
if (brief) {
ifs_dump_brief_vty(vty, vrf);
} else {
@@ -1741,7 +1733,7 @@ DEFPY(show_interface, show_interface_cmd,
/* Show all interfaces to vty. */
DEFPY (show_interface_vrf_all,
show_interface_vrf_all_cmd,
- "show interface vrf all [brief$brief]",
+ "show interface [vrf all] [brief$brief]",
SHOW_STR
"Interface status and configuration\n"
VRF_ALL_CMD_HELP_STR
@@ -1778,14 +1770,17 @@ DEFUN (show_interface_name_vrf,
int idx_ifname = 2;
int idx_name = 4;
struct interface *ifp;
- vrf_id_t vrf_id;
+ struct vrf *vrf;
interface_update_stats();
- VRF_GET_ID(vrf_id, argv[idx_name]->arg, false);
+ vrf = vrf_lookup_by_name(argv[idx_name]->arg);
+ if (!vrf) {
+ vty_out(vty, "%% VRF %s not found\n", argv[idx_name]->arg);
+ return CMD_WARNING;
+ }
- /* Specified interface print. */
- ifp = if_lookup_by_name(argv[idx_ifname]->arg, vrf_id);
+ ifp = if_lookup_by_name_vrf(argv[idx_ifname]->arg, vrf);
if (ifp == NULL) {
vty_out(vty, "%% Can't find interface %s\n",
argv[idx_ifname]->arg);
@@ -1806,35 +1801,23 @@ DEFUN (show_interface_name_vrf_all,
VRF_ALL_CMD_HELP_STR)
{
int idx_ifname = 2;
- struct vrf *vrf;
struct interface *ifp;
- int found = 0;
interface_update_stats();
- /* All interface print. */
- RB_FOREACH (vrf, vrf_name_head, &vrfs_by_name) {
- /* Specified interface print. */
- ifp = if_lookup_by_name(argv[idx_ifname]->arg, vrf->vrf_id);
- if (ifp) {
- if_dump_vty(vty, ifp);
- found++;
- }
- }
-
- if (!found) {
+ ifp = if_lookup_by_name_all_vrf(argv[idx_ifname]->arg);
+ if (ifp == NULL) {
vty_out(vty, "%% Can't find interface %s\n",
argv[idx_ifname]->arg);
return CMD_WARNING;
}
+ if_dump_vty(vty, ifp);
return CMD_SUCCESS;
}
-
-static void if_show_description(struct vty *vty, vrf_id_t vrf_id)
+static void if_show_description(struct vty *vty, struct vrf *vrf)
{
- struct vrf *vrf = vrf_lookup_by_id(vrf_id);
struct interface *ifp;
vty_out(vty, "Interface Status Protocol Description\n");
@@ -1882,18 +1865,21 @@ static void if_show_description(struct vty *vty, vrf_id_t vrf_id)
DEFUN (show_interface_desc,
show_interface_desc_cmd,
- "show interface description [vrf NAME]",
+ "show interface description vrf NAME",
SHOW_STR
"Interface status and configuration\n"
"Interface description\n"
VRF_CMD_HELP_STR)
{
- vrf_id_t vrf_id = VRF_DEFAULT;
+ struct vrf *vrf;
- if (argc > 3)
- VRF_GET_ID(vrf_id, argv[4]->arg, false);
+ vrf = vrf_lookup_by_name(argv[4]->arg);
+ if (!vrf) {
+ vty_out(vty, "%% VRF %s not found\n", argv[4]->arg);
+ return CMD_WARNING;
+ }
- if_show_description(vty, vrf_id);
+ if_show_description(vty, vrf);
return CMD_SUCCESS;
}
@@ -1901,7 +1887,7 @@ DEFUN (show_interface_desc,
DEFUN (show_interface_desc_vrf_all,
show_interface_desc_vrf_all_cmd,
- "show interface description vrf all",
+ "show interface description [vrf all]",
SHOW_STR
"Interface status and configuration\n"
"Interface description\n"
@@ -1913,7 +1899,7 @@ DEFUN (show_interface_desc_vrf_all,
if (!RB_EMPTY(if_name_head, &vrf->ifaces_by_name)) {
vty_out(vty, "\n\tVRF %s(%u)\n\n", VRF_LOGNAME(vrf),
vrf->vrf_id);
- if_show_description(vty, vrf->vrf_id);
+ if_show_description(vty, vrf);
}
return CMD_SUCCESS;