aboutsummaryrefslogtreecommitdiffstats
path: root/net/batman-adv
diff options
context:
space:
mode:
authorAntonio Quartulli <ordex@autistici.org>2011-07-07 09:35:37 -0400
committerMarek Lindner <lindner_marek@yahoo.de>2011-08-22 09:16:21 -0400
commit3d393e47321062dbf9078a66a7cc1c2a52bafecc (patch)
treef8e5675fd58984db15571fdc361655fbe6674241 /net/batman-adv
parent59b699cdee039d75915c354da06937102d1f9a84 (diff)
batman-adv: implement AP-isolation on the sender side
If a node has to send a packet issued by a WIFI client to another WIFI client, the packet is dropped. Signed-off-by: Antonio Quartulli <ordex@autistici.org> Signed-off-by: Marek Lindner <lindner_marek@yahoo.de>
Diffstat (limited to 'net/batman-adv')
-rw-r--r--net/batman-adv/routing.c2
-rw-r--r--net/batman-adv/soft-interface.c3
-rw-r--r--net/batman-adv/translation-table.c28
-rw-r--r--net/batman-adv/translation-table.h2
-rw-r--r--net/batman-adv/unicast.c6
5 files changed, 29 insertions, 12 deletions
diff --git a/net/batman-adv/routing.c b/net/batman-adv/routing.c
index 13444e92bc9..91a7860ecad 100644
--- a/net/batman-adv/routing.c
+++ b/net/batman-adv/routing.c
@@ -1535,7 +1535,7 @@ static int check_unicast_ttvn(struct bat_priv *bat_priv,
1535 1535
1536 ethhdr = (struct ethhdr *)(skb->data + 1536 ethhdr = (struct ethhdr *)(skb->data +
1537 sizeof(struct unicast_packet)); 1537 sizeof(struct unicast_packet));
1538 orig_node = transtable_search(bat_priv, ethhdr->h_dest); 1538 orig_node = transtable_search(bat_priv, NULL, ethhdr->h_dest);
1539 1539
1540 if (!orig_node) { 1540 if (!orig_node) {
1541 if (!is_my_client(bat_priv, ethhdr->h_dest)) 1541 if (!is_my_client(bat_priv, ethhdr->h_dest))
diff --git a/net/batman-adv/soft-interface.c b/net/batman-adv/soft-interface.c
index 9addbab5299..402fd96239d 100644
--- a/net/batman-adv/soft-interface.c
+++ b/net/batman-adv/soft-interface.c
@@ -597,7 +597,8 @@ static int interface_tx(struct sk_buff *skb, struct net_device *soft_iface)
597 /* Register the client MAC in the transtable */ 597 /* Register the client MAC in the transtable */
598 tt_local_add(soft_iface, ethhdr->h_source, skb->skb_iif); 598 tt_local_add(soft_iface, ethhdr->h_source, skb->skb_iif);
599 599
600 orig_node = transtable_search(bat_priv, ethhdr->h_dest); 600 orig_node = transtable_search(bat_priv, ethhdr->h_source,
601 ethhdr->h_dest);
601 if (is_multicast_ether_addr(ethhdr->h_dest) || 602 if (is_multicast_ether_addr(ethhdr->h_dest) ||
602 (orig_node && orig_node->gw_flags)) { 603 (orig_node && orig_node->gw_flags)) {
603 ret = gw_is_target(bat_priv, skb, orig_node); 604 ret = gw_is_target(bat_priv, skb, orig_node);
diff --git a/net/batman-adv/translation-table.c b/net/batman-adv/translation-table.c
index d0ed931ad2e..1f128e1656a 100644
--- a/net/batman-adv/translation-table.c
+++ b/net/batman-adv/translation-table.c
@@ -794,29 +794,43 @@ static bool _is_ap_isolated(struct tt_local_entry *tt_local_entry,
794} 794}
795 795
796struct orig_node *transtable_search(struct bat_priv *bat_priv, 796struct orig_node *transtable_search(struct bat_priv *bat_priv,
797 const uint8_t *addr) 797 const uint8_t *src, const uint8_t *addr)
798{ 798{
799 struct tt_global_entry *tt_global_entry; 799 struct tt_local_entry *tt_local_entry = NULL;
800 struct tt_global_entry *tt_global_entry = NULL;
800 struct orig_node *orig_node = NULL; 801 struct orig_node *orig_node = NULL;
801 802
802 tt_global_entry = tt_global_hash_find(bat_priv, addr); 803 if (src && atomic_read(&bat_priv->ap_isolation)) {
804 tt_local_entry = tt_local_hash_find(bat_priv, src);
805 if (!tt_local_entry)
806 goto out;
807 }
803 808
809 tt_global_entry = tt_global_hash_find(bat_priv, addr);
804 if (!tt_global_entry) 810 if (!tt_global_entry)
805 goto out; 811 goto out;
806 812
813 /* check whether the clients should not communicate due to AP
814 * isolation */
815 if (tt_local_entry && _is_ap_isolated(tt_local_entry, tt_global_entry))
816 goto out;
817
807 if (!atomic_inc_not_zero(&tt_global_entry->orig_node->refcount)) 818 if (!atomic_inc_not_zero(&tt_global_entry->orig_node->refcount))
808 goto free_tt; 819 goto out;
809 820
810 /* A global client marked as PENDING has already moved from that 821 /* A global client marked as PENDING has already moved from that
811 * originator */ 822 * originator */
812 if (tt_global_entry->flags & TT_CLIENT_PENDING) 823 if (tt_global_entry->flags & TT_CLIENT_PENDING)
813 goto free_tt; 824 goto out;
814 825
815 orig_node = tt_global_entry->orig_node; 826 orig_node = tt_global_entry->orig_node;
816 827
817free_tt:
818 tt_global_entry_free_ref(tt_global_entry);
819out: 828out:
829 if (tt_global_entry)
830 tt_global_entry_free_ref(tt_global_entry);
831 if (tt_local_entry)
832 tt_local_entry_free_ref(tt_local_entry);
833
820 return orig_node; 834 return orig_node;
821} 835}
822 836
diff --git a/net/batman-adv/translation-table.h b/net/batman-adv/translation-table.h
index f1d148ef0e3..b47e8760b76 100644
--- a/net/batman-adv/translation-table.h
+++ b/net/batman-adv/translation-table.h
@@ -43,7 +43,7 @@ void tt_global_del(struct bat_priv *bat_priv,
43 struct orig_node *orig_node, const unsigned char *addr, 43 struct orig_node *orig_node, const unsigned char *addr,
44 const char *message, bool roaming); 44 const char *message, bool roaming);
45struct orig_node *transtable_search(struct bat_priv *bat_priv, 45struct orig_node *transtable_search(struct bat_priv *bat_priv,
46 const uint8_t *addr); 46 const uint8_t *src, const uint8_t *addr);
47void tt_save_orig_buffer(struct bat_priv *bat_priv, struct orig_node *orig_node, 47void tt_save_orig_buffer(struct bat_priv *bat_priv, struct orig_node *orig_node,
48 const unsigned char *tt_buff, uint8_t tt_num_changes); 48 const unsigned char *tt_buff, uint8_t tt_num_changes);
49uint16_t tt_local_crc(struct bat_priv *bat_priv); 49uint16_t tt_local_crc(struct bat_priv *bat_priv);
diff --git a/net/batman-adv/unicast.c b/net/batman-adv/unicast.c
index 32b125fb3d3..07d1c1da89d 100644
--- a/net/batman-adv/unicast.c
+++ b/net/batman-adv/unicast.c
@@ -299,8 +299,10 @@ int unicast_send_skb(struct sk_buff *skb, struct bat_priv *bat_priv)
299 goto find_router; 299 goto find_router;
300 } 300 }
301 301
302 /* check for tt host - increases orig_node refcount */ 302 /* check for tt host - increases orig_node refcount.
303 orig_node = transtable_search(bat_priv, ethhdr->h_dest); 303 * returns NULL in case of AP isolation */
304 orig_node = transtable_search(bat_priv, ethhdr->h_source,
305 ethhdr->h_dest);
304 306
305find_router: 307find_router:
306 /** 308 /**