aboutsummaryrefslogtreecommitdiffstats
path: root/net/batman-adv/bat_iv_ogm.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/bat_iv_ogm.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/bat_iv_ogm.c')
-rw-r--r--net/batman-adv/bat_iv_ogm.c75
1 files changed, 42 insertions, 33 deletions
diff --git a/net/batman-adv/bat_iv_ogm.c b/net/batman-adv/bat_iv_ogm.c
index 0430063d3a7d..94859d45ed6e 100644
--- a/net/batman-adv/bat_iv_ogm.c
+++ b/net/batman-adv/bat_iv_ogm.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"
@@ -170,7 +168,8 @@ static void bat_iv_ogm_send_to_if(struct forw_packet *forw_packet,
170 batman_ogm_packet->tt_num_changes)) { 168 batman_ogm_packet->tt_num_changes)) {
171 169
172 /* we might have aggregated direct link packets with an 170 /* we might have aggregated direct link packets with an
173 * ordinary base packet */ 171 * ordinary base packet
172 */
174 if ((forw_packet->direct_link_flags & (1 << packet_num)) && 173 if ((forw_packet->direct_link_flags & (1 << packet_num)) &&
175 (forw_packet->if_incoming == hard_iface)) 174 (forw_packet->if_incoming == hard_iface))
176 batman_ogm_packet->flags |= DIRECTLINK; 175 batman_ogm_packet->flags |= DIRECTLINK;
@@ -237,8 +236,9 @@ static void bat_iv_ogm_emit(struct forw_packet *forw_packet)
237 if (!primary_if) 236 if (!primary_if)
238 goto out; 237 goto out;
239 238
240 /* multihomed peer assumed */ 239 /* multihomed peer assumed
241 /* non-primary OGMs are only broadcasted on their interface */ 240 * non-primary OGMs are only broadcasted on their interface
241 */
242 if ((directlink && (batman_ogm_packet->header.ttl == 1)) || 242 if ((directlink && (batman_ogm_packet->header.ttl == 1)) ||
243 (forw_packet->own && (forw_packet->if_incoming != primary_if))) { 243 (forw_packet->own && (forw_packet->if_incoming != primary_if))) {
244 244
@@ -292,41 +292,39 @@ static bool bat_iv_ogm_can_aggregate(const struct batman_ogm_packet
292 292
293 batman_ogm_packet = (struct batman_ogm_packet *)forw_packet->skb->data; 293 batman_ogm_packet = (struct batman_ogm_packet *)forw_packet->skb->data;
294 294
295 /** 295 /* we can aggregate the current packet to this aggregated packet
296 * we can aggregate the current packet to this aggregated packet
297 * if: 296 * if:
298 * 297 *
299 * - the send time is within our MAX_AGGREGATION_MS time 298 * - the send time is within our MAX_AGGREGATION_MS time
300 * - the resulting packet wont be bigger than 299 * - the resulting packet wont be bigger than
301 * MAX_AGGREGATION_BYTES 300 * MAX_AGGREGATION_BYTES
302 */ 301 */
303
304 if (time_before(send_time, forw_packet->send_time) && 302 if (time_before(send_time, forw_packet->send_time) &&
305 time_after_eq(send_time + msecs_to_jiffies(MAX_AGGREGATION_MS), 303 time_after_eq(send_time + msecs_to_jiffies(MAX_AGGREGATION_MS),
306 forw_packet->send_time) && 304 forw_packet->send_time) &&
307 (aggregated_bytes <= MAX_AGGREGATION_BYTES)) { 305 (aggregated_bytes <= MAX_AGGREGATION_BYTES)) {
308 306
309 /** 307 /* check aggregation compatibility
310 * check aggregation compatibility
311 * -> direct link packets are broadcasted on 308 * -> direct link packets are broadcasted on
312 * their interface only 309 * their interface only
313 * -> aggregate packet if the current packet is 310 * -> aggregate packet if the current packet is
314 * a "global" packet as well as the base 311 * a "global" packet as well as the base
315 * packet 312 * packet
316 */ 313 */
317
318 primary_if = primary_if_get_selected(bat_priv); 314 primary_if = primary_if_get_selected(bat_priv);
319 if (!primary_if) 315 if (!primary_if)
320 goto out; 316 goto out;
321 317
322 /* packets without direct link flag and high TTL 318 /* packets without direct link flag and high TTL
323 * are flooded through the net */ 319 * are flooded through the net
320 */
324 if ((!directlink) && 321 if ((!directlink) &&
325 (!(batman_ogm_packet->flags & DIRECTLINK)) && 322 (!(batman_ogm_packet->flags & DIRECTLINK)) &&
326 (batman_ogm_packet->header.ttl != 1) && 323 (batman_ogm_packet->header.ttl != 1) &&
327 324
328 /* own packets originating non-primary 325 /* own packets originating non-primary
329 * interfaces leave only that interface */ 326 * interfaces leave only that interface
327 */
330 ((!forw_packet->own) || 328 ((!forw_packet->own) ||
331 (forw_packet->if_incoming == primary_if))) { 329 (forw_packet->if_incoming == primary_if))) {
332 res = true; 330 res = true;
@@ -334,14 +332,16 @@ static bool bat_iv_ogm_can_aggregate(const struct batman_ogm_packet
334 } 332 }
335 333
336 /* if the incoming packet is sent via this one 334 /* if the incoming packet is sent via this one
337 * interface only - we still can aggregate */ 335 * interface only - we still can aggregate
336 */
338 if ((directlink) && 337 if ((directlink) &&
339 (new_batman_ogm_packet->header.ttl == 1) && 338 (new_batman_ogm_packet->header.ttl == 1) &&
340 (forw_packet->if_incoming == if_incoming) && 339 (forw_packet->if_incoming == if_incoming) &&
341 340
342 /* packets from direct neighbors or 341 /* packets from direct neighbors or
343 * own secondary interface packets 342 * own secondary interface packets
344 * (= secondary interface packets in general) */ 343 * (= secondary interface packets in general)
344 */
345 (batman_ogm_packet->flags & DIRECTLINK || 345 (batman_ogm_packet->flags & DIRECTLINK ||
346 (forw_packet->own && 346 (forw_packet->own &&
347 forw_packet->if_incoming != primary_if))) { 347 forw_packet->if_incoming != primary_if))) {
@@ -457,8 +457,7 @@ static void bat_iv_ogm_queue_add(struct bat_priv *bat_priv,
457 int packet_len, struct hard_iface *if_incoming, 457 int packet_len, struct hard_iface *if_incoming,
458 int own_packet, unsigned long send_time) 458 int own_packet, unsigned long send_time)
459{ 459{
460 /** 460 /* _aggr -> pointer to the packet we want to aggregate with
461 * _aggr -> pointer to the packet we want to aggregate with
462 * _pos -> pointer to the position in the queue 461 * _pos -> pointer to the position in the queue
463 */ 462 */
464 struct forw_packet *forw_packet_aggr = NULL, *forw_packet_pos = NULL; 463 struct forw_packet *forw_packet_aggr = NULL, *forw_packet_pos = NULL;
@@ -487,13 +486,13 @@ static void bat_iv_ogm_queue_add(struct bat_priv *bat_priv,
487 } 486 }
488 487
489 /* nothing to aggregate with - either aggregation disabled or no 488 /* nothing to aggregate with - either aggregation disabled or no
490 * suitable aggregation packet found */ 489 * suitable aggregation packet found
490 */
491 if (!forw_packet_aggr) { 491 if (!forw_packet_aggr) {
492 /* the following section can run without the lock */ 492 /* the following section can run without the lock */
493 spin_unlock_bh(&bat_priv->forw_bat_list_lock); 493 spin_unlock_bh(&bat_priv->forw_bat_list_lock);
494 494
495 /** 495 /* if we could not aggregate this packet with one of the others
496 * if we could not aggregate this packet with one of the others
497 * we hold it back for a while, so that it might be aggregated 496 * we hold it back for a while, so that it might be aggregated
498 * later on 497 * later on
499 */ 498 */
@@ -691,7 +690,8 @@ static void bat_iv_ogm_orig_update(struct bat_priv *bat_priv,
691 batadv_bonding_candidate_add(orig_node, neigh_node); 690 batadv_bonding_candidate_add(orig_node, neigh_node);
692 691
693 /* if this neighbor already is our next hop there is nothing 692 /* if this neighbor already is our next hop there is nothing
694 * to change */ 693 * to change
694 */
695 router = batadv_orig_node_get_router(orig_node); 695 router = batadv_orig_node_get_router(orig_node);
696 if (router == neigh_node) 696 if (router == neigh_node)
697 goto update_tt; 697 goto update_tt;
@@ -701,7 +701,8 @@ static void bat_iv_ogm_orig_update(struct bat_priv *bat_priv,
701 goto update_tt; 701 goto update_tt;
702 702
703 /* if the TQ is the same and the link not more symmetric we 703 /* if the TQ is the same and the link not more symmetric we
704 * won't consider it either */ 704 * won't consider it either
705 */
705 if (router && (neigh_node->tq_avg == router->tq_avg)) { 706 if (router && (neigh_node->tq_avg == router->tq_avg)) {
706 orig_node_tmp = router->orig_node; 707 orig_node_tmp = router->orig_node;
707 spin_lock_bh(&orig_node_tmp->ogm_cnt_lock); 708 spin_lock_bh(&orig_node_tmp->ogm_cnt_lock);
@@ -723,7 +724,8 @@ static void bat_iv_ogm_orig_update(struct bat_priv *bat_priv,
723 724
724update_tt: 725update_tt:
725 /* I have to check for transtable changes only if the OGM has been 726 /* I have to check for transtable changes only if the OGM has been
726 * sent through a primary interface */ 727 * sent through a primary interface
728 */
727 if (((batman_ogm_packet->orig != ethhdr->h_source) && 729 if (((batman_ogm_packet->orig != ethhdr->h_source) &&
728 (batman_ogm_packet->header.ttl > 2)) || 730 (batman_ogm_packet->header.ttl > 2)) ||
729 (batman_ogm_packet->flags & PRIMARIES_FIRST_HOP)) 731 (batman_ogm_packet->flags & PRIMARIES_FIRST_HOP))
@@ -812,15 +814,17 @@ static int bat_iv_ogm_calc_tq(struct orig_node *orig_node,
812 total_count = (orig_eq_count > neigh_rq_count ? 814 total_count = (orig_eq_count > neigh_rq_count ?
813 neigh_rq_count : orig_eq_count); 815 neigh_rq_count : orig_eq_count);
814 816
815 /* if we have too few packets (too less data) we set tq_own to zero */ 817 /* if we have too few packets (too less data) we set tq_own to zero
816 /* if we receive too few packets it is not considered bidirectional */ 818 * if we receive too few packets it is not considered bidirectional
819 */
817 if ((total_count < TQ_LOCAL_BIDRECT_SEND_MINIMUM) || 820 if ((total_count < TQ_LOCAL_BIDRECT_SEND_MINIMUM) ||
818 (neigh_rq_count < TQ_LOCAL_BIDRECT_RECV_MINIMUM)) 821 (neigh_rq_count < TQ_LOCAL_BIDRECT_RECV_MINIMUM))
819 tq_own = 0; 822 tq_own = 0;
820 else 823 else
821 /* neigh_node->real_packet_count is never zero as we 824 /* neigh_node->real_packet_count is never zero as we
822 * only purge old information when getting new 825 * only purge old information when getting new
823 * information */ 826 * information
827 */
824 tq_own = (TQ_MAX_VALUE * total_count) / neigh_rq_count; 828 tq_own = (TQ_MAX_VALUE * total_count) / neigh_rq_count;
825 829
826 /* 1 - ((1-x) ** 3), normalized to TQ_MAX_VALUE this does 830 /* 1 - ((1-x) ** 3), normalized to TQ_MAX_VALUE this does
@@ -846,7 +850,8 @@ static int bat_iv_ogm_calc_tq(struct orig_node *orig_node,
846 neigh_rq_count, tq_own, tq_asym_penalty, batman_ogm_packet->tq); 850 neigh_rq_count, tq_own, tq_asym_penalty, batman_ogm_packet->tq);
847 851
848 /* if link has the minimum required transmission quality 852 /* if link has the minimum required transmission quality
849 * consider it bidirectional */ 853 * consider it bidirectional
854 */
850 if (batman_ogm_packet->tq >= TQ_TOTAL_BIDRECT_LIMIT) 855 if (batman_ogm_packet->tq >= TQ_TOTAL_BIDRECT_LIMIT)
851 ret = 1; 856 ret = 1;
852 857
@@ -1039,8 +1044,9 @@ static void bat_iv_ogm_process(const struct ethhdr *ethhdr,
1039 return; 1044 return;
1040 1045
1041 /* neighbor has to indicate direct link and it has to 1046 /* neighbor has to indicate direct link and it has to
1042 * come via the corresponding interface */ 1047 * come via the corresponding interface
1043 /* save packet seqno for bidirectional check */ 1048 * save packet seqno for bidirectional check
1049 */
1044 if (has_directlink_flag && 1050 if (has_directlink_flag &&
1045 compare_eth(if_incoming->net_dev->dev_addr, 1051 compare_eth(if_incoming->net_dev->dev_addr,
1046 batman_ogm_packet->orig)) { 1052 batman_ogm_packet->orig)) {
@@ -1117,7 +1123,8 @@ static void bat_iv_ogm_process(const struct ethhdr *ethhdr,
1117 } 1123 }
1118 1124
1119 /* if sender is a direct neighbor the sender mac equals 1125 /* if sender is a direct neighbor the sender mac equals
1120 * originator mac */ 1126 * originator mac
1127 */
1121 orig_neigh_node = (is_single_hop_neigh ? 1128 orig_neigh_node = (is_single_hop_neigh ?
1122 orig_node : 1129 orig_node :
1123 batadv_get_orig_node(bat_priv, ethhdr->h_source)); 1130 batadv_get_orig_node(bat_priv, ethhdr->h_source));
@@ -1127,7 +1134,8 @@ static void bat_iv_ogm_process(const struct ethhdr *ethhdr,
1127 orig_neigh_router = batadv_orig_node_get_router(orig_neigh_node); 1134 orig_neigh_router = batadv_orig_node_get_router(orig_neigh_node);
1128 1135
1129 /* drop packet if sender is not a direct neighbor and if we 1136 /* drop packet if sender is not a direct neighbor and if we
1130 * don't route towards it */ 1137 * don't route towards it
1138 */
1131 if (!is_single_hop_neigh && (!orig_neigh_router)) { 1139 if (!is_single_hop_neigh && (!orig_neigh_router)) {
1132 bat_dbg(DBG_BATMAN, bat_priv, 1140 bat_dbg(DBG_BATMAN, bat_priv,
1133 "Drop packet: OGM via unknown neighbor!\n"); 1141 "Drop packet: OGM via unknown neighbor!\n");
@@ -1141,7 +1149,8 @@ static void bat_iv_ogm_process(const struct ethhdr *ethhdr,
1141 batman_ogm_packet); 1149 batman_ogm_packet);
1142 1150
1143 /* update ranking if it is not a duplicate or has the same 1151 /* update ranking if it is not a duplicate or has the same
1144 * seqno and similar ttl as the non-duplicate */ 1152 * seqno and similar ttl as the non-duplicate
1153 */
1145 if (is_bidirectional && 1154 if (is_bidirectional &&
1146 (!is_duplicate || 1155 (!is_duplicate ||
1147 ((orig_node->last_real_seqno == ntohl(batman_ogm_packet->seqno)) && 1156 ((orig_node->last_real_seqno == ntohl(batman_ogm_packet->seqno)) &&