b.a.t.m.a.n.lists.open-mesh.org archive mirror
 help / color / mirror / Atom feed
From: Simon Wunderlich <sw@simonwunderlich.de>
To: b.a.t.m.a.n@lists.open-mesh.org
Subject: [B.A.T.M.A.N.] [PATCH-maintv3 3/3] batman-adv: detect local excess vlans in TT request
Date: Wed,  2 Sep 2015 20:09:56 +0200	[thread overview]
Message-ID: <1441217396-18043-4-git-send-email-sw@simonwunderlich.de> (raw)
In-Reply-To: <1441217396-18043-1-git-send-email-sw@simonwunderlich.de>

If the local representation of the global TT table of one originator has
more VLAN entries than the respective TT update, there is some
inconsistency present. By detecting and reporting this inconsistency,
the global table gets updated and the excess VLAN will get removed in
the process.

Reported-by: Alessandro Bolletta <alessandro@mediaspot.net>
Signed-off-by: Simon Wunderlich <sw@simonwunderlich.de>
---
Changes to PATCH:
 * count instead of explicitly comparing VLANs, which makes it much
   simpler (thank Antonio)
---
 net/batman-adv/translation-table.c | 14 +++++++++++++-
 1 file changed, 13 insertions(+), 1 deletion(-)

diff --git a/net/batman-adv/translation-table.c b/net/batman-adv/translation-table.c
index f629c21..e7f2998 100644
--- a/net/batman-adv/translation-table.c
+++ b/net/batman-adv/translation-table.c
@@ -2391,8 +2391,8 @@ static bool batadv_tt_global_check_crc(struct batadv_orig_node *orig_node,
 {
 	struct batadv_tvlv_tt_vlan_data *tt_vlan_tmp;
 	struct batadv_orig_node_vlan *vlan;
+	int i, orig_num_vlan;
 	uint32_t crc;
-	int i;
 
 	/* check if each received CRC matches the locally stored one */
 	for (i = 0; i < num_vlan; i++) {
@@ -2418,6 +2418,18 @@ static bool batadv_tt_global_check_crc(struct batadv_orig_node *orig_node,
 			return false;
 	}
 
+	/* check if any excess VLANs exist locally for the originator
+	 * which are not mentioned in the TVLV from the originator.
+	 */
+	rcu_read_lock();
+	orig_num_vlan = 0;
+	list_for_each_entry_rcu(vlan, &orig_node->vlan_list, list)
+		orig_num_vlan++;
+	rcu_read_unlock();
+
+	if (orig_num_vlan > num_vlan)
+		return false;
+
 	return true;
 }
 
-- 
2.5.0


  parent reply	other threads:[~2015-09-02 18:09 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-09-02 18:09 [B.A.T.M.A.N.] [PATCH-maintv3 0/3] Some fixes for DAT/TT/Speedy join corner cases Simon Wunderlich
2015-09-02 18:09 ` [B.A.T.M.A.N.] [PATCH-maintv3 1/3] batman-adv: fix speedy join for DAT cache replies Simon Wunderlich
2015-09-06  8:18   ` Marek Lindner
2015-09-02 18:09 ` [B.A.T.M.A.N.] [PATCH-maintv3 2/3] batman-adv: avoid keeping false temporary entry Simon Wunderlich
2015-09-02 18:11   ` Antonio Quartulli
2015-09-06  8:21     ` Marek Lindner
2015-09-02 18:09 ` Simon Wunderlich [this message]
2015-09-02 18:12   ` [B.A.T.M.A.N.] [PATCH-maintv3 3/3] batman-adv: detect local excess vlans in TT request Antonio Quartulli
2015-09-06  8:24     ` Marek Lindner

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1441217396-18043-4-git-send-email-sw@simonwunderlich.de \
    --to=sw@simonwunderlich.de \
    --cc=b.a.t.m.a.n@lists.open-mesh.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).