Skip to content

Commit 8d22679

Browse files
edumazetkuba-moo
authored andcommitted
ipv6: ip6_skb_dst_mtu() cleanups
Use const attribute where we can, and cache skb_dst() Signed-off-by: Eric Dumazet <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
1 parent 520fbdf commit 8d22679

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

include/net/ip6_route.h

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -263,19 +263,19 @@ static inline bool ipv6_anycast_destination(const struct dst_entry *dst,
263263
int ip6_fragment(struct net *net, struct sock *sk, struct sk_buff *skb,
264264
int (*output)(struct net *, struct sock *, struct sk_buff *));
265265

266-
static inline unsigned int ip6_skb_dst_mtu(struct sk_buff *skb)
266+
static inline unsigned int ip6_skb_dst_mtu(const struct sk_buff *skb)
267267
{
268-
unsigned int mtu;
269-
270-
struct ipv6_pinfo *np = skb->sk && !dev_recursion_level() ?
268+
const struct ipv6_pinfo *np = skb->sk && !dev_recursion_level() ?
271269
inet6_sk(skb->sk) : NULL;
270+
const struct dst_entry *dst = skb_dst(skb);
271+
unsigned int mtu;
272272

273273
if (np && np->pmtudisc >= IPV6_PMTUDISC_PROBE) {
274-
mtu = READ_ONCE(skb_dst(skb)->dev->mtu);
275-
mtu -= lwtunnel_headroom(skb_dst(skb)->lwtstate, mtu);
276-
} else
277-
mtu = dst_mtu(skb_dst(skb));
278-
274+
mtu = READ_ONCE(dst->dev->mtu);
275+
mtu -= lwtunnel_headroom(dst->lwtstate, mtu);
276+
} else {
277+
mtu = dst_mtu(dst);
278+
}
279279
return mtu;
280280
}
281281

0 commit comments

Comments
 (0)