summaryrefslogtreecommitdiff
path: root/net/batman-adv
diff options
context:
space:
mode:
authorMartin Hundebøll <martin@hundeboll.net>2012-07-05 11:34:28 +0200
committerAntonio Quartulli <ordex@autistici.org>2012-08-23 14:20:19 +0200
commit74ee3634dcd1f11624192f72f458bcb5a04e4822 (patch)
treeff7c06ebe3fa8fd70efe159c5b5aa3ba5a470cd2 /net/batman-adv
parentff51fd70ad3e6bbf1ffc7d2a1d6a845d081df5a1 (diff)
batman-adv: Drop tt queries with foreign dest
When enabling promiscuous mode, tt queries for other hosts might be received. Before this patch, "foreign" tt queries were processed like any other query and thus forwarded to its destination again and thereby causing a loop. This patch adds a check to drop foreign tt queries. Signed-off-by: Martin Hundebøll <martin@hundeboll.net> Signed-off-by: Antonio Quartulli <ordex@autistici.org>
Diffstat (limited to 'net/batman-adv')
-rw-r--r--net/batman-adv/routing.c18
1 files changed, 3 insertions, 15 deletions
diff --git a/net/batman-adv/routing.c b/net/batman-adv/routing.c
index a79ded53dd94..4961278086bd 100644
--- a/net/batman-adv/routing.c
+++ b/net/batman-adv/routing.c
@@ -609,29 +609,17 @@ int batadv_recv_tt_query(struct sk_buff *skb, struct batadv_hard_iface *recv_if)
struct batadv_priv *bat_priv = netdev_priv(recv_if->soft_iface);
struct batadv_tt_query_packet *tt_query;
uint16_t tt_size;
- struct ethhdr *ethhdr;
+ int hdr_size = sizeof(*tt_query);
char tt_flag;
size_t packet_size;
- /* drop packet if it has not necessary minimum size */
- if (unlikely(!pskb_may_pull(skb,
- sizeof(struct batadv_tt_query_packet))))
- goto out;
+ if (batadv_check_unicast_packet(skb, hdr_size) < 0)
+ return NET_RX_DROP;
/* I could need to modify it */
if (skb_cow(skb, sizeof(struct batadv_tt_query_packet)) < 0)
goto out;
- ethhdr = (struct ethhdr *)skb_mac_header(skb);
-
- /* packet with unicast indication but broadcast recipient */
- if (is_broadcast_ether_addr(ethhdr->h_dest))
- goto out;
-
- /* packet with broadcast sender address */
- if (is_broadcast_ether_addr(ethhdr->h_source))
- goto out;
-
tt_query = (struct batadv_tt_query_packet *)skb->data;
switch (tt_query->flags & BATADV_TT_QUERY_TYPE_MASK) {