[2/2] batman-adv: filter out invalid DAT entries

Message ID 4b41fb1f387acd24ecab6e4e47b2126b6dbddb5a.1358961079.git.mschiffer@universe-factory.net (mailing list archive)
State Superseded, archived
Headers

Commit Message

Matthias Schiffer Jan. 23, 2013, 5:11 p.m. UTC
  Due to duplicate address detection and other strange ARP packets, sometimes
entries with broadcast MAC addresses or unspecified IP addresses would get into
the Distributed ARP Table. This patch prevents these and some other kinds of
invalid entries from getting into the DAT.

Signed-off-by: Matthias Schiffer <mschiffer@universe-factory.net>
---
 distributed-arp-table.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)
  

Comments

Antonio Quartulli Jan. 23, 2013, 9:07 p.m. UTC | #1
On Wed, Jan 23, 2013 at 06:11:54 +0100, Matthias Schiffer wrote:
> Due to duplicate address detection and other strange ARP packets, sometimes
> entries with broadcast MAC addresses or unspecified IP addresses would get into
> the Distributed ARP Table. This patch prevents these and some other kinds of
> invalid entries from getting into the DAT.
> 
> Signed-off-by: Matthias Schiffer <mschiffer@universe-factory.net>
> ---
>  distributed-arp-table.c | 12 ++++++++++++
>  1 file changed, 12 insertions(+)
> 
> diff --git a/distributed-arp-table.c b/distributed-arp-table.c
> index 9f4cff3..e28be57 100644
> --- a/distributed-arp-table.c
> +++ b/distributed-arp-table.c
> @@ -274,6 +274,18 @@ static void batadv_dat_entry_add(struct batadv_priv *bat_priv, __be32 ip,
>  	struct batadv_dat_entry *dat_entry;
>  	int hash_added;
>  
> +	/* filter invalid MAC addresses that are sometimes used as
> +	 * destinations of ARP replies
> +	 */
> +	if (is_zero_ether_addr(mac_addr) || is_multicast_ether_addr(mac_addr))
> +		return;
> +
> +	/* ARP requests with unspecified source address are used for
> +	 * duplicate address detection, we don't want those in the DAT either
> +	 */
> +	if (!ip)

Hi Matthias,
what about using ipv4_is_zeronet() ? Even if this is a base case, I would rather
prefer to use an already implemented function.

Cheers,
  

Patch

diff --git a/distributed-arp-table.c b/distributed-arp-table.c
index 9f4cff3..e28be57 100644
--- a/distributed-arp-table.c
+++ b/distributed-arp-table.c
@@ -274,6 +274,18 @@  static void batadv_dat_entry_add(struct batadv_priv *bat_priv, __be32 ip,
 	struct batadv_dat_entry *dat_entry;
 	int hash_added;
 
+	/* filter invalid MAC addresses that are sometimes used as
+	 * destinations of ARP replies
+	 */
+	if (is_zero_ether_addr(mac_addr) || is_multicast_ether_addr(mac_addr))
+		return;
+
+	/* ARP requests with unspecified source address are used for
+	 * duplicate address detection, we don't want those in the DAT either
+	 */
+	if (!ip)
+		return;
+
 	dat_entry = batadv_dat_entry_hash_find(bat_priv, ip);
 	/* if this entry is already known, just update it */
 	if (dat_entry) {