diff options
author | David S. Miller <davem@davemloft.net> | 2020-02-28 12:13:02 -0800 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2020-02-28 12:13:02 -0800 |
commit | 9a834f9b04bc5ed2db27eb45b0cc6415ce7c314c (patch) | |
tree | 9d8b2dd6c404c843212078fb52a8f38b75214afc /net/ipv4 | |
parent | e955376277839db92774ec24d559ab42442b95fc (diff) | |
parent | e427cad6eee47e2daf207cd7a4156ae72496ee07 (diff) |
Merge branch 'net-cleanup-datagram-receive-helpers'
Paolo Abeni says:
====================
net: cleanup datagram receive helpers
Several receive helpers have an optional destructor argument, which uglify
the code a bit and is taxed by retpoline overhead.
This series refactor the code so that we can drop such optional argument,
cleaning the helpers a bit and avoiding an indirect call in fast path.
The first patch refactor a bit the caller, so that the second patch
actually dropping the argument is more straight-forward
v1 -> v2:
- call scm_stat_del() only when not peeking - Kirill
- fix build issue with CONFIG_INET_ESPINTCP
====================
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/ipv4')
-rw-r--r-- | net/ipv4/udp.c | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/net/ipv4/udp.c b/net/ipv4/udp.c index 08a41f1e1cd2..a68e2ac37f26 100644 --- a/net/ipv4/udp.c +++ b/net/ipv4/udp.c @@ -1671,10 +1671,11 @@ struct sk_buff *__skb_recv_udp(struct sock *sk, unsigned int flags, error = -EAGAIN; do { spin_lock_bh(&queue->lock); - skb = __skb_try_recv_from_queue(sk, queue, flags, - udp_skb_destructor, - off, err, &last); + skb = __skb_try_recv_from_queue(sk, queue, flags, off, + err, &last); if (skb) { + if (!(flags & MSG_PEEK)) + udp_skb_destructor(sk, skb); spin_unlock_bh(&queue->lock); return skb; } @@ -1692,9 +1693,10 @@ struct sk_buff *__skb_recv_udp(struct sock *sk, unsigned int flags, spin_lock(&sk_queue->lock); skb_queue_splice_tail_init(sk_queue, queue); - skb = __skb_try_recv_from_queue(sk, queue, flags, - udp_skb_dtor_locked, - off, err, &last); + skb = __skb_try_recv_from_queue(sk, queue, flags, off, + err, &last); + if (skb && !(flags & MSG_PEEK)) + udp_skb_dtor_locked(sk, skb); spin_unlock(&sk_queue->lock); spin_unlock_bh(&queue->lock); if (skb) |