Received: by 2002:a05:6359:6284:b0:131:369:b2a3 with SMTP id se4csp444120rwb; Fri, 4 Aug 2023 15:46:58 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFwxYilYN1NFYOnR4yodt/xi/FdgTf7IGDjIbwjxzCKpR3Eki8Xbc5xFMYWVxj0YSsBUU8G X-Received: by 2002:ac2:4474:0:b0:4fa:f96c:745f with SMTP id y20-20020ac24474000000b004faf96c745fmr2195216lfl.38.1691189218089; Fri, 04 Aug 2023 15:46:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1691189218; cv=none; d=google.com; s=arc-20160816; b=uOOKs+hdphJdVJQtEV9opFswn6RAiAxF20izAgoAVA0tobUn01OoMpH5qrSSCG8ZoQ prRROuZFwQXDJOAjIG6nFyPt/u3iTP6VKjziJ2h9/KNfenxtVK98NadTC7DMUIZ6xZLU uojutEpMFw7qvMJAbsxZMU9A20SZhyy5HuKY/iYeSaoFobobdt+sPxW2TuavgvpTXHXf Lg8WxmCFmYx4cnoSNq9aU5xacBaChVFF3h9r6qJHcrCGmN+2rH/9mar4U6oVuJjFDRG1 1Ut/RChnM70vFPzyeMzXfHvbVsYrPFSsJOxXujUblxPBRiOA/5BV/axA/IIMwPiks4Oe 7XOg== 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:mime-version:date :dkim-signature:message-id; bh=E1eN8tOuww36HZPXLIuSgwhpOWc+BiApnQsrkjpB8Ks=; fh=07P41/ZJS6fOmk1wbJ+feHZltwYRM9io7wqtfK2a6k0=; b=eb1T95aopbNnQXmodTKVITocr1eVMzXf1ofrDEu+3HWK838COTs1lbiCdblvudc1V5 RshLZLt63ahXRe9Jk5QqhhQly1o8DfEyJZd3LkF+nlSJeWioWPmYWV0IUVzdf9zubxeP WxqCRlLllgyGrsDUWQvWp0K/k0tc9o8Xv+qKO9pc76yK7mAK43y2FMiTVWw+NQwgciW2 HyjNNu9tj/vd8YGQM/rHEtxtF1KCIJwD3gLT6tkOgdgQqflrEJf3z/0Hlj+5HKKGOvsQ uLYc/S27GvMAXG2Qdqgj+TalgxEarwTOJ187AIW2U3IMKXpelyS51PrNcfid3xl3ybvH ESkQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=g7gLkCsY; 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=NONE sp=NONE dis=NONE) header.from=linux.dev Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id h23-20020a1709066d9700b0099bcba9df15si2060566ejt.605.2023.08.04.15.46.31; Fri, 04 Aug 2023 15:46:58 -0700 (PDT) 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=@linux.dev header.s=key1 header.b=g7gLkCsY; 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=NONE sp=NONE dis=NONE) header.from=linux.dev Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229726AbjHDU5T (ORCPT + 99 others); Fri, 4 Aug 2023 16:57:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56670 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229553AbjHDU5S (ORCPT ); Fri, 4 Aug 2023 16:57:18 -0400 X-Greylist: delayed 471 seconds by postgrey-1.37 at lindbergh.monkeyblade.net; Fri, 04 Aug 2023 13:57:17 PDT Received: from out-89.mta0.migadu.com (out-89.mta0.migadu.com [IPv6:2001:41d0:1004:224b::59]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id ACCC710CA for ; Fri, 4 Aug 2023 13:57:17 -0700 (PDT) Message-ID: <3e38a143-b683-6368-8e76-277394155bc6@linux.dev> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1691182163; 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=E1eN8tOuww36HZPXLIuSgwhpOWc+BiApnQsrkjpB8Ks=; b=g7gLkCsYN/MAuFNNC+BDN7awxDKUINupinpjfY3fTYaXuKEuxAQZ51HBbu0376liiHg6X0 2RnwG2OGU0iRp80CxY7bu5SiyMKQmRa/3jx5heAtSWnN7nYPWQC69F6olNomt/z86uspBi AVvwcBeMYOESSVIERkVnQEDiJtrgFDQ= Date: Fri, 4 Aug 2023 21:49:19 +0100 MIME-Version: 1.0 Subject: Re: [PATCH] net/ipv4: return the real errno instead of -EINVAL Content-Language: en-US To: yang.yang29@zte.com.cn, davem@davemloft.net Cc: dsahern@kernel.org, edumazet@google.com, kuba@kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org References: <202308041648338823694@zte.com.cn> X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Vadim Fedorenko In-Reply-To: <202308041648338823694@zte.com.cn> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Migadu-Flow: FLOW_OUT X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED autolearn=unavailable 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: X-Mailing-List: linux-kernel@vger.kernel.org On 04/08/2023 09:48, yang.yang29@zte.com.cn wrote: > From: xu xin > > For now, no matter what error pointer ip_neigh_for_gw() returns, > ip_finish_output2() always return -EINVAL, which may mislead the upper > users. > > For exemple, an application uses sendto to send an UDP packet, but when the > neighbor table overflows, sendto() will get a value of -EINVAL, and it will > cause users to waste a lot of time checking parameters for errors. > > Return the real errno instead of -EINVAL. > > Signed-off-by: xu xin > Reviewed-by: Yang Yang > Cc: Si Hao > Cc: Dai Shixin > Cc: Jiang Xuexin > --- > net/ipv4/ip_output.c | 9 ++++----- > 1 file changed, 4 insertions(+), 5 deletions(-) > > diff --git a/net/ipv4/ip_output.c b/net/ipv4/ip_output.c > index 6ba1a0fafbaa..2d7cf083dff9 100644 > --- a/net/ipv4/ip_output.c > +++ b/net/ipv4/ip_output.c > @@ -201,6 +201,7 @@ static int ip_finish_output2(struct net *net, struct sock *sk, struct sk_buff *s > unsigned int hh_len = LL_RESERVED_SPACE(dev); > struct neighbour *neigh; > bool is_v6gw = false; > + int res; > > if (rt->rt_type == RTN_MULTICAST) { > IP_UPD_PO_STATS(net, IPSTATS_MIB_OUTMCAST, skb->len); > @@ -214,8 +215,7 @@ static int ip_finish_output2(struct net *net, struct sock *sk, struct sk_buff *s > } > > if (lwtunnel_xmit_redirect(dst->lwtstate)) { > - int res = lwtunnel_xmit(skb); > - > + res = lwtunnel_xmit(skb); > if (res < 0 || res == LWTUNNEL_XMIT_DONE) > return res; > } > @@ -223,8 +223,6 @@ static int ip_finish_output2(struct net *net, struct sock *sk, struct sk_buff *s > rcu_read_lock(); > neigh = ip_neigh_for_gw(rt, skb, &is_v6gw); > if (!IS_ERR(neigh)) { > - int res; > - > sock_confirm_neigh(skb, neigh); > /* if crossing protocols, can not use the cached header */ > res = neigh_output(neigh, skb, is_v6gw); > @@ -236,7 +234,8 @@ static int ip_finish_output2(struct net *net, struct sock *sk, struct sk_buff *s > net_dbg_ratelimited("%s: No header cache and no neighbour!\n", > __func__); > kfree_skb_reason(skb, SKB_DROP_REASON_NEIGH_CREATEFAIL); > - return -EINVAL; > + res = PTR_ERR(neigh); > + return res; I believe this part could be written as - return -EINVAL; + return PTR_ERR(neigh); and there is no need to change the code is other places. This will be easier to track/backport. > } > > static int ip_finish_output_gso(struct net *net, struct sock *sk,