From: David Lamparter Date: Wed, 9 Aug 2017 18:30:34 +0000 (+0200) Subject: lib: some final MAC access-list fixes X-Git-Tag: frr-4.0-dev~431^2 X-Git-Url: https://git.puffer.fish/?a=commitdiff_plain;h=3b0f6068a83da9aeb46e42c430afc7b9c8e79393;p=mirror%2Ffrr.git lib: some final MAC access-list fixes - 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 --- diff --git a/lib/filter.c b/lib/filter.c index 9b983d26f2..cb6f743c01 100644 --- a/lib/filter.c +++ b/lib/filter.c @@ -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), diff --git a/lib/prefix.c b/lib/prefix.c index d12999067c..de521b2e3e 100644 --- a/lib/prefix.c +++ b/lib/prefix.c @@ -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, '/'); diff --git a/lib/prefix.h b/lib/prefix.h index ddd01af766..f0644ea88e 100644 --- a/lib/prefix.h +++ b/lib/prefix.h @@ -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);