]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
batman-adv: implement AP-isolation on the sender side
authorAntonio Quartulli <ordex@autistici.org>
Thu, 7 Jul 2011 13:35:37 +0000 (15:35 +0200)
committerMarek Lindner <lindner_marek@yahoo.de>
Mon, 22 Aug 2011 13:16:21 +0000 (15:16 +0200)
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>
net/batman-adv/routing.c
net/batman-adv/soft-interface.c
net/batman-adv/translation-table.c
net/batman-adv/translation-table.h
net/batman-adv/unicast.c

index 13444e92bc99c9d3acef469be562e980d3469d2d..91a7860ecadd04095162796b9339cd5c60f4d8ef 100644 (file)
@@ -1535,7 +1535,7 @@ static int check_unicast_ttvn(struct bat_priv *bat_priv,
 
                ethhdr = (struct ethhdr *)(skb->data +
                        sizeof(struct unicast_packet));
-               orig_node = transtable_search(bat_priv, ethhdr->h_dest);
+               orig_node = transtable_search(bat_priv, NULL, ethhdr->h_dest);
 
                if (!orig_node) {
                        if (!is_my_client(bat_priv, ethhdr->h_dest))
index 9addbab529995803a38ed28573dcada9e01c5499..402fd96239d8387f9555b24a654ed9ba246fd88e 100644 (file)
@@ -597,7 +597,8 @@ static int interface_tx(struct sk_buff *skb, struct net_device *soft_iface)
        /* Register the client MAC in the transtable */
        tt_local_add(soft_iface, ethhdr->h_source, skb->skb_iif);
 
-       orig_node = transtable_search(bat_priv, ethhdr->h_dest);
+       orig_node = transtable_search(bat_priv, ethhdr->h_source,
+                                     ethhdr->h_dest);
        if (is_multicast_ether_addr(ethhdr->h_dest) ||
                                (orig_node && orig_node->gw_flags)) {
                ret = gw_is_target(bat_priv, skb, orig_node);
index d0ed931ad2e7f79ad5866375f3fed1128d58da34..1f128e1656a7d26e79b389d40019d8fbec4c5c44 100644 (file)
@@ -794,29 +794,43 @@ static bool _is_ap_isolated(struct tt_local_entry *tt_local_entry,
 }
 
 struct orig_node *transtable_search(struct bat_priv *bat_priv,
-                                   const uint8_t *addr)
+                                   const uint8_t *src, const uint8_t *addr)
 {
-       struct tt_global_entry *tt_global_entry;
+       struct tt_local_entry *tt_local_entry = NULL;
+       struct tt_global_entry *tt_global_entry = NULL;
        struct orig_node *orig_node = NULL;
 
-       tt_global_entry = tt_global_hash_find(bat_priv, addr);
+       if (src && atomic_read(&bat_priv->ap_isolation)) {
+               tt_local_entry = tt_local_hash_find(bat_priv, src);
+               if (!tt_local_entry)
+                       goto out;
+       }
 
+       tt_global_entry = tt_global_hash_find(bat_priv, addr);
        if (!tt_global_entry)
                goto out;
 
+       /* check whether the clients should not communicate due to AP
+        * isolation */
+       if (tt_local_entry && _is_ap_isolated(tt_local_entry, tt_global_entry))
+               goto out;
+
        if (!atomic_inc_not_zero(&tt_global_entry->orig_node->refcount))
-               goto free_tt;
+               goto out;
 
        /* A global client marked as PENDING has already moved from that
         * originator */
        if (tt_global_entry->flags & TT_CLIENT_PENDING)
-               goto free_tt;
+               goto out;
 
        orig_node = tt_global_entry->orig_node;
 
-free_tt:
-       tt_global_entry_free_ref(tt_global_entry);
 out:
+       if (tt_global_entry)
+               tt_global_entry_free_ref(tt_global_entry);
+       if (tt_local_entry)
+               tt_local_entry_free_ref(tt_local_entry);
+
        return orig_node;
 }
 
index f1d148ef0e369d8f08b0d195498e2c1668c491f3..b47e8760b76b84e3ce6ccbc44a69f8d9a067c23f 100644 (file)
@@ -43,7 +43,7 @@ void tt_global_del(struct bat_priv *bat_priv,
                   struct orig_node *orig_node, const unsigned char *addr,
                   const char *message, bool roaming);
 struct orig_node *transtable_search(struct bat_priv *bat_priv,
-                                   const uint8_t *addr);
+                                   const uint8_t *src, const uint8_t *addr);
 void tt_save_orig_buffer(struct bat_priv *bat_priv, struct orig_node *orig_node,
                         const unsigned char *tt_buff, uint8_t tt_num_changes);
 uint16_t tt_local_crc(struct bat_priv *bat_priv);
index 32b125fb3d3b65ce07d7b83ad5b574257b0cd250..07d1c1da89dde625a7c42a64ba0f5fa5694b491c 100644 (file)
@@ -299,8 +299,10 @@ int unicast_send_skb(struct sk_buff *skb, struct bat_priv *bat_priv)
                        goto find_router;
        }
 
-       /* check for tt host - increases orig_node refcount */
-       orig_node = transtable_search(bat_priv, ethhdr->h_dest);
+       /* check for tt host - increases orig_node refcount.
+        * returns NULL in case of AP isolation */
+       orig_node = transtable_search(bat_priv, ethhdr->h_source,
+                                     ethhdr->h_dest);
 
 find_router:
        /**