mirror of
https://git.proxmox.com/git/mirror_frr
synced 2025-05-29 07:59:35 +00:00
zebra: convert table range command to NB
Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
This commit is contained in:
parent
2117faf1cf
commit
86855aed78
@ -2824,6 +2824,31 @@ module frr-zebra {
|
|||||||
Removing the leaf sets it back to the default value for the profile.";
|
Removing the leaf sets it back to the default value for the profile.";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
container netns {
|
||||||
|
description
|
||||||
|
"Configuration for netns VRF backend.";
|
||||||
|
container table-range {
|
||||||
|
presence "Activates table-range configuration.";
|
||||||
|
description
|
||||||
|
"The range of tables to use for this netns.";
|
||||||
|
leaf start {
|
||||||
|
type uint32;
|
||||||
|
mandatory true;
|
||||||
|
description
|
||||||
|
"The first table to use.";
|
||||||
|
}
|
||||||
|
leaf end {
|
||||||
|
type uint32;
|
||||||
|
mandatory true;
|
||||||
|
must ". >= ../start" {
|
||||||
|
error-message "End table must be greater than or equal to start table";
|
||||||
|
}
|
||||||
|
description
|
||||||
|
"The last table to use.";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
uses ribs;
|
uses ribs;
|
||||||
|
|
||||||
uses vrf-vni-mapping;
|
uses vrf-vni-mapping;
|
||||||
|
@ -24,21 +24,6 @@
|
|||||||
#include "zebra/table_manager.h"
|
#include "zebra/table_manager.h"
|
||||||
#include "zebra/zebra_errors.h"
|
#include "zebra/zebra_errors.h"
|
||||||
|
|
||||||
/* routing table identifiers
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
#if !defined(GNU_LINUX)
|
|
||||||
/* BSD systems
|
|
||||||
*/
|
|
||||||
#else
|
|
||||||
/* Linux Systems
|
|
||||||
*/
|
|
||||||
#define RT_TABLE_ID_LOCAL 255
|
|
||||||
#define RT_TABLE_ID_MAIN 254
|
|
||||||
#define RT_TABLE_ID_DEFAULT 253
|
|
||||||
#define RT_TABLE_ID_COMPAT 252
|
|
||||||
#define RT_TABLE_ID_UNSPEC 0
|
|
||||||
#endif /* !def(GNU_LINUX) */
|
|
||||||
#define RT_TABLE_ID_UNRESERVED_MIN 1
|
#define RT_TABLE_ID_UNRESERVED_MIN 1
|
||||||
#define RT_TABLE_ID_UNRESERVED_MAX 0xffffffff
|
#define RT_TABLE_ID_UNRESERVED_MAX 0xffffffff
|
||||||
|
|
||||||
@ -279,52 +264,17 @@ void table_manager_disable(struct zebra_vrf *zvrf)
|
|||||||
zvrf->tbl_mgr = NULL;
|
zvrf->tbl_mgr = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
int table_manager_range(struct vty *vty, bool add, struct zebra_vrf *zvrf,
|
void table_manager_range(bool add, struct zebra_vrf *zvrf, uint32_t start,
|
||||||
const char *start_table_str, const char *end_table_str)
|
uint32_t end)
|
||||||
{
|
{
|
||||||
uint32_t start;
|
|
||||||
uint32_t end;
|
|
||||||
|
|
||||||
if (add) {
|
if (add) {
|
||||||
if (!start_table_str || !end_table_str) {
|
if (zvrf->tbl_mgr &&
|
||||||
vty_out(vty, "%% Labels not specified\n");
|
((zvrf->tbl_mgr->start && zvrf->tbl_mgr->start != start) ||
|
||||||
return CMD_WARNING_CONFIG_FAILED;
|
(zvrf->tbl_mgr->end && zvrf->tbl_mgr->end != end)))
|
||||||
}
|
zlog_info(
|
||||||
start = atoi(start_table_str);
|
"%% New range will be taken into account at restart");
|
||||||
end = atoi(end_table_str);
|
|
||||||
if (end < start) {
|
|
||||||
vty_out(vty, "%% End table is less than Start table\n");
|
|
||||||
return CMD_WARNING_CONFIG_FAILED;
|
|
||||||
}
|
|
||||||
|
|
||||||
#if !defined(GNU_LINUX)
|
|
||||||
/* BSD systems
|
|
||||||
*/
|
|
||||||
#else
|
|
||||||
/* Linux Systems
|
|
||||||
*/
|
|
||||||
if ((start >= RT_TABLE_ID_COMPAT && start <= RT_TABLE_ID_LOCAL)
|
|
||||||
|| (end >= RT_TABLE_ID_COMPAT
|
|
||||||
&& end <= RT_TABLE_ID_LOCAL)) {
|
|
||||||
vty_out(vty, "%% Values forbidden in range [%u;%u]\n",
|
|
||||||
RT_TABLE_ID_COMPAT, RT_TABLE_ID_LOCAL);
|
|
||||||
return CMD_WARNING_CONFIG_FAILED;
|
|
||||||
}
|
|
||||||
if (start < RT_TABLE_ID_COMPAT && end > RT_TABLE_ID_LOCAL) {
|
|
||||||
vty_out(vty,
|
|
||||||
"%% Range overlaps range [%u;%u] forbidden\n",
|
|
||||||
RT_TABLE_ID_COMPAT, RT_TABLE_ID_LOCAL);
|
|
||||||
return CMD_WARNING_CONFIG_FAILED;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
if (zvrf->tbl_mgr
|
|
||||||
&& ((zvrf->tbl_mgr->start && zvrf->tbl_mgr->start != start)
|
|
||||||
|| (zvrf->tbl_mgr->end && zvrf->tbl_mgr->end != end))) {
|
|
||||||
vty_out(vty,
|
|
||||||
"%% New range will be taken into account at restart\n");
|
|
||||||
}
|
|
||||||
table_range_add(zvrf, start, end);
|
table_range_add(zvrf, start, end);
|
||||||
} else
|
} else
|
||||||
table_range_add(zvrf, 0, 0);
|
table_range_add(zvrf, 0, 0);
|
||||||
return CMD_SUCCESS;
|
|
||||||
}
|
}
|
||||||
|
@ -18,6 +18,22 @@
|
|||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/* routing table identifiers
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
#if !defined(GNU_LINUX)
|
||||||
|
/* BSD systems
|
||||||
|
*/
|
||||||
|
#else
|
||||||
|
/* Linux Systems
|
||||||
|
*/
|
||||||
|
#define RT_TABLE_ID_LOCAL 255
|
||||||
|
#define RT_TABLE_ID_MAIN 254
|
||||||
|
#define RT_TABLE_ID_DEFAULT 253
|
||||||
|
#define RT_TABLE_ID_COMPAT 252
|
||||||
|
#define RT_TABLE_ID_UNSPEC 0
|
||||||
|
#endif /* !def(GNU_LINUX) */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Table chunk struct
|
* Table chunk struct
|
||||||
* Client daemon which the chunk belongs to can be identified by either
|
* Client daemon which the chunk belongs to can be identified by either
|
||||||
@ -56,8 +72,8 @@ int release_table_chunk(uint8_t proto, uint16_t instance, uint32_t start,
|
|||||||
uint32_t end, struct zebra_vrf *zvrf);
|
uint32_t end, struct zebra_vrf *zvrf);
|
||||||
int release_daemon_table_chunks(struct zserv *client);
|
int release_daemon_table_chunks(struct zserv *client);
|
||||||
void table_manager_disable(struct zebra_vrf *zvrf);
|
void table_manager_disable(struct zebra_vrf *zvrf);
|
||||||
int table_manager_range(struct vty *vty, bool add, struct zebra_vrf *zvrf,
|
void table_manager_range(bool add, struct zebra_vrf *zvrf, uint32_t start,
|
||||||
const char *min, const char *max);
|
uint32_t end);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
@ -893,6 +893,25 @@ const struct frr_yang_module_info frr_zebra_info = {
|
|||||||
.destroy = lib_vrf_zebra_ipv6_resolve_via_default_destroy,
|
.destroy = lib_vrf_zebra_ipv6_resolve_via_default_destroy,
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
.xpath = "/frr-vrf:lib/vrf/frr-zebra:zebra/netns/table-range",
|
||||||
|
.cbs = {
|
||||||
|
.create = lib_vrf_zebra_netns_table_range_create,
|
||||||
|
.destroy = lib_vrf_zebra_netns_table_range_destroy,
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
.xpath = "/frr-vrf:lib/vrf/frr-zebra:zebra/netns/table-range/start",
|
||||||
|
.cbs = {
|
||||||
|
.modify = lib_vrf_zebra_netns_table_range_start_modify,
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
.xpath = "/frr-vrf:lib/vrf/frr-zebra:zebra/netns/table-range/end",
|
||||||
|
.cbs = {
|
||||||
|
.modify = lib_vrf_zebra_netns_table_range_end_modify,
|
||||||
|
}
|
||||||
|
},
|
||||||
{
|
{
|
||||||
.xpath = "/frr-vrf:lib/vrf/frr-zebra:zebra/ribs/rib",
|
.xpath = "/frr-vrf:lib/vrf/frr-zebra:zebra/ribs/rib",
|
||||||
.cbs = {
|
.cbs = {
|
||||||
|
@ -433,6 +433,10 @@ int lib_vrf_zebra_resolve_via_default_destroy(struct nb_cb_destroy_args *args);
|
|||||||
int lib_vrf_zebra_ipv6_resolve_via_default_modify(struct nb_cb_modify_args *args);
|
int lib_vrf_zebra_ipv6_resolve_via_default_modify(struct nb_cb_modify_args *args);
|
||||||
int lib_vrf_zebra_ipv6_resolve_via_default_destroy(
|
int lib_vrf_zebra_ipv6_resolve_via_default_destroy(
|
||||||
struct nb_cb_destroy_args *args);
|
struct nb_cb_destroy_args *args);
|
||||||
|
int lib_vrf_zebra_netns_table_range_create(struct nb_cb_create_args *args);
|
||||||
|
int lib_vrf_zebra_netns_table_range_destroy(struct nb_cb_destroy_args *args);
|
||||||
|
int lib_vrf_zebra_netns_table_range_start_modify(struct nb_cb_modify_args *args);
|
||||||
|
int lib_vrf_zebra_netns_table_range_end_modify(struct nb_cb_modify_args *args);
|
||||||
const void *lib_vrf_zebra_ribs_rib_get_next(struct nb_cb_get_next_args *args);
|
const void *lib_vrf_zebra_ribs_rib_get_next(struct nb_cb_get_next_args *args);
|
||||||
int lib_vrf_zebra_ribs_rib_get_keys(struct nb_cb_get_keys_args *args);
|
int lib_vrf_zebra_ribs_rib_get_keys(struct nb_cb_get_keys_args *args);
|
||||||
const void *
|
const void *
|
||||||
|
@ -28,6 +28,7 @@
|
|||||||
#include "zebra/router-id.h"
|
#include "zebra/router-id.h"
|
||||||
#include "zebra/zebra_routemap.h"
|
#include "zebra/zebra_routemap.h"
|
||||||
#include "zebra/zebra_rnh.h"
|
#include "zebra/zebra_rnh.h"
|
||||||
|
#include "zebra/table_manager.h"
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* XPath: /frr-zebra:zebra/mcast-rpf-lookup
|
* XPath: /frr-zebra:zebra/mcast-rpf-lookup
|
||||||
@ -3630,6 +3631,125 @@ int lib_vrf_zebra_ipv6_resolve_via_default_destroy(struct nb_cb_destroy_args *ar
|
|||||||
return NB_OK;
|
return NB_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* XPath: /frr-vrf:lib/vrf/frr-zebra:zebra/netns/table-range
|
||||||
|
*/
|
||||||
|
static int table_range_validate(uint32_t start, uint32_t end, char *errmsg,
|
||||||
|
size_t errmsg_len)
|
||||||
|
{
|
||||||
|
#if defined(GNU_LINUX)
|
||||||
|
if ((start >= RT_TABLE_ID_COMPAT && start <= RT_TABLE_ID_LOCAL) ||
|
||||||
|
(end >= RT_TABLE_ID_COMPAT && end <= RT_TABLE_ID_LOCAL)) {
|
||||||
|
snprintfrr(errmsg, errmsg_len,
|
||||||
|
"Values forbidden in range [%u;%u]",
|
||||||
|
RT_TABLE_ID_COMPAT, RT_TABLE_ID_LOCAL);
|
||||||
|
return NB_ERR_VALIDATION;
|
||||||
|
}
|
||||||
|
if (start < RT_TABLE_ID_COMPAT && end > RT_TABLE_ID_LOCAL) {
|
||||||
|
snprintfrr(errmsg, errmsg_len,
|
||||||
|
"Range overlaps range [%u;%u] forbidden",
|
||||||
|
RT_TABLE_ID_COMPAT, RT_TABLE_ID_LOCAL);
|
||||||
|
return NB_ERR_VALIDATION;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
return NB_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
int lib_vrf_zebra_netns_table_range_create(struct nb_cb_create_args *args)
|
||||||
|
{
|
||||||
|
struct vrf *vrf;
|
||||||
|
uint32_t start, end;
|
||||||
|
const char *vrf_name;
|
||||||
|
|
||||||
|
start = yang_dnode_get_uint32(args->dnode, "start");
|
||||||
|
end = yang_dnode_get_uint32(args->dnode, "end");
|
||||||
|
|
||||||
|
if (args->event == NB_EV_VALIDATE) {
|
||||||
|
vrf_name = yang_dnode_get_string(args->dnode, "../../../name");
|
||||||
|
if (!vrf_is_backend_netns() &&
|
||||||
|
strcmp(vrf_name, VRF_DEFAULT_NAME)) {
|
||||||
|
snprintfrr(args->errmsg, args->errmsg_len,
|
||||||
|
"Configuration is not available in non-default VRFs when using VRF-lite backend.");
|
||||||
|
return NB_ERR_VALIDATION;
|
||||||
|
}
|
||||||
|
return table_range_validate(start, end, args->errmsg,
|
||||||
|
args->errmsg_len);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (args->event != NB_EV_APPLY)
|
||||||
|
return NB_OK;
|
||||||
|
|
||||||
|
vrf = nb_running_get_entry(args->dnode, NULL, true);
|
||||||
|
|
||||||
|
table_manager_range(true, vrf->info, start, end);
|
||||||
|
|
||||||
|
return NB_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
int lib_vrf_zebra_netns_table_range_destroy(struct nb_cb_destroy_args *args)
|
||||||
|
{
|
||||||
|
struct vrf *vrf;
|
||||||
|
|
||||||
|
if (args->event != NB_EV_APPLY)
|
||||||
|
return NB_OK;
|
||||||
|
|
||||||
|
vrf = nb_running_get_entry(args->dnode, NULL, true);
|
||||||
|
|
||||||
|
table_manager_range(false, vrf->info, 0, 0);
|
||||||
|
|
||||||
|
return NB_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* XPath: /frr-vrf:lib/vrf/frr-zebra:zebra/netns/table-range/start
|
||||||
|
*/
|
||||||
|
int lib_vrf_zebra_netns_table_range_start_modify(struct nb_cb_modify_args *args)
|
||||||
|
{
|
||||||
|
struct vrf *vrf;
|
||||||
|
uint32_t start, end;
|
||||||
|
|
||||||
|
start = yang_dnode_get_uint32(args->dnode, NULL);
|
||||||
|
end = yang_dnode_get_uint32(args->dnode, "../end");
|
||||||
|
|
||||||
|
if (args->event == NB_EV_VALIDATE)
|
||||||
|
return table_range_validate(start, end, args->errmsg,
|
||||||
|
args->errmsg_len);
|
||||||
|
|
||||||
|
if (args->event != NB_EV_APPLY)
|
||||||
|
return NB_OK;
|
||||||
|
|
||||||
|
vrf = nb_running_get_entry(args->dnode, NULL, true);
|
||||||
|
|
||||||
|
table_manager_range(true, vrf->info, start, end);
|
||||||
|
|
||||||
|
return NB_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* XPath: /frr-vrf:lib/vrf/frr-zebra:zebra/netns/table-range/end
|
||||||
|
*/
|
||||||
|
int lib_vrf_zebra_netns_table_range_end_modify(struct nb_cb_modify_args *args)
|
||||||
|
{
|
||||||
|
struct vrf *vrf;
|
||||||
|
uint32_t start, end;
|
||||||
|
|
||||||
|
start = yang_dnode_get_uint32(args->dnode, "../start");
|
||||||
|
end = yang_dnode_get_uint32(args->dnode, NULL);
|
||||||
|
|
||||||
|
if (args->event == NB_EV_VALIDATE)
|
||||||
|
return table_range_validate(start, end, args->errmsg,
|
||||||
|
args->errmsg_len);
|
||||||
|
|
||||||
|
if (args->event != NB_EV_APPLY)
|
||||||
|
return NB_OK;
|
||||||
|
|
||||||
|
vrf = nb_running_get_entry(args->dnode, NULL, true);
|
||||||
|
|
||||||
|
table_manager_range(true, vrf->info, start, end);
|
||||||
|
|
||||||
|
return NB_OK;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* XPath: /frr-vrf:lib/vrf/frr-zebra:zebra/l3vni-id
|
* XPath: /frr-vrf:lib/vrf/frr-zebra:zebra/l3vni-id
|
||||||
*/
|
*/
|
||||||
|
@ -4394,29 +4394,33 @@ DEFPY (no_zebra_protodown_bit,
|
|||||||
|
|
||||||
#endif /* HAVE_NETLINK */
|
#endif /* HAVE_NETLINK */
|
||||||
|
|
||||||
DEFUN(ip_table_range, ip_table_range_cmd,
|
DEFPY_YANG (ip_table_range, ip_table_range_cmd,
|
||||||
"[no] ip table range (1-4294967295) (1-4294967295)",
|
"[no] ip table range ![(1-4294967295)$start (1-4294967295)$end]",
|
||||||
NO_STR IP_STR
|
NO_STR IP_STR
|
||||||
"table configuration\n"
|
"table configuration\n"
|
||||||
"Configure table range\n"
|
"Configure table range\n"
|
||||||
"Start Routing Table\n"
|
"Start Routing Table\n"
|
||||||
"End Routing Table\n")
|
"End Routing Table\n")
|
||||||
{
|
{
|
||||||
ZEBRA_DECLVAR_CONTEXT_VRF(vrf, zvrf);
|
if (!no) {
|
||||||
|
nb_cli_enqueue_change(vty, "./frr-zebra:zebra/netns/table-range",
|
||||||
if (!zvrf)
|
NB_OP_CREATE, NULL);
|
||||||
return CMD_WARNING;
|
nb_cli_enqueue_change(vty,
|
||||||
|
"./frr-zebra:zebra/netns/table-range/start",
|
||||||
if (zvrf_id(zvrf) != VRF_DEFAULT && !vrf_is_backend_netns()) {
|
NB_OP_MODIFY, start_str);
|
||||||
vty_out(vty,
|
nb_cli_enqueue_change(vty,
|
||||||
"VRF subcommand does not make any sense in l3mdev based vrf's\n");
|
"./frr-zebra:zebra/netns/table-range/end",
|
||||||
return CMD_WARNING;
|
NB_OP_MODIFY, end_str);
|
||||||
|
} else {
|
||||||
|
nb_cli_enqueue_change(vty, "./frr-zebra:zebra/netns/table-range",
|
||||||
|
NB_OP_DESTROY, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (strmatch(argv[0]->text, "no"))
|
if (vty->node == CONFIG_NODE)
|
||||||
return table_manager_range(vty, false, zvrf, NULL, NULL);
|
return nb_cli_apply_changes(vty, "/frr-vrf:lib/vrf[name='%s']",
|
||||||
|
VRF_DEFAULT_NAME);
|
||||||
|
|
||||||
return table_manager_range(vty, true, zvrf, argv[3]->arg, argv[4]->arg);
|
return nb_cli_apply_changes(vty, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef HAVE_SCRIPTING
|
#ifdef HAVE_SCRIPTING
|
||||||
|
Loading…
Reference in New Issue
Block a user