All of lore.kernel.org
 help / color / mirror / Atom feed
* [B.A.T.M.A.N.] [PATCHv4 0/3] Implement the AP-Isolation mechanism
@ 2011-07-07 13:35 Antonio Quartulli
  2011-07-07 13:35 ` [B.A.T.M.A.N.] [PATCHv4 1/4] batman-adv: detect clients connected through a 802.11 device Antonio Quartulli
                   ` (3 more replies)
  0 siblings, 4 replies; 9+ messages in thread
From: Antonio Quartulli @ 2011-07-07 13:35 UTC (permalink / raw)
  To: B.A.T.M.A.N

Hi all,

I have to apologise for my mistake. I wrongly sent a different patchset instead
of the ap-isolation one. In this period I'm working on several stuff, including
my thesis and it's easy for me to make such errors.
----

This is the third version of the AP-Isolation patchset.
The patches have been rebased on top of the master branch but they have been
left mostly unmodified.

The Ap-isolation mechanism will prevent (if enabled) WIFI clients to communicate
with other WIFI clients over the mesh network. WIFI check on a client is done
by default while the isolation is performed only if the mechanism is enabled
either on the receiver and on the transmitter side.

Ap-isolation can be enabled or disabled by means of a new sysfs attribute (a
batctl patch has also been provided to toggle interact with it).

Thank you all.

Regards,
	Antonio Quartulli



^ permalink raw reply	[flat|nested] 9+ messages in thread

* [B.A.T.M.A.N.] [PATCHv4 1/4] batman-adv: detect clients connected through a 802.11 device
  2011-07-07 13:35 [B.A.T.M.A.N.] [PATCHv4 0/3] Implement the AP-Isolation mechanism Antonio Quartulli
