Skip to content

Commit

Permalink
batman-adv: filter ARP packets with invalid MAC addresses in DAT
Browse files Browse the repository at this point in the history
We never want multicast MAC addresses in the Distributed ARP Table, so it's
best to completely ignore ARP packets containing them where we expect unicast
addresses.

Signed-off-by: Matthias Schiffer <[email protected]>
Acked-by: Antonio Quartulli <[email protected]>
Signed-off-by: Marek Lindner <[email protected]>
Signed-off-by: Antonio Quartulli <[email protected]>
  • Loading branch information
neocturne authored and Antonio Quartulli committed Jan 27, 2013
1 parent 757dd82 commit b618ad1
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions net/batman-adv/distributed-arp-table.c
Original file line number Diff line number Diff line change
Expand Up @@ -738,6 +738,7 @@ static uint16_t batadv_arp_get_type(struct batadv_priv *bat_priv,
struct arphdr *arphdr;
struct ethhdr *ethhdr;
__be32 ip_src, ip_dst;
uint8_t *hw_src, *hw_dst;
uint16_t type = 0;

/* pull the ethernet header */
Expand Down Expand Up @@ -782,6 +783,18 @@ static uint16_t batadv_arp_get_type(struct batadv_priv *bat_priv,
ipv4_is_zeronet(ip_dst) || ipv4_is_lbcast(ip_dst))
goto out;

hw_src = batadv_arp_hw_src(skb, hdr_size);
if (is_zero_ether_addr(hw_src) || is_multicast_ether_addr(hw_src))
goto out;

/* we 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))
goto out;
}

type = ntohs(arphdr->ar_op);
out:
return type;
Expand Down

0 comments on commit b618ad1

Please sign in to comment.