From patchwork Sat Nov 20 12:40:51 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Sven Eckelmann X-Patchwork-Id: 18430 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 9AECD8447F; Sat, 20 Nov 2021 13:41:04 +0100 (CET) Received: from dvalin.narfation.org (dvalin.narfation.org [IPv6:2a00:17d8:100::8b1]) by diktynna.open-mesh.org (Postfix) with ESMTPS id 22D4383EED for ; Sat, 20 Nov 2021 13:41:01 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=narfation.org; s=20121; t=1637412060; 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=ZpdsrkCS3uAi4Z7sRXf+IT4tYwKyqPJtQ31TxLsuk5M=; b=KxMMN2uBySDradiGEHSnHkaERoyCS0+E+DpFKFFe9PSZSNtu9xXzm7gp1MFigsiBtk1Mr0 UuNwV7SXeRXU7MyATS1Qf71qhKyzl2/7NMufXv4bsc1Xlob6a8XHH67jyrsajiUaJRYHhn ttBRm/sZYt5fWxrTEhb/NCfG5O4/9ow= From: Sven Eckelmann To: stable@vger.kernel.org Subject: [PATCH 5.4 1/3] batman-adv: Consider fragmentation for needed_headroom Date: Sat, 20 Nov 2021 13:40:51 +0100 Message-Id: <20211120124053.261156-2-sven@narfation.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20211120124053.261156-1-sven@narfation.org> References: <20211120124053.261156-1-sven@narfation.org> MIME-Version: 1.0 ARC-Seal: i=1; s=20121; d=open-mesh.org; t=1637412061; a=rsa-sha256; cv=none; b=3puuKFQlPL/NYaOtt0PuvFES0lXWIuAaftrQ0fCxyNHp8PLPuL5rY20Yqbp0izLde0uEpT kpPWyqhkE6AqE2+lhKETuyBd5wJ4OhJ329+TbmwLph+I1r2eC5XwIkj8BA1+jQAr9REGft xDF5jwn28ks3D/c6Qr9t2ZfXLlXBY4M= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=open-mesh.org; s=20121; t=1637412061; 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=ZpdsrkCS3uAi4Z7sRXf+IT4tYwKyqPJtQ31TxLsuk5M=; b=PWlTxOu8fU23S/r9+GDDtw6TnQP1Hl+hMpc5ChmwkpWJMpLeEFX1cPneEixAeHuyAPLRjh NXMe2Q1tnfGqXW+CUsKJm/G8DQLkkdQlpMqZmjiY1apW57h6UUGQCbgiLV04IDbY3uFNNf x+jcFoRUQAgff+CaS51UY8Eev7WdHXQ= ARC-Authentication-Results: i=1; diktynna.open-mesh.org; dkim=pass header.d=narfation.org header.s=20121 header.b=KxMMN2uB; 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: M5GBMP2G3PXFQZZJHQVGC63NCUUYEWVL X-Message-ID-Hash: M5GBMP2G3PXFQZZJHQVGC63NCUUYEWVL 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 Signed-off-by: Sven Eckelmann --- 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 afb52282d5bd..18e644f3cb30 100644 --- a/net/batman-adv/hard-interface.c +++ b/net/batman-adv/hard-interface.c @@ -554,6 +554,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:52 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sven Eckelmann X-Patchwork-Id: 18431 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 26E63844A7; Sat, 20 Nov 2021 13:41:05 +0100 (CET) Received: from dvalin.narfation.org (dvalin.narfation.org [213.160.73.56]) by diktynna.open-mesh.org (Postfix) with ESMTPS id B62DD8448B for ; Sat, 20 Nov 2021 13:41:01 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=narfation.org; s=20121; t=1637412061; 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=1wiW33oiwS6eanJq/7vmzFtXXjSfZhSuWRQpjt2OwaQ=; b=a8RX1/ZuXxHufsu+p2GkUM2M3HpuzFgXEisJyfkH6kkHBucd+dDNBMzKtlxgW2k0TYvS9A /7Tj50nM1y98omAG0CvhYIeeLoZSjoLYAxBDf+/q2s+HoJ0/EYu1n1zJWkdHa92RPBLkCf SoKsZcurenfNypFJmPDnBMuKB/z6cxc= From: Sven Eckelmann To: stable@vger.kernel.org Subject: [PATCH 5.4 2/3] batman-adv: Reserve needed_*room for fragments Date: Sat, 20 Nov 2021 13:40:52 +0100 Message-Id: <20211120124053.261156-3-sven@narfation.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20211120124053.261156-1-sven@narfation.org> References: <20211120124053.261156-1-sven@narfation.org> MIME-Version: 1.0 ARC-Seal: i=1; s=20121; d=open-mesh.org; t=1637412061; a=rsa-sha256; cv=none; b=lF7jnHiKMFKwUsj8uRoWdAu3y5fApaH5jU+YbJEo0aoJfDkfbgnGji5M0QqUSvGVxCgwbo RRLE6nqoHlLXnGgLrGjko+RJqn9J09JD4miViiDzrSY0uRpfhpg+Xayy2B98OIgtdKvzIT 9G2Cz0UU+43/e5VLAsrisDHkxE3QDvM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=open-mesh.org; s=20121; t=1637412061; 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=1wiW33oiwS6eanJq/7vmzFtXXjSfZhSuWRQpjt2OwaQ=; b=DGD4AL9iNPP/Q/Ri+gRGD/6+wcVcsiMp6dz0qlvIdvydJCgxV0Y/0YQJ6xbDOsDChkvre4 cOoX7CCDf8m63tVdEGBwUF/0nNCui7O0zd92B1ENh0Mo5qJhJ1q+TKQ+9Il35/DpWgb1JX 0PJw8KS2DA04qMYCjNB2uWEXx7uuK8o= ARC-Authentication-Results: i=1; diktynna.open-mesh.org; dkim=pass header.d=narfation.org header.s=20121 header.b="a8RX1/Zu"; 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: YECOYSI765JRSBDFLSKPFO4QHLBGZFY5 X-Message-ID-Hash: YECOYSI765JRSBDFLSKPFO4QHLBGZFY5 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 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 385fccdcf69d..f1d202ff396c 100644 --- a/net/batman-adv/fragmentation.c +++ b/net/batman-adv/fragmentation.c @@ -391,6 +391,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 @@ -401,22 +402,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 */ @@ -439,11 +443,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; @@ -503,7 +508,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:53 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sven Eckelmann X-Patchwork-Id: 18432 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 AB169844A6; Sat, 20 Nov 2021 13:41:05 +0100 (CET) Received: from dvalin.narfation.org (dvalin.narfation.org [213.160.73.56]) by diktynna.open-mesh.org (Postfix) with ESMTPS id 4316B8448E for ; Sat, 20 Nov 2021 13:41:02 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=narfation.org; s=20121; t=1637412062; 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=Doh3R1ILM4ebcu1GsGngu/p/+ecj2NCrShmGAQilqss=; b=RgvGaXDhsdoWuPJC2CQ/l3vDf3/hdY85i/sfFpdt7/ru9591FAE4OQkfumEbWjs19PKgdU cNuUkapSVsHR/+KSbMdRz7MdUsnDj8eEtkLsIu06179MKxgbU0iZOAj0Yh6UdfkU9nnzpd hLCV8kfH4FUJ8Sk+9ex8sD0YA9zZGJk= From: Sven Eckelmann To: stable@vger.kernel.org Subject: [PATCH 5.4 3/3] batman-adv: Don't always reallocate the fragmentation skb head Date: Sat, 20 Nov 2021 13:40:53 +0100 Message-Id: <20211120124053.261156-4-sven@narfation.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20211120124053.261156-1-sven@narfation.org> References: <20211120124053.261156-1-sven@narfation.org> MIME-Version: 1.0 ARC-Seal: i=1; s=20121; d=open-mesh.org; t=1637412062; a=rsa-sha256; cv=none; b=QDsOEYBMZUrCMv08OaqXsVB64licJXl/hySK3R/PBd5xy4mSxvrPwRZbmWwkc2SUSNf8vQ 3xOpmwFcBMZwGRuA6gL65IAvuCbxVjmjZX2yzV6ehFcZrfHg7OINhMvaFUARry2IIbhU8+ J67oQKq3VNVkHP3jh8Dv79gg1wAp+fs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=open-mesh.org; s=20121; t=1637412062; 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=Doh3R1ILM4ebcu1GsGngu/p/+ecj2NCrShmGAQilqss=; b=JBoYvZ2Ff3pJmgRvfXtQF1ZW/A0vUBu1wBWBDeIP3+dOV4XVQOm9iO1XwnfuwQ4pua6RX/ AMWKoIv5rsZ56qUgAFfW3ajcgMW5k3JP29owaqERatzb2eiSuWzUoDzmT4dObLGjg4NLZr jPSWR10ueEWIbYI1UeVwAeECRKdUPFo= ARC-Authentication-Results: i=1; diktynna.open-mesh.org; dkim=pass header.d=narfation.org header.s=20121 header.b=RgvGaXDh; 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: NZOWUC4USLGVJ6ZYN7KXFPCBOOAX5UVY X-Message-ID-Hash: NZOWUC4USLGVJ6ZYN7KXFPCBOOAX5UVY 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 f1d202ff396c..0da90e73c79b 100644 --- a/net/batman-adv/fragmentation.c +++ b/net/batman-adv/fragmentation.c @@ -527,13 +527,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 */