[maint,2/4] batman-adv: avoid keeping false temporary entry

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

Commit Message

Simon Wunderlich Aug. 21, 2015, 3:15 p.m. UTC
  In the case when a temporary entry is added first and a proper tt entry
is added after that, the temporary tt entry is kept in the orig list.
However the temporary flag is removed at this point, and therefore the
purge function can not find this temporary entry anymore.

Therefore, remove the previous temp entry before adding the new proper
one.

Reported-by: Alessandro Bolletta <alessandro@mediaspot.net>
Signed-off-by: Simon Wunderlich <sw@simonwunderlich.de>
---
 net/batman-adv/translation-table.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)
  

Comments

Antonio Quartulli Aug. 25, 2015, 9:49 a.m. UTC | #1
On 21/08/15 17:15, Simon Wunderlich wrote:
> In the case when a temporary entry is added first and a proper tt entry
> is added after that, the temporary tt entry is kept in the orig list.
> However the temporary flag is removed at this point, and therefore the
> purge function can not find this temporary entry anymore.
> 
> Therefore, remove the previous temp entry before adding the new proper
> one.
> 

[..]

>  		/* if the client was temporary added before receiving the first
> -		 * OGM announcing it, we have to clear the TEMP flag
> +		 * OGM announcing it, we have to clear the TEMP flag. Also,
> +		 * remove the previous temporary orig node and re-add it
> +		 * if required. If the orig entry changed, the new one which
> +		 * is a non-temporary entry is preferred.
>  		 */
> -		common->flags &= ~BATADV_TT_CLIENT_TEMP;
> +		if (common->flags & BATADV_TT_CLIENT_TEMP) {
> +			batadv_tt_global_del_orig_list(tt_global_entry);
> +			common->flags &= ~BATADV_TT_CLIENT_TEMP;
> +		}

mh...interesting..and nice catch. Have you tested this with a client
roaming from A to B during the "speedy join" period?


Cheers,
  
Simon Wunderlich Aug. 25, 2015, 3:27 p.m. UTC | #2
Hi Antonio,

On Tuesday 25 August 2015 11:49:17 Antonio Quartulli wrote:
> On 21/08/15 17:15, Simon Wunderlich wrote:
> > In the case when a temporary entry is added first and a proper tt entry
> > is added after that, the temporary tt entry is kept in the orig list.
> > However the temporary flag is removed at this point, and therefore the
> > purge function can not find this temporary entry anymore.
> > 
> > Therefore, remove the previous temp entry before adding the new proper
> > one.
> 
> [..]
> 
> >  		/* if the client was temporary added before receiving the first
> > 
> > -		 * OGM announcing it, we have to clear the TEMP flag
> > +		 * OGM announcing it, we have to clear the TEMP flag. Also,
> > +		 * remove the previous temporary orig node and re-add it
> > +		 * if required. If the orig entry changed, the new one which
> > +		 * is a non-temporary entry is preferred.
> > 
> >  		 */
> > 
> > -		common->flags &= ~BATADV_TT_CLIENT_TEMP;
> > +		if (common->flags & BATADV_TT_CLIENT_TEMP) {
> > +			batadv_tt_global_del_orig_list(tt_global_entry);
> > +			common->flags &= ~BATADV_TT_CLIENT_TEMP;
> > +		}
> 
> mh...interesting..and nice catch. Have you tested this with a client
> roaming from A to B during the "speedy join" period?

No I didn't. I've just seen bad entries dangling and never getting cleaned up, 
and suspected that "speedy join" added TT the entry falsely. However, in that 
case it should only have been temporarily and getting removed later, which 
wasn't the case. Therefore this patch ...

I haven't tested this patch on the production network because its very hard to 
reproduce there, and the bug is probably squashed already with the first 
patch.

Thanks for reviewing!
    Simon
  

Patch

diff --git a/net/batman-adv/translation-table.c b/net/batman-adv/translation-table.c
index 7986ec5..f629c21 100644
--- a/net/batman-adv/translation-table.c
+++ b/net/batman-adv/translation-table.c
@@ -1416,9 +1416,15 @@  static bool batadv_tt_global_add(struct batadv_priv *bat_priv,
 		}
 
 		/* if the client was temporary added before receiving the first
-		 * OGM announcing it, we have to clear the TEMP flag
+		 * OGM announcing it, we have to clear the TEMP flag. Also,
+		 * remove the previous temporary orig node and re-add it
+		 * if required. If the orig entry changed, the new one which
+		 * is a non-temporary entry is preferred.
 		 */
-		common->flags &= ~BATADV_TT_CLIENT_TEMP;
+		if (common->flags & BATADV_TT_CLIENT_TEMP) {
+			batadv_tt_global_del_orig_list(tt_global_entry);
+			common->flags &= ~BATADV_TT_CLIENT_TEMP;
+		}
 
 		/* the change can carry possible "attribute" flags like the
 		 * TT_CLIENT_WIFI, therefore they have to be copied in the