diff options
| author | Philippe Guibert <philippe.guibert@6wind.com> | 2022-07-19 14:59:23 +0200 | 
|---|---|---|
| committer | Philippe Guibert <philippe.guibert@6wind.com> | 2022-11-14 17:42:55 +0100 | 
| commit | c1657d2669cb8be9cd0d0b2e6d1c7080b63422a0 (patch) | |
| tree | 356f6fa906604987521f35a7232c9051fa125d32 /pathd | |
| parent | 116f9b45ede641316ae2f0bf75bc87246b31fdf3 (diff) | |
pathd: use a define to store the the length of endpoint string
The endpoint string is a 46 byte length buffer. Use a single
place to store the length of that buffer.
Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
Diffstat (limited to 'pathd')
| -rw-r--r-- | pathd/path_cli.c | 4 | ||||
| -rw-r--r-- | pathd/pathd.c | 40 | ||||
| -rw-r--r-- | pathd/pathd.h | 2 | 
3 files changed, 30 insertions, 16 deletions
diff --git a/pathd/path_cli.c b/pathd/path_cli.c index 7510f2ad05..b88453c68f 100644 --- a/pathd/path_cli.c +++ b/pathd/path_cli.c @@ -126,7 +126,7 @@ DEFPY(show_srte_policy,  	ttable_rowseps(tt, 0, BOTTOM, true, '-');  	RB_FOREACH (policy, srte_policy_head, &srte_policies) { -		char endpoint[46]; +		char endpoint[ENDPOINT_STR_LENGTH];  		char binding_sid[16] = "-";  		ipaddr2str(&policy->endpoint, endpoint, sizeof(endpoint)); @@ -173,7 +173,7 @@ DEFPY(show_srte_policy_detail,  	vty_out(vty, "\n");  	RB_FOREACH (policy, srte_policy_head, &srte_policies) {  		struct srte_candidate *candidate; -		char endpoint[46]; +		char endpoint[ENDPOINT_STR_LENGTH];  		char binding_sid[16] = "-";  		char *segment_list_info;  		static char undefined_info[] = "(undefined)"; diff --git a/pathd/pathd.c b/pathd/pathd.c index 7e3802c734..5ede1de2ff 100644 --- a/pathd/pathd.c +++ b/pathd/pathd.c @@ -578,7 +578,7 @@ void srte_policy_apply_changes(struct srte_policy *policy)  	struct srte_candidate *candidate, *safe;  	struct srte_candidate *old_best_candidate;  	struct srte_candidate *new_best_candidate; -	char endpoint[46]; +	char endpoint[ENDPOINT_STR_LENGTH];  	ipaddr2str(&policy->endpoint, endpoint, sizeof(endpoint)); @@ -734,7 +734,7 @@ void srte_candidate_set_bandwidth(struct srte_candidate *candidate,  				  float bandwidth, bool required)  {  	struct srte_policy *policy = candidate->policy; -	char endpoint[46]; +	char endpoint[ENDPOINT_STR_LENGTH];  	ipaddr2str(&policy->endpoint, endpoint, sizeof(endpoint));  	PATH_POLICY_DEBUG( @@ -762,7 +762,8 @@ void srte_lsp_set_bandwidth(struct srte_lsp *lsp, float bandwidth,  {  	struct srte_candidate *candidate = lsp->candidate;  	struct srte_policy *policy = candidate->policy; -	char endpoint[46]; +	char endpoint[ENDPOINT_STR_LENGTH]; +  	ipaddr2str(&policy->endpoint, endpoint, sizeof(endpoint));  	PATH_POLICY_DEBUG(  		"SR-TE(%s, %u): candidate %s %slsp bandwidth set to %f B/s", @@ -783,7 +784,8 @@ void srte_lsp_set_bandwidth(struct srte_lsp *lsp, float bandwidth,  void srte_candidate_unset_bandwidth(struct srte_candidate *candidate)  {  	struct srte_policy *policy = candidate->policy; -	char endpoint[46]; +	char endpoint[ENDPOINT_STR_LENGTH]; +  	ipaddr2str(&policy->endpoint, endpoint, sizeof(endpoint));  	PATH_POLICY_DEBUG("SR-TE(%s, %u): candidate %s config bandwidth unset",  			  endpoint, policy->color, candidate->name); @@ -805,7 +807,8 @@ void srte_lsp_unset_bandwidth(struct srte_lsp *lsp)  {  	struct srte_candidate *candidate = lsp->candidate;  	struct srte_policy *policy = candidate->policy; -	char endpoint[46]; +	char endpoint[ENDPOINT_STR_LENGTH]; +  	ipaddr2str(&policy->endpoint, endpoint, sizeof(endpoint));  	PATH_POLICY_DEBUG("SR-TE(%s, %u): candidate %s lsp bandwidth unset",  			  endpoint, policy->color, candidate->name); @@ -833,7 +836,8 @@ void srte_candidate_set_metric(struct srte_candidate *candidate,  			       bool is_computed)  {  	struct srte_policy *policy = candidate->policy; -	char endpoint[46]; +	char endpoint[ENDPOINT_STR_LENGTH]; +  	ipaddr2str(&policy->endpoint, endpoint, sizeof(endpoint));  	PATH_POLICY_DEBUG(  		"SR-TE(%s, %u): candidate %s %sconfig metric %s (%u) set to %f (is-bound: %s; is_computed: %s)", @@ -867,7 +871,8 @@ void srte_lsp_set_metric(struct srte_lsp *lsp,  {  	struct srte_candidate *candidate = lsp->candidate;  	struct srte_policy *policy = candidate->policy; -	char endpoint[46]; +	char endpoint[ENDPOINT_STR_LENGTH]; +  	ipaddr2str(&policy->endpoint, endpoint, sizeof(endpoint));  	PATH_POLICY_DEBUG(  		"SR-TE(%s, %u): candidate %s %slsp metric %s (%u) set to %f (is-bound: %s; is_computed: %s)", @@ -902,7 +907,8 @@ void srte_candidate_unset_metric(struct srte_candidate *candidate,  				 enum srte_candidate_metric_type type)  {  	struct srte_policy *policy = candidate->policy; -	char endpoint[46]; +	char endpoint[ENDPOINT_STR_LENGTH]; +  	ipaddr2str(&policy->endpoint, endpoint, sizeof(endpoint));  	PATH_POLICY_DEBUG(  		"SR-TE(%s, %u): candidate %s config metric %s (%u) unset", @@ -927,7 +933,8 @@ void srte_lsp_unset_metric(struct srte_lsp *lsp,  {  	struct srte_candidate *candidate = lsp->candidate;  	struct srte_policy *policy = candidate->policy; -	char endpoint[46]; +	char endpoint[ENDPOINT_STR_LENGTH]; +  	ipaddr2str(&policy->endpoint, endpoint, sizeof(endpoint));  	PATH_POLICY_DEBUG(  		"SR-TE(%s, %u): candidate %s lsp metric %s (%u) unset", @@ -956,7 +963,8 @@ void srte_candidate_set_objfun(struct srte_candidate *candidate, bool required,  			       enum objfun_type type)  {  	struct srte_policy *policy = candidate->policy; -	char endpoint[46]; +	char endpoint[ENDPOINT_STR_LENGTH]; +  	ipaddr2str(&policy->endpoint, endpoint, sizeof(endpoint));  	candidate->objfun = type; @@ -977,7 +985,8 @@ void srte_candidate_set_objfun(struct srte_candidate *candidate, bool required,  void srte_candidate_unset_objfun(struct srte_candidate *candidate)  {  	struct srte_policy *policy = candidate->policy; -	char endpoint[46]; +	char endpoint[ENDPOINT_STR_LENGTH]; +  	ipaddr2str(&policy->endpoint, endpoint, sizeof(endpoint));  	UNSET_FLAG(candidate->flags, F_CANDIDATE_HAS_OBJFUN); @@ -1029,7 +1038,8 @@ void srte_candidate_set_affinity_filter(struct srte_candidate *candidate,  					uint32_t filter)  {  	struct srte_policy *policy = candidate->policy; -	char endpoint[46]; +	char endpoint[ENDPOINT_STR_LENGTH]; +  	ipaddr2str(&policy->endpoint, endpoint, sizeof(endpoint));  	assert(type > AFFINITY_FILTER_UNDEFINED); @@ -1054,7 +1064,8 @@ void srte_candidate_unset_affinity_filter(struct srte_candidate *candidate,  					  enum affinity_filter_type type)  {  	struct srte_policy *policy = candidate->policy; -	char endpoint[46]; +	char endpoint[ENDPOINT_STR_LENGTH]; +  	ipaddr2str(&policy->endpoint, endpoint, sizeof(endpoint));  	assert(type > AFFINITY_FILTER_UNDEFINED); @@ -1110,7 +1121,8 @@ srte_segment_entry_find(struct srte_segment_list *segment_list, uint32_t index)  void srte_candidate_status_update(struct srte_candidate *candidate, int status)  {  	struct srte_policy *policy = candidate->policy; -	char endpoint[46]; +	char endpoint[ENDPOINT_STR_LENGTH]; +  	ipaddr2str(&policy->endpoint, endpoint, sizeof(endpoint));  	PATH_POLICY_DEBUG("SR-TE(%s, %u): zebra updated status to %d", endpoint,  			  policy->color, status); diff --git a/pathd/pathd.h b/pathd/pathd.h index 7ad20044c3..bb2e63c04b 100644 --- a/pathd/pathd.h +++ b/pathd/pathd.h @@ -330,6 +330,8 @@ struct srte_candidate {  RB_HEAD(srte_candidate_head, srte_candidate);  RB_PROTOTYPE(srte_candidate_head, srte_candidate, entry, srte_candidate_compare) +#define ENDPOINT_STR_LENGTH IPADDR_STRING_SIZE +  struct srte_policy {  	RB_ENTRY(srte_policy) entry;  | 
