diff options
author | Antonio Quartulli <ordex@autistici.org> | 2012-08-08 12:50:57 -0400 |
---|---|---|
committer | Antonio Quartulli <ordex@autistici.org> | 2012-11-07 14:00:22 -0500 |
commit | 33af49ad8ae44de52c0ac30b1a9707dad5e4c418 (patch) | |
tree | 8534639935a6962d862d88d7e18a4586ced67951 /net/batman-adv | |
parent | 172244748204c894864def59133d0133ccfabe30 (diff) |
batman-adv: Distributed ARP Table - add runtime switch
This patch adds a runtime switch that enables the user to turn the DAT feature
on or off at runtime
Signed-off-by: Antonio Quartulli <ordex@autistici.org>
Diffstat (limited to 'net/batman-adv')
-rw-r--r-- | net/batman-adv/distributed-arp-table.c | 18 | ||||
-rw-r--r-- | net/batman-adv/soft-interface.c | 3 | ||||
-rw-r--r-- | net/batman-adv/sysfs.c | 7 | ||||
-rw-r--r-- | net/batman-adv/types.h | 3 |
4 files changed, 31 insertions, 0 deletions
diff --git a/net/batman-adv/distributed-arp-table.c b/net/batman-adv/distributed-arp-table.c index f43bf8e4a2b7..c1a74a126f58 100644 --- a/net/batman-adv/distributed-arp-table.c +++ b/net/batman-adv/distributed-arp-table.c | |||
@@ -621,6 +621,9 @@ out: | |||
621 | */ | 621 | */ |
622 | static void batadv_dat_hash_free(struct batadv_priv *bat_priv) | 622 | static void batadv_dat_hash_free(struct batadv_priv *bat_priv) |
623 | { | 623 | { |
624 | if (!bat_priv->dat.hash) | ||
625 | return; | ||
626 | |||
624 | __batadv_dat_purge(bat_priv, NULL); | 627 | __batadv_dat_purge(bat_priv, NULL); |
625 | 628 | ||
626 | batadv_hash_destroy(bat_priv->dat.hash); | 629 | batadv_hash_destroy(bat_priv->dat.hash); |
@@ -790,6 +793,9 @@ bool batadv_dat_snoop_outgoing_arp_request(struct batadv_priv *bat_priv, | |||
790 | struct sk_buff *skb_new; | 793 | struct sk_buff *skb_new; |
791 | struct batadv_hard_iface *primary_if = NULL; | 794 | struct batadv_hard_iface *primary_if = NULL; |
792 | 795 | ||
796 | if (!atomic_read(&bat_priv->distributed_arp_table)) | ||
797 | goto out; | ||
798 | |||
793 | type = batadv_arp_get_type(bat_priv, skb, 0); | 799 | type = batadv_arp_get_type(bat_priv, skb, 0); |
794 | /* If the node gets an ARP_REQUEST it has to send a DHT_GET unicast | 800 | /* If the node gets an ARP_REQUEST it has to send a DHT_GET unicast |
795 | * message to the selected DHT candidates | 801 | * message to the selected DHT candidates |
@@ -861,6 +867,9 @@ bool batadv_dat_snoop_incoming_arp_request(struct batadv_priv *bat_priv, | |||
861 | bool ret = false; | 867 | bool ret = false; |
862 | int err; | 868 | int err; |
863 | 869 | ||
870 | if (!atomic_read(&bat_priv->distributed_arp_table)) | ||
871 | goto out; | ||
872 | |||
864 | type = batadv_arp_get_type(bat_priv, skb, hdr_size); | 873 | type = batadv_arp_get_type(bat_priv, skb, hdr_size); |
865 | if (type != ARPOP_REQUEST) | 874 | if (type != ARPOP_REQUEST) |
866 | goto out; | 875 | goto out; |
@@ -924,6 +933,9 @@ void batadv_dat_snoop_outgoing_arp_reply(struct batadv_priv *bat_priv, | |||
924 | __be32 ip_src, ip_dst; | 933 | __be32 ip_src, ip_dst; |
925 | uint8_t *hw_src, *hw_dst; | 934 | uint8_t *hw_src, *hw_dst; |
926 | 935 | ||
936 | if (!atomic_read(&bat_priv->distributed_arp_table)) | ||
937 | return; | ||
938 | |||
927 | type = batadv_arp_get_type(bat_priv, skb, 0); | 939 | type = batadv_arp_get_type(bat_priv, skb, 0); |
928 | if (type != ARPOP_REPLY) | 940 | if (type != ARPOP_REPLY) |
929 | return; | 941 | return; |
@@ -959,6 +971,9 @@ bool batadv_dat_snoop_incoming_arp_reply(struct batadv_priv *bat_priv, | |||
959 | uint8_t *hw_src, *hw_dst; | 971 | uint8_t *hw_src, *hw_dst; |
960 | bool ret = false; | 972 | bool ret = false; |
961 | 973 | ||
974 | if (!atomic_read(&bat_priv->distributed_arp_table)) | ||
975 | goto out; | ||
976 | |||
962 | type = batadv_arp_get_type(bat_priv, skb, hdr_size); | 977 | type = batadv_arp_get_type(bat_priv, skb, hdr_size); |
963 | if (type != ARPOP_REPLY) | 978 | if (type != ARPOP_REPLY) |
964 | goto out; | 979 | goto out; |
@@ -1003,6 +1018,9 @@ bool batadv_dat_drop_broadcast_packet(struct batadv_priv *bat_priv, | |||
1003 | bool ret = false; | 1018 | bool ret = false; |
1004 | const size_t bcast_len = sizeof(struct batadv_bcast_packet); | 1019 | const size_t bcast_len = sizeof(struct batadv_bcast_packet); |
1005 | 1020 | ||
1021 | if (!atomic_read(&bat_priv->distributed_arp_table)) | ||
1022 | goto out; | ||
1023 | |||
1006 | /* If this packet is an ARP_REQUEST and the node already has the | 1024 | /* If this packet is an ARP_REQUEST and the node already has the |
1007 | * information that it is going to ask, then the packet can be dropped | 1025 | * information that it is going to ask, then the packet can be dropped |
1008 | */ | 1026 | */ |
diff --git a/net/batman-adv/soft-interface.c b/net/batman-adv/soft-interface.c index 9dc0ae1d4da3..7b4a3a3d9dd5 100644 --- a/net/batman-adv/soft-interface.c +++ b/net/batman-adv/soft-interface.c | |||
@@ -480,6 +480,9 @@ struct net_device *batadv_softif_create(const char *name) | |||
480 | atomic_set(&bat_priv->aggregated_ogms, 1); | 480 | atomic_set(&bat_priv->aggregated_ogms, 1); |
481 | atomic_set(&bat_priv->bonding, 0); | 481 | atomic_set(&bat_priv->bonding, 0); |
482 | atomic_set(&bat_priv->bridge_loop_avoidance, 0); | 482 | atomic_set(&bat_priv->bridge_loop_avoidance, 0); |
483 | #ifdef CONFIG_BATMAN_ADV_DAT | ||
484 | atomic_set(&bat_priv->distributed_arp_table, 1); | ||
485 | #endif | ||
483 | atomic_set(&bat_priv->ap_isolation, 0); | 486 | atomic_set(&bat_priv->ap_isolation, 0); |
484 | atomic_set(&bat_priv->vis_mode, BATADV_VIS_TYPE_CLIENT_UPDATE); | 487 | atomic_set(&bat_priv->vis_mode, BATADV_VIS_TYPE_CLIENT_UPDATE); |
485 | atomic_set(&bat_priv->gw_mode, BATADV_GW_MODE_OFF); | 488 | atomic_set(&bat_priv->gw_mode, BATADV_GW_MODE_OFF); |
diff --git a/net/batman-adv/sysfs.c b/net/batman-adv/sysfs.c index 42cd09e24c5f..fa3cc1af0918 100644 --- a/net/batman-adv/sysfs.c +++ b/net/batman-adv/sysfs.c | |||
@@ -20,6 +20,7 @@ | |||
20 | #include "main.h" | 20 | #include "main.h" |
21 | #include "sysfs.h" | 21 | #include "sysfs.h" |
22 | #include "translation-table.h" | 22 | #include "translation-table.h" |
23 | #include "distributed-arp-table.h" | ||
23 | #include "originator.h" | 24 | #include "originator.h" |
24 | #include "hard-interface.h" | 25 | #include "hard-interface.h" |
25 | #include "gateway_common.h" | 26 | #include "gateway_common.h" |
@@ -420,6 +421,9 @@ BATADV_ATTR_SIF_BOOL(bonding, S_IRUGO | S_IWUSR, NULL); | |||
420 | #ifdef CONFIG_BATMAN_ADV_BLA | 421 | #ifdef CONFIG_BATMAN_ADV_BLA |
421 | BATADV_ATTR_SIF_BOOL(bridge_loop_avoidance, S_IRUGO | S_IWUSR, NULL); | 422 | BATADV_ATTR_SIF_BOOL(bridge_loop_avoidance, S_IRUGO | S_IWUSR, NULL); |
422 | #endif | 423 | #endif |
424 | #ifdef CONFIG_BATMAN_ADV_DAT | ||
425 | BATADV_ATTR_SIF_BOOL(distributed_arp_table, S_IRUGO | S_IWUSR, NULL); | ||
426 | #endif | ||
423 | BATADV_ATTR_SIF_BOOL(fragmentation, S_IRUGO | S_IWUSR, batadv_update_min_mtu); | 427 | BATADV_ATTR_SIF_BOOL(fragmentation, S_IRUGO | S_IWUSR, batadv_update_min_mtu); |
424 | BATADV_ATTR_SIF_BOOL(ap_isolation, S_IRUGO | S_IWUSR, NULL); | 428 | BATADV_ATTR_SIF_BOOL(ap_isolation, S_IRUGO | S_IWUSR, NULL); |
425 | static BATADV_ATTR(vis_mode, S_IRUGO | S_IWUSR, batadv_show_vis_mode, | 429 | static BATADV_ATTR(vis_mode, S_IRUGO | S_IWUSR, batadv_show_vis_mode, |
@@ -445,6 +449,9 @@ static struct batadv_attribute *batadv_mesh_attrs[] = { | |||
445 | #ifdef CONFIG_BATMAN_ADV_BLA | 449 | #ifdef CONFIG_BATMAN_ADV_BLA |
446 | &batadv_attr_bridge_loop_avoidance, | 450 | &batadv_attr_bridge_loop_avoidance, |
447 | #endif | 451 | #endif |
452 | #ifdef CONFIG_BATMAN_ADV_DAT | ||
453 | &batadv_attr_distributed_arp_table, | ||
454 | #endif | ||
448 | &batadv_attr_fragmentation, | 455 | &batadv_attr_fragmentation, |
449 | &batadv_attr_ap_isolation, | 456 | &batadv_attr_ap_isolation, |
450 | &batadv_attr_vis_mode, | 457 | &batadv_attr_vis_mode, |
diff --git a/net/batman-adv/types.h b/net/batman-adv/types.h index 00d3093f3a9c..0afeb2b43f70 100644 --- a/net/batman-adv/types.h +++ b/net/batman-adv/types.h | |||
@@ -275,6 +275,9 @@ struct batadv_priv { | |||
275 | atomic_t fragmentation; /* boolean */ | 275 | atomic_t fragmentation; /* boolean */ |
276 | atomic_t ap_isolation; /* boolean */ | 276 | atomic_t ap_isolation; /* boolean */ |
277 | atomic_t bridge_loop_avoidance; /* boolean */ | 277 | atomic_t bridge_loop_avoidance; /* boolean */ |
278 | #ifdef CONFIG_BATMAN_ADV_DAT | ||
279 | atomic_t distributed_arp_table; /* boolean */ | ||
280 | #endif | ||
278 | atomic_t vis_mode; /* VIS_TYPE_* */ | 281 | atomic_t vis_mode; /* VIS_TYPE_* */ |
279 | atomic_t gw_mode; /* GW_MODE_* */ | 282 | atomic_t gw_mode; /* GW_MODE_* */ |
280 | atomic_t gw_sel_class; /* uint */ | 283 | atomic_t gw_sel_class; /* uint */ |