All of lore.kernel.org
 help / color / mirror / Atom feed
* [B.A.T.M.A.N.] [PATCH] batman-adv: allow snooping gratuitous ARP Replies
@ 2019-02-14 15:51 Linus Lüssing
  2019-02-14 16:16 ` Marek Lindner
  0 siblings, 1 reply; 5+ messages in thread
From: Linus Lüssing @ 2019-02-14 15:51 UTC (permalink / raw)
  To: b.a.t.m.a.n; +Cc: Daniel Ehlers, Matthias Schiffer, Linus Lüssing

A gratuitous ARP Reply has the following format (example):

Sender MAC: 00:12:34:56:78:9A
Sender IP:  192.168.2.3
Target MAC: FF:FF:FF:FF:FF:FF
Target IP:  192.168.2.3

A gratuitous ARP Reply is commonly used to update an ARP table in the
network in an unsolicited way. Here, the host with the MAC address
00:12:34:56:78:9A announces that it is now the owner of 192.168.2.3.
Gratuitous ARP Replies are usually used for redundancy or for IP address
handovers between hosts.

So far, gratuitous ARP Replies were ignored for DAT processing as it
contains a broadcast MAC address. This patch changes this and allows
snooping such ARP messages, too.

Special care needs to be taken with the target MAC, to not accidentally
add this broadcast MAC to the DAT cache.

Signed-off-by: Linus Lüssing <linus.luessing@c0d3.blue>

---
Gratuitous ARP Replies were ignored since this commit:

ab361a9ccc5 ("batman-adv: filter ARP packets with invalid MAC addresses in DAT")

Daniel Ehlers is currently working on a distributed DHCP server for mesh
networks. For cases like these it would be helpful if userspace programs
were able to add entries to the DAT, too. Sending gratuitous ARP Replies
would be one easy way for userspace tools to do so.

This patch was verified in VMs with gratuitous ARP Replies generated via
"mausezahn". Sending such packets with a 00:00:00:00:00:00 ethernet
frame destination address even allows updating the DAT without actually
broadcasting the original frame into the mesh.

[0]: https://github.com/sargon/ddhcpd,
[1]: https://media.freifunk.net/search/?q=ddhcp
---
 net/batman-adv/distributed-arp-table.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/net/batman-adv/distributed-arp-table.c b/net/batman-adv/distributed-arp-table.c
index 310a4f35..c8923c7d 100644
--- a/net/batman-adv/distributed-arp-table.c
+++ b/net/batman-adv/distributed-arp-table.c
@@ -373,9 +373,12 @@ batadv_dat_entry_hash_find(struct batadv_priv *bat_priv, __be32 ip,
 static void batadv_dat_entry_add(struct batadv_priv *bat_priv, __be32 ip,
 				 u8 *mac_addr, unsigned short vid)
 {
-	struct batadv_dat_entry *dat_entry;
+	struct batadv_dat_entry *dat_entry = NULL;
 	int hash_added;
 
+	if (is_multicast_ether_addr(mac_addr))
+		goto out;
+
 	dat_entry = batadv_dat_entry_hash_find(bat_priv, ip, vid);
 	/* if this entry is already known, just update it */
 	if (dat_entry) {
@@ -1117,8 +1120,7 @@ static u16 batadv_arp_get_type(struct batadv_priv *bat_priv,
 	/* don't care about the destination MAC address in ARP requests */
 	if (arphdr->ar_op != htons(ARPOP_REQUEST)) {
 		hw_dst = batadv_arp_hw_dst(skb, hdr_size);
-		if (is_zero_ether_addr(hw_dst) ||
-		    is_multicast_ether_addr(hw_dst))
+		if (is_zero_ether_addr(hw_dst))
 			goto out;
 	}
 
-- 
2.11.0


^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2019-02-15 17:45 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-02-14 15:51 [B.A.T.M.A.N.] [PATCH] batman-adv: allow snooping gratuitous ARP Replies Linus Lüssing
2019-02-14 16:16 ` Marek Lindner
2019-02-14 17:49   ` Linus Lüssing
2019-02-15  6:36     ` Antonio Quartulli
2019-02-15 17:45       ` Linus Lüssing

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.