summaryrefslogtreecommitdiff
path: root/pathd/path_pcep_config.c
diff options
context:
space:
mode:
authorJavier Garcia <javier.garcia@voltanet.io>2021-04-22 16:04:42 +0200
committerJavier Garcia <javier.garcia@voltanet.io>2021-05-10 15:24:59 +0200
commitf2b9485d6f5aa1508334a7e92d26d95faf0e1733 (patch)
tree18d754185d84e48675820d0c4fb658b53e78d1e6 /pathd/path_pcep_config.c
parent75c69d151c8e72e42dfb4b1966428e9cf79cb7f4 (diff)
pathd. TED support . Validation of candidate path - [part 2/4]
- Explicit segment list nai will be resolved to corresponded sid. - Dynamic segment list (from pce) will be validated. - If segment list could not be resolved or validated won't be used. - Now this new config is supported segment-list sl-1 index 10 nai prefix 10.1.2.1/32 iface 1 index 30 nai adjacency 10.2.5.2 10.2.5.5 index 40 nai prefix 10.10.10.5/32 algorithm 0 Signed-off-by: Javier Garcia <javier.garcia@voltanet.io>
Diffstat (limited to 'pathd/path_pcep_config.c')
-rw-r--r--pathd/path_pcep_config.c87
1 files changed, 55 insertions, 32 deletions
diff --git a/pathd/path_pcep_config.c b/pathd/path_pcep_config.c
index aacbca4ae9..609f091559 100644
--- a/pathd/path_pcep_config.c
+++ b/pathd/path_pcep_config.c
@@ -246,6 +246,10 @@ path_pcep_config_list_path_hops(struct srte_segment_list *segment_list)
switch (segment->nai_type) {
case SRTE_SEGMENT_NAI_TYPE_IPV4_NODE:
case SRTE_SEGMENT_NAI_TYPE_IPV6_NODE:
+ case SRTE_SEGMENT_NAI_TYPE_IPV4_LOCAL_IFACE:
+ case SRTE_SEGMENT_NAI_TYPE_IPV6_LOCAL_IFACE:
+ case SRTE_SEGMENT_NAI_TYPE_IPV4_ALGORITHM:
+ case SRTE_SEGMENT_NAI_TYPE_IPV6_ALGORITHM:
memcpy(&hop->nai.local_addr, &segment->nai_local_addr,
sizeof(struct ipaddr));
break;
@@ -278,6 +282,7 @@ int path_pcep_config_update_path(struct path *path)
assert(path->nbkey.preference != 0);
assert(path->nbkey.endpoint.ipa_type == IPADDR_V4);
+ int number_of_sid_clashed = 0;
struct path_hop *hop;
struct path_metric *metric;
int index;
@@ -297,40 +302,44 @@ int path_pcep_config_update_path(struct path *path)
if (candidate->lsp->segment_list) {
SET_FLAG(candidate->lsp->segment_list->flags,
F_SEGMENT_LIST_DELETED);
+ srte_segment_list_del(candidate->lsp->segment_list);
candidate->lsp->segment_list = NULL;
}
- if (path->first_hop != NULL) {
- snprintf(segment_list_name_buff, sizeof(segment_list_name_buff),
- "%s-%u", path->name, path->plsp_id);
- segment_list_name = segment_list_name_buff;
-
- segment_list = srte_segment_list_add(segment_list_name);
- segment_list->protocol_origin = path->update_origin;
- strlcpy(segment_list->originator, path->originator,
- sizeof(segment_list->originator));
- SET_FLAG(segment_list->flags, F_SEGMENT_LIST_NEW);
- SET_FLAG(segment_list->flags, F_SEGMENT_LIST_MODIFIED);
-
- for (hop = path->first_hop, index = 10; hop != NULL;
- hop = hop->next, index += 10) {
- assert(hop->has_sid);
- assert(hop->is_mpls);
-
- segment = srte_segment_entry_add(segment_list, index);
-
- segment->sid_value = (mpls_label_t)hop->sid.mpls.label;
- SET_FLAG(segment->segment_list->flags,
- F_SEGMENT_LIST_MODIFIED);
-
- if (hop->has_nai)
- srte_segment_entry_set_nai(
- segment, srte_nai_type(hop->nai.type),
- &hop->nai.local_addr,
- hop->nai.local_iface,
- &hop->nai.remote_addr,
- hop->nai.remote_iface);
- }
+ if (path->first_hop == NULL)
+ return PATH_NB_ERR;
+
+ snprintf(segment_list_name_buff, sizeof(segment_list_name_buff),
+ "%s-%u", path->name, path->plsp_id);
+ segment_list_name = segment_list_name_buff;
+
+ segment_list = srte_segment_list_add(segment_list_name);
+ segment_list->protocol_origin = path->update_origin;
+ strlcpy(segment_list->originator, path->originator,
+ sizeof(segment_list->originator));
+ SET_FLAG(segment_list->flags, F_SEGMENT_LIST_NEW);
+ SET_FLAG(segment_list->flags, F_SEGMENT_LIST_MODIFIED);
+
+ for (hop = path->first_hop, index = 10; hop != NULL;
+ hop = hop->next, index += 10) {
+ assert(hop->has_sid);
+ assert(hop->is_mpls);
+
+ segment = srte_segment_entry_add(segment_list, index);
+
+ segment->sid_value = (mpls_label_t)hop->sid.mpls.label;
+ SET_FLAG(segment->segment_list->flags, F_SEGMENT_LIST_MODIFIED);
+
+ if (!hop->has_nai)
+ continue;
+ if (srte_segment_entry_set_nai(
+ segment, srte_nai_type(hop->nai.type),
+ &hop->nai.local_addr, hop->nai.local_iface,
+ &hop->nai.remote_addr, hop->nai.remote_iface, 0, 0)
+ == PATH_SID_ERROR)
+ /* TED queries don't match PCE */
+ /* Don't apply srte,zebra changes */
+ number_of_sid_clashed++;
}
candidate->lsp->segment_list = segment_list;
@@ -352,7 +361,11 @@ int path_pcep_config_update_path(struct path *path)
candidate->lsp->objfun = path->pce_objfun;
}
- srte_apply_changes();
+ if (number_of_sid_clashed)
+ SET_FLAG(segment->segment_list->flags,
+ F_SEGMENT_LIST_SID_CONFLICT);
+ else
+ srte_apply_changes();
return 0;
}
@@ -402,6 +415,16 @@ enum pcep_sr_subobj_nai pcep_nai_type(enum srte_segment_nai_type type)
return PCEP_SR_SUBOBJ_NAI_IPV6_ADJACENCY;
case SRTE_SEGMENT_NAI_TYPE_IPV4_UNNUMBERED_ADJACENCY:
return PCEP_SR_SUBOBJ_NAI_UNNUMBERED_IPV4_ADJACENCY;
+ case SRTE_SEGMENT_NAI_TYPE_IPV6_ADJACENCY_LINK_LOCAL_ADDRESSES:
+ return PCEP_SR_SUBOBJ_NAI_LINK_LOCAL_IPV6_ADJACENCY;
+ case SRTE_SEGMENT_NAI_TYPE_IPV4_LOCAL_IFACE:
+ return PCEP_SR_SUBOBJ_NAI_IPV4_NODE;
+ case SRTE_SEGMENT_NAI_TYPE_IPV6_LOCAL_IFACE:
+ return PCEP_SR_SUBOBJ_NAI_IPV6_NODE;
+ case SRTE_SEGMENT_NAI_TYPE_IPV4_ALGORITHM:
+ return PCEP_SR_SUBOBJ_NAI_IPV4_NODE;
+ case SRTE_SEGMENT_NAI_TYPE_IPV6_ALGORITHM:
+ return PCEP_SR_SUBOBJ_NAI_IPV6_NODE;
default:
return PCEP_SR_SUBOBJ_NAI_UNKNOWN;
}