@ 2011-07-07 13:35 ` Antonio Quartulli
  2011-07-25 20:11   ` Marek Lindner
  2011-07-07 13:35 ` [B.A.T.M.A.N.] [PATCHv4 2/4] batman-adv: implement AP-isolation on the receiver side Antonio Quartulli
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 9+ messages in thread
From: Antonio Quartulli @ 2011-07-07 13:35 UTC (permalink / raw)
  To: B.A.T.M.A.N

Clients connected through a 802.11 device are now marked with the
TT_CLIENT_WIFI flag. This flag is also advertised with the tt
announcement.

Signed-off-by: Antonio Quartulli <ordex@autistici.org>
---
 compat.h            |    2 ++
 hard-interface.c    |   30 ++++++++++++++++++++++++++++++
 hard-interface.h    |    1 +
 main.c              |    2 +-
 main.h              |    2 ++
 packet.h            |    1 +
 routing.c           |    2 +-
 soft-interface.c    |    4 ++--
 translation-table.c |   15 ++++++++++++---
 translation-table.h |    9 +++++----
 10 files changed, 57 insertions(+), 11 deletions(-)

diff --git a/compat.h b/compat.h
index 66a8adc..f1965d0 100644
--- a/compat.h
+++ b/compat.h
@@ -263,6 +263,8 @@ int bat_seq_printf(struct seq_file *m, const char *f, ...);
 
 #define __always_unused			__attribute__((unused))
 
+#define skb_iif iif
+
 #endif /* < KERNEL_VERSION(2, 6, 33) */
 
 #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 34)
diff --git a/hard-interface.c b/hard-interface.c
index db7aacf..f2b6fd9 100644
--- a/hard-interface.c
+++ b/hard-interface.c
@@ -681,6 +681,36 @@ err_out:
 	return NET_RX_DROP;
 }
 
+/* This function returns true if the interface represented by ifindex is a
+ * 802.11 wireless device */
+bool is_wifi_iface(int ifindex)
+{
+	struct net_device *net_device = NULL;
+	bool ret = false;
+
+	if (ifindex == NULL_IFINDEX)
+		goto out;
+
+	net_device = dev_get_by_index(&init_net, ifindex);
+	if (!net_device)
+		goto out;
+
+#ifdef CONFIG_WIRELESS_EXT
+	/* pre-cfg80211 drivers have to implement WEXT, so it is possible to
+	 * check for wireless_handlers != NULL */
+	if (net_device->wireless_handlers)
+		ret = true;
+	else
+#endif
+		/* cfg80211 drivers have to set ieee80211_ptr */
+		if (net_device->ieee80211_ptr)
+			ret = true;
+out:
+	if (net_device)
+		dev_put(net_device);
+	return ret;
+}
+
 struct notifier_block hard_if_notifier = {
 	.notifier_call = hard_if_event,
 };
diff --git a/hard-interface.h b/hard-interface.h
index 442eacb..67f78d1 100644
--- a/hard-interface.h
+++ b/hard-interface.h
@@ -42,6 +42,7 @@ void hardif_remove_interfaces(void);
 int hardif_min_mtu(struct net_device *soft_iface);
 void update_min_mtu(struct net_device *soft_iface);
 void hardif_free_rcu(struct rcu_head *rcu);
+bool is_wifi_iface(int ifindex);
 
 static inline void hardif_free_ref(struct hard_iface *hard_iface)
 {
diff --git a/main.c b/main.c
index b0f9068..79b9ae5 100644
--- a/main.c
+++ b/main.c
@@ -107,7 +107,7 @@ int mesh_init(struct net_device *soft_iface)
 	if (tt_init(bat_priv) < 1)
 		goto err;
 
-	tt_local_add(soft_iface, soft_iface->dev_addr);
+	tt_local_add(soft_iface, soft_iface->dev_addr, NULL_IFINDEX);
 
 	if (vis_init(bat_priv) < 1)
 		goto err;
diff --git a/main.h b/main.h
index 9ee8023..dc38942 100644
--- a/main.h
+++ b/main.h
@@ -62,6 +62,8 @@
 
 #define NO_FLAGS 0
 
+#define NULL_IFINDEX 0 /* dummy ifindex used to avoid iface checks */
+
 #define NUM_WORDS (TQ_LOCAL_WINDOW_SIZE / WORD_BIT_SIZE)
 
 #define LOG_BUF_LEN 8192	  /* has to be a power of 2 */
diff --git a/packet.h b/packet.h
index b76b4be..8802eab 100644
--- a/packet.h
+++ b/packet.h
@@ -84,6 +84,7 @@ enum tt_query_flags {
 enum tt_client_flags {
 	TT_CLIENT_DEL     = 1 << 0,
 	TT_CLIENT_ROAM    = 1 << 1,
+	TT_CLIENT_WIFI    = 1 << 2,
 	TT_CLIENT_NOPURGE = 1 << 8,
 	TT_CLIENT_NEW     = 1 << 9,
 	TT_CLIENT_PENDING = 1 << 10
diff --git a/routing.c b/routing.c
index 0f32c81..0d7c1c2 100644
--- a/routing.c
+++ b/routing.c
@@ -1300,7 +1300,7 @@ int recv_roam_adv(struct sk_buff *skb, struct hard_iface *recv_if)
 		roam_adv_packet->client);
 
 	tt_global_add(bat_priv, orig_node, roam_adv_packet->client,
-		      atomic_read(&orig_node->last_ttvn) + 1, true);
+		      atomic_read(&orig_node->last_ttvn) + 1, true, false);
 
 	/* Roaming phase starts: I have new information but the ttvn has not
 	 * been incremented yet. This flag will make me check all the incoming
diff --git a/soft-interface.c b/soft-interface.c
index 3f20332..48146e5 100644
--- a/soft-interface.c
+++ b/soft-interface.c
@@ -536,7 +536,7 @@ static int interface_set_mac_addr(struct net_device *dev, void *p)
 	if (atomic_read(&bat_priv->mesh_state) == MESH_ACTIVE) {
 		tt_local_remove(bat_priv, dev->dev_addr,
 				"mac address changed", false);
-		tt_local_add(dev, addr->sa_data);
+		tt_local_add(dev, addr->sa_data, NULL_IFINDEX);
 	}
 
 	memcpy(dev->dev_addr, addr->sa_data, ETH_ALEN);
@@ -595,7 +595,7 @@ static int interface_tx(struct sk_buff *skb, struct net_device *soft_iface)
 		goto dropped;
 
 	/* Register the client MAC in the transtable */
-	tt_local_add(soft_iface, ethhdr->h_source);
+	tt_local_add(soft_iface, ethhdr->h_source, skb->skb_iif);
 
 	orig_node = transtable_search(bat_priv, ethhdr->h_dest);
 	if (is_multicast_ether_addr(ethhdr->h_dest) ||
diff --git a/translation-table.c b/translation-table.c
index fb6931d..ad6174d 100644
--- a/translation-table.c
+++ b/translation-table.c
@@ -183,7 +183,8 @@ static int tt_local_init(struct bat_priv *bat_priv)
 	return 1;
 }
 
-void tt_local_add(struct net_device *soft_iface, const uint8_t *addr)
+void tt_local_add(struct net_device *soft_iface, const uint8_t *addr,
+		  int ifindex)
 {
 	struct bat_priv *bat_priv = netdev_priv(soft_iface);
 	struct tt_local_entry *tt_local_entry = NULL;
@@ -207,6 +208,8 @@ void tt_local_add(struct net_device *soft_iface, const uint8_t *addr)
 	memcpy(tt_local_entry->addr, addr, ETH_ALEN);
 	tt_local_entry->last_seen = jiffies;
 	tt_local_entry->flags = NO_FLAGS;
+	if (is_wifi_iface(ifindex))
+		tt_local_entry->flags |= TT_CLIENT_WIFI;
 	atomic_set(&tt_local_entry->refcount, 2);
 
 	/* the batman interface mac address should never be purged */
@@ -495,7 +498,8 @@ static void tt_changes_list_free(struct bat_priv *bat_priv)
 
 /* caller must hold orig_node refcount */
 int tt_global_add(struct bat_priv *bat_priv, struct orig_node *orig_node,
-		  const unsigned char *tt_addr, uint8_t ttvn, bool roaming)
+		  const unsigned char *tt_addr, uint8_t ttvn, bool roaming,
+		  bool wifi)
 {
 	struct tt_global_entry *tt_global_entry;
 	struct orig_node *orig_node_tmp;
@@ -537,6 +541,9 @@ int tt_global_add(struct bat_priv *bat_priv, struct orig_node *orig_node,
 		tt_global_entry->roam_at = 0;
 	}
 
+	if (wifi)
+		tt_global_entry->flags |= TT_CLIENT_WIFI;
+
 	bat_dbg(DBG_TT, bat_priv,
 		"Creating new global tt entry: %pM (via %pM)\n",
 		tt_global_entry->addr, orig_node->orig);
@@ -1363,7 +1370,9 @@ static void _tt_update_changes(struct bat_priv *bat_priv,
 				      (tt_change + i)->flags & TT_CLIENT_ROAM);
 		else
 			if (!tt_global_add(bat_priv, orig_node,
-					   (tt_change + i)->addr, ttvn, false))
+					   (tt_change + i)->addr, ttvn, false,
+					   (tt_change + i)->flags &
+							TT_CLIENT_WIFI))
 				/* In case of problem while storing a
 				 * global_entry, we stop the updating
 				 * procedure without committing the
diff --git a/translation-table.h b/translation-table.h
index d4122cb..8773103 100644
--- a/translation-table.h
+++ b/translation-table.h
@@ -26,15 +26,16 @@ int tt_len(int changes_num);
 int tt_changes_fill_buffer(struct bat_priv *bat_priv,
 			   unsigned char *buff, int buff_len);
 int tt_init(struct bat_priv *bat_priv);
-void tt_local_add(struct net_device *soft_iface, const uint8_t *addr);
+void tt_local_add(struct net_device *soft_iface, const uint8_t *addr,
+		  int ifindex);
 void tt_local_remove(struct bat_priv *bat_priv,
 		     const uint8_t *addr, const char *message, bool roaming);
 int tt_local_seq_print_text(struct seq_file *seq, void *offset);
 void tt_global_add_orig(struct bat_priv *bat_priv, struct orig_node *orig_node,
 			const unsigned char *tt_buff, int tt_buff_len);
-int tt_global_add(struct bat_priv *bat_priv,
-		  struct orig_node *orig_node, const unsigned char *addr,
-		  uint8_t ttvn, bool roaming);
+int tt_global_add(struct bat_priv *bat_priv, struct orig_node *orig_node,
+		  const unsigned char *addr, uint8_t ttvn, bool roaming,
+		  bool wifi);
 int tt_global_seq_print_text(struct seq_file *seq, void *offset);
 void tt_global_del_orig(struct bat_priv *bat_priv,
 			struct orig_node *orig_node, const char *message);
-- 
1.7.3.4


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [B.A.T.M.A.N.] [PATCHv4 2/4] batman-adv: implement AP-isolation on the receiver side
  2011-07-07 13:35 [B.A.T.M.A.N.] [PATCHv4 0/3] Implement the AP-Isolation mechanism Antonio Quartulli
  2011-07-07 13:35 ` [B.A.T.M.A.N.] [PATCHv4 1/4] batman-adv: detect clients connected through a 802.11 device Antonio Quartulli
