aboutsummaryrefslogtreecommitdiffstats
path: root/net/batman-adv
diff options
context:
space:
mode:
authorMarek Lindner <lindner_marek@yahoo.de>2013-04-23 09:39:59 -0400
committerAntonio Quartulli <antonio@meshcoding.com>2013-10-09 15:22:27 -0400
commit17cf0ea455f1a4a7e8436ef96236999e9c452a93 (patch)
tree86b0a10dc27b3c32f27c13f15bc3e43291cacca9 /net/batman-adv
parent414254e342a0d58144de40c3da777521ebaeeb07 (diff)
batman-adv: tvlv - add distributed arp table container
Create DAT container to announce DAT capabilities (if enabled). Signed-off-by: Marek Lindner <lindner_marek@yahoo.de> Signed-off-by: Antonio Quartulli <antonio@meshcoding.com>
Diffstat (limited to 'net/batman-adv')
-rw-r--r--net/batman-adv/distributed-arp-table.c64
-rw-r--r--net/batman-adv/distributed-arp-table.h5
-rw-r--r--net/batman-adv/packet.h2
-rw-r--r--net/batman-adv/sysfs.c3
-rw-r--r--net/batman-adv/types.h10
5 files changed, 83 insertions, 1 deletions
diff --git a/net/batman-adv/distributed-arp-table.c b/net/batman-adv/distributed-arp-table.c
index 06345d401588..f07ec320dc01 100644
--- a/net/batman-adv/distributed-arp-table.c
+++ b/net/batman-adv/distributed-arp-table.c
@@ -419,6 +419,10 @@ static bool batadv_is_orig_node_eligible(struct batadv_dat_candidate *res,
419 bool ret = false; 419 bool ret = false;
420 int j; 420 int j;
421 421
422 /* check if orig node candidate is running DAT */
423 if (!(candidate->capabilities & BATADV_ORIG_CAPA_HAS_DAT))
424 goto out;
425
422 /* Check if this node has already been selected... */ 426 /* Check if this node has already been selected... */
423 for (j = 0; j < select; j++) 427 for (j = 0; j < select; j++)
424 if (res[j].orig_node == candidate) 428 if (res[j].orig_node == candidate)
@@ -626,6 +630,59 @@ out:
626} 630}
627 631
628/** 632/**
633 * batadv_dat_tvlv_container_update - update the dat tvlv container after dat
634 * setting change
635 * @bat_priv: the bat priv with all the soft interface information
636 */
637static void batadv_dat_tvlv_container_update(struct batadv_priv *bat_priv)
638{
639 char dat_mode;
640
641 dat_mode = atomic_read(&bat_priv->distributed_arp_table);
642
643 switch (dat_mode) {
644 case 0:
645 batadv_tvlv_container_unregister(bat_priv, BATADV_TVLV_DAT, 1);
646 break;
647 case 1:
648 batadv_tvlv_container_register(bat_priv, BATADV_TVLV_DAT, 1,
649 NULL, 0);
650 break;
651 }
652}
653
654/**
655 * batadv_dat_status_update - update the dat tvlv container after dat
656 * setting change
657 * @net_dev: the soft interface net device
658 */
659void batadv_dat_status_update(struct net_device *net_dev)
660{
661 struct batadv_priv *bat_priv = netdev_priv(net_dev);
662 batadv_dat_tvlv_container_update(bat_priv);
663}
664
665/**
666 * batadv_gw_tvlv_ogm_handler_v1 - process incoming dat tvlv container
667 * @bat_priv: the bat priv with all the soft interface information
668 * @orig: the orig_node of the ogm
669 * @flags: flags indicating the tvlv state (see batadv_tvlv_handler_flags)
670 * @tvlv_value: tvlv buffer containing the gateway data
671 * @tvlv_value_len: tvlv buffer length
672 */
673static void batadv_dat_tvlv_ogm_handler_v1(struct batadv_priv *bat_priv,
674 struct batadv_orig_node *orig,
675 uint8_t flags,
676 void *tvlv_value,
677 uint16_t tvlv_value_len)
678{
679 if (flags & BATADV_TVLV_HANDLER_OGM_CIFNOTFND)
680 orig->capabilities &= ~BATADV_ORIG_CAPA_HAS_DAT;
681 else
682 orig->capabilities |= BATADV_ORIG_CAPA_HAS_DAT;
683}
684
685/**
629 * batadv_dat_hash_free - free the local DAT hash table 686 * batadv_dat_hash_free - free the local DAT hash table
630 * @bat_priv: the bat priv with all the soft interface information 687 * @bat_priv: the bat priv with all the soft interface information
631 */ 688 */
@@ -657,6 +714,10 @@ int batadv_dat_init(struct batadv_priv *bat_priv)
657 714
658 batadv_dat_start_timer(bat_priv); 715 batadv_dat_start_timer(bat_priv);
659 716
717 batadv_tvlv_handler_register(bat_priv, batadv_dat_tvlv_ogm_handler_v1,
718 NULL, BATADV_TVLV_DAT, 1,
719 BATADV_TVLV_HANDLER_OGM_CIFNOTFND);
720 batadv_dat_tvlv_container_update(bat_priv);
660 return 0; 721 return 0;
661} 722}
662 723
@@ -666,6 +727,9 @@ int batadv_dat_init(struct batadv_priv *bat_priv)
666 */ 727 */
667void batadv_dat_free(struct batadv_priv *bat_priv) 728void batadv_dat_free(struct batadv_priv *bat_priv)
668{ 729{
730 batadv_tvlv_container_unregister(bat_priv, BATADV_TVLV_DAT, 1);
731 batadv_tvlv_handler_unregister(bat_priv, BATADV_TVLV_DAT, 1);
732
669 cancel_delayed_work_sync(&bat_priv->dat.work); 733 cancel_delayed_work_sync(&bat_priv->dat.work);
670 734
671 batadv_dat_hash_free(bat_priv); 735 batadv_dat_hash_free(bat_priv);
diff --git a/net/batman-adv/distributed-arp-table.h b/net/batman-adv/distributed-arp-table.h
index 125c8c6fcfad..60d853beb8d8 100644
--- a/net/batman-adv/distributed-arp-table.h
+++ b/net/batman-adv/distributed-arp-table.h
@@ -29,6 +29,7 @@
29 29
30#define BATADV_DAT_ADDR_MAX ((batadv_dat_addr_t)~(batadv_dat_addr_t)0) 30#define BATADV_DAT_ADDR_MAX ((batadv_dat_addr_t)~(batadv_dat_addr_t)0)
31 31
32void batadv_dat_status_update(struct net_device *net_dev);
32bool batadv_dat_snoop_outgoing_arp_request(struct batadv_priv *bat_priv, 33bool batadv_dat_snoop_outgoing_arp_request(struct batadv_priv *bat_priv,
33 struct sk_buff *skb); 34 struct sk_buff *skb);
34bool batadv_dat_snoop_incoming_arp_request(struct batadv_priv *bat_priv, 35bool batadv_dat_snoop_incoming_arp_request(struct batadv_priv *bat_priv,
@@ -98,6 +99,10 @@ static inline void batadv_dat_inc_counter(struct batadv_priv *bat_priv,
98 99
99#else 100#else
100 101
102static inline void batadv_dat_status_update(struct net_device *net_dev)
103{
104}
105
101static inline bool 106static inline bool
102batadv_dat_snoop_outgoing_arp_request(struct batadv_priv *bat_priv, 107batadv_dat_snoop_outgoing_arp_request(struct batadv_priv *bat_priv,
103 struct sk_buff *skb) 108 struct sk_buff *skb)
diff --git a/net/batman-adv/packet.h b/net/batman-adv/packet.h
index 6d0b3a73cee7..8d470b2696ac 100644
--- a/net/batman-adv/packet.h
+++ b/net/batman-adv/packet.h
@@ -121,9 +121,11 @@ enum batadv_bla_claimframe {
121/** 121/**
122 * enum batadv_tvlv_type - tvlv type definitions 122 * enum batadv_tvlv_type - tvlv type definitions
123 * @BATADV_TVLV_GW: gateway tvlv 123 * @BATADV_TVLV_GW: gateway tvlv
124 * @BATADV_TVLV_DAT: distributed arp table tvlv
124 */ 125 */
125enum batadv_tvlv_type { 126enum batadv_tvlv_type {
126 BATADV_TVLV_GW = 0x01, 127 BATADV_TVLV_GW = 0x01,
128 BATADV_TVLV_DAT = 0x02,
127}; 129};
128 130
129/* the destination hardware field in the ARP frame is used to 131/* the destination hardware field in the ARP frame is used to
diff --git a/net/batman-adv/sysfs.c b/net/batman-adv/sysfs.c
index 68793f53f182..e1a826e43210 100644
--- a/net/batman-adv/sysfs.c
+++ b/net/batman-adv/sysfs.c
@@ -425,7 +425,8 @@ BATADV_ATTR_SIF_BOOL(bonding, S_IRUGO | S_IWUSR, NULL);
425BATADV_ATTR_SIF_BOOL(bridge_loop_avoidance, S_IRUGO | S_IWUSR, NULL); 425BATADV_ATTR_SIF_BOOL(bridge_loop_avoidance, S_IRUGO | S_IWUSR, NULL);
426#endif 426#endif
427#ifdef CONFIG_BATMAN_ADV_DAT 427#ifdef CONFIG_BATMAN_ADV_DAT
428BATADV_ATTR_SIF_BOOL(distributed_arp_table, S_IRUGO | S_IWUSR, NULL); 428BATADV_ATTR_SIF_BOOL(distributed_arp_table, S_IRUGO | S_IWUSR,
429 batadv_dat_status_update);
429#endif 430#endif
430BATADV_ATTR_SIF_BOOL(fragmentation, S_IRUGO | S_IWUSR, batadv_update_min_mtu); 431BATADV_ATTR_SIF_BOOL(fragmentation, S_IRUGO | S_IWUSR, batadv_update_min_mtu);
431BATADV_ATTR_SIF_BOOL(ap_isolation, S_IRUGO | S_IWUSR, NULL); 432BATADV_ATTR_SIF_BOOL(ap_isolation, S_IRUGO | S_IWUSR, NULL);
diff --git a/net/batman-adv/types.h b/net/batman-adv/types.h
index b22a04391f6c..35ce83480685 100644
--- a/net/batman-adv/types.h
+++ b/net/batman-adv/types.h
@@ -100,6 +100,7 @@ struct batadv_hard_iface {
100 * @bcast_seqno_reset: time when the broadcast seqno window was reset 100 * @bcast_seqno_reset: time when the broadcast seqno window was reset
101 * @batman_seqno_reset: time when the batman seqno window was reset 101 * @batman_seqno_reset: time when the batman seqno window was reset
102 * @flags: for now only VIS_SERVER flag 102 * @flags: for now only VIS_SERVER flag
103 * @capabilities: announced capabilities of this originator
103 * @last_ttvn: last seen translation table version number 104 * @last_ttvn: last seen translation table version number
104 * @tt_crc: CRC of the translation table 105 * @tt_crc: CRC of the translation table
105 * @tt_buff: last tt changeset this node received from the orig node 106 * @tt_buff: last tt changeset this node received from the orig node
@@ -147,6 +148,7 @@ struct batadv_orig_node {
147 unsigned long bcast_seqno_reset; 148 unsigned long bcast_seqno_reset;
148 unsigned long batman_seqno_reset; 149 unsigned long batman_seqno_reset;
149 uint8_t flags; 150 uint8_t flags;
151 uint8_t capabilities;
150 atomic_t last_ttvn; 152 atomic_t last_ttvn;
151 uint16_t tt_crc; 153 uint16_t tt_crc;
152 unsigned char *tt_buff; 154 unsigned char *tt_buff;
@@ -184,6 +186,14 @@ struct batadv_orig_node {
184}; 186};
185 187
186/** 188/**
189 * enum batadv_orig_capabilities - orig node capabilities
190 * @BATADV_ORIG_CAPA_HAS_DAT: orig node has distributed arp table enabled
191 */
192enum batadv_orig_capabilities {
193 BATADV_ORIG_CAPA_HAS_DAT = BIT(0),
194};
195
196/**
187 * struct batadv_gw_node - structure for orig nodes announcing gw capabilities 197 * struct batadv_gw_node - structure for orig nodes announcing gw capabilities
188 * @list: list node for batadv_priv_gw::list 198 * @list: list node for batadv_priv_gw::list
189 * @orig_node: pointer to corresponding orig node 199 * @orig_node: pointer to corresponding orig node