[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <2853344436a97a9a0aaeea60ce11e544f74d2511.camel@redhat.com>
Date: Mon, 18 Nov 2019 17:44:26 +0100
From: Paolo Abeni <pabeni@...hat.com>
To: Edward Cree <ecree@...arflare.com>, netdev@...r.kernel.org
Cc: "David S. Miller" <davem@...emloft.net>,
Willem de Bruijn <willemdebruijn.kernel@...il.com>
Subject: Re: [PATCH net-next 2/2] ipv4: use dst hint for ipv4 list receive
On Mon, 2019-11-18 at 16:15 +0000, Edward Cree wrote:
> @@ -538,6 +543,7 @@ static void ip_sublist_rcv_finish(struct list_head *head)
> > static void ip_list_rcv_finish(struct net *net, struct sock *sk,
> > struct list_head *head)
> > {
> > + struct ip_route_input_hint _hint, *hint = NULL;
> > struct dst_entry *curr_dst = NULL;
> > struct sk_buff *skb, *next;
> > struct list_head sublist;
> > @@ -554,11 +560,24 @@ static void ip_list_rcv_finish(struct net *net, struct sock *sk,
> > skb = l3mdev_ip_rcv(skb);
> > if (!skb)
> > continue;
> > - if (ip_rcv_finish_core(net, sk, skb, dev) == NET_RX_DROP)
> > + if (ip_rcv_finish_core(net, sk, skb, dev, hint) == NET_RX_DROP)
> > continue;
> >
> > dst = skb_dst(skb);
> > if (curr_dst != dst) {
> > + struct rtable *rt = (struct rtable *)dst;
> > +
> > + if (!net->ipv4.fib_has_custom_rules &&
> > + rt->rt_type != RTN_BROADCAST) {
> > + _hint.refdst = skb->_skb_refdst;
> > + _hint.daddr = ip_hdr(skb)->daddr;
> > + _hint.tos = ip_hdr(skb)->tos;
> > + _hint.local = rt->rt_type == RTN_LOCAL;
> > + hint = &_hint;
> > + } else {
> > + hint = NULL;
> > + }
> Perhaps factor this block out into a function? Just because it's getting
> deeply indented and giving it a name would make it more obvious what it's
> for. hint = ipv4_extract_route_hint(skb, &_hint)?
yep, I like the idea, will do in the next iteration.
>
> > +
> > /* dispatch old sublist */
> > if (!list_empty(&sublist))
> > ip_sublist_rcv_finish(&sublist);
> > diff --git a/net/ipv4/route.c b/net/ipv4/route.c
> > index dcc4fa10138d..b0ddff17db80 100644
> > --- a/net/ipv4/route.c
> > +++ b/net/ipv4/route.c
> > @@ -2019,6 +2019,44 @@ static int ip_mkroute_input(struct sk_buff *skb,
> > return __mkroute_input(skb, res, in_dev, daddr, saddr, tos);
> > }
> >
> > +/* Implements all the saddr-related checks as ip_route_input_slow(),
> > + * assuming daddr is valid and this is not a local broadcast.
> > + * Uses the provided hint instead of performing a route lookup.
> > + */
> > +int ip_route_use_hint(struct sk_buff *skb, __be32 daddr, __be32 saddr,
> > + u8 tos, struct net_device *dev,
> > + struct ip_route_input_hint *hint)
> Mostly I like the idea of these patches, but it bugs me that this seems
> to be reimplementing a little bit, and might get out of sync. Is it
> possible to factor out the checks from ip_route_input_slow() and just
> call them here?
> Otherwise maybe stick something in the comment to ip_route_input_slow()
> reminding to propagate changes to ip_route_use_hint()?
>
> Or perhaps better still would be to come up with a single function that
> always takes a hint, that may be NULL, in which case it performs normal
> routing; and use that in all paths? (Plumbing the hint through from
> ip_route_input_noref() etc.)
I experimented a bit with the latter option before restricting to
!RTN_BROADCAST, and it make the code quite uglier. Anyhow, preserving
the !RTN_BROADCAST restriction for hint usage, I think it could work.
Let me try that.
Thank you for the feedback!
Paolo
Powered by blists - more mailing lists