Commit 3504bb63 authored by David S. Miller's avatar David S. Miller

Merge branch 'af_unix_MSG_PEEK'

Aaron Conole says:

====================
af_unix: return data from multiple SKBs on recv() with MSG_PEEK flag

This patch set implements a bugfix for kernel.org bugzilla #12323, allowing
MSG_PEEK to return all queued data on the unix domain socket, not just the
data contained in a single SKB.

This is the v3 version of this patch, which includes a suggested modification
by Eric Dumazet to convert the unix_sk() conversion macro to a static inline
function. These patches are independent and can be applied separately.

This set was tested over a 24-hour period, utilizing a loop continually
executing the bugzilla issue attached python code. It was instrumented with
a pr_err_once() ([   13.798683] unix: went there at least one time).

v2->v3:
 - Added Eric Dumazet's suggestion for #define to static inline
 - Fixed an issue calling unix_state_lock() with an invalid argument

v3->v4:
 - Eliminated an XXX comment
 - Changed from goto unlock to explicit unix_state_unlock() and break
====================
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parents 2103d6b8 9f389e35
...@@ -63,7 +63,11 @@ struct unix_sock { ...@@ -63,7 +63,11 @@ struct unix_sock {
#define UNIX_GC_MAYBE_CYCLE 1 #define UNIX_GC_MAYBE_CYCLE 1
struct socket_wq peer_wq; struct socket_wq peer_wq;
}; };
#define unix_sk(__sk) ((struct unix_sock *)__sk)
static inline struct unix_sock *unix_sk(struct sock *sk)
{
return (struct unix_sock *)sk;
}
#define peer_wait peer_wq.wait #define peer_wait peer_wq.wait
......
...@@ -2179,8 +2179,21 @@ static int unix_stream_read_generic(struct unix_stream_read_state *state) ...@@ -2179,8 +2179,21 @@ static int unix_stream_read_generic(struct unix_stream_read_state *state)
if (UNIXCB(skb).fp) if (UNIXCB(skb).fp)
scm.fp = scm_fp_dup(UNIXCB(skb).fp); scm.fp = scm_fp_dup(UNIXCB(skb).fp);
sk_peek_offset_fwd(sk, chunk); if (skip) {
sk_peek_offset_fwd(sk, chunk);
skip -= chunk;
}
if (UNIXCB(skb).fp)
break;
last = skb;
last_len = skb->len;
unix_state_lock(sk);
skb = skb_peek_next(skb, &sk->sk_receive_queue);
if (skb)
goto again;
unix_state_unlock(sk);
break; break;
} }
} while (size); } while (size);
......
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