Commit 8f34b388 authored by Markus Pargmann's avatar Markus Pargmann Committed by Antonio Quartulli

batman-adv: iv_ogm_can_aggregate, code readability

This patch tries to increase code readability by negating the first if
block and rearranging some of the other conditional blocks. This way we
save an indentation level, we also save some allocation that is not
necessary for one of the conditions.
Signed-off-by: default avatarMarkus Pargmann <mpa@pengutronix.de>
Signed-off-by: default avatarMarek Lindner <mareklindner@neomailbox.ch>
parent fc1f8693
...@@ -544,10 +544,19 @@ batadv_iv_ogm_can_aggregate(const struct batadv_ogm_packet *new_bat_ogm_packet, ...@@ -544,10 +544,19 @@ batadv_iv_ogm_can_aggregate(const struct batadv_ogm_packet *new_bat_ogm_packet,
* - the send time is within our MAX_AGGREGATION_MS time * - the send time is within our MAX_AGGREGATION_MS time
* - the resulting packet wont be bigger than * - the resulting packet wont be bigger than
* MAX_AGGREGATION_BYTES * MAX_AGGREGATION_BYTES
* otherwise aggregation is not possible
*/ */
if (time_before(send_time, forw_packet->send_time) && if (!time_before(send_time, forw_packet->send_time) ||
time_after_eq(aggregation_end_time, forw_packet->send_time) && !time_after_eq(aggregation_end_time, forw_packet->send_time))
(aggregated_bytes <= BATADV_MAX_AGGREGATION_BYTES)) { return false;
if (aggregated_bytes > BATADV_MAX_AGGREGATION_BYTES)
return false;
/* packet is not leaving on the same interface. */
if (forw_packet->if_outgoing != if_outgoing)
return false;
/* check aggregation compatibility /* check aggregation compatibility
* -> direct link packets are broadcasted on * -> direct link packets are broadcasted on
* their interface only * their interface only
...@@ -557,24 +566,20 @@ batadv_iv_ogm_can_aggregate(const struct batadv_ogm_packet *new_bat_ogm_packet, ...@@ -557,24 +566,20 @@ batadv_iv_ogm_can_aggregate(const struct batadv_ogm_packet *new_bat_ogm_packet,
*/ */
primary_if = batadv_primary_if_get_selected(bat_priv); primary_if = batadv_primary_if_get_selected(bat_priv);
if (!primary_if) if (!primary_if)
goto out; return false;
/* packet is not leaving on the same interface. */
if (forw_packet->if_outgoing != if_outgoing)
goto out;
/* packets without direct link flag and high TTL /* packets without direct link flag and high TTL
* are flooded through the net * are flooded through the net
*/ */
if ((!directlink) && if (!directlink &&
(!(batadv_ogm_packet->flags & BATADV_DIRECTLINK)) && !(batadv_ogm_packet->flags & BATADV_DIRECTLINK) &&
(batadv_ogm_packet->ttl != 1) && batadv_ogm_packet->ttl != 1 &&
/* own packets originating non-primary /* own packets originating non-primary
* interfaces leave only that interface * interfaces leave only that interface
*/ */
((!forw_packet->own) || (!forw_packet->own ||
(forw_packet->if_incoming == primary_if))) { forw_packet->if_incoming == primary_if)) {
res = true; res = true;
goto out; goto out;
} }
...@@ -582,9 +587,9 @@ batadv_iv_ogm_can_aggregate(const struct batadv_ogm_packet *new_bat_ogm_packet, ...@@ -582,9 +587,9 @@ batadv_iv_ogm_can_aggregate(const struct batadv_ogm_packet *new_bat_ogm_packet,
/* if the incoming packet is sent via this one /* if the incoming packet is sent via this one
* interface only - we still can aggregate * interface only - we still can aggregate
*/ */
if ((directlink) && if (directlink &&
(new_bat_ogm_packet->ttl == 1) && new_bat_ogm_packet->ttl == 1 &&
(forw_packet->if_incoming == if_incoming) && forw_packet->if_incoming == if_incoming &&
/* packets from direct neighbors or /* packets from direct neighbors or
* own secondary interface packets * own secondary interface packets
...@@ -596,7 +601,6 @@ batadv_iv_ogm_can_aggregate(const struct batadv_ogm_packet *new_bat_ogm_packet, ...@@ -596,7 +601,6 @@ batadv_iv_ogm_can_aggregate(const struct batadv_ogm_packet *new_bat_ogm_packet,
res = true; res = true;
goto out; goto out;
} }
}
out: out:
if (primary_if) if (primary_if)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment