aboutsummaryrefslogtreecommitdiffstats
path: root/net/batman-adv/routing.c
diff options
context:
space:
mode:
authorSven Eckelmann <sven@narfation.org>2012-05-11 20:09:43 -0400
committerAntonio Quartulli <ordex@autistici.org>2012-06-20 16:15:33 -0400
commit9cfc7bd608b97463993b4f3e4775d99022253f8d (patch)
treefcfcf1e714a91943a740dcaa2744ee66448f9f73 /net/batman-adv/routing.c
parent3193e8fdfa355289892661d206d1954114a7be95 (diff)
batman-adv: Reformat multiline comments to consistent style
batman-adv doesn't follow the style for multiline comments that David S. Miller prefers. All comments should be reformatted to follow this consistent style to make the code slightly more readable. Signed-off-by: Sven Eckelmann <sven@narfation.org>
Diffstat (limited to 'net/batman-adv/routing.c')
-rw-r--r--net/batman-adv/routing.c67
1 files changed, 39 insertions, 28 deletions
diff --git a/net/batman-adv/routing.c b/net/batman-adv/routing.c
index 1b1dd41f5fe6..79f63cf11be4 100644
--- a/net/batman-adv/routing.c
+++ b/net/batman-adv/routing.c
@@ -1,5 +1,4 @@
1/* 1/* Copyright (C) 2007-2012 B.A.T.M.A.N. contributors:
2 * Copyright (C) 2007-2012 B.A.T.M.A.N. contributors:
3 * 2 *
4 * Marek Lindner, Simon Wunderlich 3 * Marek Lindner, Simon Wunderlich
5 * 4 *
@@ -16,7 +15,6 @@
16 * along with this program; if not, write to the Free Software 15 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
18 * 02110-1301, USA 17 * 02110-1301, USA
19 *
20 */ 18 */
21 19
22#include "main.h" 20#include "main.h"
@@ -165,8 +163,7 @@ void batadv_bonding_candidate_add(struct orig_node *orig_node,
165 if (neigh_node->tq_avg < router->tq_avg - BONDING_TQ_THRESHOLD) 163 if (neigh_node->tq_avg < router->tq_avg - BONDING_TQ_THRESHOLD)
166 goto candidate_del; 164 goto candidate_del;
167 165
168 /** 166 /* check if we have another candidate with the same mac address or
169 * check if we have another candidate with the same mac address or
170 * interface. If we do, we won't select this candidate because of 167 * interface. If we do, we won't select this candidate because of
171 * possible interference. 168 * possible interference.
172 */ 169 */
@@ -177,7 +174,8 @@ void batadv_bonding_candidate_add(struct orig_node *orig_node,
177 continue; 174 continue;
178 175
179 /* we only care if the other candidate is even 176 /* we only care if the other candidate is even
180 * considered as candidate. */ 177 * considered as candidate.
178 */
181 if (list_empty(&tmp_neigh_node->bonding_list)) 179 if (list_empty(&tmp_neigh_node->bonding_list))
182 continue; 180 continue;
183 181
@@ -398,9 +396,7 @@ int batadv_recv_icmp_packet(struct sk_buff *skb, struct hard_iface *recv_if)
398 int hdr_size = sizeof(struct icmp_packet); 396 int hdr_size = sizeof(struct icmp_packet);
399 int ret = NET_RX_DROP; 397 int ret = NET_RX_DROP;
400 398
401 /** 399 /* we truncate all incoming icmp packets if they don't match our size */
402 * we truncate all incoming icmp packets if they don't match our size
403 */
404 if (skb->len >= sizeof(struct icmp_packet_rr)) 400 if (skb->len >= sizeof(struct icmp_packet_rr))
405 hdr_size = sizeof(struct icmp_packet_rr); 401 hdr_size = sizeof(struct icmp_packet_rr);
406 402
@@ -474,7 +470,8 @@ out:
474 * robin fashion over the remaining interfaces. 470 * robin fashion over the remaining interfaces.
475 * 471 *
476 * This method rotates the bonding list and increases the 472 * This method rotates the bonding list and increases the
477 * returned router's refcount. */ 473 * returned router's refcount.
474 */
478static struct neigh_node *find_bond_router(struct orig_node *primary_orig, 475static struct neigh_node *find_bond_router(struct orig_node *primary_orig,
479 const struct hard_iface *recv_if) 476 const struct hard_iface *recv_if)
480{ 477{
@@ -507,10 +504,12 @@ static struct neigh_node *find_bond_router(struct orig_node *primary_orig,
507 goto out; 504 goto out;
508 505
509 /* selected should point to the next element 506 /* selected should point to the next element
510 * after the current router */ 507 * after the current router
508 */
511 spin_lock_bh(&primary_orig->neigh_list_lock); 509 spin_lock_bh(&primary_orig->neigh_list_lock);
512 /* this is a list_move(), which unfortunately 510 /* this is a list_move(), which unfortunately
513 * does not exist as rcu version */ 511 * does not exist as rcu version
512 */
514 list_del_rcu(&primary_orig->bond_list); 513 list_del_rcu(&primary_orig->bond_list);
515 list_add_rcu(&primary_orig->bond_list, 514 list_add_rcu(&primary_orig->bond_list,
516 &router->bonding_list); 515 &router->bonding_list);
@@ -525,7 +524,8 @@ out:
525 * remaining candidates which are not using 524 * remaining candidates which are not using
526 * this interface. 525 * this interface.
527 * 526 *
528 * Increases the returned router's refcount */ 527 * Increases the returned router's refcount
528 */
529static struct neigh_node *find_ifalter_router(struct orig_node *primary_orig, 529static struct neigh_node *find_ifalter_router(struct orig_node *primary_orig,
530 const struct hard_iface *recv_if) 530 const struct hard_iface *recv_if)
531{ 531{
@@ -546,11 +546,13 @@ static struct neigh_node *find_ifalter_router(struct orig_node *primary_orig,
546 continue; 546 continue;
547 547
548 /* if we don't have a router yet 548 /* if we don't have a router yet
549 * or this one is better, choose it. */ 549 * or this one is better, choose it.
550 */
550 if ((!router) || 551 if ((!router) ||
551 (tmp_neigh_node->tq_avg > router->tq_avg)) { 552 (tmp_neigh_node->tq_avg > router->tq_avg)) {
552 /* decrement refcount of 553 /* decrement refcount of
553 * previously selected router */ 554 * previously selected router
555 */
554 if (router) 556 if (router)
555 batadv_neigh_node_free_ref(router); 557 batadv_neigh_node_free_ref(router);
556 558
@@ -602,7 +604,8 @@ int batadv_recv_tt_query(struct sk_buff *skb, struct hard_iface *recv_if)
602 batadv_inc_counter(bat_priv, BAT_CNT_TT_REQUEST_RX); 604 batadv_inc_counter(bat_priv, BAT_CNT_TT_REQUEST_RX);
603 605
604 /* If we cannot provide an answer the tt_request is 606 /* If we cannot provide an answer the tt_request is
605 * forwarded */ 607 * forwarded
608 */
606 if (!batadv_send_tt_response(bat_priv, tt_query)) { 609 if (!batadv_send_tt_response(bat_priv, tt_query)) {
607 bat_dbg(DBG_TT, bat_priv, 610 bat_dbg(DBG_TT, bat_priv,
608 "Routing TT_REQUEST to %pM [%c]\n", 611 "Routing TT_REQUEST to %pM [%c]\n",
@@ -616,7 +619,8 @@ int batadv_recv_tt_query(struct sk_buff *skb, struct hard_iface *recv_if)
616 619
617 if (batadv_is_my_mac(tt_query->dst)) { 620 if (batadv_is_my_mac(tt_query->dst)) {
618 /* packet needs to be linearized to access the TT 621 /* packet needs to be linearized to access the TT
619 * changes */ 622 * changes
623 */
620 if (skb_linearize(skb) < 0) 624 if (skb_linearize(skb) < 0)
621 goto out; 625 goto out;
622 /* skb_linearize() possibly changed skb->data */ 626 /* skb_linearize() possibly changed skb->data */
@@ -694,7 +698,8 @@ int batadv_recv_roam_adv(struct sk_buff *skb, struct hard_iface *recv_if)
694 698
695 /* Roaming phase starts: I have new information but the ttvn has not 699 /* Roaming phase starts: I have new information but the ttvn has not
696 * been incremented yet. This flag will make me check all the incoming 700 * been incremented yet. This flag will make me check all the incoming
697 * packets for the correct destination. */ 701 * packets for the correct destination.
702 */
698 bat_priv->tt_poss_change = true; 703 bat_priv->tt_poss_change = true;
699 704
700 batadv_orig_node_free_ref(orig_node); 705 batadv_orig_node_free_ref(orig_node);
@@ -705,7 +710,8 @@ out:
705 710
706/* find a suitable router for this originator, and use 711/* find a suitable router for this originator, and use
707 * bonding if possible. increases the found neighbors 712 * bonding if possible. increases the found neighbors
708 * refcount.*/ 713 * refcount.
714 */
709struct neigh_node *batadv_find_router(struct bat_priv *bat_priv, 715struct neigh_node *batadv_find_router(struct bat_priv *bat_priv,
710 struct orig_node *orig_node, 716 struct orig_node *orig_node,
711 const struct hard_iface *recv_if) 717 const struct hard_iface *recv_if)
@@ -724,7 +730,8 @@ struct neigh_node *batadv_find_router(struct bat_priv *bat_priv,
724 goto err; 730 goto err;
725 731
726 /* without bonding, the first node should 732 /* without bonding, the first node should
727 * always choose the default router. */ 733 * always choose the default router.
734 */
728 bonding_enabled = atomic_read(&bat_priv->bonding); 735 bonding_enabled = atomic_read(&bat_priv->bonding);
729 736
730 rcu_read_lock(); 737 rcu_read_lock();
@@ -737,13 +744,14 @@ struct neigh_node *batadv_find_router(struct bat_priv *bat_priv,
737 goto return_router; 744 goto return_router;
738 745
739 /* if we have something in the primary_addr, we can search 746 /* if we have something in the primary_addr, we can search
740 * for a potential bonding candidate. */ 747 * for a potential bonding candidate.
748 */
741 if (compare_eth(router_orig->primary_addr, zero_mac)) 749 if (compare_eth(router_orig->primary_addr, zero_mac))
742 goto return_router; 750 goto return_router;
743 751
744 /* find the orig_node which has the primary interface. might 752 /* find the orig_node which has the primary interface. might
745 * even be the same as our router_orig in many cases */ 753 * even be the same as our router_orig in many cases
746 754 */
747 if (compare_eth(router_orig->primary_addr, router_orig->orig)) { 755 if (compare_eth(router_orig->primary_addr, router_orig->orig)) {
748 primary_orig_node = router_orig; 756 primary_orig_node = router_orig;
749 } else { 757 } else {
@@ -756,14 +764,15 @@ struct neigh_node *batadv_find_router(struct bat_priv *bat_priv,
756 } 764 }
757 765
758 /* with less than 2 candidates, we can't do any 766 /* with less than 2 candidates, we can't do any
759 * bonding and prefer the original router. */ 767 * bonding and prefer the original router.
768 */
760 if (atomic_read(&primary_orig_node->bond_candidates) < 2) 769 if (atomic_read(&primary_orig_node->bond_candidates) < 2)
761 goto return_router; 770 goto return_router;
762 771
763 /* all nodes between should choose a candidate which 772 /* all nodes between should choose a candidate which
764 * is is not on the interface where the packet came 773 * is is not on the interface where the packet came
765 * in. */ 774 * in.
766 775 */
767 batadv_neigh_node_free_ref(router); 776 batadv_neigh_node_free_ref(router);
768 777
769 if (bonding_enabled) 778 if (bonding_enabled)
@@ -1089,7 +1098,8 @@ int batadv_recv_bcast_packet(struct sk_buff *skb, struct hard_iface *recv_if)
1089 goto spin_unlock; 1098 goto spin_unlock;
1090 1099
1091 /* mark broadcast in flood history, update window position 1100 /* mark broadcast in flood history, update window position
1092 * if required. */ 1101 * if required.
1102 */
1093 if (batadv_bit_get_packet(bat_priv, orig_node->bcast_bits, seq_diff, 1)) 1103 if (batadv_bit_get_packet(bat_priv, orig_node->bcast_bits, seq_diff, 1))
1094 orig_node->last_bcast_seqno = ntohl(bcast_packet->seqno); 1104 orig_node->last_bcast_seqno = ntohl(bcast_packet->seqno);
1095 1105
@@ -1165,6 +1175,7 @@ int batadv_recv_vis_packet(struct sk_buff *skb, struct hard_iface *recv_if)
1165 } 1175 }
1166 1176
1167 /* We take a copy of the data in the packet, so we should 1177 /* We take a copy of the data in the packet, so we should
1168 always free the skbuf. */ 1178 * always free the skbuf.
1179 */
1169 return NET_RX_DROP; 1180 return NET_RX_DROP;
1170} 1181}