[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <CADxym3YK5QYHs8oFwY8FQdcpuQSSY5N=Pj8N40U+vaUdi4er-w@mail.gmail.com>
Date: Wed, 6 Nov 2024 19:59:18 +0800
From: Menglong Dong <menglong8.dong@...il.com>
To: Paolo Abeni <pabeni@...hat.com>
Cc: davem@...emloft.net, edumazet@...gle.com, kuba@...nel.org,
horms@...nel.org, dsahern@...nel.org, pablo@...filter.org,
kadlec@...filter.org, roopa@...dia.com, razor@...ckwall.org,
gnault@...hat.com, bigeasy@...utronix.de, hawk@...nel.org, idosch@...dia.com,
dongml2@...natelecom.cn, netdev@...r.kernel.org, linux-kernel@...r.kernel.org,
netfilter-devel@...r.kernel.org, coreteam@...filter.org,
bridge@...ts.linux.dev, bpf@...r.kernel.org
Subject: Re: [PATCH RESEND net-next v4 9/9] net: ip: make ip_route_use_hint()
return drop reasons
On Tue, Nov 5, 2024 at 7:28 PM Paolo Abeni <pabeni@...hat.com> wrote:
>
> 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.
Okay!
Thanks!
Menglong Dong
> Thanks,
>
> Paolo
>
Powered by blists - more mailing lists