diff options
author | Antonio Quartulli <ordex@autistici.org> | 2011-07-07 09:35:35 -0400 |
---|---|---|
committer | Marek Lindner <lindner_marek@yahoo.de> | 2011-08-22 09:16:20 -0400 |
commit | bc2790808a7a3699a7c9f72f7ad225c8504824aa (patch) | |
tree | a1b0e88091facf44e0afb78d3438c55cfd6633ad /net/batman-adv | |
parent | 015758d00251a4dd9287806cdab4b9c1298f97ed (diff) |
batman-adv: detect clients connected through a 802.11 device
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>
Signed-off-by: Marek Lindner <lindner_marek@yahoo.de>
Diffstat (limited to 'net/batman-adv')
-rw-r--r-- | net/batman-adv/hard-interface.c | 30 | ||||
-rw-r--r-- | net/batman-adv/hard-interface.h | 1 | ||||
-rw-r--r-- | net/batman-adv/main.c | 2 | ||||
-rw-r--r-- | net/batman-adv/main.h | 2 | ||||
-rw-r--r-- | net/batman-adv/packet.h | 1 | ||||
-rw-r--r-- | net/batman-adv/routing.c | 2 | ||||
-rw-r--r-- | net/batman-adv/soft-interface.c | 4 | ||||
-rw-r--r-- | net/batman-adv/translation-table.c | 15 | ||||
-rw-r--r-- | net/batman-adv/translation-table.h | 9 |
9 files changed, 55 insertions, 11 deletions
diff --git a/net/batman-adv/hard-interface.c b/net/batman-adv/hard-interface.c index 0d73e1e9e3d5..bf91e4d8a47f 100644 --- a/net/batman-adv/hard-interface.c +++ b/net/batman-adv/hard-interface.c | |||
@@ -681,6 +681,36 @@ err_out: | |||
681 | return NET_RX_DROP; | 681 | return NET_RX_DROP; |
682 | } | 682 | } |
683 | 683 | ||
684 | /* This function returns true if the interface represented by ifindex is a | ||
685 | * 802.11 wireless device */ | ||
686 | bool is_wifi_iface(int ifindex) | ||
687 | { | ||
688 | struct net_device *net_device = NULL; | ||
689 | bool ret = false; | ||
690 | |||
691 | if (ifindex == NULL_IFINDEX) | ||
692 | goto out; | ||
693 | |||
694 | net_device = dev_get_by_index(&init_net, ifindex); | ||
695 | if (!net_device) | ||
696 | goto out; | ||
697 | |||
698 | #ifdef CONFIG_WIRELESS_EXT | ||
699 | /* pre-cfg80211 drivers have to implement WEXT, so it is possible to | ||
700 | * check for wireless_handlers != NULL */ | ||
701 | if (net_device->wireless_handlers) | ||
702 | ret = true; | ||
703 | else | ||
704 | #endif | ||
705 | /* cfg80211 drivers have to set ieee80211_ptr */ | ||
706 | if (net_device->ieee80211_ptr) | ||
707 | ret = true; | ||
708 | out: | ||
709 | if (net_device) | ||
710 | dev_put(net_device); | ||
711 | return ret; | ||
712 | } | ||
713 | |||
684 | struct notifier_block hard_if_notifier = { | 714 | struct notifier_block hard_if_notifier = { |
685 | .notifier_call = hard_if_event, | 715 | .notifier_call = hard_if_event, |
686 | }; | 716 | }; |
diff --git a/net/batman-adv/hard-interface.h b/net/batman-adv/hard-interface.h index 442eacbc9e3a..67f78d1a63b4 100644 --- a/net/batman-adv/hard-interface.h +++ b/net/batman-adv/hard-interface.h | |||
@@ -42,6 +42,7 @@ void hardif_remove_interfaces(void); | |||
42 | int hardif_min_mtu(struct net_device *soft_iface); | 42 | int hardif_min_mtu(struct net_device *soft_iface); |
43 | void update_min_mtu(struct net_device *soft_iface); | 43 | void update_min_mtu(struct net_device *soft_iface); |
44 | void hardif_free_rcu(struct rcu_head *rcu); | 44 | void hardif_free_rcu(struct rcu_head *rcu); |
45 | bool is_wifi_iface(int ifindex); | ||
45 | 46 | ||
46 | static inline void hardif_free_ref(struct hard_iface *hard_iface) | 47 | static inline void hardif_free_ref(struct hard_iface *hard_iface) |
47 | { | 48 | { |
diff --git a/net/batman-adv/main.c b/net/batman-adv/main.c index b0f9068ade57..79b9ae522ce9 100644 --- a/net/batman-adv/main.c +++ b/net/batman-adv/main.c | |||
@@ -107,7 +107,7 @@ int mesh_init(struct net_device *soft_iface) | |||
107 | if (tt_init(bat_priv) < 1) | 107 | if (tt_init(bat_priv) < 1) |
108 | goto err; | 108 | goto err; |
109 | 109 | ||
110 | tt_local_add(soft_iface, soft_iface->dev_addr); | 110 | tt_local_add(soft_iface, soft_iface->dev_addr, NULL_IFINDEX); |
111 | 111 | ||
112 | if (vis_init(bat_priv) < 1) | 112 | if (vis_init(bat_priv) < 1) |
113 | goto err; | 113 | goto err; |
diff --git a/net/batman-adv/main.h b/net/batman-adv/main.h index 3daa9b65a833..60b369635b4d 100644 --- a/net/batman-adv/main.h +++ b/net/batman-adv/main.h | |||
@@ -62,6 +62,8 @@ | |||
62 | 62 | ||
63 | #define NO_FLAGS 0 | 63 | #define NO_FLAGS 0 |
64 | 64 | ||
65 | #define NULL_IFINDEX 0 /* dummy ifindex used to avoid iface checks */ | ||
66 | |||
65 | #define NUM_WORDS (TQ_LOCAL_WINDOW_SIZE / WORD_BIT_SIZE) | 67 | #define NUM_WORDS (TQ_LOCAL_WINDOW_SIZE / WORD_BIT_SIZE) |
66 | 68 | ||
67 | #define LOG_BUF_LEN 8192 /* has to be a power of 2 */ | 69 | #define 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 b76b4be10b92..8802eab2a46d 100644 --- a/net/batman-adv/packet.h +++ b/net/batman-adv/packet.h | |||
@@ -84,6 +84,7 @@ enum tt_query_flags { | |||
84 | enum tt_client_flags { | 84 | enum tt_client_flags { |
85 | TT_CLIENT_DEL = 1 << 0, | 85 | TT_CLIENT_DEL = 1 << 0, |
86 | TT_CLIENT_ROAM = 1 << 1, | 86 | TT_CLIENT_ROAM = 1 << 1, |
87 | TT_CLIENT_WIFI = 1 << 2, | ||
87 | TT_CLIENT_NOPURGE = 1 << 8, | 88 | TT_CLIENT_NOPURGE = 1 << 8, |
88 | TT_CLIENT_NEW = 1 << 9, | 89 | TT_CLIENT_NEW = 1 << 9, |
89 | TT_CLIENT_PENDING = 1 << 10 | 90 | TT_CLIENT_PENDING = 1 << 10 |
diff --git a/net/batman-adv/routing.c b/net/batman-adv/routing.c index ec23f9f7d146..13444e92bc99 100644 --- a/net/batman-adv/routing.c +++ b/net/batman-adv/routing.c | |||
@@ -1299,7 +1299,7 @@ int recv_roam_adv(struct sk_buff *skb, struct hard_iface *recv_if) | |||
1299 | roam_adv_packet->client); | 1299 | roam_adv_packet->client); |
1300 | 1300 | ||
1301 | tt_global_add(bat_priv, orig_node, roam_adv_packet->client, | 1301 | tt_global_add(bat_priv, orig_node, roam_adv_packet->client, |
1302 | atomic_read(&orig_node->last_ttvn) + 1, true); | 1302 | atomic_read(&orig_node->last_ttvn) + 1, true, false); |
1303 | 1303 | ||
1304 | /* Roaming phase starts: I have new information but the ttvn has not | 1304 | /* Roaming phase starts: I have new information but the ttvn has not |
1305 | * been incremented yet. This flag will make me check all the incoming | 1305 | * been incremented yet. This flag will make me check all the incoming |
diff --git a/net/batman-adv/soft-interface.c b/net/batman-adv/soft-interface.c index 6ba35a2772ff..6deed44a3703 100644 --- a/net/batman-adv/soft-interface.c +++ b/net/batman-adv/soft-interface.c | |||
@@ -536,7 +536,7 @@ static int interface_set_mac_addr(struct net_device *dev, void *p) | |||
536 | if (atomic_read(&bat_priv->mesh_state) == MESH_ACTIVE) { | 536 | if (atomic_read(&bat_priv->mesh_state) == MESH_ACTIVE) { |
537 | tt_local_remove(bat_priv, dev->dev_addr, | 537 | tt_local_remove(bat_priv, dev->dev_addr, |
538 | "mac address changed", false); | 538 | "mac address changed", false); |
539 | tt_local_add(dev, addr->sa_data); | 539 | tt_local_add(dev, addr->sa_data, NULL_IFINDEX); |
540 | } | 540 | } |
541 | 541 | ||
542 | memcpy(dev->dev_addr, addr->sa_data, ETH_ALEN); | 542 | 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) | |||
595 | goto dropped; | 595 | goto dropped; |
596 | 596 | ||
597 | /* Register the client MAC in the transtable */ | 597 | /* Register the client MAC in the transtable */ |
598 | tt_local_add(soft_iface, ethhdr->h_source); | 598 | tt_local_add(soft_iface, ethhdr->h_source, skb->skb_iif); |
599 | 599 | ||
600 | orig_node = transtable_search(bat_priv, ethhdr->h_dest); | 600 | orig_node = transtable_search(bat_priv, ethhdr->h_dest); |
601 | if (is_multicast_ether_addr(ethhdr->h_dest) || | 601 | if (is_multicast_ether_addr(ethhdr->h_dest) || |
diff --git a/net/batman-adv/translation-table.c b/net/batman-adv/translation-table.c index 6004cd8eb9c7..d6305645e08d 100644 --- a/net/batman-adv/translation-table.c +++ b/net/batman-adv/translation-table.c | |||
@@ -183,7 +183,8 @@ static int tt_local_init(struct bat_priv *bat_priv) | |||
183 | return 1; | 183 | return 1; |
184 | } | 184 | } |
185 | 185 | ||
186 | void tt_local_add(struct net_device *soft_iface, const uint8_t *addr) | 186 | void tt_local_add(struct net_device *soft_iface, const uint8_t *addr, |
187 | int ifindex) | ||
187 | { | 188 | { |
188 | struct bat_priv *bat_priv = netdev_priv(soft_iface); | 189 | struct bat_priv *bat_priv = netdev_priv(soft_iface); |
189 | struct tt_local_entry *tt_local_entry = NULL; | 190 | 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) | |||
207 | memcpy(tt_local_entry->addr, addr, ETH_ALEN); | 208 | memcpy(tt_local_entry->addr, addr, ETH_ALEN); |
208 | tt_local_entry->last_seen = jiffies; | 209 | tt_local_entry->last_seen = jiffies; |
209 | tt_local_entry->flags = NO_FLAGS; | 210 | tt_local_entry->flags = NO_FLAGS; |
211 | if (is_wifi_iface(ifindex)) | ||
212 | tt_local_entry->flags |= TT_CLIENT_WIFI; | ||
210 | atomic_set(&tt_local_entry->refcount, 2); | 213 | atomic_set(&tt_local_entry->refcount, 2); |
211 | 214 | ||
212 | /* the batman interface mac address should never be purged */ | 215 | /* the batman interface mac address should never be purged */ |
@@ -495,7 +498,8 @@ static void tt_changes_list_free(struct bat_priv *bat_priv) | |||
495 | 498 | ||
496 | /* caller must hold orig_node refcount */ | 499 | /* caller must hold orig_node refcount */ |
497 | int tt_global_add(struct bat_priv *bat_priv, struct orig_node *orig_node, | 500 | int tt_global_add(struct bat_priv *bat_priv, struct orig_node *orig_node, |
498 | const unsigned char *tt_addr, uint8_t ttvn, bool roaming) | 501 | const unsigned char *tt_addr, uint8_t ttvn, bool roaming, |
502 | bool wifi) | ||
499 | { | 503 | { |
500 | struct tt_global_entry *tt_global_entry; | 504 | struct tt_global_entry *tt_global_entry; |
501 | struct orig_node *orig_node_tmp; | 505 | struct orig_node *orig_node_tmp; |
@@ -537,6 +541,9 @@ int tt_global_add(struct bat_priv *bat_priv, struct orig_node *orig_node, | |||
537 | tt_global_entry->roam_at = 0; | 541 | tt_global_entry->roam_at = 0; |
538 | } | 542 | } |
539 | 543 | ||
544 | if (wifi) | ||
545 | tt_global_entry->flags |= TT_CLIENT_WIFI; | ||
546 | |||
540 | bat_dbg(DBG_TT, bat_priv, | 547 | bat_dbg(DBG_TT, bat_priv, |
541 | "Creating new global tt entry: %pM (via %pM)\n", | 548 | "Creating new global tt entry: %pM (via %pM)\n", |
542 | tt_global_entry->addr, orig_node->orig); | 549 | tt_global_entry->addr, orig_node->orig); |
@@ -1363,7 +1370,9 @@ static void _tt_update_changes(struct bat_priv *bat_priv, | |||
1363 | (tt_change + i)->flags & TT_CLIENT_ROAM); | 1370 | (tt_change + i)->flags & TT_CLIENT_ROAM); |
1364 | else | 1371 | else |
1365 | if (!tt_global_add(bat_priv, orig_node, | 1372 | if (!tt_global_add(bat_priv, orig_node, |
1366 | (tt_change + i)->addr, ttvn, false)) | 1373 | (tt_change + i)->addr, ttvn, false, |
1374 | (tt_change + i)->flags & | ||
1375 | TT_CLIENT_WIFI)) | ||
1367 | /* In case of problem while storing a | 1376 | /* In case of problem while storing a |
1368 | * global_entry, we stop the updating | 1377 | * global_entry, we stop the updating |
1369 | * procedure without committing the | 1378 | * procedure without committing the |
diff --git a/net/batman-adv/translation-table.h b/net/batman-adv/translation-table.h index e6b564dfe97c..4d1ca35c6818 100644 --- a/net/batman-adv/translation-table.h +++ b/net/batman-adv/translation-table.h | |||
@@ -26,15 +26,16 @@ int tt_len(int changes_num); | |||
26 | int tt_changes_fill_buffer(struct bat_priv *bat_priv, | 26 | int tt_changes_fill_buffer(struct bat_priv *bat_priv, |
27 | unsigned char *buff, int buff_len); | 27 | unsigned char *buff, int buff_len); |
28 | int tt_init(struct bat_priv *bat_priv); | 28 | int tt_init(struct bat_priv *bat_priv); |
29 | void tt_local_add(struct net_device *soft_iface, const uint8_t *addr); | 29 | void tt_local_add(struct net_device *soft_iface, const uint8_t *addr, |
30 | int ifindex); | ||
30 | void tt_local_remove(struct bat_priv *bat_priv, | 31 | void tt_local_remove(struct bat_priv *bat_priv, |
31 | const uint8_t *addr, const char *message, bool roaming); | 32 | const uint8_t *addr, const char *message, bool roaming); |
32 | int tt_local_seq_print_text(struct seq_file *seq, void *offset); | 33 | int tt_local_seq_print_text(struct seq_file *seq, void *offset); |
33 | void tt_global_add_orig(struct bat_priv *bat_priv, struct orig_node *orig_node, | 34 | void tt_global_add_orig(struct bat_priv *bat_priv, struct orig_node *orig_node, |
34 | const unsigned char *tt_buff, int tt_buff_len); | 35 | const unsigned char *tt_buff, int tt_buff_len); |
35 | int tt_global_add(struct bat_priv *bat_priv, | 36 | int tt_global_add(struct bat_priv *bat_priv, struct orig_node *orig_node, |
36 | struct orig_node *orig_node, const unsigned char *addr, | 37 | const unsigned char *addr, uint8_t ttvn, bool roaming, |
37 | uint8_t ttvn, bool roaming); | 38 | bool wifi); |
38 | int tt_global_seq_print_text(struct seq_file *seq, void *offset); | 39 | int tt_global_seq_print_text(struct seq_file *seq, void *offset); |
39 | void tt_global_del_orig(struct bat_priv *bat_priv, | 40 | void tt_global_del_orig(struct bat_priv *bat_priv, |
40 | struct orig_node *orig_node, const char *message); | 41 | struct orig_node *orig_node, const char *message); |