void *object)
{
struct access_list *alist;
+ struct prefix p;
if (type == RMAP_BGP) {
alist = access_list_lookup(AFI_L2VPN, (char *)rule);
if (prefix->u.prefix_evpn.route_type != BGP_EVPN_MAC_IP_ROUTE)
return RMAP_NOMATCH;
- return (access_list_apply(alist, &(prefix->u.prefix_evpn.mac))
+ p.family = AF_ETHERNET;
+ p.prefixlen = ETH_ALEN * 8;
+ p.u.prefix_eth = prefix->u.prefix_evpn.mac;
+
+ return (access_list_apply(alist, &p)
== FILTER_DENY
? RMAP_NOMATCH
: RMAP_MATCH);
}
}
-/*
- * mac filter match
- * n is of type struct prefix_eth
- * p can be of type struct ethaddr
- */
-static int mac_filter_match(struct prefix *n, struct ethaddr *p)
-{
- if (!n && !p)
- return 1;
-
- 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;
-
- return 0;
-}
-
/* If filter match to the prefix then return 1. */
static int filter_match_cisco(struct filter *mfilter, struct prefix *p)
{
}
/* If filter match to the prefix then return 1. */
-static int filter_match_zebra(struct filter *mfilter, void *obj)
+static int filter_match_zebra(struct filter *mfilter, struct prefix *p)
{
struct filter_zebra *filter = NULL;
filter = &mfilter->u.zfilter;
if (filter->prefix.family == AF_ETHERNET) {
- struct ethaddr *p = NULL;
-
- p = (struct ethaddr *)obj;
- return mac_filter_match(&filter->prefix, p);
+ return prefix_match(&filter->prefix, p);
}
if (filter->prefix.family == AF_INET
|| filter->prefix.family == AF_INET6) {
- struct prefix *p = NULL;
- p = (struct prefix *)obj;
if (filter->prefix.family == p->family) {
if (filter->exact) {
if (filter->prefix.prefixlen == p->prefixlen)
enum filter_type access_list_apply(struct access_list *access, void *object)
{
struct filter *filter;
- struct prefix *p;
-
- p = (struct prefix *)object;
+ struct prefix *p = (struct prefix *)object;
if (access == NULL)
return FILTER_DENY;
if (filter_match_cisco(filter, p))
return filter->type;
} else {
- if (filter_match_zebra(filter, object))
+ if (filter_match_zebra(filter, p))
return filter->type;
}
}
if (filter->exact == new->exact
&& mfilter->type == mnew->type) {
- if (new->prefix.family == AF_ETHERNET) {
- if (prefix_eth_same(
- (struct prefix_eth *)&filter
- ->prefix,
- (struct prefix_eth *)&new->prefix))
- return mfilter;
- } else {
- if (prefix_same(&filter->prefix, &new->prefix))
- return mfilter;
- }
+ if (prefix_same(&filter->prefix, &new->prefix))
+ return mfilter;
}
}
return NULL;
#define MASKBIT(offset) ((0xff << (PNBBY - (offset))) & 0xff)
-int is_zero_mac(struct ethaddr *mac)
+int is_zero_mac(const struct ethaddr *mac)
{
int i = 0;
}
}
-/* check if the two prefix_eth struct are same*/
-int prefix_eth_same(struct prefix_eth *p1, struct prefix_eth *p2)
-{
- if (!p1 && !p2)
- return 1;
-
- if (p1 && !p2)
- return 0;
-
- if (!p1 && p2)
- return 0;
-
- if (memcmp(p1, p2, sizeof(struct prefix_eth)) == 0)
- return 1;
-
- return 0;
-}
-
/*
* Return 1 if the address/netmask contained in the prefix structure
* is the same, and else return 0. For this routine, 'same' requires
const char *str_addr = str;
unsigned int a[6];
int i;
+ bool slash = false;
/* Find slash inside string. */
pnt = strchr(str, '/');
*(cp + (pnt - str)) = '\0';
str_addr = cp;
+ slash = true;
}
/* Convert string to prefix. */
}
p->prefixlen = plen;
p->family = AF_ETHERNET;
+
+ /*
+ * special case to allow old configurations to work
+ * Since all zero's is implicitly meant to allow
+ * a comparison to zero, let's assume
+ */
+ if (!slash && is_zero_mac(&(p->eth_addr)))
+ p->prefixlen = 0;
+
ret = 1;
done:
#endif /*s6_addr32*/
/* Prototypes. */
-extern int is_zero_mac(struct ethaddr *mac);
+extern int is_zero_mac(const struct ethaddr *mac);
extern int str2family(const char *);
extern int afi2family(afi_t);
extern afi_t family2afi(int);
extern int prefix_common_bits(const struct prefix *, const struct prefix *);
extern void prefix_copy(struct prefix *dest, const struct prefix *src);
extern void apply_mask(struct prefix *);
-extern int prefix_eth_same(struct prefix_eth *p1, struct prefix_eth *p2);
extern struct prefix *sockunion2prefix(const union sockunion *dest,
const union sockunion *mask);