From patchwork Sat Nov 20 12:40:41 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Sven Eckelmann X-Patchwork-Id: 18425 X-Patchwork-Delegate: sw@simonwunderlich.de Return-Path: X-Original-To: patchwork@open-mesh.org Delivered-To: patchwork@open-mesh.org Received: from diktynna.open-mesh.org (localhost [IPv6:::1]) by diktynna.open-mesh.org (Postfix) with ESMTP id 619EC84489; Sat, 20 Nov 2021 13:40:49 +0100 (CET) Received: from dvalin.narfation.org (dvalin.narfation.org [213.160.73.56]) by diktynna.open-mesh.org (Postfix) with ESMTPS id 049C483E46 for ; Sat, 20 Nov 2021 13:40:47 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=narfation.org; s=20121; t=1637412046; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=uvfKuwQfHKN+QDGmHKtOHG+Wr8ch4KZb1jEgy3gq5ss=; b=qbHZ0gE/gRbrQQaZ8oi85QhPuZyPKsr216MTcuQ9uhtuGmPkGm5E2X+NDxx62h5kWOJV8B 1/hi9sJSESzbYlQOMplc59aW7uf/Vip0g15C2vNbmoyfJ2ZL1e5OBszG5/kYgHgqnCohLh OvXlLIF+R6kfo/OdQi6N22kixcTnqF0= From: Sven Eckelmann To: stable@vger.kernel.org Subject: [PATCH 4.19 1/4] batman-adv: mcast: fix duplicate mcast packets in BLA backbone from LAN Date: Sat, 20 Nov 2021 13:40:41 +0100 Message-Id: <20211120124044.261086-2-sven@narfation.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20211120124044.261086-1-sven@narfation.org> References: <20211120124044.261086-1-sven@narfation.org> MIME-Version: 1.0 ARC-Seal: i=1; s=20121; d=open-mesh.org; t=1637412047; a=rsa-sha256; cv=none; b=vv7SCdDhAalKmoDZWOa2S4BB7u8z1Bc6K1Wz46YUn6EF/Rq9Hu2ZJv9mQ58JCmOUz+JRPp WmMncCNxZWIqRXFCLflPIIKXdLXnqeoGYfkvreQ50WbTD9D8DCrGuo/MKFQeFgstSJ3nwV 73aGlt79Ur5RojCxd1PHEvg2nO527Eo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=open-mesh.org; s=20121; t=1637412047; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=uvfKuwQfHKN+QDGmHKtOHG+Wr8ch4KZb1jEgy3gq5ss=; b=iL1bVUR3YX2vO+YbQ9szaek9gP3myVBAXbB8cYjOKaZ/qRrtt8aqOV3NPJKr+LM9ZwlcqE MoBXlaolco6KXnasrz6s9FPCXNXj4L4JVlhr+zLRaSdiMxP9ezadyVkmMeatWLdJzULtMl pbJ/Iy6+kOSrgTF5z3nlkDZy02QV1aY= ARC-Authentication-Results: i=1; diktynna.open-mesh.org; dkim=pass header.d=narfation.org header.s=20121 header.b="qbHZ0gE/"; spf=pass (diktynna.open-mesh.org: domain of sven@narfation.org designates 213.160.73.56 as permitted sender) smtp.mailfrom=sven@narfation.org; dmarc=pass (policy=none) header.from=narfation.org Message-ID-Hash: 7ULBCNGRWN6VXGGMGLIFHL62BDQMLXWF X-Message-ID-Hash: 7ULBCNGRWN6VXGGMGLIFHL62BDQMLXWF X-MailFrom: sven@narfation.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-b.a.t.m.a.n.lists.open-mesh.org-0; header-match-b.a.t.m.a.n.lists.open-mesh.org-1; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; suspicious-header CC: b.a.t.m.a.n@lists.open-mesh.org X-Mailman-Version: 3.2.1 Precedence: list Reply-To: The list for a Better Approach To Mobile Ad-hoc Networking List-Id: The list for a Better Approach To Mobile Ad-hoc Networking Archived-At: List-Archive: List-Help: List-Post: List-Subscribe: List-Unsubscribe: From: Linus Lüssing commit 3236d215ad38a3f5372e65cd1e0a52cf93d3c6a2 upstream. Scenario: * Multicast frame send from a BLA backbone (multiple nodes with their bat0 bridged together, with BLA enabled) Issue: * BLA backbone nodes receive the frame multiple times on bat0 For multicast frames received via batman-adv broadcast packets the originator of the broadcast packet is checked before decapsulating and forwarding the frame to bat0 (batadv_bla_is_backbone_gw()-> batadv_recv_bcast_packet()). If it came from a node which shares the same BLA backbone with us then it is not forwarded to bat0 to avoid a loop. When sending a multicast frame in a non-4-address batman-adv unicast packet we are currently missing this check - and cannot do so because the batman-adv unicast packet has no originator address field. However, we can simply fix this on the sender side by only sending the multicast frame via unicasts to interested nodes which do not share the same BLA backbone with us. This also nicely avoids some unnecessary transmissions on mesh side. Note that no infinite loop was observed, probably because of dropping via batadv_interface_tx()->batadv_bla_tx(). However the duplicates still utterly confuse switches/bridges, ICMPv6 duplicate address detection and neighbor discovery and therefore leads to long delays before being able to establish TCP connections, for instance. And it also leads to the Linux bridge printing messages like: "br-lan: received packet on eth1 with own address as source address ..." Fixes: 1d8ab8d3c176 ("batman-adv: Modified forwarding behaviour for multicast packets") Signed-off-by: Linus Lüssing Signed-off-by: Simon Wunderlich [ bp: 4.19 backport: drop usage in non-existing batadv_mcast_forw*, correct fixes line ] Signed-off-by: Sven Eckelmann --- net/batman-adv/multicast.c | 31 +++++++++++++++++++++++++++++++ net/batman-adv/multicast.h | 15 +++++++++++++++ net/batman-adv/soft-interface.c | 5 ++--- 3 files changed, 48 insertions(+), 3 deletions(-) diff --git a/net/batman-adv/multicast.c b/net/batman-adv/multicast.c index b90fe25d6b0b..9b3311dae2e4 100644 --- a/net/batman-adv/multicast.c +++ b/net/batman-adv/multicast.c @@ -62,10 +62,12 @@ #include #include +#include "bridge_loop_avoidance.h" #include "hard-interface.h" #include "hash.h" #include "log.h" #include "netlink.h" +#include "send.h" #include "soft-interface.h" #include "translation-table.h" #include "tvlv.h" @@ -1024,6 +1026,35 @@ batadv_mcast_forw_mode(struct batadv_priv *bat_priv, struct sk_buff *skb, } } +/** + * batadv_mcast_forw_send_orig() - send a multicast packet to an originator + * @bat_priv: the bat priv with all the soft interface information + * @skb: the multicast packet to send + * @vid: the vlan identifier + * @orig_node: the originator to send the packet to + * + * Return: NET_XMIT_DROP in case of error or NET_XMIT_SUCCESS otherwise. + */ +int batadv_mcast_forw_send_orig(struct batadv_priv *bat_priv, + struct sk_buff *skb, + unsigned short vid, + struct batadv_orig_node *orig_node) +{ + /* Avoid sending multicast-in-unicast packets to other BLA + * gateways - they already got the frame from the LAN side + * we share with them. + * TODO: Refactor to take BLA into account earlier, to avoid + * reducing the mcast_fanout count. + */ + if (batadv_bla_is_backbone_gw_orig(bat_priv, orig_node->orig, vid)) { + dev_kfree_skb(skb); + return NET_XMIT_SUCCESS; + } + + return batadv_send_skb_unicast(bat_priv, skb, BATADV_UNICAST, 0, + orig_node, vid); +} + /** * batadv_mcast_want_unsnoop_update() - update unsnoop counter and list * @bat_priv: the bat priv with all the soft interface information diff --git a/net/batman-adv/multicast.h b/net/batman-adv/multicast.h index 3b04ab13f0eb..6f9f3813fc59 100644 --- a/net/batman-adv/multicast.h +++ b/net/batman-adv/multicast.h @@ -51,6 +51,11 @@ enum batadv_forw_mode batadv_mcast_forw_mode(struct batadv_priv *bat_priv, struct sk_buff *skb, struct batadv_orig_node **mcast_single_orig); +int batadv_mcast_forw_send_orig(struct batadv_priv *bat_priv, + struct sk_buff *skb, + unsigned short vid, + struct batadv_orig_node *orig_node); + void batadv_mcast_init(struct batadv_priv *bat_priv); int batadv_mcast_flags_seq_print_text(struct seq_file *seq, void *offset); @@ -78,6 +83,16 @@ static inline int batadv_mcast_init(struct batadv_priv *bat_priv) return 0; } +static inline int +batadv_mcast_forw_send_orig(struct batadv_priv *bat_priv, + struct sk_buff *skb, + unsigned short vid, + struct batadv_orig_node *orig_node) +{ + kfree_skb(skb); + return NET_XMIT_DROP; +} + static inline int batadv_mcast_mesh_info_put(struct sk_buff *msg, struct batadv_priv *bat_priv) { diff --git a/net/batman-adv/soft-interface.c b/net/batman-adv/soft-interface.c index 6ff78080ec7f..1003abb8cc35 100644 --- a/net/batman-adv/soft-interface.c +++ b/net/batman-adv/soft-interface.c @@ -367,9 +367,8 @@ static netdev_tx_t batadv_interface_tx(struct sk_buff *skb, goto dropped; ret = batadv_send_skb_via_gw(bat_priv, skb, vid); } else if (mcast_single_orig) { - ret = batadv_send_skb_unicast(bat_priv, skb, - BATADV_UNICAST, 0, - mcast_single_orig, vid); + ret = batadv_mcast_forw_send_orig(bat_priv, skb, vid, + mcast_single_orig); } else { if (batadv_dat_snoop_outgoing_arp_request(bat_priv, skb)) From patchwork Sat Nov 20 12:40:42 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Sven Eckelmann X-Patchwork-Id: 18426 X-Patchwork-Delegate: sw@simonwunderlich.de Return-Path: X-Original-To: patchwork@open-mesh.org Delivered-To: patchwork@open-mesh.org Received: from diktynna.open-mesh.org (localhost [IPv6:::1]) by diktynna.open-mesh.org (Postfix) with ESMTP id 6DC1A8448F; Sat, 20 Nov 2021 13:40:52 +0100 (CET) Received: from dvalin.narfation.org (dvalin.narfation.org [IPv6:2a00:17d8:100::8b1]) by diktynna.open-mesh.org (Postfix) with ESMTPS id 8F2C084480 for ; Sat, 20 Nov 2021 13:40:47 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=narfation.org; s=20121; t=1637412047; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=3lm6nqq2xu4SpmySi5wgAUdKKMbNpugMRhaz/YZ0vxs=; b=rmr9RPZJZ52Kx10xV/ErVknNZ2n59UK+XoCabnqC0UbXQRcI3V7wHbEjTMJsf3gQzeXsZo 0vGzkeK0qlOfpkQc6VW+yXFuxF9huMO80HX5wzoAZmGyJbBeV6Tj3Zanz1ql0BYgUtX7nl FhoKspuFXBiW7f+FKE+sYPy6xNiayQA= From: Sven Eckelmann To: stable@vger.kernel.org Subject: [PATCH 4.19 2/4] batman-adv: Consider fragmentation for needed_headroom Date: Sat, 20 Nov 2021 13:40:42 +0100 Message-Id: <20211120124044.261086-3-sven@narfation.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20211120124044.261086-1-sven@narfation.org> References: <20211120124044.261086-1-sven@narfation.org> MIME-Version: 1.0 ARC-Seal: i=1; s=20121; d=open-mesh.org; t=1637412047; a=rsa-sha256; cv=none; b=o9r3z79D7ekbGTf0PPSrn1jOiedBsDU0mY4Za9s7ZklLmuYl9UiF4/IK6kGe3Wet5VKq+m YzMIheNzCl2lyd71U1Ubnrm4wknsTfJDALfQ/sViw3YfGI50gESXoxHjy2eLGzWvYWS99a Ra7IQTM5gE+GilJO8Qzr4vZF19XVgDg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=open-mesh.org; s=20121; t=1637412047; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=3lm6nqq2xu4SpmySi5wgAUdKKMbNpugMRhaz/YZ0vxs=; b=yfVNJig3vZR/XqEaM/X1+67XkC+SjLcIf1vkSLJ5nLzVB7l7l/PW/HBnj0wZwiGnrY+b7u EnOyFC0BzhgyY9ujqF5zqTlcneJWNdE2bXAppv/TX9VB24pHxQnt/D5WMYItlELdWXFAk2 WY7yOchVT6LeijluCkKlqLC4gLugOEA= ARC-Authentication-Results: i=1; diktynna.open-mesh.org; dkim=pass header.d=narfation.org header.s=20121 header.b=rmr9RPZJ; spf=pass (diktynna.open-mesh.org: domain of sven@narfation.org designates 2a00:17d8:100::8b1 as permitted sender) smtp.mailfrom=sven@narfation.org; dmarc=pass (policy=none) header.from=narfation.org Message-ID-Hash: SNQKN62SR5VILRNG4E7RPCSOPHDPEHRG X-Message-ID-Hash: SNQKN62SR5VILRNG4E7RPCSOPHDPEHRG X-MailFrom: sven@narfation.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-b.a.t.m.a.n.lists.open-mesh.org-0; header-match-b.a.t.m.a.n.lists.open-mesh.org-1; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; suspicious-header CC: b.a.t.m.a.n@lists.open-mesh.org X-Mailman-Version: 3.2.1 Precedence: list Reply-To: The list for a Better Approach To Mobile Ad-hoc Networking List-Id: The list for a Better Approach To Mobile Ad-hoc Networking Archived-At: List-Archive: List-Help: List-Post: List-Subscribe: List-Unsubscribe: commit 4ca23e2c2074465bff55ea14221175fecdf63c5f upstream. If a batman-adv packets has to be fragmented, then the original batman-adv packet header is not stripped away. Instead, only a new header is added in front of the packet after it was split. This size must be considered to avoid cost intensive reallocations during the transmission through the various device layers. Fixes: 7bca68c7844b ("batman-adv: Add lower layer needed_(head|tail)room to own ones") Reported-by: Linus Lüssing Signed-off-by: Sven Eckelmann Signed-off-by: Simon Wunderlich --- net/batman-adv/hard-interface.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/net/batman-adv/hard-interface.c b/net/batman-adv/hard-interface.c index c4e0435c952d..fc732b78daf7 100644 --- a/net/batman-adv/hard-interface.c +++ b/net/batman-adv/hard-interface.c @@ -565,6 +565,9 @@ static void batadv_hardif_recalc_extra_skbroom(struct net_device *soft_iface) needed_headroom = lower_headroom + (lower_header_len - ETH_HLEN); needed_headroom += batadv_max_header_len(); + /* fragmentation headers don't strip the unicast/... header */ + needed_headroom += sizeof(struct batadv_frag_packet); + soft_iface->needed_headroom = needed_headroom; soft_iface->needed_tailroom = lower_tailroom; } From patchwork Sat Nov 20 12:40:43 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sven Eckelmann X-Patchwork-Id: 18427 X-Patchwork-Delegate: sw@simonwunderlich.de Return-Path: X-Original-To: patchwork@open-mesh.org Delivered-To: patchwork@open-mesh.org Received: from diktynna.open-mesh.org (localhost [IPv6:::1]) by diktynna.open-mesh.org (Postfix) with ESMTP id EDBAA84496; Sat, 20 Nov 2021 13:40:52 +0100 (CET) Received: from dvalin.narfation.org (dvalin.narfation.org [IPv6:2a00:17d8:100::8b1]) by diktynna.open-mesh.org (Postfix) with ESMTPS id 29F9183E46 for ; Sat, 20 Nov 2021 13:40:48 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=narfation.org; s=20121; t=1637412047; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=DvgL5dwztchqPC54QdQLKnJGtSClAz5ynY2dj6ITDXg=; b=LpWQAw2Su5fpj6C8rk3CNvioBtNoue/UdTSGWRhlBDbyKXJp24sVLluNoGXMQFY2C2lECi 8Y8cAEe//nqBkoDPX2ZDfdX0j8/bN99sYGCrG1PVjNT8e/Bz6lYbkqW4xSCNd3miEy/7Bd cVmiU1eaqlp9sZ9CbPRmeF9lZNjH7x4= From: Sven Eckelmann To: stable@vger.kernel.org Subject: [PATCH 4.19 3/4] batman-adv: Reserve needed_*room for fragments Date: Sat, 20 Nov 2021 13:40:43 +0100 Message-Id: <20211120124044.261086-4-sven@narfation.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20211120124044.261086-1-sven@narfation.org> References: <20211120124044.261086-1-sven@narfation.org> MIME-Version: 1.0 ARC-Seal: i=1; s=20121; d=open-mesh.org; t=1637412048; a=rsa-sha256; cv=none; b=qxYvM0x12YZj1SrfumMdbcnKLd7RE5ui98GOVM/xA5V9aCTAZ64Paup/SJ14UQuv6JGUGt uBAoVVOjNqEZcHKBhvfBoMUZyWWCIMeMqDyTXRS3aioIrqOMZLUPjOGOOnK/5mps7sFU6c 0EW9oVkoHRohQkHiZtAyAFz3Nsb+bfE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=open-mesh.org; s=20121; t=1637412048; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=DvgL5dwztchqPC54QdQLKnJGtSClAz5ynY2dj6ITDXg=; b=tI43VQZJrfSxez9sAM12WJEWk2H6vtLatE2g197ia9bzONeVQJqeuQqRYX8n8mNzWdjSf7 TxXOzmyVFuvLBBjgvlxegku2/PCZ+7BqtmTiz4sQnFn4nXrufsRG6LamjSWqWBR2GoIYAx Edl4gxmFTdmvTKC3M/Vk8opyPYYW+HQ= ARC-Authentication-Results: i=1; diktynna.open-mesh.org; dkim=pass header.d=narfation.org header.s=20121 header.b=LpWQAw2S; spf=pass (diktynna.open-mesh.org: domain of sven@narfation.org designates 2a00:17d8:100::8b1 as permitted sender) smtp.mailfrom=sven@narfation.org; dmarc=pass (policy=none) header.from=narfation.org Message-ID-Hash: MW3BXHKBH5STQJ2XQRBXVOTTBPGLUF3L X-Message-ID-Hash: MW3BXHKBH5STQJ2XQRBXVOTTBPGLUF3L X-MailFrom: sven@narfation.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-b.a.t.m.a.n.lists.open-mesh.org-0; header-match-b.a.t.m.a.n.lists.open-mesh.org-1; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; suspicious-header CC: b.a.t.m.a.n@lists.open-mesh.org X-Mailman-Version: 3.2.1 Precedence: list Reply-To: The list for a Better Approach To Mobile Ad-hoc Networking List-Id: The list for a Better Approach To Mobile Ad-hoc Networking Archived-At: List-Archive: List-Help: List-Post: List-Subscribe: List-Unsubscribe: commit c5cbfc87558168ef4c3c27ce36eba6b83391db19 upstream. The batadv net_device is trying to propagate the needed_headroom and needed_tailroom from the lower devices. This is needed to avoid cost intensive reallocations using pskb_expand_head during the transmission. But the fragmentation code split the skb's without adding extra room at the end/beginning of the various fragments. This reduced the performance of transmissions over complex scenarios (batadv on vxlan on wireguard) because the lower devices had to perform the reallocations at least once. Fixes: ee75ed88879a ("batman-adv: Fragment and send skbs larger than mtu") Signed-off-by: Sven Eckelmann Signed-off-by: Simon Wunderlich [ bp: 4.19 backported: adjust context. ] Signed-off-by: Sven Eckelmann --- net/batman-adv/fragmentation.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/net/batman-adv/fragmentation.c b/net/batman-adv/fragmentation.c index 5b71a289d04f..2dbd870221e4 100644 --- a/net/batman-adv/fragmentation.c +++ b/net/batman-adv/fragmentation.c @@ -403,6 +403,7 @@ bool batadv_frag_skb_fwd(struct sk_buff *skb, /** * batadv_frag_create() - create a fragment from skb + * @net_dev: outgoing device for fragment * @skb: skb to create fragment from * @frag_head: header to use in new fragment * @fragment_size: size of new fragment @@ -413,22 +414,25 @@ bool batadv_frag_skb_fwd(struct sk_buff *skb, * * Return: the new fragment, NULL on error. */ -static struct sk_buff *batadv_frag_create(struct sk_buff *skb, +static struct sk_buff *batadv_frag_create(struct net_device *net_dev, + struct sk_buff *skb, struct batadv_frag_packet *frag_head, unsigned int fragment_size) { + unsigned int ll_reserved = LL_RESERVED_SPACE(net_dev); + unsigned int tailroom = net_dev->needed_tailroom; struct sk_buff *skb_fragment; unsigned int header_size = sizeof(*frag_head); unsigned int mtu = fragment_size + header_size; - skb_fragment = netdev_alloc_skb(NULL, mtu + ETH_HLEN); + skb_fragment = dev_alloc_skb(ll_reserved + mtu + tailroom); if (!skb_fragment) goto err; skb_fragment->priority = skb->priority; /* Eat the last mtu-bytes of the skb */ - skb_reserve(skb_fragment, header_size + ETH_HLEN); + skb_reserve(skb_fragment, ll_reserved + header_size); skb_split(skb, skb_fragment, skb->len - fragment_size); /* Add the header */ @@ -451,11 +455,12 @@ int batadv_frag_send_packet(struct sk_buff *skb, struct batadv_orig_node *orig_node, struct batadv_neigh_node *neigh_node) { + struct net_device *net_dev = neigh_node->if_incoming->net_dev; struct batadv_priv *bat_priv; struct batadv_hard_iface *primary_if = NULL; struct batadv_frag_packet frag_header; struct sk_buff *skb_fragment; - unsigned int mtu = neigh_node->if_incoming->net_dev->mtu; + unsigned int mtu = net_dev->mtu; unsigned int header_size = sizeof(frag_header); unsigned int max_fragment_size, num_fragments; int ret; @@ -515,7 +520,7 @@ int batadv_frag_send_packet(struct sk_buff *skb, goto put_primary_if; } - skb_fragment = batadv_frag_create(skb, &frag_header, + skb_fragment = batadv_frag_create(net_dev, skb, &frag_header, max_fragment_size); if (!skb_fragment) { ret = -ENOMEM; From patchwork Sat Nov 20 12:40:44 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sven Eckelmann X-Patchwork-Id: 18428 X-Patchwork-Delegate: sw@simonwunderlich.de Return-Path: X-Original-To: patchwork@open-mesh.org Delivered-To: patchwork@open-mesh.org Received: from diktynna.open-mesh.org (localhost [IPv6:::1]) by diktynna.open-mesh.org (Postfix) with ESMTP id 7851E84488; Sat, 20 Nov 2021 13:40:53 +0100 (CET) Received: from dvalin.narfation.org (dvalin.narfation.org [213.160.73.56]) by diktynna.open-mesh.org (Postfix) with ESMTPS id AEB6B84484 for ; Sat, 20 Nov 2021 13:40:48 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=narfation.org; s=20121; t=1637412048; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=+tBFI+c/zrKjqSB+eEK3KHNzW5Yo1CUzU2UbnYjd1bU=; b=HmAQtKlyJLK+arpJsol4rguUOl+AGByII/2fQEkmb3obu9IsQwkFJojgF62shMziTUkqQS Vw3tpq7c9lpXGngNQF53nFVgNsp/Vp7pWftaHC5NN+3U0ZS+vEKKhcXxxS1kqmYwN8OyPi i/CT3xZWIlj/Cl8ntE8SC3NtA0/Pfoc= From: Sven Eckelmann To: stable@vger.kernel.org Subject: [PATCH 4.19 4/4] batman-adv: Don't always reallocate the fragmentation skb head Date: Sat, 20 Nov 2021 13:40:44 +0100 Message-Id: <20211120124044.261086-5-sven@narfation.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20211120124044.261086-1-sven@narfation.org> References: <20211120124044.261086-1-sven@narfation.org> MIME-Version: 1.0 ARC-Seal: i=1; s=20121; d=open-mesh.org; t=1637412048; a=rsa-sha256; cv=none; b=l9LXqcS7Nmc/Ry6Ouf05JuC6fmyJQLPygDS6FrmgjriEU2z0XfXG+qflHprGF73HezgjpG V0muWRcAKGzgXcX9+WyTV4IV4IdshXcFVZ0PMoVMGujhEp4XHrWX+U8X776MiJztNL5onq RhMGg0plwBlSBpisZG/nGUwbE5Y2g1E= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=open-mesh.org; s=20121; t=1637412048; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=+tBFI+c/zrKjqSB+eEK3KHNzW5Yo1CUzU2UbnYjd1bU=; b=neLDZZPac+aYgjObxEN9a5E3fbi8ImUipPDtP9/S5IArwn3Z15lfRfb8AV8QYNzDcjmQm6 B+JivnHpT1db8oqhAPu41HQ9LdhKLAdBuH3xxXYazyTU0183Dc5MAGErCHz3T2+I2PR5dO JXPhWdnHTJbhIOx3VZZOoyn1OtOaKPI= ARC-Authentication-Results: i=1; diktynna.open-mesh.org; dkim=pass header.d=narfation.org header.s=20121 header.b=HmAQtKly; spf=pass (diktynna.open-mesh.org: domain of sven@narfation.org designates 213.160.73.56 as permitted sender) smtp.mailfrom=sven@narfation.org; dmarc=pass (policy=none) header.from=narfation.org Message-ID-Hash: Z554DV7DQSN2RI7B45KSWAZTSNDY3ICM X-Message-ID-Hash: Z554DV7DQSN2RI7B45KSWAZTSNDY3ICM X-MailFrom: sven@narfation.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-b.a.t.m.a.n.lists.open-mesh.org-0; header-match-b.a.t.m.a.n.lists.open-mesh.org-1; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; suspicious-header CC: b.a.t.m.a.n@lists.open-mesh.org X-Mailman-Version: 3.2.1 Precedence: list Reply-To: The list for a Better Approach To Mobile Ad-hoc Networking List-Id: The list for a Better Approach To Mobile Ad-hoc Networking Archived-At: List-Archive: List-Help: List-Post: List-Subscribe: List-Unsubscribe: commit 992b03b88e36254e26e9a4977ab948683e21bd9f upstream. When a packet is fragmented by batman-adv, the original batman-adv header is not modified. Only a new fragmentation is inserted between the original one and the ethernet header. The code must therefore make sure that it has a writable region of this size in the skbuff head. But it is not useful to always reallocate the skbuff by this size even when there would be more than enough headroom still in the skb. The reallocation is just to costly during in this codepath. Fixes: ee75ed88879a ("batman-adv: Fragment and send skbs larger than mtu") Signed-off-by: Sven Eckelmann Signed-off-by: Simon Wunderlich Signed-off-by: Sven Eckelmann --- net/batman-adv/fragmentation.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/net/batman-adv/fragmentation.c b/net/batman-adv/fragmentation.c index 2dbd870221e4..cc062b69fc8d 100644 --- a/net/batman-adv/fragmentation.c +++ b/net/batman-adv/fragmentation.c @@ -539,13 +539,14 @@ int batadv_frag_send_packet(struct sk_buff *skb, frag_header.no++; } - /* Make room for the fragment header. */ - if (batadv_skb_head_push(skb, header_size) < 0 || - pskb_expand_head(skb, header_size + ETH_HLEN, 0, GFP_ATOMIC) < 0) { - ret = -ENOMEM; + /* make sure that there is at least enough head for the fragmentation + * and ethernet headers + */ + ret = skb_cow_head(skb, ETH_HLEN + header_size); + if (ret < 0) goto put_primary_if; - } + skb_push(skb, header_size); memcpy(skb->data, &frag_header, header_size); /* Send the last fragment */