From: Antonio Quartulli <antonio@meshcoding.com>
To: b.a.t.m.a.n@lists.open-mesh.org
Cc: Antonio Quartulli <antonio@open-mesh.com>
Subject: [B.A.T.M.A.N.] [PATCHv2 3/4] batman-adv: improve the TT component to support runtime flag changes
Date: Sun, 13 Oct 2013 02:50:19 +0200 [thread overview]
Message-ID: <1381625420-4062-4-git-send-email-antonio@meshcoding.com> (raw)
In-Reply-To: <1381625420-4062-1-git-send-email-antonio@meshcoding.com>
From: Antonio Quartulli <antonio@open-mesh.com>
Some flags (i.e. the WIFI flag) may change after that the
related client has already been announced. However it is
useful to informa the rest of the network about this change.
Add a runtime-flag-switch detection mechanism and
re-announce the related TT entry to advertise the new flag
value.
This mechanism can be easily exploited by future flags that
may need the same treatment.
Signed-off-by: Antonio Quartulli <antonio@open-mesh.com>
---
packet.h | 6 ++++++
translation-table.c | 25 ++++++++++++++++++++++++-
2 files changed, 30 insertions(+), 1 deletion(-)
diff --git a/packet.h b/packet.h
index f4bbb05..bf4c91f 100644
--- a/packet.h
+++ b/packet.h
@@ -123,6 +123,12 @@ enum batadv_tt_client_flags {
};
/**
+ * BATADV_TT_REMOTE_MASK - bitmask selecting the flags that are sent over the
+ * wire only
+ */
+#define BATADV_TT_REMOTE_MASK 0x00FF
+
+/**
* batadv_vlan_flags - flags for the four MSB of any vlan ID field
* @BATADV_VLAN_HAS_TAG: whether the field contains a valid vlan tag or not
*/
diff --git a/translation-table.c b/translation-table.c
index a0f31cf..4212e9a 100644
--- a/translation-table.c
+++ b/translation-table.c
@@ -358,6 +358,13 @@ static void batadv_tt_local_event(struct batadv_priv *bat_priv,
goto del;
if (del_op_requested && !del_op_entry)
goto del;
+
+ /* this is a second add in the same originator interval. It
+ * means that flags have been changed: update them!
+ */
+ if (!del_op_requested && !del_op_entry)
+ entry->change.flags = flags;
+
continue;
del:
list_del(&entry->list);
@@ -482,6 +489,7 @@ bool batadv_tt_local_add(struct net_device *soft_iface, const uint8_t *addr,
struct batadv_tt_orig_list_entry *orig_entry;
int hash_added, table_size, packet_size_max;
bool ret = false, roamed_back = false;
+ uint8_t remote_flags;
if (ifindex != BATADV_NULL_IFINDEX)
in_dev = dev_get_by_index(&init_net, ifindex);
@@ -596,8 +604,23 @@ check_roaming:
}
}
- ret = true;
+ /* store the current remote flags before altering them. This helps
+ * understanding is flags are changing or not
+ */
+ remote_flags = tt_local->common.flags & BATADV_TT_REMOTE_MASK;
+
+ if (batadv_is_wifi_netdev(in_dev))
+ tt_local->common.flags |= BATADV_TT_CLIENT_WIFI;
+ else
+ tt_local->common.flags &= ~BATADV_TT_CLIENT_WIFI;
+ /* if any "dynamic" flag has been modified, resend an ADD event for this
+ * entry so that all the nodes can get the new flags
+ */
+ if (remote_flags ^ (tt_local->common.flags & BATADV_TT_REMOTE_MASK))
+ batadv_tt_local_event(bat_priv, tt_local, BATADV_NO_FLAGS);
+
+ ret = true;
out:
if (in_dev)
dev_put(in_dev);
--
1.8.3.2
next prev parent reply other threads:[~2013-10-13 0:50 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-10-13 0:50 [B.A.T.M.A.N.] [PATCHv2 0/4] Introduce the SYNCHRONIZED TT flags Antonio Quartulli
2013-10-13 0:50 ` [B.A.T.M.A.N.] [PATCHv2 1/4] batman-adv: don't switch byte order too often if not needed Antonio Quartulli
2013-10-13 9:44 ` Marek Lindner
2013-10-13 9:51 ` Antonio Quartulli
2013-10-14 11:07 ` Marek Lindner
2013-10-13 0:50 ` [B.A.T.M.A.N.] [PATCHv2 2/4] batman-adv: invoke dev_get_by_index() outside of is_wifi_iface() Antonio Quartulli
2013-10-14 13:20 ` Marek Lindner
2013-10-13 0:50 ` Antonio Quartulli [this message]
2013-10-14 11:22 ` [B.A.T.M.A.N.] [PATCHv2 3/4] batman-adv: improve the TT component to support runtime flag changes Marek Lindner
2013-10-13 0:50 ` [B.A.T.M.A.N.] [PATCHv2 4/4] batman-adv: include the synch-flags when compute the global/local table CRC Antonio Quartulli
2013-10-14 14:37 ` 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=1381625420-4062-4-git-send-email-antonio@meshcoding.com \
--to=antonio@meshcoding.com \
--cc=antonio@open-mesh.com \
--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