From patchwork Wed Aug 24 13:00:35 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Lindner X-Patchwork-Id: 1248 Return-Path: Received: from nm2-vm0.bullet.mail.ukl.yahoo.com (nm2-vm0.bullet.mail.ukl.yahoo.com [217.146.183.226]) by open-mesh.org (Postfix) with SMTP id 9E71A60084E for ; Wed, 24 Aug 2011 15:01:06 +0200 (CEST) Authentication-Results: open-mesh.org; dkim=pass (1024-bit key) header.i=@yahoo.de; dkim-adsp=none Received: from [217.146.183.213] by nm2.bullet.mail.ukl.yahoo.com with NNFMP; 24 Aug 2011 13:01:06 -0000 Received: from [77.238.184.72] by tm6.bullet.mail.ukl.yahoo.com with NNFMP; 24 Aug 2011 13:01:06 -0000 Received: from [127.0.0.1] by smtp141.mail.ukl.yahoo.com with NNFMP; 24 Aug 2011 13:01:06 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.de; s=s1024; t=1314190866; bh=mqZMPlRTOTsb1T8/oOH8jlRjh9ZblM1QEsLkG0mqPa8=; h=X-Yahoo-Newman-Id:X-Yahoo-Newman-Property:X-YMail-OSG:X-Yahoo-SMTP:Received:From:To:Cc:Subject:Date:Message-Id:X-Mailer:In-Reply-To:References; b=L8n0J86p91BQUONjpP7Jznexj165xIcPNXtoomtkS1QmJLA0/sEE3zWzJW58WpgsYphy0PjPjLvM6A2WjoLPiOChz3uOgD+7zCHQqk33MEtUJuyloUxbQ3KCE43ijr4dwnPtYfF4+Qln2RSNEgLFY/Xm7u4k+Aham4oOGyaBUR8= X-Yahoo-Newman-Id: 465243.71112.bm@smtp141.mail.ukl.yahoo.com X-Yahoo-Newman-Property: ymail-3 X-YMail-OSG: i8ozrcsVM1l5yFx0SqqbfM_1lElaFDDcxPaQ7GJ_q3GwFxo tKeuFrPxvZlmJpfAerLEJEIbN0TvfSrsb_.8GTwtEJVSJaITFyV9rvI_VIlM _IcvBBX0KVU2du4sD347LlbIz4OhXi6hevbRIv1BLXBxlIknnClgjNkSiXIj .L9VEJpbLseQG8kqhL3R_qDqIJx.Kvr7_1Jy8T1egohR1pexoBlh2xy6h8wg UFaFl5o7UyujGvHVrxNhtHuPRHhIkoipVR.oKh7s9a6QXm2E3Y3QnWb2k8yN KBXuMmg1pkjvEoRMIiS77.pU5zEIZaoS6Fk2s324MdvY0pI1cqK7NwQxJKwZ 0wgSHutPUi8mPyLeIrNviSNuUqXeg1Qy39Gm2zaEGe0ScjJuhXWMQbyg- X-Yahoo-SMTP: tW.h3tiswBBMXO2coYcbPigGD5Lt6zY_.Zc- Received: from localhost (lindner_marek@90.61.151.134 with plain) by smtp141.mail.ukl.yahoo.com with SMTP; 24 Aug 2011 13:01:00 +0000 GMT From: Marek Lindner To: davem@davemloft.net Date: Wed, 24 Aug 2011 15:00:35 +0200 Message-Id: <1314190838-2273-6-git-send-email-lindner_marek@yahoo.de> X-Mailer: git-send-email 1.7.5.3 In-Reply-To: <1314190838-2273-1-git-send-email-lindner_marek@yahoo.de> References: <1314190838-2273-1-git-send-email-lindner_marek@yahoo.de> Cc: netdev@vger.kernel.org, b.a.t.m.a.n@lists.open-mesh.org, Marek Lindner Subject: [B.A.T.M.A.N.] [PATCH 5/8] batman-adv: implement AP-isolation on the sender side X-BeenThere: b.a.t.m.a.n@lists.open-mesh.org X-Mailman-Version: 2.1.13 Precedence: list Reply-To: The list for a Better Approach To Mobile Ad-hoc Networking List-Id: The list for a Better Approach To Mobile Ad-hoc Networking List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 24 Aug 2011 13:01:06 -0000 From: Antonio Quartulli 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 Signed-off-by: Marek Lindner --- net/batman-adv/routing.c | 2 +- net/batman-adv/soft-interface.c | 3 ++- net/batman-adv/translation-table.c | 28 +++++++++++++++++++++------- net/batman-adv/translation-table.h | 2 +- net/batman-adv/unicast.c | 6 ++++-- 5 files changed, 29 insertions(+), 12 deletions(-) diff --git a/net/batman-adv/routing.c b/net/batman-adv/routing.c index 13444e9..91a7860 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, 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)) diff --git a/net/batman-adv/soft-interface.c b/net/batman-adv/soft-interface.c index 9addbab..402fd96 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) /* 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); diff --git a/net/batman-adv/translation-table.c b/net/batman-adv/translation-table.c index d0ed931..1f128e1 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, } 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; + 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; } diff --git a/net/batman-adv/translation-table.h b/net/batman-adv/translation-table.h index f1d148e..b47e876 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, 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); diff --git a/net/batman-adv/unicast.c b/net/batman-adv/unicast.c index 32b125f..07d1c1d 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) 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: /**