Message ID | 20221207072349.28608-1-jgross@suse.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp35076wrr; Tue, 6 Dec 2022 23:31:23 -0800 (PST) X-Google-Smtp-Source: AA0mqf7RX5sxyqRIEC7BJp4d1HeqED454nkcSDZgvRWBdT+Z81Bz5wm/WrOejOhSzAYafGY7s+1I X-Received: by 2002:a17:90a:c383:b0:219:5997:fb0a with SMTP id h3-20020a17090ac38300b002195997fb0amr39147025pjt.109.1670398282843; Tue, 06 Dec 2022 23:31:22 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1670398282; cv=none; d=google.com; s=arc-20160816; b=E7YvqYNA+ga8M3jzPNeQitNydRi73fPgUjlgQQbQeeGMeWsBhMwmxVjQTHLQE+SscK iLjBMSq5Z1VXkVUsPFzP5TosjTl8NQUCDoVc3K6xVagGrGZ50f/aoJWCwEN09Fs/zHBW CrjD5SYt4PERqbtMFc5ektl+IzWTntWTtk0SaeC2KH94H6CS08x9FJcG6CO979LGIxv6 7sg37I20+4J4KSrnD6LWyat403fKoachICz11HigLa73dmIreTu2RvVZoSu06t4SBT85 tJfefiuGdHMS4OzX1DW0/NiZV9ZmnFYb51okHFaKctQqMXAXy6E8ZXotdq3KRXu0wEir rOdA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=8z7/YudCGGKCXhaRYUEabm0CJvk7asrQBPAqjkCdK1A=; b=QZrYxV2j+op5ojvT2e5n0P3P0NjfK8GgVaSZx9S0HRAvR+EbwuTgx6AM7hdcDdk+sD iVLEnYL7WWAebz5phGvsjbJu4IGRNQZjW6hD0tJcuKBzwWskeupQLvq0j+oKCWmDaf9F ypQwUL/XKg+8PsANwhn+iLs5xyGWj05uFWPMaQek9wdZ30dvIFuO/VfZoxb5dRtcT9fA HayIKXacGzqXJXiWjaIJaZj2T5pnMuPXClFoB5tMW9v1Q+t6QPKNzXmvoCbVlGxprLVj heWIoBaI/7nPN+EJgBia0penx0S8qvttLdX2IXQsRXxYDmj7j8n2izFqyEIfibj4P4UY CYHQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.com header.s=susede1 header.b="JqFhNl/H"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=suse.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id t9-20020a17090340c900b00186897fb90dsi19962789pld.233.2022.12.06.23.31.10; Tue, 06 Dec 2022 23:31:22 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@suse.com header.s=susede1 header.b="JqFhNl/H"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=suse.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229527AbiLGHYQ (ORCPT <rfc822;b08248@gmail.com> + 99 others); Wed, 7 Dec 2022 02:24:16 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50794 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229456AbiLGHYB (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Wed, 7 Dec 2022 02:24:01 -0500 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B6CBDB3D; Tue, 6 Dec 2022 23:23:58 -0800 (PST) Received: from imap1.suse-dmz.suse.de (imap1.suse-dmz.suse.de [192.168.254.73]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 3F2D821C24; Wed, 7 Dec 2022 07:23:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1670397837; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=8z7/YudCGGKCXhaRYUEabm0CJvk7asrQBPAqjkCdK1A=; b=JqFhNl/HgV93fIyw5L1DM8x9B/PUZf+bk70tC2kJ78oA38eB+MUhdsv6IrF0KwXrzXTiU9 s7jWV24du+vMIFJSIc7E5lDpoJtwCrgDAzCldKvixun7J1PNk1YgV0Mn65L1jxJrL2gZYn 066f6AQx0C41SQrKdTPASsx1Su23lNc= Received: from imap1.suse-dmz.suse.de (imap1.suse-dmz.suse.de [192.168.254.73]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap1.suse-dmz.suse.de (Postfix) with ESMTPS id E8F08136B4; Wed, 7 Dec 2022 07:23:56 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap1.suse-dmz.suse.de with ESMTPSA id uRpoN4w/kGPuLAAAGKfGzw (envelope-from <jgross@suse.com>); Wed, 07 Dec 2022 07:23:56 +0000 From: Juergen Gross <jgross@suse.com> To: linux-kernel@vger.kernel.org, netdev@vger.kernel.org Cc: Juergen Gross <jgross@suse.com>, Wei Liu <wei.liu@kernel.org>, Paul Durrant <paul@xen.org>, "David S. Miller" <davem@davemloft.net>, Eric Dumazet <edumazet@google.com>, Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>, xen-devel@lists.xenproject.org Subject: [PATCH] xen/netback: fix build warning Date: Wed, 7 Dec 2022 08:23:49 +0100 Message-Id: <20221207072349.28608-1-jgross@suse.com> X-Mailer: git-send-email 2.35.3 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1751539550155844170?= X-GMAIL-MSGID: =?utf-8?q?1751539550155844170?= |
Series |
xen/netback: fix build warning
|
|
Commit Message
Juergen Gross
Dec. 7, 2022, 7:23 a.m. UTC
Commit ad7f402ae4f4 ("xen/netback: Ensure protocol headers don't fall in
the non-linear area") introduced a (valid) build warning.
Fix it.
Fixes: ad7f402ae4f4 ("xen/netback: Ensure protocol headers don't fall in the non-linear area")
Signed-off-by: Juergen Gross <jgross@suse.com>
---
drivers/net/xen-netback/netback.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
Comments
On 07.12.2022 08:23, Juergen Gross wrote: > Commit ad7f402ae4f4 ("xen/netback: Ensure protocol headers don't fall in > the non-linear area") introduced a (valid) build warning. > > Fix it. > > Fixes: ad7f402ae4f4 ("xen/netback: Ensure protocol headers don't fall in the non-linear area") > Signed-off-by: Juergen Gross <jgross@suse.com> Reviewed-by: Jan Beulich <jbeulich@suse.com> > --- a/drivers/net/xen-netback/netback.c > +++ b/drivers/net/xen-netback/netback.c > @@ -530,7 +530,7 @@ static int xenvif_tx_check_gop(struct xenvif_queue *queue, > const bool sharedslot = nr_frags && > frag_get_pending_idx(&shinfo->frags[0]) == > copy_pending_idx(skb, copy_count(skb) - 1); > - int i, err; > + int i, err = 0; > > for (i = 0; i < copy_count(skb); i++) { > int newerr; I'm afraid other logic (below here) is now slightly wrong as well, in particular /* If the mapping of the first frag was OK, but * the header's copy failed, and they are * sharing a slot, send an error */ if (i == 0 && !first_shinfo && sharedslot) xenvif_idx_release(queue, pending_idx, XEN_NETIF_RSP_ERROR); else xenvif_idx_release(queue, pending_idx, XEN_NETIF_RSP_OKAY); which looks to be intended to deal with _only_ failure of the one shared part of the header, whereas "err" now can indicate an error on any earlier part as well. Jan
On 07.12.22 10:25, Jan Beulich wrote: > On 07.12.2022 08:23, Juergen Gross wrote: >> Commit ad7f402ae4f4 ("xen/netback: Ensure protocol headers don't fall in >> the non-linear area") introduced a (valid) build warning. >> >> Fix it. >> >> Fixes: ad7f402ae4f4 ("xen/netback: Ensure protocol headers don't fall in the non-linear area") >> Signed-off-by: Juergen Gross <jgross@suse.com> > > Reviewed-by: Jan Beulich <jbeulich@suse.com> > >> --- a/drivers/net/xen-netback/netback.c >> +++ b/drivers/net/xen-netback/netback.c >> @@ -530,7 +530,7 @@ static int xenvif_tx_check_gop(struct xenvif_queue *queue, >> const bool sharedslot = nr_frags && >> frag_get_pending_idx(&shinfo->frags[0]) == >> copy_pending_idx(skb, copy_count(skb) - 1); >> - int i, err; >> + int i, err = 0; >> >> for (i = 0; i < copy_count(skb); i++) { >> int newerr; > > I'm afraid other logic (below here) is now slightly wrong as well, in > particular > > /* If the mapping of the first frag was OK, but > * the header's copy failed, and they are > * sharing a slot, send an error > */ > if (i == 0 && !first_shinfo && sharedslot) > xenvif_idx_release(queue, pending_idx, > XEN_NETIF_RSP_ERROR); > else > xenvif_idx_release(queue, pending_idx, > XEN_NETIF_RSP_OKAY); > > which looks to be intended to deal with _only_ failure of the one shared > part of the header, whereas "err" now can indicate an error on any earlier > part as well. The comment at the end of that loop seems to imply this is the desired behavior: /* Remember the error: invalidate all subsequent fragments. */ err = newerr; } Juergen
On 07.12.2022 11:18, Juergen Gross wrote: > On 07.12.22 10:25, Jan Beulich wrote: >> On 07.12.2022 08:23, Juergen Gross wrote: >>> Commit ad7f402ae4f4 ("xen/netback: Ensure protocol headers don't fall in >>> the non-linear area") introduced a (valid) build warning. >>> >>> Fix it. >>> >>> Fixes: ad7f402ae4f4 ("xen/netback: Ensure protocol headers don't fall in the non-linear area") >>> Signed-off-by: Juergen Gross <jgross@suse.com> >> >> Reviewed-by: Jan Beulich <jbeulich@suse.com> >> >>> --- a/drivers/net/xen-netback/netback.c >>> +++ b/drivers/net/xen-netback/netback.c >>> @@ -530,7 +530,7 @@ static int xenvif_tx_check_gop(struct xenvif_queue *queue, >>> const bool sharedslot = nr_frags && >>> frag_get_pending_idx(&shinfo->frags[0]) == >>> copy_pending_idx(skb, copy_count(skb) - 1); >>> - int i, err; >>> + int i, err = 0; >>> >>> for (i = 0; i < copy_count(skb); i++) { >>> int newerr; >> >> I'm afraid other logic (below here) is now slightly wrong as well, in >> particular >> >> /* If the mapping of the first frag was OK, but >> * the header's copy failed, and they are >> * sharing a slot, send an error >> */ >> if (i == 0 && !first_shinfo && sharedslot) >> xenvif_idx_release(queue, pending_idx, >> XEN_NETIF_RSP_ERROR); >> else >> xenvif_idx_release(queue, pending_idx, >> XEN_NETIF_RSP_OKAY); >> >> which looks to be intended to deal with _only_ failure of the one shared >> part of the header, whereas "err" now can indicate an error on any earlier >> part as well. > > The comment at the end of that loop seems to imply this is the desired > behavior: > > /* Remember the error: invalidate all subsequent fragments. */ > err = newerr; > } This says "subsequent", whereas I was describing a situation where e.g. the first piece of header copying failed, the 2nd (shared part) succeeded, and the mapping of the rest of the shared part also succeeded. At the very least the comment in the code fragment I did quote then has become stale. Furthermore, if "all subsequent" really meant all, then in the new first loop this isn't followed either - an error response is sent only for the pieces where copying failed. Jan
On 07.12.22 11:26, Jan Beulich wrote: > On 07.12.2022 11:18, Juergen Gross wrote: >> On 07.12.22 10:25, Jan Beulich wrote: >>> On 07.12.2022 08:23, Juergen Gross wrote: >>>> Commit ad7f402ae4f4 ("xen/netback: Ensure protocol headers don't fall in >>>> the non-linear area") introduced a (valid) build warning. >>>> >>>> Fix it. >>>> >>>> Fixes: ad7f402ae4f4 ("xen/netback: Ensure protocol headers don't fall in the non-linear area") >>>> Signed-off-by: Juergen Gross <jgross@suse.com> >>> >>> Reviewed-by: Jan Beulich <jbeulich@suse.com> >>> >>>> --- a/drivers/net/xen-netback/netback.c >>>> +++ b/drivers/net/xen-netback/netback.c >>>> @@ -530,7 +530,7 @@ static int xenvif_tx_check_gop(struct xenvif_queue *queue, >>>> const bool sharedslot = nr_frags && >>>> frag_get_pending_idx(&shinfo->frags[0]) == >>>> copy_pending_idx(skb, copy_count(skb) - 1); >>>> - int i, err; >>>> + int i, err = 0; >>>> >>>> for (i = 0; i < copy_count(skb); i++) { >>>> int newerr; >>> >>> I'm afraid other logic (below here) is now slightly wrong as well, in >>> particular >>> >>> /* If the mapping of the first frag was OK, but >>> * the header's copy failed, and they are >>> * sharing a slot, send an error >>> */ >>> if (i == 0 && !first_shinfo && sharedslot) >>> xenvif_idx_release(queue, pending_idx, >>> XEN_NETIF_RSP_ERROR); >>> else >>> xenvif_idx_release(queue, pending_idx, >>> XEN_NETIF_RSP_OKAY); >>> >>> which looks to be intended to deal with _only_ failure of the one shared >>> part of the header, whereas "err" now can indicate an error on any earlier >>> part as well. >> >> The comment at the end of that loop seems to imply this is the desired >> behavior: >> >> /* Remember the error: invalidate all subsequent fragments. */ >> err = newerr; >> } > > This says "subsequent", whereas I was describing a situation where e.g. > the first piece of header copying failed, the 2nd (shared part) succeeded, > and the mapping of the rest of the shared part also succeeded. At the > very least the comment in the code fragment I did quote then has become > stale. Furthermore, if "all subsequent" really meant all, then in the > new first loop this isn't followed either - an error response is sent > only for the pieces where copying failed. Having stared at the code for quite some time now, I think there is some room for confusion: "invalidating" the frags seems not to be the same as setting the related idx to have an error. XEN_NETIF_RSP_ERROR seems to be set only for the idx which really had an error, while if any of them had one, all idx-es must be unmapped, have a status set, and returned to the frontend. And I think the code is doing this quite fine. The comments _could_ need some improvements, though. And some more restructuring could help, too (at least I think that the "goto check_frags" is a rather clumsy construct - I'd prefer splitting xenvif_tx_check_gop() into some helper functions and a rather small body calling those with e.g. different shinfo values). Juergen
On Wed, Dec 7, 2022 at 2:24 AM Juergen Gross <jgross@suse.com> wrote: > > Commit ad7f402ae4f4 ("xen/netback: Ensure protocol headers don't fall in > the non-linear area") introduced a (valid) build warning. > > Fix it. > > Fixes: ad7f402ae4f4 ("xen/netback: Ensure protocol headers don't fall in the non-linear area") > Signed-off-by: Juergen Gross <jgross@suse.com> Tested-by: Jason Andryuk <jandryuk@gmail.com> I applied ad7f402ae4f4 to 5.15.y and 5.4.y and it broke networking with my driver domains. The frontend failed to DHCP an address and it didn't look like any packets were getting through. This patch fixed networking with 5.15.y and 5.4.y. I think the commit message is worth expanding that this is more than just a build warning. Thanks, Jason
diff --git a/drivers/net/xen-netback/netback.c b/drivers/net/xen-netback/netback.c index 054ac0e897f6..bf627af723bf 100644 --- a/drivers/net/xen-netback/netback.c +++ b/drivers/net/xen-netback/netback.c @@ -530,7 +530,7 @@ static int xenvif_tx_check_gop(struct xenvif_queue *queue, const bool sharedslot = nr_frags && frag_get_pending_idx(&shinfo->frags[0]) == copy_pending_idx(skb, copy_count(skb) - 1); - int i, err; + int i, err = 0; for (i = 0; i < copy_count(skb); i++) { int newerr;