Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pathd pcep pcc initiated refactor #23

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 0 additions & 8 deletions bgpd/bgp_routemap.c
Original file line number Diff line number Diff line change
Expand Up @@ -1670,23 +1670,15 @@ route_set_srte_color(void *rule, const struct prefix *prefix,
{
uint32_t *srte_color = rule;
struct bgp_path_info *path;
struct peer *peer;

if (type != RMAP_BGP)
return RMAP_OKAY;

path = object;
peer = path->peer;

path->attr->srte_color = *srte_color;
path->attr->flag |= ATTR_FLAG_BIT(BGP_ATTR_SRTE_COLOR);

if ((CHECK_FLAG(peer->rmap_type, PEER_RMAP_TYPE_IN)) && peer->su_remote
&& sockunion_family(peer->su_remote) == AF_INET) {
path->attr->nexthop.s_addr = sockunion2ip(peer->su_remote);
path->attr->flag |= ATTR_FLAG_BIT(BGP_ATTR_NEXT_HOP);
}

return RMAP_OKAY;
}

Expand Down
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 @@ -59,6 +59,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);

/* Module Functions */
static int pcep_module_finish(void);
static int pcep_module_late_init(struct thread_master *tm);
Expand Down Expand Up @@ -88,6 +92,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 @@ -161,8 +197,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 @@ -267,6 +267,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 @@ -287,6 +292,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_
Loading