]> git.puffer.fish Git - mirror/frr.git/commitdiff
lib: some final MAC access-list fixes 822/head
authorDavid Lamparter <equinox@opensourcerouting.org>
Wed, 9 Aug 2017 18:30:34 +0000 (20:30 +0200)
committerDavid Lamparter <equinox@opensourcerouting.org>
Wed, 9 Aug 2017 18:30:34 +0000 (20:30 +0200)
- couldn't load back written configs because it was trying to parse
  "any" as MAC address
- don't need special-casing in filter_match_zebra(), exact is going to
  be 0 for AF_ETHERNET anyway
- some vty formatting was slightly different
- is_zero_mac now static to prefix.c

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
lib/filter.c
lib/prefix.c
lib/prefix.h

index 9b983d26f26400987eda74ca5919966b49187a95..cb6f743c0136f157691ad0719c6ae1af7a2c62d6 100644 (file)
@@ -187,26 +187,16 @@ static int filter_match_zebra(struct filter *mfilter, struct prefix *p)
 
        filter = &mfilter->u.zfilter;
 
-       if (filter->prefix.family == AF_ETHERNET) {
-               return prefix_match(&filter->prefix, p);
-       }
-
-       if (filter->prefix.family == AF_INET
-           || filter->prefix.family == AF_INET6) {
-
-               if (filter->prefix.family == p->family) {
-                       if (filter->exact) {
-                               if (filter->prefix.prefixlen == p->prefixlen)
-                                       return prefix_match(&filter->prefix, p);
-                               else
-                                       return 0;
-                       } else
+       if (filter->prefix.family == p->family) {
+               if (filter->exact) {
+                       if (filter->prefix.prefixlen == p->prefixlen)
                                return prefix_match(&filter->prefix, p);
+                       else
+                               return 0;
                } else
-                       return 0;
-       }
-
-       return 0;
+                       return prefix_match(&filter->prefix, p);
+       } else
+               return 0;
 }
 
 /* Allocate new access list structure. */
@@ -1755,9 +1745,9 @@ static int filter_show(struct vty *vty, const char *name, afi_t afi)
                                                                  : "Standard")
                                                       : "Zebra",
                                        (afi == AFI_IP)
-                                               ? ("")
-                                               : ((afi == AFI_IP6) ? ("ipv6 ")
-                                                                   : ("mac ")),
+                                               ? ("IP")
+                                               : ((afi == AFI_IP6) ? ("IPv6 ")
+                                                                   : ("MAC ")),
                                        access->name);
                                write = 0;
                        }
@@ -1802,9 +1792,9 @@ static int filter_show(struct vty *vty, const char *name, afi_t afi)
                                                                  : "Standard")
                                                       : "Zebra",
                                        (afi == AFI_IP)
-                                               ? ("")
-                                               : ((afi == AFI_IP6) ? ("ipv6 ")
-                                                                   : ("mac ")),
+                                               ? ("IP")
+                                               : ((afi == AFI_IP6) ? ("IPv6 ")
+                                                                   : ("MAC ")),
                                        access->name);
                                write = 0;
                        }
@@ -1960,7 +1950,7 @@ void config_write_access_zebra(struct vty *vty, struct filter *mfilter)
                        inet_ntop(p->family, &p->u.prefix, buf, BUFSIZ),
                        p->prefixlen, filter->exact ? " exact-match" : "");
        else if (p->family == AF_ETHERNET) {
-               if (is_zero_mac(&(p->u.prefix_eth)))
+               if (p->prefixlen == 0)
                        vty_out(vty, " any");
                else
                        vty_out(vty, " %s", prefix_mac2str(&(p->u.prefix_eth),
index d12999067c931d0e6c4276121af0034751e7459c..de521b2e3e0949ec7a0e5f4f91a1508f2e86c8fd 100644 (file)
@@ -301,7 +301,7 @@ static const struct in6_addr maskbytes6[] = {
 
 #define MASKBIT(offset)  ((0xff << (PNBBY - (offset))) & 0xff)
 
-int is_zero_mac(const struct ethaddr *mac)
+static int is_zero_mac(const struct ethaddr *mac)
 {
        int i = 0;
 
@@ -683,6 +683,12 @@ int str2prefix_eth(const char *str, struct prefix_eth *p)
        int i;
        bool slash = false;
 
+       if (!strcmp(str, "any")) {
+               memset(p, 0, sizeof(*p));
+               p->family = AF_ETHERNET;
+               return 1;
+       }
+
        /* Find slash inside string. */
        pnt = strchr(str, '/');
 
index ddd01af76683f41b9c23a9f358896f0306276fa5..f0644ea88e9dbb238e4900dc012ffe938b464603 100644 (file)
@@ -276,7 +276,6 @@ union prefixconstptr {
 #endif /*s6_addr32*/
 
 /* Prototypes. */
-extern int is_zero_mac(const struct ethaddr *mac);
 extern int str2family(const char *);
 extern int afi2family(afi_t);
 extern afi_t family2afi(int);