Ethernet Bridge development
 help / color / mirror / Atom feed
From: Paolo Abeni <pabeni@redhat.com>
To: Menglong Dong <menglong8.dong@gmail.com>
Cc: davem@davemloft.net, edumazet@google.com, kuba@kernel.org,
	horms@kernel.org, dsahern@kernel.org, pablo@netfilter.org,
	kadlec@netfilter.org, roopa@nvidia.com, razor@blackwall.org,
	gnault@redhat.com, bigeasy@linutronix.de, hawk@kernel.org,
	idosch@nvidia.com, dongml2@chinatelecom.cn,
	netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
	netfilter-devel@vger.kernel.org, coreteam@netfilter.org,
	bridge@lists.linux.dev, bpf@vger.kernel.org
Subject: Re: [PATCH RESEND net-next v4 9/9] net: ip: make ip_route_use_hint() return drop reasons
Date: Tue, 5 Nov 2024 12:28:41 +0100	[thread overview]
Message-ID: <8f83725e-1ea9-438f-8ab1-ff528ca761fb@redhat.com> (raw)
In-Reply-To: <20241030014145.1409628-10-dongml2@chinatelecom.cn>

On 10/30/24 02:41, Menglong Dong wrote:
> diff --git a/net/ipv4/route.c b/net/ipv4/route.c
> index e248e5577d0e..7f969c865c81 100644
> --- a/net/ipv4/route.c
> +++ b/net/ipv4/route.c
> @@ -2142,28 +2142,34 @@ ip_mkroute_input(struct sk_buff *skb, struct fib_result *res,
>   * assuming daddr is valid and the destination is not a local broadcast one.
>   * Uses the provided hint instead of performing a route lookup.
>   */
> -int ip_route_use_hint(struct sk_buff *skb, __be32 daddr, __be32 saddr,
> -		      dscp_t dscp, struct net_device *dev,
> -		      const struct sk_buff *hint)
> +enum skb_drop_reason
> +ip_route_use_hint(struct sk_buff *skb, __be32 daddr, __be32 saddr,
> +		  dscp_t dscp, struct net_device *dev,
> +		  const struct sk_buff *hint)
>  {
> +	enum skb_drop_reason reason = SKB_DROP_REASON_NOT_SPECIFIED;
>  	struct in_device *in_dev = __in_dev_get_rcu(dev);
>  	struct rtable *rt = skb_rtable(hint);
>  	struct net *net = dev_net(dev);
> -	enum skb_drop_reason reason;
> -	int err = -EINVAL;
>  	u32 tag = 0;
>  
>  	if (!in_dev)
> -		return -EINVAL;
> +		return reason;
>  
> -	if (ipv4_is_multicast(saddr) || ipv4_is_lbcast(saddr))
> +	if (ipv4_is_multicast(saddr) || ipv4_is_lbcast(saddr)) {
> +		reason = SKB_DROP_REASON_IP_INVALID_SOURCE;
>  		goto martian_source;
> +	}
>  
> -	if (ipv4_is_zeronet(saddr))
> +	if (ipv4_is_zeronet(saddr)) {
> +		reason = SKB_DROP_REASON_IP_INVALID_SOURCE;
>  		goto martian_source;
> +	}
>  
> -	if (ipv4_is_loopback(saddr) && !IN_DEV_NET_ROUTE_LOCALNET(in_dev, net))
> +	if (ipv4_is_loopback(saddr) && !IN_DEV_NET_ROUTE_LOCALNET(in_dev, net)) {
> +		reason = IP_LOCALNET;
>  		goto martian_source;
> +	}
>  
>  	if (rt->rt_type != RTN_LOCAL)
>  		goto skip_validate_source;

Please explicitly replace also the

	return 0;

with

	return SKB_NOT_DROPPED_YET;

So that is clear the drop reason is always specified.

Thanks,

Paolo


  reply	other threads:[~2024-11-05 11:28 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-10-30  1:41 [PATCH RESEND net-next v4 0/9] net: ip: add drop reasons to input route Menglong Dong
2024-10-30  1:41 ` [PATCH RESEND net-next v4 1/9] net: ip: make fib_validate_source() support drop reasons Menglong Dong
2024-10-30  1:41 ` [PATCH RESEND net-next v4 2/9] net: ip: make ip_route_input_mc() return drop reason Menglong Dong
2024-10-30  1:41 ` [PATCH RESEND net-next v4 3/9] net: ip: make ip_mc_validate_source() " Menglong Dong
2024-10-30  1:41 ` [PATCH RESEND net-next v4 4/9] net: ip: make ip_route_input_slow() return drop reasons Menglong Dong
2024-10-30  1:41 ` [PATCH RESEND net-next v4 5/9] net: ip: make ip_route_input_rcu() " Menglong Dong
2024-10-30  1:41 ` [PATCH RESEND net-next v4 6/9] net: ip: make ip_route_input_noref() " Menglong Dong
2024-11-05 11:22   ` Paolo Abeni
2024-11-06  9:40     ` Menglong Dong
2024-10-30  1:41 ` [PATCH RESEND net-next v4 7/9] net: ip: make ip_route_input() " Menglong Dong
2024-10-30  1:41 ` [PATCH RESEND net-next v4 8/9] net: ip: make ip_mkroute_input/__mkroute_input " Menglong Dong
2024-11-05 11:25   ` Paolo Abeni
2024-11-06 11:58     ` Menglong Dong
2024-10-30  1:41 ` [PATCH RESEND net-next v4 9/9] net: ip: make ip_route_use_hint() " Menglong Dong
2024-11-05 11:28   ` Paolo Abeni [this message]
2024-11-06 11:59     ` Menglong Dong

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=8f83725e-1ea9-438f-8ab1-ff528ca761fb@redhat.com \
    --to=pabeni@redhat.com \
    --cc=bigeasy@linutronix.de \
    --cc=bpf@vger.kernel.org \
    --cc=bridge@lists.linux.dev \
    --cc=coreteam@netfilter.org \
    --cc=davem@davemloft.net \
    --cc=dongml2@chinatelecom.cn \
    --cc=dsahern@kernel.org \
    --cc=edumazet@google.com \
    --cc=gnault@redhat.com \
    --cc=hawk@kernel.org \
    --cc=horms@kernel.org \
    --cc=idosch@nvidia.com \
    --cc=kadlec@netfilter.org \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=menglong8.dong@gmail.com \
    --cc=netdev@vger.kernel.org \
    --cc=netfilter-devel@vger.kernel.org \
    --cc=pablo@netfilter.org \
    --cc=razor@blackwall.org \
    --cc=roopa@nvidia.com \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox