Re: [PATCH net-next] net: copy routing table more efficiently in rt_dst_clone

From: Oliver Crumrine
Date: Wed Feb 21 2024 - 18:52:42 EST


On Tue, Feb 20, 2024 at 07:44:24PM -0700, David Ahern wrote:
Hi David,

You are correct that rtable is a container of dst_entry, and the
previous code copied not only the fields of rtable but also the fields
of dst_entry. However, the *new_rt = *rt line not only copies the fields
of rtable, but also the fields of dst_entry.

I have demonstrated this by generating a random number and putting it in
the "expired" field of the dst_entry that is part of rt, and the printing
the random number that was generated. After the copy, I printed the
expired field of the dst_entry that is part of new_rt and the numbers
matched. This proves that not only the fields that were part of rtable
were copied but also the fields of dst_entry.

Thanks,
Oliver
> On 2/18/24 6:35 AM, Oliver Crumrine wrote:
> > diff --git a/net/ipv4/route.c b/net/ipv4/route.c
> > index 16615d107cf0..ebb17c3a0dec 100644
> > --- a/net/ipv4/route.c
> > +++ b/net/ipv4/route.c
> > @@ -1664,22 +1664,8 @@ struct rtable *rt_dst_clone(struct net_device *dev, struct rtable *rt)
> > rt->dst.flags);
> >
> > if (new_rt) {
> > + *new_rt = *rt;
>
> rtable is a container of dst_entry, so this is copying those fields as well.
>
> pw-bot: reject
>