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: Markus Pargmann <mpa@pengutronix.de> Signed-off-by: Marek Lindner <mareklindner@neomailbox.ch>
This commit is contained in:
parent
fc1f869366
commit
8f34b38878
|
@ -544,58 +544,62 @@ 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;
|
||||||
/* check aggregation compatibility
|
|
||||||
* -> direct link packets are broadcasted on
|
|
||||||
* their interface only
|
|
||||||
* -> aggregate packet if the current packet is
|
|
||||||
* a "global" packet as well as the base
|
|
||||||
* packet
|
|
||||||
*/
|
|
||||||
primary_if = batadv_primary_if_get_selected(bat_priv);
|
|
||||||
if (!primary_if)
|
|
||||||
goto out;
|
|
||||||
|
|
||||||
/* packet is not leaving on the same interface. */
|
if (aggregated_bytes > BATADV_MAX_AGGREGATION_BYTES)
|
||||||
if (forw_packet->if_outgoing != if_outgoing)
|
return false;
|
||||||
goto out;
|
|
||||||
|
|
||||||
/* packets without direct link flag and high TTL
|
/* packet is not leaving on the same interface. */
|
||||||
* are flooded through the net
|
if (forw_packet->if_outgoing != if_outgoing)
|
||||||
*/
|
return false;
|
||||||
if ((!directlink) &&
|
|
||||||
(!(batadv_ogm_packet->flags & BATADV_DIRECTLINK)) &&
|
|
||||||
(batadv_ogm_packet->ttl != 1) &&
|
|
||||||
|
|
||||||
/* own packets originating non-primary
|
/* check aggregation compatibility
|
||||||
* interfaces leave only that interface
|
* -> direct link packets are broadcasted on
|
||||||
*/
|
* their interface only
|
||||||
((!forw_packet->own) ||
|
* -> aggregate packet if the current packet is
|
||||||
(forw_packet->if_incoming == primary_if))) {
|
* a "global" packet as well as the base
|
||||||
res = true;
|
* packet
|
||||||
goto out;
|
*/
|
||||||
}
|
primary_if = batadv_primary_if_get_selected(bat_priv);
|
||||||
|
if (!primary_if)
|
||||||
|
return false;
|
||||||
|
|
||||||
/* if the incoming packet is sent via this one
|
/* packets without direct link flag and high TTL
|
||||||
* interface only - we still can aggregate
|
* are flooded through the net
|
||||||
*/
|
*/
|
||||||
if ((directlink) &&
|
if (!directlink &&
|
||||||
(new_bat_ogm_packet->ttl == 1) &&
|
!(batadv_ogm_packet->flags & BATADV_DIRECTLINK) &&
|
||||||
(forw_packet->if_incoming == if_incoming) &&
|
batadv_ogm_packet->ttl != 1 &&
|
||||||
|
|
||||||
/* packets from direct neighbors or
|
/* own packets originating non-primary
|
||||||
* own secondary interface packets
|
* interfaces leave only that interface
|
||||||
* (= secondary interface packets in general)
|
*/
|
||||||
*/
|
(!forw_packet->own ||
|
||||||
(batadv_ogm_packet->flags & BATADV_DIRECTLINK ||
|
forw_packet->if_incoming == primary_if)) {
|
||||||
(forw_packet->own &&
|
res = true;
|
||||||
forw_packet->if_incoming != primary_if))) {
|
goto out;
|
||||||
res = true;
|
}
|
||||||
goto out;
|
|
||||||
}
|
/* if the incoming packet is sent via this one
|
||||||
|
* interface only - we still can aggregate
|
||||||
|
*/
|
||||||
|
if (directlink &&
|
||||||
|
new_bat_ogm_packet->ttl == 1 &&
|
||||||
|
forw_packet->if_incoming == if_incoming &&
|
||||||
|
|
||||||
|
/* packets from direct neighbors or
|
||||||
|
* own secondary interface packets
|
||||||
|
* (= secondary interface packets in general)
|
||||||
|
*/
|
||||||
|
(batadv_ogm_packet->flags & BATADV_DIRECTLINK ||
|
||||||
|
(forw_packet->own &&
|
||||||
|
forw_packet->if_incoming != primary_if))) {
|
||||||
|
res = true;
|
||||||
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
out:
|
out:
|
||||||
|
|
Loading…
Reference in New Issue