batman-adv: distributed arp table fixes
[openwrt/svn-archive/archive.git] / net / batman-adv / patches / 0003-batman-adv-filter-ARP-packets-with-invalid-MAC-addre.patch
1 From ab361a9ccc584e7501c06bfe1c00cb0411feebaf Mon Sep 17 00:00:00 2001
2 From: Matthias Schiffer <mschiffer@universe-factory.net>
3 Date: Thu, 24 Jan 2013 18:18:27 +0100
4 Subject: [PATCH 3/3] batman-adv: filter ARP packets with invalid MAC
5 addresses in DAT
6
7 We never want multicast MAC addresses in the Distributed ARP Table, so it's
8 best to completely ignore ARP packets containing them where we expect unicast
9 addresses.
10
11 Signed-off-by: Matthias Schiffer <mschiffer@universe-factory.net>
12 Acked-by: Antonio Quartulli <ordex@autistici.org>
13 Signed-off-by: Marek Lindner <lindner_marek@yahoo.de>
14 ---
15 distributed-arp-table.c | 13 +++++++++++++
16 1 file changed, 13 insertions(+)
17
18 diff --git a/distributed-arp-table.c b/distributed-arp-table.c
19 index be3be28..ea0bd31 100644
20 --- a/distributed-arp-table.c
21 +++ b/distributed-arp-table.c
22 @@ -738,6 +738,7 @@ static uint16_t batadv_arp_get_type(struct batadv_priv *bat_priv,
23 struct arphdr *arphdr;
24 struct ethhdr *ethhdr;
25 __be32 ip_src, ip_dst;
26 + uint8_t *hw_src, *hw_dst;
27 uint16_t type = 0;
28
29 /* pull the ethernet header */
30 @@ -782,6 +783,18 @@ static uint16_t batadv_arp_get_type(struct batadv_priv *bat_priv,
31 ipv4_is_zeronet(ip_dst) || ipv4_is_lbcast(ip_dst))
32 goto out;
33
34 + hw_src = batadv_arp_hw_src(skb, hdr_size);
35 + if (is_zero_ether_addr(hw_src) || is_multicast_ether_addr(hw_src))
36 + goto out;
37 +
38 + /* we don't care about the destination MAC address in ARP requests */
39 + if (arphdr->ar_op != htons(ARPOP_REQUEST)) {
40 + hw_dst = batadv_arp_hw_dst(skb, hdr_size);
41 + if (is_zero_ether_addr(hw_dst) ||
42 + is_multicast_ether_addr(hw_dst))
43 + goto out;
44 + }
45 +
46 type = ntohs(arphdr->ar_op);
47 out:
48 return type;
49 --
50 1.7.10.4
51