Skip to content

Commit

Permalink
path: pcep module: change the synchronization workflow.
Browse files Browse the repository at this point in the history
  • Loading branch information
sylane committed Jun 25, 2020
1 parent 678424d commit 8a4487c
Show file tree
Hide file tree
Showing 11 changed files with 348 additions and 119 deletions.
6 changes: 6 additions & 0 deletions pathd/path_errors.c
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,12 @@ static struct log_ref ferr_path_warn[] = {
.description = "Some recoverable internal error",
.suggestion = "Open an Issue with all relevant log files"
},
{
.code = EC_PATH_PCEP_UNSUPPORTED_PCEP_FEATURE,
.title = "Unsupported PCEP feature",
.description = "Receved an unsupported PCEP message",
.suggestion = "The PCC and PCE are probably not compatible. Open an Issue with all relevant log files"
},
{
.code = EC_PATH_PCEP_UNEXPECTED_PCEP_MESSAGE,
.title = "Unexpected pcep message",
Expand Down
1 change: 1 addition & 0 deletions pathd/path_errors.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ enum path_log_refs {
EC_PATH_PCEP_LIB_CONNECT,
EC_PATH_PCEP_MISSING_SOURCE_ADDRESS,
EC_PATH_PCEP_RECOVERABLE_INTERNAL_ERROR,
EC_PATH_PCEP_UNSUPPORTED_PCEP_FEATURE,
EC_PATH_PCEP_UNEXPECTED_PCEP_MESSAGE,
EC_PATH_PCEP_UNEXPECTED_PCEPLIB_EVENT,
EC_PATH_PCEP_UNEXPECTED_PCEP_OBJECT,
Expand Down
38 changes: 36 additions & 2 deletions pathd/path_pcep.c
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,10 @@ static int pathd_candidate_created_handler(struct srte_candidate *candidate);
static int pathd_candidate_updated_handler(struct srte_candidate *candidate);
static int pathd_candidate_removed_handler(struct srte_candidate *candidate);

/* Path manipulation functions */
static struct path_metric *pcep_copy_metrics(struct path_metric *metric);
static struct path_hop *pcep_copy_hops(struct path_hop *hop);

/* CLI Functions */
static int pcep_cli_debug_config_write(struct vty *vty);
static int pcep_cli_debug_set_all(uint32_t flags, bool set);
Expand Down Expand Up @@ -101,6 +105,38 @@ struct path_metric *pcep_new_metric(void)
return metric;
}

struct path_metric *pcep_copy_metrics(struct path_metric *metric)
{
if (metric == NULL) return NULL;
struct path_metric *new_metric = pcep_new_metric();
*new_metric = *metric;
new_metric->next = pcep_copy_metrics(metric->next);
return new_metric;
}

struct path_hop *pcep_copy_hops(struct path_hop *hop)
{
if (hop == NULL) return NULL;
struct path_hop *new_hop = pcep_new_hop();
*new_hop = *hop;
new_hop->next = pcep_copy_hops(hop->next);
return new_hop;
}

struct path *pcep_copy_path(struct path *path)
{
struct path *new_path = pcep_new_path();

*new_path = *path;
new_path->first_metric = pcep_copy_metrics(path->first_metric);
new_path->first_hop = pcep_copy_hops(path->first_hop);
if (path->name != NULL)
new_path->name = XSTRDUP(MTYPE_PCEP, path->name);
if (path->originator != NULL)
new_path->originator = XSTRDUP(MTYPE_PCEP, path->originator);
return new_path;
}

void pcep_free_path(struct path *path)
{
struct path_hop *hop;
Expand Down Expand Up @@ -174,8 +210,6 @@ int pcep_main_event_start_sync(int pcc_id)
int pcep_main_event_start_sync_cb(struct path *path, void *arg)
{
int *pcc_id = (int *)arg;
path->is_synching = true;
path->go_active = true;
pcep_ctrl_sync_path(pcep_g->fpt, *pcc_id, path);
return 1;
}
Expand Down
7 changes: 7 additions & 0 deletions pathd/path_pcep.h
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,11 @@ struct path {
/* Indicate the given path was created by the PCE,
See draft-ietf-pce-pce-initiated-lsp, section-5.3.1, flag C */
bool was_created;

/* The following data is defined for comnputation replies */

/* Indicate that no path could be computed */
bool no_path;
};

struct pcep_glob {
Expand All @@ -254,6 +259,8 @@ extern struct pcep_glob *pcep_g;
struct path *pcep_new_path(void);
struct path_hop *pcep_new_hop(void);
struct path_metric *pcep_new_metric(void);
struct path *pcep_copy_path(struct path *path);
void pcep_free_path(struct path *path);


#endif // _PATH_PCEP_H_
32 changes: 31 additions & 1 deletion pathd/path_pcep_debug.c
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ _format_pcep_object_ipv4_endpoint(int ps,
struct pcep_object_endpoints_ipv4 *obj);
static void _format_pcep_object_metric(int ps, struct pcep_object_metric *obj);
static void _format_pcep_object_bandwidth(int ps, struct pcep_object_bandwidth *obj);
static void _format_pcep_object_nopath(int ps, struct pcep_object_nopath *obj);
static void _format_pcep_object_ro(int ps, struct pcep_object_ro *obj);
static void _format_pcep_object_ro_details(int ps,
struct pcep_object_ro_subobj *ro);
Expand Down Expand Up @@ -594,6 +595,22 @@ const char *pcep_metric_type_name(enum pcep_metric_types type)
}
}

const char *pcep_nopath_tlv_err_code_name(enum pcep_nopath_tlv_err_codes type)
{
switch (type) {
case PCEP_NOPATH_TLV_ERR_NO_TLV:
return "NO_TLV";
case PCEP_NOPATH_TLV_ERR_PCE_UNAVAILABLE:
return "PCE_UNAVAILABLE";
case PCEP_NOPATH_TLV_ERR_UNKNOWN_DST:
return "UNKNOWN_DST";
case PCEP_NOPATH_TLV_ERR_UNKNOWN_SRC:
return "UNKNOWN_SRC";
default:
return "UNKNOWN";
}
}

const char *format_pcc_opts(struct pcc_opts *opts)
{
PCEP_FORMAT_INIT();
Expand Down Expand Up @@ -831,7 +848,7 @@ void _format_path(int ps, struct path *path)
path->has_bandwidth);
if (path->has_bandwidth) {
PCEP_FORMAT("%*sbandwidth: %f\n", ps2, "",
path->bandwidth);
path->bandwidth);
}

