aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAntonio Quartulli <antonio@open-mesh.com>2013-11-16 06:03:48 -0500
committerAntonio Quartulli <antonio@meshcoding.com>2014-01-08 14:49:43 -0500
commit9464d07188c5322957427a456d12d945370f7b29 (patch)
tree0284e8544e13f3b41a92de6f793805d63f13a4f3
parentc42edfe382fee1c2c74550a5a3cbf50b2a28cf07 (diff)
batman-adv: mark a local client as isolated when needed
A client sending packets which mark matches the value configured via sysfs has to be identified as isolated using the TT_CLIENT_ISOLA flag. The match is mask based, meaning that only bits set in the mask are compared with those in the mark value. If the configured mask is equal to 0 no operation is performed. Such flag is then advertised within the classic client announcement mechanism. Signed-off-by: Antonio Quartulli <antonio@open-mesh.com> Signed-off-by: Marek Lindner <mareklindner@neomailbox.ch>
-rw-r--r--net/batman-adv/main.h2
-rw-r--r--net/batman-adv/packet.h1
-rw-r--r--net/batman-adv/soft-interface.c7
-rw-r--r--net/batman-adv/translation-table.c16
-rw-r--r--net/batman-adv/translation-table.h2
5 files changed, 23 insertions, 5 deletions
diff --git a/net/batman-adv/main.h b/net/batman-adv/main.h
index 9e76b6cddb69..fa9edbf79323 100644
--- a/net/batman-adv/main.h
+++ b/net/batman-adv/main.h
@@ -70,6 +70,8 @@
70 70
71#define BATADV_NULL_IFINDEX 0 /* dummy ifindex used to avoid iface checks */ 71#define BATADV_NULL_IFINDEX 0 /* dummy ifindex used to avoid iface checks */
72 72
73#define BATADV_NO_MARK 0
74
73#define BATADV_NUM_WORDS BITS_TO_LONGS(BATADV_TQ_LOCAL_WINDOW_SIZE) 75#define BATADV_NUM_WORDS BITS_TO_LONGS(BATADV_TQ_LOCAL_WINDOW_SIZE)
74 76
75#define BATADV_LOG_BUF_LEN 8192 /* has to be a power of 2 */ 77#define BATADV_LOG_BUF_LEN 8192 /* has to be a power of 2 */
diff --git a/net/batman-adv/packet.h b/net/batman-adv/packet.h
index 5e73294900eb..ef2010c27146 100644
--- a/net/batman-adv/packet.h
+++ b/net/batman-adv/packet.h
@@ -115,6 +115,7 @@ enum batadv_tt_client_flags {
115 BATADV_TT_CLIENT_DEL = BIT(0), 115 BATADV_TT_CLIENT_DEL = BIT(0),
116 BATADV_TT_CLIENT_ROAM = BIT(1), 116 BATADV_TT_CLIENT_ROAM = BIT(1),
117 BATADV_TT_CLIENT_WIFI = BIT(4), 117 BATADV_TT_CLIENT_WIFI = BIT(4),
118 BATADV_TT_CLIENT_ISOLA = BIT(5),
118 BATADV_TT_CLIENT_NOPURGE = BIT(8), 119 BATADV_TT_CLIENT_NOPURGE = BIT(8),
119 BATADV_TT_CLIENT_NEW = BIT(9), 120 BATADV_TT_CLIENT_NEW = BIT(9),
120 BATADV_TT_CLIENT_PENDING = BIT(10), 121 BATADV_TT_CLIENT_PENDING = BIT(10),
diff --git a/net/batman-adv/soft-interface.c b/net/batman-adv/soft-interface.c
index 35a82e36c003..e126d74da6b8 100644
--- a/net/batman-adv/soft-interface.c
+++ b/net/batman-adv/soft-interface.c
@@ -119,7 +119,7 @@ static int batadv_interface_set_mac_addr(struct net_device *dev, void *p)
119 batadv_tt_local_remove(bat_priv, old_addr, BATADV_NO_FLAGS, 119 batadv_tt_local_remove(bat_priv, old_addr, BATADV_NO_FLAGS,
120 "mac address changed", false); 120 "mac address changed", false);
121 batadv_tt_local_add(dev, addr->sa_data, BATADV_NO_FLAGS, 121 batadv_tt_local_add(dev, addr->sa_data, BATADV_NO_FLAGS,
122 BATADV_NULL_IFINDEX); 122 BATADV_NULL_IFINDEX, BATADV_NO_MARK);
123 } 123 }
124 124
125 return 0; 125 return 0;
@@ -199,7 +199,8 @@ static int batadv_interface_tx(struct sk_buff *skb,
199 /* Register the client MAC in the transtable */ 199 /* Register the client MAC in the transtable */
200 if (!is_multicast_ether_addr(ethhdr->h_source)) { 200 if (!is_multicast_ether_addr(ethhdr->h_source)) {
201 client_added = batadv_tt_local_add(soft_iface, ethhdr->h_source, 201 client_added = batadv_tt_local_add(soft_iface, ethhdr->h_source,
202 vid, skb->skb_iif); 202 vid, skb->skb_iif,
203 skb->mark);
203 if (!client_added) 204 if (!client_added)
204 goto dropped; 205 goto dropped;
205 } 206 }
@@ -489,7 +490,7 @@ int batadv_softif_create_vlan(struct batadv_priv *bat_priv, unsigned short vid)
489 */ 490 */
490 batadv_tt_local_add(bat_priv->soft_iface, 491 batadv_tt_local_add(bat_priv->soft_iface,
491 bat_priv->soft_iface->dev_addr, vid, 492 bat_priv->soft_iface->dev_addr, vid,
492 BATADV_NULL_IFINDEX); 493 BATADV_NULL_IFINDEX, BATADV_NO_MARK);
493 494
494 spin_lock_bh(&bat_priv->softif_vlan_list_lock); 495 spin_lock_bh(&bat_priv->softif_vlan_list_lock);
495 hlist_add_head_rcu(&vlan->list, &bat_priv->softif_vlan_list); 496 hlist_add_head_rcu(&vlan->list, &bat_priv->softif_vlan_list);
diff --git a/net/batman-adv/translation-table.c b/net/batman-adv/translation-table.c
index 2eaa1e9d8c99..669b8b64a39a 100644
--- a/net/batman-adv/translation-table.c
+++ b/net/batman-adv/translation-table.c
@@ -474,11 +474,13 @@ static void batadv_tt_global_free(struct batadv_priv *bat_priv,
474 * @vid: VLAN identifier 474 * @vid: VLAN identifier
475 * @ifindex: index of the interface where the client is connected to (useful to 475 * @ifindex: index of the interface where the client is connected to (useful to
476 * identify wireless clients) 476 * identify wireless clients)
477 * @mark: the value contained in the skb->mark field of the received packet (if
478 * any)
477 * 479 *
478 * Returns true if the client was successfully added, false otherwise. 480 * Returns true if the client was successfully added, false otherwise.
479 */ 481 */
480bool batadv_tt_local_add(struct net_device *soft_iface, const uint8_t *addr, 482bool batadv_tt_local_add(struct net_device *soft_iface, const uint8_t *addr,
481 unsigned short vid, int ifindex) 483 unsigned short vid, int ifindex, uint32_t mark)
482{ 484{
483 struct batadv_priv *bat_priv = netdev_priv(soft_iface); 485 struct batadv_priv *bat_priv = netdev_priv(soft_iface);
484 struct batadv_tt_local_entry *tt_local; 486 struct batadv_tt_local_entry *tt_local;
@@ -489,6 +491,7 @@ bool batadv_tt_local_add(struct net_device *soft_iface, const uint8_t *addr,
489 int hash_added, table_size, packet_size_max; 491 int hash_added, table_size, packet_size_max;
490 bool ret = false, roamed_back = false; 492 bool ret = false, roamed_back = false;
491 uint8_t remote_flags; 493 uint8_t remote_flags;
494 uint32_t match_mark;
492 495
493 if (ifindex != BATADV_NULL_IFINDEX) 496 if (ifindex != BATADV_NULL_IFINDEX)
494 in_dev = dev_get_by_index(&init_net, ifindex); 497 in_dev = dev_get_by_index(&init_net, ifindex);
@@ -613,6 +616,17 @@ check_roaming:
613 else 616 else
614 tt_local->common.flags &= ~BATADV_TT_CLIENT_WIFI; 617 tt_local->common.flags &= ~BATADV_TT_CLIENT_WIFI;
615 618
619 /* check the mark in the skb: if it's equal to the configured
620 * isolation_mark, it means the packet is coming from an isolated
621 * non-mesh client
622 */
623 match_mark = (mark & bat_priv->isolation_mark_mask);
624 if (bat_priv->isolation_mark_mask &&
625 match_mark == bat_priv->isolation_mark)
626 tt_local->common.flags |= BATADV_TT_CLIENT_ISOLA;
627 else
628 tt_local->common.flags &= ~BATADV_TT_CLIENT_ISOLA;
629
616 /* if any "dynamic" flag has been modified, resend an ADD event for this 630 /* if any "dynamic" flag has been modified, resend an ADD event for this
617 * entry so that all the nodes can get the new flags 631 * entry so that all the nodes can get the new flags
618 */ 632 */
diff --git a/net/batman-adv/translation-table.h b/net/batman-adv/translation-table.h
index 08d9bbe53e24..0e7023eda2ed 100644
--- a/net/batman-adv/translation-table.h
+++ b/net/batman-adv/translation-table.h
@@ -20,7 +20,7 @@
20 20
21int batadv_tt_init(struct batadv_priv *bat_priv); 21int batadv_tt_init(struct batadv_priv *bat_priv);
22bool batadv_tt_local_add(struct net_device *soft_iface, const uint8_t *addr, 22bool batadv_tt_local_add(struct net_device *soft_iface, const uint8_t *addr,
23 unsigned short vid, int ifindex); 23 unsigned short vid, int ifindex, uint32_t mark);
24uint16_t batadv_tt_local_remove(struct batadv_priv *bat_priv, 24uint16_t batadv_tt_local_remove(struct batadv_priv *bat_priv,
25 const uint8_t *addr, unsigned short vid, 25 const uint8_t *addr, unsigned short vid,
26 const char *message, bool roaming); 26 const char *message, bool roaming);