提交 d4f44692 编写于 作者: A Antonio Quartulli

batman-adv: beautify tt_global_add() argument list

Instead of adding a new bool argument each time it is needed, it is better (and
simpler) to pass an 8bit flag argument which contains all the needed flags
Signed-off-by: NAntonio Quartulli <ordex@autistici.org>
Signed-off-by: NSven Eckelmann <sven@narfation.org>
上级 3b643de5
...@@ -699,8 +699,8 @@ int batadv_recv_roam_adv(struct sk_buff *skb, struct hard_iface *recv_if) ...@@ -699,8 +699,8 @@ int batadv_recv_roam_adv(struct sk_buff *skb, struct hard_iface *recv_if)
roam_adv_packet->src, roam_adv_packet->client); roam_adv_packet->src, roam_adv_packet->client);
batadv_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, TT_CLIENT_ROAM,
false); atomic_read(&orig_node->last_ttvn) + 1);
/* 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
......
...@@ -657,8 +657,8 @@ batadv_tt_global_add_orig_entry(struct tt_global_entry *tt_global_entry, ...@@ -657,8 +657,8 @@ batadv_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 batadv_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, const unsigned char *tt_addr, uint8_t flags,
bool roaming, bool wifi) uint8_t ttvn)
{ {
struct tt_global_entry *tt_global_entry = NULL; struct tt_global_entry *tt_global_entry = NULL;
int ret = 0; int ret = 0;
...@@ -668,15 +668,14 @@ int batadv_tt_global_add(struct bat_priv *bat_priv, struct orig_node *orig_node, ...@@ -668,15 +668,14 @@ int batadv_tt_global_add(struct bat_priv *bat_priv, struct orig_node *orig_node,
tt_global_entry = batadv_tt_global_hash_find(bat_priv, tt_addr); tt_global_entry = batadv_tt_global_hash_find(bat_priv, tt_addr);
if (!tt_global_entry) { if (!tt_global_entry) {
tt_global_entry = kzalloc(sizeof(*tt_global_entry), tt_global_entry = kzalloc(sizeof(*tt_global_entry), GFP_ATOMIC);
GFP_ATOMIC);
if (!tt_global_entry) if (!tt_global_entry)
goto out; goto out;
common = &tt_global_entry->common; common = &tt_global_entry->common;
memcpy(common->addr, tt_addr, ETH_ALEN); memcpy(common->addr, tt_addr, ETH_ALEN);
common->flags = NO_FLAGS; common->flags = flags;
tt_global_entry->roam_at = 0; tt_global_entry->roam_at = 0;
atomic_set(&common->refcount, 2); atomic_set(&common->refcount, 2);
...@@ -718,9 +717,6 @@ int batadv_tt_global_add(struct bat_priv *bat_priv, struct orig_node *orig_node, ...@@ -718,9 +717,6 @@ int batadv_tt_global_add(struct bat_priv *bat_priv, struct orig_node *orig_node,
orig_node, ttvn); orig_node, ttvn);
} }
if (wifi)
tt_global_entry->common.flags |= TT_CLIENT_WIFI;
batadv_dbg(DBG_TT, bat_priv, batadv_dbg(DBG_TT, bat_priv,
"Creating new global tt entry: %pM (via %pM)\n", "Creating new global tt entry: %pM (via %pM)\n",
tt_global_entry->common.addr, orig_node->orig); tt_global_entry->common.addr, orig_node->orig);
...@@ -728,7 +724,7 @@ int batadv_tt_global_add(struct bat_priv *bat_priv, struct orig_node *orig_node, ...@@ -728,7 +724,7 @@ int batadv_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 */
batadv_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", flags & TT_CLIENT_ROAM);
ret = 1; ret = 1;
out: out:
if (tt_global_entry) if (tt_global_entry)
...@@ -1755,7 +1751,6 @@ static void _batadv_tt_update_changes(struct bat_priv *bat_priv, ...@@ -1755,7 +1751,6 @@ static void _batadv_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;
int roams; int roams;
for (i = 0; i < tt_num_changes; i++) { for (i = 0; i < tt_num_changes; i++) {
...@@ -1763,13 +1758,12 @@ static void _batadv_tt_update_changes(struct bat_priv *bat_priv, ...@@ -1763,13 +1758,12 @@ static void _batadv_tt_update_changes(struct bat_priv *bat_priv,
roams = (tt_change + i)->flags & TT_CLIENT_ROAM; roams = (tt_change + i)->flags & TT_CLIENT_ROAM;
batadv_tt_global_del(bat_priv, orig_node, batadv_tt_global_del(bat_priv, orig_node,
(tt_change + i)->addr, (tt_change + i)->addr,
"tt removed by changes", "tt removed by changes",
roams); roams);
} else { } else {
is_wifi = (tt_change + i)->flags & TT_CLIENT_WIFI;
if (!batadv_tt_global_add(bat_priv, orig_node, if (!batadv_tt_global_add(bat_priv, orig_node,
(tt_change + i)->addr, ttvn, (tt_change + i)->addr,
false, is_wifi)) (tt_change + i)->flags, ttvn))
/* 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
......
...@@ -32,8 +32,8 @@ void batadv_tt_global_add_orig(struct bat_priv *bat_priv, ...@@ -32,8 +32,8 @@ void batadv_tt_global_add_orig(struct bat_priv *bat_priv,
struct orig_node *orig_node, struct orig_node *orig_node,
const unsigned char *tt_buff, int tt_buff_len); const unsigned char *tt_buff, int tt_buff_len);
int batadv_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 flags,
bool wifi); uint8_t ttvn);
int batadv_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 batadv_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, struct orig_node *orig_node,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册