]> git.puffer.fish Git - mirror/frr.git/commitdiff
bgpd: Rename ecomm_intersect() to ecommunity_include()
authorDonatas Abraitis <donatas@opensourcerouting.org>
Fri, 19 Aug 2022 09:50:29 +0000 (12:50 +0300)
committerDonatas Abraitis <donatas@opensourcerouting.org>
Fri, 19 Aug 2022 09:50:29 +0000 (12:50 +0300)
Makes more sense.

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
bgpd/bgp_ecommunity.c
bgpd/bgp_ecommunity.h
bgpd/bgp_mplsvpn.c

index 4120524e631f86243422030b64b8ed1c4eb37f66..3f627521e7d74dd4804d9bc1fb3bad231b9d1f45 100644 (file)
@@ -1188,6 +1188,23 @@ char *ecommunity_ecom2str(struct ecommunity *ecom, int format, int filter)
        return str_buf;
 }
 
+bool ecommunity_include(struct ecommunity *e1, struct ecommunity *e2)
+{
+       uint32_t i, j;
+
+       if (!e1 || !e2)
+               return false;
+       for (i = 0; i < e1->size; ++i) {
+               for (j = 0; j < e2->size; ++j) {
+                       if (!memcmp(e1->val + (i * e1->unit_size),
+                                   e2->val + (j * e2->unit_size),
+                                   e1->unit_size))
+                               return true;
+               }
+       }
+       return false;
+}
+
 bool ecommunity_match(const struct ecommunity *ecom1,
                      const struct ecommunity *ecom2)
 {
index f22855c329076f3b40afdee136d366434640d983..84e310c3f93d679ebd7825aaf9cf3c8c7256faed 100644 (file)
@@ -257,6 +257,7 @@ extern struct ecommunity *ecommunity_str2com_ipv6(const char *str, int type,
                                                  int keyword_included);
 extern char *ecommunity_ecom2str(struct ecommunity *, int, int);
 extern void ecommunity_strfree(char **s);
+extern bool ecommunity_include(struct ecommunity *e1, struct ecommunity *e2);
 extern bool ecommunity_match(const struct ecommunity *,
                             const struct ecommunity *);
 extern char *ecommunity_str(struct ecommunity *);
index 7b8f0df2e27e80e29d4f8b90a101b31448b0c4a6..be83f94755a226c16adfab354d5320422e7e21a2 100644 (file)
@@ -662,25 +662,6 @@ void transpose_sid(struct in6_addr *sid, uint32_t label, uint8_t offset,
        }
 }
 
-static bool ecom_intersect(struct ecommunity *e1, struct ecommunity *e2)
-{
-       uint32_t i, j;
-
-       if (!e1 || !e2)
-               return false;
-       for (i = 0; i < e1->size; ++i) {
-               for (j = 0; j < e2->size; ++j) {
-                       if (!memcmp(e1->val + (i * e1->unit_size),
-                                   e2->val + (j * e2->unit_size),
-                                   e1->unit_size)) {
-
-                               return true;
-                       }
-               }
-       }
-       return false;
-}
-
 static bool labels_same(struct bgp_path_info *bpi, mpls_label_t *label,
                        uint32_t n)
 {
@@ -1502,7 +1483,7 @@ vpn_leak_to_vrf_update_onevrf(struct bgp *to_bgp,      /* to */
        }
 
        /* Check for intersection of route targets */
-       if (!ecom_intersect(
+       if (!ecommunity_include(
                    to_bgp->vpn_policy[afi].rtlist[BGP_VPN_POLICY_DIR_FROMVPN],
                    bgp_attr_get_ecommunity(path_vpn->attr))) {
                if (debug)
@@ -1751,9 +1732,10 @@ void vpn_leak_to_vrf_withdraw(struct bgp *from_bgp,         /* from */
                }
 
                /* Check for intersection of route targets */
-               if (!ecom_intersect(bgp->vpn_policy[afi]
-                                           .rtlist[BGP_VPN_POLICY_DIR_FROMVPN],
-                                   bgp_attr_get_ecommunity(path_vpn->attr))) {
+               if (!ecommunity_include(
+                           bgp->vpn_policy[afi]
+                                   .rtlist[BGP_VPN_POLICY_DIR_FROMVPN],
+                           bgp_attr_get_ecommunity(path_vpn->attr))) {
 
                        continue;
                }
@@ -2932,7 +2914,7 @@ vrf_id_t get_first_vrf_for_redirect_with_rt(struct ecommunity *eckey)
                if (ec && eckey->unit_size != ec->unit_size)
                        continue;
 
-               if (ecom_intersect(ec, eckey))
+               if (ecommunity_include(ec, eckey))
                        return bgp->vrf_id;
        }
        return VRF_UNKNOWN;