summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPooja Jagadeesh Doijode <pdoijode@nvidia.com>2025-01-21 23:19:32 +0100
committerPooja Jagadeesh Doijode <pdoijode@nvidia.com>2025-01-22 19:09:03 +0100
commit8c6489bc568a8a1714411cdb5b5a3c517bef941a (patch)
treeccf4260bbdd3950ebd798da23b7e6e0aa35d0129
parentMerge pull request #17895 from LabNConsulting/chopps/fix-coverity-use-after-free (diff)
downloadfrr-8c6489bc568a8a1714411cdb5b5a3c517bef941a.tar.xz
frr-8c6489bc568a8a1714411cdb5b5a3c517bef941a.zip
zebra: Return error if v6 prefix is passed to show ip route
Return error if IPv6 address or prefix is passed as an argument to "show ip route" command. UT: r1# show ip route 2::3/128 % Cannot specify IPv6 address/prefix for IPv4 table r1# r1# show ip route 2::3 % Cannot specify IPv6 address/prefix for IPv4 table r1# Signed-off-by: Pooja Jagadeesh Doijode <pdoijode@nvidia.com>
-rw-r--r--zebra/zebra_vty.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/zebra/zebra_vty.c b/zebra/zebra_vty.c
index 582d15627..a1731712d 100644
--- a/zebra/zebra_vty.c
+++ b/zebra/zebra_vty.c
@@ -1789,9 +1789,24 @@ DEFPY (show_route_detail,
rib_dest_t *dest;
bool network_found = false;
bool show_ng = !!ng;
+ int idx = 0;
+
+ /*
+ * Return error if V6 address/prefix is passed as an argument to
+ * "show ip route" cmd.
+ *
+ * When "show ip route <X:X::X:X|X:X::X:X/M>" is queried,
+ * argv[idx]->text will be set to "ipv6" but argv[idx]->arg will be set
+ * to "ip".
+ */
+ if (argv_find(argv, argc, "ipv6", &idx) && !strcmp(argv[idx]->arg, "ip")) {
+ vty_out(vty, "%% Cannot specify IPv6 address/prefix for IPv4 table\n");
+ return CMD_WARNING;
+ }
if (address_str)
prefix_str = address_str;
+
if (str2prefix(prefix_str, &p) < 0) {
vty_out(vty, "%% Malformed address\n");
return CMD_WARNING;