From patchwork Thu Mar 13 16:45:15 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Wunderlich X-Patchwork-Id: 14015476 X-Patchwork-Delegate: kuba@kernel.org Received: from mail.simonwunderlich.de (mail.simonwunderlich.de [23.88.38.48]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2F0DB26A0F3 for ; Thu, 13 Mar 2025 16:45:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=23.88.38.48 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741884331; cv=none; b=rQbdj2EM1cyMVMsKDHd7sMVPrm7V+W4juMen8hl5ApLo7k3Fr5I6NtdE+DOQnwT09FKs21KOATKXkj94d2f05cAz2XpIeCywXGlK9wO+8Lm7gFIdYD4TCzjbEL6dIEF0cDbCV6a/fmr3SLuddo8BfV4Jd1t0UWdCk1QKFtQLu1s= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741884331; c=relaxed/simple; bh=l/SH9lwM63iubItcEfCoVV9ESdy0UjhCPBIuCZCqlig=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=OuMG756zs7wEX1T7vr/OfuEyFI8fYj7XlVn40uPLX7A0C8XEAGeuHoWFQBFru1cYTIOJx+fvFaXguOp5e6icbXVkqegKnqvScSSL4Riuzco7zCILr14eGPPYOY1Ifz4NUO4m6fjGNegtwy9zgj18lQ8LAmScjdrxh/42JILAyAU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=simonwunderlich.de; spf=pass smtp.mailfrom=simonwunderlich.de; arc=none smtp.client-ip=23.88.38.48 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=simonwunderlich.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=simonwunderlich.de Received: from kero.packetmixer.de (p200300Fa272413901A38A4BC9c0De305.dip0.t-ipconnect.de [IPv6:2003:fa:2724:1390:1a38:a4bc:9c0d:e305]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (prime256v1) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mail.simonwunderlich.de (Postfix) with ESMTPSA id 5DAE0FA132; Thu, 13 Mar 2025 17:45:28 +0100 (CET) From: Simon Wunderlich To: kuba@kernel.org, davem@davemloft.net Cc: netdev@vger.kernel.org, b.a.t.m.a.n@lists.open-mesh.org, Sven Eckelmann , Simon Wunderlich Subject: [PATCH 06/10] batman-adv: Limit number of aggregated packets directly Date: Thu, 13 Mar 2025 17:45:15 +0100 Message-Id: <20250313164519.72808-7-sw@simonwunderlich.de> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20250313164519.72808-1-sw@simonwunderlich.de> References: <20250313164519.72808-1-sw@simonwunderlich.de> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org From: Sven Eckelmann 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 Signed-off-by: Simon Wunderlich --- net/batman-adv/bat_iv_ogm.c | 4 ++++ net/batman-adv/main.h | 3 --- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/net/batman-adv/bat_iv_ogm.c b/net/batman-adv/bat_iv_ogm.c index 8513f6661dd1..b715f7343ffd 100644 --- a/net/batman-adv/bat_iv_ogm.c +++ b/net/batman-adv/bat_iv_ogm.c @@ -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; diff --git a/net/batman-adv/main.h b/net/batman-adv/main.h index 5adefdfc69bc..c08c96b5b8b1 100644 --- a/net/batman-adv/main.h +++ b/net/batman-adv/main.h @@ -104,9 +104,6 @@ */ #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