Commit 48100bac authored by Antonio Quartulli's avatar Antonio Quartulli Committed by Sven Eckelmann

batman-adv: create a common substructure for tt_global/local_entry

Several functions in the translation table management code assume that the
tt_global_entry and tt_local_entry structures have the same initial fields such
as 'addr' and 'hash_entry'. To improve the code readability and to avoid
mistakes in later changes, a common substructure that substitute the shared
fields has been introduced (struct tt_common_entry).

Thanks to this modification, it has also been possible to slightly reduce the
code length by merging some functions like compare_ltt/gtt() and
tt_local/global_hash_find()
Signed-off-by: default avatarAntonio Quartulli <ordex@autistici.org>
Signed-off-by: default avatarSven Eckelmann <sven@narfation.org>
parent ad244312
This diff is collapsed.
...@@ -222,24 +222,24 @@ struct socket_packet { ...@@ -222,24 +222,24 @@ struct socket_packet {
struct icmp_packet_rr icmp_packet; struct icmp_packet_rr icmp_packet;
}; };
struct tt_local_entry { struct tt_common_entry {
uint8_t addr[ETH_ALEN]; uint8_t addr[ETH_ALEN];
struct hlist_node hash_entry; struct hlist_node hash_entry;
unsigned long last_seen;
uint16_t flags; uint16_t flags;
atomic_t refcount; atomic_t refcount;
struct rcu_head rcu; struct rcu_head rcu;
}; };
struct tt_local_entry {
struct tt_common_entry common;
unsigned long last_seen;
};
struct tt_global_entry { struct tt_global_entry {
uint8_t addr[ETH_ALEN]; struct tt_common_entry common;
struct hlist_node hash_entry; /* entry in the global table */
struct orig_node *orig_node; struct orig_node *orig_node;
uint8_t ttvn; uint8_t ttvn;
uint16_t flags; /* only TT_GLOBAL_ROAM is used */
unsigned long roam_at; /* time at which TT_GLOBAL_ROAM was set */ unsigned long roam_at; /* time at which TT_GLOBAL_ROAM was set */
atomic_t refcount;
struct rcu_head rcu;
}; };
struct tt_change_node { struct tt_change_node {
......
...@@ -609,7 +609,7 @@ static int generate_vis_packet(struct bat_priv *bat_priv) ...@@ -609,7 +609,7 @@ static int generate_vis_packet(struct bat_priv *bat_priv)
struct vis_info *info = bat_priv->my_vis_info; struct vis_info *info = bat_priv->my_vis_info;
struct vis_packet *packet = (struct vis_packet *)info->skb_packet->data; struct vis_packet *packet = (struct vis_packet *)info->skb_packet->data;
struct vis_info_entry *entry; struct vis_info_entry *entry;
struct tt_local_entry *tt_local_entry; struct tt_common_entry *tt_common_entry;
int best_tq = -1; int best_tq = -1;
uint32_t i; uint32_t i;
...@@ -672,13 +672,13 @@ static int generate_vis_packet(struct bat_priv *bat_priv) ...@@ -672,13 +672,13 @@ static int generate_vis_packet(struct bat_priv *bat_priv)
head = &hash->table[i]; head = &hash->table[i];
rcu_read_lock(); rcu_read_lock();
hlist_for_each_entry_rcu(tt_local_entry, node, head, hlist_for_each_entry_rcu(tt_common_entry, node, head,
hash_entry) { hash_entry) {
entry = (struct vis_info_entry *) entry = (struct vis_info_entry *)
skb_put(info->skb_packet, skb_put(info->skb_packet,
sizeof(*entry)); sizeof(*entry));
memset(entry->src, 0, ETH_ALEN); memset(entry->src, 0, ETH_ALEN);
memcpy(entry->dest, tt_local_entry->addr, ETH_ALEN); memcpy(entry->dest, tt_common_entry->addr, ETH_ALEN);
entry->quality = 0; /* 0 means TT */ entry->quality = 0; /* 0 means TT */
packet->entries++; packet->entries++;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment