Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

net: use indirect call helpers for dst_mtu

This patch avoids the indirect call for the common case:
ip6_mtu and ipv4_mtu

Signed-off-by: Brian Vazquez <brianvv@google.com>
Signed-off-by: Jakub Kicinski <kuba@kernel.org>

authored by

Brian Vazquez and committed by
Jakub Kicinski
f67fbeae 6585d7dc

+11 -5
+3 -1
include/net/dst.h
··· 194 194 return dst_metric(dst, RTAX_FEATURES) & feature; 195 195 } 196 196 197 + INDIRECT_CALLABLE_DECLARE(unsigned int ip6_mtu(const struct dst_entry *)); 198 + INDIRECT_CALLABLE_DECLARE(unsigned int ipv4_mtu(const struct dst_entry *)); 197 199 static inline u32 dst_mtu(const struct dst_entry *dst) 198 200 { 199 - return dst->ops->mtu(dst); 201 + return INDIRECT_CALL_INET(dst->ops->mtu, ip6_mtu, ipv4_mtu, dst); 200 202 } 201 203 202 204 /* RTT metrics are stored in milliseconds for user ABI, but used as jiffies */
+4 -2
net/ipv4/route.c
··· 135 135 136 136 static struct dst_entry *ipv4_dst_check(struct dst_entry *dst, u32 cookie); 137 137 static unsigned int ipv4_default_advmss(const struct dst_entry *dst); 138 - static unsigned int ipv4_mtu(const struct dst_entry *dst); 138 + INDIRECT_CALLABLE_SCOPE 139 + unsigned int ipv4_mtu(const struct dst_entry *dst); 139 140 static struct dst_entry *ipv4_negative_advice(struct dst_entry *dst); 140 141 static void ipv4_link_failure(struct sk_buff *skb); 141 142 static void ip_rt_update_pmtu(struct dst_entry *dst, struct sock *sk, ··· 1312 1311 return min(advmss, IPV4_MAX_PMTU - header_size); 1313 1312 } 1314 1313 1315 - static unsigned int ipv4_mtu(const struct dst_entry *dst) 1314 + INDIRECT_CALLABLE_SCOPE unsigned int ipv4_mtu(const struct dst_entry *dst) 1316 1315 { 1317 1316 const struct rtable *rt = (const struct rtable *)dst; 1318 1317 unsigned int mtu = rt->rt_pmtu; ··· 1334 1333 1335 1334 return mtu - lwtunnel_headroom(dst->lwtstate, mtu); 1336 1335 } 1336 + EXPORT_SYMBOL(ipv4_mtu); 1337 1337 1338 1338 static void ip_del_fnhe(struct fib_nh_common *nhc, __be32 daddr) 1339 1339 {
+4 -2
net/ipv6/route.c
··· 83 83 84 84 static struct dst_entry *ip6_dst_check(struct dst_entry *dst, u32 cookie); 85 85 static unsigned int ip6_default_advmss(const struct dst_entry *dst); 86 - static unsigned int ip6_mtu(const struct dst_entry *dst); 86 + INDIRECT_CALLABLE_SCOPE 87 + unsigned int ip6_mtu(const struct dst_entry *dst); 87 88 static struct dst_entry *ip6_negative_advice(struct dst_entry *); 88 89 static void ip6_dst_destroy(struct dst_entry *); 89 90 static void ip6_dst_ifdown(struct dst_entry *, ··· 3090 3089 return mtu; 3091 3090 } 3092 3091 3093 - static unsigned int ip6_mtu(const struct dst_entry *dst) 3092 + INDIRECT_CALLABLE_SCOPE unsigned int ip6_mtu(const struct dst_entry *dst) 3094 3093 { 3095 3094 struct inet6_dev *idev; 3096 3095 unsigned int mtu; ··· 3112 3111 3113 3112 return mtu - lwtunnel_headroom(dst->lwtstate, mtu); 3114 3113 } 3114 + EXPORT_SYMBOL(ip6_mtu); 3115 3115 3116 3116 /* MTU selection: 3117 3117 * 1. mtu on route is locked - use it