All of lore.kernel.org
 help / color / mirror / Atom feed
* [B.A.T.M.A.N.] [PATCH 1/2] batman-adv: Move batadv_check_unicast_packet()
@ 2012-07-05  9:34 Martin Hundebøll
  2012-07-05  9:34 ` [B.A.T.M.A.N.] [PATCH 2/2] batman-adv: Drop tt queries with foreign dest Martin Hundebøll
  2012-07-16  9:55 ` [B.A.T.M.A.N.] [PATCH 1/2] batman-adv: Move batadv_check_unicast_packet() Marek Lindner
  0 siblings, 2 replies; 4+ messages in thread
From: Martin Hundebøll @ 2012-07-05  9:34 UTC (permalink / raw)
  To: b.a.t.m.a.n; +Cc: Martin Hundebøll

batadv_check_unicast_packet() is needed in batadv_recv_tt_query(), so
move the former to before the latter.

Signed-off-by: Martin Hundebøll <martin@hundeboll.net>
---
 routing.c | 50 +++++++++++++++++++++++++-------------------------
 1 file changed, 25 insertions(+), 25 deletions(-)

diff --git a/routing.c b/routing.c
index bc2b88b..30d7605 100644
--- a/routing.c
+++ b/routing.c
@@ -579,6 +579,31 @@ batadv_find_ifalter_router(struct batadv_orig_node *primary_orig,
 	return router;
 }
 
+static int batadv_check_unicast_packet(struct sk_buff *skb, int hdr_size)
+{
+	struct ethhdr *ethhdr;
+
+	/* drop packet if it has not necessary minimum size */
+	if (unlikely(!pskb_may_pull(skb, hdr_size)))
+		return -1;
+
+	ethhdr = (struct ethhdr *)skb_mac_header(skb);
+
+	/* packet with unicast indication but broadcast recipient */
+	if (is_broadcast_ether_addr(ethhdr->h_dest))
+		return -1;
+
+	/* packet with broadcast sender address */
+	if (is_broadcast_ether_addr(ethhdr->h_source))
+		return -1;
+
+	/* not for me */
+	if (!batadv_is_my_mac(ethhdr->h_dest))
+		return -1;
+
+	return 0;
+}
+
 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);
@@ -819,31 +844,6 @@ err:
 	return NULL;
 }
 
-static int batadv_check_unicast_packet(struct sk_buff *skb, int hdr_size)
-{
-	struct ethhdr *ethhdr;
-
-	/* drop packet if it has not necessary minimum size */
-	if (unlikely(!pskb_may_pull(skb, hdr_size)))
-		return -1;
-
-	ethhdr = (struct ethhdr *)skb_mac_header(skb);
-
-	/* packet with unicast indication but broadcast recipient */
-	if (is_broadcast_ether_addr(ethhdr->h_dest))
-		return -1;
-
-	/* packet with broadcast sender address */
-	if (is_broadcast_ether_addr(ethhdr->h_source))
-		return -1;
-
-	/* not for me */
-	if (!batadv_is_my_mac(ethhdr->h_dest))
-		return -1;
-
-	return 0;
-}
-
 static int batadv_route_unicast_packet(struct sk_buff *skb,
 				       struct batadv_hard_iface *recv_if)
 {
-- 
1.7.11.1


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

* [B.A.T.M.A.N.] [PATCH 2/2] batman-adv: Drop tt queries with foreign dest
  2012-07-05  9:34 [B.A.T.M.A.N.] [PATCH 1/2] batman-adv: Move batadv_check_unicast_packet() Martin Hundebøll
@ 2012-07-05  9:34 ` Martin Hundebøll
  2012-07-16  9:58   ` Marek Lindner
  2012-07-16  9:55 ` [B.A.T.M.A.N.] [PATCH 1/2] batman-adv: Move batadv_check_unicast_packet() Marek Lindner
  1 sibling, 1 reply; 4+ messages in thread
From: Martin Hundebøll @ 2012-07-05  9:34 UTC (permalink / raw)
  To: b.a.t.m.a.n; +Cc: Martin Hundebøll

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>
---
 routing.c | 18 +++---------------
 1 file changed, 3 insertions(+), 15 deletions(-)

diff --git a/routing.c b/routing.c
index 30d7605..f1ed845 100644
--- a/routing.c
+++ b/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) {
-- 
1.7.11.1


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

* Re: [B.A.T.M.A.N.] [PATCH 1/2] batman-adv: Move batadv_check_unicast_packet()
  2012-07-05  9:34 [B.A.T.M.A.N.] [PATCH 1/2] batman-adv: Move batadv_check_unicast_packet() Martin Hundebøll
  2012-07-05  9:34 ` [B.A.T.M.A.N.] [PATCH 2/2] batman-adv: Drop tt queries with foreign dest Martin Hundebøll
@ 2012-07-16  9:55 ` Marek Lindner
  1 sibling, 0 replies; 4+ messages in thread
From: Marek Lindner @ 2012-07-16  9:55 UTC (permalink / raw)
  To: The list for a Better Approach To Mobile Ad-hoc Networking

On Thursday, July 05, 2012 11:34:27 Martin Hundebøll wrote:
> batadv_check_unicast_packet() is needed in batadv_recv_tt_query(), so
> move the former to before the latter.
> 
> Signed-off-by: Martin Hundebøll <martin@hundeboll.net>
> ---
>  routing.c | 50 +++++++++++++++++++++++++-------------------------
>  1 file changed, 25 insertions(+), 25 deletions(-)

Applied in revision 9353d58.

Thanks,
Marek

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

* Re: [B.A.T.M.A.N.] [PATCH 2/2] batman-adv: Drop tt queries with foreign dest
  2012-07-05  9:34 ` [B.A.T.M.A.N.] [PATCH 2/2] batman-adv: Drop tt queries with foreign dest Martin Hundebøll
@ 2012-07-16  9:58   ` Marek Lindner
  0 siblings, 0 replies; 4+ messages in thread
From: Marek Lindner @ 2012-07-16  9:58 UTC (permalink / raw)
  To: The list for a Better Approach To Mobile Ad-hoc Networking

On Thursday, July 05, 2012 11:34:28 Martin Hundebøll wrote:
> 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>
> ---
>  routing.c | 18 +++---------------
>  1 file changed, 3 insertions(+), 15 deletions(-)

Applied in revision 2b7b639.

Thanks,
Marek

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

end of thread, other threads:[~2012-07-16  9:58 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-07-05  9:34 [B.A.T.M.A.N.] [PATCH 1/2] batman-adv: Move batadv_check_unicast_packet() Martin Hundebøll
2012-07-05  9:34 ` [B.A.T.M.A.N.] [PATCH 2/2] batman-adv: Drop tt queries with foreign dest Martin Hundebøll
2012-07-16  9:58   ` Marek Lindner
2012-07-16  9:55 ` [B.A.T.M.A.N.] [PATCH 1/2] batman-adv: Move batadv_check_unicast_packet() Marek Lindner

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.