提交 08c36d3e 编写于 作者: S Sven Eckelmann 提交者: Antonio Quartulli

batman-adv: Prefix translation-table non-static functions with batadv_

batman-adv can be compiled as part of the kernel instead of an module. In that
case the linker will see all non-static symbols of batman-adv and all other
non-static symbols of the kernel. This could lead to symbol collisions. A
prefix for the batman-adv symbols that defines their private namespace avoids
such a problem.
Reported-by: NDavid Miller <davem@davemloft.net>
Signed-off-by: NSven Eckelmann <sven@narfation.org>
上级 04b482a2
...@@ -242,7 +242,7 @@ static int gateways_open(struct inode *inode, struct file *file) ...@@ -242,7 +242,7 @@ static int gateways_open(struct inode *inode, struct file *file)
static int transtable_global_open(struct inode *inode, struct file *file) static int transtable_global_open(struct inode *inode, struct file *file)
{ {
struct net_device *net_dev = (struct net_device *)inode->i_private; struct net_device *net_dev = (struct net_device *)inode->i_private;
return single_open(file, tt_global_seq_print_text, net_dev); return single_open(file, batadv_tt_global_seq_print_text, net_dev);
} }
#ifdef CONFIG_BATMAN_ADV_BLA #ifdef CONFIG_BATMAN_ADV_BLA
...@@ -257,7 +257,7 @@ static int bla_claim_table_open(struct inode *inode, struct file *file) ...@@ -257,7 +257,7 @@ static int bla_claim_table_open(struct inode *inode, struct file *file)
static int transtable_local_open(struct inode *inode, struct file *file) static int transtable_local_open(struct inode *inode, struct file *file)
{ {
struct net_device *net_dev = (struct net_device *)inode->i_private; struct net_device *net_dev = (struct net_device *)inode->i_private;
return single_open(file, tt_local_seq_print_text, net_dev); return single_open(file, batadv_tt_local_seq_print_text, net_dev);
} }
static int vis_data_open(struct inode *inode, struct file *file) static int vis_data_open(struct inode *inode, struct file *file)
......
...@@ -138,7 +138,10 @@ static uint8_t hop_penalty(uint8_t tq, const struct bat_priv *bat_priv) ...@@ -138,7 +138,10 @@ static uint8_t hop_penalty(uint8_t tq, const struct bat_priv *bat_priv)
static int bat_iv_ogm_aggr_packet(int buff_pos, int packet_len, static int bat_iv_ogm_aggr_packet(int buff_pos, int packet_len,
int tt_num_changes) int tt_num_changes)
{ {
int next_buff_pos = buff_pos + BATMAN_OGM_HLEN + tt_len(tt_num_changes); int next_buff_pos = 0;
next_buff_pos += buff_pos + BATMAN_OGM_HLEN;
next_buff_pos += batadv_tt_len(tt_num_changes);
return (next_buff_pos <= packet_len) && return (next_buff_pos <= packet_len) &&
(next_buff_pos <= MAX_AGGREGATION_BYTES); (next_buff_pos <= MAX_AGGREGATION_BYTES);
...@@ -188,8 +191,8 @@ static void bat_iv_ogm_send_to_if(struct forw_packet *forw_packet, ...@@ -188,8 +191,8 @@ static void bat_iv_ogm_send_to_if(struct forw_packet *forw_packet,
batman_ogm_packet->ttvn, hard_iface->net_dev->name, batman_ogm_packet->ttvn, hard_iface->net_dev->name,
hard_iface->net_dev->dev_addr); hard_iface->net_dev->dev_addr);
buff_pos += BATMAN_OGM_HLEN + buff_pos += BATMAN_OGM_HLEN;
tt_len(batman_ogm_packet->tt_num_changes); buff_pos += batadv_tt_len(batman_ogm_packet->tt_num_changes);
packet_num++; packet_num++;
batman_ogm_packet = (struct batman_ogm_packet *) batman_ogm_packet = (struct batman_ogm_packet *)
(forw_packet->skb->data + buff_pos); (forw_packet->skb->data + buff_pos);
...@@ -556,7 +559,7 @@ static void bat_iv_ogm_forward(struct orig_node *orig_node, ...@@ -556,7 +559,7 @@ static void bat_iv_ogm_forward(struct orig_node *orig_node,
batman_ogm_packet->flags &= ~DIRECTLINK; batman_ogm_packet->flags &= ~DIRECTLINK;
bat_iv_ogm_queue_add(bat_priv, (unsigned char *)batman_ogm_packet, bat_iv_ogm_queue_add(bat_priv, (unsigned char *)batman_ogm_packet,
BATMAN_OGM_HLEN + tt_len(tt_num_changes), BATMAN_OGM_HLEN + batadv_tt_len(tt_num_changes),
if_incoming, 0, bat_iv_ogm_fwd_send_time()); if_incoming, 0, bat_iv_ogm_fwd_send_time());
} }
...@@ -724,7 +727,7 @@ static void bat_iv_ogm_orig_update(struct bat_priv *bat_priv, ...@@ -724,7 +727,7 @@ static void bat_iv_ogm_orig_update(struct bat_priv *bat_priv,
if (((batman_ogm_packet->orig != ethhdr->h_source) && if (((batman_ogm_packet->orig != ethhdr->h_source) &&
(batman_ogm_packet->header.ttl > 2)) || (batman_ogm_packet->header.ttl > 2)) ||
(batman_ogm_packet->flags & PRIMARIES_FIRST_HOP)) (batman_ogm_packet->flags & PRIMARIES_FIRST_HOP))
tt_update_orig(bat_priv, orig_node, tt_buff, batadv_tt_update_orig(bat_priv, orig_node, tt_buff,
batman_ogm_packet->tt_num_changes, batman_ogm_packet->tt_num_changes,
batman_ogm_packet->ttvn, batman_ogm_packet->ttvn,
ntohs(batman_ogm_packet->tt_crc)); ntohs(batman_ogm_packet->tt_crc));
...@@ -1229,8 +1232,8 @@ static int bat_iv_ogm_receive(struct sk_buff *skb, ...@@ -1229,8 +1232,8 @@ static int bat_iv_ogm_receive(struct sk_buff *skb,
bat_iv_ogm_process(ethhdr, batman_ogm_packet, bat_iv_ogm_process(ethhdr, batman_ogm_packet,
tt_buff, if_incoming); tt_buff, if_incoming);
buff_pos += BATMAN_OGM_HLEN + buff_pos += BATMAN_OGM_HLEN;
tt_len(batman_ogm_packet->tt_num_changes); buff_pos += batadv_tt_len(batman_ogm_packet->tt_num_changes);
batman_ogm_packet = (struct batman_ogm_packet *) batman_ogm_packet = (struct batman_ogm_packet *)
(packet_buff + buff_pos); (packet_buff + buff_pos);
......
...@@ -397,7 +397,7 @@ static struct backbone_gw *bla_get_backbone_gw(struct bat_priv *bat_priv, ...@@ -397,7 +397,7 @@ static struct backbone_gw *bla_get_backbone_gw(struct bat_priv *bat_priv,
/* this is a gateway now, remove any tt entries */ /* this is a gateway now, remove any tt entries */
orig_node = orig_hash_find(bat_priv, orig); orig_node = orig_hash_find(bat_priv, orig);
if (orig_node) { if (orig_node) {
tt_global_del_orig(bat_priv, orig_node, batadv_tt_global_del_orig(bat_priv, orig_node,
"became a backbone gateway"); "became a backbone gateway");
batadv_orig_node_free_ref(orig_node); batadv_orig_node_free_ref(orig_node);
} }
......
...@@ -652,7 +652,7 @@ bool batadv_gw_out_of_range(struct bat_priv *bat_priv, ...@@ -652,7 +652,7 @@ bool batadv_gw_out_of_range(struct bat_priv *bat_priv,
if (!ret) if (!ret)
goto out; goto out;
orig_dst_node = transtable_search(bat_priv, ethhdr->h_source, orig_dst_node = batadv_transtable_search(bat_priv, ethhdr->h_source,
ethhdr->h_dest); ethhdr->h_dest);
if (!orig_dst_node) if (!orig_dst_node)
goto out; goto out;
......
...@@ -115,11 +115,11 @@ int mesh_init(struct net_device *soft_iface) ...@@ -115,11 +115,11 @@ int mesh_init(struct net_device *soft_iface)
if (ret < 0) if (ret < 0)
goto err; goto err;
ret = tt_init(bat_priv); ret = batadv_tt_init(bat_priv);
if (ret < 0) if (ret < 0)
goto err; goto err;
tt_local_add(soft_iface, soft_iface->dev_addr, NULL_IFINDEX); batadv_tt_local_add(soft_iface, soft_iface->dev_addr, NULL_IFINDEX);
ret = vis_init(bat_priv); ret = vis_init(bat_priv);
if (ret < 0) if (ret < 0)
...@@ -152,7 +152,7 @@ void mesh_free(struct net_device *soft_iface) ...@@ -152,7 +152,7 @@ void mesh_free(struct net_device *soft_iface)
batadv_gw_node_purge(bat_priv); batadv_gw_node_purge(bat_priv);
batadv_originator_free(bat_priv); batadv_originator_free(bat_priv);
tt_free(bat_priv); batadv_tt_free(bat_priv);
batadv_bla_free(bat_priv); batadv_bla_free(bat_priv);
......
...@@ -139,7 +139,7 @@ static void orig_node_free_rcu(struct rcu_head *rcu) ...@@ -139,7 +139,7 @@ static void orig_node_free_rcu(struct rcu_head *rcu)
spin_unlock_bh(&orig_node->neigh_list_lock); spin_unlock_bh(&orig_node->neigh_list_lock);
frag_list_free(&orig_node->frag_list); frag_list_free(&orig_node->frag_list);
tt_global_del_orig(orig_node->bat_priv, orig_node, batadv_tt_global_del_orig(orig_node->bat_priv, orig_node,
"originator timed out"); "originator timed out");
kfree(orig_node->tt_buff); kfree(orig_node->tt_buff);
......
...@@ -75,7 +75,7 @@ static void _update_route(struct bat_priv *bat_priv, ...@@ -75,7 +75,7 @@ static void _update_route(struct bat_priv *bat_priv,
if ((curr_router) && (!neigh_node)) { if ((curr_router) && (!neigh_node)) {
bat_dbg(DBG_ROUTES, bat_priv, "Deleting route towards: %pM\n", bat_dbg(DBG_ROUTES, bat_priv, "Deleting route towards: %pM\n",
orig_node->orig); orig_node->orig);
tt_global_del_orig(bat_priv, orig_node, batadv_tt_global_del_orig(bat_priv, orig_node,
"Deleted route towards originator"); "Deleted route towards originator");
/* route added */ /* route added */
...@@ -603,7 +603,7 @@ int batadv_recv_tt_query(struct sk_buff *skb, struct hard_iface *recv_if) ...@@ -603,7 +603,7 @@ int batadv_recv_tt_query(struct sk_buff *skb, struct hard_iface *recv_if)
/* If we cannot provide an answer the tt_request is /* If we cannot provide an answer the tt_request is
* forwarded */ * forwarded */
if (!send_tt_response(bat_priv, tt_query)) { if (!batadv_send_tt_response(bat_priv, tt_query)) {
bat_dbg(DBG_TT, bat_priv, bat_dbg(DBG_TT, bat_priv,
"Routing TT_REQUEST to %pM [%c]\n", "Routing TT_REQUEST to %pM [%c]\n",
tt_query->dst, tt_query->dst,
...@@ -622,14 +622,14 @@ int batadv_recv_tt_query(struct sk_buff *skb, struct hard_iface *recv_if) ...@@ -622,14 +622,14 @@ int batadv_recv_tt_query(struct sk_buff *skb, struct hard_iface *recv_if)
/* skb_linearize() possibly changed skb->data */ /* skb_linearize() possibly changed skb->data */
tt_query = (struct tt_query_packet *)skb->data; tt_query = (struct tt_query_packet *)skb->data;
tt_size = tt_len(ntohs(tt_query->tt_data)); tt_size = batadv_tt_len(ntohs(tt_query->tt_data));
/* Ensure we have all the claimed data */ /* Ensure we have all the claimed data */
if (unlikely(skb_headlen(skb) < if (unlikely(skb_headlen(skb) <
sizeof(struct tt_query_packet) + tt_size)) sizeof(struct tt_query_packet) + tt_size))
goto out; goto out;
handle_tt_response(bat_priv, tt_query); batadv_handle_tt_response(bat_priv, tt_query);
} else { } else {
bat_dbg(DBG_TT, bat_priv, bat_dbg(DBG_TT, bat_priv,
"Routing TT_RESPONSE to %pM [%c]\n", "Routing TT_RESPONSE to %pM [%c]\n",
...@@ -688,8 +688,9 @@ int batadv_recv_roam_adv(struct sk_buff *skb, struct hard_iface *recv_if) ...@@ -688,8 +688,9 @@ int batadv_recv_roam_adv(struct sk_buff *skb, struct hard_iface *recv_if)
"Received ROAMING_ADV from %pM (client %pM)\n", "Received ROAMING_ADV from %pM (client %pM)\n",
roam_adv_packet->src, roam_adv_packet->client); roam_adv_packet->src, roam_adv_packet->client);
tt_global_add(bat_priv, orig_node, roam_adv_packet->client, batadv_tt_global_add(bat_priv, orig_node, roam_adv_packet->client,
atomic_read(&orig_node->last_ttvn) + 1, true, false); atomic_read(&orig_node->last_ttvn) + 1, true,
false);
/* Roaming phase starts: I have new information but the ttvn has not /* Roaming phase starts: I have new information but the ttvn has not
* been incremented yet. This flag will make me check all the incoming * been incremented yet. This flag will make me check all the incoming
...@@ -934,13 +935,15 @@ static int check_unicast_ttvn(struct bat_priv *bat_priv, ...@@ -934,13 +935,15 @@ static int check_unicast_ttvn(struct bat_priv *bat_priv,
/* we don't have an updated route for this client, so we should /* we don't have an updated route for this client, so we should
* not try to reroute the packet!! * not try to reroute the packet!!
*/ */
if (tt_global_client_is_roaming(bat_priv, ethhdr->h_dest)) if (batadv_tt_global_client_is_roaming(bat_priv,
ethhdr->h_dest))
return 1; return 1;
orig_node = transtable_search(bat_priv, NULL, ethhdr->h_dest); orig_node = batadv_transtable_search(bat_priv, NULL,
ethhdr->h_dest);
if (!orig_node) { if (!orig_node) {
if (!is_my_client(bat_priv, ethhdr->h_dest)) if (!batadv_is_my_client(bat_priv, ethhdr->h_dest))
return 0; return 0;
primary_if = primary_if_get_selected(bat_priv); primary_if = primary_if_get_selected(bat_priv);
if (!primary_if) if (!primary_if)
......
...@@ -109,9 +109,9 @@ static int interface_set_mac_addr(struct net_device *dev, void *p) ...@@ -109,9 +109,9 @@ static int interface_set_mac_addr(struct net_device *dev, void *p)
/* only modify transtable if it has been initialized before */ /* only modify transtable if it has been initialized before */
if (atomic_read(&bat_priv->mesh_state) == MESH_ACTIVE) { if (atomic_read(&bat_priv->mesh_state) == MESH_ACTIVE) {
tt_local_remove(bat_priv, dev->dev_addr, batadv_tt_local_remove(bat_priv, dev->dev_addr,
"mac address changed", false); "mac address changed", false);
tt_local_add(dev, addr->sa_data, NULL_IFINDEX); batadv_tt_local_add(dev, addr->sa_data, NULL_IFINDEX);
} }
memcpy(dev->dev_addr, addr->sa_data, ETH_ALEN); memcpy(dev->dev_addr, addr->sa_data, ETH_ALEN);
...@@ -166,7 +166,7 @@ static int interface_tx(struct sk_buff *skb, struct net_device *soft_iface) ...@@ -166,7 +166,7 @@ static int interface_tx(struct sk_buff *skb, struct net_device *soft_iface)
goto dropped; goto dropped;
/* Register the client MAC in the transtable */ /* Register the client MAC in the transtable */
tt_local_add(soft_iface, ethhdr->h_source, skb->skb_iif); batadv_tt_local_add(soft_iface, ethhdr->h_source, skb->skb_iif);
/* don't accept stp packets. STP does not help in meshes. /* don't accept stp packets. STP does not help in meshes.
* better use the bridge loop avoidance ... * better use the bridge loop avoidance ...
...@@ -303,7 +303,7 @@ void batadv_interface_rx(struct net_device *soft_iface, ...@@ -303,7 +303,7 @@ void batadv_interface_rx(struct net_device *soft_iface,
soft_iface->last_rx = jiffies; soft_iface->last_rx = jiffies;
if (is_ap_isolated(bat_priv, ethhdr->h_source, ethhdr->h_dest)) if (batadv_is_ap_isolated(bat_priv, ethhdr->h_source, ethhdr->h_dest))
goto dropped; goto dropped;
/* Let the bridge loop avoidance check the packet. If will /* Let the bridge loop avoidance check the packet. If will
......
...@@ -173,7 +173,7 @@ static void tt_local_event(struct bat_priv *bat_priv, const uint8_t *addr, ...@@ -173,7 +173,7 @@ static void tt_local_event(struct bat_priv *bat_priv, const uint8_t *addr,
atomic_set(&bat_priv->tt_ogm_append_cnt, 0); atomic_set(&bat_priv->tt_ogm_append_cnt, 0);
} }
int tt_len(int changes_num) int batadv_tt_len(int changes_num)
{ {
return changes_num * sizeof(struct tt_change); return changes_num * sizeof(struct tt_change);
} }
...@@ -191,7 +191,7 @@ static int tt_local_init(struct bat_priv *bat_priv) ...@@ -191,7 +191,7 @@ static int tt_local_init(struct bat_priv *bat_priv)
return 0; return 0;
} }
void tt_local_add(struct net_device *soft_iface, const uint8_t *addr, void batadv_tt_local_add(struct net_device *soft_iface, const uint8_t *addr,
int ifindex) int ifindex)
{ {
struct bat_priv *bat_priv = netdev_priv(soft_iface); struct bat_priv *bat_priv = netdev_priv(soft_iface);
...@@ -302,7 +302,7 @@ static void tt_prepare_packet_buff(struct bat_priv *bat_priv, ...@@ -302,7 +302,7 @@ static void tt_prepare_packet_buff(struct bat_priv *bat_priv,
primary_if = primary_if_get_selected(bat_priv); primary_if = primary_if_get_selected(bat_priv);
req_len = min_packet_len; req_len = min_packet_len;
req_len += tt_len(atomic_read(&bat_priv->tt_local_changes)); req_len += batadv_tt_len(atomic_read(&bat_priv->tt_local_changes));
/* if we have too many changes for one packet don't send any /* if we have too many changes for one packet don't send any
* and wait for the tt table request which will be fragmented * and wait for the tt table request which will be fragmented
...@@ -332,7 +332,7 @@ static int tt_changes_fill_buff(struct bat_priv *bat_priv, ...@@ -332,7 +332,7 @@ static int tt_changes_fill_buff(struct bat_priv *bat_priv,
tt_buff = *packet_buff + min_packet_len; tt_buff = *packet_buff + min_packet_len;
if (new_len > 0) if (new_len > 0)
tot_changes = new_len / tt_len(1); tot_changes = new_len / batadv_tt_len(1);
spin_lock_bh(&bat_priv->tt_changes_list_lock); spin_lock_bh(&bat_priv->tt_changes_list_lock);
atomic_set(&bat_priv->tt_local_changes, 0); atomic_set(&bat_priv->tt_local_changes, 0);
...@@ -340,7 +340,7 @@ static int tt_changes_fill_buff(struct bat_priv *bat_priv, ...@@ -340,7 +340,7 @@ static int tt_changes_fill_buff(struct bat_priv *bat_priv,
list_for_each_entry_safe(entry, safe, &bat_priv->tt_changes_list, list_for_each_entry_safe(entry, safe, &bat_priv->tt_changes_list,
list) { list) {
if (count < tot_changes) { if (count < tot_changes) {
memcpy(tt_buff + tt_len(count), memcpy(tt_buff + batadv_tt_len(count),
&entry->change, sizeof(struct tt_change)); &entry->change, sizeof(struct tt_change));
count++; count++;
} }
...@@ -370,7 +370,7 @@ static int tt_changes_fill_buff(struct bat_priv *bat_priv, ...@@ -370,7 +370,7 @@ static int tt_changes_fill_buff(struct bat_priv *bat_priv,
return count; return count;
} }
int tt_local_seq_print_text(struct seq_file *seq, void *offset) int batadv_tt_local_seq_print_text(struct seq_file *seq, void *offset)
{ {
struct net_device *net_dev = (struct net_device *)seq->private; struct net_device *net_dev = (struct net_device *)seq->private;
struct bat_priv *bat_priv = netdev_priv(net_dev); struct bat_priv *bat_priv = netdev_priv(net_dev);
...@@ -445,7 +445,7 @@ static void tt_local_set_pending(struct bat_priv *bat_priv, ...@@ -445,7 +445,7 @@ static void tt_local_set_pending(struct bat_priv *bat_priv,
tt_local_entry->common.addr, message); tt_local_entry->common.addr, message);
} }
void tt_local_remove(struct bat_priv *bat_priv, const uint8_t *addr, void batadv_tt_local_remove(struct bat_priv *bat_priv, const uint8_t *addr,
const char *message, bool roaming) const char *message, bool roaming)
{ {
struct tt_local_entry *tt_local_entry = NULL; struct tt_local_entry *tt_local_entry = NULL;
...@@ -611,9 +611,9 @@ static void tt_global_add_orig_entry(struct tt_global_entry *tt_global_entry, ...@@ -611,9 +611,9 @@ static void tt_global_add_orig_entry(struct tt_global_entry *tt_global_entry,
} }
/* caller must hold orig_node refcount */ /* caller must hold orig_node refcount */
int tt_global_add(struct bat_priv *bat_priv, struct orig_node *orig_node, int batadv_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 wifi) bool roaming, bool wifi)
{ {
struct tt_global_entry *tt_global_entry = NULL; struct tt_global_entry *tt_global_entry = NULL;
int ret = 0; int ret = 0;
...@@ -677,7 +677,7 @@ int tt_global_add(struct bat_priv *bat_priv, struct orig_node *orig_node, ...@@ -677,7 +677,7 @@ int tt_global_add(struct bat_priv *bat_priv, struct orig_node *orig_node,
out_remove: out_remove:
/* remove address from local hash if present */ /* remove address from local hash if present */
tt_local_remove(bat_priv, tt_global_entry->common.addr, batadv_tt_local_remove(bat_priv, tt_global_entry->common.addr,
"global tt received", roaming); "global tt received", roaming);
ret = 1; ret = 1;
out: out:
...@@ -714,7 +714,7 @@ static void tt_global_print_entry(struct tt_global_entry *tt_global_entry, ...@@ -714,7 +714,7 @@ static void tt_global_print_entry(struct tt_global_entry *tt_global_entry,
} }
} }
int tt_global_seq_print_text(struct seq_file *seq, void *offset) int batadv_tt_global_seq_print_text(struct seq_file *seq, void *offset)
{ {
struct net_device *net_dev = (struct net_device *)seq->private; struct net_device *net_dev = (struct net_device *)seq->private;
struct bat_priv *bat_priv = netdev_priv(net_dev); struct bat_priv *bat_priv = netdev_priv(net_dev);
...@@ -919,7 +919,7 @@ static void tt_global_del(struct bat_priv *bat_priv, ...@@ -919,7 +919,7 @@ static void tt_global_del(struct bat_priv *bat_priv,
tt_local_entry_free_ref(tt_local_entry); tt_local_entry_free_ref(tt_local_entry);
} }
void tt_global_del_orig(struct bat_priv *bat_priv, void batadv_tt_global_del_orig(struct bat_priv *bat_priv,
struct orig_node *orig_node, const char *message) struct orig_node *orig_node, const char *message)
{ {
struct tt_global_entry *tt_global_entry; struct tt_global_entry *tt_global_entry;
...@@ -1048,8 +1048,9 @@ static bool _is_ap_isolated(struct tt_local_entry *tt_local_entry, ...@@ -1048,8 +1048,9 @@ static bool _is_ap_isolated(struct tt_local_entry *tt_local_entry,
return ret; return ret;
} }
struct orig_node *transtable_search(struct bat_priv *bat_priv, struct orig_node *batadv_transtable_search(struct bat_priv *bat_priv,
const uint8_t *src, const uint8_t *addr) const uint8_t *src,
const uint8_t *addr)
{ {
struct tt_local_entry *tt_local_entry = NULL; struct tt_local_entry *tt_local_entry = NULL;
struct tt_global_entry *tt_global_entry = NULL; struct tt_global_entry *tt_global_entry = NULL;
...@@ -1204,7 +1205,7 @@ static void tt_save_orig_buffer(struct bat_priv *bat_priv, ...@@ -1204,7 +1205,7 @@ static void tt_save_orig_buffer(struct bat_priv *bat_priv,
const unsigned char *tt_buff, const unsigned char *tt_buff,
uint8_t tt_num_changes) uint8_t tt_num_changes)
{ {
uint16_t tt_buff_len = tt_len(tt_num_changes); uint16_t tt_buff_len = batadv_tt_len(tt_num_changes);
/* Replace the old buffer only if I received something in the /* Replace the old buffer only if I received something in the
* last OGM (the OGM could carry no changes) */ * last OGM (the OGM could carry no changes) */
...@@ -1669,7 +1670,7 @@ static bool send_my_tt_response(struct bat_priv *bat_priv, ...@@ -1669,7 +1670,7 @@ static bool send_my_tt_response(struct bat_priv *bat_priv,
return true; return true;
} }
bool send_tt_response(struct bat_priv *bat_priv, bool batadv_send_tt_response(struct bat_priv *bat_priv,
struct tt_query_packet *tt_request) struct tt_query_packet *tt_request)
{ {
if (is_my_mac(tt_request->dst)) { if (is_my_mac(tt_request->dst)) {
...@@ -1689,18 +1690,19 @@ static void _tt_update_changes(struct bat_priv *bat_priv, ...@@ -1689,18 +1690,19 @@ static void _tt_update_changes(struct bat_priv *bat_priv,
uint16_t tt_num_changes, uint8_t ttvn) uint16_t tt_num_changes, uint8_t ttvn)
{ {
int i; int i;
int is_wifi;
for (i = 0; i < tt_num_changes; i++) { for (i = 0; i < tt_num_changes; i++) {
if ((tt_change + i)->flags & TT_CLIENT_DEL) if ((tt_change + i)->flags & TT_CLIENT_DEL) {
tt_global_del(bat_priv, orig_node, tt_global_del(bat_priv, orig_node,
(tt_change + i)->addr, (tt_change + i)->addr,
"tt removed by changes", "tt removed by changes",
(tt_change + i)->flags & TT_CLIENT_ROAM); (tt_change + i)->flags & TT_CLIENT_ROAM);
else } else {
if (!tt_global_add(bat_priv, orig_node, is_wifi = (tt_change + i)->flags & TT_CLIENT_WIFI;
(tt_change + i)->addr, ttvn, false, if (!batadv_tt_global_add(bat_priv, orig_node,
(tt_change + i)->flags & (tt_change + i)->addr, ttvn,
TT_CLIENT_WIFI)) false, is_wifi))
/* In case of problem while storing a /* In case of problem while storing a
* global_entry, we stop the updating * global_entry, we stop the updating
* procedure without committing the * procedure without committing the
...@@ -1709,6 +1711,7 @@ static void _tt_update_changes(struct bat_priv *bat_priv, ...@@ -1709,6 +1711,7 @@ static void _tt_update_changes(struct bat_priv *bat_priv,
*/ */
return; return;
} }
}
orig_node->tt_initialised = true; orig_node->tt_initialised = true;
} }
...@@ -1722,7 +1725,7 @@ static void tt_fill_gtable(struct bat_priv *bat_priv, ...@@ -1722,7 +1725,7 @@ static void tt_fill_gtable(struct bat_priv *bat_priv,
goto out; goto out;
/* Purge the old table first.. */ /* Purge the old table first.. */
tt_global_del_orig(bat_priv, orig_node, "Received full table"); batadv_tt_global_del_orig(bat_priv, orig_node, "Received full table");
_tt_update_changes(bat_priv, orig_node, _tt_update_changes(bat_priv, orig_node,
(struct tt_change *)(tt_response + 1), (struct tt_change *)(tt_response + 1),
...@@ -1754,7 +1757,7 @@ static void tt_update_changes(struct bat_priv *bat_priv, ...@@ -1754,7 +1757,7 @@ static void tt_update_changes(struct bat_priv *bat_priv,
atomic_set(&orig_node->last_ttvn, ttvn); atomic_set(&orig_node->last_ttvn, ttvn);
} }
bool is_my_client(struct bat_priv *bat_priv, const uint8_t *addr) bool batadv_is_my_client(struct bat_priv *bat_priv, const uint8_t *addr)
{ {
struct tt_local_entry *tt_local_entry = NULL; struct tt_local_entry *tt_local_entry = NULL;
bool ret = false; bool ret = false;
...@@ -1773,7 +1776,7 @@ bool is_my_client(struct bat_priv *bat_priv, const uint8_t *addr) ...@@ -1773,7 +1776,7 @@ bool is_my_client(struct bat_priv *bat_priv, const uint8_t *addr)
return ret; return ret;
} }
void handle_tt_response(struct bat_priv *bat_priv, void batadv_handle_tt_response(struct bat_priv *bat_priv,
struct tt_query_packet *tt_response) struct tt_query_packet *tt_response)
{ {
struct tt_req_node *node, *safe; struct tt_req_node *node, *safe;
...@@ -1821,7 +1824,7 @@ void handle_tt_response(struct bat_priv *bat_priv, ...@@ -1821,7 +1824,7 @@ void handle_tt_response(struct bat_priv *bat_priv,
batadv_orig_node_free_ref(orig_node); batadv_orig_node_free_ref(orig_node);
} }
int tt_init(struct bat_priv *bat_priv) int batadv_tt_init(struct bat_priv *bat_priv)
{ {
int ret; int ret;
...@@ -1983,7 +1986,7 @@ static void tt_purge(struct work_struct *work) ...@@ -1983,7 +1986,7 @@ static void tt_purge(struct work_struct *work)
tt_start_timer(bat_priv); tt_start_timer(bat_priv);
} }
void tt_free(struct bat_priv *bat_priv) void batadv_tt_free(struct bat_priv *bat_priv)
{ {
cancel_delayed_work_sync(&bat_priv->tt_work); cancel_delayed_work_sync(&bat_priv->tt_work);
...@@ -2125,7 +2128,8 @@ int batadv_tt_append_diff(struct bat_priv *bat_priv, ...@@ -2125,7 +2128,8 @@ int batadv_tt_append_diff(struct bat_priv *bat_priv,
return tt_num_changes; return tt_num_changes;
} }
bool is_ap_isolated(struct bat_priv *bat_priv, uint8_t *src, uint8_t *dst) bool batadv_is_ap_isolated(struct bat_priv *bat_priv, uint8_t *src,
uint8_t *dst)
{ {
struct tt_local_entry *tt_local_entry = NULL; struct tt_local_entry *tt_local_entry = NULL;
struct tt_global_entry *tt_global_entry = NULL; struct tt_global_entry *tt_global_entry = NULL;
...@@ -2155,7 +2159,8 @@ bool is_ap_isolated(struct bat_priv *bat_priv, uint8_t *src, uint8_t *dst) ...@@ -2155,7 +2159,8 @@ bool is_ap_isolated(struct bat_priv *bat_priv, uint8_t *src, uint8_t *dst)
return ret; return ret;
} }
void tt_update_orig(struct bat_priv *bat_priv, struct orig_node *orig_node, void batadv_tt_update_orig(struct bat_priv *bat_priv,
struct orig_node *orig_node,
const unsigned char *tt_buff, uint8_t tt_num_changes, const unsigned char *tt_buff, uint8_t tt_num_changes,
uint8_t ttvn, uint16_t tt_crc) uint8_t ttvn, uint16_t tt_crc)
{ {
...@@ -2222,7 +2227,8 @@ void tt_update_orig(struct bat_priv *bat_priv, struct orig_node *orig_node, ...@@ -2222,7 +2227,8 @@ void tt_update_orig(struct bat_priv *bat_priv, struct orig_node *orig_node,
* originator to another one. This entry is kept is still kept for consistency * originator to another one. This entry is kept is still kept for consistency
* purposes * purposes
*/ */
bool tt_global_client_is_roaming(struct bat_priv *bat_priv, uint8_t *addr) bool batadv_tt_global_client_is_roaming(struct bat_priv *bat_priv,
uint8_t *addr)
{ {
struct tt_global_entry *tt_global_entry; struct tt_global_entry *tt_global_entry;
bool ret = false; bool ret = false;
......
...@@ -22,37 +22,44 @@ ...@@ -22,37 +22,44 @@
#ifndef _NET_BATMAN_ADV_TRANSLATION_TABLE_H_ #ifndef _NET_BATMAN_ADV_TRANSLATION_TABLE_H_
#define _NET_BATMAN_ADV_TRANSLATION_TABLE_H_ #define _NET_BATMAN_ADV_TRANSLATION_TABLE_H_
int tt_len(int changes_num); int batadv_tt_len(int changes_num);
int tt_init(struct bat_priv *bat_priv); int batadv_tt_init(struct bat_priv *bat_priv);
void tt_local_add(struct net_device *soft_iface, const uint8_t *addr, void batadv_tt_local_add(struct net_device *soft_iface, const uint8_t *addr,
int ifindex); int ifindex);
void tt_local_remove(struct bat_priv *bat_priv, void batadv_tt_local_remove(struct bat_priv *bat_priv,
const uint8_t *addr, const char *message, bool roaming); const uint8_t *addr, const char *message,
int tt_local_seq_print_text(struct seq_file *seq, void *offset); bool roaming);
void tt_global_add_orig(struct bat_priv *bat_priv, struct orig_node *orig_node, int batadv_tt_local_seq_print_text(struct seq_file *seq, void *offset);
void batadv_tt_global_add_orig(struct bat_priv *bat_priv,
struct orig_node *orig_node,
const unsigned char *tt_buff, int tt_buff_len); const unsigned char *tt_buff, int tt_buff_len);
int tt_global_add(struct bat_priv *bat_priv, struct orig_node *orig_node, int batadv_tt_global_add(struct bat_priv *bat_priv, struct orig_node *orig_node,
const unsigned char *addr, uint8_t ttvn, bool roaming, const unsigned char *addr, uint8_t ttvn, bool roaming,
bool wifi); bool wifi);
int tt_global_seq_print_text(struct seq_file *seq, void *offset); int batadv_tt_global_seq_print_text(struct seq_file *seq, void *offset);
void tt_global_del_orig(struct bat_priv *bat_priv, void batadv_tt_global_del_orig(struct bat_priv *bat_priv,
struct orig_node *orig_node, const char *message); struct orig_node *orig_node,
struct orig_node *transtable_search(struct bat_priv *bat_priv, const char *message);
const uint8_t *src, const uint8_t *addr); struct orig_node *batadv_transtable_search(struct bat_priv *bat_priv,
void tt_free(struct bat_priv *bat_priv); const uint8_t *src,
bool send_tt_response(struct bat_priv *bat_priv, const uint8_t *addr);
void batadv_tt_free(struct bat_priv *bat_priv);
bool batadv_send_tt_response(struct bat_priv *bat_priv,
struct tt_query_packet *tt_request); struct tt_query_packet *tt_request);
bool is_my_client(struct bat_priv *bat_priv, const uint8_t *addr); bool batadv_is_my_client(struct bat_priv *bat_priv, const uint8_t *addr);
void handle_tt_response(struct bat_priv *bat_priv, void batadv_handle_tt_response(struct bat_priv *bat_priv,
struct tt_query_packet *tt_response); struct tt_query_packet *tt_response);
bool is_ap_isolated(struct bat_priv *bat_priv, uint8_t *src, uint8_t *dst); bool batadv_is_ap_isolated(struct bat_priv *bat_priv, uint8_t *src,
void tt_update_orig(struct bat_priv *bat_priv, struct orig_node *orig_node, uint8_t *dst);
void batadv_tt_update_orig(struct bat_priv *bat_priv,
struct orig_node *orig_node,
const unsigned char *tt_buff, uint8_t tt_num_changes, const unsigned char *tt_buff, uint8_t tt_num_changes,
uint8_t ttvn, uint16_t tt_crc); uint8_t ttvn, uint16_t tt_crc);
int batadv_tt_append_diff(struct bat_priv *bat_priv, int batadv_tt_append_diff(struct bat_priv *bat_priv,
unsigned char **packet_buff, int *packet_buff_len, unsigned char **packet_buff, int *packet_buff_len,
int packet_min_len); int packet_min_len);
bool tt_global_client_is_roaming(struct bat_priv *bat_priv, uint8_t *addr); bool batadv_tt_global_client_is_roaming(struct bat_priv *bat_priv,
uint8_t *addr);
#endif /* _NET_BATMAN_ADV_TRANSLATION_TABLE_H_ */ #endif /* _NET_BATMAN_ADV_TRANSLATION_TABLE_H_ */
...@@ -301,9 +301,8 @@ int unicast_send_skb(struct sk_buff *skb, struct bat_priv *bat_priv) ...@@ -301,9 +301,8 @@ int unicast_send_skb(struct sk_buff *skb, struct bat_priv *bat_priv)
/* check for tt host - increases orig_node refcount. /* check for tt host - increases orig_node refcount.
* returns NULL in case of AP isolation */ * returns NULL in case of AP isolation */
orig_node = transtable_search(bat_priv, ethhdr->h_source, orig_node = batadv_transtable_search(bat_priv, ethhdr->h_source,
ethhdr->h_dest); ethhdr->h_dest);
find_router: find_router:
/** /**
* find_router(): * find_router():
...@@ -335,7 +334,7 @@ int unicast_send_skb(struct sk_buff *skb, struct bat_priv *bat_priv) ...@@ -335,7 +334,7 @@ int unicast_send_skb(struct sk_buff *skb, struct bat_priv *bat_priv)
* try to reroute it because the ttvn contained in the header is less * try to reroute it because the ttvn contained in the header is less
* than the current one * than the current one
*/ */
if (tt_global_client_is_roaming(bat_priv, ethhdr->h_dest)) if (batadv_tt_global_client_is_roaming(bat_priv, ethhdr->h_dest))
unicast_packet->ttvn = unicast_packet->ttvn - 1; unicast_packet->ttvn = unicast_packet->ttvn - 1;
if (atomic_read(&bat_priv->fragmentation) && if (atomic_read(&bat_priv->fragmentation) &&
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册