From patchwork Sun Jun 5 21:01:04 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Antonio Quartulli X-Patchwork-Id: 1178 Return-Path: Received: from confino.investici.org (investici.nine.ch [217.150.252.179]) by open-mesh.org (Postfix) with ESMTPS id 097121544F6 for ; Sun, 5 Jun 2011 23:02:05 +0200 (CEST) Authentication-Results: open-mesh.org; dkim=pass (1024-bit key) header.i=@autistici.org; dkim-adsp=pass Received: from [217.150.252.179] (confino [217.150.252.179]) (Authenticated sender: ordex@autistici.org) by localhost (Postfix) with ESMTPSA id 4B68DC8646; Sun, 5 Jun 2011 21:02:04 +0000 (UTC) X-DKIM: Sendmail DKIM Filter v2.8.2 confino.investici.org 4B68DC8646 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=autistici.org; s=stigmate; t=1307307724; bh=qyGpvd2HdzP7tixVMXqkbFN30O6qjjz2M8KEQcM5+TU=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References; b=QeRXYnR4MXE1aJpXTRtskY2mHxdCJf0WpTM4Hr9JVEcgLmZZNcFyDseGWtAIzjJVh jbHjPqTVlqVZ2qAo3N3dEn2hQUjmlPcNP9448Qq74kTU80UJh7uyKoP1cJtrhr5nym As6/KjIiBKvFA6CG+5Swzls9lyhrBmQjrZT7oEHE= From: Antonio Quartulli To: "B.A.T.M.A.N" Date: Sun, 5 Jun 2011 23:01:04 +0200 Message-Id: <1307307664-19910-4-git-send-email-ordex@autistici.org> X-Mailer: git-send-email 1.7.3.4 In-Reply-To: <1307307664-19910-1-git-send-email-ordex@autistici.org> References: <1307307664-19910-1-git-send-email-ordex@autistici.org> Subject: [B.A.T.M.A.N.] [PATCH 3/3] batman-adv: implement AP-isolation on the receiver 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: Sun, 05 Jun 2011 21:02:05 -0000 When a node receives a unicast packet it checks if the source and the destination client can communicate or not due to the AP isolation Signed-off-by: Antonio Quartulli --- soft-interface.c | 3 +++ translation-table.c | 30 ++++++++++++++++++++++++++++++ translation-table.h | 1 + 3 files changed, 34 insertions(+), 0 deletions(-) diff --git a/soft-interface.c b/soft-interface.c index 6489665..714a2af 100644 --- a/soft-interface.c +++ b/soft-interface.c @@ -733,6 +733,9 @@ void interface_rx(struct net_device *soft_iface, soft_iface->last_rx = jiffies; + if (is_ap_isolated(bat_priv, ethhdr->h_source, ethhdr->h_dest)) + goto dropped; + netif_rx(skb); goto out; diff --git a/translation-table.c b/translation-table.c index e0c5945..24e48e7 100644 --- a/translation-table.c +++ b/translation-table.c @@ -1683,3 +1683,33 @@ void tt_free(struct bat_priv *bat_priv) kfree(bat_priv->tt_buff); } + +bool is_ap_isolated(struct bat_priv *bat_priv, uint8_t *src, uint8_t *dst) +{ + struct tt_local_entry *tt_local_entry = NULL; + struct tt_global_entry *tt_global_entry = NULL; + bool ret = true; + + if (!atomic_read(&bat_priv->ap_isolation)) + return false; + + tt_local_entry = tt_local_hash_find(bat_priv, dst); + if (!tt_local_entry) + goto out; + + tt_global_entry = tt_global_hash_find(bat_priv, src); + if (!tt_global_entry) + goto out; + + if (_is_ap_isolated(tt_local_entry, tt_global_entry)) + goto out; + + ret = false; + +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 ret; +} diff --git a/translation-table.h b/translation-table.h index 3055b8b..8080153 100644 --- a/translation-table.h +++ b/translation-table.h @@ -67,5 +67,6 @@ void handle_tt_response(struct bat_priv *bat_priv, struct tt_query_packet *tt_response); void send_roam_adv(struct bat_priv *bat_priv, uint8_t *client, struct orig_node *orig_node); +bool is_ap_isolated(struct bat_priv *bat_priv, uint8_t *src, uint8_t *dst); #endif /* _NET_BATMAN_ADV_TRANSLATION_TABLE_H_ */