mirror of
https://git.proxmox.com/git/mirror_frr
synced 2026-01-28 08:59:55 +00:00
lib: changes needed for mac access-list any command
Ticket: CM-17074 Review: CCR-6453 Unit-test: Manual Signed-off-by: Mitesh Kanjariya <mitesh@cumulusnetworks.com>
This commit is contained in:
parent
297a21b66b
commit
69b61704b8
16
lib/filter.c
16
lib/filter.c
@ -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");
|
||||
}
|
||||
|
||||
12
lib/prefix.c
12
lib/prefix.c
@ -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;
|
||||
|
||||
@ -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);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user