All of lore.kernel.org
 help / color / mirror / Atom feed
From: Kuniyuki Iwashima <kuniyu@amazon.com>
To: <xu.xin.sc@gmail.com>
Cc: <davem@davemloft.net>, <dsahern@kernel.org>, <kuba@kernel.org>,
	<linux-kernel@vger.kernel.org>, <netdev@vger.kernel.org>,
	<pabeni@redhat.com>, <si.hao@zte.com.cn>, <xu.xin16@zte.com.cn>,
	<yang.yang29@zte.com.cn>, <kuniyu@amazon.com>
Subject: Re: [PATCH linux-next v2] net/ipv4: return the real errno instead of -EINVAL
Date: Mon, 7 Aug 2023 13:17:33 -0700	[thread overview]
Message-ID: <20230807201733.45450-1-kuniyu@amazon.com> (raw)
In-Reply-To: <20230807015408.248237-1-xu.xin16@zte.com.cn>

From:   xu.xin.sc@gmail.com
Date:   Mon,  7 Aug 2023 01:54:08 +0000
> From: xu xin <xu.xin16@zte.com.cn>
> 
> 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 <xu.xin16@zte.com.cn>
> Reviewed-by: Yang Yang <yang.yang29@zte.com.cn>

Recently I was also investigating a similar issue that ip_finish_output2()
returned the fixed -EINVAL.  But in my case, arp_constructor() failed with
-EINVAL, and ___neigh_create() returned ERR_PTR(-EINVAL);

So, there are still confusing paths even with this patch though, the change
would be useful.

Reviewed-by: Kuniyuki Iwashima <kuniyu@amazon.com>

Thanks!


> Cc: Si Hao <si.hao@zte.com.cn>
> ---
>  net/ipv4/ip_output.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/net/ipv4/ip_output.c b/net/ipv4/ip_output.c
> index 6ba1a0fafbaa..f28c87533a46 100644
> --- a/net/ipv4/ip_output.c
> +++ b/net/ipv4/ip_output.c
> @@ -236,7 +236,7 @@ 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;
> +	return PTR_ERR(neigh);
>  }
>  
>  static int ip_finish_output_gso(struct net *net, struct sock *sk,
> -- 
> 2.15.2

  reply	other threads:[~2023-08-07 20:18 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-08-07  1:54 [PATCH linux-next v2] net/ipv4: return the real errno instead of -EINVAL xu.xin.sc
2023-08-07 20:17 ` Kuniyuki Iwashima [this message]
2023-08-08 13:11 ` Vadim Fedorenko
2023-08-08 23:00 ` patchwork-bot+netdevbpf

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230807201733.45450-1-kuniyu@amazon.com \
    --to=kuniyu@amazon.com \
    --cc=davem@davemloft.net \
    --cc=dsahern@kernel.org \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=si.hao@zte.com.cn \
    --cc=xu.xin.sc@gmail.com \
    --cc=xu.xin16@zte.com.cn \
    --cc=yang.yang29@zte.com.cn \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.