]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
batman-adv: Limit number of aggregated packets directly
authorSven Eckelmann <sven@narfation.org>
Sun, 2 Feb 2025 16:04:10 +0000 (17:04 +0100)
committerSimon Wunderlich <sw@simonwunderlich.de>
Sat, 22 Feb 2025 10:36:25 +0000 (11:36 +0100)
The currently selected size in BATADV_MAX_AGGREGATION_BYTES (512) is chosen
such that the number of possible aggregated packets is lower than 32. This
number must be limited so that the type of
batadv_forw_packet->direct_link_flags has enough bits to represent each
packet (with the size of at least 24 bytes).

This requirement is better implemented in code instead of having it inside
a comment.

Signed-off-by: Sven Eckelmann <sven@narfation.org>
Signed-off-by: Simon Wunderlich <sw@simonwunderlich.de>
net/batman-adv/bat_iv_ogm.c
net/batman-adv/main.h

index 8513f6661dd10079baf717bb98b4bbf3f21e5e95..b715f7343ffddcbba271274996decced6217f268 100644 (file)
@@ -446,6 +446,7 @@ batadv_iv_ogm_can_aggregate(const struct batadv_ogm_packet *new_bat_ogm_packet,
        struct batadv_ogm_packet *batadv_ogm_packet;
        int aggregated_bytes = forw_packet->packet_len + packet_len;
        struct batadv_hard_iface *primary_if = NULL;
+       u8 packet_num = forw_packet->num_packets + 1;
        bool res = false;
        unsigned long aggregation_end_time;
 
@@ -468,6 +469,9 @@ batadv_iv_ogm_can_aggregate(const struct batadv_ogm_packet *new_bat_ogm_packet,
        if (aggregated_bytes > BATADV_MAX_AGGREGATION_BYTES)
                return false;
 
+       if (packet_num >= BITS_PER_TYPE(forw_packet->direct_link_flags))
+               return false;
+
        /* packet is not leaving on the same interface. */
        if (forw_packet->if_outgoing != if_outgoing)
                return false;
index 5adefdfc69bcd407a9eef841eb6fdb3ccb9ef9b1..c08c96b5b8b13f0ab92c2692e36f69cfff226815 100644 (file)
  */
 #define BATADV_TQ_SIMILARITY_THRESHOLD 50
 
-/* should not be bigger than 512 bytes or change the size of
- * forw_packet->direct_link_flags
- */
 #define BATADV_MAX_AGGREGATION_BYTES 512
 #define BATADV_MAX_AGGREGATION_MS 100