]> git.puffer.fish Git - mirror/frr.git/commitdiff
pathd: display SRTE policy status when removing policy 11992/head
authorPhilippe Guibert <philippe.guibert@6wind.com>
Mon, 25 Jul 2022 13:06:35 +0000 (15:06 +0200)
committerPhilippe Guibert <philippe.guibert@6wind.com>
Mon, 14 Nov 2022 16:42:55 +0000 (17:42 +0100)
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>
pathd/pathd.c

index 5baaaf5159e733c6023ea58284a35a7c650b83a9..167c88aeab1eaba4c4cbb989211ed292eee0d24a 100644 (file)
@@ -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;