hash_ipv4 is only used in distributed-arp-table.c and therefore can be placed inside this file instead of the header.
Signed-off-by: Sven Eckelmann sven@narfation.org --- distributed-arp-table.c | 24 +++++++++++++++++++++++- distributed-arp-table.h | 22 ---------------------- 2 files changed, 23 insertions(+), 23 deletions(-)
diff --git a/distributed-arp-table.c b/distributed-arp-table.c index e678ec4..4894a85 100644 --- a/distributed-arp-table.c +++ b/distributed-arp-table.c @@ -32,6 +32,28 @@ #include "translation-table.h" #include "unicast.h"
+/* hash function to choose an entry in a hash table of given size. + * hash algorithm from http://en.wikipedia.org/wiki/Hash_table + */ +static uint32_t batadv_hash_ipv4(const void *data, uint32_t size) +{ + const unsigned char *key = data; + uint32_t hash = 0; + size_t i; + + for (i = 0; i < 4; i++) { + hash += key[i]; + hash += (hash << 10); + hash ^= (hash >> 6); + } + + hash += (hash << 3); + hash ^= (hash >> 11); + hash += (hash << 15); + + return hash % size; +} + #ifdef CONFIG_BATMAN_ADV_DEBUG
static void bat_dbg_arp(struct bat_priv *bat_priv, struct sk_buff *skb, @@ -214,7 +236,7 @@ static struct dht_candidate *dht_select_candidates(struct bat_priv *bat_priv, if (!res) return NULL;
- ip_key = (dat_addr_t)hash_ipv4(&ip_dst, DAT_ADDR_MAX); + ip_key = (dat_addr_t)batadv_hash_ipv4(&ip_dst, DAT_ADDR_MAX);
bat_dbg(DBG_DAT, bat_priv, "dht_select_candidates(): IP=%pI4 hash(IP)=%u\n", &ip_dst, diff --git a/distributed-arp-table.h b/distributed-arp-table.h index 1ba7f01..ee5200a 100644 --- a/distributed-arp-table.h +++ b/distributed-arp-table.h @@ -49,28 +49,6 @@ bool batadv_dat_drop_broadcast_packet(struct bat_priv *bat_priv, struct forw_packet *forw_packet); void batadv_arp_change_timeout(struct net_device *soft_iface, const char *name);
-/* hash function to choose an entry in a hash table of given size. - * hash algorithm from http://en.wikipedia.org/wiki/Hash_table - */ -static inline uint32_t hash_ipv4(const void *data, uint32_t size) -{ - const unsigned char *key = data; - uint32_t hash = 0; - size_t i; - - for (i = 0; i < 4; i++) { - hash += key[i]; - hash += (hash << 10); - hash ^= (hash >> 6); - } - - hash += (hash << 3); - hash ^= (hash >> 11); - hash += (hash << 15); - - return hash % size; -} - static inline void batadv_dat_init_orig_node_dht_addr(struct orig_node *orig_node) {
All non-static symbols of batman-adv were prefixed with batadv_ to avoid collisions with other symbols of the kernel. Other symbols of batman-adv should use the same prefix to keep the naming scheme consistent.
Signed-off-by: Sven Eckelmann sven@narfation.org --- bat_iv_ogm.c | 13 +++++++------ bitarray.c | 8 ++++---- bitarray.h | 6 +++--- routing.c | 4 ++-- 4 files changed, 16 insertions(+), 15 deletions(-)
diff --git a/bat_iv_ogm.c b/bat_iv_ogm.c index 84d93a5..bc30a40 100644 --- a/bat_iv_ogm.c +++ b/bat_iv_ogm.c @@ -901,9 +901,9 @@ static int bat_iv_ogm_update_seqnos(const struct ethhdr *ethhdr, hlist_for_each_entry_rcu(tmp_neigh_node, node, &orig_node->neigh_list, list) {
- is_duplicate |= bat_test_bit(tmp_neigh_node->real_bits, - orig_node->last_real_seqno, - seqno); + is_duplicate |= batadv_test_bit(tmp_neigh_node->real_bits, + orig_node->last_real_seqno, + seqno);
if (compare_eth(tmp_neigh_node->addr, ethhdr->h_source) && (tmp_neigh_node->if_incoming == if_incoming)) @@ -1037,6 +1037,7 @@ static void bat_iv_ogm_process(const struct ethhdr *ethhdr, if (is_my_orig) { unsigned long *word; int offset; + int32_t bit_pos;
orig_neigh_node = batadv_get_orig_node(bat_priv, ethhdr->h_source); @@ -1054,9 +1055,9 @@ static void bat_iv_ogm_process(const struct ethhdr *ethhdr,
spin_lock_bh(&orig_neigh_node->ogm_cnt_lock); word = &(orig_neigh_node->bcast_own[offset]); - bat_set_bit(word, - if_incoming_seqno - - ntohl(batman_ogm_packet->seqno) - 2); + bit_pos = if_incoming_seqno - 2; + bit_pos -= ntohl(batman_ogm_packet->seqno); + batadv_set_bit(word, bit_pos); orig_neigh_node->bcast_own_sum[if_incoming->if_num] = bitmap_weight(word, TQ_LOCAL_WINDOW_SIZE); spin_unlock_bh(&orig_neigh_node->ogm_cnt_lock); diff --git a/bitarray.c b/bitarray.c index 838abbc..7a7065c 100644 --- a/bitarray.c +++ b/bitarray.c @@ -48,7 +48,7 @@ int batadv_bit_get_packet(void *priv, unsigned long *seq_bits, */ if ((seq_num_diff <= 0) && (seq_num_diff > -TQ_LOCAL_WINDOW_SIZE)) { if (set_mark) - bat_set_bit(seq_bits, -seq_num_diff); + batadv_set_bit(seq_bits, -seq_num_diff); return 0; }
@@ -59,7 +59,7 @@ int batadv_bit_get_packet(void *priv, unsigned long *seq_bits, batadv_bitmap_shift_left(seq_bits, seq_num_diff);
if (set_mark) - bat_set_bit(seq_bits, 0); + batadv_set_bit(seq_bits, 0); return 1; }
@@ -71,7 +71,7 @@ int batadv_bit_get_packet(void *priv, unsigned long *seq_bits, seq_num_diff - 1); bitmap_zero(seq_bits, TQ_LOCAL_WINDOW_SIZE); if (set_mark) - bat_set_bit(seq_bits, 0); + batadv_set_bit(seq_bits, 0); return 1; }
@@ -88,7 +88,7 @@ int batadv_bit_get_packet(void *priv, unsigned long *seq_bits,
bitmap_zero(seq_bits, TQ_LOCAL_WINDOW_SIZE); if (set_mark) - bat_set_bit(seq_bits, 0); + batadv_set_bit(seq_bits, 0);
return 1; } diff --git a/bitarray.h b/bitarray.h index 8ab5426..7954ba8 100644 --- a/bitarray.h +++ b/bitarray.h @@ -23,8 +23,8 @@ /* returns true if the corresponding bit in the given seq_bits indicates true * and curr_seqno is within range of last_seqno */ -static inline int bat_test_bit(const unsigned long *seq_bits, - uint32_t last_seqno, uint32_t curr_seqno) +static inline int batadv_test_bit(const unsigned long *seq_bits, + uint32_t last_seqno, uint32_t curr_seqno) { int32_t diff;
@@ -36,7 +36,7 @@ static inline int bat_test_bit(const unsigned long *seq_bits, }
/* turn corresponding bit on, so we can remember that we got the packet */ -static inline void bat_set_bit(unsigned long *seq_bits, int32_t n) +static inline void batadv_set_bit(unsigned long *seq_bits, int32_t n) { /* if too old, just drop it */ if (n < 0 || n >= TQ_LOCAL_WINDOW_SIZE) diff --git a/routing.c b/routing.c index 66aabab..091188e 100644 --- a/routing.c +++ b/routing.c @@ -1087,8 +1087,8 @@ int batadv_recv_bcast_packet(struct sk_buff *skb, struct hard_iface *recv_if) spin_lock_bh(&orig_node->bcast_seqno_lock);
/* check whether the packet is a duplicate */ - if (bat_test_bit(orig_node->bcast_bits, orig_node->last_bcast_seqno, - ntohl(bcast_packet->seqno))) + if (batadv_test_bit(orig_node->bcast_bits, orig_node->last_bcast_seqno, + ntohl(bcast_packet->seqno))) goto spin_unlock;
seq_diff = ntohl(bcast_packet->seqno) - orig_node->last_bcast_seqno;
On Saturday, May 12, 2012 19:48:53 Sven Eckelmann wrote:
All non-static symbols of batman-adv were prefixed with batadv_ to avoid collisions with other symbols of the kernel. Other symbols of batman-adv should use the same prefix to keep the naming scheme consistent.
Signed-off-by: Sven Eckelmann sven@narfation.org
bat_iv_ogm.c | 13 +++++++------ bitarray.c | 8 ++++---- bitarray.h | 6 +++--- routing.c | 4 ++-- 4 files changed, 16 insertions(+), 15 deletions(-)
Applied in revision 0140511.
Thanks, Marek
All non-static symbols of batman-adv were prefixed with batadv_ to avoid collisions with other symbols of the kernel. Other symbols of batman-adv should use the same prefix to keep the naming scheme consistent.
Signed-off-by: Sven Eckelmann sven@narfation.org --- bat_iv_ogm.c | 14 +++++++------- bat_sysfs.c | 12 ++++++------ bridge_loop_avoidance.c | 28 ++++++++++++++-------------- distributed-arp-table.c | 14 ++++++++------ gateway_client.c | 4 ++-- hard-interface.c | 28 ++++++++++++++-------------- hard-interface.h | 7 ++++--- icmp_socket.c | 4 ++-- originator.c | 4 ++-- routing.c | 12 ++++++------ send.c | 6 +++--- soft-interface.c | 4 ++-- translation-table.c | 28 ++++++++++++++-------------- unicast.c | 8 ++++---- vis.c | 8 ++++---- 15 files changed, 92 insertions(+), 89 deletions(-)
diff --git a/bat_iv_ogm.c b/bat_iv_ogm.c index bc30a40..51c2e19 100644 --- a/bat_iv_ogm.c +++ b/bat_iv_ogm.c @@ -232,7 +232,7 @@ static void bat_iv_ogm_emit(struct forw_packet *forw_packet) if (forw_packet->if_incoming->if_status != IF_ACTIVE) goto out;
- primary_if = primary_if_get_selected(bat_priv); + primary_if = batadv_primary_if_get_selected(bat_priv); if (!primary_if) goto out;
@@ -273,7 +273,7 @@ static void bat_iv_ogm_emit(struct forw_packet *forw_packet)
out: if (primary_if) - hardif_free_ref(primary_if); + batadv_hardif_free_ref(primary_if); }
/* return true if new_packet can be aggregated with forw_packet */ @@ -311,7 +311,7 @@ static bool bat_iv_ogm_can_aggregate(const struct batman_ogm_packet * a "global" packet as well as the base * packet */ - primary_if = primary_if_get_selected(bat_priv); + primary_if = batadv_primary_if_get_selected(bat_priv); if (!primary_if) goto out;
@@ -352,7 +352,7 @@ static bool bat_iv_ogm_can_aggregate(const struct batman_ogm_packet
out: if (primary_if) - hardif_free_ref(primary_if); + batadv_hardif_free_ref(primary_if); return res; }
@@ -431,7 +431,7 @@ static void bat_iv_ogm_aggregate_new(const unsigned char *packet_buff,
return; out: - hardif_free_ref(if_incoming); + batadv_hardif_free_ref(if_incoming); }
/* aggregate a new packet into the existing ogm packet */ @@ -570,7 +570,7 @@ static void bat_iv_ogm_schedule(struct hard_iface *hard_iface) int vis_server, tt_num_changes = 0;
vis_server = atomic_read(&bat_priv->vis_mode); - primary_if = primary_if_get_selected(bat_priv); + primary_if = batadv_primary_if_get_selected(bat_priv);
if (hard_iface == primary_if) tt_num_changes = batadv_tt_append_diff(bat_priv, @@ -608,7 +608,7 @@ static void bat_iv_ogm_schedule(struct hard_iface *hard_iface) bat_iv_ogm_emit_send_time(bat_priv));
if (primary_if) - hardif_free_ref(primary_if); + batadv_hardif_free_ref(primary_if); }
static void bat_iv_ogm_orig_update(struct bat_priv *bat_priv, diff --git a/bat_sysfs.c b/bat_sysfs.c index 74bc607..dd3c8e6 100644 --- a/bat_sysfs.c +++ b/bat_sysfs.c @@ -533,7 +533,7 @@ static ssize_t show_mesh_iface(struct kobject *kobj, struct attribute *attr, length = sprintf(buff, "%s\n", hard_iface->if_status == IF_NOT_IN_USE ? "none" : hard_iface->soft_iface->name);
- hardif_free_ref(hard_iface); + batadv_hardif_free_ref(hard_iface);
return length; } @@ -555,7 +555,7 @@ static ssize_t store_mesh_iface(struct kobject *kobj, struct attribute *attr, if (strlen(buff) >= IFNAMSIZ) { pr_err("Invalid parameter for 'mesh_iface' setting received: interface name too long '%s'\n", buff); - hardif_free_ref(hard_iface); + batadv_hardif_free_ref(hard_iface); return -EINVAL; }
@@ -590,7 +590,7 @@ static ssize_t store_mesh_iface(struct kobject *kobj, struct attribute *attr, unlock: rtnl_unlock(); out: - hardif_free_ref(hard_iface); + batadv_hardif_free_ref(hard_iface); return ret; }
@@ -623,7 +623,7 @@ static ssize_t show_iface_status(struct kobject *kobj, struct attribute *attr, break; }
- hardif_free_ref(hard_iface); + batadv_hardif_free_ref(hard_iface);
return length; } @@ -686,7 +686,7 @@ int batadv_throw_uevent(struct bat_priv *bat_priv, enum uev_type type, struct kobject *bat_kobj; char *uevent_env[4] = { NULL, NULL, NULL, NULL };
- primary_if = primary_if_get_selected(bat_priv); + primary_if = batadv_primary_if_get_selected(bat_priv); if (!primary_if) goto out;
@@ -725,7 +725,7 @@ out: kfree(uevent_env[2]);
if (primary_if) - hardif_free_ref(primary_if); + batadv_hardif_free_ref(primary_if);
if (ret) bat_dbg(DBG_BATMAN, bat_priv, diff --git a/bridge_loop_avoidance.c b/bridge_loop_avoidance.c index 52c0d63..72ff8b9 100644 --- a/bridge_loop_avoidance.c +++ b/bridge_loop_avoidance.c @@ -255,7 +255,7 @@ static void bla_send_claim(struct bat_priv *bat_priv, uint8_t *mac, struct bla_claim_dst local_claim_dest; __be32 zeroip = 0;
- primary_if = primary_if_get_selected(bat_priv); + primary_if = batadv_primary_if_get_selected(bat_priv); if (!primary_if) return;
@@ -339,7 +339,7 @@ static void bla_send_claim(struct bat_priv *bat_priv, uint8_t *mac, netif_rx(skb); out: if (primary_if) - hardif_free_ref(primary_if); + batadv_hardif_free_ref(primary_if); }
/* @bat_priv: the bat priv with all the soft interface information @@ -1075,7 +1075,7 @@ static void bla_periodic_work(struct work_struct *work) struct hard_iface *primary_if; int i;
- primary_if = primary_if_get_selected(bat_priv); + primary_if = batadv_primary_if_get_selected(bat_priv); if (!primary_if) goto out;
@@ -1106,7 +1106,7 @@ static void bla_periodic_work(struct work_struct *work) } out: if (primary_if) - hardif_free_ref(primary_if); + batadv_hardif_free_ref(primary_if);
bla_start_timer(bat_priv); } @@ -1131,12 +1131,12 @@ int batadv_bla_init(struct bat_priv *bat_priv) /* setting claim destination address */ memcpy(&bat_priv->claim_dest.magic, claim_dest, 3); bat_priv->claim_dest.type = 0; - primary_if = primary_if_get_selected(bat_priv); + primary_if = batadv_primary_if_get_selected(bat_priv); if (primary_if) { bat_priv->claim_dest.group = htons(crc16(0, primary_if->net_dev->dev_addr, ETH_ALEN)); - hardif_free_ref(primary_if); + batadv_hardif_free_ref(primary_if); } else { bat_priv->claim_dest.group = 0; /* will be set later */ } @@ -1319,7 +1319,7 @@ void batadv_bla_free(struct bat_priv *bat_priv) struct hard_iface *primary_if;
cancel_delayed_work_sync(&bat_priv->bla_work); - primary_if = primary_if_get_selected(bat_priv); + primary_if = batadv_primary_if_get_selected(bat_priv);
if (bat_priv->claim_hash) { bla_purge_claims(bat_priv, primary_if, 1); @@ -1332,7 +1332,7 @@ void batadv_bla_free(struct bat_priv *bat_priv) bat_priv->backbone_hash = NULL; } if (primary_if) - hardif_free_ref(primary_if); + batadv_hardif_free_ref(primary_if); }
/* @bat_priv: the bat priv with all the soft interface information @@ -1356,7 +1356,7 @@ int batadv_bla_rx(struct bat_priv *bat_priv, struct sk_buff *skb, short vid)
ethhdr = (struct ethhdr *)skb_mac_header(skb);
- primary_if = primary_if_get_selected(bat_priv); + primary_if = batadv_primary_if_get_selected(bat_priv); if (!primary_if) goto handled;
@@ -1416,7 +1416,7 @@ handled:
out: if (primary_if) - hardif_free_ref(primary_if); + batadv_hardif_free_ref(primary_if); if (claim) claim_free_ref(claim); return ret; @@ -1441,7 +1441,7 @@ int batadv_bla_tx(struct bat_priv *bat_priv, struct sk_buff *skb, short vid) struct hard_iface *primary_if; int ret = 0;
- primary_if = primary_if_get_selected(bat_priv); + primary_if = batadv_primary_if_get_selected(bat_priv); if (!primary_if) goto out;
@@ -1502,7 +1502,7 @@ handled: ret = 1; out: if (primary_if) - hardif_free_ref(primary_if); + batadv_hardif_free_ref(primary_if); if (claim) claim_free_ref(claim); return ret; @@ -1521,7 +1521,7 @@ int batadv_bla_claim_table_seq_print_text(struct seq_file *seq, void *offset) bool is_own; int ret = 0;
- primary_if = primary_if_get_selected(bat_priv); + primary_if = batadv_primary_if_get_selected(bat_priv); if (!primary_if) { ret = seq_printf(seq, "BATMAN mesh %s disabled - please specify interfaces to enable it\n", @@ -1559,6 +1559,6 @@ int batadv_bla_claim_table_seq_print_text(struct seq_file *seq, void *offset) } out: if (primary_if) - hardif_free_ref(primary_if); + batadv_hardif_free_ref(primary_if); return ret; } diff --git a/distributed-arp-table.c b/distributed-arp-table.c index 4894a85..a0b38b1 100644 --- a/distributed-arp-table.c +++ b/distributed-arp-table.c @@ -310,7 +310,9 @@ out: static void arp_neigh_update(struct bat_priv *bat_priv, __be32 ip, uint8_t *hw) { struct neighbour *n = NULL; - struct hard_iface *primary_if = primary_if_get_selected(bat_priv); + struct hard_iface *primary_if; + + primary_if = batadv_primary_if_get_selected(bat_priv); if (!primary_if) goto out;
@@ -325,7 +327,7 @@ out: if (n && !IS_ERR(n)) neigh_release(n); if (primary_if) - hardif_free_ref(primary_if); + batadv_hardif_free_ref(primary_if); }
/* Returns arphdr->ar_op if the skb contains a valid ARP packet, otherwise @@ -412,7 +414,7 @@ bool batadv_dat_snoop_outgoing_arp_request(struct bat_priv *bat_priv, hw_src = ARP_HW_SRC(skb, 0); ip_dst = ARP_IP_DST(skb, 0);
- primary_if = primary_if_get_selected(bat_priv); + primary_if = batadv_primary_if_get_selected(bat_priv); if (!primary_if) goto out;
@@ -445,7 +447,7 @@ out: if (n) neigh_release(n); if (primary_if) - hardif_free_ref(primary_if); + batadv_hardif_free_ref(primary_if); return ret; }
@@ -476,7 +478,7 @@ bool batadv_dat_snoop_incoming_arp_request(struct bat_priv *bat_priv, bat_dbg_arp(bat_priv, skb, type, hdr_size, "Parsing incoming ARP REQUEST");
- primary_if = primary_if_get_selected(bat_priv); + primary_if = batadv_primary_if_get_selected(bat_priv); if (!primary_if) goto out;
@@ -503,7 +505,7 @@ out: if (n) neigh_release(n); if (primary_if) - hardif_free_ref(primary_if); + batadv_hardif_free_ref(primary_if); if (ret) kfree_skb(skb); return ret; diff --git a/gateway_client.c b/gateway_client.c index 0d90fff..c917a2e 100644 --- a/gateway_client.c +++ b/gateway_client.c @@ -464,7 +464,7 @@ int batadv_gw_client_seq_print_text(struct seq_file *seq, void *offset) struct hlist_node *node; int gw_count = 0, ret = 0;
- primary_if = primary_if_get_selected(bat_priv); + primary_if = batadv_primary_if_get_selected(bat_priv); if (!primary_if) { ret = seq_printf(seq, "BATMAN mesh %s disabled - please specify interfaces to enable it\n", @@ -503,7 +503,7 @@ int batadv_gw_client_seq_print_text(struct seq_file *seq, void *offset)
out: if (primary_if) - hardif_free_ref(primary_if); + batadv_hardif_free_ref(primary_if); return ret; }
diff --git a/hard-interface.c b/hard-interface.c index baa1c33..58ff796 100644 --- a/hard-interface.c +++ b/hard-interface.c @@ -103,7 +103,7 @@ static void primary_if_update_addr(struct bat_priv *bat_priv, struct vis_packet *vis_packet; struct hard_iface *primary_if;
- primary_if = primary_if_get_selected(bat_priv); + primary_if = batadv_primary_if_get_selected(bat_priv); if (!primary_if) goto out;
@@ -118,7 +118,7 @@ static void primary_if_update_addr(struct bat_priv *bat_priv, batadv_bla_update_orig_address(bat_priv, primary_if, oldif); out: if (primary_if) - hardif_free_ref(primary_if); + batadv_hardif_free_ref(primary_if); }
static void primary_if_select(struct bat_priv *bat_priv, @@ -142,7 +142,7 @@ static void primary_if_select(struct bat_priv *bat_priv,
out: if (curr_hard_iface) - hardif_free_ref(curr_hard_iface); + batadv_hardif_free_ref(curr_hard_iface); }
static bool hardif_is_iface_up(const struct hard_iface *hard_iface) @@ -232,7 +232,7 @@ static void hardif_activate_interface(struct hard_iface *hard_iface) /* the first active interface becomes our primary interface or * the next active interface after the old primary interface was removed */ - primary_if = primary_if_get_selected(bat_priv); + primary_if = batadv_primary_if_get_selected(bat_priv); if (!primary_if) primary_if_select(bat_priv, hard_iface);
@@ -243,7 +243,7 @@ static void hardif_activate_interface(struct hard_iface *hard_iface)
out: if (primary_if) - hardif_free_ref(primary_if); + batadv_hardif_free_ref(primary_if); }
static void hardif_deactivate_interface(struct hard_iface *hard_iface) @@ -350,7 +350,7 @@ out: err_dev: dev_put(soft_iface); err: - hardif_free_ref(hard_iface); + batadv_hardif_free_ref(hard_iface); return ret; }
@@ -372,7 +372,7 @@ void batadv_hardif_disable_interface(struct hard_iface *hard_iface) bat_priv->num_ifaces--; batadv_orig_hash_del_if(hard_iface, bat_priv->num_ifaces);
- primary_if = primary_if_get_selected(bat_priv); + primary_if = batadv_primary_if_get_selected(bat_priv); if (hard_iface == primary_if) { struct hard_iface *new_if;
@@ -380,7 +380,7 @@ void batadv_hardif_disable_interface(struct hard_iface *hard_iface) primary_if_select(bat_priv, new_if);
if (new_if) - hardif_free_ref(new_if); + batadv_hardif_free_ref(new_if); }
bat_priv->bat_algo_ops->bat_iface_disable(hard_iface); @@ -396,11 +396,11 @@ void batadv_hardif_disable_interface(struct hard_iface *hard_iface) batadv_softif_destroy(hard_iface->soft_iface);
hard_iface->soft_iface = NULL; - hardif_free_ref(hard_iface); + batadv_hardif_free_ref(hard_iface);
out: if (primary_if) - hardif_free_ref(primary_if); + batadv_hardif_free_ref(primary_if); }
static struct hard_iface *hardif_add_interface(struct net_device *net_dev) @@ -464,7 +464,7 @@ static void hardif_remove_interface(struct hard_iface *hard_iface)
hard_iface->if_status = IF_TO_BE_REMOVED; batadv_sysfs_del_hardif(&hard_iface->hardif_obj); - hardif_free_ref(hard_iface); + batadv_hardif_free_ref(hard_iface); }
void batadv_hardif_remove_interfaces(void) @@ -520,7 +520,7 @@ static int hard_if_event(struct notifier_block *this, bat_priv = netdev_priv(hard_iface->soft_iface); bat_priv->bat_algo_ops->bat_iface_update_mac(hard_iface);
- primary_if = primary_if_get_selected(bat_priv); + primary_if = batadv_primary_if_get_selected(bat_priv); if (!primary_if) goto hardif_put;
@@ -532,10 +532,10 @@ static int hard_if_event(struct notifier_block *this, }
hardif_put: - hardif_free_ref(hard_iface); + batadv_hardif_free_ref(hard_iface); out: if (primary_if) - hardif_free_ref(primary_if); + batadv_hardif_free_ref(primary_if); return NOTIFY_DONE; }
diff --git a/hard-interface.h b/hard-interface.h index 6bc12c0..d66dabd 100644 --- a/hard-interface.h +++ b/hard-interface.h @@ -42,14 +42,15 @@ void batadv_update_min_mtu(struct net_device *soft_iface); void batadv_hardif_free_rcu(struct rcu_head *rcu); bool batadv_is_wifi_iface(int ifindex);
-static inline void hardif_free_ref(struct hard_iface *hard_iface) +static inline void +batadv_hardif_free_ref(struct hard_iface *hard_iface) { if (atomic_dec_and_test(&hard_iface->refcount)) call_rcu(&hard_iface->rcu, batadv_hardif_free_rcu); }
-static inline struct hard_iface *primary_if_get_selected( - struct bat_priv *bat_priv) +static inline struct hard_iface * +batadv_primary_if_get_selected(struct bat_priv *bat_priv) { struct hard_iface *hard_iface;
diff --git a/icmp_socket.c b/icmp_socket.c index 3fad5aa..d9e8cb3 100644 --- a/icmp_socket.c +++ b/icmp_socket.c @@ -163,7 +163,7 @@ static ssize_t bat_socket_write(struct file *file, const char __user *buff, return -EINVAL; }
- primary_if = primary_if_get_selected(bat_priv); + primary_if = batadv_primary_if_get_selected(bat_priv);
if (!primary_if) { len = -EFAULT; @@ -244,7 +244,7 @@ free_skb: kfree_skb(skb); out: if (primary_if) - hardif_free_ref(primary_if); + batadv_hardif_free_ref(primary_if); if (neigh_node) batadv_neigh_node_free_ref(neigh_node); if (orig_node) diff --git a/originator.c b/originator.c index 35cd717..8bed038 100644 --- a/originator.c +++ b/originator.c @@ -414,7 +414,7 @@ int batadv_orig_seq_print_text(struct seq_file *seq, void *offset) uint32_t i; int ret = 0;
- primary_if = primary_if_get_selected(bat_priv); + primary_if = batadv_primary_if_get_selected(bat_priv);
if (!primary_if) { ret = seq_printf(seq, @@ -481,7 +481,7 @@ next:
out: if (primary_if) - hardif_free_ref(primary_if); + batadv_hardif_free_ref(primary_if); return ret; }
diff --git a/routing.c b/routing.c index 091188e..2312da1 100644 --- a/routing.c +++ b/routing.c @@ -292,7 +292,7 @@ static int recv_my_icmp_packet(struct bat_priv *bat_priv, goto out; }
- primary_if = primary_if_get_selected(bat_priv); + primary_if = batadv_primary_if_get_selected(bat_priv); if (!primary_if) goto out;
@@ -322,7 +322,7 @@ static int recv_my_icmp_packet(struct bat_priv *bat_priv,
out: if (primary_if) - hardif_free_ref(primary_if); + batadv_hardif_free_ref(primary_if); if (router) batadv_neigh_node_free_ref(router); if (orig_node) @@ -348,7 +348,7 @@ static int recv_icmp_ttl_exceeded(struct bat_priv *bat_priv, goto out; }
- primary_if = primary_if_get_selected(bat_priv); + primary_if = batadv_primary_if_get_selected(bat_priv); if (!primary_if) goto out;
@@ -377,7 +377,7 @@ static int recv_icmp_ttl_exceeded(struct bat_priv *bat_priv,
out: if (primary_if) - hardif_free_ref(primary_if); + batadv_hardif_free_ref(primary_if); if (router) batadv_neigh_node_free_ref(router); if (orig_node) @@ -952,12 +952,12 @@ static int check_unicast_ttvn(struct bat_priv *bat_priv, if (!orig_node) { if (!batadv_is_my_client(bat_priv, ethhdr->h_dest)) return 0; - primary_if = primary_if_get_selected(bat_priv); + primary_if = batadv_primary_if_get_selected(bat_priv); if (!primary_if) return 0; memcpy(unicast_packet->dest, primary_if->net_dev->dev_addr, ETH_ALEN); - hardif_free_ref(primary_if); + batadv_hardif_free_ref(primary_if); } else { memcpy(unicast_packet->dest, orig_node->orig, ETH_ALEN); diff --git a/send.c b/send.c index d77d023..edf2bfa 100644 --- a/send.c +++ b/send.c @@ -102,7 +102,7 @@ static void forw_packet_free(struct forw_packet *forw_packet) if (forw_packet->skb) kfree_skb(forw_packet->skb); if (forw_packet->if_incoming) - hardif_free_ref(forw_packet->if_incoming); + batadv_hardif_free_ref(forw_packet->if_incoming); kfree(forw_packet); }
@@ -147,7 +147,7 @@ int batadv_add_bcast_packet_to_list(struct bat_priv *bat_priv, goto out; }
- primary_if = primary_if_get_selected(bat_priv); + primary_if = batadv_primary_if_get_selected(bat_priv); if (!primary_if) goto out_and_inc;
@@ -181,7 +181,7 @@ out_and_inc: atomic_inc(&bat_priv->bcast_queue_left); out: if (primary_if) - hardif_free_ref(primary_if); + batadv_hardif_free_ref(primary_if); return NETDEV_TX_BUSY; }
diff --git a/soft-interface.c b/soft-interface.c index e2f1339..faba6f3 100644 --- a/soft-interface.c +++ b/soft-interface.c @@ -201,7 +201,7 @@ static int interface_tx(struct sk_buff *skb, struct net_device *soft_iface)
/* ethernet packet should be broadcasted */ if (do_bcast) { - primary_if = primary_if_get_selected(bat_priv); + primary_if = batadv_primary_if_get_selected(bat_priv); if (!primary_if) goto dropped;
@@ -260,7 +260,7 @@ dropped_freed: bat_priv->stats.tx_dropped++; end: if (primary_if) - hardif_free_ref(primary_if); + batadv_hardif_free_ref(primary_if); return NETDEV_TX_OK; }
diff --git a/translation-table.c b/translation-table.c index b116b9a..bda8f6e 100644 --- a/translation-table.c +++ b/translation-table.c @@ -298,7 +298,7 @@ static void tt_prepare_packet_buff(struct bat_priv *bat_priv, struct hard_iface *primary_if; int req_len;
- primary_if = primary_if_get_selected(bat_priv); + primary_if = batadv_primary_if_get_selected(bat_priv);
req_len = min_packet_len; req_len += batadv_tt_len(atomic_read(&bat_priv->tt_local_changes)); @@ -313,7 +313,7 @@ static void tt_prepare_packet_buff(struct bat_priv *bat_priv, min_packet_len, req_len);
if (primary_if) - hardif_free_ref(primary_if); + batadv_hardif_free_ref(primary_if); }
static int tt_changes_fill_buff(struct bat_priv *bat_priv, @@ -381,7 +381,7 @@ int batadv_tt_local_seq_print_text(struct seq_file *seq, void *offset) uint32_t i; int ret = 0;
- primary_if = primary_if_get_selected(bat_priv); + primary_if = batadv_primary_if_get_selected(bat_priv); if (!primary_if) { ret = seq_printf(seq, "BATMAN mesh %s disabled - please specify interfaces to enable it\n", @@ -423,7 +423,7 @@ int batadv_tt_local_seq_print_text(struct seq_file *seq, void *offset) } out: if (primary_if) - hardif_free_ref(primary_if); + batadv_hardif_free_ref(primary_if); return ret; }
@@ -727,7 +727,7 @@ int batadv_tt_global_seq_print_text(struct seq_file *seq, void *offset) uint32_t i; int ret = 0;
- primary_if = primary_if_get_selected(bat_priv); + primary_if = batadv_primary_if_get_selected(bat_priv); if (!primary_if) { ret = seq_printf(seq, "BATMAN mesh %s disabled - please specify interfaces to enable it\n", @@ -763,7 +763,7 @@ int batadv_tt_global_seq_print_text(struct seq_file *seq, void *offset) } out: if (primary_if) - hardif_free_ref(primary_if); + batadv_hardif_free_ref(primary_if); return ret; }
@@ -1370,7 +1370,7 @@ static int send_tt_request(struct bat_priv *bat_priv, struct tt_req_node *tt_req_node = NULL; int ret = 1;
- primary_if = primary_if_get_selected(bat_priv); + primary_if = batadv_primary_if_get_selected(bat_priv); if (!primary_if) goto out;
@@ -1420,7 +1420,7 @@ out: if (neigh_node) batadv_neigh_node_free_ref(neigh_node); if (primary_if) - hardif_free_ref(primary_if); + batadv_hardif_free_ref(primary_if); if (ret) kfree_skb(skb); if (ret && tt_req_node) { @@ -1464,7 +1464,7 @@ static bool send_other_tt_response(struct bat_priv *bat_priv, if (!neigh_node) goto out;
- primary_if = primary_if_get_selected(bat_priv); + primary_if = batadv_primary_if_get_selected(bat_priv); if (!primary_if) goto out;
@@ -1555,7 +1555,7 @@ out: if (neigh_node) batadv_neigh_node_free_ref(neigh_node); if (primary_if) - hardif_free_ref(primary_if); + batadv_hardif_free_ref(primary_if); if (!ret) kfree_skb(skb); return ret; @@ -1592,7 +1592,7 @@ static bool send_my_tt_response(struct bat_priv *bat_priv, if (!neigh_node) goto out;
- primary_if = primary_if_get_selected(bat_priv); + primary_if = batadv_primary_if_get_selected(bat_priv); if (!primary_if) goto out;
@@ -1672,7 +1672,7 @@ out: if (neigh_node) batadv_neigh_node_free_ref(neigh_node); if (primary_if) - hardif_free_ref(primary_if); + batadv_hardif_free_ref(primary_if); if (!ret) kfree_skb(skb); /* This packet was for me, so it doesn't need to be re-routed */ @@ -1956,11 +1956,11 @@ static void send_roam_adv(struct bat_priv *bat_priv, uint8_t *client, roam_adv_packet->header.packet_type = BAT_ROAM_ADV; roam_adv_packet->header.version = COMPAT_VERSION; roam_adv_packet->header.ttl = TTL; - primary_if = primary_if_get_selected(bat_priv); + primary_if = batadv_primary_if_get_selected(bat_priv); if (!primary_if) goto out; memcpy(roam_adv_packet->src, primary_if->net_dev->dev_addr, ETH_ALEN); - hardif_free_ref(primary_if); + batadv_hardif_free_ref(primary_if); memcpy(roam_adv_packet->dst, orig_node->orig, ETH_ALEN); memcpy(roam_adv_packet->client, client, ETH_ALEN);
diff --git a/unicast.c b/unicast.c index 9029142..e70cbbc 100644 --- a/unicast.c +++ b/unicast.c @@ -227,7 +227,7 @@ int batadv_frag_send_skb(struct sk_buff *skb, struct bat_priv *bat_priv, int large_tail = 0, ret = NET_RX_DROP; uint16_t seqno;
- primary_if = primary_if_get_selected(bat_priv); + primary_if = batadv_primary_if_get_selected(bat_priv); if (!primary_if) goto dropped;
@@ -277,7 +277,7 @@ dropped: kfree_skb(skb); out: if (primary_if) - hardif_free_ref(primary_if); + batadv_hardif_free_ref(primary_if); return ret; }
@@ -320,7 +320,7 @@ bool batadv_prepare_unicast_4addr_packet(struct bat_priv *bat_priv, struct unicast_4addr_packet *unicast_4addr_packet; bool ret = false;
- primary_if = primary_if_get_selected(bat_priv); + primary_if = batadv_primary_if_get_selected(bat_priv); if (!primary_if) goto out;
@@ -341,7 +341,7 @@ bool batadv_prepare_unicast_4addr_packet(struct bat_priv *bat_priv, ret = true; out: if (primary_if) - hardif_free_ref(primary_if); + batadv_hardif_free_ref(primary_if); return ret; }
diff --git a/vis.c b/vis.c index 20eef04..619f0a5 100644 --- a/vis.c +++ b/vis.c @@ -208,7 +208,7 @@ int batadv_vis_seq_print_text(struct seq_file *seq, void *offset) size_t buff_pos, buf_size; char *buff;
- primary_if = primary_if_get_selected(bat_priv); + primary_if = batadv_primary_if_get_selected(bat_priv); if (!primary_if) goto out;
@@ -329,7 +329,7 @@ int batadv_vis_seq_print_text(struct seq_file *seq, void *offset)
out: if (primary_if) - hardif_free_ref(primary_if); + batadv_hardif_free_ref(primary_if); return ret; }
@@ -828,7 +828,7 @@ static void send_vis_packet(struct bat_priv *bat_priv, struct vis_info *info) struct hard_iface *primary_if; struct vis_packet *packet;
- primary_if = primary_if_get_selected(bat_priv); + primary_if = batadv_primary_if_get_selected(bat_priv); if (!primary_if) goto out;
@@ -849,7 +849,7 @@ static void send_vis_packet(struct bat_priv *bat_priv, struct vis_info *info)
out: if (primary_if) - hardif_free_ref(primary_if); + batadv_hardif_free_ref(primary_if); }
/* called from timer; send (and maybe generate) vis packet. */
On Saturday, May 12, 2012 19:48:54 Sven Eckelmann wrote:
All non-static symbols of batman-adv were prefixed with batadv_ to avoid collisions with other symbols of the kernel. Other symbols of batman-adv should use the same prefix to keep the naming scheme consistent.
Signed-off-by: Sven Eckelmann sven@narfation.org
bat_iv_ogm.c | 14 +++++++------- bat_sysfs.c | 12 ++++++------ bridge_loop_avoidance.c | 28 ++++++++++++++-------------- distributed-arp-table.c | 14 ++++++++------ gateway_client.c | 4 ++-- hard-interface.c | 28 ++++++++++++++-------------- hard-interface.h | 7 ++++--- icmp_socket.c | 4 ++-- originator.c | 4 ++-- routing.c | 12 ++++++------ send.c | 6 +++--- soft-interface.c | 4 ++-- translation-table.c | 28 ++++++++++++++-------------- unicast.c | 8 ++++---- vis.c | 8 ++++---- 15 files changed, 92 insertions(+), 89 deletions(-)
Applied in revision 3670993.
Thanks, Marek
All non-static symbols of batman-adv were prefixed with batadv_ to avoid collisions with other symbols of the kernel. Other symbols of batman-adv should use the same prefix to keep the naming scheme consistent.
Signed-off-by: Sven Eckelmann sven@narfation.org --- bridge_loop_avoidance.c | 13 ++++++++----- hash.h | 19 ++++++++++--------- originator.c | 5 +++-- translation-table.c | 24 +++++++++++++----------- vis.c | 16 ++++++++-------- 5 files changed, 42 insertions(+), 35 deletions(-)
diff --git a/bridge_loop_avoidance.c b/bridge_loop_avoidance.c index 72ff8b9..7a2dfd4 100644 --- a/bridge_loop_avoidance.c +++ b/bridge_loop_avoidance.c @@ -379,8 +379,9 @@ static struct backbone_gw *bla_get_backbone_gw(struct bat_priv *bat_priv, /* one for the hash, one for returning */ atomic_set(&entry->refcount, 2);
- hash_added = hash_add(bat_priv->backbone_hash, compare_backbone_gw, - choose_backbone_gw, entry, &entry->hash_entry); + hash_added = batadv_hash_add(bat_priv->backbone_hash, + compare_backbone_gw, choose_backbone_gw, + entry, &entry->hash_entry);
if (unlikely(hash_added != 0)) { /* hash failed, free the structure */ @@ -540,8 +541,9 @@ static void bla_add_claim(struct bat_priv *bat_priv, const uint8_t *mac, bat_dbg(DBG_BLA, bat_priv, "bla_add_claim(): adding new entry %pM, vid %d to hash ...\n", mac, vid); - hash_added = hash_add(bat_priv->claim_hash, compare_claim, - choose_claim, claim, &claim->hash_entry); + hash_added = batadv_hash_add(bat_priv->claim_hash, + compare_claim, choose_claim, + claim, &claim->hash_entry);
if (unlikely(hash_added != 0)) { /* only local changes happened. */ @@ -590,7 +592,8 @@ static void bla_del_claim(struct bat_priv *bat_priv, const uint8_t *mac,
bat_dbg(DBG_BLA, bat_priv, "bla_del_claim(): %pM, vid %d\n", mac, vid);
- hash_remove(bat_priv->claim_hash, compare_claim, choose_claim, claim); + batadv_hash_remove(bat_priv->claim_hash, compare_claim, choose_claim, + claim); claim_free_ref(claim); /* reference from the hash is gone */
claim->backbone_gw->crc ^= crc16(0, claim->addr, ETH_ALEN); diff --git a/hash.h b/hash.h index eba8f2a..7ec4e5b 100644 --- a/hash.h +++ b/hash.h @@ -54,8 +54,8 @@ void batadv_hash_destroy(struct hashtable_t *hash); * called to remove the elements inside of the hash. if you don't remove the * elements, memory might be leaked. */ -static inline void hash_delete(struct hashtable_t *hash, - hashdata_free_cb free_cb, void *arg) +static inline void batadv_hash_delete(struct hashtable_t *hash, + hashdata_free_cb free_cb, void *arg) { struct hlist_head *head; struct hlist_node *node, *node_tmp; @@ -89,10 +89,11 @@ static inline void hash_delete(struct hashtable_t *hash, * Returns 0 on success, 1 if the element already is in the hash * and -1 on error. */ -static inline int hash_add(struct hashtable_t *hash, - hashdata_compare_cb compare, - hashdata_choose_cb choose, - const void *data, struct hlist_node *data_node) +static inline int batadv_hash_add(struct hashtable_t *hash, + hashdata_compare_cb compare, + hashdata_choose_cb choose, + const void *data, + struct hlist_node *data_node) { uint32_t index; int ret = -1; @@ -133,9 +134,9 @@ out: * structure you use with just the key filled, we just need the key for * comparing. */ -static inline void *hash_remove(struct hashtable_t *hash, - hashdata_compare_cb compare, - hashdata_choose_cb choose, void *data) +static inline void *batadv_hash_remove(struct hashtable_t *hash, + hashdata_compare_cb compare, + hashdata_choose_cb choose, void *data) { uint32_t index; struct hlist_node *node; diff --git a/originator.c b/originator.c index 8bed038..9e7e1c2 100644 --- a/originator.c +++ b/originator.c @@ -250,8 +250,9 @@ struct orig_node *batadv_get_orig_node(struct bat_priv *bat_priv, if (!orig_node->bcast_own_sum) goto free_bcast_own;
- hash_added = hash_add(bat_priv->orig_hash, compare_orig, - choose_orig, orig_node, &orig_node->hash_entry); + hash_added = batadv_hash_add(bat_priv->orig_hash, compare_orig, + choose_orig, orig_node, + &orig_node->hash_entry); if (hash_added != 0) goto free_bcast_own_sum;
diff --git a/translation-table.c b/translation-table.c index bda8f6e..0283d91 100644 --- a/translation-table.c +++ b/translation-table.c @@ -234,9 +234,9 @@ void batadv_tt_local_add(struct net_device *soft_iface, const uint8_t *addr, */ tt_local_entry->common.flags |= TT_CLIENT_NEW;
- hash_added = hash_add(bat_priv->tt_local_hash, compare_tt, choose_orig, - &tt_local_entry->common, - &tt_local_entry->common.hash_entry); + hash_added = batadv_hash_add(bat_priv->tt_local_hash, compare_tt, + choose_orig, &tt_local_entry->common, + &tt_local_entry->common.hash_entry);
if (unlikely(hash_added != 0)) { /* remove the reference for the hash */ @@ -618,6 +618,7 @@ int batadv_tt_global_add(struct bat_priv *bat_priv, struct orig_node *orig_node, struct tt_global_entry *tt_global_entry = NULL; int ret = 0; int hash_added; + struct tt_common_entry *common;
tt_global_entry = tt_global_hash_find(bat_priv, tt_addr);
@@ -627,18 +628,19 @@ int batadv_tt_global_add(struct bat_priv *bat_priv, struct orig_node *orig_node, if (!tt_global_entry) goto out;
- memcpy(tt_global_entry->common.addr, tt_addr, ETH_ALEN); + common = &tt_global_entry->common; + memcpy(common->addr, tt_addr, ETH_ALEN);
- tt_global_entry->common.flags = NO_FLAGS; + common->flags = NO_FLAGS; tt_global_entry->roam_at = 0; - atomic_set(&tt_global_entry->common.refcount, 2); + atomic_set(&common->refcount, 2);
INIT_HLIST_HEAD(&tt_global_entry->orig_list); spin_lock_init(&tt_global_entry->list_lock);
- hash_added = hash_add(bat_priv->tt_global_hash, compare_tt, - choose_orig, &tt_global_entry->common, - &tt_global_entry->common.hash_entry); + hash_added = batadv_hash_add(bat_priv->tt_global_hash, + compare_tt, choose_orig, + common, &common->hash_entry);
if (unlikely(hash_added != 0)) { /* remove the reference for the hash */ @@ -816,8 +818,8 @@ static void tt_global_del_struct(struct bat_priv *bat_priv, "Deleting global tt entry %pM: %s\n", tt_global_entry->common.addr, message);
- hash_remove(bat_priv->tt_global_hash, compare_tt, choose_orig, - tt_global_entry->common.addr); + batadv_hash_remove(bat_priv->tt_global_hash, compare_tt, choose_orig, + tt_global_entry->common.addr); tt_global_entry_free_ref(tt_global_entry);
} diff --git a/vis.c b/vis.c index 619f0a5..e0a9057 100644 --- a/vis.c +++ b/vis.c @@ -433,8 +433,8 @@ static struct vis_info *add_packet(struct bat_priv *bat_priv, } } /* remove old entry */ - hash_remove(bat_priv->vis_hash, vis_info_cmp, vis_info_choose, - old_info); + batadv_hash_remove(bat_priv->vis_hash, vis_info_cmp, + vis_info_choose, old_info); send_list_del(old_info); kref_put(&old_info->refcount, free_info); } @@ -474,8 +474,8 @@ static struct vis_info *add_packet(struct bat_priv *bat_priv, recv_list_add(bat_priv, &info->recv_list, packet->sender_orig);
/* try to add it */ - hash_added = hash_add(bat_priv->vis_hash, vis_info_cmp, vis_info_choose, - info, &info->hash_entry); + hash_added = batadv_hash_add(bat_priv->vis_hash, vis_info_cmp, + vis_info_choose, info, &info->hash_entry); if (hash_added != 0) { /* did not work (for some reason) */ kref_put(&info->refcount, free_info); @@ -934,9 +934,9 @@ int batadv_vis_init(struct bat_priv *bat_priv)
INIT_LIST_HEAD(&bat_priv->vis_send_list);
- hash_added = hash_add(bat_priv->vis_hash, vis_info_cmp, vis_info_choose, - bat_priv->my_vis_info, - &bat_priv->my_vis_info->hash_entry); + hash_added = batadv_hash_add(bat_priv->vis_hash, vis_info_cmp, + vis_info_choose, bat_priv->my_vis_info, + &bat_priv->my_vis_info->hash_entry); if (hash_added != 0) { pr_err("Can't add own vis packet into hash\n"); /* not in hash, need to remove it manually. */ @@ -977,7 +977,7 @@ void batadv_vis_quit(struct bat_priv *bat_priv)
spin_lock_bh(&bat_priv->vis_hash_lock); /* properly remove, kill timers ... */ - hash_delete(bat_priv->vis_hash, free_info_ref, NULL); + batadv_hash_delete(bat_priv->vis_hash, free_info_ref, NULL); bat_priv->vis_hash = NULL; bat_priv->my_vis_info = NULL; spin_unlock_bh(&bat_priv->vis_hash_lock);
On Saturday, May 12, 2012 19:48:55 Sven Eckelmann wrote:
All non-static symbols of batman-adv were prefixed with batadv_ to avoid collisions with other symbols of the kernel. Other symbols of batman-adv should use the same prefix to keep the naming scheme consistent.
Signed-off-by: Sven Eckelmann sven@narfation.org
bridge_loop_avoidance.c | 13 ++++++++----- hash.h | 19 ++++++++++--------- originator.c | 5 +++-- translation-table.c | 24 +++++++++++++----------- vis.c | 16 ++++++++-------- 5 files changed, 42 insertions(+), 35 deletions(-)
Applied in revision 489d169.
Thanks, Marek
All non-static symbols of batman-adv were prefixed with batadv_ to avoid collisions with other symbols of the kernel. Other symbols of batman-adv should use the same prefix to keep the naming scheme consistent.
Signed-off-by: Sven Eckelmann sven@narfation.org --- bridge_loop_avoidance.c | 4 ++-- distributed-arp-table.h | 14 +++++++++----- icmp_socket.c | 2 +- originator.c | 4 ++-- originator.h | 8 ++++---- routing.c | 26 +++++++++++++++----------- translation-table.c | 21 +++++++++++---------- unicast.c | 2 +- vis.c | 2 +- 9 files changed, 46 insertions(+), 37 deletions(-)
diff --git a/bridge_loop_avoidance.c b/bridge_loop_avoidance.c index 7a2dfd4..1d143d5 100644 --- a/bridge_loop_avoidance.c +++ b/bridge_loop_avoidance.c @@ -390,7 +390,7 @@ static struct backbone_gw *bla_get_backbone_gw(struct bat_priv *bat_priv, }
/* this is a gateway now, remove any tt entries */ - orig_node = orig_hash_find(bat_priv, orig); + orig_node = batadv_orig_hash_find(bat_priv, orig); if (orig_node) { batadv_tt_global_del_orig(bat_priv, orig_node, "became a backbone gateway"); @@ -780,7 +780,7 @@ static int check_claim_group(struct bat_priv *bat_priv, return 2;
/* lets see if this originator is in our mesh */ - orig_node = orig_hash_find(bat_priv, backbone_addr); + orig_node = batadv_orig_hash_find(bat_priv, backbone_addr);
/* dont accept claims from gateways which are not in * the same mesh or group. diff --git a/distributed-arp-table.h b/distributed-arp-table.h index ee5200a..6b1d22c 100644 --- a/distributed-arp-table.h +++ b/distributed-arp-table.h @@ -52,16 +52,20 @@ void batadv_arp_change_timeout(struct net_device *soft_iface, const char *name); static inline void batadv_dat_init_orig_node_dht_addr(struct orig_node *orig_node) { - orig_node->dht_addr = (dat_addr_t)choose_orig(orig_node->orig, - DAT_ADDR_MAX); + uint32_t addr; + + addr = batadv_choose_orig(orig_node->orig, DAT_ADDR_MAX); + orig_node->dht_addr = (dat_addr_t)addr; }
static inline void batadv_dat_init_own_dht_addr(struct bat_priv *bat_priv, struct hard_iface *primary_if) { - bat_priv->dht_addr = (dat_addr_t) - choose_orig(primary_if->net_dev->dev_addr, - DAT_ADDR_MAX); + uint32_t addr; + + addr = batadv_choose_orig(primary_if->net_dev->dev_addr, DAT_ADDR_MAX); + + bat_priv->dht_addr = (dat_addr_t)addr; }
#else diff --git a/icmp_socket.c b/icmp_socket.c index d9e8cb3..76a8324 100644 --- a/icmp_socket.c +++ b/icmp_socket.c @@ -213,7 +213,7 @@ static ssize_t bat_socket_write(struct file *file, const char __user *buff, if (atomic_read(&bat_priv->mesh_state) != MESH_ACTIVE) goto dst_unreach;
- orig_node = orig_hash_find(bat_priv, icmp_packet->dst); + orig_node = batadv_orig_hash_find(bat_priv, icmp_packet->dst); if (!orig_node) goto dst_unreach;
diff --git a/originator.c b/originator.c index 9e7e1c2..26fa8b6 100644 --- a/originator.c +++ b/originator.c @@ -196,7 +196,7 @@ struct orig_node *batadv_get_orig_node(struct bat_priv *bat_priv, int size; int hash_added;
- orig_node = orig_hash_find(bat_priv, addr); + orig_node = batadv_orig_hash_find(bat_priv, addr); if (orig_node) return orig_node;
@@ -251,7 +251,7 @@ struct orig_node *batadv_get_orig_node(struct bat_priv *bat_priv, goto free_bcast_own;
hash_added = batadv_hash_add(bat_priv->orig_hash, compare_orig, - choose_orig, orig_node, + batadv_choose_orig, orig_node, &orig_node->hash_entry); if (hash_added != 0) goto free_bcast_own_sum; diff --git a/originator.h b/originator.h index a721719..c4f63b4 100644 --- a/originator.h +++ b/originator.h @@ -41,7 +41,7 @@ int batadv_orig_hash_del_if(struct hard_iface *hard_iface, int max_if_num); /* hashfunction to choose an entry in a hash table of given size * hash algorithm from http://en.wikipedia.org/wiki/Hash_table */ -static inline uint32_t choose_orig(const void *data, uint32_t size) +static inline uint32_t batadv_choose_orig(const void *data, uint32_t size) { const unsigned char *key = data; uint32_t hash = 0; @@ -60,8 +60,8 @@ static inline uint32_t choose_orig(const void *data, uint32_t size) return hash % size; }
-static inline struct orig_node *orig_hash_find(struct bat_priv *bat_priv, - const void *data) +static inline struct orig_node *batadv_orig_hash_find(struct bat_priv *bat_priv, + const void *data) { struct hashtable_t *hash = bat_priv->orig_hash; struct hlist_head *head; @@ -72,7 +72,7 @@ static inline struct orig_node *orig_hash_find(struct bat_priv *bat_priv, if (!hash) return NULL;
- index = choose_orig(data, hash->size); + index = batadv_choose_orig(data, hash->size); head = &hash->table[index];
rcu_read_lock(); diff --git a/routing.c b/routing.c index 2312da1..4741cdc 100644 --- a/routing.c +++ b/routing.c @@ -298,7 +298,7 @@ static int recv_my_icmp_packet(struct bat_priv *bat_priv,
/* answer echo request (ping) */ /* get routing information */ - orig_node = orig_hash_find(bat_priv, icmp_packet->orig); + orig_node = batadv_orig_hash_find(bat_priv, icmp_packet->orig); if (!orig_node) goto out;
@@ -353,7 +353,7 @@ static int recv_icmp_ttl_exceeded(struct bat_priv *bat_priv, goto out;
/* get routing information */ - orig_node = orig_hash_find(bat_priv, icmp_packet->orig); + orig_node = batadv_orig_hash_find(bat_priv, icmp_packet->orig); if (!orig_node) goto out;
@@ -437,7 +437,7 @@ int batadv_recv_icmp_packet(struct sk_buff *skb, struct hard_iface *recv_if) return recv_icmp_ttl_exceeded(bat_priv, skb);
/* get routing information */ - orig_node = orig_hash_find(bat_priv, icmp_packet->dst); + orig_node = batadv_orig_hash_find(bat_priv, icmp_packet->dst); if (!orig_node) goto out;
@@ -682,7 +682,7 @@ int batadv_recv_roam_adv(struct sk_buff *skb, struct hard_iface *recv_if) if (batadv_bla_is_backbone_gw_orig(bat_priv, roam_adv_packet->src)) goto out;
- orig_node = orig_hash_find(bat_priv, roam_adv_packet->src); + orig_node = batadv_orig_hash_find(bat_priv, roam_adv_packet->src); if (!orig_node) goto out;
@@ -719,6 +719,7 @@ struct neigh_node *batadv_find_router(struct bat_priv *bat_priv, struct neigh_node *router; static uint8_t zero_mac[ETH_ALEN] = {0, 0, 0, 0, 0, 0}; int bonding_enabled; + uint8_t *primary_addr;
if (!orig_node) return NULL; @@ -741,20 +742,22 @@ struct neigh_node *batadv_find_router(struct bat_priv *bat_priv, if ((!recv_if) && (!bonding_enabled)) goto return_router;
+ primary_addr = router_orig->primary_addr; + /* if we have something in the primary_addr, we can search * for a potential bonding candidate. */ - if (compare_eth(router_orig->primary_addr, zero_mac)) + if (compare_eth(primary_addr, zero_mac)) goto return_router;
/* find the orig_node which has the primary interface. might * even be the same as our router_orig in many cases */ - if (compare_eth(router_orig->primary_addr, router_orig->orig)) { + if (compare_eth(primary_addr, router_orig->orig)) { primary_orig_node = router_orig; } else { - primary_orig_node = orig_hash_find(bat_priv, - router_orig->primary_addr); + primary_orig_node = batadv_orig_hash_find(bat_priv, + primary_addr); if (!primary_orig_node) goto return_router;
@@ -837,7 +840,7 @@ static int route_unicast_packet(struct sk_buff *skb, struct hard_iface *recv_if) }
/* get routing information */ - orig_node = orig_hash_find(bat_priv, unicast_packet->dest); + orig_node = batadv_orig_hash_find(bat_priv, unicast_packet->dest);
if (!orig_node) goto out; @@ -919,7 +922,8 @@ static int check_unicast_ttvn(struct bat_priv *bat_priv, tt_poss_change = bat_priv->tt_poss_change; curr_ttvn = (uint8_t)atomic_read(&bat_priv->ttvn); } else { - orig_node = orig_hash_find(bat_priv, unicast_packet->dest); + orig_node = batadv_orig_hash_find(bat_priv, + unicast_packet->dest);
if (!orig_node) return 0; @@ -1079,7 +1083,7 @@ int batadv_recv_bcast_packet(struct sk_buff *skb, struct hard_iface *recv_if) if (bcast_packet->header.ttl < 2) goto out;
- orig_node = orig_hash_find(bat_priv, bcast_packet->orig); + orig_node = batadv_orig_hash_find(bat_priv, bcast_packet->orig);
if (!orig_node) goto out; diff --git a/translation-table.c b/translation-table.c index 0283d91..bd0e505 100644 --- a/translation-table.c +++ b/translation-table.c @@ -61,7 +61,7 @@ static struct tt_common_entry *tt_hash_find(struct hashtable_t *hash, if (!hash) return NULL;
- index = choose_orig(data, hash->size); + index = batadv_choose_orig(data, hash->size); head = &hash->table[index];
rcu_read_lock(); @@ -235,7 +235,8 @@ void batadv_tt_local_add(struct net_device *soft_iface, const uint8_t *addr, tt_local_entry->common.flags |= TT_CLIENT_NEW;
hash_added = batadv_hash_add(bat_priv->tt_local_hash, compare_tt, - choose_orig, &tt_local_entry->common, + batadv_choose_orig, + &tt_local_entry->common, &tt_local_entry->common.hash_entry);
if (unlikely(hash_added != 0)) { @@ -639,7 +640,7 @@ int batadv_tt_global_add(struct bat_priv *bat_priv, struct orig_node *orig_node, spin_lock_init(&tt_global_entry->list_lock);
hash_added = batadv_hash_add(bat_priv->tt_global_hash, - compare_tt, choose_orig, + compare_tt, batadv_choose_orig, common, &common->hash_entry);
if (unlikely(hash_added != 0)) { @@ -818,8 +819,8 @@ static void tt_global_del_struct(struct bat_priv *bat_priv, "Deleting global tt entry %pM: %s\n", tt_global_entry->common.addr, message);
- batadv_hash_remove(bat_priv->tt_global_hash, compare_tt, choose_orig, - tt_global_entry->common.addr); + batadv_hash_remove(bat_priv->tt_global_hash, compare_tt, + batadv_choose_orig, tt_global_entry->common.addr); tt_global_entry_free_ref(tt_global_entry);
} @@ -1454,11 +1455,11 @@ static bool send_other_tt_response(struct bat_priv *bat_priv, (tt_request->flags & TT_FULL_TABLE ? 'F' : '.'));
/* Let's get the orig node of the REAL destination */ - req_dst_orig_node = orig_hash_find(bat_priv, tt_request->dst); + req_dst_orig_node = batadv_orig_hash_find(bat_priv, tt_request->dst); if (!req_dst_orig_node) goto out;
- res_dst_orig_node = orig_hash_find(bat_priv, tt_request->src); + res_dst_orig_node = batadv_orig_hash_find(bat_priv, tt_request->src); if (!res_dst_orig_node) goto out;
@@ -1586,7 +1587,7 @@ static bool send_my_tt_response(struct bat_priv *bat_priv, my_ttvn = (uint8_t)atomic_read(&bat_priv->ttvn); req_ttvn = tt_request->ttvn;
- orig_node = orig_hash_find(bat_priv, tt_request->src); + orig_node = batadv_orig_hash_find(bat_priv, tt_request->src); if (!orig_node) goto out;
@@ -1731,7 +1732,7 @@ static void tt_fill_gtable(struct bat_priv *bat_priv, { struct orig_node *orig_node = NULL;
- orig_node = orig_hash_find(bat_priv, tt_response->src); + orig_node = batadv_orig_hash_find(bat_priv, tt_response->src); if (!orig_node) goto out;
@@ -1804,7 +1805,7 @@ void batadv_handle_tt_response(struct bat_priv *bat_priv, if (batadv_bla_is_backbone_gw_orig(bat_priv, tt_response->src)) goto out;
- orig_node = orig_hash_find(bat_priv, tt_response->src); + orig_node = batadv_orig_hash_find(bat_priv, tt_response->src); if (!orig_node) goto out;
diff --git a/unicast.c b/unicast.c index e70cbbc..387b959 100644 --- a/unicast.c +++ b/unicast.c @@ -181,7 +181,7 @@ int batadv_frag_reassemble_skb(struct sk_buff *skb, struct bat_priv *bat_priv,
*new_skb = NULL;
- orig_node = orig_hash_find(bat_priv, unicast_packet->orig); + orig_node = batadv_orig_hash_find(bat_priv, unicast_packet->orig); if (!orig_node) goto out;
diff --git a/vis.c b/vis.c index e0a9057..bf72c52 100644 --- a/vis.c +++ b/vis.c @@ -803,7 +803,7 @@ static void unicast_vis_packet(struct bat_priv *bat_priv,
packet = (struct vis_packet *)info->skb_packet->data;
- orig_node = orig_hash_find(bat_priv, packet->target_orig); + orig_node = batadv_orig_hash_find(bat_priv, packet->target_orig); if (!orig_node) goto out;
On Saturday, May 12, 2012 19:48:56 Sven Eckelmann wrote:
All non-static symbols of batman-adv were prefixed with batadv_ to avoid collisions with other symbols of the kernel. Other symbols of batman-adv should use the same prefix to keep the naming scheme consistent.
Signed-off-by: Sven Eckelmann sven@narfation.org
bridge_loop_avoidance.c | 4 ++-- distributed-arp-table.h | 14 +++++++++----- icmp_socket.c | 2 +- originator.c | 4 ++-- originator.h | 8 ++++---- routing.c | 26 +++++++++++++++----------- translation-table.c | 21 +++++++++++---------- unicast.c | 2 +- vis.c | 2 +- 9 files changed, 46 insertions(+), 37 deletions(-)
Applied in revision 12c5e46.
Thanks, Marek
All non-static symbols of batman-adv were prefixed with batadv_ to avoid collisions with other symbols of the kernel. Other symbols of batman-adv should use the same prefix to keep the naming scheme consistent.
Signed-off-by: Sven Eckelmann sven@narfation.org --- distributed-arp-table.c | 2 +- routing.c | 3 ++- soft-interface.c | 2 +- unicast.h | 12 ++++++------ 4 files changed, 10 insertions(+), 9 deletions(-)
diff --git a/distributed-arp-table.c b/distributed-arp-table.c index a0b38b1..68dbde1 100644 --- a/distributed-arp-table.c +++ b/distributed-arp-table.c @@ -498,7 +498,7 @@ bool batadv_dat_snoop_incoming_arp_request(struct bat_priv *bat_priv,
inc_counter(bat_priv, BAT_CNT_DAT_REPLY_TX);
- unicast_4addr_send_skb(skb_new, bat_priv, BAT_P_DAT_CACHE_REPLY); + batadv_unicast_4addr_send_skb(skb_new, bat_priv, BAT_P_DAT_CACHE_REPLY);
ret = true; out: diff --git a/routing.c b/routing.c index 4741cdc..b1a1732 100644 --- a/routing.c +++ b/routing.c @@ -867,7 +867,8 @@ static int route_unicast_packet(struct sk_buff *skb, struct hard_iface *recv_if) }
if (unicast_packet->header.packet_type == BAT_UNICAST_FRAG && - frag_can_reassemble(skb, neigh_node->if_incoming->net_dev->mtu)) { + batadv_frag_can_reassemble(skb, + neigh_node->if_incoming->net_dev->mtu)) {
ret = batadv_frag_reassemble_skb(skb, bat_priv, &new_skb);
diff --git a/soft-interface.c b/soft-interface.c index faba6f3..fc3ea29 100644 --- a/soft-interface.c +++ b/soft-interface.c @@ -245,7 +245,7 @@ static int interface_tx(struct sk_buff *skb, struct net_device *soft_iface)
batadv_dat_snoop_outgoing_arp_reply(bat_priv, skb);
- ret = unicast_send_skb(skb, bat_priv); + ret = batadv_unicast_send_skb(skb, bat_priv); if (ret != 0) goto dropped_freed; } diff --git a/unicast.h b/unicast.h index c09ebbc..a9a71af 100644 --- a/unicast.h +++ b/unicast.h @@ -39,21 +39,21 @@ int batadv_unicast_generic_send_skb(struct sk_buff *skb, struct bat_priv *bat_priv, int packet_type, int packet_subtype);
-static inline int unicast_send_skb(struct sk_buff *skb, - struct bat_priv *bat_priv) +static inline int batadv_unicast_send_skb(struct sk_buff *skb, + struct bat_priv *bat_priv) { return batadv_unicast_generic_send_skb(skb, bat_priv, BAT_UNICAST, 0); }
-static inline int unicast_4addr_send_skb(struct sk_buff *skb, - struct bat_priv *bat_priv, - int packet_subtype) +static inline int batadv_unicast_4addr_send_skb(struct sk_buff *skb, + struct bat_priv *bat_priv, + int packet_subtype) { return batadv_unicast_generic_send_skb(skb, bat_priv, BAT_UNICAST_4ADDR, packet_subtype); }
-static inline int frag_can_reassemble(const struct sk_buff *skb, int mtu) +static inline int batadv_frag_can_reassemble(const struct sk_buff *skb, int mtu) { const struct unicast_frag_packet *unicast_packet; int uneven_correction = 0;
On Saturday, May 12, 2012 19:48:57 Sven Eckelmann wrote:
All non-static symbols of batman-adv were prefixed with batadv_ to avoid collisions with other symbols of the kernel. Other symbols of batman-adv should use the same prefix to keep the naming scheme consistent.
Signed-off-by: Sven Eckelmann sven@narfation.org
distributed-arp-table.c | 2 +- routing.c | 3 ++- soft-interface.c | 2 +- unicast.h | 12 ++++++------ 4 files changed, 10 insertions(+), 9 deletions(-)
Applied in revision 347c71c.
Thanks, Marek
All non-static symbols of batman-adv were prefixed with batadv_ to avoid collisions with other symbols of the kernel. Other symbols of batman-adv should use the same prefix to keep the naming scheme consistent.
Signed-off-by: Sven Eckelmann sven@narfation.org --- bat_iv_ogm.c | 213 ++++++++++++++++++++++++----------------------- bat_sysfs.c | 8 +- bitarray.c | 10 +-- bridge_loop_avoidance.c | 165 ++++++++++++++++++------------------ distributed-arp-table.c | 79 +++++++++--------- gateway_client.c | 54 ++++++------ hard-interface.c | 4 +- icmp_socket.c | 12 +-- main.c | 8 +- main.h | 25 +++--- originator.c | 61 +++++++------- originator.h | 2 +- routing.c | 71 ++++++++-------- send.c | 12 +-- soft-interface.c | 4 +- translation-table.c | 149 +++++++++++++++++---------------- vis.c | 27 +++--- 17 files changed, 464 insertions(+), 440 deletions(-)
diff --git a/bat_iv_ogm.c b/bat_iv_ogm.c index 51c2e19..304284d 100644 --- a/bat_iv_ogm.c +++ b/bat_iv_ogm.c @@ -179,16 +179,16 @@ static void bat_iv_ogm_send_to_if(struct forw_packet *forw_packet, fwd_str = (packet_num > 0 ? "Forwarding" : (forw_packet->own ? "Sending own" : "Forwarding")); - bat_dbg(DBG_BATMAN, bat_priv, - "%s %spacket (originator %pM, seqno %u, TQ %d, TTL %d, IDF %s, ttvn %d) on interface %s [%pM]\n", - fwd_str, (packet_num > 0 ? "aggregated " : ""), - batman_ogm_packet->orig, - ntohl(batman_ogm_packet->seqno), - batman_ogm_packet->tq, batman_ogm_packet->header.ttl, - (batman_ogm_packet->flags & DIRECTLINK ? - "on" : "off"), - batman_ogm_packet->ttvn, hard_iface->net_dev->name, - hard_iface->net_dev->dev_addr); + batadv_dbg(DBG_BATMAN, bat_priv, + "%s %spacket (originator %pM, seqno %u, TQ %d, TTL %d, IDF %s, ttvn %d) on interface %s [%pM]\n", + fwd_str, (packet_num > 0 ? "aggregated " : ""), + batman_ogm_packet->orig, + ntohl(batman_ogm_packet->seqno), + batman_ogm_packet->tq, batman_ogm_packet->header.ttl, + (batman_ogm_packet->flags & DIRECTLINK ? + "on" : "off"), + batman_ogm_packet->ttvn, hard_iface->net_dev->name, + hard_iface->net_dev->dev_addr);
buff_pos += BATMAN_OGM_HLEN; buff_pos += batadv_tt_len(batman_ogm_packet->tt_num_changes); @@ -201,8 +201,8 @@ static void bat_iv_ogm_send_to_if(struct forw_packet *forw_packet, skb = skb_clone(forw_packet->skb, GFP_ATOMIC); if (skb) { inc_counter(bat_priv, BAT_CNT_MGMT_TX); - add_counter(bat_priv, BAT_CNT_MGMT_TX_BYTES, - skb->len + ETH_HLEN); + batadv_add_counter(bat_priv, BAT_CNT_MGMT_TX_BYTES, + skb->len + ETH_HLEN); batadv_send_skb_packet(skb, hard_iface, batadv_broadcast_addr); } } @@ -243,14 +243,14 @@ static void bat_iv_ogm_emit(struct forw_packet *forw_packet) (forw_packet->own && (forw_packet->if_incoming != primary_if))) {
/* FIXME: what about aggregated packets ? */ - bat_dbg(DBG_BATMAN, bat_priv, - "%s packet (originator %pM, seqno %u, TTL %d) on interface %s [%pM]\n", - (forw_packet->own ? "Sending own" : "Forwarding"), - batman_ogm_packet->orig, - ntohl(batman_ogm_packet->seqno), - batman_ogm_packet->header.ttl, - forw_packet->if_incoming->net_dev->name, - forw_packet->if_incoming->net_dev->dev_addr); + batadv_dbg(DBG_BATMAN, bat_priv, + "%s packet (originator %pM, seqno %u, TTL %d) on interface %s [%pM]\n", + (forw_packet->own ? "Sending own" : "Forwarding"), + batman_ogm_packet->orig, + ntohl(batman_ogm_packet->seqno), + batman_ogm_packet->header.ttl, + forw_packet->if_incoming->net_dev->name, + forw_packet->if_incoming->net_dev->dev_addr);
/* skb is only used once and than forw_packet is free'd */ batadv_send_skb_packet(forw_packet->skb, @@ -373,8 +373,8 @@ static void bat_iv_ogm_aggregate_new(const unsigned char *packet_buff, /* own packet should always be scheduled */ if (!own_packet) { if (!atomic_dec_not_zero(&bat_priv->batman_queue_left)) { - bat_dbg(DBG_BATMAN, bat_priv, - "batman packet queue full\n"); + batadv_dbg(DBG_BATMAN, bat_priv, + "batman packet queue full\n"); goto out; } } @@ -521,7 +521,7 @@ static void bat_iv_ogm_forward(struct orig_node *orig_node, uint8_t tt_num_changes;
if (batman_ogm_packet->header.ttl <= 1) { - bat_dbg(DBG_BATMAN, bat_priv, "ttl exceeded\n"); + batadv_dbg(DBG_BATMAN, bat_priv, "ttl exceeded\n"); return; }
@@ -546,9 +546,9 @@ static void bat_iv_ogm_forward(struct orig_node *orig_node, /* apply hop penalty */ batman_ogm_packet->tq = hop_penalty(batman_ogm_packet->tq, bat_priv);
- bat_dbg(DBG_BATMAN, bat_priv, - "Forwarding packet: tq: %i, ttl: %i\n", - batman_ogm_packet->tq, batman_ogm_packet->header.ttl); + batadv_dbg(DBG_BATMAN, bat_priv, + "Forwarding packet: tq: %i, ttl: %i\n", + batman_ogm_packet->tq, batman_ogm_packet->header.ttl);
/* switch of primaries first hop flag when forwarding */ batman_ogm_packet->flags &= ~PRIMARIES_FIRST_HOP; @@ -625,16 +625,18 @@ static void bat_iv_ogm_orig_update(struct bat_priv *bat_priv, struct orig_node *orig_node_tmp; struct hlist_node *node; uint8_t bcast_own_sum_orig, bcast_own_sum_neigh; + uint8_t *neigh_addr;
- bat_dbg(DBG_BATMAN, bat_priv, - "update_originator(): Searching and updating originator entry of received packet\n"); + batadv_dbg(DBG_BATMAN, bat_priv, + "update_originator(): Searching and updating originator entry of received packet\n");
rcu_read_lock(); hlist_for_each_entry_rcu(tmp_neigh_node, node, &orig_node->neigh_list, list) { - if (compare_eth(tmp_neigh_node->addr, ethhdr->h_source) && - (tmp_neigh_node->if_incoming == if_incoming) && - atomic_inc_not_zero(&tmp_neigh_node->refcount)) { + neigh_addr = tmp_neigh_node->addr; + if (batadv_compare_eth(neigh_addr, ethhdr->h_source) && + tmp_neigh_node->if_incoming == if_incoming && + atomic_inc_not_zero(&tmp_neigh_node->refcount)) { if (neigh_node) batadv_neigh_node_free_ref(neigh_node); neigh_node = tmp_neigh_node; @@ -667,8 +669,8 @@ static void bat_iv_ogm_orig_update(struct bat_priv *bat_priv, if (!neigh_node) goto unlock; } else - bat_dbg(DBG_BATMAN, bat_priv, - "Updating existing last-hop neighbor of originator\n"); + batadv_dbg(DBG_BATMAN, bat_priv, + "Updating existing last-hop neighbor of originator\n");
rcu_read_unlock();
@@ -774,7 +776,8 @@ static int bat_iv_ogm_calc_tq(struct orig_node *orig_node, hlist_for_each_entry_rcu(tmp_neigh_node, node, &orig_neigh_node->neigh_list, list) {
- if (!compare_eth(tmp_neigh_node->addr, orig_neigh_node->orig)) + if (!batadv_compare_eth(tmp_neigh_node->addr, + orig_neigh_node->orig)) continue;
if (tmp_neigh_node->if_incoming != if_incoming) @@ -844,10 +847,11 @@ static int bat_iv_ogm_calc_tq(struct orig_node *orig_node, * tq_asym_penalty) / (TQ_MAX_VALUE * TQ_MAX_VALUE));
- bat_dbg(DBG_BATMAN, bat_priv, - "bidirectional: orig = %-15pM neigh = %-15pM => own_bcast = %2i, real recv = %2i, local tq: %3i, asym_penalty: %3i, total tq: %3i\n", - orig_node->orig, orig_neigh_node->orig, total_count, - neigh_rq_count, tq_own, tq_asym_penalty, batman_ogm_packet->tq); + batadv_dbg(DBG_BATMAN, bat_priv, + "bidirectional: orig = %-15pM neigh = %-15pM => own_bcast = %2i, real recv = %2i, local tq: %3i, asym_penalty: %3i, total tq: %3i\n", + orig_node->orig, orig_neigh_node->orig, total_count, + neigh_rq_count, tq_own, + tq_asym_penalty, batman_ogm_packet->tq);
/* if link has the minimum required transmission quality * consider it bidirectional @@ -883,6 +887,7 @@ static int bat_iv_ogm_update_seqnos(const struct ethhdr *ethhdr, int need_update = 0; int set_mark, ret = -1; uint32_t seqno = ntohl(batman_ogm_packet->seqno); + uint8_t *neigh_addr;
orig_node = batadv_get_orig_node(bat_priv, batman_ogm_packet->orig); if (!orig_node) @@ -905,8 +910,9 @@ static int bat_iv_ogm_update_seqnos(const struct ethhdr *ethhdr, orig_node->last_real_seqno, seqno);
- if (compare_eth(tmp_neigh_node->addr, ethhdr->h_source) && - (tmp_neigh_node->if_incoming == if_incoming)) + neigh_addr = tmp_neigh_node->addr; + if (batadv_compare_eth(neigh_addr, ethhdr->h_source) && + tmp_neigh_node->if_incoming == if_incoming) set_mark = 1; else set_mark = 0; @@ -923,9 +929,9 @@ static int bat_iv_ogm_update_seqnos(const struct ethhdr *ethhdr, rcu_read_unlock();
if (need_update) { - bat_dbg(DBG_BATMAN, bat_priv, - "updating last_seqno: old %u, new %u\n", - orig_node->last_real_seqno, seqno); + batadv_dbg(DBG_BATMAN, bat_priv, + "updating last_seqno: old %u, new %u\n", + orig_node->last_real_seqno, seqno); orig_node->last_real_seqno = seqno; }
@@ -954,6 +960,7 @@ static void bat_iv_ogm_process(const struct ethhdr *ethhdr, bool is_from_best_next_hop = false; int is_duplicate; uint32_t if_incoming_seqno; + uint8_t *prev_sender;
/* Silently drop when the batman packet is actually not a * correct packet. @@ -975,18 +982,19 @@ static void bat_iv_ogm_process(const struct ethhdr *ethhdr,
has_directlink_flag = (batman_ogm_packet->flags & DIRECTLINK ? 1 : 0);
- if (compare_eth(ethhdr->h_source, batman_ogm_packet->orig)) + if (batadv_compare_eth(ethhdr->h_source, batman_ogm_packet->orig)) is_single_hop_neigh = true;
- bat_dbg(DBG_BATMAN, bat_priv, - "Received BATMAN packet via NB: %pM, IF: %s [%pM] (from OG: %pM, via prev OG: %pM, seqno %u, ttvn %u, crc %u, changes %u, td %d, TTL %d, V %d, IDF %d)\n", - ethhdr->h_source, if_incoming->net_dev->name, - if_incoming->net_dev->dev_addr, batman_ogm_packet->orig, - batman_ogm_packet->prev_sender, ntohl(batman_ogm_packet->seqno), - batman_ogm_packet->ttvn, ntohs(batman_ogm_packet->tt_crc), - batman_ogm_packet->tt_num_changes, batman_ogm_packet->tq, - batman_ogm_packet->header.ttl, - batman_ogm_packet->header.version, has_directlink_flag); + batadv_dbg(DBG_BATMAN, bat_priv, + "Received BATMAN packet via NB: %pM, IF: %s [%pM] (from OG: %pM, via prev OG: %pM, seqno %u, ttvn %u, crc %u, changes %u, td %d, TTL %d, V %d, IDF %d)\n", + ethhdr->h_source, if_incoming->net_dev->name, + if_incoming->net_dev->dev_addr, batman_ogm_packet->orig, + batman_ogm_packet->prev_sender, + ntohl(batman_ogm_packet->seqno), batman_ogm_packet->ttvn, + ntohs(batman_ogm_packet->tt_crc), + batman_ogm_packet->tt_num_changes, batman_ogm_packet->tq, + batman_ogm_packet->header.ttl, + batman_ogm_packet->header.version, has_directlink_flag);
rcu_read_lock(); list_for_each_entry_rcu(hard_iface, &batadv_hardif_list, list) { @@ -996,16 +1004,16 @@ static void bat_iv_ogm_process(const struct ethhdr *ethhdr, if (hard_iface->soft_iface != if_incoming->soft_iface) continue;
- if (compare_eth(ethhdr->h_source, - hard_iface->net_dev->dev_addr)) + if (batadv_compare_eth(ethhdr->h_source, + hard_iface->net_dev->dev_addr)) is_my_addr = 1;
- if (compare_eth(batman_ogm_packet->orig, - hard_iface->net_dev->dev_addr)) + if (batadv_compare_eth(batman_ogm_packet->orig, + hard_iface->net_dev->dev_addr)) is_my_orig = 1;
- if (compare_eth(batman_ogm_packet->prev_sender, - hard_iface->net_dev->dev_addr)) + if (batadv_compare_eth(batman_ogm_packet->prev_sender, + hard_iface->net_dev->dev_addr)) is_my_oldorig = 1;
if (is_broadcast_ether_addr(ethhdr->h_source)) @@ -1014,23 +1022,23 @@ static void bat_iv_ogm_process(const struct ethhdr *ethhdr, rcu_read_unlock();
if (batman_ogm_packet->header.version != COMPAT_VERSION) { - bat_dbg(DBG_BATMAN, bat_priv, - "Drop packet: incompatible batman version (%i)\n", - batman_ogm_packet->header.version); + batadv_dbg(DBG_BATMAN, bat_priv, + "Drop packet: incompatible batman version (%i)\n", + batman_ogm_packet->header.version); return; }
if (is_my_addr) { - bat_dbg(DBG_BATMAN, bat_priv, - "Drop packet: received my own broadcast (sender: %pM)\n", - ethhdr->h_source); + batadv_dbg(DBG_BATMAN, bat_priv, + "Drop packet: received my own broadcast (sender: %pM)\n", + ethhdr->h_source); return; }
if (is_broadcast) { - bat_dbg(DBG_BATMAN, bat_priv, - "Drop packet: ignoring all packets with broadcast source addr (sender: %pM)\n", - ethhdr->h_source); + batadv_dbg(DBG_BATMAN, bat_priv, + "Drop packet: ignoring all packets with broadcast source addr (sender: %pM)\n", + ethhdr->h_source); return; }
@@ -1049,8 +1057,8 @@ static void bat_iv_ogm_process(const struct ethhdr *ethhdr, * save packet seqno for bidirectional check */ if (has_directlink_flag && - compare_eth(if_incoming->net_dev->dev_addr, - batman_ogm_packet->orig)) { + batadv_compare_eth(if_incoming->net_dev->dev_addr, + batman_ogm_packet->orig)) { offset = if_incoming->if_num * NUM_WORDS;
spin_lock_bh(&orig_neigh_node->ogm_cnt_lock); @@ -1063,23 +1071,23 @@ static void bat_iv_ogm_process(const struct ethhdr *ethhdr, spin_unlock_bh(&orig_neigh_node->ogm_cnt_lock); }
- bat_dbg(DBG_BATMAN, bat_priv, - "Drop packet: originator packet from myself (via neighbor)\n"); + batadv_dbg(DBG_BATMAN, bat_priv, + "Drop packet: originator packet from myself (via neighbor)\n"); batadv_orig_node_free_ref(orig_neigh_node); return; }
if (is_my_oldorig) { - bat_dbg(DBG_BATMAN, bat_priv, - "Drop packet: ignoring all rebroadcast echos (sender: %pM)\n", - ethhdr->h_source); + batadv_dbg(DBG_BATMAN, bat_priv, + "Drop packet: ignoring all rebroadcast echos (sender: %pM)\n", + ethhdr->h_source); return; }
if (batman_ogm_packet->flags & NOT_BEST_NEXT_HOP) { - bat_dbg(DBG_BATMAN, bat_priv, - "Drop packet: ignoring all packets not forwarded from the best next hop (sender: %pM)\n", - ethhdr->h_source); + batadv_dbg(DBG_BATMAN, bat_priv, + "Drop packet: ignoring all packets not forwarded from the best next hop (sender: %pM)\n", + ethhdr->h_source); return; }
@@ -1091,15 +1099,15 @@ static void bat_iv_ogm_process(const struct ethhdr *ethhdr, if_incoming);
if (is_duplicate == -1) { - bat_dbg(DBG_BATMAN, bat_priv, - "Drop packet: packet within seqno protection time (sender: %pM)\n", - ethhdr->h_source); + batadv_dbg(DBG_BATMAN, bat_priv, + "Drop packet: packet within seqno protection time (sender: %pM)\n", + ethhdr->h_source); goto out; }
if (batman_ogm_packet->tq == 0) { - bat_dbg(DBG_BATMAN, bat_priv, - "Drop packet: originator packet with tq equal 0\n"); + batadv_dbg(DBG_BATMAN, bat_priv, + "Drop packet: originator packet with tq equal 0\n"); goto out; }
@@ -1108,18 +1116,18 @@ static void bat_iv_ogm_process(const struct ethhdr *ethhdr, router_router = batadv_orig_node_get_router(router->orig_node);
if ((router && router->tq_avg != 0) && - (compare_eth(router->addr, ethhdr->h_source))) + (batadv_compare_eth(router->addr, ethhdr->h_source))) is_from_best_next_hop = true;
+ prev_sender = batman_ogm_packet->prev_sender; /* avoid temporary routing loops */ if (router && router_router && - (compare_eth(router->addr, batman_ogm_packet->prev_sender)) && - !(compare_eth(batman_ogm_packet->orig, - batman_ogm_packet->prev_sender)) && - (compare_eth(router->addr, router_router->addr))) { - bat_dbg(DBG_BATMAN, bat_priv, - "Drop packet: ignoring all rebroadcast packets that may make me loop (sender: %pM)\n", - ethhdr->h_source); + (batadv_compare_eth(router->addr, prev_sender)) && + !(batadv_compare_eth(batman_ogm_packet->orig, prev_sender)) && + (batadv_compare_eth(router->addr, router_router->addr))) { + batadv_dbg(DBG_BATMAN, bat_priv, + "Drop packet: ignoring all rebroadcast packets that may make me loop (sender: %pM)\n", + ethhdr->h_source); goto out; }
@@ -1138,8 +1146,8 @@ static void bat_iv_ogm_process(const struct ethhdr *ethhdr, * don't route towards it */ if (!is_single_hop_neigh && (!orig_neigh_router)) { - bat_dbg(DBG_BATMAN, bat_priv, - "Drop packet: OGM via unknown neighbor!\n"); + batadv_dbg(DBG_BATMAN, bat_priv, + "Drop packet: OGM via unknown neighbor!\n"); goto out_neigh; }
@@ -1168,26 +1176,26 @@ static void bat_iv_ogm_process(const struct ethhdr *ethhdr, is_single_hop_neigh, is_from_best_next_hop, if_incoming);
- bat_dbg(DBG_BATMAN, bat_priv, - "Forwarding packet: rebroadcast neighbor packet with direct link flag\n"); + batadv_dbg(DBG_BATMAN, bat_priv, + "Forwarding packet: rebroadcast neighbor packet with direct link flag\n"); goto out_neigh; }
/* multihop originator */ if (!is_bidirectional) { - bat_dbg(DBG_BATMAN, bat_priv, - "Drop packet: not received via bidirectional link\n"); + batadv_dbg(DBG_BATMAN, bat_priv, + "Drop packet: not received via bidirectional link\n"); goto out_neigh; }
if (is_duplicate) { - bat_dbg(DBG_BATMAN, bat_priv, - "Drop packet: duplicate packet received\n"); + batadv_dbg(DBG_BATMAN, bat_priv, + "Drop packet: duplicate packet received\n"); goto out_neigh; }
- bat_dbg(DBG_BATMAN, bat_priv, - "Forwarding packet: rebroadcast originator packet\n"); + batadv_dbg(DBG_BATMAN, bat_priv, + "Forwarding packet: rebroadcast originator packet\n"); bat_iv_ogm_forward(orig_node, ethhdr, batman_ogm_packet, is_single_hop_neigh, is_from_best_next_hop, if_incoming); @@ -1227,7 +1235,8 @@ static int bat_iv_ogm_receive(struct sk_buff *skb, return NET_RX_DROP;
inc_counter(bat_priv, BAT_CNT_MGMT_RX); - add_counter(bat_priv, BAT_CNT_MGMT_RX_BYTES, skb->len + ETH_HLEN); + batadv_add_counter(bat_priv, BAT_CNT_MGMT_RX_BYTES, + skb->len + ETH_HLEN);
packet_len = skb_headlen(skb); ethhdr = (struct ethhdr *)skb_mac_header(skb); diff --git a/bat_sysfs.c b/bat_sysfs.c index dd3c8e6..1e1060f 100644 --- a/bat_sysfs.c +++ b/bat_sysfs.c @@ -728,9 +728,9 @@ out: batadv_hardif_free_ref(primary_if);
if (ret) - bat_dbg(DBG_BATMAN, bat_priv, - "Impossible to send uevent for (%s,%s,%s) event (err: %d)\n", - uev_type_str[type], uev_action_str[action], - (action == UEV_DEL ? "NULL" : data), ret); + batadv_dbg(DBG_BATMAN, bat_priv, + "Impossible to send uevent for (%s,%s,%s) event (err: %d)\n", + uev_type_str[type], uev_action_str[action], + (action == UEV_DEL ? "NULL" : data), ret); return ret; } diff --git a/bitarray.c b/bitarray.c index 7a7065c..e195b9e 100644 --- a/bitarray.c +++ b/bitarray.c @@ -66,9 +66,9 @@ int batadv_bit_get_packet(void *priv, unsigned long *seq_bits, /* sequence number is much newer, probably missed a lot of packets */ if ((seq_num_diff >= TQ_LOCAL_WINDOW_SIZE) && (seq_num_diff < EXPECTED_SEQNO_RANGE)) { - bat_dbg(DBG_BATMAN, bat_priv, - "We missed a lot of packets (%i) !\n", - seq_num_diff - 1); + batadv_dbg(DBG_BATMAN, bat_priv, + "We missed a lot of packets (%i) !\n", + seq_num_diff - 1); bitmap_zero(seq_bits, TQ_LOCAL_WINDOW_SIZE); if (set_mark) batadv_set_bit(seq_bits, 0); @@ -83,8 +83,8 @@ int batadv_bit_get_packet(void *priv, unsigned long *seq_bits, if ((seq_num_diff <= -TQ_LOCAL_WINDOW_SIZE) || (seq_num_diff >= EXPECTED_SEQNO_RANGE)) {
- bat_dbg(DBG_BATMAN, bat_priv, - "Other host probably restarted!\n"); + batadv_dbg(DBG_BATMAN, bat_priv, + "Other host probably restarted!\n");
bitmap_zero(seq_bits, TQ_LOCAL_WINDOW_SIZE); if (set_mark) diff --git a/bridge_loop_avoidance.c b/bridge_loop_avoidance.c index 1d143d5..b7d7084 100644 --- a/bridge_loop_avoidance.c +++ b/bridge_loop_avoidance.c @@ -294,25 +294,26 @@ static void bla_send_claim(struct bat_priv *bat_priv, uint8_t *mac, * set Ethernet SRC to the clients mac */ memcpy(ethhdr->h_source, mac, ETH_ALEN); - bat_dbg(DBG_BLA, bat_priv, - "bla_send_claim(): CLAIM %pM on vid %d\n", mac, vid); + batadv_dbg(DBG_BLA, bat_priv, + "bla_send_claim(): CLAIM %pM on vid %d\n", mac, vid); break; case CLAIM_TYPE_DEL: /* unclaim frame * set HW SRC to the clients mac */ memcpy(hw_src, mac, ETH_ALEN); - bat_dbg(DBG_BLA, bat_priv, - "bla_send_claim(): UNCLAIM %pM on vid %d\n", mac, vid); + batadv_dbg(DBG_BLA, bat_priv, + "bla_send_claim(): UNCLAIM %pM on vid %d\n", mac, + vid); break; case CLAIM_TYPE_ANNOUNCE: /* announcement frame * set HW SRC to the special mac containg the crc */ memcpy(hw_src, mac, ETH_ALEN); - bat_dbg(DBG_BLA, bat_priv, - "bla_send_claim(): ANNOUNCE of %pM on vid %d\n", - ethhdr->h_source, vid); + batadv_dbg(DBG_BLA, bat_priv, + "bla_send_claim(): ANNOUNCE of %pM on vid %d\n", + ethhdr->h_source, vid); break; case CLAIM_TYPE_REQUEST: /* request frame @@ -320,9 +321,9 @@ static void bla_send_claim(struct bat_priv *bat_priv, uint8_t *mac, */ memcpy(hw_src, mac, ETH_ALEN); memcpy(ethhdr->h_dest, mac, ETH_ALEN); - bat_dbg(DBG_BLA, bat_priv, - "bla_send_claim(): REQUEST of %pM to %pMon vid %d\n", - ethhdr->h_source, ethhdr->h_dest, vid); + batadv_dbg(DBG_BLA, bat_priv, + "bla_send_claim(): REQUEST of %pM to %pMon vid %d\n", + ethhdr->h_source, ethhdr->h_dest, vid); break;
} @@ -361,9 +362,9 @@ static struct backbone_gw *bla_get_backbone_gw(struct bat_priv *bat_priv, if (entry) return entry;
- bat_dbg(DBG_BLA, bat_priv, - "bla_get_backbone_gw(): not found (%pM, %d), creating new entry\n", - orig, vid); + batadv_dbg(DBG_BLA, bat_priv, + "bla_get_backbone_gw(): not found (%pM, %d), creating new entry\n", + orig, vid);
entry = kzalloc(sizeof(*entry), GFP_ATOMIC); if (!entry) @@ -433,8 +434,8 @@ static void bla_answer_request(struct bat_priv *bat_priv, struct backbone_gw *backbone_gw; int i;
- bat_dbg(DBG_BLA, bat_priv, - "bla_answer_request(): received a claim request, send all of our own claims again\n"); + batadv_dbg(DBG_BLA, bat_priv, + "bla_answer_request(): received a claim request, send all of our own claims again\n");
backbone_gw = backbone_hash_find(bat_priv, primary_if->net_dev->dev_addr, vid); @@ -473,9 +474,8 @@ static void bla_send_request(struct backbone_gw *backbone_gw) /* first, remove all old entries */ bla_del_backbone_claims(backbone_gw);
- bat_dbg(DBG_BLA, backbone_gw->bat_priv, - "Sending REQUEST to %pM\n", - backbone_gw->orig); + batadv_dbg(DBG_BLA, backbone_gw->bat_priv, "Sending REQUEST to %pM\n", + backbone_gw->orig);
/* send request */ bla_send_claim(backbone_gw->bat_priv, backbone_gw->orig, @@ -538,9 +538,9 @@ static void bla_add_claim(struct bat_priv *bat_priv, const uint8_t *mac, claim->backbone_gw = backbone_gw;
atomic_set(&claim->refcount, 2); - bat_dbg(DBG_BLA, bat_priv, - "bla_add_claim(): adding new entry %pM, vid %d to hash ...\n", - mac, vid); + batadv_dbg(DBG_BLA, bat_priv, + "bla_add_claim(): adding new entry %pM, vid %d to hash ...\n", + mac, vid); hash_added = batadv_hash_add(bat_priv->claim_hash, compare_claim, choose_claim, claim, &claim->hash_entry); @@ -556,9 +556,9 @@ static void bla_add_claim(struct bat_priv *bat_priv, const uint8_t *mac, /* no need to register a new backbone */ goto claim_free_ref;
- bat_dbg(DBG_BLA, bat_priv, - "bla_add_claim(): changing ownership for %pM, vid %d\n", - mac, vid); + batadv_dbg(DBG_BLA, bat_priv, + "bla_add_claim(): changing ownership for %pM, vid %d\n", + mac, vid);
claim->backbone_gw->crc ^= crc16(0, claim->addr, ETH_ALEN); @@ -590,7 +590,8 @@ static void bla_del_claim(struct bat_priv *bat_priv, const uint8_t *mac, if (!claim) return;
- bat_dbg(DBG_BLA, bat_priv, "bla_del_claim(): %pM, vid %d\n", mac, vid); + batadv_dbg(DBG_BLA, bat_priv, "bla_del_claim(): %pM, vid %d\n", mac, + vid);
batadv_hash_remove(bat_priv->claim_hash, compare_claim, choose_claim, claim); @@ -622,15 +623,15 @@ static int handle_announce(struct bat_priv *bat_priv, backbone_gw->lasttime = jiffies; crc = ntohs(*((__be16 *)(&an_addr[4])));
- bat_dbg(DBG_BLA, bat_priv, - "handle_announce(): ANNOUNCE vid %d (sent by %pM)... CRC = %04x\n", - vid, backbone_gw->orig, crc); + batadv_dbg(DBG_BLA, bat_priv, + "handle_announce(): ANNOUNCE vid %d (sent by %pM)... CRC = %04x\n", + vid, backbone_gw->orig, crc);
if (backbone_gw->crc != crc) { - bat_dbg(DBG_BLA, backbone_gw->bat_priv, - "handle_announce(): CRC FAILED for %pM/%d (my = %04x, sent = %04x)\n", - backbone_gw->orig, backbone_gw->vid, backbone_gw->crc, - crc); + batadv_dbg(DBG_BLA, backbone_gw->bat_priv, + "handle_announce(): CRC FAILED for %pM/%d (my = %04x, sent = %04x)\n", + backbone_gw->orig, backbone_gw->vid, + backbone_gw->crc, crc);
bla_send_request(backbone_gw); } else { @@ -654,18 +655,18 @@ static int handle_request(struct bat_priv *bat_priv, struct ethhdr *ethhdr, short vid) { /* check for REQUEST frame */ - if (!compare_eth(backbone_addr, ethhdr->h_dest)) + if (!batadv_compare_eth(backbone_addr, ethhdr->h_dest)) return 0;
/* sanity check, this should not happen on a normal switch, * we ignore it in this case. */ - if (!compare_eth(ethhdr->h_dest, primary_if->net_dev->dev_addr)) + if (!batadv_compare_eth(ethhdr->h_dest, primary_if->net_dev->dev_addr)) return 1;
- bat_dbg(DBG_BLA, bat_priv, - "handle_request(): REQUEST vid %d (sent by %pM)...\n", - vid, ethhdr->h_source); + batadv_dbg(DBG_BLA, bat_priv, + "handle_request(): REQUEST vid %d (sent by %pM)...\n", + vid, ethhdr->h_source);
bla_answer_request(bat_priv, primary_if, vid); return 1; @@ -680,8 +681,8 @@ static int handle_unclaim(struct bat_priv *bat_priv, struct backbone_gw *backbone_gw;
/* unclaim in any case if it is our own */ - if (primary_if && compare_eth(backbone_addr, - primary_if->net_dev->dev_addr)) + if (primary_if && batadv_compare_eth(backbone_addr, + primary_if->net_dev->dev_addr)) bla_send_claim(bat_priv, claim_addr, vid, CLAIM_TYPE_DEL);
backbone_gw = backbone_hash_find(bat_priv, backbone_addr, vid); @@ -690,9 +691,9 @@ static int handle_unclaim(struct bat_priv *bat_priv, return 1;
/* this must be an UNCLAIM frame */ - bat_dbg(DBG_BLA, bat_priv, - "handle_unclaim(): UNCLAIM %pM on vid %d (sent by %pM)...\n", - claim_addr, vid, backbone_gw->orig); + batadv_dbg(DBG_BLA, bat_priv, + "handle_unclaim(): UNCLAIM %pM on vid %d (sent by %pM)...\n", + claim_addr, vid, backbone_gw->orig);
bla_del_claim(bat_priv, claim_addr, vid); backbone_gw_free_ref(backbone_gw); @@ -715,7 +716,7 @@ static int handle_claim(struct bat_priv *bat_priv,
/* this must be a CLAIM frame */ bla_add_claim(bat_priv, claim_addr, vid, backbone_gw); - if (compare_eth(backbone_addr, primary_if->net_dev->dev_addr)) + if (batadv_compare_eth(backbone_addr, primary_if->net_dev->dev_addr)) bla_send_claim(bat_priv, claim_addr, vid, CLAIM_TYPE_ADD);
/* TODO: we could call something like tt_local_del() here. */ @@ -772,7 +773,7 @@ static int check_claim_group(struct bat_priv *bat_priv, }
/* don't accept claim frames from ourselves */ - if (compare_eth(backbone_addr, primary_if->net_dev->dev_addr)) + if (batadv_compare_eth(backbone_addr, primary_if->net_dev->dev_addr)) return 0;
/* if its already the same group, it is fine. */ @@ -790,9 +791,9 @@ static int check_claim_group(struct bat_priv *bat_priv,
/* if our mesh friends mac is bigger, use it for ourselves. */ if (ntohs(bla_dst->group) > ntohs(bla_dst_own->group)) { - bat_dbg(DBG_BLA, bat_priv, - "taking other backbones claim group: %04x\n", - ntohs(bla_dst->group)); + batadv_dbg(DBG_BLA, bat_priv, + "taking other backbones claim group: %04x\n", + ntohs(bla_dst->group)); bla_dst_own->group = bla_dst->group; }
@@ -867,9 +868,9 @@ static int bla_process_claim(struct bat_priv *bat_priv, /* check if it is a claim frame. */ ret = check_claim_group(bat_priv, primary_if, hw_src, hw_dst, ethhdr); if (ret == 1) - bat_dbg(DBG_BLA, bat_priv, - "bla_process_claim(): received a claim frame from another group. From: %pM on vid %d ...(hw_src %pM, hw_dst %pM)\n", - ethhdr->h_source, vid, hw_src, hw_dst); + batadv_dbg(DBG_BLA, bat_priv, + "bla_process_claim(): received a claim frame from another group. From: %pM on vid %d ...(hw_src %pM, hw_dst %pM)\n", + ethhdr->h_source, vid, hw_src, hw_dst);
if (ret < 2) return ret; @@ -900,9 +901,9 @@ static int bla_process_claim(struct bat_priv *bat_priv, break; }
- bat_dbg(DBG_BLA, bat_priv, - "bla_process_claim(): ERROR - this looks like a claim frame, but is useless. eth src %pM on vid %d ...(hw_src %pM, hw_dst %pM)\n", - ethhdr->h_source, vid, hw_src, hw_dst); + batadv_dbg(DBG_BLA, bat_priv, + "bla_process_claim(): ERROR - this looks like a claim frame, but is useless. eth src %pM on vid %d ...(hw_src %pM, hw_dst %pM)\n", + ethhdr->h_source, vid, hw_src, hw_dst); return 1; }
@@ -931,13 +932,13 @@ static void bla_purge_backbone_gw(struct bat_priv *bat_priv, int now) head, hash_entry) { if (now) goto purge_now; - if (!has_timed_out(backbone_gw->lasttime, - BLA_BACKBONE_TIMEOUT)) + if (!batadv_has_timed_out(backbone_gw->lasttime, + BLA_BACKBONE_TIMEOUT)) continue;
- bat_dbg(DBG_BLA, backbone_gw->bat_priv, - "bla_purge_backbone_gw(): backbone gw %pM timed out\n", - backbone_gw->orig); + batadv_dbg(DBG_BLA, backbone_gw->bat_priv, + "bla_purge_backbone_gw(): backbone gw %pM timed out\n", + backbone_gw->orig);
purge_now: /* don't wait for the pending request anymore */ @@ -980,16 +981,16 @@ static void bla_purge_claims(struct bat_priv *bat_priv, hlist_for_each_entry_rcu(claim, node, head, hash_entry) { if (now) goto purge_now; - if (!compare_eth(claim->backbone_gw->orig, - primary_if->net_dev->dev_addr)) + if (!batadv_compare_eth(claim->backbone_gw->orig, + primary_if->net_dev->dev_addr)) continue; - if (!has_timed_out(claim->lasttime, - BLA_CLAIM_TIMEOUT)) + if (!batadv_has_timed_out(claim->lasttime, + BLA_CLAIM_TIMEOUT)) continue;
- bat_dbg(DBG_BLA, bat_priv, - "bla_purge_claims(): %pM, vid %d, time out\n", - claim->addr, claim->vid); + batadv_dbg(DBG_BLA, bat_priv, + "bla_purge_claims(): %pM, vid %d, time out\n", + claim->addr, claim->vid);
purge_now: handle_unclaim(bat_priv, primary_if, @@ -1036,8 +1037,8 @@ void batadv_bla_update_orig_address(struct bat_priv *bat_priv, rcu_read_lock(); hlist_for_each_entry_rcu(backbone_gw, node, head, hash_entry) { /* own orig still holds the old value. */ - if (!compare_eth(backbone_gw->orig, - oldif->net_dev->dev_addr)) + if (!batadv_compare_eth(backbone_gw->orig, + oldif->net_dev->dev_addr)) continue;
memcpy(backbone_gw->orig, @@ -1097,8 +1098,8 @@ static void bla_periodic_work(struct work_struct *work)
rcu_read_lock(); hlist_for_each_entry_rcu(backbone_gw, node, head, hash_entry) { - if (!compare_eth(backbone_gw->orig, - primary_if->net_dev->dev_addr)) + if (!batadv_compare_eth(backbone_gw->orig, + primary_if->net_dev->dev_addr)) continue;
backbone_gw->lasttime = jiffies; @@ -1129,7 +1130,7 @@ int batadv_bla_init(struct bat_priv *bat_priv) uint8_t claim_dest[ETH_ALEN] = {0xff, 0x43, 0x05, 0x00, 0x00, 0x00}; struct hard_iface *primary_if;
- bat_dbg(DBG_BLA, bat_priv, "bla hash registering\n"); + batadv_dbg(DBG_BLA, bat_priv, "bla hash registering\n");
/* setting claim destination address */ memcpy(&bat_priv->claim_dest.magic, claim_dest, 3); @@ -1164,7 +1165,7 @@ int batadv_bla_init(struct bat_priv *bat_priv) batadv_hash_set_lock_class(bat_priv->backbone_hash, &backbone_hash_lock_class_key);
- bat_dbg(DBG_BLA, bat_priv, "bla hashes initialized\n"); + batadv_dbg(DBG_BLA, bat_priv, "bla hashes initialized\n");
bla_start_timer(bat_priv); return 0; @@ -1206,13 +1207,13 @@ int batadv_bla_check_bcast_duplist(struct bat_priv *bat_priv, /* we can stop searching if the entry is too old ; * later entries will be even older */ - if (has_timed_out(entry->entrytime, DUPLIST_TIMEOUT)) + if (batadv_has_timed_out(entry->entrytime, DUPLIST_TIMEOUT)) break;
if (entry->crc != crc) continue;
- if (compare_eth(entry->orig, bcast_packet->orig)) + if (batadv_compare_eth(entry->orig, bcast_packet->orig)) continue;
/* this entry seems to match: same crc, not too old, @@ -1260,7 +1261,7 @@ int batadv_bla_is_backbone_gw_orig(struct bat_priv *bat_priv, uint8_t *orig)
rcu_read_lock(); hlist_for_each_entry_rcu(backbone_gw, node, head, hash_entry) { - if (compare_eth(backbone_gw->orig, orig)) { + if (batadv_compare_eth(backbone_gw->orig, orig)) { rcu_read_unlock(); return 1; } @@ -1387,8 +1388,8 @@ int batadv_bla_rx(struct bat_priv *bat_priv, struct sk_buff *skb, short vid) }
/* if it is our own claim ... */ - if (compare_eth(claim->backbone_gw->orig, - primary_if->net_dev->dev_addr)) { + if (batadv_compare_eth(claim->backbone_gw->orig, + primary_if->net_dev->dev_addr)) { /* ... allow it in any case */ claim->lasttime = jiffies; goto allow; @@ -1474,8 +1475,8 @@ int batadv_bla_tx(struct bat_priv *bat_priv, struct sk_buff *skb, short vid) goto allow;
/* check if we are responsible. */ - if (compare_eth(claim->backbone_gw->orig, - primary_if->net_dev->dev_addr)) { + if (batadv_compare_eth(claim->backbone_gw->orig, + primary_if->net_dev->dev_addr)) { /* if yes, the client has roamed and we have * to unclaim it. */ @@ -1523,6 +1524,7 @@ int batadv_bla_claim_table_seq_print_text(struct seq_file *seq, void *offset) uint32_t i; bool is_own; int ret = 0; + uint8_t *primary_addr;
primary_if = batadv_primary_if_get_selected(bat_priv); if (!primary_if) { @@ -1539,9 +1541,10 @@ int batadv_bla_claim_table_seq_print_text(struct seq_file *seq, void *offset) goto out; }
+ primary_addr = primary_if->net_dev->dev_addr; seq_printf(seq, "Claims announced for the mesh %s (orig %pM, group id %04x)\n", - net_dev->name, primary_if->net_dev->dev_addr, + net_dev->name, primary_addr, ntohs(bat_priv->claim_dest.group)); seq_printf(seq, " %-17s %-5s %-17s [o] (%-4s)\n", "Client", "VID", "Originator", "CRC"); @@ -1550,8 +1553,8 @@ int batadv_bla_claim_table_seq_print_text(struct seq_file *seq, void *offset)
rcu_read_lock(); hlist_for_each_entry_rcu(claim, node, head, hash_entry) { - is_own = compare_eth(claim->backbone_gw->orig, - primary_if->net_dev->dev_addr); + is_own = batadv_compare_eth(claim->backbone_gw->orig, + primary_addr); seq_printf(seq, " * %pM on % 5d by %pM [%c] (%04x)\n", claim->addr, claim->vid, claim->backbone_gw->orig, diff --git a/distributed-arp-table.c b/distributed-arp-table.c index 68dbde1..3a0c7a7 100644 --- a/distributed-arp-table.c +++ b/distributed-arp-table.c @@ -62,11 +62,12 @@ static void bat_dbg_arp(struct bat_priv *bat_priv, struct sk_buff *skb, struct unicast_4addr_packet *unicast_4addr_packet;
if (msg) - bat_dbg(DBG_DAT, bat_priv, "%s\n", msg); + batadv_dbg(DBG_DAT, bat_priv, "%s\n", msg);
- bat_dbg(DBG_DAT, bat_priv, "ARP MSG = [src: %pM-%pI4 dst: %pM-%pI4]\n", - ARP_HW_SRC(skb, hdr_size), &ARP_IP_SRC(skb, hdr_size), - ARP_HW_DST(skb, hdr_size), &ARP_IP_DST(skb, hdr_size)); + batadv_dbg(DBG_DAT, bat_priv, + "ARP MSG = [src: %pM-%pI4 dst: %pM-%pI4]\n", + ARP_HW_SRC(skb, hdr_size), &ARP_IP_SRC(skb, hdr_size), + ARP_HW_DST(skb, hdr_size), &ARP_IP_DST(skb, hdr_size));
if (hdr_size == 0) return; @@ -78,39 +79,40 @@ static void bat_dbg_arp(struct bat_priv *bat_priv, struct sk_buff *skb,
switch (unicast_4addr_packet->u.header.packet_type) { case BAT_UNICAST: - bat_dbg(DBG_DAT, bat_priv, - "* encapsulated within a UNICAST packet\n"); + batadv_dbg(DBG_DAT, bat_priv, + "* encapsulated within a UNICAST packet\n"); break; case BAT_UNICAST_4ADDR: - bat_dbg(DBG_DAT, bat_priv, - "* encapsulated within a UNICAST_4ADDR packet (src: %pM)\n", - unicast_4addr_packet->src); + batadv_dbg(DBG_DAT, bat_priv, + "* encapsulated within a UNICAST_4ADDR packet (src: %pM)\n", + unicast_4addr_packet->src); switch (unicast_4addr_packet->subtype) { case BAT_P_DAT_DHT_PUT: - bat_dbg(DBG_DAT, bat_priv, "* type: DAT_DHT_PUT\n"); + batadv_dbg(DBG_DAT, bat_priv, "* type: DAT_DHT_PUT\n"); break; case BAT_P_DAT_DHT_GET: - bat_dbg(DBG_DAT, bat_priv, "* type: DAT_DHT_GET\n"); + batadv_dbg(DBG_DAT, bat_priv, "* type: DAT_DHT_GET\n"); break; case BAT_P_DAT_CACHE_REPLY: - bat_dbg(DBG_DAT, bat_priv, "* type: DAT_CACHE_REPLY\n"); + batadv_dbg(DBG_DAT, bat_priv, + "* type: DAT_CACHE_REPLY\n"); break; case BAT_P_DATA: - bat_dbg(DBG_DAT, bat_priv, "* type: DATA\n"); + batadv_dbg(DBG_DAT, bat_priv, "* type: DATA\n"); break; default: - bat_dbg(DBG_DAT, bat_priv, "* type: Unknown!\n"); + batadv_dbg(DBG_DAT, bat_priv, "* type: Unknown!\n"); } break; case BAT_BCAST: - bat_dbg(DBG_DAT, bat_priv, - "* encapsulated within a BCAST packet (src: %pM)\n", - ((struct bcast_packet *)unicast_4addr_packet)->orig); + batadv_dbg(DBG_DAT, bat_priv, + "* encapsulated within a BCAST packet (src: %pM)\n", + ((struct bcast_packet *)unicast_4addr_packet)->orig); break; default: - bat_dbg(DBG_DAT, bat_priv, - "* encapsulated within an unknown packet type (0x%x)\n", - unicast_4addr_packet->u.header.packet_type); + batadv_dbg(DBG_DAT, bat_priv, + "* encapsulated within an unknown packet type (0x%x)\n", + unicast_4addr_packet->u.header.packet_type); } }
@@ -151,7 +153,7 @@ static bool is_orig_node_eligible(struct dht_candidate *res, int select, * the one with the lowest address */ if ((tmp_max == max) && - (compare_eth(candidate->orig, max_orig_node->orig) > 0)) + (batadv_compare_eth(candidate->orig, max_orig_node->orig) > 0)) goto out;
ret = true; @@ -207,10 +209,10 @@ static void choose_next_candidate(struct bat_priv *bat_priv, if (max_orig_node) { cands[select].type = DHT_CANDIDATE_ORIG; cands[select].orig_node = max_orig_node; - bat_dbg(DBG_DAT, bat_priv, - "dht_select_candidates() %d: selected %pM addr=%u dist=%u\n", - select, max_orig_node->orig, max_orig_node->dht_addr, - max); + batadv_dbg(DBG_DAT, bat_priv, + "dht_select_candidates() %d: selected %pM addr=%u dist=%u\n", + select, max_orig_node->orig, max_orig_node->dht_addr, + max); } *last_max = max; } @@ -238,9 +240,9 @@ static struct dht_candidate *dht_select_candidates(struct bat_priv *bat_priv,
ip_key = (dat_addr_t)batadv_hash_ipv4(&ip_dst, DAT_ADDR_MAX);
- bat_dbg(DBG_DAT, bat_priv, - "dht_select_candidates(): IP=%pI4 hash(IP)=%u\n", &ip_dst, - ip_key); + batadv_dbg(DBG_DAT, bat_priv, + "dht_select_candidates(): IP=%pI4 hash(IP)=%u\n", &ip_dst, + ip_key);
for (select = 0; select < DHT_CANDIDATES_NUM; select++) choose_next_candidate(bat_priv, res, select, ip_key, &last_max); @@ -268,7 +270,7 @@ static bool dht_send_data(struct bat_priv *bat_priv, struct sk_buff *skb, if (!cand) goto out;
- bat_dbg(DBG_DAT, bat_priv, "DHT_SEND for %pI4\n", &ip); + batadv_dbg(DBG_DAT, bat_priv, "DHT_SEND for %pI4\n", &ip);
for (i = 0; i < DHT_CANDIDATES_NUM; i++) { if (cand[i].type == DHT_CANDIDATE_NOT_FOUND) @@ -320,7 +322,8 @@ static void arp_neigh_update(struct bat_priv *bat_priv, __be32 ip, uint8_t *hw) if (!n) goto out;
- bat_dbg(DBG_DAT, bat_priv, "Updating neighbour: %pI4 - %pM\n", &ip, hw); + batadv_dbg(DBG_DAT, bat_priv, "Updating neighbour: %pI4 - %pM\n", &ip, + hw);
neigh_update(n, hw, NUD_REACHABLE, NEIGH_UPDATE_F_OVERRIDE); out: @@ -437,7 +440,7 @@ bool batadv_dat_snoop_outgoing_arp_request(struct bat_priv *bat_priv, primary_if->soft_iface->last_rx = jiffies;
netif_rx(skb_new); - bat_dbg(DBG_DAT, bat_priv, "ARP request replied locally\n"); + batadv_dbg(DBG_DAT, bat_priv, "ARP request replied locally\n"); } else { /* Send the request on the DHT */ inc_counter(bat_priv, BAT_CNT_DAT_REQUEST_TX); @@ -604,16 +607,16 @@ bool batadv_dat_drop_broadcast_packet(struct bat_priv *bat_priv, forw_packet->if_incoming->soft_iface); /* check if we already know this neigh */ if (n && (n->nud_state & NUD_CONNECTED)) { - bat_dbg(DBG_DAT, bat_priv, - "ARP Request for %pI4: fallback prevented\n", - &ARP_IP_DST(forw_packet->skb, - sizeof(struct bcast_packet))); + batadv_dbg(DBG_DAT, bat_priv, + "ARP Request for %pI4: fallback prevented\n", + &ARP_IP_DST(forw_packet->skb, + sizeof(struct bcast_packet))); return true; }
- bat_dbg(DBG_DAT, bat_priv, "ARP Request for %pI4: fallback\n", - &ARP_IP_DST(forw_packet->skb, - sizeof(struct bcast_packet))); + batadv_dbg(DBG_DAT, bat_priv, "ARP Request for %pI4: fallback\n", + &ARP_IP_DST(forw_packet->skb, + sizeof(struct bcast_packet))); } return false; } diff --git a/gateway_client.c b/gateway_client.c index c917a2e..a0b2ded 100644 --- a/gateway_client.c +++ b/gateway_client.c @@ -217,20 +217,20 @@ void batadv_gw_election(struct bat_priv *bat_priv) }
if ((curr_gw) && (!next_gw)) { - bat_dbg(DBG_BATMAN, bat_priv, - "Removing selected gateway - no gateway in range\n"); + batadv_dbg(DBG_BATMAN, bat_priv, + "Removing selected gateway - no gateway in range\n"); batadv_throw_uevent(bat_priv, UEV_GW, UEV_DEL, NULL); } else if ((!curr_gw) && (next_gw)) { - bat_dbg(DBG_BATMAN, bat_priv, - "Adding route to gateway %pM (gw_flags: %i, tq: %i)\n", - next_gw->orig_node->orig, next_gw->orig_node->gw_flags, - router->tq_avg); + batadv_dbg(DBG_BATMAN, bat_priv, + "Adding route to gateway %pM (gw_flags: %i, tq: %i)\n", + next_gw->orig_node->orig, + next_gw->orig_node->gw_flags, router->tq_avg); batadv_throw_uevent(bat_priv, UEV_GW, UEV_ADD, gw_addr); } else { - bat_dbg(DBG_BATMAN, bat_priv, - "Changing route to gateway %pM (gw_flags: %i, tq: %i)\n", - next_gw->orig_node->orig, next_gw->orig_node->gw_flags, - router->tq_avg); + batadv_dbg(DBG_BATMAN, bat_priv, + "Changing route to gateway %pM (gw_flags: %i, tq: %i)\n", + next_gw->orig_node->orig, + next_gw->orig_node->gw_flags, router->tq_avg); batadv_throw_uevent(bat_priv, UEV_GW, UEV_CHANGE, gw_addr); }
@@ -282,9 +282,9 @@ void batadv_gw_check_election(struct bat_priv *bat_priv, (orig_tq_avg - gw_tq_avg < atomic_read(&bat_priv->gw_sel_class))) goto out;
- bat_dbg(DBG_BATMAN, bat_priv, - "Restarting gateway selection: better gateway found (tq curr: %i, tq new: %i)\n", - gw_tq_avg, orig_tq_avg); + batadv_dbg(DBG_BATMAN, bat_priv, + "Restarting gateway selection: better gateway found (tq curr: %i, tq new: %i)\n", + gw_tq_avg, orig_tq_avg);
deselect: batadv_gw_deselect(bat_priv); @@ -318,13 +318,13 @@ static void gw_node_add(struct bat_priv *bat_priv, spin_unlock_bh(&bat_priv->gw_list_lock);
batadv_gw_bandwidth_to_kbit(new_gwflags, &down, &up); - bat_dbg(DBG_BATMAN, bat_priv, - "Found new gateway %pM -> gw_class: %i - %i%s/%i%s\n", - orig_node->orig, new_gwflags, - (down > 2048 ? down / 1024 : down), - (down > 2048 ? "MBit" : "KBit"), - (up > 2048 ? up / 1024 : up), - (up > 2048 ? "MBit" : "KBit")); + batadv_dbg(DBG_BATMAN, bat_priv, + "Found new gateway %pM -> gw_class: %i - %i%s/%i%s\n", + orig_node->orig, new_gwflags, + (down > 2048 ? down / 1024 : down), + (down > 2048 ? "MBit" : "KBit"), + (up > 2048 ? up / 1024 : up), + (up > 2048 ? "MBit" : "KBit")); }
void batadv_gw_node_update(struct bat_priv *bat_priv, @@ -345,18 +345,18 @@ void batadv_gw_node_update(struct bat_priv *bat_priv, if (gw_node->orig_node != orig_node) continue;
- bat_dbg(DBG_BATMAN, bat_priv, - "Gateway class of originator %pM changed from %i to %i\n", - orig_node->orig, gw_node->orig_node->gw_flags, - new_gwflags); + batadv_dbg(DBG_BATMAN, bat_priv, + "Gateway class of originator %pM changed from %i to %i\n", + orig_node->orig, gw_node->orig_node->gw_flags, + new_gwflags);
gw_node->deleted = 0;
if (new_gwflags == NO_FLAGS) { gw_node->deleted = jiffies; - bat_dbg(DBG_BATMAN, bat_priv, - "Gateway %pM removed from gateway list\n", - orig_node->orig); + batadv_dbg(DBG_BATMAN, bat_priv, + "Gateway %pM removed from gateway list\n", + orig_node->orig);
if (gw_node == curr_gw) goto deselect; diff --git a/hard-interface.c b/hard-interface.c index 58ff796..0337fed 100644 --- a/hard-interface.c +++ b/hard-interface.c @@ -166,8 +166,8 @@ static void check_known_mac_addr(const struct net_device *net_dev) if (hard_iface->net_dev == net_dev) continue;
- if (!compare_eth(hard_iface->net_dev->dev_addr, - net_dev->dev_addr)) + if (!batadv_compare_eth(hard_iface->net_dev->dev_addr, + net_dev->dev_addr)) continue;
pr_warn("The newly added mac address (%pM) already exists on: %s\n", diff --git a/icmp_socket.c b/icmp_socket.c index 76a8324..ae26a96 100644 --- a/icmp_socket.c +++ b/icmp_socket.c @@ -158,8 +158,8 @@ static ssize_t bat_socket_write(struct file *file, const char __user *buff, size_t packet_len = sizeof(struct icmp_packet);
if (len < sizeof(struct icmp_packet)) { - bat_dbg(DBG_BATMAN, bat_priv, - "Error - can't send packet from char device: invalid packet size\n"); + batadv_dbg(DBG_BATMAN, bat_priv, + "Error - can't send packet from char device: invalid packet size\n"); return -EINVAL; }
@@ -188,15 +188,15 @@ static ssize_t bat_socket_write(struct file *file, const char __user *buff, }
if (icmp_packet->header.packet_type != BAT_ICMP) { - bat_dbg(DBG_BATMAN, bat_priv, - "Error - can't send packet from char device: got bogus packet type (expected: BAT_ICMP)\n"); + batadv_dbg(DBG_BATMAN, bat_priv, + "Error - can't send packet from char device: got bogus packet type (expected: BAT_ICMP)\n"); len = -EINVAL; goto free_skb; }
if (icmp_packet->msg_type != ECHO_REQUEST) { - bat_dbg(DBG_BATMAN, bat_priv, - "Error - can't send packet from char device: got bogus message type (expected: ECHO_REQUEST)\n"); + batadv_dbg(DBG_BATMAN, bat_priv, + "Error - can't send packet from char device: got bogus message type (expected: ECHO_REQUEST)\n"); len = -EINVAL; goto free_skb; } diff --git a/main.c b/main.c index e386615..5df1032 100644 --- a/main.c +++ b/main.c @@ -180,7 +180,7 @@ int batadv_is_my_mac(const uint8_t *addr) if (hard_iface->if_status != IF_ACTIVE) continue;
- if (compare_eth(hard_iface->net_dev->dev_addr, addr)) { + if (batadv_compare_eth(hard_iface->net_dev->dev_addr, addr)) { rcu_read_unlock(); return 1; } @@ -238,9 +238,9 @@ int batadv_batman_skb_recv(struct sk_buff *skb, struct net_device *dev, batman_ogm_packet = (struct batman_ogm_packet *)skb->data;
if (batman_ogm_packet->header.version != COMPAT_VERSION) { - bat_dbg(DBG_BATMAN, bat_priv, - "Drop packet: incompatible batman version (%i)\n", - batman_ogm_packet->header.version); + batadv_dbg(DBG_BATMAN, bat_priv, + "Drop packet: incompatible batman version (%i)\n", + batman_ogm_packet->header.version); goto err_free; }
diff --git a/main.h b/main.h index 161961d..245323b 100644 --- a/main.h +++ b/main.h @@ -190,7 +190,7 @@ int batadv_algo_seq_print_text(struct seq_file *seq, void *offset); int batadv_debug_log(struct bat_priv *bat_priv, const char *fmt, ...) __printf(2, 3);
-#define bat_dbg(type, bat_priv, fmt, arg...) \ +#define batadv_dbg(type, bat_priv, fmt, arg...) \ do { \ if (atomic_read(&bat_priv->log_level) & type) \ batadv_debug_log(bat_priv, fmt, ## arg);\ @@ -198,9 +198,9 @@ __printf(2, 3); while (0) #else /* !CONFIG_BATMAN_ADV_DEBUG */ __printf(3, 4) -static inline void bat_dbg(int type __always_unused, - struct bat_priv *bat_priv __always_unused, - const char *fmt __always_unused, ...) +static inline void batadv_dbg(int type __always_unused, + struct bat_priv *bat_priv __always_unused, + const char *fmt __always_unused, ...) { } #endif @@ -209,14 +209,14 @@ static inline void bat_dbg(int type __always_unused, do { \ struct net_device *_netdev = (net_dev); \ struct bat_priv *_batpriv = netdev_priv(_netdev); \ - bat_dbg(DBG_ALL, _batpriv, fmt, ## arg); \ + batadv_dbg(DBG_ALL, _batpriv, fmt, ## arg); \ pr_info("%s: " fmt, _netdev->name, ## arg); \ } while (0) #define bat_err(net_dev, fmt, arg...) \ do { \ struct net_device *_netdev = (net_dev); \ struct bat_priv *_batpriv = netdev_priv(_netdev); \ - bat_dbg(DBG_ALL, _batpriv, fmt, ## arg); \ + batadv_dbg(DBG_ALL, _batpriv, fmt, ## arg); \ pr_err("%s: " fmt, _netdev->name, ## arg); \ } while (0)
@@ -224,7 +224,7 @@ static inline void bat_dbg(int type __always_unused, * * note: can't use compare_ether_addr() as it requires aligned memory */ -static inline int compare_eth(const void *data1, const void *data2) +static inline int batadv_compare_eth(const void *data1, const void *data2) { return (memcmp(data1, data2, ETH_ALEN) == 0 ? 1 : 0); } @@ -235,7 +235,8 @@ static inline int compare_eth(const void *data1, const void *data2) * * Returns true if current time is after timestamp + timeout */ -static inline bool has_timed_out(unsigned long timestamp, unsigned int timeout) +static inline bool batadv_has_timed_out(unsigned long timestamp, + unsigned int timeout) { return time_is_before_jiffies(timestamp + msecs_to_jiffies(timeout)); } @@ -263,18 +264,18 @@ static inline bool has_timed_out(unsigned long timestamp, unsigned int timeout) #define seq_after(x, y) seq_before(y, x)
/* Stop preemption on local cpu while incrementing the counter */ -static inline void add_counter(struct bat_priv *bat_priv, size_t idx, - size_t count) +static inline void batadv_add_counter(struct bat_priv *bat_priv, size_t idx, + size_t count) { int cpu = get_cpu(); per_cpu_ptr(bat_priv->bat_counters, cpu)[idx] += count; put_cpu(); }
-#define inc_counter(b, i) add_counter(b, i, 1) +#define inc_counter(b, i) batadv_add_counter(b, i, 1)
/* Sum and return the cpu-local counters for index 'idx' */ -static inline uint64_t sum_counter(struct bat_priv *bat_priv, size_t idx) +static inline uint64_t batadv_sum_counter(struct bat_priv *bat_priv, size_t idx) { uint64_t *counters; int cpu; diff --git a/originator.c b/originator.c index 26fa8b6..8f908be 100644 --- a/originator.c +++ b/originator.c @@ -103,9 +103,9 @@ struct neigh_node *batadv_neigh_node_new(struct hard_iface *hard_iface, /* extra reference for return */ atomic_set(&neigh_node->refcount, 2);
- bat_dbg(DBG_BATMAN, bat_priv, - "Creating new neighbor %pM, initial seqno %d\n", - neigh_addr, seqno); + batadv_dbg(DBG_BATMAN, bat_priv, + "Creating new neighbor %pM, initial seqno %d\n", + neigh_addr, seqno);
out: return neigh_node; @@ -200,8 +200,8 @@ struct orig_node *batadv_get_orig_node(struct bat_priv *bat_priv, if (orig_node) return orig_node;
- bat_dbg(DBG_BATMAN, bat_priv, - "Creating new originator: %pM\n", addr); + batadv_dbg(DBG_BATMAN, bat_priv, "Creating new originator: %pM\n", + addr);
orig_node = kzalloc(sizeof(*orig_node), GFP_ATOMIC); if (!orig_node) @@ -274,6 +274,7 @@ static bool purge_orig_neighbors(struct bat_priv *bat_priv, struct neigh_node *neigh_node; bool neigh_purged = false; unsigned long last_seen; + struct hard_iface *if_incoming;
*best_neigh_node = NULL;
@@ -283,28 +284,26 @@ static bool purge_orig_neighbors(struct bat_priv *bat_priv, hlist_for_each_entry_safe(neigh_node, node, node_tmp, &orig_node->neigh_list, list) {
- if ((has_timed_out(neigh_node->last_seen, PURGE_TIMEOUT)) || - (neigh_node->if_incoming->if_status == IF_INACTIVE) || - (neigh_node->if_incoming->if_status == IF_NOT_IN_USE) || - (neigh_node->if_incoming->if_status == IF_TO_BE_REMOVED)) { + last_seen = neigh_node->last_seen; + if_incoming = neigh_node->if_incoming;
- last_seen = neigh_node->last_seen; + if ((batadv_has_timed_out(last_seen, PURGE_TIMEOUT)) || + (if_incoming->if_status == IF_INACTIVE) || + (if_incoming->if_status == IF_NOT_IN_USE) || + (if_incoming->if_status == IF_TO_BE_REMOVED)) {
- if ((neigh_node->if_incoming->if_status == - IF_INACTIVE) || - (neigh_node->if_incoming->if_status == - IF_NOT_IN_USE) || - (neigh_node->if_incoming->if_status == - IF_TO_BE_REMOVED)) - bat_dbg(DBG_BATMAN, bat_priv, - "neighbor purge: originator %pM, neighbor: %pM, iface: %s\n", - orig_node->orig, neigh_node->addr, - neigh_node->if_incoming->net_dev->name); + if ((if_incoming->if_status == IF_INACTIVE) || + (if_incoming->if_status == IF_NOT_IN_USE) || + (if_incoming->if_status == IF_TO_BE_REMOVED)) + batadv_dbg(DBG_BATMAN, bat_priv, + "neighbor purge: originator %pM, neighbor: %pM, iface: %s\n", + orig_node->orig, neigh_node->addr, + if_incoming->net_dev->name); else - bat_dbg(DBG_BATMAN, bat_priv, - "neighbor timeout: originator %pM, neighbor: %pM, last_seen: %u\n", - orig_node->orig, neigh_node->addr, - jiffies_to_msecs(last_seen)); + batadv_dbg(DBG_BATMAN, bat_priv, + "neighbor timeout: originator %pM, neighbor: %pM, last_seen: %u\n", + orig_node->orig, neigh_node->addr, + jiffies_to_msecs(last_seen));
neigh_purged = true;
@@ -327,11 +326,11 @@ static bool purge_orig_node(struct bat_priv *bat_priv, { struct neigh_node *best_neigh_node;
- if (has_timed_out(orig_node->last_seen, 2 * PURGE_TIMEOUT)) { - bat_dbg(DBG_BATMAN, bat_priv, - "Originator timeout: originator %pM, last_seen %u\n", - orig_node->orig, - jiffies_to_msecs(orig_node->last_seen)); + if (batadv_has_timed_out(orig_node->last_seen, 2 * PURGE_TIMEOUT)) { + batadv_dbg(DBG_BATMAN, bat_priv, + "Originator timeout: originator %pM, last_seen %u\n", + orig_node->orig, + jiffies_to_msecs(orig_node->last_seen)); return true; } else { if (purge_orig_neighbors(bat_priv, orig_node, @@ -372,8 +371,8 @@ static void _purge_orig(struct bat_priv *bat_priv) continue; }
- if (has_timed_out(orig_node->last_frag_packet, - FRAG_TIMEOUT)) + if (batadv_has_timed_out(orig_node->last_frag_packet, + FRAG_TIMEOUT)) batadv_frag_list_free(&orig_node->frag_list); } spin_unlock_bh(list_lock); diff --git a/originator.h b/originator.h index c4f63b4..35f67eb 100644 --- a/originator.h +++ b/originator.h @@ -77,7 +77,7 @@ static inline struct orig_node *batadv_orig_hash_find(struct bat_priv *bat_priv,
rcu_read_lock(); hlist_for_each_entry_rcu(orig_node, node, head, hash_entry) { - if (!compare_eth(orig_node, data)) + if (!batadv_compare_eth(orig_node, data)) continue;
if (!atomic_inc_not_zero(&orig_node->refcount)) diff --git a/routing.c b/routing.c index b1a1732..977e44c 100644 --- a/routing.c +++ b/routing.c @@ -71,23 +71,23 @@ static void _update_route(struct bat_priv *bat_priv,
/* route deleted */ if ((curr_router) && (!neigh_node)) { - bat_dbg(DBG_ROUTES, bat_priv, "Deleting route towards: %pM\n", - orig_node->orig); + batadv_dbg(DBG_ROUTES, bat_priv, "Deleting route towards: %pM\n", + orig_node->orig); batadv_tt_global_del_orig(bat_priv, orig_node, "Deleted route towards originator");
/* route added */ } else if ((!curr_router) && (neigh_node)) {
- bat_dbg(DBG_ROUTES, bat_priv, - "Adding route towards: %pM (via %pM)\n", - orig_node->orig, neigh_node->addr); + batadv_dbg(DBG_ROUTES, bat_priv, + "Adding route towards: %pM (via %pM)\n", + orig_node->orig, neigh_node->addr); /* route changed */ } else if (neigh_node && curr_router) { - bat_dbg(DBG_ROUTES, bat_priv, - "Changing route towards: %pM (now via %pM - was via %pM)\n", - orig_node->orig, neigh_node->addr, - curr_router->addr); + batadv_dbg(DBG_ROUTES, bat_priv, + "Changing route towards: %pM (now via %pM - was via %pM)\n", + orig_node->orig, neigh_node->addr, + curr_router->addr); }
if (curr_router) @@ -151,8 +151,8 @@ void batadv_bonding_candidate_add(struct orig_node *orig_node, spin_lock_bh(&orig_node->neigh_list_lock);
/* only consider if it has the same primary address ... */ - if (!compare_eth(orig_node->orig, - neigh_node->orig_node->primary_addr)) + if (!batadv_compare_eth(orig_node->orig, + neigh_node->orig_node->primary_addr)) goto candidate_del;
router = batadv_orig_node_get_router(orig_node); @@ -180,7 +180,8 @@ void batadv_bonding_candidate_add(struct orig_node *orig_node, continue;
if ((neigh_node->if_incoming == tmp_neigh_node->if_incoming) || - (compare_eth(neigh_node->addr, tmp_neigh_node->addr))) { + (batadv_compare_eth(neigh_node->addr, + tmp_neigh_node->addr))) { interference_candidate = 1; break; } @@ -233,12 +234,12 @@ int batadv_window_protected(struct bat_priv *bat_priv, int32_t seq_num_diff, { if ((seq_num_diff <= -TQ_LOCAL_WINDOW_SIZE) || (seq_num_diff >= EXPECTED_SEQNO_RANGE)) { - if (!has_timed_out(*last_reset, RESET_PROTECTION_MS)) + if (!batadv_has_timed_out(*last_reset, RESET_PROTECTION_MS)) return 1;
*last_reset = jiffies; - bat_dbg(DBG_BATMAN, bat_priv, - "old packet received, start protection\n"); + batadv_dbg(DBG_BATMAN, bat_priv, + "old packet received, start protection\n"); }
return 0; @@ -578,6 +579,7 @@ int batadv_recv_tt_query(struct sk_buff *skb, struct hard_iface *recv_if) struct tt_query_packet *tt_query; uint16_t tt_size; struct ethhdr *ethhdr; + char tt_flag;
/* drop packet if it has not necessary minimum size */ if (unlikely(!pskb_may_pull(skb, sizeof(struct tt_query_packet)))) @@ -607,10 +609,11 @@ int batadv_recv_tt_query(struct sk_buff *skb, struct hard_iface *recv_if) * forwarded */ if (!batadv_send_tt_response(bat_priv, tt_query)) { - bat_dbg(DBG_TT, bat_priv, - "Routing TT_REQUEST to %pM [%c]\n", - tt_query->dst, - (tt_query->flags & TT_FULL_TABLE ? 'F' : '.')); + tt_flag = tt_query->flags & TT_FULL_TABLE ? 'F' : '.'; + batadv_dbg(DBG_TT, bat_priv, + "Routing TT_REQUEST to %pM [%c]\n", + tt_query->dst, + tt_flag); return route_unicast_packet(skb, recv_if); } break; @@ -633,10 +636,11 @@ int batadv_recv_tt_query(struct sk_buff *skb, struct hard_iface *recv_if)
batadv_handle_tt_response(bat_priv, tt_query); } else { - bat_dbg(DBG_TT, bat_priv, - "Routing TT_RESPONSE to %pM [%c]\n", - tt_query->dst, - (tt_query->flags & TT_FULL_TABLE ? 'F' : '.')); + tt_flag = tt_query->flags & TT_FULL_TABLE ? 'F' : '.'; + batadv_dbg(DBG_TT, bat_priv, + "Routing TT_RESPONSE to %pM [%c]\n", + tt_query->dst, + tt_flag); return route_unicast_packet(skb, recv_if); } break; @@ -686,9 +690,9 @@ int batadv_recv_roam_adv(struct sk_buff *skb, struct hard_iface *recv_if) if (!orig_node) goto out;
- bat_dbg(DBG_TT, bat_priv, - "Received ROAMING_ADV from %pM (client %pM)\n", - roam_adv_packet->src, roam_adv_packet->client); + batadv_dbg(DBG_TT, bat_priv, + "Received ROAMING_ADV from %pM (client %pM)\n", + roam_adv_packet->src, roam_adv_packet->client);
batadv_tt_global_add(bat_priv, orig_node, roam_adv_packet->client, atomic_read(&orig_node->last_ttvn) + 1, true, @@ -747,13 +751,13 @@ struct neigh_node *batadv_find_router(struct bat_priv *bat_priv, /* if we have something in the primary_addr, we can search * for a potential bonding candidate. */ - if (compare_eth(primary_addr, zero_mac)) + if (batadv_compare_eth(primary_addr, zero_mac)) goto return_router;
/* find the orig_node which has the primary interface. might * even be the same as our router_orig in many cases */ - if (compare_eth(primary_addr, router_orig->orig)) { + if (batadv_compare_eth(primary_addr, router_orig->orig)) { primary_orig_node = router_orig; } else { primary_orig_node = batadv_orig_hash_find(bat_priv, @@ -890,7 +894,8 @@ static int route_unicast_packet(struct sk_buff *skb, struct hard_iface *recv_if)
/* Update stats counter */ inc_counter(bat_priv, BAT_CNT_FORWARD); - add_counter(bat_priv, BAT_CNT_FORWARD_BYTES, skb->len + ETH_HLEN); + batadv_add_counter(bat_priv, BAT_CNT_FORWARD_BYTES, + skb->len + ETH_HLEN);
/* route it */ batadv_send_skb_packet(skb, neigh_node->if_incoming, neigh_node->addr); @@ -971,10 +976,10 @@ static int check_unicast_ttvn(struct bat_priv *bat_priv, batadv_orig_node_free_ref(orig_node); }
- bat_dbg(DBG_ROUTES, bat_priv, - "TTVN mismatch (old_ttvn %u new_ttvn %u)! Rerouting unicast packet (for %pM) to %pM\n", - unicast_packet->ttvn, curr_ttvn, ethhdr->h_dest, - unicast_packet->dest); + batadv_dbg(DBG_ROUTES, bat_priv, + "TTVN mismatch (old_ttvn %u new_ttvn %u)! Rerouting unicast packet (for %pM) to %pM\n", + unicast_packet->ttvn, curr_ttvn, ethhdr->h_dest, + unicast_packet->dest);
unicast_packet->ttvn = curr_ttvn; } diff --git a/send.c b/send.c index edf2bfa..ef4b4b3 100644 --- a/send.c +++ b/send.c @@ -143,7 +143,7 @@ int batadv_add_bcast_packet_to_list(struct bat_priv *bat_priv, struct sk_buff *newskb;
if (!atomic_dec_not_zero(&bat_priv->bcast_queue_left)) { - bat_dbg(DBG_BATMAN, bat_priv, "bcast packet queue full\n"); + batadv_dbg(DBG_BATMAN, bat_priv, "bcast packet queue full\n"); goto out; }
@@ -275,12 +275,12 @@ void batadv_purge_outstanding_packets(struct bat_priv *bat_priv, bool pending;
if (hard_iface) - bat_dbg(DBG_BATMAN, bat_priv, - "purge_outstanding_packets(): %s\n", - hard_iface->net_dev->name); + batadv_dbg(DBG_BATMAN, bat_priv, + "purge_outstanding_packets(): %s\n", + hard_iface->net_dev->name); else - bat_dbg(DBG_BATMAN, bat_priv, - "purge_outstanding_packets()\n"); + batadv_dbg(DBG_BATMAN, bat_priv, + "purge_outstanding_packets()\n");
/* free bcast list */ spin_lock_bh(&bat_priv->forw_bcast_list_lock); diff --git a/soft-interface.c b/soft-interface.c index fc3ea29..dfe32b9 100644 --- a/soft-interface.c +++ b/soft-interface.c @@ -170,7 +170,7 @@ static int interface_tx(struct sk_buff *skb, struct net_device *soft_iface) /* don't accept stp packets. STP does not help in meshes. * better use the bridge loop avoidance ... */ - if (compare_eth(ethhdr->h_dest, stp_addr)) + if (batadv_compare_eth(ethhdr->h_dest, stp_addr)) goto dropped;
if (is_multicast_ether_addr(ethhdr->h_dest)) { @@ -559,7 +559,7 @@ static void bat_get_ethtool_stats(struct net_device *dev, int i;
for (i = 0; i < BAT_CNT_NUM; i++) - data[i] = sum_counter(bat_priv, i); + data[i] = batadv_sum_counter(bat_priv, i); }
static int bat_get_sset_count(struct net_device *dev, int stringset) diff --git a/translation-table.c b/translation-table.c index bd0e505..84b2b91 100644 --- a/translation-table.c +++ b/translation-table.c @@ -66,7 +66,7 @@ static struct tt_common_entry *tt_hash_find(struct hashtable_t *hash,
rcu_read_lock(); hlist_for_each_entry_rcu(tt_common_entry, node, head, hash_entry) { - if (!compare_eth(tt_common_entry, data)) + if (!batadv_compare_eth(tt_common_entry, data)) continue;
if (!atomic_inc_not_zero(&tt_common_entry->refcount)) @@ -213,9 +213,9 @@ void batadv_tt_local_add(struct net_device *soft_iface, const uint8_t *addr, if (!tt_local_entry) goto out;
- bat_dbg(DBG_TT, bat_priv, - "Creating new local tt entry: %pM (ttvn: %d)\n", addr, - (uint8_t)atomic_read(&bat_priv->ttvn)); + batadv_dbg(DBG_TT, bat_priv, + "Creating new local tt entry: %pM (ttvn: %d)\n", addr, + (uint8_t)atomic_read(&bat_priv->ttvn));
memcpy(tt_local_entry->common.addr, addr, ETH_ALEN); tt_local_entry->common.flags = NO_FLAGS; @@ -225,7 +225,7 @@ void batadv_tt_local_add(struct net_device *soft_iface, const uint8_t *addr, tt_local_entry->last_seen = jiffies;
/* the batman interface mac address should never be purged */ - if (compare_eth(addr, soft_iface->dev_addr)) + if (batadv_compare_eth(addr, soft_iface->dev_addr)) tt_local_entry->common.flags |= TT_CLIENT_NOPURGE;
/* The local entry has to be marked as NEW to avoid to send it in @@ -441,9 +441,9 @@ static void tt_local_set_pending(struct bat_priv *bat_priv, */ tt_local_entry->common.flags |= TT_CLIENT_PENDING;
- bat_dbg(DBG_TT, bat_priv, - "Local tt entry (%pM) pending to be removed: %s\n", - tt_local_entry->common.addr, message); + batadv_dbg(DBG_TT, bat_priv, + "Local tt entry (%pM) pending to be removed: %s\n", + tt_local_entry->common.addr, message); }
void batadv_tt_local_remove(struct bat_priv *bat_priv, const uint8_t *addr, @@ -489,8 +489,8 @@ static void tt_local_purge(struct bat_priv *bat_priv) if (tt_local_entry->common.flags & TT_CLIENT_PENDING) continue;
- if (!has_timed_out(tt_local_entry->last_seen, - TT_LOCAL_TIMEOUT)) + if (!batadv_has_timed_out(tt_local_entry->last_seen, + TT_LOCAL_TIMEOUT)) continue;
tt_local_set_pending(bat_priv, tt_local_entry, @@ -674,9 +674,9 @@ int batadv_tt_global_add(struct bat_priv *bat_priv, struct orig_node *orig_node, if (wifi) tt_global_entry->common.flags |= TT_CLIENT_WIFI;
- bat_dbg(DBG_TT, bat_priv, - "Creating new global tt entry: %pM (via %pM)\n", - tt_global_entry->common.addr, orig_node->orig); + batadv_dbg(DBG_TT, bat_priv, + "Creating new global tt entry: %pM (via %pM)\n", + tt_global_entry->common.addr, orig_node->orig);
out_remove: /* remove address from local hash if present */ @@ -800,10 +800,10 @@ static void tt_global_del_orig_entry(struct bat_priv *bat_priv, head = &tt_global_entry->orig_list; hlist_for_each_entry_safe(orig_entry, node, safe, head, list) { if (orig_entry->orig_node == orig_node) { - bat_dbg(DBG_TT, bat_priv, - "Deleting %pM from global tt entry %pM: %s\n", - orig_node->orig, tt_global_entry->common.addr, - message); + batadv_dbg(DBG_TT, bat_priv, + "Deleting %pM from global tt entry %pM: %s\n", + orig_node->orig, + tt_global_entry->common.addr, message); hlist_del_rcu(node); tt_orig_list_entry_free_ref(orig_entry); } @@ -815,9 +815,8 @@ static void tt_global_del_struct(struct bat_priv *bat_priv, struct tt_global_entry *tt_global_entry, const char *message) { - bat_dbg(DBG_TT, bat_priv, - "Deleting global tt entry %pM: %s\n", - tt_global_entry->common.addr, message); + batadv_dbg(DBG_TT, bat_priv, "Deleting global tt entry %pM: %s\n", + tt_global_entry->common.addr, message);
batadv_hash_remove(bat_priv->tt_global_hash, compare_tt, batadv_choose_orig, tt_global_entry->common.addr); @@ -951,10 +950,10 @@ void batadv_tt_global_del_orig(struct bat_priv *bat_priv, orig_node, message);
if (hlist_empty(&tt_global_entry->orig_list)) { - bat_dbg(DBG_TT, bat_priv, - "Deleting global tt entry %pM: %s\n", - tt_global_entry->common.addr, - message); + batadv_dbg(DBG_TT, bat_priv, + "Deleting global tt entry %pM: %s\n", + tt_global_entry->common.addr, + message); hlist_del_rcu(node); tt_global_entry_free_ref(tt_global_entry); } @@ -987,13 +986,13 @@ static void tt_global_roam_purge(struct bat_priv *bat_priv) common); if (!(tt_global_entry->common.flags & TT_CLIENT_ROAM)) continue; - if (!has_timed_out(tt_global_entry->roam_at, - TT_CLIENT_ROAM_TIMEOUT)) + if (!batadv_has_timed_out(tt_global_entry->roam_at, + TT_CLIENT_ROAM_TIMEOUT)) continue;
- bat_dbg(DBG_TT, bat_priv, - "Deleting global tt entry (%pM): Roaming timeout\n", - tt_global_entry->common.addr); + batadv_dbg(DBG_TT, bat_priv, + "Deleting global tt entry (%pM): Roaming timeout\n", + tt_global_entry->common.addr);
hlist_del_rcu(node); tt_global_entry_free_ref(tt_global_entry); @@ -1234,7 +1233,7 @@ static void tt_req_purge(struct bat_priv *bat_priv)
spin_lock_bh(&bat_priv->tt_req_list_lock); list_for_each_entry_safe(node, safe, &bat_priv->tt_req_list, list) { - if (has_timed_out(node->issued_at, TT_REQUEST_TIMEOUT)) { + if (batadv_has_timed_out(node->issued_at, TT_REQUEST_TIMEOUT)) { list_del(&node->list); kfree(node); } @@ -1252,9 +1251,9 @@ static struct tt_req_node *new_tt_req_node(struct bat_priv *bat_priv,
spin_lock_bh(&bat_priv->tt_req_list_lock); list_for_each_entry(tt_req_node_tmp, &bat_priv->tt_req_list, list) { - if (compare_eth(tt_req_node_tmp, orig_node) && - !has_timed_out(tt_req_node_tmp->issued_at, - TT_REQUEST_TIMEOUT)) + if (batadv_compare_eth(tt_req_node_tmp, orig_node) && + !batadv_has_timed_out(tt_req_node_tmp->issued_at, + TT_REQUEST_TIMEOUT)) goto unlock; }
@@ -1409,10 +1408,10 @@ static int send_tt_request(struct bat_priv *bat_priv, if (!neigh_node) goto out;
- bat_dbg(DBG_TT, bat_priv, - "Sending TT_REQUEST to %pM via %pM [%c]\n", - dst_orig_node->orig, neigh_node->addr, - (full_table ? 'F' : '.')); + batadv_dbg(DBG_TT, bat_priv, + "Sending TT_REQUEST to %pM via %pM [%c]\n", + dst_orig_node->orig, neigh_node->addr, + (full_table ? 'F' : '.'));
inc_counter(bat_priv, BAT_CNT_TT_REQUEST_TX);
@@ -1449,10 +1448,10 @@ static bool send_other_tt_response(struct bat_priv *bat_priv, struct sk_buff *skb = NULL; struct tt_query_packet *tt_response;
- bat_dbg(DBG_TT, bat_priv, - "Received TT_REQUEST from %pM for ttvn: %u (%pM) [%c]\n", - tt_request->src, tt_request->ttvn, tt_request->dst, - (tt_request->flags & TT_FULL_TABLE ? 'F' : '.')); + batadv_dbg(DBG_TT, bat_priv, + "Received TT_REQUEST from %pM for ttvn: %u (%pM) [%c]\n", + tt_request->src, tt_request->ttvn, tt_request->dst, + (tt_request->flags & TT_FULL_TABLE ? 'F' : '.'));
/* Let's get the orig node of the REAL destination */ req_dst_orig_node = batadv_orig_hash_find(bat_priv, tt_request->dst); @@ -1536,10 +1535,10 @@ static bool send_other_tt_response(struct bat_priv *bat_priv, if (full_table) tt_response->flags |= TT_FULL_TABLE;
- bat_dbg(DBG_TT, bat_priv, - "Sending TT_RESPONSE %pM via %pM for %pM (ttvn: %u)\n", - res_dst_orig_node->orig, neigh_node->addr, - req_dst_orig_node->orig, req_ttvn); + batadv_dbg(DBG_TT, bat_priv, + "Sending TT_RESPONSE %pM via %pM for %pM (ttvn: %u)\n", + res_dst_orig_node->orig, neigh_node->addr, + req_dst_orig_node->orig, req_ttvn);
inc_counter(bat_priv, BAT_CNT_TT_RESPONSE_TX);
@@ -1578,10 +1577,10 @@ static bool send_my_tt_response(struct bat_priv *bat_priv, struct sk_buff *skb = NULL; struct tt_query_packet *tt_response;
- bat_dbg(DBG_TT, bat_priv, - "Received TT_REQUEST from %pM for ttvn: %u (me) [%c]\n", - tt_request->src, tt_request->ttvn, - (tt_request->flags & TT_FULL_TABLE ? 'F' : '.')); + batadv_dbg(DBG_TT, bat_priv, + "Received TT_REQUEST from %pM for ttvn: %u (me) [%c]\n", + tt_request->src, tt_request->ttvn, + (tt_request->flags & TT_FULL_TABLE ? 'F' : '.'));
my_ttvn = (uint8_t)atomic_read(&bat_priv->ttvn); @@ -1656,10 +1655,10 @@ static bool send_my_tt_response(struct bat_priv *bat_priv, if (full_table) tt_response->flags |= TT_FULL_TABLE;
- bat_dbg(DBG_TT, bat_priv, - "Sending TT_RESPONSE to %pM via %pM [%c]\n", - orig_node->orig, neigh_node->addr, - (tt_response->flags & TT_FULL_TABLE ? 'F' : '.')); + batadv_dbg(DBG_TT, bat_priv, + "Sending TT_RESPONSE to %pM via %pM [%c]\n", + orig_node->orig, neigh_node->addr, + (tt_response->flags & TT_FULL_TABLE ? 'F' : '.'));
inc_counter(bat_priv, BAT_CNT_TT_RESPONSE_TX);
@@ -1795,11 +1794,11 @@ void batadv_handle_tt_response(struct bat_priv *bat_priv, struct tt_req_node *node, *safe; struct orig_node *orig_node = NULL;
- bat_dbg(DBG_TT, bat_priv, - "Received TT_RESPONSE from %pM for ttvn %d t_size: %d [%c]\n", - tt_response->src, tt_response->ttvn, - ntohs(tt_response->tt_data), - (tt_response->flags & TT_FULL_TABLE ? 'F' : '.')); + batadv_dbg(DBG_TT, bat_priv, + "Received TT_RESPONSE from %pM for ttvn %d t_size: %d [%c]\n", + tt_response->src, tt_response->ttvn, + ntohs(tt_response->tt_data), + (tt_response->flags & TT_FULL_TABLE ? 'F' : '.'));
/* we should have never asked a backbone gw */ if (batadv_bla_is_backbone_gw_orig(bat_priv, tt_response->src)) @@ -1820,7 +1819,7 @@ void batadv_handle_tt_response(struct bat_priv *bat_priv, /* Delete the tt_req_node from pending tt_requests list */ spin_lock_bh(&bat_priv->tt_req_list_lock); list_for_each_entry_safe(node, safe, &bat_priv->tt_req_list, list) { - if (!compare_eth(node->addr, tt_response->src)) + if (!batadv_compare_eth(node->addr, tt_response->src)) continue; list_del(&node->list); kfree(node); @@ -1875,7 +1874,7 @@ static void tt_roam_purge(struct bat_priv *bat_priv)
spin_lock_bh(&bat_priv->tt_roam_list_lock); list_for_each_entry_safe(node, safe, &bat_priv->tt_roam_list, list) { - if (!has_timed_out(node->first_time, ROAMING_MAX_TIME)) + if (!batadv_has_timed_out(node->first_time, ROAMING_MAX_TIME)) continue;
list_del(&node->list); @@ -1901,10 +1900,11 @@ static bool tt_check_roam_count(struct bat_priv *bat_priv, * reply from the same orig_node yet */ list_for_each_entry(tt_roam_node, &bat_priv->tt_roam_list, list) { - if (!compare_eth(tt_roam_node->addr, client)) + if (!batadv_compare_eth(tt_roam_node->addr, client)) continue;
- if (has_timed_out(tt_roam_node->first_time, ROAMING_MAX_TIME)) + if (batadv_has_timed_out(tt_roam_node->first_time, + ROAMING_MAX_TIME)) continue;
if (!atomic_dec_not_zero(&tt_roam_node->counter)) @@ -1971,9 +1971,9 @@ static void send_roam_adv(struct bat_priv *bat_priv, uint8_t *client, if (!neigh_node) goto out;
- bat_dbg(DBG_TT, bat_priv, - "Sending ROAMING_ADV to %pM (client %pM) via %pM\n", - orig_node->orig, client, neigh_node->addr); + batadv_dbg(DBG_TT, bat_priv, + "Sending ROAMING_ADV to %pM (client %pM) via %pM\n", + orig_node->orig, client, neigh_node->addr);
inc_counter(bat_priv, BAT_CNT_TT_ROAM_ADV_TX);
@@ -2078,9 +2078,9 @@ static void tt_local_purge_pending_clients(struct bat_priv *bat_priv) if (!(tt_common_entry->flags & TT_CLIENT_PENDING)) continue;
- bat_dbg(DBG_TT, bat_priv, - "Deleting local tt entry (%pM): pending\n", - tt_common_entry->addr); + batadv_dbg(DBG_TT, bat_priv, + "Deleting local tt entry (%pM): pending\n", + tt_common_entry->addr);
atomic_dec(&bat_priv->num_local_tt); hlist_del_rcu(node); @@ -2113,8 +2113,9 @@ static int tt_commit_changes(struct bat_priv *bat_priv,
/* Increment the TTVN only once per OGM interval */ atomic_inc(&bat_priv->ttvn); - bat_dbg(DBG_TT, bat_priv, "Local changes committed, updating to ttvn %u\n", - (uint8_t)atomic_read(&bat_priv->ttvn)); + batadv_dbg(DBG_TT, bat_priv, + "Local changes committed, updating to ttvn %u\n", + (uint8_t)atomic_read(&bat_priv->ttvn)); bat_priv->tt_poss_change = false;
/* reset the sending counter */ @@ -2235,10 +2236,10 @@ void batadv_tt_update_orig(struct bat_priv *bat_priv, if (!orig_node->tt_initialised || ttvn != orig_ttvn || orig_node->tt_crc != tt_crc) { request_table: - bat_dbg(DBG_TT, bat_priv, - "TT inconsistency for %pM. Need to retrieve the correct information (ttvn: %u last_ttvn: %u crc: %u last_crc: %u num_changes: %u)\n", - orig_node->orig, ttvn, orig_ttvn, tt_crc, - orig_node->tt_crc, tt_num_changes); + batadv_dbg(DBG_TT, bat_priv, + "TT inconsistency for %pM. Need to retrieve the correct information (ttvn: %u last_ttvn: %u crc: %u last_crc: %u num_changes: %u)\n", + orig_node->orig, ttvn, orig_ttvn, tt_crc, + orig_node->tt_crc, tt_num_changes); send_tt_request(bat_priv, orig_node, ttvn, tt_crc, full_table); return; diff --git a/vis.c b/vis.c index bf72c52..d45989e 100644 --- a/vis.c +++ b/vis.c @@ -59,7 +59,7 @@ static int vis_info_cmp(const struct hlist_node *node, const void *data2) d2 = data2; p1 = (struct vis_packet *)d1->skb_packet->data; p2 = (struct vis_packet *)d2->skb_packet->data; - return compare_eth(p1->vis_orig, p2->vis_orig); + return batadv_compare_eth(p1->vis_orig, p2->vis_orig); }
/* hash function to choose an entry in a hash table of given size @@ -127,7 +127,7 @@ static void vis_data_insert_interface(const uint8_t *interface, struct hlist_node *pos;
hlist_for_each_entry(entry, pos, if_list, list) { - if (compare_eth(entry->addr, interface)) + if (batadv_compare_eth(entry->addr, interface)) return; }
@@ -181,7 +181,7 @@ static ssize_t vis_data_read_entry(char *buff, /* maximal length: max(4+17+2, 3+17+1+3+2) == 26 */ if (primary && entry->quality == 0) return sprintf(buff, "TT %pM, ", entry->dest); - else if (compare_eth(entry->src, src)) + else if (batadv_compare_eth(entry->src, src)) return sprintf(buff, "TQ %pM %d, ", entry->dest, entry->quality);
@@ -233,8 +233,8 @@ int batadv_vis_seq_print_text(struct seq_file *seq, void *offset) for (j = 0; j < packet->entries; j++) { if (entries[j].quality == 0) continue; - if (compare_eth(entries[j].src, - packet->vis_orig)) + if (batadv_compare_eth(entries[j].src, + packet->vis_orig)) continue; vis_data_insert_interface(entries[j].src, &vis_if_list, @@ -245,7 +245,8 @@ int batadv_vis_seq_print_text(struct seq_file *seq, void *offset) buf_size += 18 + 26 * packet->entries;
/* add primary/secondary records */ - if (compare_eth(entry->addr, packet->vis_orig)) + if (batadv_compare_eth(entry->addr, + packet->vis_orig)) buf_size += vis_data_count_prim_sec(&vis_if_list);
@@ -285,8 +286,8 @@ int batadv_vis_seq_print_text(struct seq_file *seq, void *offset) for (j = 0; j < packet->entries; j++) { if (entries[j].quality == 0) continue; - if (compare_eth(entries[j].src, - packet->vis_orig)) + if (batadv_compare_eth(entries[j].src, + packet->vis_orig)) continue; vis_data_insert_interface(entries[j].src, &vis_if_list, @@ -305,7 +306,8 @@ int batadv_vis_seq_print_text(struct seq_file *seq, void *offset) entry->primary);
/* add primary/secondary records */ - if (compare_eth(entry->addr, packet->vis_orig)) + if (batadv_compare_eth(entry->addr, + packet->vis_orig)) buff_pos += vis_data_read_prim_sec(buff + buff_pos, &vis_if_list); @@ -379,7 +381,7 @@ static int recv_list_is_in(struct bat_priv *bat_priv,
spin_lock_bh(&bat_priv->vis_list_lock); list_for_each_entry(entry, recv_list, list) { - if (compare_eth(entry->mac, mac)) { + if (batadv_compare_eth(entry->mac, mac)) { spin_unlock_bh(&bat_priv->vis_list_lock); return 1; } @@ -651,7 +653,7 @@ static int generate_vis_packet(struct bat_priv *bat_priv) if (!router) continue;
- if (!compare_eth(router->addr, orig_node->orig)) + if (!batadv_compare_eth(router->addr, orig_node->orig)) goto next;
if (router->if_incoming->if_status != IF_ACTIVE) @@ -728,7 +730,8 @@ static void purge_vis_packets(struct bat_priv *bat_priv) if (info == bat_priv->my_vis_info) continue;
- if (has_timed_out(info->first_seen, VIS_TIMEOUT)) { + if (batadv_has_timed_out(info->first_seen, + VIS_TIMEOUT)) { hlist_del(node); send_list_del(info); kref_put(&info->refcount, free_info);
On Saturday, May 12, 2012 19:48:58 Sven Eckelmann wrote:
All non-static symbols of batman-adv were prefixed with batadv_ to avoid collisions with other symbols of the kernel. Other symbols of batman-adv should use the same prefix to keep the naming scheme consistent.
Signed-off-by: Sven Eckelmann sven@narfation.org
bat_iv_ogm.c | 213 ++++++++++++++++++++++++----------------------- bat_sysfs.c | 8 +- bitarray.c | 10 +-- bridge_loop_avoidance.c | 165 ++++++++++++++++++------------------ distributed-arp-table.c | 79 +++++++++--------- gateway_client.c | 54 ++++++------ hard-interface.c | 4 +- icmp_socket.c | 12 +-- main.c | 8 +- main.h | 25 +++--- originator.c | 61 +++++++------- originator.h | 2 +- routing.c | 71 ++++++++-------- send.c | 12 +-- soft-interface.c | 4 +- translation-table.c | 149 +++++++++++++++++---------------- vis.c | 27 +++--- 17 files changed, 464 insertions(+), 440 deletions(-)
Applied in revision 033ae41.
Thanks, Marek
All non-static symbols of batman-adv were prefixed with batadv_ to avoid collisions with other symbols of the kernel. Other symbols of batman-adv should use the same prefix to keep the naming scheme consistent.
Signed-off-by: Sven Eckelmann sven@narfation.org --- compat.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/compat.h b/compat.h index 7347890..d58ba17 100644 --- a/compat.h +++ b/compat.h @@ -113,12 +113,12 @@ struct kernel_param_ops { __compat_get_param_##name, arg, \ __same_type((arg), bool *), perm)
-static inline int __param_set_copystring(const char *val, - const struct kernel_param *kp) +static inline int batadv_param_set_copystring(const char *val, + const struct kernel_param *kp) { return param_set_copystring(val, (struct kernel_param *)kp); } -#define param_set_copystring __param_set_copystring +#define param_set_copystring batadv_param_set_copystring
/* hack for dev->addr_assign_type &= ~NET_ADDR_RANDOM; */ #define addr_assign_type ifindex
On Saturday, May 12, 2012 19:48:59 Sven Eckelmann wrote:
All non-static symbols of batman-adv were prefixed with batadv_ to avoid collisions with other symbols of the kernel. Other symbols of batman-adv should use the same prefix to keep the naming scheme consistent.
Signed-off-by: Sven Eckelmann sven@narfation.org
compat.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
Applied in revision 04d3849.
Thanks, Marek
On Sat, May 12, 2012 at 01:48:52 +0200, Sven Eckelmann wrote:
hash_ipv4 is only used in distributed-arp-table.c and therefore can be placed inside this file instead of the header.
Signed-off-by: Sven Eckelmann sven@narfation.org
distributed-arp-table.c | 24 +++++++++++++++++++++++- distributed-arp-table.h | 22 ---------------------- 2 files changed, 23 insertions(+), 23 deletions(-)
diff --git a/distributed-arp-table.c b/distributed-arp-table.c index e678ec4..4894a85 100644 --- a/distributed-arp-table.c +++ b/distributed-arp-table.c @@ -32,6 +32,28 @@ #include "translation-table.h" #include "unicast.h"
+/* hash function to choose an entry in a hash table of given size.
- hash algorithm from http://en.wikipedia.org/wiki/Hash_table
- */
+static uint32_t batadv_hash_ipv4(const void *data, uint32_t size)
since the function is static, why do we want to use the batadv prefix? would this create confusion?
Cheers,
On Saturday 12 May 2012 13:56:55 Antonio Quartulli wrote:
On Sat, May 12, 2012 at 01:48:52 +0200, Sven Eckelmann wrote:
hash_ipv4 is only used in distributed-arp-table.c and therefore can be placed inside this file instead of the header.
Signed-off-by: Sven Eckelmann sven@narfation.org
distributed-arp-table.c | 24 +++++++++++++++++++++++- distributed-arp-table.h | 22 ---------------------- 2 files changed, 23 insertions(+), 23 deletions(-)
diff --git a/distributed-arp-table.c b/distributed-arp-table.c index e678ec4..4894a85 100644 --- a/distributed-arp-table.c +++ b/distributed-arp-table.c @@ -32,6 +32,28 @@
#include "translation-table.h" #include "unicast.h"
+/* hash function to choose an entry in a hash table of given size.
- hash algorithm from http://en.wikipedia.org/wiki/Hash_table
- */
+static uint32_t batadv_hash_ipv4(const void *data, uint32_t size)
since the function is static, why do we want to use the batadv prefix? would this create confusion?
Consistent naming scheme.
Just imagine that somebody needs some function like that in another file and don't want to move it to the header. That would mean that he removes the static and add a declaration in the header file.... and now we have the problem of the missing batadv_ prefix. Either he changes the name everywhere or creates those potential namespace problems.
So I would recommend to use the batadv_ prefix everywhere. Less problems in the future and maybe a happier David. :)
Kind regards, Sven
On Sat, May 12, 2012 at 02:01:41PM +0200, Sven Eckelmann wrote:
On Saturday 12 May 2012 13:56:55 Antonio Quartulli wrote:
On Sat, May 12, 2012 at 01:48:52 +0200, Sven Eckelmann wrote:
hash_ipv4 is only used in distributed-arp-table.c and therefore can be placed inside this file instead of the header.
Signed-off-by: Sven Eckelmann sven@narfation.org
distributed-arp-table.c | 24 +++++++++++++++++++++++- distributed-arp-table.h | 22 ---------------------- 2 files changed, 23 insertions(+), 23 deletions(-)
diff --git a/distributed-arp-table.c b/distributed-arp-table.c index e678ec4..4894a85 100644 --- a/distributed-arp-table.c +++ b/distributed-arp-table.c @@ -32,6 +32,28 @@
#include "translation-table.h" #include "unicast.h"
+/* hash function to choose an entry in a hash table of given size.
- hash algorithm from http://en.wikipedia.org/wiki/Hash_table
- */
+static uint32_t batadv_hash_ipv4(const void *data, uint32_t size)
since the function is static, why do we want to use the batadv prefix? would this create confusion?
Consistent naming scheme.
Just imagine that somebody needs some function like that in another file and don't want to move it to the header. That would mean that he removes the static and add a declaration in the header file.... and now we have the problem of the missing batadv_ prefix. Either he changes the name everywhere or creates those potential namespace problems.
Oh ok. Then we will use it everywhere.
Thanks Sven.
Cheers,
On Saturday, May 12, 2012 19:48:52 Sven Eckelmann wrote:
hash_ipv4 is only used in distributed-arp-table.c and therefore can be placed inside this file instead of the header.
Signed-off-by: Sven Eckelmann sven@narfation.org
distributed-arp-table.c | 24 +++++++++++++++++++++++- distributed-arp-table.h | 22 ---------------------- 2 files changed, 23 insertions(+), 23 deletions(-)
Applied in revision 9fed716.
Thanks, Marek
b.a.t.m.a.n@lists.open-mesh.org