summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/agentx.c2
-rw-r--r--lib/command.c55
-rw-r--r--lib/command.h3
-rw-r--r--lib/distribute.c2
-rw-r--r--lib/filter.c26
-rw-r--r--lib/grammar_sandbox.c6
-rw-r--r--lib/hash.c9
-rw-r--r--lib/hash.h4
-rw-r--r--lib/if.c8
-rw-r--r--lib/if_rmap.c6
-rw-r--r--lib/keychain.c14
-rw-r--r--lib/module.c2
-rw-r--r--lib/ns.c10
-rw-r--r--lib/plist.c36
-rw-r--r--lib/routemap.c34
-rw-r--r--lib/smux.c6
-rw-r--r--lib/vrf.c6
-rw-r--r--lib/vty.c20
-rw-r--r--lib/vty.h9
19 files changed, 148 insertions, 110 deletions
diff --git a/lib/agentx.c b/lib/agentx.c
index d058779aff..53e5f2bc53 100644
--- a/lib/agentx.c
+++ b/lib/agentx.c
@@ -197,7 +197,7 @@ DEFUN (no_agentx,
{
if (!agentx_enabled) return CMD_SUCCESS;
vty_outln (vty, "SNMP AgentX support cannot be disabled once enabled");
- return CMD_WARNING;
+ return CMD_WARNING_CONFIG_FAILED;
}
void
diff --git a/lib/command.c b/lib/command.c
index 5ca4a0fda9..18a28f57c0 100644
--- a/lib/command.c
+++ b/lib/command.c
@@ -715,6 +715,41 @@ cmd_variable_complete (struct cmd_token *token, const char *arg, vector comps)
vector_free(tmpcomps);
}
+#define AUTOCOMP_INDENT 5
+
+char *
+cmd_variable_comp2str(vector comps, unsigned short cols, const char nl[])
+{
+ size_t bsz = 16;
+ char *buf = XCALLOC(MTYPE_TMP, bsz);
+ int lc = AUTOCOMP_INDENT;
+ size_t cs = AUTOCOMP_INDENT;
+ size_t nllen = strlen(nl);
+ size_t itemlen;
+ snprintf(buf, bsz, "%*s", AUTOCOMP_INDENT, "");
+ for (size_t j = 0; j < vector_active (comps); j++)
+ {
+ char *item = vector_slot (comps, j);
+ itemlen = strlen(item);
+
+ if (cs + itemlen + nllen + AUTOCOMP_INDENT + 2 >= bsz)
+ buf = XREALLOC(MTYPE_TMP, buf, (bsz *= 2));
+
+ if (lc + itemlen + 1 >= cols)
+ {
+ cs += snprintf(&buf[cs], bsz - cs, "%s%*s", nl, AUTOCOMP_INDENT, "");
+ lc = AUTOCOMP_INDENT;
+ }
+
+ size_t written = snprintf(&buf[cs], bsz - cs, "%s ", item);
+ lc += written;
+ cs += written;
+ XFREE (MTYPE_COMPLETION, item);
+ vector_set_index (comps, j, NULL);
+ }
+ return buf;
+}
+
void
cmd_variable_handler_register (const struct cmd_variable_handler *cvh)
{
@@ -1150,7 +1185,7 @@ DEFUN (config_terminal,
else
{
vty_outln (vty, "VTY configuration is locked by other VTY");
- return CMD_WARNING;
+ return CMD_WARNING_CONFIG_FAILED;
}
return CMD_SUCCESS;
}
@@ -1722,7 +1757,7 @@ DEFUN (config_hostname,
if (!isalpha((int) word->arg[0]))
{
vty_outln (vty, "Please specify string starting with alphabet");
- return CMD_WARNING;
+ return CMD_WARNING_CONFIG_FAILED;
}
return cmd_hostname_set (word->arg);
@@ -1763,7 +1798,7 @@ DEFUN (config_password,
{
vty_outln (vty,
"Please specify string starting with alphanumeric");
- return CMD_WARNING;
+ return CMD_WARNING_CONFIG_FAILED;
}
if (host.password)
@@ -1812,7 +1847,7 @@ DEFUN (config_enable_password,
else
{
vty_outln (vty, "Unknown encryption type.");
- return CMD_WARNING;
+ return CMD_WARNING_CONFIG_FAILED;
}
}
@@ -1820,7 +1855,7 @@ DEFUN (config_enable_password,
{
vty_outln (vty,
"Please specify string starting with alphanumeric");
- return CMD_WARNING;
+ return CMD_WARNING_CONFIG_FAILED;
}
if (host.enable)
@@ -2134,14 +2169,14 @@ set_log_file(struct vty *vty, const char *fname, int loglevel)
if (getcwd (cwd, MAXPATHLEN) == NULL)
{
zlog_err ("config_log_file: Unable to alloc mem!");
- return CMD_WARNING;
+ return CMD_WARNING_CONFIG_FAILED;
}
if ( (p = XMALLOC (MTYPE_TMP, strlen (cwd) + strlen (fname) + 2))
== NULL)
{
zlog_err ("config_log_file: Unable to alloc mem!");
- return CMD_WARNING;
+ return CMD_WARNING_CONFIG_FAILED;
}
sprintf (p, "%s/%s", cwd, fname);
fullpath = p;
@@ -2157,7 +2192,7 @@ set_log_file(struct vty *vty, const char *fname, int loglevel)
if (!ret)
{
vty_out (vty, "can't open logfile %s\n", fname);
- return CMD_WARNING;
+ return CMD_WARNING_CONFIG_FAILED;
}
if (host.logfile)
@@ -2371,7 +2406,7 @@ cmd_banner_motd_file (const char *file)
host.motdfile = XSTRDUP (MTYPE_HOST, file);
}
else
- success = CMD_WARNING;
+ success = CMD_WARNING_CONFIG_FAILED;
return success;
}
@@ -2390,7 +2425,7 @@ DEFUN (banner_motd_file,
if (cmd == CMD_ERR_NO_FILE)
vty_out (vty, "%s does not exist", filename);
- else if (cmd == CMD_WARNING)
+ else if (cmd == CMD_WARNING_CONFIG_FAILED)
vty_out (vty, "%s must be in %s", filename, SYSCONFDIR);
return cmd;
diff --git a/lib/command.h b/lib/command.h
index 927c04006c..f712407b7f 100644
--- a/lib/command.h
+++ b/lib/command.h
@@ -178,6 +178,7 @@ struct cmd_node
#define CMD_SUCCESS_DAEMON 10
#define CMD_ERR_NO_FILE 11
#define CMD_SUSPEND 12
+#define CMD_WARNING_CONFIG_FAILED 13
/* Argc max counts. */
#define CMD_ARGC_MAX 25
@@ -293,6 +294,7 @@ struct cmd_node
*/
#define CMD_CREATE_STR(s) CMD_CREATE_STR_HELPER(s)
#define CMD_CREATE_STR_HELPER(s) #s
+#define CMD_RANGE_STR(a,s) "(" CMD_CREATE_STR(a) "-" CMD_CREATE_STR(s) ")"
/* Common descriptions. */
#define SHOW_STR "Show running system information\n"
@@ -404,5 +406,6 @@ struct cmd_variable_handler {
extern void cmd_variable_complete (struct cmd_token *token, const char *arg, vector comps);
extern void cmd_variable_handler_register (const struct cmd_variable_handler *cvh);
+extern char *cmd_variable_comp2str (vector comps, unsigned short cols, const char nl[]);
#endif /* _ZEBRA_COMMAND_H */
diff --git a/lib/distribute.c b/lib/distribute.c
index 79d7b18ff5..02c888b690 100644
--- a/lib/distribute.c
+++ b/lib/distribute.c
@@ -350,7 +350,7 @@ DEFUN (no_distribute_list,
if (! ret)
{
vty_outln (vty, "distribute list doesn't exist");
- return CMD_WARNING;
+ return CMD_WARNING_CONFIG_FAILED;
}
return CMD_SUCCESS;
}
diff --git a/lib/filter.c b/lib/filter.c
index 3cef49b2da..d2c80fc2ab 100644
--- a/lib/filter.c
+++ b/lib/filter.c
@@ -577,7 +577,7 @@ vty_access_list_remark_unset (struct vty *vty, afi_t afi, const char *name)
if (! access)
{
vty_outln (vty, "%% access-list %s doesn't exist",name);
- return CMD_WARNING;
+ return CMD_WARNING_CONFIG_FAILED;
}
if (access->remark)
@@ -616,21 +616,21 @@ filter_set_cisco (struct vty *vty, const char *name_str, const char *type_str,
else
{
vty_outln (vty, "%% filter type must be permit or deny");
- return CMD_WARNING;
+ return CMD_WARNING_CONFIG_FAILED;
}
ret = inet_aton (addr_str, &addr);
if (ret <= 0)
{
vty_outln (vty,"%%Inconsistent address and mask");
- return CMD_WARNING;
+ return CMD_WARNING_CONFIG_FAILED;
}
ret = inet_aton (addr_mask_str, &addr_mask);
if (ret <= 0)
{
vty_outln (vty,"%%Inconsistent address and mask");
- return CMD_WARNING;
+ return CMD_WARNING_CONFIG_FAILED;
}
if (extended)
@@ -639,14 +639,14 @@ filter_set_cisco (struct vty *vty, const char *name_str, const char *type_str,
if (ret <= 0)
{
vty_outln (vty,"%%Inconsistent address and mask");
- return CMD_WARNING;
+ return CMD_WARNING_CONFIG_FAILED;
}
ret = inet_aton (mask_mask_str, &mask_mask);
if (ret <= 0)
{
vty_outln (vty,"%%Inconsistent address and mask");
- return CMD_WARNING;
+ return CMD_WARNING_CONFIG_FAILED;
}
}
@@ -1259,7 +1259,7 @@ filter_set_zebra (struct vty *vty, const char *name_str, const char *type_str,
vty_outln (vty, "%% ACL name %s is invalid: length exceeds "
"%d characters",
name_str, ACL_NAMSIZ);
- return CMD_WARNING;
+ return CMD_WARNING_CONFIG_FAILED;
}
/* Check of filter type. */
@@ -1270,7 +1270,7 @@ filter_set_zebra (struct vty *vty, const char *name_str, const char *type_str,
else
{
vty_outln (vty, "filter type must be [permit|deny]");
- return CMD_WARNING;
+ return CMD_WARNING_CONFIG_FAILED;
}
/* Check string format of prefix and prefixlen. */
@@ -1280,7 +1280,7 @@ filter_set_zebra (struct vty *vty, const char *name_str, const char *type_str,
if (ret <= 0)
{
vty_outln (vty,"IP address prefix/prefixlen is malformed");
- return CMD_WARNING;
+ return CMD_WARNING_CONFIG_FAILED;
}
}
else if (afi == AFI_IP6)
@@ -1289,11 +1289,11 @@ filter_set_zebra (struct vty *vty, const char *name_str, const char *type_str,
if (ret <= 0)
{
vty_outln (vty,"IPv6 address prefix/prefixlen is malformed");
- return CMD_WARNING;
+ return CMD_WARNING_CONFIG_FAILED;
}
}
else
- return CMD_WARNING;
+ return CMD_WARNING_CONFIG_FAILED;
mfilter = filter_new ();
mfilter->type = type;
@@ -1425,7 +1425,7 @@ DEFUN (no_access_list_all,
if (access == NULL)
{
vty_outln (vty, "%% access-list %s doesn't exist",argv[idx_acl]->arg);
- return CMD_WARNING;
+ return CMD_WARNING_CONFIG_FAILED;
}
master = access->master;
@@ -1602,7 +1602,7 @@ DEFUN (no_ipv6_access_list_all,
if (access == NULL)
{
vty_outln (vty, "%% access-list %s doesn't exist",argv[idx_word]->arg);
- return CMD_WARNING;
+ return CMD_WARNING_CONFIG_FAILED;
}
master = access->master;
diff --git a/lib/grammar_sandbox.c b/lib/grammar_sandbox.c
index 454e076f06..7962b5aef5 100644
--- a/lib/grammar_sandbox.c
+++ b/lib/grammar_sandbox.c
@@ -399,7 +399,7 @@ DEFUN (grammar_findambig,
if (!scan && !nodegraph)
{
vty_out(vty, "nodegraph uninitialized\r\n");
- return CMD_WARNING;
+ return CMD_WARNING_CONFIG_FAILED;
}
do {
@@ -442,7 +442,7 @@ DEFUN (grammar_findambig,
if (scan)
nodegraph = NULL;
- return ambig == 0 ? CMD_SUCCESS : CMD_WARNING;
+ return ambig == 0 ? CMD_SUCCESS : CMD_WARNING_CONFIG_FAILED;
}
DEFUN (grammar_init_graph,
@@ -476,7 +476,7 @@ DEFUN (grammar_access,
if (!cnode)
{
vty_outln (vty, "%% no such node");
- return CMD_WARNING;
+ return CMD_WARNING_CONFIG_FAILED;
}
vty_outln (vty, "node %d", (int)cnode->node);
diff --git a/lib/hash.c b/lib/hash.c
index 62a39953c6..bdb2e097c6 100644
--- a/lib/hash.c
+++ b/lib/hash.c
@@ -87,13 +87,8 @@ hash_alloc_intern (void *arg)
}
#define hash_update_ssq(hz, old, new) \
- do { \
- long double res; \
- res = powl(old, 2.0); \
- hz->stats.ssq -= (uint64_t) res;\
- res = powl(new, 2.0); \
- hz->stats.ssq += (uint64_t) res; \
- } while (0); \
+ atomic_fetch_add_explicit(&hz->stats.ssq, (new + old)*(new - old),\
+ memory_order_relaxed);
/* Expand hash if the chain length exceeds the threshold. */
static void hash_expand (struct hash *hash)
diff --git a/lib/hash.h b/lib/hash.h
index 01d2b1ddc8..3b2671afae 100644
--- a/lib/hash.h
+++ b/lib/hash.h
@@ -53,9 +53,9 @@ struct hash_backet
struct hashstats
{
/* number of empty hash buckets */
- _Atomic int empty;
+ _Atomic uint_fast32_t empty;
/* sum of squares of bucket length */
- _Atomic uint64_t ssq;
+ _Atomic uint_fast32_t ssq;
};
struct hash
diff --git a/lib/if.c b/lib/if.c
index 1d6a8cb529..cea05643e7 100644
--- a/lib/if.c
+++ b/lib/if.c
@@ -693,7 +693,7 @@ DEFUN (interface,
vty_outln (vty, "%% Interface name %s is invalid: length exceeds "
"%d characters",
ifname, INTERFACE_NAMSIZ);
- return CMD_WARNING;
+ return CMD_WARNING_CONFIG_FAILED;
}
/*Pending: need proper vrf name based lookup/(possible creation of VRF)
@@ -710,7 +710,7 @@ DEFUN (interface,
if (!ifp)
{
vty_outln (vty, "%% interface %s not in %s", ifname, vrfname);
- return CMD_WARNING;
+ return CMD_WARNING_CONFIG_FAILED;
}
VTY_PUSH_CONTEXT (INTERFACE_NODE, ifp);
@@ -740,14 +740,14 @@ DEFUN_NOSH (no_interface,
if (ifp == NULL)
{
vty_out (vty, "%% Interface %s does not exist%s", ifname, VTYNL);
- return CMD_WARNING;
+ return CMD_WARNING_CONFIG_FAILED;
}
if (CHECK_FLAG (ifp->status, ZEBRA_INTERFACE_ACTIVE))
{
vty_out (vty, "%% Only inactive interfaces can be deleted%s",
VTYNL);
- return CMD_WARNING;
+ return CMD_WARNING_CONFIG_FAILED;
}
if_delete(ifp);
diff --git a/lib/if_rmap.c b/lib/if_rmap.c
index 32bebd67ff..492c39c6ae 100644
--- a/lib/if_rmap.c
+++ b/lib/if_rmap.c
@@ -229,7 +229,7 @@ DEFUN (if_rmap,
else
{
vty_outln (vty, "route-map direction must be [in|out]");
- return CMD_WARNING;
+ return CMD_WARNING_CONFIG_FAILED;
}
if_rmap_set (argv[idx_ifname]->arg, type, argv[idx_rmap_name]->arg);
@@ -260,14 +260,14 @@ DEFUN (no_if_rmap,
else
{
vty_outln (vty, "route-map direction must be [in|out]");
- return CMD_WARNING;
+ return CMD_WARNING_CONFIG_FAILED;
}
ret = if_rmap_unset (argv[idx_ifname]->arg, type, argv[idx_routemap_name]->arg);
if (! ret)
{
vty_outln (vty, "route-map doesn't exist");
- return CMD_WARNING;
+ return CMD_WARNING_CONFIG_FAILED;
}
return CMD_SUCCESS;
}
diff --git a/lib/keychain.c b/lib/keychain.c
index 9fe887c2c0..ab2ad3262e 100644
--- a/lib/keychain.c
+++ b/lib/keychain.c
@@ -272,7 +272,7 @@ DEFUN (no_key_chain,
if (! keychain)
{
vty_outln (vty, "Can't find keychain %s", argv[idx_word]->arg);
- return CMD_WARNING;
+ return CMD_WARNING_CONFIG_FAILED;
}
keychain_delete (keychain);
@@ -315,7 +315,7 @@ DEFUN (no_key,
if (! key)
{
vty_outln (vty, "Can't find key %d", index);
- return CMD_WARNING;
+ return CMD_WARNING_CONFIG_FAILED;
}
key_delete (keychain, key);
@@ -478,20 +478,20 @@ key_lifetime_set (struct vty *vty, struct key_range *krange,
if (time_start < 0)
{
vty_outln (vty, "Malformed time value");
- return CMD_WARNING;
+ return CMD_WARNING_CONFIG_FAILED;
}
time_end = key_str2time (etime_str, eday_str, emonth_str, eyear_str);
if (time_end < 0)
{
vty_outln (vty, "Malformed time value");
- return CMD_WARNING;
+ return CMD_WARNING_CONFIG_FAILED;
}
if (time_end <= time_start)
{
vty_outln (vty, "Expire time is not later than start time");
- return CMD_WARNING;
+ return CMD_WARNING_CONFIG_FAILED;
}
krange->start = time_start;
@@ -513,7 +513,7 @@ key_lifetime_duration_set (struct vty *vty, struct key_range *krange,
if (time_start < 0)
{
vty_outln (vty, "Malformed time value");
- return CMD_WARNING;
+ return CMD_WARNING_CONFIG_FAILED;
}
krange->start = time_start;
@@ -535,7 +535,7 @@ key_lifetime_infinite_set (struct vty *vty, struct key_range *krange,
if (time_start < 0)
{
vty_outln (vty, "Malformed time value");
- return CMD_WARNING;
+ return CMD_WARNING_CONFIG_FAILED;
}
krange->start = time_start;
diff --git a/lib/module.c b/lib/module.c
index c7dd5538cd..140fd87b99 100644
--- a/lib/module.c
+++ b/lib/module.c
@@ -110,7 +110,7 @@ struct frrmod_runtime *frrmod_load(const char *spec,
dlclose(handle);
if (err)
snprintf(err, err_len,
- "\"%s\" is not a Quagga module: %s",
+ "\"%s\" is not an FRR module: %s",
name, dlerror());
return NULL;
}
diff --git a/lib/ns.c b/lib/ns.c
index 4d46ecd0af..71f2b3ab6f 100644
--- a/lib/ns.c
+++ b/lib/ns.c
@@ -317,7 +317,7 @@ DEFUN_NOSH (ns_netns,
char *pathname = ns_netns_pathname (vty, argv[idx_name]->arg);
if (!pathname)
- return CMD_WARNING;
+ return CMD_WARNING_CONFIG_FAILED;
ns_id = strtoul (argv[idx_number]->arg, NULL, 10);
ns = ns_get (ns_id);
@@ -326,7 +326,7 @@ DEFUN_NOSH (ns_netns,
{
vty_out (vty, "NS %u is already configured with NETNS %s%s",
ns->ns_id, ns->name, VTYNL);
- return CMD_WARNING;
+ return CMD_WARNING_CONFIG_FAILED;
}
if (!ns->name)
@@ -336,7 +336,7 @@ DEFUN_NOSH (ns_netns,
{
vty_out (vty, "Can not associate NS %u with NETNS %s%s",
ns->ns_id, ns->name, VTYNL);
- return CMD_WARNING;
+ return CMD_WARNING_CONFIG_FAILED;
}
return CMD_SUCCESS;
@@ -358,7 +358,7 @@ DEFUN (no_ns_netns,
char *pathname = ns_netns_pathname (vty, argv[idx_name]->arg);
if (!pathname)
- return CMD_WARNING;
+ return CMD_WARNING_CONFIG_FAILED;
ns_id = strtoul(argv[idx_number]->arg, NULL, 10);
ns = ns_lookup (ns_id);
@@ -372,7 +372,7 @@ DEFUN (no_ns_netns,
if (ns->name && strcmp (ns->name, pathname) != 0)
{
vty_outln (vty, "Incorrect NETNS file name");
- return CMD_WARNING;
+ return CMD_WARNING_CONFIG_FAILED;
}
ns_disable (ns);
diff --git a/lib/plist.c b/lib/plist.c
index 339540a2b5..88788b14b1 100644
--- a/lib/plist.c
+++ b/lib/plist.c
@@ -884,7 +884,7 @@ vty_invalid_prefix_range (struct vty *vty, const char *prefix)
{
vty_outln (vty, "%% Invalid prefix range for %s, make sure: len < ge-value <= le-value",
prefix);
- return CMD_WARNING;
+ return CMD_WARNING_CONFIG_FAILED;
}
static int
@@ -921,7 +921,7 @@ vty_prefix_list_install (struct vty *vty, afi_t afi, const char *name,
else
{
vty_outln (vty, "%% prefix type must be permit or deny");
- return CMD_WARNING;
+ return CMD_WARNING_CONFIG_FAILED;
}
/* "any" is special token for matching any IPv4 addresses. */
@@ -941,7 +941,7 @@ vty_prefix_list_install (struct vty *vty, afi_t afi, const char *name,
if (ret <= 0)
{
vty_outln (vty, "%% Malformed IPv4 prefix");
- return CMD_WARNING;
+ return CMD_WARNING_CONFIG_FAILED;
}
/* make a copy to verify prefix matches mask length */
@@ -963,7 +963,7 @@ vty_prefix_list_install (struct vty *vty, afi_t afi, const char *name,
if (ret <= 0)
{
vty_outln (vty, "%% Malformed IPv6 prefix");
- return CMD_WARNING;
+ return CMD_WARNING_CONFIG_FAILED;
}
/* make a copy to verify prefix matches mask length */
@@ -974,7 +974,7 @@ vty_prefix_list_install (struct vty *vty, afi_t afi, const char *name,
case AFI_L2VPN:
default:
vty_outln (vty, "%% Unrecognized AFI (%d)", afi);
- return CMD_WARNING;
+ return CMD_WARNING_CONFIG_FAILED;
break;
}
@@ -1043,7 +1043,7 @@ vty_prefix_list_uninstall (struct vty *vty, afi_t afi, const char *name,
if (! plist)
{
vty_outln (vty, "%% Can't find specified prefix-list");
- return CMD_WARNING;
+ return CMD_WARNING_CONFIG_FAILED;
}
/* Only prefix-list name specified, delete the entire prefix-list. */
@@ -1058,7 +1058,7 @@ vty_prefix_list_uninstall (struct vty *vty, afi_t afi, const char *name,
if ((typestr == NULL) || (prefix == NULL))
{
vty_outln (vty, "%% Both prefix and type required");
- return CMD_WARNING;
+ return CMD_WARNING_CONFIG_FAILED;
}
/* Check sequence number. */
@@ -1079,7 +1079,7 @@ vty_prefix_list_uninstall (struct vty *vty, afi_t afi, const char *name,
else
{
vty_outln (vty, "%% prefix type must be permit or deny");
- return CMD_WARNING;
+ return CMD_WARNING_CONFIG_FAILED;
}
/* "any" is special token for matching any IPv4 addresses. */
@@ -1097,7 +1097,7 @@ vty_prefix_list_uninstall (struct vty *vty, afi_t afi, const char *name,
if (ret <= 0)
{
vty_outln (vty, "%% Malformed IPv4 prefix");
- return CMD_WARNING;
+ return CMD_WARNING_CONFIG_FAILED;
}
}
else if (afi == AFI_IP6)
@@ -1114,7 +1114,7 @@ vty_prefix_list_uninstall (struct vty *vty, afi_t afi, const char *name,
if (ret <= 0)
{
vty_outln (vty, "%% Malformed IPv6 prefix");
- return CMD_WARNING;
+ return CMD_WARNING_CONFIG_FAILED;
}
}
@@ -1124,7 +1124,7 @@ vty_prefix_list_uninstall (struct vty *vty, afi_t afi, const char *name,
if (pentry == NULL)
{
vty_outln (vty, "%% Can't find specified prefix-list");
- return CMD_WARNING;
+ return CMD_WARNING_CONFIG_FAILED;
}
/* Install new filter to the access_list. */
@@ -1142,7 +1142,7 @@ vty_prefix_list_desc_unset (struct vty *vty, afi_t afi, const char *name)
if (! plist)
{
vty_outln (vty, "%% Can't find specified prefix-list");
- return CMD_WARNING;
+ return CMD_WARNING_CONFIG_FAILED;
}
if (plist->desc)
@@ -1944,18 +1944,18 @@ prefix_bgp_orf_set (char *name, afi_t afi, struct orf_prefix *orfp,
/* ge and le value check */
if (orfp->ge && orfp->ge <= orfp->p.prefixlen)
- return CMD_WARNING;
+ return CMD_WARNING_CONFIG_FAILED;
if (orfp->le && orfp->le <= orfp->p.prefixlen)
- return CMD_WARNING;
+ return CMD_WARNING_CONFIG_FAILED;
if (orfp->le && orfp->ge > orfp->le)
- return CMD_WARNING;
+ return CMD_WARNING_CONFIG_FAILED;
if (orfp->ge && orfp->le == (afi == AFI_IP ? 32 : 128))
orfp->le = 0;
plist = prefix_list_get (afi, 1, name);
if (! plist)
- return CMD_WARNING;
+ return CMD_WARNING_CONFIG_FAILED;
if (set)
{
@@ -1966,7 +1966,7 @@ prefix_bgp_orf_set (char *name, afi_t afi, struct orf_prefix *orfp,
if (prefix_entry_dup_check (plist, pentry))
{
prefix_list_entry_free (pentry);
- return CMD_WARNING;
+ return CMD_WARNING_CONFIG_FAILED;
}
prefix_list_entry_add (plist, pentry);
@@ -1978,7 +1978,7 @@ prefix_bgp_orf_set (char *name, afi_t afi, struct orf_prefix *orfp,
orfp->seq, orfp->le, orfp->ge);
if (! pentry)
- return CMD_WARNING;
+ return CMD_WARNING_CONFIG_FAILED;
prefix_list_entry_delete (plist, pentry, 1);
}
diff --git a/lib/routemap.c b/lib/routemap.c
index caba8afd71..da8d48192c 100644
--- a/lib/routemap.c
+++ b/lib/routemap.c
@@ -522,11 +522,11 @@ generic_match_add (struct vty *vty, struct route_map_index *index,
{
case RMAP_RULE_MISSING:
vty_outln (vty, "%% [%s] Can't find rule.", frr_protonameinst);
- return CMD_WARNING;
+ return CMD_WARNING_CONFIG_FAILED;
case RMAP_COMPILE_ERROR:
vty_outln (vty, "%% [%s] Argument form is unsupported or malformed.",
frr_protonameinst);
- return CMD_WARNING;
+ return CMD_WARNING_CONFIG_FAILED;
}
}
@@ -579,7 +579,7 @@ generic_match_delete (struct vty *vty, struct route_map_index *index,
XFREE(MTYPE_ROUTE_MAP_RULE, dep_name);
if (rmap_name)
XFREE(MTYPE_ROUTE_MAP_NAME, rmap_name);
- return CMD_WARNING;
+ return CMD_WARNING_CONFIG_FAILED;
}
if (type != RMAP_EVENT_MATCH_DELETED && dep_name)
@@ -606,11 +606,11 @@ generic_set_add (struct vty *vty, struct route_map_index *index,
{
case RMAP_RULE_MISSING:
vty_outln (vty, "%% [%s] Can't find rule.", frr_protonameinst);
- return CMD_WARNING;
+ return CMD_WARNING_CONFIG_FAILED;
case RMAP_COMPILE_ERROR:
vty_outln (vty, "%% [%s] Argument form is unsupported or malformed.",
frr_protonameinst);
- return CMD_WARNING;
+ return CMD_WARNING_CONFIG_FAILED;
}
}
return CMD_SUCCESS;
@@ -629,11 +629,11 @@ generic_set_delete (struct vty *vty, struct route_map_index *index,
{
case RMAP_RULE_MISSING:
vty_outln (vty, "%% [%s] Can't find rule.", frr_protonameinst);
- return CMD_WARNING;
+ return CMD_WARNING_CONFIG_FAILED;
case RMAP_COMPILE_ERROR:
vty_outln (vty, "%% [%s] Argument form is unsupported or malformed.",
frr_protonameinst);
- return CMD_WARNING;
+ return CMD_WARNING_CONFIG_FAILED;
}
}
return CMD_SUCCESS;
@@ -2360,14 +2360,14 @@ DEFUN (set_ip_nexthop,
if (ret < 0)
{
vty_outln (vty, "%% Malformed nexthop address");
- return CMD_WARNING;
+ return CMD_WARNING_CONFIG_FAILED;
}
if (su.sin.sin_addr.s_addr == 0 ||
IPV4_CLASS_DE(su.sin.sin_addr.s_addr))
{
vty_outln (vty,
"%% nexthop address cannot be 0.0.0.0, multicast " "or reserved");
- return CMD_WARNING;
+ return CMD_WARNING_CONFIG_FAILED;
}
if (rmap_match_set_hook.set_ip_nexthop)
@@ -2417,12 +2417,12 @@ DEFUN (set_ipv6_nexthop_local,
if (!ret)
{
vty_outln (vty, "%% Malformed nexthop address");
- return CMD_WARNING;
+ return CMD_WARNING_CONFIG_FAILED;
}
if (!IN6_IS_ADDR_LINKLOCAL(&addr))
{
vty_outln (vty, "%% Invalid link-local nexthop address");
- return CMD_WARNING;
+ return CMD_WARNING_CONFIG_FAILED;
}
if (rmap_match_set_hook.set_ipv6_nexthop_local)
@@ -2578,7 +2578,7 @@ DEFUN (no_route_map_all,
if (map == NULL)
{
vty_outln (vty, "%% Could not find route-map %s", mapname);
- return CMD_WARNING;
+ return CMD_WARNING_CONFIG_FAILED;
}
route_map_delete (map);
@@ -2613,7 +2613,7 @@ DEFUN (no_route_map,
if (map == NULL)
{
vty_outln (vty, "%% Could not find route-map %s", mapname);
- return CMD_WARNING;
+ return CMD_WARNING_CONFIG_FAILED;
}
/* Lookup route map index. */
@@ -2622,7 +2622,7 @@ DEFUN (no_route_map,
{
vty_outln (vty, "%% Could not find route-map entry %s %s",
mapname, prefstr);
- return CMD_WARNING;
+ return CMD_WARNING_CONFIG_FAILED;
}
/* Delete index from route map. */
@@ -2649,7 +2649,7 @@ DEFUN (rmap_onmatch_next,
{
/* Under a deny clause, match means it's finished. No need to set next */
vty_outln (vty,"on-match next not supported under route-map deny");
- return CMD_WARNING;
+ return CMD_WARNING_CONFIG_FAILED;
}
index->exitpolicy = RMAP_NEXT;
}
@@ -2690,7 +2690,7 @@ DEFUN (rmap_onmatch_goto,
{
/* Under a deny clause, match means it's finished. No need to go anywhere */
vty_outln (vty,"on-match goto not supported under route-map deny");
- return CMD_WARNING;
+ return CMD_WARNING_CONFIG_FAILED;
}
if (num)
@@ -2702,7 +2702,7 @@ DEFUN (rmap_onmatch_goto,
{
/* Can't allow you to do that, Dave */
vty_outln (vty, "can't jump backwards in route-maps");
- return CMD_WARNING;
+ return CMD_WARNING_CONFIG_FAILED;
}
else
{
diff --git a/lib/smux.c b/lib/smux.c
index 6f4b45f9a3..77092cdc21 100644
--- a/lib/smux.c
+++ b/lib/smux.c
@@ -1279,7 +1279,7 @@ smux_peer_oid (struct vty *vty, const char *oid_str, const char *passwd_str)
if (ret != 0)
{
vty_out (vty, "object ID malformed%s", VTYNL);
- return CMD_WARNING;
+ return CMD_WARNING_CONFIG_FAILED;
}
if (smux_oid)
@@ -1339,7 +1339,7 @@ DEFUN (smux_peer,
return CMD_SUCCESS;
}
else
- return CMD_WARNING;
+ return CMD_WARNING_CONFIG_FAILED;
}
DEFUN (smux_peer_password,
@@ -1357,7 +1357,7 @@ DEFUN (smux_peer_password,
return CMD_SUCCESS;
}
else
- return CMD_WARNING;
+ return CMD_WARNING_CONFIG_FAILED;
}
DEFUN (no_smux_peer,
diff --git a/lib/vrf.c b/lib/vrf.c
index 6ad8cd91b6..d191514917 100644
--- a/lib/vrf.c
+++ b/lib/vrf.c
@@ -476,7 +476,7 @@ DEFUN_NOSH (vrf,
vty_out (vty, "%% VRF name %s is invalid: length exceeds "
"%d characters%s",
vrfname, VRF_NAMSIZ, VTYNL);
- return CMD_WARNING;
+ return CMD_WARNING_CONFIG_FAILED;
}
vrfp = vrf_get (VRF_UNKNOWN, vrfname);
@@ -502,14 +502,14 @@ DEFUN_NOSH (no_vrf,
if (vrfp == NULL)
{
vty_out (vty, "%% VRF %s does not exist%s", vrfname, VTYNL);
- return CMD_WARNING;
+ return CMD_WARNING_CONFIG_FAILED;
}
if (CHECK_FLAG (vrfp->status, VRF_ACTIVE))
{
vty_out (vty, "%% Only inactive VRFs can be deleted%s",
VTYNL);
- return CMD_WARNING;
+ return CMD_WARNING_CONFIG_FAILED;
}
vrf_delete(vrfp);
diff --git a/lib/vty.c b/lib/vty.c
index e6497b3100..2c25bd2fc3 100644
--- a/lib/vty.c
+++ b/lib/vty.c
@@ -1134,17 +1134,13 @@ vty_describe_command (struct vty *vty)
vector varcomps = vector_init (VECTOR_MIN_SIZE);
cmd_variable_complete (token, ref, varcomps);
- if (vector_active(varcomps) > 0)
+ if (vector_active (varcomps) > 0)
{
- vty_out(vty, " ");
- for (size_t j = 0; j < vector_active (varcomps); j++)
- {
- char *item = vector_slot (varcomps, j);
- vty_out(vty, " %s", item);
- XFREE(MTYPE_COMPLETION, item);
- }
- vty_out (vty, VTYNL);
+ char *ac = cmd_variable_comp2str(varcomps, vty->width, VTYNL);
+ vty_outln(vty, "%s", ac);
+ XFREE(MTYPE_TMP, ac);
}
+
vector_free(varcomps);
}
#if 0
@@ -2221,7 +2217,7 @@ vtysh_read (struct thread *thread)
if (ret == CMD_SUSPEND)
break;
- /* warning: watchquagga hardcodes this result write */
+ /* warning: watchfrr hardcodes this result write */
header[3] = ret;
buffer_put(vty->obuf, header, 4);
@@ -2820,7 +2816,7 @@ DEFUN (no_vty_access_class,
if (! vty_accesslist_name || (argc == 3 && strcmp(vty_accesslist_name, accesslist)))
{
vty_outln (vty,"Access-class is not currently applied to vty");
- return CMD_WARNING;
+ return CMD_WARNING_CONFIG_FAILED;
}
XFREE(MTYPE_VTY, vty_accesslist_name);
@@ -2863,7 +2859,7 @@ DEFUN (no_vty_ipv6_access_class,
(argc == 4 && strcmp(vty_ipv6_accesslist_name, accesslist)))
{
vty_outln (vty,"IPv6 access-class is not currently applied to vty");
- return CMD_WARNING;
+ return CMD_WARNING_CONFIG_FAILED;
}
XFREE(MTYPE_VTY, vty_ipv6_accesslist_name);
diff --git a/lib/vty.h b/lib/vty.h
index a76b9f5a17..b4a55180d3 100644
--- a/lib/vty.h
+++ b/lib/vty.h
@@ -182,6 +182,15 @@ struct vty_arg
/* Small macro to determine newline is newline only or linefeed needed. */
#define VTYNL ((vty->type == VTY_TERM) ? "\r\n" : "\n")
+/* for compatibility */
+#define VTY_NEWLINE VTYNL
+#define VTY_GET_INTEGER(desc,v,str) {(v)=strtoul ((str), NULL, 10);}
+#define VTY_GET_INTEGER_RANGE(desc,v,str,min,max) {(v)=strtoul ((str), NULL, 10);}
+#define VTY_GET_ULONG(desc,v,str) {(v)=strtoul ((str), NULL, 10);}
+#define VTY_GET_ULL(desc,v,str) {(v)=strtoull ((str), NULL, 10);}
+#define VTY_GET_IPV4_ADDRESS(desc,v,str) inet_aton ((str), &(v))
+#define VTY_GET_IPV4_PREFIX(desc,v,str) str2prefix_ipv4 ((str), &(v))
+
/* Default time out value */
#define VTY_TIMEOUT_DEFAULT 600