[maint,1/4] batman-adv: fix speedy join for DAT cache replies

Message ID 1440170118-10876-2-git-send-email-sw@simonwunderlich.de (mailing list archive)
State Superseded, archived
Headers

Commit Message

Simon Wunderlich Aug. 21, 2015, 3:15 p.m. UTC
  DAT Cache replies are answered on behalf of other clients which are not
connected to the answering originator. Therefore, we shouldn't add these
clients to the answering originators TT table through speed join to
avoid bogus entries.

Reported-by: Alessandro Bolletta <alessandro@mediaspot.net>
Signed-off-by: Simon Wunderlich <sw@simonwunderlich.de>
---
 net/batman-adv/routing.c | 17 +++++++++++++----
 1 file changed, 13 insertions(+), 4 deletions(-)
  

Comments

Antonio Quartulli Aug. 25, 2015, 9:42 a.m. UTC | #1
On 21/08/15 17:15, Simon Wunderlich wrote:
> +			/* Cache replies should not be considered for speedy
> +			 * join, since the clients do not actually reside at
> +			 * the originator.
> +			 */
> +			if (subtype != BATADV_P_DAT_CACHE_REPLY) {

Tha patch looks good but this should really be:

			if (subtype == BATADV_P_DATA) {

because speedy join is supposed to work with any payload packet.

Cheers,

> +				orig_addr = unicast_4addr_packet->src;
> +				orig_node = batadv_orig_hash_find(bat_priv,
> +								  orig_addr);
> +			}
>  		}
>  
>  		if (batadv_dat_snoop_incoming_arp_request(bat_priv, skb,
>
  
Simon Wunderlich Aug. 25, 2015, 3:24 p.m. UTC | #2
Hi Antonio,

On Tuesday 25 August 2015 11:42:05 Antonio Quartulli wrote:
> On 21/08/15 17:15, Simon Wunderlich wrote:
> > +			/* Cache replies should not be considered for speedy
> > +			 * join, since the clients do not actually reside at
> > +			 * the originator.
> > +			 */
> > +			if (subtype != BATADV_P_DAT_CACHE_REPLY) {
> 
> Tha patch looks good but this should really be:
> 
> 			if (subtype == BATADV_P_DATA) {
> 
> because speedy join is supposed to work with any payload packet.
> 

OK, will make that change in PATCH v2.

Thanks,
   Simon
  

Patch

diff --git a/net/batman-adv/routing.c b/net/batman-adv/routing.c
index c360c0c..f2779b6 100644
--- a/net/batman-adv/routing.c
+++ b/net/batman-adv/routing.c
@@ -836,6 +836,7 @@  int batadv_recv_unicast_packet(struct sk_buff *skb,
 	uint8_t *orig_addr;
 	struct batadv_orig_node *orig_node = NULL;
 	int check, hdr_size = sizeof(*unicast_packet);
+	enum batadv_subtype subtype;
 	bool is4addr;
 
 	unicast_packet = (struct batadv_unicast_packet *)skb->data;
@@ -863,10 +864,18 @@  int batadv_recv_unicast_packet(struct sk_buff *skb,
 	/* packet for me */
 	if (batadv_is_my_mac(bat_priv, unicast_packet->dest)) {
 		if (is4addr) {
-			batadv_dat_inc_counter(bat_priv,
-					       unicast_4addr_packet->subtype);
-			orig_addr = unicast_4addr_packet->src;
-			orig_node = batadv_orig_hash_find(bat_priv, orig_addr);
+			subtype = unicast_4addr_packet->subtype;
+			batadv_dat_inc_counter(bat_priv, subtype);
+
+			/* Cache replies should not be considered for speedy
+			 * join, since the clients do not actually reside at
+			 * the originator.
+			 */
+			if (subtype != BATADV_P_DAT_CACHE_REPLY) {
+				orig_addr = unicast_4addr_packet->src;
+				orig_node = batadv_orig_hash_find(bat_priv,
+								  orig_addr);
+			}
 		}
 
 		if (batadv_dat_snoop_incoming_arp_request(bat_priv, skb,