Skip to content

Commit

Permalink
fix ci test, added ipv6 sr lsp fillibg
Browse files Browse the repository at this point in the history
added command "route_leanking ipv4/ipv6 level's route-map name" in cli
according to RFC5302

Signed-off-by: squirrelking57 <[email protected]>
  • Loading branch information
Sashhkaa committed Mar 26, 2024
1 parent 93d4ff0 commit 3f3e9ce
Show file tree
Hide file tree
Showing 9 changed files with 152 additions and 141 deletions.
101 changes: 49 additions & 52 deletions isisd/isis_cli.c
Original file line number Diff line number Diff line change
Expand Up @@ -1426,13 +1426,13 @@ DEFPY_YANG(isis_redistribute, isis_redistribute_cmd,
}

return nb_cli_apply_changes(vty,
"./redistribute/%s[protocol='%s'][level='%s']",
"./redistribute/%s[protocol='%s'][level='%s']",
ip, proto, level);
}

/*
* XPath: /frr-isisd:isis/instance/route_leanking
*/
*/
DEFPY_YANG(isis_leanking, isis_leanking_cmd,
"[no] route_leanking <ipv4|ipv6>$ip"
"<level2_to_level1|level1_to_level2>$level"
Expand All @@ -1447,6 +1447,7 @@ DEFPY_YANG(isis_leanking, isis_leanking_cmd,
"Pointer to route-map entries\n")
{
char proto[] = "isis";

if (no)
nb_cli_enqueue_change(vty, ".", NB_OP_DESTROY, NULL);
else {
Expand All @@ -1459,8 +1460,8 @@ DEFPY_YANG(isis_leanking, isis_leanking_cmd,
}

return nb_cli_apply_changes(vty,
"./route_leanking/%s[protocol='%s'][level='%s']",
ip, proto, level);
"./route_leanking/%s[protocol='%s'][level='%s']",
ip, proto, level);
}

/*
Expand Down Expand Up @@ -1560,36 +1561,36 @@ static void vty_print_redistribute(struct vty *vty, const struct lyd_node *dnode
}

static void vty_print_route_leanking(struct vty *vty,
const struct lyd_node *dnode,
bool show_defaults, const char *family,
bool table)
{
const char *level;
const char *protocol = NULL;
const char *routemap = NULL;
uint16_t tableid;

if (table) {
level = yang_dnode_get_string(dnode, "../level");
tableid = yang_dnode_get_uint16(dnode, "./table");
vty_out(vty, " route_leanking %s table %d ", family, tableid);
} else {
protocol = yang_dnode_get_string(dnode, "./protocol");
if (!table && strmatch(protocol, "table"))
return;
level = yang_dnode_get_string(dnode, "./level");
vty_out(vty, " route_leanking %s %s ", family, protocol);
}
vty_out(vty, "%s", level);
if (show_defaults || !yang_dnode_is_default(dnode, "./metric"))
vty_out(vty, " metric %s",
yang_dnode_get_string(dnode, "%s", "./metric"));

if (yang_dnode_exists(dnode, "./route-map"))
routemap = yang_dnode_get_string(dnode, "./route-map");
if (routemap)
vty_out(vty, " route-map %s", routemap);
vty_out(vty, "\n");
const struct lyd_node *dnode,
bool show_defaults, const char *family,
bool table)
{
const char *level;
const char *protocol = NULL;
const char *routemap = NULL;
uint16_t tableid;

if (table) {
level = yang_dnode_get_string(dnode, "../level");
tableid = yang_dnode_get_uint16(dnode, "./table");
vty_out(vty, " route_leanking %s table %d ", family, tableid);
} else {
protocol = yang_dnode_get_string(dnode, "./protocol");
if (!table && strmatch(protocol, "table"))
return;
level = yang_dnode_get_string(dnode, "./level");
vty_out(vty, " route_leanking %s %s ", family, protocol);
}
vty_out(vty, "%s", level);
if (show_defaults || !yang_dnode_is_default(dnode, "./metric"))
vty_out(vty, " metric %s",
yang_dnode_get_string(dnode, "%s", "./metric"));

if (yang_dnode_exists(dnode, "./route-map"))
routemap = yang_dnode_get_string(dnode, "./route-map");
if (routemap)
vty_out(vty, " route-map %s", routemap);
vty_out(vty, "\n");
}

void cli_show_isis_leanking_ipv4(struct vty *vty, const struct lyd_node *dnode,
Expand Down Expand Up @@ -1874,8 +1875,8 @@ void cli_show_isis_label_blocks(struct vty *vty, const struct lyd_node *dnode,
vty_out(vty, " segment-routing global-block %s %s",
yang_dnode_get_string(dnode, "./srgb/lower-bound"),
yang_dnode_get_string(dnode, "./srgb/upper-bound"));
if (!yang_dnode_is_default(dnode, "./srlb/lower-bound")
|| !yang_dnode_is_default(dnode, "./srlb/upper-bound"))
if (!yang_dnode_is_default(dnode, "./srlb/lower-bound") ||
!yang_dnode_is_default(dnode, "./srlb/upper-bound"))
vty_out(vty, " local-block %s %s",
yang_dnode_get_string(dnode, "./srlb/lower-bound"),
yang_dnode_get_string(dnode, "./srlb/upper-bound"));
Expand Down Expand Up @@ -3405,28 +3406,24 @@ DEFPY(isis_lfa_exclude_interface, isis_lfa_exclude_interface_cmd,
{
if (!level || strmatch(level, "level-1")) {
if (no) {
nb_cli_enqueue_change(
vty,
"./frr-isisd:isis/fast-reroute/level-1/lfa/exclude-interface",
NB_OP_DESTROY, ifname);
nb_cli_enqueue_change(vty,
"./frr-isisd:isis/fast-reroute/level-1/lfa/exclude-interface",
NB_OP_DESTROY, ifname);
} else {
nb_cli_enqueue_change(
vty,
"./frr-isisd:isis/fast-reroute/level-1/lfa/exclude-interface",
NB_OP_CREATE, ifname);
nb_cli_enqueue_change(vty,
"./frr-isisd:isis/fast-reroute/level-1/lfa/exclude-interface",
NB_OP_CREATE, ifname);
}
}
if (!level || strmatch(level, "level-2")) {
if (no) {
nb_cli_enqueue_change(
vty,
"./frr-isisd:isis/fast-reroute/level-2/lfa/exclude-interface",
NB_OP_DESTROY, ifname);
nb_cli_enqueue_change(vty,
"./frr-isisd:isis/fast-reroute/level-2/lfa/exclude-interface",
NB_OP_DESTROY, ifname);
} else {
nb_cli_enqueue_change(
vty,
"./frr-isisd:isis/fast-reroute/level-2/lfa/exclude-interface",
NB_OP_CREATE, ifname);
nb_cli_enqueue_change(vty,
"./frr-isisd:isis/fast-reroute/level-2/lfa/exclude-interface",
NB_OP_CREATE, ifname);
}
}

Expand Down
9 changes: 4 additions & 5 deletions isisd/isis_constants.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,10 @@
/*
* implementation specific route-leanking values
*/

#define LEVEL2_TO_LEVEL1 4
#define LEVEL1_TO_LEVEL2 5
#define LVL_ISIS_LEANKING_1 0
#define LVL_ISIS_LEANKING_2 1
#define LEVEL2_TO_LEVEL1 4
#define LEVEL1_TO_LEVEL2 5
#define LVL_ISIS_LEANKING_1 0
#define LVL_ISIS_LEANKING_2 1
/*
* Default values
* ISO - 10589 Section 7.3.21 - Parameters
Expand Down
17 changes: 15 additions & 2 deletions isisd/isis_lsp.c
Original file line number Diff line number Diff line change
Expand Up @@ -1034,7 +1034,7 @@ static void lsp_build_ext_reach_ipv6(struct isis_lsp *lsp,
}

static void lsp_build_leanking_reach(struct isis_lsp *lsp,
struct isis_area *area)
struct isis_area *area)
{
struct listnode *node;
struct prefix_leanking *leanking;
Expand Down Expand Up @@ -1079,6 +1079,18 @@ static void lsp_build_leanking_reach(struct isis_lsp *lsp,
NULL
};

if (area->srdb.enabled)
for (int i = 0; i < SR_ALGORITHM_COUNT; i++) {
#ifndef FABRICD
if (flex_algo_id_valid(i) &&
!isis_flex_algo_elected_supported(
i, area))
continue;
#endif /* ifndef FABRICD */
pcfgs[i] = isis_sr_cfg_prefix_find(
area, ipv6, i);
}

