Commit 8d22679d authored by Eric Dumazet's avatar Eric Dumazet Committed by Jakub Kicinski

ipv6: ip6_skb_dst_mtu() cleanups

Use const attribute where we can, and cache skb_dst()
Signed-off-by: default avatarEric Dumazet <edumazet@google.com>
Link: https://lore.kernel.org/r/20211119022355.2985984-1-eric.dumazet@gmail.comSigned-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parent 520fbdf7
......@@ -263,19 +263,19 @@ static inline bool ipv6_anycast_destination(const struct dst_entry *dst,
int ip6_fragment(struct net *net, struct sock *sk, struct sk_buff *skb,
int (*output)(struct net *, struct sock *, struct sk_buff *));
static inline unsigned int ip6_skb_dst_mtu(struct sk_buff *skb)
static inline unsigned int ip6_skb_dst_mtu(const struct sk_buff *skb)
{
unsigned int mtu;
struct ipv6_pinfo *np = skb->sk && !dev_recursion_level() ?
const struct ipv6_pinfo *np = skb->sk && !dev_recursion_level() ?
inet6_sk(skb->sk) : NULL;
const struct dst_entry *dst = skb_dst(skb);
unsigned int mtu;
if (np && np->pmtudisc >= IPV6_PMTUDISC_PROBE) {
mtu = READ_ONCE(skb_dst(skb)->dev->mtu);
mtu -= lwtunnel_headroom(skb_dst(skb)->lwtstate, mtu);
} else
mtu = dst_mtu(skb_dst(skb));
mtu = READ_ONCE(dst->dev->mtu);
mtu -= lwtunnel_headroom(dst->lwtstate, mtu);
} else {
mtu = dst_mtu(dst);
}
return mtu;
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment