Received: by 2002:a05:7412:b130:b0:e2:908c:2ebd with SMTP id az48csp1676895rdb; Sun, 19 Nov 2023 06:08:33 -0800 (PST) X-Google-Smtp-Source: AGHT+IFMN52a+2B3yx2aTaXanFTxIm3kUcOSbNlvQcc/7HUajA7gG1DmokVqxpl4Cfxo9GdIZ9UY X-Received: by 2002:a05:6a00:8d87:b0:6c6:b762:ad8c with SMTP id im7-20020a056a008d8700b006c6b762ad8cmr3922465pfb.0.1700402912711; Sun, 19 Nov 2023 06:08:32 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700402912; cv=none; d=google.com; s=arc-20160816; b=sw3ySPNMHGqH2XOm0oLPCjYpWL8QT92nrt9U2va/FYd5xQhXX62ovmnMLyv2MYNXYn vpMNAYbh1XVrx+9sxFAMVNPcLltLFCqZW9Vttf+MKVsmt5F0ej8+iNaNgnsGjzGeatvm 4HhxMGOnqQU32hM99sdiMZuAzg6x56gIkNuwKTYCRYCK8n7gBrQKV9Dho/LUml1iSjd0 TH+GSWnu8zealYCPXE8ZAJcb4Uw4RPEg0BFMqw7ZnGee/60dlRxUHFJ5yTddfhlSmPkG pfpFakxMcf2lHh+i7qWCltVevHz+CaAgHVh38w4D5nA06ihw55MVtvPSbYl2F6HLkAqa f39Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id; bh=hOTuisD90J/kvlvluMFWwMsb2Qzos9hj33v0LzjAWVE=; fh=X81yWT34jGDqoDEdIff29YDTpO9D3ZdkFedZrn79mHw=; b=L0RJT2qsC2ODbUDV0TVcF4Qb5jq+Zbu2p0kAQpwrVRHy1dBa/Ye1+c+GX1ZYYxtE7P vuhvMx/Ymav+sadgPxZETYmz4g/Yqwo3Qe+tp4ozRyJQ48gLV96jVzvCfm8MNCLZ8ztA /+tPYP631GlveBSlwCGMRAZ8FS9lzODrFbrIToxqSEDexEoFZSq9DV7oGdJuLN1Xy068 fP2aSpV47oIqI/ej+rt8FqtKwI0rgp04ThagOjkxwhM9AWIMvGg35ezY+ozkD4fwcTRu 25nvNK+s7gRlYqP559jqsfU1Ld+lEui1j1l8GmJ9Sop+141TGmbxBXZ3ZR9b70LphuEk lobA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from groat.vger.email (groat.vger.email. [23.128.96.35]) by mx.google.com with ESMTPS id b21-20020a056a000a9500b006be062ed5c6si6342783pfl.276.2023.11.19.06.08.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 19 Nov 2023 06:08:32 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) client-ip=23.128.96.35; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by groat.vger.email (Postfix) with ESMTP id 2275D80613A2; Sun, 19 Nov 2023 06:08:30 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229715AbjKSOEx (ORCPT + 99 others); Sun, 19 Nov 2023 09:04:53 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43376 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229441AbjKSOEv (ORCPT ); Sun, 19 Nov 2023 09:04:51 -0500 Received: from mailgw.kylinos.cn (mailgw.kylinos.cn [124.126.103.232]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5A9F8E6; Sun, 19 Nov 2023 06:04:37 -0800 (PST) X-UUID: fd166c3e721240ddbd62ef20f841775c-20231119 X-CID-P-RULE: Release_Ham X-CID-O-INFO: VERSION:1.1.32,REQID:73491798-38e8-4b57-91e5-290706a0f642,IP:5,U RL:0,TC:0,Content:-5,EDM:0,RT:0,SF:-15,FILE:0,BULK:0,RULE:Release_Ham,ACTI ON:release,TS:-15 X-CID-INFO: VERSION:1.1.32,REQID:73491798-38e8-4b57-91e5-290706a0f642,IP:5,URL :0,TC:0,Content:-5,EDM:0,RT:0,SF:-15,FILE:0,BULK:0,RULE:Release_Ham,ACTION :release,TS:-15 X-CID-META: VersionHash:5f78ec9,CLOUDID:ce9fd172-1bd3-4f48-b671-ada88705968c,B ulkID:23111801152865C88OMS,BulkQuantity:3,Recheck:0,SF:19|44|64|66|24|17|1 02,TC:nil,Content:0,EDM:-3,IP:-2,URL:11|1,File:nil,Bulk:40,QS:nil,BEC:nil, COL:0,OSI:0,OSA:0,AV:0,LES:1,SPR:NO,DKR:0,DKP:0,BRR:0,BRE:0 X-CID-BVR: 0 X-CID-BAS: 0,_,0,_ X-CID-FACTOR: TF_CID_SPAM_FSD,TF_CID_SPAM_FSI,TF_CID_SPAM_ULN,TF_CID_SPAM_SNR, TF_CID_SPAM_FAS X-UUID: fd166c3e721240ddbd62ef20f841775c-20231119 X-User: chentao@kylinos.cn Received: from [172.20.15.254] [(116.128.244.169)] by mailgw (envelope-from ) (Generic MTA) with ESMTP id 1059029858; Sun, 19 Nov 2023 22:04:19 +0800 Message-ID: Date: Sun, 19 Nov 2023 22:04:18 +0800 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH] ipv4: Correct/silence an endian warning in __ip_do_redirect Content-Language: en-US To: Eric Dumazet Cc: davem@davemloft.net, dsahern@kernel.org, kuba@kernel.org, pabeni@redhat.com, kunwu.chan@hotmail.com, netdev@vger.kernel.org, linux-kernel@vger.kernel.org References: <20231117152728.2286551-1-chentao@kylinos.cn> From: Kunwu Chan In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-0.8 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on groat.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (groat.vger.email [0.0.0.0]); Sun, 19 Nov 2023 06:08:30 -0800 (PST) Hi Eric, Thank you so much for taking the time to guide me, I'm a rookie who really wants to do my part for the kernel, and I can't get started, so I thought about eliminating some of the sparse warnings. I've looked at some other commits and thought I could resolve the alert this way, sorry for the trouble. Follow your suggestion: 1. I will add a 'Fixes' tag as follows: 'Fixes: 969447f226b4 ("ipv4: use new_gw for redirect neigh lookup")' 2. Refer to the modification method of commit 3c42b2019863b327caa233072c50739d4144dd16, and modify the patch to: 'n = __ipv4_neigh_lookup(rt->dst.dev, (__force u32)new_gw); ' On 2023/11/18 01:15, Eric Dumazet wrote: > On Fri, Nov 17, 2023 at 6:07 PM Kunwu Chan wrote: >> >> net/ipv4/route.c:783:46: warning: incorrect type in argument 2 (different base types) >> net/ipv4/route.c:783:46: expected unsigned int [usertype] key >> net/ipv4/route.c:783:46: got restricted __be32 [usertype] new_gw >> >> Signed-off-by: Kunwu Chan > > We need Fixes: tag for networking patches. > >> --- >> net/ipv4/route.c | 2 +- >> 1 file changed, 1 insertion(+), 1 deletion(-) >> >> diff --git a/net/ipv4/route.c b/net/ipv4/route.c >> index 3290a4442b4a..e8a542c6b031 100644 >> --- a/net/ipv4/route.c >> +++ b/net/ipv4/route.c >> @@ -780,7 +780,7 @@ static void __ip_do_redirect(struct rtable *rt, struct sk_buff *skb, struct flow >> goto reject_redirect; >> } >> >> - n = __ipv4_neigh_lookup(rt->dst.dev, new_gw); >> + n = __ipv4_neigh_lookup(rt->dst.dev, be32_to_cpu(new_gw)); >> if (!n) >> n = neigh_create(&arp_tbl, &new_gw, rt->dst.dev); >> if (!IS_ERR(n)) { >> -- >> 2.34.1 >> > > How was this patch tested ? > > You are 'fixing' sparse warnings by replacing them with real bugs. > > be32_to_cpu() is going to swap bytes on x86, so the lookup will fail horribly. > > Here, if you must silence sparse, you want (__force u32)new_gw > > Look at this commit for a template. > > commit 3c42b2019863b327caa233072c50739d4144dd16