aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--net/batman-adv/hard-interface.c2
-rw-r--r--net/batman-adv/main.c2
-rw-r--r--net/batman-adv/main.h10
-rw-r--r--net/batman-adv/routing.c55
-rw-r--r--net/batman-adv/send.c2
-rw-r--r--net/batman-adv/soft-interface.c2
-rw-r--r--net/batman-adv/translation-table.c2
-rw-r--r--net/batman-adv/vis.c18
8 files changed, 51 insertions, 42 deletions
diff --git a/net/batman-adv/hard-interface.c b/net/batman-adv/hard-interface.c
index 89824853d6e3..de9bd36e00dc 100644
--- a/net/batman-adv/hard-interface.c
+++ b/net/batman-adv/hard-interface.c
@@ -187,7 +187,7 @@ static void check_known_mac_addr(struct net_device *net_dev)
187 if (batman_if->net_dev == net_dev) 187 if (batman_if->net_dev == net_dev)
188 continue; 188 continue;
189 189
190 if (!compare_orig(batman_if->net_dev->dev_addr, 190 if (!compare_eth(batman_if->net_dev->dev_addr,
191 net_dev->dev_addr)) 191 net_dev->dev_addr))
192 continue; 192 continue;
193 193
diff --git a/net/batman-adv/main.c b/net/batman-adv/main.c
index 06d956c91c27..3f977eab2987 100644
--- a/net/batman-adv/main.c
+++ b/net/batman-adv/main.c
@@ -161,7 +161,7 @@ int is_my_mac(uint8_t *addr)
161 if (batman_if->if_status != IF_ACTIVE) 161 if (batman_if->if_status != IF_ACTIVE)
162 continue; 162 continue;
163 163
164 if (compare_orig(batman_if->net_dev->dev_addr, addr)) { 164 if (compare_eth(batman_if->net_dev->dev_addr, addr)) {
165 rcu_read_unlock(); 165 rcu_read_unlock();
166 return 1; 166 return 1;
167 } 167 }
diff --git a/net/batman-adv/main.h b/net/batman-adv/main.h
index e235d7bbe045..06b5b994cc20 100644
--- a/net/batman-adv/main.h
+++ b/net/batman-adv/main.h
@@ -165,4 +165,14 @@ static inline void bat_dbg(char type __always_unused,
165 pr_err("%s: " fmt, _netdev->name, ## arg); \ 165 pr_err("%s: " fmt, _netdev->name, ## arg); \
166 } while (0) 166 } while (0)
167 167
168/**
169 * returns 1 if they are the same ethernet addr
170 *
171 * note: can't use compare_ether_addr() as it requires aligned memory
172 */
173static inline int compare_eth(void *data1, void *data2)
174{
175 return (memcmp(data1, data2, ETH_ALEN) == 0 ? 1 : 0);
176}
177
168#endif /* _NET_BATMAN_ADV_MAIN_H_ */ 178#endif /* _NET_BATMAN_ADV_MAIN_H_ */
diff --git a/net/batman-adv/routing.c b/net/batman-adv/routing.c
index ce68815f3eb3..b54bf6ec637e 100644
--- a/net/batman-adv/routing.c
+++ b/net/batman-adv/routing.c
@@ -163,8 +163,8 @@ static int is_bidirectional_neigh(struct orig_node *orig_node,
163 hlist_for_each_entry_rcu(tmp_neigh_node, node, 163 hlist_for_each_entry_rcu(tmp_neigh_node, node,
164 &orig_node->neigh_list, list) { 164 &orig_node->neigh_list, list) {
165 165
166 if (compare_orig(tmp_neigh_node->addr, 166 if (compare_eth(tmp_neigh_node->addr,
167 orig_neigh_node->orig) && 167 orig_neigh_node->orig) &&
168 (tmp_neigh_node->if_incoming == if_incoming)) 168 (tmp_neigh_node->if_incoming == if_incoming))
169 neigh_node = tmp_neigh_node; 169 neigh_node = tmp_neigh_node;
170 } 170 }
@@ -192,8 +192,8 @@ static int is_bidirectional_neigh(struct orig_node *orig_node,
192 hlist_for_each_entry_rcu(tmp_neigh_node, node, 192 hlist_for_each_entry_rcu(tmp_neigh_node, node,
193 &orig_neigh_node->neigh_list, list) { 193 &orig_neigh_node->neigh_list, list) {
194 194
195 if (compare_orig(tmp_neigh_node->addr, 195 if (compare_eth(tmp_neigh_node->addr,
196 orig_neigh_node->orig) && 196 orig_neigh_node->orig) &&
197 (tmp_neigh_node->if_incoming == if_incoming)) 197 (tmp_neigh_node->if_incoming == if_incoming))
198 neigh_node = tmp_neigh_node; 198 neigh_node = tmp_neigh_node;
199 } 199 }
@@ -304,8 +304,8 @@ static void bonding_candidate_add(struct orig_node *orig_node,
304 spin_lock_bh(&orig_node->neigh_list_lock); 304 spin_lock_bh(&orig_node->neigh_list_lock);
305 305
306 /* only consider if it has the same primary address ... */ 306 /* only consider if it has the same primary address ... */
307 if (!compare_orig(orig_node->orig, 307 if (!compare_eth(orig_node->orig,
308 neigh_node->orig_node->primary_addr)) 308 neigh_node->orig_node->primary_addr))
309 goto candidate_del; 309 goto candidate_del;
310 310
311 if (!orig_node->router) 311 if (!orig_node->router)
@@ -334,7 +334,7 @@ static void bonding_candidate_add(struct orig_node *orig_node,
334 continue; 334 continue;
335 335
336 if ((neigh_node->if_incoming == tmp_neigh_node->if_incoming) || 336 if ((neigh_node->if_incoming == tmp_neigh_node->if_incoming) ||
337 (compare_orig(neigh_node->addr, tmp_neigh_node->addr))) { 337 (compare_eth(neigh_node->addr, tmp_neigh_node->addr))) {
338 interference_candidate = 1; 338 interference_candidate = 1;
339 break; 339 break;
340 } 340 }
@@ -394,7 +394,7 @@ static void update_orig(struct bat_priv *bat_priv,
394 rcu_read_lock(); 394 rcu_read_lock();
395 hlist_for_each_entry_rcu(tmp_neigh_node, node, 395 hlist_for_each_entry_rcu(tmp_neigh_node, node,
396 &orig_node->neigh_list, list) { 396 &orig_node->neigh_list, list) {
397 if (compare_orig(tmp_neigh_node->addr, ethhdr->h_source) && 397 if (compare_eth(tmp_neigh_node->addr, ethhdr->h_source) &&
398 (tmp_neigh_node->if_incoming == if_incoming) && 398 (tmp_neigh_node->if_incoming == if_incoming) &&
399 atomic_inc_not_zero(&tmp_neigh_node->refcount)) { 399 atomic_inc_not_zero(&tmp_neigh_node->refcount)) {
400 if (neigh_node) 400 if (neigh_node)
@@ -579,7 +579,7 @@ static char count_real_packets(struct ethhdr *ethhdr,
579 orig_node->last_real_seqno, 579 orig_node->last_real_seqno,
580 batman_packet->seqno); 580 batman_packet->seqno);
581 581
582 if (compare_orig(tmp_neigh_node->addr, ethhdr->h_source) && 582 if (compare_eth(tmp_neigh_node->addr, ethhdr->h_source) &&
583 (tmp_neigh_node->if_incoming == if_incoming)) 583 (tmp_neigh_node->if_incoming == if_incoming))
584 set_mark = 1; 584 set_mark = 1;
585 else 585 else
@@ -644,8 +644,8 @@ void receive_bat_packet(struct ethhdr *ethhdr,
644 644
645 has_directlink_flag = (batman_packet->flags & DIRECTLINK ? 1 : 0); 645 has_directlink_flag = (batman_packet->flags & DIRECTLINK ? 1 : 0);
646 646
647 is_single_hop_neigh = (compare_orig(ethhdr->h_source, 647 is_single_hop_neigh = (compare_eth(ethhdr->h_source,
648 batman_packet->orig) ? 1 : 0); 648 batman_packet->orig) ? 1 : 0);
649 649
650 bat_dbg(DBG_BATMAN, bat_priv, 650 bat_dbg(DBG_BATMAN, bat_priv,
651 "Received BATMAN packet via NB: %pM, IF: %s [%pM] " 651 "Received BATMAN packet via NB: %pM, IF: %s [%pM] "
@@ -665,19 +665,19 @@ void receive_bat_packet(struct ethhdr *ethhdr,
665 if (batman_if->soft_iface != if_incoming->soft_iface) 665 if (batman_if->soft_iface != if_incoming->soft_iface)
666 continue; 666 continue;
667 667
668 if (compare_orig(ethhdr->h_source, 668 if (compare_eth(ethhdr->h_source,
669 batman_if->net_dev->dev_addr)) 669 batman_if->net_dev->dev_addr))
670 is_my_addr = 1; 670 is_my_addr = 1;
671 671
672 if (compare_orig(batman_packet->orig, 672 if (compare_eth(batman_packet->orig,
673 batman_if->net_dev->dev_addr)) 673 batman_if->net_dev->dev_addr))
674 is_my_orig = 1; 674 is_my_orig = 1;
675 675
676 if (compare_orig(batman_packet->prev_sender, 676 if (compare_eth(batman_packet->prev_sender,
677 batman_if->net_dev->dev_addr)) 677 batman_if->net_dev->dev_addr))
678 is_my_oldorig = 1; 678 is_my_oldorig = 1;
679 679
680 if (compare_orig(ethhdr->h_source, broadcast_addr)) 680 if (compare_eth(ethhdr->h_source, broadcast_addr))
681 is_broadcast = 1; 681 is_broadcast = 1;
682 } 682 }
683 rcu_read_unlock(); 683 rcu_read_unlock();
@@ -717,8 +717,8 @@ void receive_bat_packet(struct ethhdr *ethhdr,
717 /* if received seqno equals last send seqno save new 717 /* if received seqno equals last send seqno save new
718 * seqno for bidirectional check */ 718 * seqno for bidirectional check */
719 if (has_directlink_flag && 719 if (has_directlink_flag &&
720 compare_orig(if_incoming->net_dev->dev_addr, 720 compare_eth(if_incoming->net_dev->dev_addr,
721 batman_packet->orig) && 721 batman_packet->orig) &&
722 (batman_packet->seqno - if_incoming_seqno + 2 == 0)) { 722 (batman_packet->seqno - if_incoming_seqno + 2 == 0)) {
723 offset = if_incoming->if_num * NUM_WORDS; 723 offset = if_incoming->if_num * NUM_WORDS;
724 724
@@ -765,11 +765,11 @@ void receive_bat_packet(struct ethhdr *ethhdr,
765 /* avoid temporary routing loops */ 765 /* avoid temporary routing loops */
766 if ((orig_node->router) && 766 if ((orig_node->router) &&
767 (orig_node->router->orig_node->router) && 767 (orig_node->router->orig_node->router) &&
768 (compare_orig(orig_node->router->addr, 768 (compare_eth(orig_node->router->addr,
769 batman_packet->prev_sender)) && 769 batman_packet->prev_sender)) &&
770 !(compare_orig(batman_packet->orig, batman_packet->prev_sender)) && 770 !(compare_eth(batman_packet->orig, batman_packet->prev_sender)) &&
771 (compare_orig(orig_node->router->addr, 771 (compare_eth(orig_node->router->addr,
772 orig_node->router->orig_node->router->addr))) { 772 orig_node->router->orig_node->router->addr))) {
773 bat_dbg(DBG_BATMAN, bat_priv, 773 bat_dbg(DBG_BATMAN, bat_priv,
774 "Drop packet: ignoring all rebroadcast packets that " 774 "Drop packet: ignoring all rebroadcast packets that "
775 "may make me loop (sender: %pM)\n", ethhdr->h_source); 775 "may make me loop (sender: %pM)\n", ethhdr->h_source);
@@ -1185,14 +1185,13 @@ struct neigh_node *find_router(struct bat_priv *bat_priv,
1185 1185
1186 /* if we have something in the primary_addr, we can search 1186 /* if we have something in the primary_addr, we can search
1187 * for a potential bonding candidate. */ 1187 * for a potential bonding candidate. */
1188 if (memcmp(router_orig->primary_addr, zero_mac, ETH_ALEN) == 0) 1188 if (compare_eth(router_orig->primary_addr, zero_mac))
1189 goto return_router; 1189 goto return_router;
1190 1190
1191 /* find the orig_node which has the primary interface. might 1191 /* find the orig_node which has the primary interface. might
1192 * even be the same as our router_orig in many cases */ 1192 * even be the same as our router_orig in many cases */
1193 1193
1194 if (memcmp(router_orig->primary_addr, 1194 if (compare_eth(router_orig->primary_addr, router_orig->orig)) {
1195 router_orig->orig, ETH_ALEN) == 0) {
1196 primary_orig_node = router_orig; 1195 primary_orig_node = router_orig;
1197 } else { 1196 } else {
1198 primary_orig_node = hash_find(bat_priv->orig_hash, compare_orig, 1197 primary_orig_node = hash_find(bat_priv->orig_hash, compare_orig,
diff --git a/net/batman-adv/send.c b/net/batman-adv/send.c
index 831427694fc2..f0232ad77222 100644
--- a/net/batman-adv/send.c
+++ b/net/batman-adv/send.c
@@ -326,7 +326,7 @@ void schedule_forward_packet(struct orig_node *orig_node,
326 if ((orig_node->router) && (orig_node->router->tq_avg != 0)) { 326 if ((orig_node->router) && (orig_node->router->tq_avg != 0)) {
327 327
328 /* rebroadcast ogm of best ranking neighbor as is */ 328 /* rebroadcast ogm of best ranking neighbor as is */
329 if (!compare_orig(orig_node->router->addr, ethhdr->h_source)) { 329 if (!compare_eth(orig_node->router->addr, ethhdr->h_source)) {
330 batman_packet->tq = orig_node->router->tq_avg; 330 batman_packet->tq = orig_node->router->tq_avg;
331 331
332 if (orig_node->router->last_ttl) 332 if (orig_node->router->last_ttl)
diff --git a/net/batman-adv/soft-interface.c b/net/batman-adv/soft-interface.c
index c30ccd66786a..bea2dcf6bef5 100644
--- a/net/batman-adv/soft-interface.c
+++ b/net/batman-adv/soft-interface.c
@@ -132,7 +132,7 @@ static struct softif_neigh *softif_neigh_get(struct bat_priv *bat_priv,
132 rcu_read_lock(); 132 rcu_read_lock();
133 hlist_for_each_entry_rcu(softif_neigh, node, 133 hlist_for_each_entry_rcu(softif_neigh, node,
134 &bat_priv->softif_neigh_list, list) { 134 &bat_priv->softif_neigh_list, list) {
135 if (memcmp(softif_neigh->addr, addr, ETH_ALEN) != 0) 135 if (!compare_eth(softif_neigh->addr, addr))
136 continue; 136 continue;
137 137
138 if (softif_neigh->vid != vid) 138 if (softif_neigh->vid != vid)
diff --git a/net/batman-adv/translation-table.c b/net/batman-adv/translation-table.c
index b25e4b328dcb..77d0ee0d1257 100644
--- a/net/batman-adv/translation-table.c
+++ b/net/batman-adv/translation-table.c
@@ -101,7 +101,7 @@ void hna_local_add(struct net_device *soft_iface, uint8_t *addr)
101 hna_local_entry->last_seen = jiffies; 101 hna_local_entry->last_seen = jiffies;
102 102
103 /* the batman interface mac address should never be purged */ 103 /* the batman interface mac address should never be purged */
104 if (compare_orig(addr, soft_iface->dev_addr)) 104 if (compare_eth(addr, soft_iface->dev_addr))
105 hna_local_entry->never_purge = 1; 105 hna_local_entry->never_purge = 1;
106 else 106 else
107 hna_local_entry->never_purge = 0; 107 hna_local_entry->never_purge = 0;
diff --git a/net/batman-adv/vis.c b/net/batman-adv/vis.c
index 9832d8f9ed44..fc9732967dbd 100644
--- a/net/batman-adv/vis.c
+++ b/net/batman-adv/vis.c
@@ -75,7 +75,7 @@ static int vis_info_cmp(void *data1, void *data2)
75 d2 = data2; 75 d2 = data2;
76 p1 = (struct vis_packet *)d1->skb_packet->data; 76 p1 = (struct vis_packet *)d1->skb_packet->data;
77 p2 = (struct vis_packet *)d2->skb_packet->data; 77 p2 = (struct vis_packet *)d2->skb_packet->data;
78 return compare_orig(p1->vis_orig, p2->vis_orig); 78 return compare_eth(p1->vis_orig, p2->vis_orig);
79} 79}
80 80
81/* hash function to choose an entry in a hash table of given size */ 81/* hash function to choose an entry in a hash table of given size */
@@ -113,7 +113,7 @@ static void vis_data_insert_interface(const uint8_t *interface,
113 struct hlist_node *pos; 113 struct hlist_node *pos;
114 114
115 hlist_for_each_entry(entry, pos, if_list, list) { 115 hlist_for_each_entry(entry, pos, if_list, list) {
116 if (compare_orig(entry->addr, (void *)interface)) 116 if (compare_eth(entry->addr, (void *)interface))
117 return; 117 return;
118 } 118 }
119 119
@@ -165,7 +165,7 @@ static ssize_t vis_data_read_entry(char *buff, struct vis_info_entry *entry,
165 /* maximal length: max(4+17+2, 3+17+1+3+2) == 26 */ 165 /* maximal length: max(4+17+2, 3+17+1+3+2) == 26 */
166 if (primary && entry->quality == 0) 166 if (primary && entry->quality == 0)
167 return sprintf(buff, "HNA %pM, ", entry->dest); 167 return sprintf(buff, "HNA %pM, ", entry->dest);
168 else if (compare_orig(entry->src, src)) 168 else if (compare_eth(entry->src, src))
169 return sprintf(buff, "TQ %pM %d, ", entry->dest, 169 return sprintf(buff, "TQ %pM %d, ", entry->dest,
170 entry->quality); 170 entry->quality);
171 171
@@ -212,7 +212,7 @@ int vis_seq_print_text(struct seq_file *seq, void *offset)
212 if (entries[j].quality == 0) 212 if (entries[j].quality == 0)
213 continue; 213 continue;
214 compare = 214 compare =
215 compare_orig(entries[j].src, packet->vis_orig); 215 compare_eth(entries[j].src, packet->vis_orig);
216 vis_data_insert_interface(entries[j].src, 216 vis_data_insert_interface(entries[j].src,
217 &vis_if_list, 217 &vis_if_list,
218 compare); 218 compare);
@@ -222,7 +222,7 @@ int vis_seq_print_text(struct seq_file *seq, void *offset)
222 buf_size += 18 + 26 * packet->entries; 222 buf_size += 18 + 26 * packet->entries;
223 223
224 /* add primary/secondary records */ 224 /* add primary/secondary records */
225 if (compare_orig(entry->addr, packet->vis_orig)) 225 if (compare_eth(entry->addr, packet->vis_orig))
226 buf_size += 226 buf_size +=
227 vis_data_count_prim_sec(&vis_if_list); 227 vis_data_count_prim_sec(&vis_if_list);
228 228
@@ -258,7 +258,7 @@ int vis_seq_print_text(struct seq_file *seq, void *offset)
258 if (entries[j].quality == 0) 258 if (entries[j].quality == 0)
259 continue; 259 continue;
260 compare = 260 compare =
261 compare_orig(entries[j].src, packet->vis_orig); 261 compare_eth(entries[j].src, packet->vis_orig);
262 vis_data_insert_interface(entries[j].src, 262 vis_data_insert_interface(entries[j].src,
263 &vis_if_list, 263 &vis_if_list,
264 compare); 264 compare);
@@ -276,7 +276,7 @@ int vis_seq_print_text(struct seq_file *seq, void *offset)
276 entry->primary); 276 entry->primary);
277 277
278 /* add primary/secondary records */ 278 /* add primary/secondary records */
279 if (compare_orig(entry->addr, packet->vis_orig)) 279 if (compare_eth(entry->addr, packet->vis_orig))
280 buff_pos += 280 buff_pos +=
281 vis_data_read_prim_sec(buff + buff_pos, 281 vis_data_read_prim_sec(buff + buff_pos,
282 &vis_if_list); 282 &vis_if_list);
@@ -344,7 +344,7 @@ static int recv_list_is_in(struct bat_priv *bat_priv,
344 344
345 spin_lock_bh(&bat_priv->vis_list_lock); 345 spin_lock_bh(&bat_priv->vis_list_lock);
346 list_for_each_entry(entry, recv_list, list) { 346 list_for_each_entry(entry, recv_list, list) {
347 if (memcmp(entry->mac, mac, ETH_ALEN) == 0) { 347 if (compare_eth(entry->mac, mac)) {
348 spin_unlock_bh(&bat_priv->vis_list_lock); 348 spin_unlock_bh(&bat_priv->vis_list_lock);
349 return 1; 349 return 1;
350 } 350 }
@@ -617,7 +617,7 @@ static int generate_vis_packet(struct bat_priv *bat_priv)
617 if (!neigh_node) 617 if (!neigh_node)
618 continue; 618 continue;
619 619
620 if (!compare_orig(neigh_node->addr, orig_node->orig)) 620 if (!compare_eth(neigh_node->addr, orig_node->orig))
621 continue; 621 continue;
622 622
623 if (neigh_node->if_incoming->if_status != IF_ACTIVE) 623 if (neigh_node->if_incoming->if_status != IF_ACTIVE)