]> git.proxmox.com Git - mirror_frr.git/commitdiff
pathd: use a define to store the the length of endpoint string
authorPhilippe Guibert <philippe.guibert@6wind.com>
Tue, 19 Jul 2022 12:59:23 +0000 (14:59 +0200)
committerPhilippe Guibert <philippe.guibert@6wind.com>
Mon, 14 Nov 2022 16:42:55 +0000 (17:42 +0100)
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>
lib/ipaddr.h
pathd/path_cli.c
pathd/pathd.c
pathd/pathd.h

index d7ab358afea794f45f7fd207c79386eded772df9..43b3028200c7e9c71d0a81497833b2cac61a7d61 100644 (file)
@@ -61,6 +61,8 @@ struct ipaddr {
 #define IPADDRSZ(p)                                                            \
        (IS_IPADDR_V4((p)) ? sizeof(struct in_addr) : sizeof(struct in6_addr))
 
+#define IPADDR_STRING_SIZE 46
+
 static inline int ipaddr_family(const struct ipaddr *ip)
 {
        switch (ip->ipa_type) {
index 7510f2ad05a790c72019d198e19a38529438d028..b88453c68f899697eaa2dd0bcedc38afe87ab7f9 100644 (file)
@@ -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)";
index 7e3802c73400881ef09323e53705c57467e02f76..5ede1de2fffe9c581675545f906933ac0d6692a6 100644 (file)
@@ -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);
index 7ad20044c32af2df7122fe5ae771870db6c99a88..bb2e63c04ba725dfa44721974e059eb248dd50f4 100644 (file)
@@ -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;