diff options
author | Antonio Quartulli <ordex@autistici.org> | 2012-05-24 18:00:54 -0400 |
---|---|---|
committer | Antonio Quartulli <ordex@autistici.org> | 2012-06-28 02:44:52 -0400 |
commit | d4f4469255359c97564b15b5ef04253fd3ec08f1 (patch) | |
tree | b9752e703c15bc1499439699ea0bbff56c325316 /net/batman-adv | |
parent | 3b643de541d4051f236f1e422f3329cccb7bd9c5 (diff) |
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: Antonio Quartulli <ordex@autistici.org>
Signed-off-by: Sven Eckelmann <sven@narfation.org>
Diffstat (limited to 'net/batman-adv')
-rw-r--r-- | net/batman-adv/routing.c | 4 | ||||
-rw-r--r-- | net/batman-adv/translation-table.c | 24 | ||||
-rw-r--r-- | net/batman-adv/translation-table.h | 4 |
3 files changed, 13 insertions, 19 deletions
diff --git a/net/batman-adv/routing.c b/net/batman-adv/routing.c index 1b8f67744e23..864692add808 100644 --- a/net/batman-adv/routing.c +++ b/net/batman-adv/routing.c | |||
@@ -699,8 +699,8 @@ int batadv_recv_roam_adv(struct sk_buff *skb, struct hard_iface *recv_if) | |||
699 | roam_adv_packet->src, roam_adv_packet->client); | 699 | roam_adv_packet->src, roam_adv_packet->client); |
700 | 700 | ||
701 | batadv_tt_global_add(bat_priv, orig_node, roam_adv_packet->client, | 701 | batadv_tt_global_add(bat_priv, orig_node, roam_adv_packet->client, |
702 | atomic_read(&orig_node->last_ttvn) + 1, true, | 702 | TT_CLIENT_ROAM, |
703 | false); | 703 | atomic_read(&orig_node->last_ttvn) + 1); |
704 | 704 | ||
705 | /* Roaming phase starts: I have new information but the ttvn has not | 705 | /* Roaming phase starts: I have new information but the ttvn has not |
706 | * been incremented yet. This flag will make me check all the incoming | 706 | * been incremented yet. This flag will make me check all the incoming |
diff --git a/net/batman-adv/translation-table.c b/net/batman-adv/translation-table.c index d82766bfd264..3ca2e48d669e 100644 --- a/net/batman-adv/translation-table.c +++ b/net/batman-adv/translation-table.c | |||
@@ -657,8 +657,8 @@ batadv_tt_global_add_orig_entry(struct tt_global_entry *tt_global_entry, | |||
657 | 657 | ||
658 | /* caller must hold orig_node refcount */ | 658 | /* caller must hold orig_node refcount */ |
659 | int batadv_tt_global_add(struct bat_priv *bat_priv, struct orig_node *orig_node, | 659 | int batadv_tt_global_add(struct bat_priv *bat_priv, struct orig_node *orig_node, |
660 | const unsigned char *tt_addr, uint8_t ttvn, | 660 | const unsigned char *tt_addr, uint8_t flags, |
661 | bool roaming, bool wifi) | 661 | uint8_t ttvn) |
662 | { | 662 | { |
663 | struct tt_global_entry *tt_global_entry = NULL; | 663 | struct tt_global_entry *tt_global_entry = NULL; |
664 | int ret = 0; | 664 | int ret = 0; |
@@ -668,15 +668,14 @@ int batadv_tt_global_add(struct bat_priv *bat_priv, struct orig_node *orig_node, | |||
668 | tt_global_entry = batadv_tt_global_hash_find(bat_priv, tt_addr); | 668 | tt_global_entry = batadv_tt_global_hash_find(bat_priv, tt_addr); |
669 | 669 | ||
670 | if (!tt_global_entry) { | 670 | if (!tt_global_entry) { |
671 | tt_global_entry = kzalloc(sizeof(*tt_global_entry), | 671 | tt_global_entry = kzalloc(sizeof(*tt_global_entry), GFP_ATOMIC); |
672 | GFP_ATOMIC); | ||
673 | if (!tt_global_entry) | 672 | if (!tt_global_entry) |
674 | goto out; | 673 | goto out; |
675 | 674 | ||
676 | common = &tt_global_entry->common; | 675 | common = &tt_global_entry->common; |
677 | memcpy(common->addr, tt_addr, ETH_ALEN); | 676 | memcpy(common->addr, tt_addr, ETH_ALEN); |
678 | 677 | ||
679 | common->flags = NO_FLAGS; | 678 | common->flags = flags; |
680 | tt_global_entry->roam_at = 0; | 679 | tt_global_entry->roam_at = 0; |
681 | atomic_set(&common->refcount, 2); | 680 | atomic_set(&common->refcount, 2); |
682 | 681 | ||
@@ -718,9 +717,6 @@ int batadv_tt_global_add(struct bat_priv *bat_priv, struct orig_node *orig_node, | |||
718 | orig_node, ttvn); | 717 | orig_node, ttvn); |
719 | } | 718 | } |
720 | 719 | ||
721 | if (wifi) | ||
722 | tt_global_entry->common.flags |= TT_CLIENT_WIFI; | ||
723 | |||
724 | batadv_dbg(DBG_TT, bat_priv, | 720 | batadv_dbg(DBG_TT, bat_priv, |
725 | "Creating new global tt entry: %pM (via %pM)\n", | 721 | "Creating new global tt entry: %pM (via %pM)\n", |
726 | tt_global_entry->common.addr, orig_node->orig); | 722 | 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 | out_remove: | 724 | out_remove: |
729 | /* remove address from local hash if present */ | 725 | /* remove address from local hash if present */ |
730 | batadv_tt_local_remove(bat_priv, tt_global_entry->common.addr, | 726 | batadv_tt_local_remove(bat_priv, tt_global_entry->common.addr, |
731 | "global tt received", roaming); | 727 | "global tt received", flags & TT_CLIENT_ROAM); |
732 | ret = 1; | 728 | ret = 1; |
733 | out: | 729 | out: |
734 | if (tt_global_entry) | 730 | if (tt_global_entry) |
@@ -1755,7 +1751,6 @@ static void _batadv_tt_update_changes(struct bat_priv *bat_priv, | |||
1755 | uint16_t tt_num_changes, uint8_t ttvn) | 1751 | uint16_t tt_num_changes, uint8_t ttvn) |
1756 | { | 1752 | { |
1757 | int i; | 1753 | int i; |
1758 | int is_wifi; | ||
1759 | int roams; | 1754 | int roams; |
1760 | 1755 | ||
1761 | for (i = 0; i < tt_num_changes; i++) { | 1756 | for (i = 0; i < tt_num_changes; i++) { |
@@ -1763,13 +1758,12 @@ static void _batadv_tt_update_changes(struct bat_priv *bat_priv, | |||
1763 | roams = (tt_change + i)->flags & TT_CLIENT_ROAM; | 1758 | roams = (tt_change + i)->flags & TT_CLIENT_ROAM; |
1764 | batadv_tt_global_del(bat_priv, orig_node, | 1759 | batadv_tt_global_del(bat_priv, orig_node, |
1765 | (tt_change + i)->addr, | 1760 | (tt_change + i)->addr, |
1766 | "tt removed by changes", | 1761 | "tt removed by changes", |
1767 | roams); | 1762 | roams); |
1768 | } else { | 1763 | } else { |
1769 | is_wifi = (tt_change + i)->flags & TT_CLIENT_WIFI; | ||
1770 | if (!batadv_tt_global_add(bat_priv, orig_node, | 1764 | if (!batadv_tt_global_add(bat_priv, orig_node, |
1771 | (tt_change + i)->addr, ttvn, | 1765 | (tt_change + i)->addr, |
1772 | false, is_wifi)) | 1766 | (tt_change + i)->flags, ttvn)) |
1773 | /* In case of problem while storing a | 1767 | /* In case of problem while storing a |
1774 | * global_entry, we stop the updating | 1768 | * global_entry, we stop the updating |
1775 | * procedure without committing the | 1769 | * procedure without committing the |
diff --git a/net/batman-adv/translation-table.h b/net/batman-adv/translation-table.h index 7edc9dff8ba1..46b60bd822fe 100644 --- a/net/batman-adv/translation-table.h +++ b/net/batman-adv/translation-table.h | |||
@@ -32,8 +32,8 @@ void batadv_tt_global_add_orig(struct bat_priv *bat_priv, | |||
32 | struct orig_node *orig_node, | 32 | struct orig_node *orig_node, |
33 | const unsigned char *tt_buff, int tt_buff_len); | 33 | const unsigned char *tt_buff, int tt_buff_len); |
34 | int batadv_tt_global_add(struct bat_priv *bat_priv, struct orig_node *orig_node, | 34 | int batadv_tt_global_add(struct bat_priv *bat_priv, struct orig_node *orig_node, |
35 | const unsigned char *addr, uint8_t ttvn, bool roaming, | 35 | const unsigned char *addr, uint8_t flags, |
36 | bool wifi); | 36 | uint8_t ttvn); |
37 | int batadv_tt_global_seq_print_text(struct seq_file *seq, void *offset); | 37 | int batadv_tt_global_seq_print_text(struct seq_file *seq, void *offset); |
38 | void batadv_tt_global_del_orig(struct bat_priv *bat_priv, | 38 | void batadv_tt_global_del_orig(struct bat_priv *bat_priv, |
39 | struct orig_node *orig_node, | 39 | struct orig_node *orig_node, |