linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH linux-next v2] net/ipv4: return the real errno instead of -EINVAL
@ 2023-08-07  1:54 xu.xin.sc
  2023-08-07 20:17 ` Kuniyuki Iwashima
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: xu.xin.sc @ 2023-08-07  1:54 UTC (permalink / raw)
  To: davem
  Cc: dsahern, kuba, pabeni, netdev, linux-kernel, xu xin, Yang Yang, Si Hao

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>
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



^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH linux-next v2] net/ipv4: return the real errno instead of -EINVAL
  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
  2023-08-08 13:11 ` Vadim Fedorenko
  2023-08-08 23:00 ` patchwork-bot+netdevbpf
  2 siblings, 0 replies; 4+ messages in thread
From: Kuniyuki Iwashima @ 2023-08-07 20:17 UTC (permalink / raw)
  To: xu.xin.sc
  Cc: davem, dsahern, kuba, linux-kernel, netdev, pabeni, si.hao,
	xu.xin16, yang.yang29, kuniyu

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

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH linux-next v2] net/ipv4: return the real errno instead of -EINVAL
  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
@ 2023-08-08 13:11 ` Vadim Fedorenko
  2023-08-08 23:00 ` patchwork-bot+netdevbpf
  2 siblings, 0 replies; 4+ messages in thread
From: Vadim Fedorenko @ 2023-08-08 13:11 UTC (permalink / raw)
  To: xu.xin.sc
  Cc: dsahern, kuba, pabeni, netdev, linux-kernel, xu xin, Yang Yang,
	Si Hao, davem

On 07/08/2023 02:54, xu.xin.sc@gmail.com wrote:
> 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>
> Cc: Si Hao <si.hao@zte.com.cn>
> ---

Reviewed-by: Vadim Fedorenko <vadim.fedorenko@linux.dev>

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH linux-next v2] net/ipv4: return the real errno instead of -EINVAL
  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
  2023-08-08 13:11 ` Vadim Fedorenko
@ 2023-08-08 23:00 ` patchwork-bot+netdevbpf
  2 siblings, 0 replies; 4+ messages in thread
From: patchwork-bot+netdevbpf @ 2023-08-08 23:00 UTC (permalink / raw)
  To: xu
  Cc: davem, dsahern, kuba, pabeni, netdev, linux-kernel, xu.xin16,
	yang.yang29, si.hao

Hello:

This patch was applied to netdev/net-next.git (main)
by Jakub Kicinski <kuba@kernel.org>:

On Mon,  7 Aug 2023 01:54:08 +0000 you wrote:
> 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.
> 
> [...]

Here is the summary with links:
  - [linux-next,v2] net/ipv4: return the real errno instead of -EINVAL
    https://git.kernel.org/netdev/net-next/c/c67180efc507

You are awesome, thank you!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2023-08-08 23:00 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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
2023-08-08 13:11 ` Vadim Fedorenko
2023-08-08 23:00 ` patchwork-bot+netdevbpf

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).