]> git.proxmox.com Git - mirror_frr.git/commitdiff
bgpd : Support for exact-match in match clause for lcommunity
authorvishaldhingra <vdhingra@vmware.com>
Mon, 6 May 2019 06:09:08 +0000 (23:09 -0700)
committervishaldhingra <vdhingra@vmware.com>
Wed, 19 Jun 2019 11:37:51 +0000 (04:37 -0700)
FRR has a provision to give exact-match in match clause for
standard community, but this option is missing for lcommunity.

Part 1 : Added support in clist lib

Signed-off-by: vishaldhingra <vdhingra@vmware.com>
bgpd/bgp_clist.c
bgpd/bgp_clist.h

index b9a5784799c6df89e0ebb8ebda00aeaeb9ae5ed8..ce617fe6b51b82fd5cb8feca246d1e9f361692a3 100644 (file)
@@ -695,6 +695,32 @@ int lcommunity_list_match(struct lcommunity *lcom, struct community_list *list)
        return 0;
 }
 
+
+/* Perform exact matching.  In case of expanded large-community-list, do
+ * same thing as lcommunity_list_match().
+ */
+int lcommunity_list_exact_match(struct lcommunity *lcom,
+                              struct community_list *list)
+{
+       struct community_entry *entry;
+
+       for (entry = list->head; entry; entry = entry->next) {
+               if (entry->any)
+                       return entry->direct == COMMUNITY_PERMIT ? 1 : 0;
+
+               if (entry->style == LARGE_COMMUNITY_LIST_STANDARD) {
+                       if (lcommunity_cmp(lcom, entry->u.com))
+                               return entry->direct == COMMUNITY_PERMIT ? 1
+                                                                        : 0;
+               } else if (entry->style == LARGE_COMMUNITY_LIST_EXPANDED) {
+                       if (lcommunity_regexp_match(lcom, entry->reg))
+                               return entry->direct == COMMUNITY_PERMIT ? 1
+                                                                        : 0;
+               }
+       }
+       return 0;
+}
+
 int ecommunity_list_match(struct ecommunity *ecom, struct community_list *list)
 {
        struct community_entry *entry;
index 75a31611bae86b16dd771fadb1f20933f1301283..87b29ac3bebe92a21a12024c7f9c88e8c7f3ddef 100644 (file)
@@ -165,6 +165,8 @@ extern int ecommunity_list_match(struct ecommunity *, struct community_list *);
 extern int lcommunity_list_match(struct lcommunity *, struct community_list *);
 extern int community_list_exact_match(struct community *,
                                      struct community_list *);
+extern int lcommunity_list_exact_match(struct lcommunity *lcom,
+                                      struct community_list *list);
 extern struct community *community_list_match_delete(struct community *,
                                                     struct community_list *);
 extern struct lcommunity *