Commit cd3c7480 authored by Pavel Begunkov's avatar Pavel Begunkov Committed by Jakub Kicinski

ipv6: optimise dst refcounting on skb init

__ip6_make_skb() gets a cork->dst ref, hands it over to skb and shortly
after puts cork->dst. Save two atomics by stealing it without extra
referencing, ip6_cork_release() handles NULL cork->dst.
Signed-off-by: default avatarPavel Begunkov <asml.silence@gmail.com>
Reviewed-by: default avatarWillem de Bruijn <willemb@google.com>
Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parent d344e553
...@@ -1807,6 +1807,15 @@ int ip6_append_data(struct sock *sk, ...@@ -1807,6 +1807,15 @@ int ip6_append_data(struct sock *sk,
} }
EXPORT_SYMBOL_GPL(ip6_append_data); EXPORT_SYMBOL_GPL(ip6_append_data);
static void ip6_cork_steal_dst(struct sk_buff *skb, struct inet_cork_full *cork)
{
struct dst_entry *dst = cork->base.dst;
cork->base.dst = NULL;
cork->base.flags &= ~IPCORK_ALLFRAG;
skb_dst_set(skb, dst);
}
static void ip6_cork_release(struct inet_cork_full *cork, static void ip6_cork_release(struct inet_cork_full *cork,
struct inet6_cork *v6_cork) struct inet6_cork *v6_cork)
{ {
...@@ -1889,7 +1898,7 @@ struct sk_buff *__ip6_make_skb(struct sock *sk, ...@@ -1889,7 +1898,7 @@ struct sk_buff *__ip6_make_skb(struct sock *sk,
skb->tstamp = cork->base.transmit_time; skb->tstamp = cork->base.transmit_time;
skb_dst_set(skb, dst_clone(&rt->dst)); ip6_cork_steal_dst(skb, cork);
IP6_UPD_PO_STATS(net, rt->rt6i_idev, IPSTATS_MIB_OUT, skb->len); IP6_UPD_PO_STATS(net, rt->rt6i_idev, IPSTATS_MIB_OUT, skb->len);
if (proto == IPPROTO_ICMPV6) { if (proto == IPPROTO_ICMPV6) {
struct inet6_dev *idev = ip6_dst_idev(skb_dst(skb)); struct inet6_dev *idev = ip6_dst_idev(skb_dst(skb));
......
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