mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH net-next] net: copy routing table more efficiently in rt_dst_clone
@ 2024-02-18 13:35 Oliver Crumrine
  2024-02-21  2:44 ` David Ahern
  0 siblings, 1 reply; 3+ messages in thread
From: Oliver Crumrine @ 2024-02-18 13:35 UTC (permalink / raw)
  To: davem, dsahern, edumazet, kuba, pabeni; +Cc: netdev, linux-kernel

Instead of copying field-by-field, copy the entire struct at once. This
should lead to a performance improvment in rt_dst_clone.

Signed-off-by: Oliver Crumrine <ozlinuxc@gmail.com>
---
 net/ipv4/route.c | 16 +---------------
 1 file changed, 1 insertion(+), 15 deletions(-)

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;
 		new_rt->rt_genid = rt_genid_ipv4(dev_net(dev));
-		new_rt->rt_flags = rt->rt_flags;
-		new_rt->rt_type = rt->rt_type;
-		new_rt->rt_is_input = rt->rt_is_input;
-		new_rt->rt_iif = rt->rt_iif;
-		new_rt->rt_pmtu = rt->rt_pmtu;
-		new_rt->rt_mtu_locked = rt->rt_mtu_locked;
-		new_rt->rt_gw_family = rt->rt_gw_family;
-		if (rt->rt_gw_family == AF_INET)
-			new_rt->rt_gw4 = rt->rt_gw4;
-		else if (rt->rt_gw_family == AF_INET6)
-			new_rt->rt_gw6 = rt->rt_gw6;
-
-		new_rt->dst.input = rt->dst.input;
-		new_rt->dst.output = rt->dst.output;
-		new_rt->dst.error = rt->dst.error;
 		new_rt->dst.lastuse = jiffies;
 		new_rt->dst.lwtstate = lwtstate_get(rt->dst.lwtstate);
 	}
-- 
2.43.0


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

end of thread, other threads:[~2024-02-21 23:50 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-02-18 13:35 [PATCH net-next] net: copy routing table more efficiently in rt_dst_clone Oliver Crumrine
2024-02-21  2:44 ` David Ahern
2024-02-21 18:50   ` Oliver Crumrine

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®