aboutsummaryrefslogtreecommitdiffstats
path: root/net/batman-adv
diff options
context:
space:
mode:
authorAntonio Quartulli <antonio@open-mesh.com>2013-10-12 20:50:19 -0400
committerAntonio Quartulli <antonio@meshcoding.com>2013-10-23 11:03:45 -0400
commit3c4f7ab60cc21e8fc65b234f3a6174fc19a93fee (patch)
treec57433819c206083f626c4e7411b67e4898ff17e /net/batman-adv
parent0c69aecc5b1a57d62c39cf8c552a9e823409db60 (diff)
batman-adv: improve the TT component to support runtime flag changes
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> Signed-off-by: Marek Lindner <mareklindner@neomailbox.ch>
Diffstat (limited to 'net/batman-adv')
-rw-r--r--net/batman-adv/translation-table.c25
-rw-r--r--net/batman-adv/types.h6
2 files changed, 30 insertions, 1 deletions
diff --git a/net/batman-adv/translation-table.c b/net/batman-adv/translation-table.c
index b0fe177956ef..267780f4b438 100644
--- a/net/batman-adv/translation-table.c
+++ b/net/batman-adv/translation-table.c
@@ -358,6 +358,13 @@ static void batadv_tt_local_event(struct batadv_priv *bat_priv,
358 goto del; 358 goto del;
359 if (del_op_requested && !del_op_entry) 359 if (del_op_requested && !del_op_entry)
360 goto del; 360 goto del;
361
362 /* this is a second add in the same originator interval. It
363 * means that flags have been changed: update them!
364 */
365 if (!del_op_requested && !del_op_entry)
366 entry->change.flags = flags;
367
361 continue; 368 continue;
362del: 369del:
363 list_del(&entry->list); 370 list_del(&entry->list);
@@ -482,6 +489,7 @@ bool batadv_tt_local_add(struct net_device *soft_iface, const uint8_t *addr,
482 struct batadv_tt_orig_list_entry *orig_entry; 489 struct batadv_tt_orig_list_entry *orig_entry;
483 int hash_added, table_size, packet_size_max; 490 int hash_added, table_size, packet_size_max;
484 bool ret = false, roamed_back = false; 491 bool ret = false, roamed_back = false;
492 uint8_t remote_flags;
485 493
486 if (ifindex != BATADV_NULL_IFINDEX) 494 if (ifindex != BATADV_NULL_IFINDEX)
487 in_dev = dev_get_by_index(&init_net, ifindex); 495 in_dev = dev_get_by_index(&init_net, ifindex);
@@ -596,8 +604,23 @@ check_roaming:
596 } 604 }
597 } 605 }
598 606
599 ret = true; 607 /* store the current remote flags before altering them. This helps
608 * understanding is flags are changing or not
609 */
610 remote_flags = tt_local->common.flags & BATADV_TT_REMOTE_MASK;
611
612 if (batadv_is_wifi_netdev(in_dev))
613 tt_local->common.flags |= BATADV_TT_CLIENT_WIFI;
614 else
615 tt_local->common.flags &= ~BATADV_TT_CLIENT_WIFI;
600 616
617 /* if any "dynamic" flag has been modified, resend an ADD event for this
618 * entry so that all the nodes can get the new flags
619 */
620 if (remote_flags ^ (tt_local->common.flags & BATADV_TT_REMOTE_MASK))
621 batadv_tt_local_event(bat_priv, tt_local, BATADV_NO_FLAGS);
622
623 ret = true;
601out: 624out:
602 if (in_dev) 625 if (in_dev)
603 dev_put(in_dev); 626 dev_put(in_dev);
diff --git a/net/batman-adv/types.h b/net/batman-adv/types.h
index 04b6b0b00af2..61297b6db85e 100644
--- a/net/batman-adv/types.h
+++ b/net/batman-adv/types.h
@@ -36,6 +36,12 @@
36#endif /* CONFIG_BATMAN_ADV_DAT */ 36#endif /* CONFIG_BATMAN_ADV_DAT */
37 37
38/** 38/**
39 * BATADV_TT_REMOTE_MASK - bitmask selecting the flags that are sent over the
40 * wire only
41 */
42#define BATADV_TT_REMOTE_MASK 0x00FF
43
44/**
39 * struct batadv_hard_iface_bat_iv - per hard interface B.A.T.M.A.N. IV data 45 * struct batadv_hard_iface_bat_iv - per hard interface B.A.T.M.A.N. IV data
40 * @ogm_buff: buffer holding the OGM packet 46 * @ogm_buff: buffer holding the OGM packet
41 * @ogm_buff_len: length of the OGM packet buffer 47 * @ogm_buff_len: length of the OGM packet buffer