if (path->first_hop == NULL) {
Expand Down Expand Up @@ -1045,6 +1062,10 @@ void _format_pcep_object_details(int ps, struct pcep_object_header *obj)
_format_pcep_object_bandwidth(ps,
(struct pcep_object_bandwidth *)obj);
break;
case TUP(PCEP_OBJ_CLASS_NOPATH, PCEP_OBJ_TYPE_NOPATH):
_format_pcep_object_nopath(ps,
(struct pcep_object_nopath *)obj);
break;
default:
PCEP_FORMAT("%*s...\n", ps, "");
break;
Expand Down Expand Up @@ -1120,6 +1141,15 @@ void _format_pcep_object_bandwidth(int ps, struct pcep_object_bandwidth *obj)
PCEP_FORMAT("%*sbandwidth: %f\n", ps, "", obj->bandwidth);
}

void _format_pcep_object_nopath(int ps, struct pcep_object_nopath *obj)
{
PCEP_FORMAT("%*sni: %u\n", ps, "", obj->ni);
PCEP_FORMAT("%*sflag_c: %u\n", ps, "", obj->flag_c);
PCEP_FORMAT("%*serr_code: %s (%u)\n", ps, "",
pcep_nopath_tlv_err_code_name(obj->err_code),
obj->err_code);
}