@ 2011-07-07 13:35 ` Antonio Quartulli
  2011-07-25 20:17   ` Marek Lindner
  2011-07-07 13:35 ` [B.A.T.M.A.N.] [PATCHv4 3/4] batman-adv: implement AP-isolation on the sender side Antonio Quartulli
  2011-07-07 13:35 ` [B.A.T.M.A.N.] [PATCHv4 4/4] batman-adv: print client flags in the local/global transtables output Antonio Quartulli
  3 siblings, 1 reply; 9+ messages in thread
From: Antonio Quartulli @ 2011-07-07 13:35 UTC (permalink / raw)
  To: B.A.T.M.A.N

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 <ordex@autistici.org>
---
 bat_sysfs.c          |    2 ++
 soft-interface.c     |    4 ++++
 sysfs-class-net-mesh |    8 ++++++++
 translation-table.c  |   42 ++++++++++++++++++++++++++++++++++++++++++
 translation-table.h  |    1 +
 types.h              |    1 +
 6 files changed, 58 insertions(+), 0 deletions(-)

diff --git a/bat_sysfs.c b/bat_sysfs.c
index cd15deb..b8a7414 100644
--- a/bat_sysfs.c
+++ b/bat_sysfs.c
@@ -380,6 +380,7 @@ static ssize_t store_gw_bwidth(struct kobject *kobj, struct attribute *attr,
 BAT_ATTR_BOOL(aggregated_ogms, S_IRUGO | S_IWUSR, NULL);
 BAT_ATTR_BOOL(bonding, S_IRUGO | S_IWUSR, NULL);
 BAT_ATTR_BOOL(fragmentation, S_IRUGO | S_IWUSR, update_min_mtu);
+BAT_ATTR_BOOL(ap_isolation, S_IRUGO | S_IWUSR, NULL);
 static BAT_ATTR(vis_mode, S_IRUGO | S_IWUSR, show_vis_mode, store_vis_mode);
 static BAT_ATTR(gw_mode, S_IRUGO | S_IWUSR, show_gw_mode, store_gw_mode);
 BAT_ATTR_UINT(orig_interval, S_IRUGO | S_IWUSR, 2 * JITTER, INT_MAX, NULL);
@@ -396,6 +397,7 @@ static struct bat_attribute *mesh_attrs[] = {
 	&bat_attr_aggregated_ogms,
 	&bat_attr_bonding,
 	&bat_attr_fragmentation,
+	&bat_attr_ap_isolation,
 	&bat_attr_vis_mode,
 	&bat_attr_gw_mode,
 	&bat_attr_orig_interval,
diff --git a/soft-interface.c b/soft-interface.c
index 48146e5..839ded9 100644
--- a/soft-interface.c
+++ b/soft-interface.c
@@ -739,6 +739,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;
 
@@ -823,6 +826,7 @@ struct net_device *softif_create(const char *name)
 
 	atomic_set(&bat_priv->aggregated_ogms, 1);
 	atomic_set(&bat_priv->bonding, 0);
+	atomic_set(&bat_priv->ap_isolation, 0);
 	atomic_set(&bat_priv->vis_mode, VIS_TYPE_CLIENT_UPDATE);
 	atomic_set(&bat_priv->gw_mode, GW_MODE_OFF);
 	atomic_set(&bat_priv->gw_sel_class, 20);
diff --git a/sysfs-class-net-mesh b/sysfs-class-net-mesh
index 748fe17..b020014 100644
--- a/sysfs-class-net-mesh
+++ b/sysfs-class-net-mesh
@@ -22,6 +22,14 @@ Description:
                 mesh will be fragmented or silently discarded if the
                 packet size exceeds the outgoing interface MTU.
 
+What:		/sys/class/net/<mesh_iface>/mesh/ap_isolation
+Date:		May 2011
+Contact:	Antonio Quartulli <ordex@autistici.org>
+Description:
+		Indicates whether the data traffic going from a
+		wireless client to another wireless client will be
+		silently dropped.
+
 What:           /sys/class/net/<mesh_iface>/mesh/gw_bandwidth
 Date:           October 2010
 Contact:        Marek Lindner <lindner_marek@yahoo.de>
diff --git a/translation-table.c b/translation-table.c
index ad6174d..9f0f3f1 100644
--- a/translation-table.c
+++ b/translation-table.c
@@ -781,6 +781,18 @@ static void tt_global_table_free(struct bat_priv *bat_priv)
 	bat_priv->tt_global_hash = NULL;
 }
 
+static bool _is_ap_isolated(struct tt_local_entry *tt_local_entry,
+			    struct tt_global_entry *tt_global_entry)
+{
+	bool ret = false;
+
+	if (tt_local_entry->flags & TT_CLIENT_WIFI &&
+	    tt_global_entry->flags & TT_CLIENT_WIFI)
+		ret = true;
+
+	return ret;
+}
+
 struct orig_node *transtable_search(struct bat_priv *bat_priv,
 				    const uint8_t *addr)
 {
@@ -1729,3 +1741,33 @@ void tt_commit_changes(struct bat_priv *bat_priv)
 	atomic_inc(&bat_priv->ttvn);
 	bat_priv->tt_poss_change = false;
 }
+
+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 8773103..ba2d76d 100644
--- a/translation-table.h
+++ b/translation-table.h
@@ -63,5 +63,6 @@ void handle_tt_response(struct bat_priv *bat_priv,
 void send_roam_adv(struct bat_priv *bat_priv, uint8_t *client,
 		   struct orig_node *orig_node);
 void tt_commit_changes(struct bat_priv *bat_priv);
+bool is_ap_isolated(struct bat_priv *bat_priv, uint8_t *src, uint8_t *dst);
 
 #endif /* _NET_BATMAN_ADV_TRANSLATION_TABLE_H_ */
diff --git a/types.h b/types.h
index 25bd1db..f4b6459 100644
--- a/types.h
+++ b/types.h
@@ -146,6 +146,7 @@ struct bat_priv {
 	atomic_t aggregated_ogms;	/* boolean */
 	atomic_t bonding;		/* boolean */
 	atomic_t fragmentation;		/* boolean */
+	atomic_t ap_isolation;		/* boolean */
 	atomic_t vis_mode;		/* VIS_TYPE_* */
 	atomic_t gw_mode;		/* GW_MODE_* */
 	atomic_t gw_sel_class;		/* uint */
-- 
1.7.3.4


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [B.A.T.M.A.N.] [PATCHv4 3/4] batman-adv: implement AP-isolation on the sender side
  2011-07-07 13:35 [B.A.T.M.A.N.] [PATCHv4 0/3] Implement the AP-Isolation mechanism Antonio Quartulli
  2011-07-07 13:35 ` [B.A.T.M.A.N.] [PATCHv4 1/4] batman-adv: detect clients connected through a 802.11 device Antonio Quartulli
  2011-07-07 13:35 ` [B.A.T.M.A.N.] [PATCHv4 2/4] batman-adv: implement AP-isolation on the receiver side Antonio Quartulli
@ 2011-07-07 13:35 ` Antonio Quartulli
  2011-07-25 20:19   ` Marek Lindner
  2011-07-07 13:35 ` [B.A.T.M.A.N.] [PATCHv4 4/4] batman-adv: print client flags in the local/global transtables output Antonio Quartulli
  3 siblings, 1 reply; 9+ messages in thread
From: Antonio Quartulli @ 2011-07-07 13:35 UTC (permalink / raw)
  To: B.A.T.M.A.N

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>
---
 routing.c           |    2 +-
 soft-interface.c    |    3 ++-
 translation-table.c |   28 +++++++++++++++++++++-------
 translation-table.h |    2 +-
 unicast.c           |    6 ++++--
 5 files changed, 29 insertions(+), 12 deletions(-)

diff --git a/routing.c b/routing.c
index 0d7c1c2..e5dd94d 100644
--- a/routing.c
+++ b/routing.c
@@ -1536,7 +1536,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/soft-interface.c b/soft-interface.c
index 839ded9..ef2fad5 100644
--- a/soft-interface.c
+++ b/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/translation-table.c b/translation-table.c
index 9f0f3f1..0b25fd9 100644
--- a/translation-table.c
+++ b/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;
 
-	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;
 }
 
diff --git a/translation-table.h b/translation-table.h
index ba2d76d..fe28d14 100644
--- a/translation-table.h
+++ b/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/unicast.c b/unicast.c
index 32b125f..07d1c1d 100644
--- a/unicast.c
+++ b/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:
 	/**
-- 
1.7.3.4


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [B.A.T.M.A.N.] [PATCHv4 4/4] batman-adv: print client flags in the local/global transtables output
  2011-07-07 13:35 [B.A.T.M.A.N.] [PATCHv4 0/3] Implement the AP-Isolation mechanism Antonio Quartulli
                   ` (2 preceding siblings ...)
  2011-07-07 13:35 ` [B.A.T.M.A.N.] [PATCHv4 3/4] batman-adv: implement AP-isolation on the sender side Antonio Quartulli
@ 2011-07-07 13:35 ` Antonio Quartulli
  2011-07-25 20:24   ` Marek Lindner
  3 siblings, 1 reply; 9+ messages in thread
From: Antonio Quartulli @ 2011-07-07 13:35 UTC (permalink / raw)
  To: B.A.T.M.A.N

Since clients can have several flags on or off, this patches make them
appear in the local/global transtable output so that they can be checked
for debugging purposes.

Signed-off-by: Antonio Quartulli <ordex@autistici.org>
---
 translation-table.c |   37 +++++++++++++++++++++++++++----------
 1 files changed, 27 insertions(+), 10 deletions(-)

diff --git a/translation-table.c b/translation-table.c
index 0b25fd9..512faf1 100644
--- a/translation-table.c
+++ b/translation-table.c
@@ -332,7 +332,7 @@ int tt_local_seq_print_text(struct seq_file *seq, void *offset)
 
 		rcu_read_lock();
 		__hlist_for_each_rcu(node, head)
-			buf_size += 21;
+			buf_size += 29;
 		rcu_read_unlock();
 	}
 
@@ -351,8 +351,19 @@ int tt_local_seq_print_text(struct seq_file *seq, void *offset)
 		rcu_read_lock();
 		hlist_for_each_entry_rcu(tt_local_entry, node,
 					 head, hash_entry) {
-			pos += snprintf(buff + pos, 22, " * %pM\n",
-					tt_local_entry->addr);
+			pos += snprintf(buff + pos, 30, " * %pM "
+					"[%c%c%c%c%c]\n",
+					tt_local_entry->addr,
+					(tt_local_entry->flags &
+					 TT_CLIENT_ROAM ? 'R' : '.'),
+					(tt_local_entry->flags &
+					 TT_CLIENT_NOPURGE ? 'P' : '.'),
+					(tt_local_entry->flags &
+					 TT_CLIENT_NEW ? 'N' : '.'),
+					(tt_local_entry->flags &
+					 TT_CLIENT_PENDING ? 'X' : '.'),
+					(tt_local_entry->flags &
+					 TT_CLIENT_WIFI ? 'W' : '.'));
 		}
 		rcu_read_unlock();
 	}
@@ -589,8 +600,8 @@ int tt_global_seq_print_text(struct seq_file *seq, void *offset)
 	seq_printf(seq,
 		   "Globally announced TT entries received via the mesh %s\n",
 		   net_dev->name);
-	seq_printf(seq, "       %-13s %s       %-15s %s\n",
-		   "Client", "(TTVN)", "Originator", "(Curr TTVN)");
+	seq_printf(seq, "       %-13s %s       %-15s %s %s\n",
+		   "Client", "(TTVN)", "Originator", "(Curr TTVN)", "Flags");
 
 	buf_size = 1;
 	/* Estimate length for: " * xx:xx:xx:xx:xx:xx (ttvn) via
@@ -600,7 +611,7 @@ int tt_global_seq_print_text(struct seq_file *seq, void *offset)
 
 		rcu_read_lock();
 		__hlist_for_each_rcu(node, head)
-			buf_size += 59;
+			buf_size += 67;
 		rcu_read_unlock();
 	}
 
@@ -619,14 +630,20 @@ int tt_global_seq_print_text(struct seq_file *seq, void *offset)
 		rcu_read_lock();
 		hlist_for_each_entry_rcu(tt_global_entry, node,
 					 head, hash_entry) {
-			pos += snprintf(buff + pos, 61,
-					" * %pM  (%3u) via %pM     (%3u)\n",
-					tt_global_entry->addr,
+			pos += snprintf(buff + pos, 69,
+					" * %pM  (%3u) via %pM     (%3u)   "
+					"[%c%c%c]\n", tt_global_entry->addr,
 					tt_global_entry->ttvn,
 					tt_global_entry->orig_node->orig,
 					(uint8_t) atomic_read(
 						&tt_global_entry->orig_node->
-						last_ttvn));
+						last_ttvn),
+					(tt_global_entry->flags &
+					 TT_CLIENT_ROAM ? 'R' : '.'),
+					(tt_global_entry->flags &
+					 TT_CLIENT_PENDING ? 'X' : '.'),
+					(tt_global_entry->flags &
+					 TT_CLIENT_WIFI ? 'W' : '.'));
 		}
 		rcu_read_unlock();
 	}
-- 
1.7.3.4


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* Re: [B.A.T.M.A.N.] [PATCHv4 1/4] batman-adv: detect clients connected through a 802.11 device
  2011-07-07 13:35 ` [B.A.T.M.A.N.] [PATCHv4 1/4] batman-adv: detect clients connected through a 802.11 device Antonio Quartulli
@ 2011-07-25 20:11   ` Marek Lindner
  0 siblings, 0 replies; 9+ messages in thread
From: Marek Lindner @ 2011-07-25 20:11 UTC (permalink / raw)
  To: The list for a Better Approach To Mobile Ad-hoc Networking

On Thursday, July 07, 2011 15:35:35 Antonio Quartulli wrote:
> Clients connected through a 802.11 device are now marked with the
> TT_CLIENT_WIFI flag. This flag is also advertised with the tt
> announcement.

Applied in revision 75d6435.

Thanks,
Marek

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [B.A.T.M.A.N.] [PATCHv4 2/4] batman-adv: implement AP-isolation on the receiver side
  2011-07-07 13:35 ` [B.A.T.M.A.N.] [PATCHv4 2/4] batman-adv: implement AP-isolation on the receiver side Antonio Quartulli
@ 2011-07-25 20:17   ` Marek Lindner
  0 siblings, 0 replies; 9+ messages in thread
From: Marek Lindner @ 2011-07-25 20:17 UTC (permalink / raw)
  To: The list for a Better Approach To Mobile Ad-hoc Networking

On Thursday, July 07, 2011 15:35:36 Antonio Quartulli wrote:
> 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

Applied in revision 48ab74a.

Thanks,
Marek

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [B.A.T.M.A.N.] [PATCHv4 3/4] batman-adv: implement AP-isolation on the sender side
  2011-07-07 13:35 ` [B.A.T.M.A.N.] [PATCHv4 3/4] batman-adv: implement AP-isolation on the sender side Antonio Quartulli
@ 2011-07-25 20:19   ` Marek Lindner
  0 siblings, 0 replies; 9+ messages in thread
From: Marek Lindner @ 2011-07-25 20:19 UTC (permalink / raw)
  To: The list for a Better Approach To Mobile Ad-hoc Networking

On Thursday, July 07, 2011 15:35:37 Antonio Quartulli wrote:
> If a node has to send a packet issued by a WIFI client to another WIFI
> client, the packet is dropped.

Applied in revision 5c837c9.

Thanks,
Marek

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [B.A.T.M.A.N.] [PATCHv4 4/4] batman-adv: print client flags in the local/global transtables output
  2011-07-07 13:35 ` [B.A.T.M.A.N.] [PATCHv4 4/4] batman-adv: print client flags in the local/global transtables output Antonio Quartulli
@ 2011-07-25 20:24   ` Marek Lindner
  0 siblings, 0 replies; 9+ messages in thread
From: Marek Lindner @ 2011-07-25 20:24 UTC (permalink / raw)
  To: The list for a Better Approach To Mobile Ad-hoc Networking

On Thursday, July 07, 2011 15:35:38 Antonio Quartulli wrote:
> Since clients can have several flags on or off, this patches make them
> appear in the local/global transtable output so that they can be checked
> for debugging purposes.

Applied in revision bb280c4.

Thanks,
Marek

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2011-07-25 20:24 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-07-07 13:35 [B.A.T.M.A.N.] [PATCHv4 0/3] Implement the AP-Isolation mechanism Antonio Quartulli
2011-07-07 13:35 ` [B.A.T.M.A.N.] [PATCHv4 1/4] batman-adv: detect clients connected through a 802.11 device Antonio Quartulli
2011-07-25 20:11   ` Marek Lindner
2011-07-07 13:35 ` [B.A.T.M.A.N.] [PATCHv4 2/4] batman-adv: implement AP-isolation on the receiver side Antonio Quartulli
2011-07-25 20:17   ` Marek Lindner
2011-07-07 13:35 ` [B.A.T.M.A.N.] [PATCHv4 3/4] batman-adv: implement AP-isolation on the sender side Antonio Quartulli
2011-07-25 20:19   ` Marek Lindner
2011-07-07 13:35 ` [B.A.T.M.A.N.] [PATCHv4 4/4] batman-adv: print client flags in the local/global transtables output Antonio Quartulli
2011-07-25 20:24   ` Marek Lindner

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.