Commit d4f4469255359c97564b15b5ef04253fd3ec08f1
1 parent
3b643de541
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>
Showing 3 changed files with 13 additions and 19 deletions Side-by-side Diff
net/batman-adv/routing.c
... | ... | @@ -699,8 +699,8 @@ |
699 | 699 | roam_adv_packet->src, roam_adv_packet->client); |
700 | 700 | |
701 | 701 | batadv_tt_global_add(bat_priv, orig_node, roam_adv_packet->client, |
702 | - atomic_read(&orig_node->last_ttvn) + 1, true, | |
703 | - false); | |
702 | + TT_CLIENT_ROAM, | |
703 | + atomic_read(&orig_node->last_ttvn) + 1); | |
704 | 704 | |
705 | 705 | /* Roaming phase starts: I have new information but the ttvn has not |
706 | 706 | * been incremented yet. This flag will make me check all the incoming |
net/batman-adv/translation-table.c
... | ... | @@ -657,8 +657,8 @@ |
657 | 657 | |
658 | 658 | /* caller must hold orig_node refcount */ |
659 | 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, | |
661 | - bool roaming, bool wifi) | |
660 | + const unsigned char *tt_addr, uint8_t flags, | |
661 | + uint8_t ttvn) | |
662 | 662 | { |
663 | 663 | struct tt_global_entry *tt_global_entry = NULL; |
664 | 664 | int ret = 0; |
665 | 665 | |
... | ... | @@ -668,15 +668,14 @@ |
668 | 668 | tt_global_entry = batadv_tt_global_hash_find(bat_priv, tt_addr); |
669 | 669 | |
670 | 670 | if (!tt_global_entry) { |
671 | - tt_global_entry = kzalloc(sizeof(*tt_global_entry), | |
672 | - GFP_ATOMIC); | |
671 | + tt_global_entry = kzalloc(sizeof(*tt_global_entry), GFP_ATOMIC); | |
673 | 672 | if (!tt_global_entry) |
674 | 673 | goto out; |
675 | 674 | |
676 | 675 | common = &tt_global_entry->common; |
677 | 676 | memcpy(common->addr, tt_addr, ETH_ALEN); |
678 | 677 | |
679 | - common->flags = NO_FLAGS; | |
678 | + common->flags = flags; | |
680 | 679 | tt_global_entry->roam_at = 0; |
681 | 680 | atomic_set(&common->refcount, 2); |
682 | 681 | |
... | ... | @@ -718,9 +717,6 @@ |
718 | 717 | orig_node, ttvn); |
719 | 718 | } |
720 | 719 | |
721 | - if (wifi) | |
722 | - tt_global_entry->common.flags |= TT_CLIENT_WIFI; | |
723 | - | |
724 | 720 | batadv_dbg(DBG_TT, bat_priv, |
725 | 721 | "Creating new global tt entry: %pM (via %pM)\n", |
726 | 722 | tt_global_entry->common.addr, orig_node->orig); |
... | ... | @@ -728,7 +724,7 @@ |
728 | 724 | out_remove: |
729 | 725 | /* remove address from local hash if present */ |
730 | 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 | 728 | ret = 1; |
733 | 729 | out: |
734 | 730 | if (tt_global_entry) |
... | ... | @@ -1755,7 +1751,6 @@ |
1755 | 1751 | uint16_t tt_num_changes, uint8_t ttvn) |
1756 | 1752 | { |
1757 | 1753 | int i; |
1758 | - int is_wifi; | |
1759 | 1754 | int roams; |
1760 | 1755 | |
1761 | 1756 | for (i = 0; i < tt_num_changes; i++) { |
1762 | 1757 | |
1763 | 1758 | |
... | ... | @@ -1763,13 +1758,12 @@ |
1763 | 1758 | roams = (tt_change + i)->flags & TT_CLIENT_ROAM; |
1764 | 1759 | batadv_tt_global_del(bat_priv, orig_node, |
1765 | 1760 | (tt_change + i)->addr, |
1766 | - "tt removed by changes", | |
1767 | - roams); | |
1761 | + "tt removed by changes", | |
1762 | + roams); | |
1768 | 1763 | } else { |
1769 | - is_wifi = (tt_change + i)->flags & TT_CLIENT_WIFI; | |
1770 | 1764 | if (!batadv_tt_global_add(bat_priv, orig_node, |
1771 | - (tt_change + i)->addr, ttvn, | |
1772 | - false, is_wifi)) | |
1765 | + (tt_change + i)->addr, | |
1766 | + (tt_change + i)->flags, ttvn)) | |
1773 | 1767 | /* In case of problem while storing a |
1774 | 1768 | * global_entry, we stop the updating |
1775 | 1769 | * procedure without committing the |
net/batman-adv/translation-table.h
... | ... | @@ -32,8 +32,8 @@ |
32 | 32 | struct orig_node *orig_node, |
33 | 33 | const unsigned char *tt_buff, int tt_buff_len); |
34 | 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, | |
36 | - bool wifi); | |
35 | + const unsigned char *addr, uint8_t flags, | |
36 | + uint8_t ttvn); | |
37 | 37 | int batadv_tt_global_seq_print_text(struct seq_file *seq, void *offset); |
38 | 38 | void batadv_tt_global_del_orig(struct bat_priv *bat_priv, |
39 | 39 | struct orig_node *orig_node, |