isis_tlvs_add_ipv6_reach(lsp->tlvs,
isis_area_ipv6_topology(area),
ipv6, leanking->metric, true,
Expand Down Expand Up @@ -1491,9 +1503,10 @@ static void lsp_build(struct isis_lsp *lsp, struct isis_area *area)
zlog_warn("lsp_area_create: unknown circuit type");
}
}

struct listnode *node_redist;
struct isis_leanking *redist;

for (ALL_LIST_ELEMENTS_RO(area->leanking_settings, node_redist, redist))
iteration_in_spftree(area, redist);

Expand Down
104 changes: 52 additions & 52 deletions isisd/isis_nb.c
Original file line number Diff line number Diff line change
Expand Up @@ -409,50 +409,50 @@ const struct frr_yang_module_info frr_isisd_info = {
},
},
{
.xpath = "/frr-isisd:isis/instance/route_leanking/ipv4",
.cbs = {
.apply_finish = leanking_ipv4_apply_finish,
.cli_show = cli_show_isis_leanking_ipv4,
.create = isis_instance_leanking_ipv4_create,
.destroy = isis_instance_leanking_ipv4_destroy,
},
},
{
.xpath = "/frr-isisd:isis/instance/route_leanking/ipv4/route-map",
.cbs = {
.destroy = isis_instance_route_leanking_ipv4_route_map_destroy,
.modify = isis_instance_route_leanking_ipv4_route_map_modify,
},
},
{
.xpath = "/frr-isisd:isis/instance/route_leanking/ipv4/metric",
.cbs = {
.destroy = isis_instance_route_leanking_ipv4_metric_destroy,
.modify = isis_instance_route_leanking_ipv4_metric_modify,
},
},
{
.xpath = "/frr-isisd:isis/instance/route_leanking/ipv4/table",
.cbs = {
.cli_show = cli_show_isis_route_leanking_ipv4_table,
.cli_cmp = cli_cmp_isis_route_leanking_table,
.create = isis_instance_route_leanking_ipv4_table_create,
.destroy = isis_instance_route_leanking_ipv4_table_destroy,
},
},
{
.xpath = "/frr-isisd:isis/instance/route_leanking/ipv4/table/route-map",
.cbs = {
.destroy = isis_instance_route_leanking_ipv4_route_map_destroy,
.modify = isis_instance_route_leanking_ipv4_route_map_modify,
},
},
{
.xpath = "/frr-isisd:isis/instance/route_leanking/ipv4/table/metric",
.cbs = {
.modify = isis_instance_route_leanking_ipv4_metric_modify,
},
},
.xpath = "/frr-isisd:isis/instance/route_leanking/ipv4",
.cbs = {
.apply_finish = leanking_ipv4_apply_finish,
.cli_show = cli_show_isis_leanking_ipv4,
.create = isis_instance_leanking_ipv4_create,
.destroy = isis_instance_leanking_ipv4_destroy,
},
},
{
.xpath = "/frr-isisd:isis/instance/route_leanking/ipv4/route-map",
.cbs = {
.destroy = isis_instance_route_leanking_ipv4_route_map_destroy,
.modify = isis_instance_route_leanking_ipv4_route_map_modify,
},
},
{
.xpath = "/frr-isisd:isis/instance/route_leanking/ipv4/metric",
.cbs = {
.destroy = isis_instance_route_leanking_ipv4_metric_destroy,
.modify = isis_instance_route_leanking_ipv4_metric_modify,
},
},
{
.xpath = "/frr-isisd:isis/instance/route_leanking/ipv4/table",
.cbs = {
.cli_show = cli_show_isis_route_leanking_ipv4_table,
.cli_cmp = cli_cmp_isis_route_leanking_table,
.create = isis_instance_route_leanking_ipv4_table_create,
.destroy = isis_instance_route_leanking_ipv4_table_destroy,
},
},
{
.xpath = "/frr-isisd:isis/instance/route_leanking/ipv4/table/route-map",
.cbs = {
.destroy = isis_instance_route_leanking_ipv4_route_map_destroy,
.modify = isis_instance_route_leanking_ipv4_route_map_modify,
},
},
{
.xpath = "/frr-isisd:isis/instance/route_leanking/ipv4/table/metric",
.cbs = {
.modify = isis_instance_route_leanking_ipv4_metric_modify,
},
},
{
.xpath = "/frr-isisd:isis/instance/route_leanking/ipv6",
.cbs = {
Expand Down Expand Up @@ -499,14 +499,14 @@ const struct frr_yang_module_info frr_isisd_info = {
},
},
{
.xpath = "/frr-isisd:isis/instance/redistribute/ipv6",
.cbs = {
.apply_finish = redistribute_ipv6_apply_finish,
.cli_show = cli_show_isis_redistribute_ipv6,
.create = isis_instance_redistribute_ipv6_create,
.destroy = isis_instance_redistribute_ipv6_destroy,
},
},
.xpath = "/frr-isisd:isis/instance/redistribute/ipv6",
.cbs = {
.apply_finish = redistribute_ipv6_apply_finish,
.cli_show = cli_show_isis_redistribute_ipv6,
.create = isis_instance_redistribute_ipv6_create,
.destroy = isis_instance_redistribute_ipv6_destroy,
},
},
{
.xpath = "/frr-isisd:isis/instance/redistribute/ipv6/route-map",
.cbs = {
Expand Down
Loading

0 comments on commit 3f3e9ce

Please sign in to comment.