diff options
| author | Philippe Guibert <philippe.guibert@6wind.com> | 2022-07-25 15:06:35 +0200 | 
|---|---|---|
| committer | Philippe Guibert <philippe.guibert@6wind.com> | 2022-11-14 17:42:55 +0100 | 
| commit | ec139f60f19088611a2fa177c1f81dd64f97d744 (patch) | |
| tree | 9a9dc424e500188e942281d27361283af53c76d9 /pathd/pathd.c | |
| parent | b5ca313856f86d044b20c3806825a8c17e17f11e (diff) | |
pathd: display SRTE policy status when removing policy
Create a function that logs the status of a given SR-TE policy.
Add a call to this function when a policy is being removed.
Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
Diffstat (limited to 'pathd/pathd.c')
| -rw-r--r-- | pathd/pathd.c | 24 | 
1 files changed, 20 insertions, 4 deletions
diff --git a/pathd/pathd.c b/pathd/pathd.c index 5baaaf5159..167c88aeab 100644 --- a/pathd/pathd.c +++ b/pathd/pathd.c @@ -110,6 +110,20 @@ RB_GENERATE(srte_policy_head, srte_policy, entry, srte_policy_compare)  struct srte_policy_head srte_policies = RB_INITIALIZER(&srte_policies); +static void srte_policy_status_log(struct srte_policy *policy) +{ +	char endpoint[ENDPOINT_STR_LENGTH]; + +	ipaddr2str(&policy->endpoint, endpoint, sizeof(endpoint)); +	if (policy->status == SRTE_POLICY_STATUS_DOWN) { +		PATH_POLICY_DEBUG("SR-TE(%s, %u): policy is DOWN", endpoint, +				  policy->color); +	} else if (policy->status == SRTE_POLICY_STATUS_UP) { +		PATH_POLICY_DEBUG("SR-TE(%s, %u): policy is UP", endpoint, +				  policy->color); +	} +} +  /**   * Adds a segment list to pathd.   * @@ -544,6 +558,10 @@ void srte_apply_changes(void)  	RB_FOREACH_SAFE (policy, srte_policy_head, &srte_policies, safe_pol) {  		if (CHECK_FLAG(policy->flags, F_POLICY_DELETED)) { +			if (policy->status != SRTE_POLICY_STATUS_DOWN) { +				policy->status = SRTE_POLICY_STATUS_DOWN; +				srte_policy_status_log(policy); +			}  			srte_policy_del(policy);  			continue;  		} @@ -1138,9 +1156,8 @@ void srte_candidate_status_update(struct srte_candidate *candidate, int status)  		case SRTE_POLICY_STATUS_DOWN:  			return;  		default: -			PATH_POLICY_DEBUG("SR-TE(%s, %u): policy is DOWN", -					  endpoint, policy->color);  			policy->status = SRTE_POLICY_STATUS_DOWN; +			srte_policy_status_log(policy);  			break;  		}  		break; @@ -1149,9 +1166,8 @@ void srte_candidate_status_update(struct srte_candidate *candidate, int status)  		case SRTE_POLICY_STATUS_UP:  			return;  		default: -			PATH_POLICY_DEBUG("SR-TE(%s, %u): policy is UP", -					  endpoint, policy->color);  			policy->status = SRTE_POLICY_STATUS_UP; +			srte_policy_status_log(policy);  			break;  		}  		break;  | 
