]> git.puffer.fish Git - mirror/frr.git/commitdiff
lib: changes needed for mac access-list any command
authorMitesh Kanjariya <mitesh@marvel-07.cumulusnetworks.com>
Wed, 12 Jul 2017 21:27:24 +0000 (14:27 -0700)
committerDonald Sharp <sharpd@cumulusnetworks.com>
Tue, 8 Aug 2017 14:28:55 +0000 (10:28 -0400)
Ticket: CM-17074
Review: CCR-6453
Unit-test: Manual

Signed-off-by: Mitesh Kanjariya <mitesh@cumulusnetworks.com>
lib/filter.c
lib/prefix.c
lib/prefix.h

index 186b32bbbac28455c5bd01d3390628096bccd022..c01ee4ee1060b2a2ed89a9cd5533f5fd842b0dca 100644 (file)
@@ -169,6 +169,10 @@ static int mac_filter_match(struct prefix *n, struct ethaddr *p)
        if (!n || !p)
                return 0;
 
+       /* check if we are matching on any mac */
+       if (is_zero_mac(&(n->u.prefix_eth)))
+               return 1;
+
        if (memcmp(&(n->u.prefix), p, sizeof(struct ethaddr)) == 0)
                return 1;
 
@@ -1398,7 +1402,7 @@ DEFUN (no_mac_access_list_any,
        "Specify packets to forward\n"
        "MAC address to match. e.g. 00:01:00:01:00:01\n")
 {
-       return filter_set_zebra(vty, argv[2]->arg, argv[3]->arg, AFI_L2VPN,
+       return filter_set_zebra(vty, argv[3]->arg, argv[4]->arg, AFI_L2VPN,
                                "00:00:00:00:00:00", 0, 0);
 }
 
@@ -1994,9 +1998,13 @@ void config_write_access_zebra(struct vty *vty, struct filter *mfilter)
                vty_out(vty, " %s/%d%s",
                        inet_ntop(p->family, &p->u.prefix, buf, BUFSIZ),
                        p->prefixlen, filter->exact ? " exact-match" : "");
-       else
-               vty_out(vty, " %s",
-                       prefix_mac2str(&(p->u.prefix_eth), buf, sizeof(buf)));
+       else if (p->family == AF_ETHERNET) {
+               if (is_zero_mac(&(p->u.prefix_eth)))
+                       vty_out(vty, " any");
+               else
+                       vty_out(vty, " %s", prefix_mac2str(&(p->u.prefix_eth),
+                                                          buf, sizeof(buf)));
+       }
 
        vty_out(vty, "\n");
 }
index e67184f52b04719ef6a48bd57a03218d70269785..edfc22fb428d118704f7cdd0a91f9262f3d20b24 100644 (file)
@@ -301,6 +301,18 @@ static const struct in6_addr maskbytes6[] = {
 
 #define MASKBIT(offset)  ((0xff << (PNBBY - (offset))) & 0xff)
 
+int is_zero_mac(struct ethaddr *mac)
+{
+       int i = 0;
+
+       for (i = 0; i < ETH_ALEN; i++) {
+               if (mac->octet[i])
+                       return 0;
+       }
+
+       return 1;
+}
+
 unsigned int prefix_bit(const u_char *prefix, const u_char prefixlen)
 {
        unsigned int offset = prefixlen / 8;
index 0f3ad562d9a2ea292fe2f895af1e4ed72a72a07a..f665f55dfd7536adf98148679ffc0c924b7c370e 100644 (file)
@@ -265,6 +265,7 @@ union prefixconstptr {
 #endif /*s6_addr32*/
 
 /* Prototypes. */
+extern int is_zero_mac(struct ethaddr *mac);
 extern int str2family(const char *);
 extern int afi2family(afi_t);
 extern afi_t family2afi(int);