From 951b6632bcdd29490c111a79285911795adb41cb Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Linus=20L=C3=BCssing?= <linus.luessing@c0d3.blue>
Date: Sat, 31 Mar 2018 19:12:43 +0200
Subject: [PATCH] gluon-ebtables-limit-arp: do not add multicast addresses to
 filter
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

With the batman-adv multicast support compiled back in again we end up
with multicast addresses in the batman-adv translation table.

Currently we wrongly interpret multicast addresses returned by TT as a
unique host, too, which adds them with a source address filter to
ebtables as well. However, the source address of an ethernet frames is
never supposed to be a multicat one.

This leads to unnecessary entries in ebtables. Fixing this by ignoring
those MAC addreses returned by TT which have the multicast bit set.

Signed-off-by: Linus Lüssing <linus.luessing@c0d3.blue>
---
 package/gluon-ebtables-limit-arp/src/gluon-arp-limiter.c | 3 +++
 package/gluon-ebtables-limit-arp/src/mac.h               | 5 +++++
 2 files changed, 8 insertions(+)

diff --git a/package/gluon-ebtables-limit-arp/src/gluon-arp-limiter.c b/package/gluon-ebtables-limit-arp/src/gluon-arp-limiter.c
index af4acf48d..cbb6faf21 100644
--- a/package/gluon-ebtables-limit-arp/src/gluon-arp-limiter.c
+++ b/package/gluon-ebtables-limit-arp/src/gluon-arp-limiter.c
@@ -248,6 +248,9 @@ static void ebt_tl_update(void)
 			break;
 		}
 
+		if (mac_is_multicast(&mac))
+			continue;
+
 		ebt_add_mac(&mac);
 	}
 
diff --git a/package/gluon-ebtables-limit-arp/src/mac.h b/package/gluon-ebtables-limit-arp/src/mac.h
index e61917364..11567ade6 100644
--- a/package/gluon-ebtables-limit-arp/src/mac.h
+++ b/package/gluon-ebtables-limit-arp/src/mac.h
@@ -16,4 +16,9 @@ struct mac_addr {
 int mac_aton(const char *cp, struct  mac_addr *mac);
 char *mac_ntoa(struct mac_addr *mac);
 
+static inline int mac_is_multicast(struct mac_addr *addr)
+{
+	return addr->storage[0] & 0x01;
+}
+
 #endif /* _MAC_H_ */
-- 
GitLab