Skip to content

Commit

Permalink
pathd: filter out the segment lists generated by PCEP in show config
Browse files Browse the repository at this point in the history
  • Loading branch information
sylane committed Apr 24, 2020
1 parent bccfba6 commit 3f72fde
Show file tree
Hide file tree
Showing 7 changed files with 74 additions and 17 deletions.
10 changes: 10 additions & 0 deletions pathd/path_cli.c
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,11 @@ DEFPY(no_te_path_segment_list, no_te_path_segment_list_cmd,
void cli_show_te_path_segment_list(struct vty *vty, struct lyd_node *dnode,
bool show_defaults)
{
enum srte_protocol_origin origin;
origin = yang_dnode_get_enum(dnode, "./protocol-origin");
if (origin != SRTE_ORIGIN_LOCAL)
return;

vty_out(vty, "segment-list %s\n",
yang_dnode_get_string(dnode, "./name"));
}
Expand Down Expand Up @@ -255,6 +260,11 @@ void cli_show_te_path_segment_list_segment(struct vty *vty,
struct lyd_node *dnode,
bool show_defaults)
{
enum srte_protocol_origin origin;
origin = yang_dnode_get_enum(dnode, "../protocol-origin");
if (origin != SRTE_ORIGIN_LOCAL)
return;

vty_out(vty, " index %s mpls label %s",
yang_dnode_get_string(dnode, "./index"),
yang_dnode_get_string(dnode, "./sid-value"));
Expand Down
7 changes: 7 additions & 0 deletions pathd/path_nb.c
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,13 @@ const struct frr_yang_module_info frr_pathd_info = {
},
.priority = NB_DFLT_PRIORITY - 1
},
{
.xpath = "/frr-pathd:pathd/segment-list/protocol-origin",
.cbs = {
.modify = pathd_te_segment_list_protocol_origin_modify,
},
.priority = NB_DFLT_PRIORITY - 1
},
{
.xpath = "/frr-pathd:pathd/segment-list/segment",
.cbs = {
Expand Down
3 changes: 3 additions & 0 deletions pathd/path_nb.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@ int pathd_te_segment_list_segment_create(enum nb_event event,
union nb_resource *resource);
int pathd_te_segment_list_segment_destroy(enum nb_event event,
const struct lyd_node *dnode);
int pathd_te_segment_list_protocol_origin_modify(enum nb_event event,
const struct lyd_node *dnode,
union nb_resource *resource);
int pathd_te_segment_list_segment_sid_value_modify(enum nb_event event,
const struct lyd_node *dnode,
union nb_resource *resource);
Expand Down
19 changes: 19 additions & 0 deletions pathd/path_nb_config.c
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,25 @@ int pathd_te_segment_list_destroy(enum nb_event event,
return NB_OK;
}

/*
* XPath: /frr-pathd:pathd/segment-list/protocol-origin
*/
int pathd_te_segment_list_protocol_origin_modify(enum nb_event event,
const struct lyd_node *dnode,
union nb_resource *resource)
{
struct srte_segment_list *segment_list;

if (event != NB_EV_APPLY)
return NB_OK;

segment_list = nb_running_get_entry(dnode, NULL, true);
segment_list->protocol_origin = yang_dnode_get_enum(dnode, NULL);
SET_FLAG(segment_list->flags, F_SEGMENT_LIST_MODIFIED);

return NB_OK;
}

/*
* XPath: /frr-pathd:pathd/segment-list/segment
*/
Expand Down
7 changes: 5 additions & 2 deletions pathd/path_pcep_nb.c
Original file line number Diff line number Diff line change
Expand Up @@ -538,11 +538,14 @@ void path_nb_add_segment_list_segment_nai_ipv4_unnumbered_adj(
void path_nb_create_segment_list(struct nb_config *config,
const char *segment_list_name)
{
char xpath_base[XPATH_MAXLEN];
char xpath[XPATH_MAXLEN];

snprintf(xpath, sizeof(xpath),
snprintf(xpath_base, sizeof(xpath_base),
"/frr-pathd:pathd/segment-list[name='%s']", segment_list_name);
path_nb_edit_candidate_config(config, xpath, NB_OP_CREATE, NULL);
path_nb_edit_candidate_config(config, xpath_base, NB_OP_CREATE, NULL);
snprintf(xpath, sizeof(xpath), "%s/protocol-origin", xpath_base);
path_nb_edit_candidate_config(config, xpath, NB_OP_MODIFY, "pcep");
}

void path_nb_add_candidate_path(struct nb_config *config, uint32_t color,
Expand Down
3 changes: 3 additions & 0 deletions pathd/pathd.h
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,9 @@ struct srte_segment_list {
/* Name of the Segment List. */
char name[64];

/* The Protocol-Origin. */
enum srte_protocol_origin protocol_origin;

/* Nexthops. */
struct srte_segment_entry_head segments;

Expand Down
42 changes: 27 additions & 15 deletions yang/frr-pathd.yang
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,25 @@ module frr-pathd {
"Initial revision.";
}

typedef protocol {
description
"Indication for the protocol origin of an object.";
type enumeration {
enum pcep {
value 1;
description "The object was created through PCEP";
}
enum bgp {
value 2;
description "The object was created through GBP";
}
enum local {
value 3;
description "The object was created through CLI, Yang model via Netconf, gRPC, etc";
}
}
}

container pathd {
list segment-list {
key "name";
Expand All @@ -39,6 +58,12 @@ module frr-pathd {
}
description "Segment-list name";
}
leaf protocol-origin {
type protocol;
default "local";
description
"Indication for the protocol origin of the segment list.";
}
list segment {
key "index";
description "Configure Segment/hop at the index";
Expand Down Expand Up @@ -157,23 +182,10 @@ module frr-pathd {
"True if the candidate path is the best candidate path, False otherwise";
}
leaf protocol-origin {
type protocol;
mandatory true;
description
"Indication for the protocol origin of the Candidate Path.";
mandatory true;
type enumeration {
enum pcep {
value 1;
description "PCEP used as signalling mechanism for the candidate path";
}
enum bgp {
value 2;
description "BGP used as signalling mechanism for the candidate path";
}
enum local {
value 3;
description "CLI, Yang model via Netconf, gRPC, etc used for candidate path instantiation";
}
}
}
leaf originator {
type inet:ip-address;
Expand Down

0 comments on commit 3f72fde

Please sign in to comment.