void _format_pcep_object_ro(int ps, struct pcep_object_ro *obj)
{
double_linked_list *obj_list = obj->sub_objects;
Expand Down
1 change: 1 addition & 0 deletions pathd/path_pcep_debug.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ const char *pcep_tlv_type_name(enum pcep_object_tlv_types tlv_type);
const char *pcep_ro_type_name(enum pcep_ro_subobj_types ro_type);
const char *pcep_nai_type_name(enum pcep_sr_subobj_nai nai_type);
const char *pcep_metric_type_name(enum pcep_metric_types type);
const char *pcep_nopath_tlv_err_code_name(enum pcep_nopath_tlv_err_codes code);

const char *format_pcc_opts(struct pcc_opts *ops);
const char *format_pcc_state(struct pcc_state *state);
Expand Down
12 changes: 11 additions & 1 deletion pathd/path_pcep_lib.c
Original file line number Diff line number Diff line change
Expand Up @@ -340,18 +340,21 @@ struct pcep_message *pcep_lib_format_request(uint32_t reqid, struct ipaddr *src,
dll_append(rp_tlvs, setup_type_tlv);

rp = pcep_obj_create_rp(0, false, false, false, reqid, rp_tlvs);
rp->header.flag_p = true;
if (IS_IPADDR_V6(src)) {
endpoints_ipv6 = pcep_obj_create_endpoint_ipv6(&src->ipaddr_v6,
&dst->ipaddr_v6);
endpoints_ipv6->header.flag_p = true;
return pcep_msg_create_request_ipv6(rp, endpoints_ipv6, NULL);
} else {
endpoints_ipv4 = pcep_obj_create_endpoint_ipv4(&src->ipaddr_v4,
&dst->ipaddr_v4);
endpoints_ipv4->header.flag_p = true;
return pcep_msg_create_request(rp, endpoints_ipv4, NULL);
}
}

struct pcep_message *pcep_lib_reject_message(int error_type, int error_value)
struct pcep_message *pcep_lib_format_error(int error_type, int error_value)
{
return pcep_msg_create_error(error_type, error_value);
}
Expand Down Expand Up @@ -409,6 +412,10 @@ struct path *pcep_lib_parse_path(struct pcep_message *msg)
path->has_bandwidth = true;
path->bandwidth = bandwidth->bandwidth;
break;
case CLASS_TYPE(PCEP_OBJ_CLASS_NOPATH,
PCEP_OBJ_TYPE_NOPATH):
path->no_path = true;
break;
default:
flog_warn(EC_PATH_PCEP_UNEXPECTED_PCEP_OBJECT,
"Unexpected PCEP object %s (%u) / %s (%u)",
Expand Down Expand Up @@ -508,6 +515,7 @@ double_linked_list *pcep_lib_format_path(struct path *path)
dll_append(srp_tlvs, tlv);
srp = pcep_obj_create_srp(path->do_remove, path->srp_id, srp_tlvs);
assert(srp != NULL);
srp->header.flag_p = true;
dll_append(objs, srp);
}

Expand Down Expand Up @@ -564,6 +572,7 @@ double_linked_list *pcep_lib_format_path(struct path *path)
path->is_synching /* S Flag */, path->is_delegated /* D Flag */,
lsp_tlvs);
assert(lsp != NULL);
lsp->header.flag_p = true;
dll_append(objs, lsp);
/* ERO object */
ero_objs = dll_initialize();
Expand Down Expand Up @@ -660,6 +669,7 @@ double_linked_list *pcep_lib_format_path(struct path *path)
}
ero = pcep_obj_create_ero(ero_objs);
assert(ero != NULL);
ero->header.flag_p = true;
dll_append(objs, ero);

if (path->plsp_id == 0) {
Expand Down
2 changes: 1 addition & 1 deletion pathd/path_pcep_lib.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ void pcep_lib_disconnect(pcep_session *sess);
struct pcep_message *pcep_lib_format_report(struct path *path);
struct pcep_message *pcep_lib_format_request(uint32_t reqid, struct ipaddr *src,
struct ipaddr *dst);
struct pcep_message *pcep_lib_reject_message(int error_type, int error_value);
struct pcep_message *pcep_lib_format_error(int error_type, int error_value);
struct path *pcep_lib_parse_path(struct pcep_message *msg);
void pcep_lib_parse_capabilities(struct pcep_message *msg,
struct pcep_caps *caps);
Expand Down
3 changes: 2 additions & 1 deletion pathd/path_pcep_nb.c
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,7 @@ struct path *candidate_to_path(struct srte_candidate *candidate)
segment_list = RB_FIND(srte_segment_list_head,
&srte_segment_lists, &key);
assert(segment_list != NULL);
assert(segment_list == candidate->segment_list);
hop = path_nb_list_path_hops(segment_list);
update_origin = segment_list->protocol_origin;
originator = XSTRDUP(MTYPE_PCEP, segment_list->originator);
Expand Down Expand Up @@ -242,7 +243,7 @@ struct path_hop *path_nb_list_path_hops(struct srte_segment_list *segment_list)
hop = pcep_new_hop();
*hop = (struct path_hop){
.next = last_hop,
.is_loose = false,
.is_loose = true,
.has_sid = true,
.is_mpls = true,
.has_attribs = false,
Expand Down
Loading

0 comments on commit 8a4487c

Please sign in to comment.