summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/affinitymap.h4
-rw-r--r--lib/affinitymap_cli.c40
-rw-r--r--lib/affinitymap_northbound.c1
-rw-r--r--lib/command.h8
-rw-r--r--lib/defun_lex.l1
-rw-r--r--lib/if.c2
-rw-r--r--lib/if.h2
-rw-r--r--lib/mgmt_be_client.c4
-rw-r--r--lib/northbound.c3
-rw-r--r--lib/northbound.h8
-rw-r--r--lib/vrf.c21
-rw-r--r--lib/vty.c14
-rw-r--r--lib/yang.c14
-rw-r--r--lib/yang.h8
-rw-r--r--lib/yang_wrappers.c27
-rw-r--r--lib/yang_wrappers.h7
16 files changed, 106 insertions, 58 deletions
diff --git a/lib/affinitymap.h b/lib/affinitymap.h
index f5924ca3ef..ebe2659bf7 100644
--- a/lib/affinitymap.h
+++ b/lib/affinitymap.h
@@ -58,6 +58,7 @@ struct affinity_maps {
DECLARE_QOBJ_TYPE(affinity_maps);
extern const struct frr_yang_module_info frr_affinity_map_info;
+extern const struct frr_yang_module_info frr_affinity_map_cli_info;
void affinity_map_set(const char *name, int pos);
void affinity_map_unset(const char *name);
@@ -69,9 +70,6 @@ void affinity_map_set_update_hook(void (*func)(const char *affmap_name,
uint16_t old_pos,
uint16_t new_pos));
-void cli_show_affinity_map(struct vty *vty, const struct lyd_node *dnode,
- bool show_defaults);
-
void affinity_map_init(void);
diff --git a/lib/affinitymap_cli.c b/lib/affinitymap_cli.c
index d417ae1951..73b91e775b 100644
--- a/lib/affinitymap_cli.c
+++ b/lib/affinitymap_cli.c
@@ -30,15 +30,6 @@
#include "lib/affinitymap.h"
#include "lib/affinitymap_cli_clippy.c"
-/* Route map node structure. */
-static int affinity_map_config_write(struct vty *vty);
-static struct cmd_node affinitymap_node = {
- .name = "affinity-map",
- .node = AFFMAP_NODE,
- .prompt = "",
- .config_write = affinity_map_config_write,
-};
-
/* max value is EXT_ADMIN_GROUP_MAX_POSITIONS - 1 */
DEFPY_YANG_NOSH(affinity_map, affinity_map_cmd,
"affinity-map NAME$name bit-position (0-1023)$position",
@@ -75,21 +66,7 @@ DEFPY_YANG_NOSH(no_affinity_map, no_affinity_map_cmd,
return nb_cli_apply_changes(vty, NULL);
}
-static int affinity_map_config_write(struct vty *vty)
-{
- const struct lyd_node *dnode;
- int written = 0;
-
- dnode = yang_dnode_get(running_config->dnode, "/frr-affinity-map:lib");
- if (dnode) {
- nb_cli_show_dnode_cmds(vty, dnode, false);
- written = 1;
- }
-
- return written;
-}
-
-void cli_show_affinity_map(struct vty *vty, const struct lyd_node *dnode,
+static void cli_show_affinity_map(struct vty *vty, const struct lyd_node *dnode,
bool show_defaults __attribute__((__unused__)))
{
vty_out(vty, "affinity-map %s bit-position %u\n",
@@ -97,11 +74,24 @@ void cli_show_affinity_map(struct vty *vty, const struct lyd_node *dnode,
yang_dnode_get_uint16(dnode, "value"));
}
+const struct frr_yang_module_info frr_affinity_map_cli_info = {
+ .name = "frr-affinity-map",
+ .ignore_cfg_cbs = true,
+ .nodes = {
+ {
+ .xpath = "/frr-affinity-map:lib/affinity-maps/affinity-map",
+ .cbs.cli_show = cli_show_affinity_map,
+ },
+ {
+ .xpath = NULL,
+ },
+ }
+};
+
/* Initialization of affinity map vector. */
void affinity_map_init(void)
{
/* CLI commands. */
- install_node(&affinitymap_node);
install_element(CONFIG_NODE, &affinity_map_cmd);
install_element(CONFIG_NODE, &no_affinity_map_cmd);
}
diff --git a/lib/affinitymap_northbound.c b/lib/affinitymap_northbound.c
index 9daccc2800..8e84d36f2f 100644
--- a/lib/affinitymap_northbound.c
+++ b/lib/affinitymap_northbound.c
@@ -94,7 +94,6 @@ const struct frr_yang_module_info frr_affinity_map_info = {
.cbs = {
.create = lib_affinity_map_create,
.destroy = lib_affinity_map_destroy,
- .cli_show = cli_show_affinity_map,
}
},
{
diff --git a/lib/command.h b/lib/command.h
index 4886b4bc47..04c66adb26 100644
--- a/lib/command.h
+++ b/lib/command.h
@@ -291,6 +291,10 @@ struct cmd_node {
#define DEFPY_YANG(funcname, cmdname, cmdstr, helpstr) \
DEFPY_ATTR(funcname, cmdname, cmdstr, helpstr, CMD_ATTR_YANG)
+#define DEFPY_YANG_HIDDEN(funcname, cmdname, cmdstr, helpstr) \
+ DEFPY_ATTR(funcname, cmdname, cmdstr, helpstr, \
+ CMD_ATTR_YANG | CMD_ATTR_HIDDEN)
+
#define DEFPY_YANG_NOSH(funcname, cmdname, cmdstr, helpstr) \
DEFPY_ATTR(funcname, cmdname, cmdstr, helpstr, \
CMD_ATTR_YANG | CMD_ATTR_NOSH)
@@ -315,6 +319,10 @@ struct cmd_node {
#define DEFUN_NOSH(funcname, cmdname, cmdstr, helpstr) \
DEFUN_ATTR(funcname, cmdname, cmdstr, helpstr, CMD_ATTR_NOSH)
+#define DEFUN_YANG_HIDDEN(funcname, cmdname, cmdstr, helpstr) \
+ DEFUN_ATTR(funcname, cmdname, cmdstr, helpstr, \
+ CMD_ATTR_YANG | CMD_ATTR_HIDDEN)
+
#define DEFUN_YANG_NOSH(funcname, cmdname, cmdstr, helpstr) \
DEFUN_ATTR(funcname, cmdname, cmdstr, helpstr, \
CMD_ATTR_YANG | CMD_ATTR_NOSH)
diff --git a/lib/defun_lex.l b/lib/defun_lex.l
index 124f864166..3104e48063 100644
--- a/lib/defun_lex.l
+++ b/lib/defun_lex.l
@@ -140,6 +140,7 @@ SPECIAL [(),]
"DEFPY_ATTR" value = strdup(yytext); return DEFUNNY;
"DEFPY_HIDDEN" value = strdup(yytext); return DEFUNNY;
"DEFPY_YANG" value = strdup(yytext); return DEFUNNY;
+"DEFPY_YANG_HIDDEN" value = strdup(yytext); return DEFUNNY;
"DEFPY_YANG_NOSH" value = strdup(yytext); return DEFUNNY;
"ALIAS" value = strdup(yytext); return DEFUNNY;
"ALIAS_HIDDEN" value = strdup(yytext); return DEFUNNY;
diff --git a/lib/if.c b/lib/if.c
index 1a8195de67..1328e21874 100644
--- a/lib/if.c
+++ b/lib/if.c
@@ -1135,7 +1135,7 @@ struct if_link_params *if_link_params_enable(struct interface *ifp)
iflp->unrsv_bw[i] = iflp->default_bw;
/* Update Link parameters status */
- iflp->lp_status = LP_MAX_BW | LP_MAX_RSV_BW | LP_UNRSV_BW | LP_EXTEND_ADM_GRP;
+ iflp->lp_status = LP_MAX_BW | LP_MAX_RSV_BW | LP_UNRSV_BW;
/* Set TE metric equal to standard metric only if it is set */
if (ifp->metric != 0) {
diff --git a/lib/if.h b/lib/if.h
index fd5f6f7502..548a91b948 100644
--- a/lib/if.h
+++ b/lib/if.h
@@ -195,7 +195,7 @@ struct if_link_params {
uint32_t min_delay; /* Link Min Delay */
uint32_t max_delay; /* Link Max Delay */
uint32_t delay_var; /* Link Delay Variation */
- float pkt_loss; /* Link Packet Loss */
+ uint32_t pkt_loss; /* Link Packet Loss */
float res_bw; /* Residual Bandwidth */
float ava_bw; /* Available Bandwidth */
float use_bw; /* Utilized Bandwidth */
diff --git a/lib/mgmt_be_client.c b/lib/mgmt_be_client.c
index 458623844a..463aefdf25 100644
--- a/lib/mgmt_be_client.c
+++ b/lib/mgmt_be_client.c
@@ -19,6 +19,7 @@
#include "northbound.h"
#include "stream.h"
#include "sockopt.h"
+#include "northbound_cli.h"
#include "lib/mgmt_be_client_clippy.c"
@@ -1068,7 +1069,7 @@ struct mgmt_be_client *mgmt_be_client_create(const char *client_name,
client->name = XSTRDUP(MTYPE_MGMTD_BE_CLIENT_NAME, client_name);
client->running_config = running_config;
- client->candidate_config = nb_config_new(NULL);
+ client->candidate_config = vty_shared_candidate_config;
if (cbs)
client->cbs = *cbs;
mgmt_be_txns_init(&client->txn_head);
@@ -1107,7 +1108,6 @@ void mgmt_be_client_destroy(struct mgmt_be_client *client)
msg_client_cleanup(&client->client);
mgmt_be_cleanup_all_txns(client);
mgmt_be_txns_fini(&client->txn_head);
- nb_config_free(client->candidate_config);
XFREE(MTYPE_MGMTD_BE_CLIENT_NAME, client->name);
XFREE(MTYPE_MGMTD_BE_CLIENT, client);
diff --git a/lib/northbound.c b/lib/northbound.c
index 949218332a..b1da3315d0 100644
--- a/lib/northbound.c
+++ b/lib/northbound.c
@@ -2384,7 +2384,8 @@ void nb_init(struct event_loop *tm,
for (size_t i = 0; i < nmodules; i++) {
DEBUGD(&nb_dbg_events, "northbound: loading %s.yang",
modules[i]->name);
- *loadedp++ = yang_module_load(modules[i]->name);
+ *loadedp++ = yang_module_load(modules[i]->name,
+ modules[i]->features);
}
if (explicit_compile)
diff --git a/lib/northbound.h b/lib/northbound.h
index 493e5ce703..2d9643e7b4 100644
--- a/lib/northbound.h
+++ b/lib/northbound.h
@@ -628,6 +628,14 @@ struct frr_yang_module_info {
*/
bool ignore_cfg_cbs;
+ /*
+ * The NULL-terminated list of supported features.
+ * Features are defined with "feature" statements in the YANG model.
+ * Use ["*", NULL] to enable all features.
+ * Use NULL to disable all features.
+ */
+ const char **features;
+
/* Northbound callbacks. */
const struct {
/* Data path of this YANG node. */
diff --git a/lib/vrf.c b/lib/vrf.c
index 48071f2bd6..65721445ab 100644
--- a/lib/vrf.c
+++ b/lib/vrf.c
@@ -956,6 +956,25 @@ static int lib_vrf_destroy(struct nb_cb_destroy_args *args)
return NB_OK;
}
+static void lib_vrf_cli_write(struct vty *vty, const struct lyd_node *dnode,
+ bool show_defaults)
+{
+ const char *name = yang_dnode_get_string(dnode, "name");
+
+ if (strcmp(name, VRF_DEFAULT_NAME)) {
+ vty_out(vty, "!\n");
+ vty_out(vty, "vrf %s\n", name);
+ }
+}
+
+static void lib_vrf_cli_write_end(struct vty *vty, const struct lyd_node *dnode)
+{
+ const char *name = yang_dnode_get_string(dnode, "name");
+
+ if (strcmp(name, VRF_DEFAULT_NAME))
+ vty_out(vty, "exit-vrf\n");
+}
+
static const void *lib_vrf_get_next(struct nb_cb_get_next_args *args)
{
struct vrf *vrfp = (struct vrf *)args->list_entry;
@@ -1035,6 +1054,8 @@ const struct frr_yang_module_info frr_vrf_info = {
.cbs = {
.create = lib_vrf_create,
.destroy = lib_vrf_destroy,
+ .cli_show = lib_vrf_cli_write,
+ .cli_show_end = lib_vrf_cli_write_end,
.get_next = lib_vrf_get_next,
.get_keys = lib_vrf_get_keys,
.lookup_entry = lib_vrf_lookup_entry,
diff --git a/lib/vty.c b/lib/vty.c
index a6b4de579a..ea35c541ee 100644
--- a/lib/vty.c
+++ b/lib/vty.c
@@ -126,6 +126,7 @@ bool vty_log_commands;
static bool vty_log_commands_perm;
char const *const mgmt_daemons[] = {
+ "zebra",
#ifdef HAVE_RIPD
"ripd",
#endif
@@ -2264,19 +2265,6 @@ bool mgmt_vty_read_configs(void)
snprintf(path, sizeof(path), "%s/mgmtd.conf", frr_sysconfdir);
confp = vty_open_config(path, config_default);
- if (!confp) {
- char *orig;
-
- snprintf(path, sizeof(path), "%s/zebra.conf", frr_sysconfdir);
- orig = XSTRDUP(MTYPE_TMP, host_config_get());
-
- zlog_info("mgmtd: trying backup config file: %s", path);
- confp = vty_open_config(path, config_default);
-
- host_config_set(path);
- XFREE(MTYPE_TMP, orig);
- }
-
if (confp) {
zlog_info("mgmtd: reading config file: %s", path);
diff --git a/lib/yang.c b/lib/yang.c
index b6884619d9..3dd2513a4b 100644
--- a/lib/yang.c
+++ b/lib/yang.c
@@ -100,13 +100,14 @@ RB_GENERATE(yang_modules, yang_module, entry, yang_module_compare)
struct yang_modules yang_modules = RB_INITIALIZER(&yang_modules);
-struct yang_module *yang_module_load(const char *module_name)
+struct yang_module *yang_module_load(const char *module_name,
+ const char **features)
{
struct yang_module *module;
const struct lys_module *module_info;
- module_info =
- ly_ctx_load_module(ly_native_ctx, module_name, NULL, NULL);
+ module_info = ly_ctx_load_module(ly_native_ctx, module_name, NULL,
+ features);
if (!module_info) {
flog_err(EC_LIB_YANG_MODULE_LOAD,
"%s: failed to load data model: %s", __func__,
@@ -130,8 +131,10 @@ struct yang_module *yang_module_load(const char *module_name)
void yang_module_load_all(void)
{
+ static const char * const all_features[] = { "*", NULL };
+
for (size_t i = 0; i < array_size(frr_native_modules); i++)
- yang_module_load(frr_native_modules[i]);
+ yang_module_load(frr_native_modules[i], (const char **)all_features);
}
struct yang_module *yang_module_find(const char *module_name)
@@ -625,7 +628,8 @@ struct lyd_node *yang_dnode_dup(const struct lyd_node *dnode)
{
struct lyd_node *dup = NULL;
LY_ERR err;
- err = lyd_dup_siblings(dnode, NULL, LYD_DUP_RECURSIVE, &dup);
+ err = lyd_dup_siblings(dnode, NULL,
+ LYD_DUP_RECURSIVE | LYD_DUP_WITH_FLAGS, &dup);
assert(!err);
return dup;
}
diff --git a/lib/yang.h b/lib/yang.h
index 1235125f26..431b2eee48 100644
--- a/lib/yang.h
+++ b/lib/yang.h
@@ -112,10 +112,16 @@ extern struct yang_modules yang_modules;
* module_name
* Name of the YANG module.
*
+ * features
+ * NULL-terminated array of feature names to enable.
+ * If NULL, all features are disabled.
+ * To enable all features, use ["*", NULL].
+ *
* Returns:
* Pointer to newly created YANG module.
*/
-extern struct yang_module *yang_module_load(const char *module_name);
+extern struct yang_module *yang_module_load(const char *module_name,
+ const char **features);
/*
* Load all FRR native YANG models.
diff --git a/lib/yang_wrappers.c b/lib/yang_wrappers.c
index dc049a374a..a0133954c3 100644
--- a/lib/yang_wrappers.c
+++ b/lib/yang_wrappers.c
@@ -168,10 +168,9 @@ struct yang_data *yang_data_new_dec64(const char *xpath, double value)
double yang_dnode_get_dec64(const struct lyd_node *dnode, const char *xpath_fmt,
...)
{
- const double denom[19] = {1e0, 1e-1, 1e-2, 1e-3, 1e-4,
- 1e-5, 1e-6, 1e-7, 1e-8, 1e-9,
- 1e-10, 1e-11, 1e-12, 1e-13, 1e-14,
- 1e-15, 1e-16, 1e-17, 1e-18};
+ const double denom[19] = { 1e0, 1e1, 1e2, 1e3, 1e4, 1e5, 1e6,
+ 1e7, 1e8, 1e9, 1e10, 1e11, 1e12, 1e13,
+ 1e14, 1e15, 1e16, 1e17, 1e18 };
const struct lysc_type_dec *dectype;
const struct lyd_value *dvalue;
@@ -179,7 +178,7 @@ double yang_dnode_get_dec64(const struct lyd_node *dnode, const char *xpath_fmt,
dectype = (const struct lysc_type_dec *)dvalue->realtype;
assert(dectype->basetype == LY_TYPE_DEC64);
assert(dectype->fraction_digits < sizeof(denom) / sizeof(*denom));
- return (double)dvalue->dec64 * denom[dectype->fraction_digits];
+ return (double)dvalue->dec64 / denom[dectype->fraction_digits];
}
double yang_get_default_dec64(const char *xpath_fmt, ...)
@@ -1020,6 +1019,13 @@ void yang_str2mac(const char *value, struct ethaddr *mac)
(void)prefix_str2mac(value, mac);
}
+void yang_dnode_get_mac(struct ethaddr *mac, const struct lyd_node *dnode,
+ const char *xpath_fmt, ...)
+{
+ const char *canon = YANG_DNODE_XPATH_GET_CANON(dnode, xpath_fmt);
+ (void)prefix_str2mac(canon, mac);
+}
+
struct yang_data *yang_data_new_date_and_time(const char *xpath, time_t time)
{
struct tm tm;
@@ -1046,6 +1052,17 @@ struct yang_data *yang_data_new_date_and_time(const char *xpath, time_t time)
return yang_data_new(xpath, timebuf);
}
+float yang_dnode_get_bandwidth_ieee_float32(const struct lyd_node *dnode,
+ const char *xpath_fmt, ...)
+{
+ const char *canon = YANG_DNODE_XPATH_GET_CANON(dnode, xpath_fmt);
+ float value;
+
+ assert(sscanf(canon, "%a", &value) == 1);
+
+ return value;
+}
+
const char *yang_nexthop_type2str(uint32_t ntype)
{
switch (ntype) {
diff --git a/lib/yang_wrappers.h b/lib/yang_wrappers.h
index 06e05872e3..59b5b13acd 100644
--- a/lib/yang_wrappers.h
+++ b/lib/yang_wrappers.h
@@ -195,11 +195,18 @@ extern void yang_get_default_ip(struct ipaddr *var, const char *xpath_fmt, ...)
extern struct yang_data *yang_data_new_mac(const char *xpath,
const struct ethaddr *mac);
extern void yang_str2mac(const char *value, struct ethaddr *mac);
+extern void yang_dnode_get_mac(struct ethaddr *mac, const struct lyd_node *dnode,
+ const char *xpath_fmt, ...) PRINTFRR(3, 4);
/*data-and-time */
extern struct yang_data *yang_data_new_date_and_time(const char *xpath,
time_t time);
+/* rt-types:bandwidth-ieee-float32 */
+extern float yang_dnode_get_bandwidth_ieee_float32(const struct lyd_node *dnode,
+ const char *xpath_fmt, ...)
+ PRINTFRR(2, 3);
+
/* nexthop enum2str */
extern const char *yang_nexthop_type2str(uint32_t ntype);