summaryrefslogtreecommitdiff
path: root/net
diff options
context:
space:
mode:
authorJohn Fastabend <john.fastabend@gmail.com>2017-08-15 22:30:47 -0700
committerDavid S. Miller <davem@davemloft.net>2017-08-16 11:27:52 -0700
commitf26de110f4f1d8d2490d1f9f003d5abbde030f03 (patch)
tree32fc03dceb672f28fb7f098799d92451ae817681 /net
parentd369bcaf7dcbe1a5d09ed2e519f35e4841303003 (diff)
net: early init support for strparser
It is useful to allow strparser to init sockets before the read_sock callback has been established. Signed-off-by: John Fastabend <john.fastabend@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net')
-rw-r--r--net/strparser/strparser.c10
1 files changed, 4 insertions, 6 deletions
diff --git a/net/strparser/strparser.c b/net/strparser/strparser.c
index 0d18fbc6f870..434aa6637a52 100644
--- a/net/strparser/strparser.c
+++ b/net/strparser/strparser.c
@@ -373,6 +373,9 @@ static int strp_read_sock(struct strparser *strp)
struct socket *sock = strp->sk->sk_socket;
read_descriptor_t desc;
+ if (unlikely(!sock || !sock->ops || !sock->ops->read_sock))
+ return -EBUSY;
+
desc.arg.data = strp;
desc.error = 0;
desc.count = 1; /* give more than one skb per call */
@@ -486,12 +489,7 @@ int strp_init(struct strparser *strp, struct sock *sk,
* The upper layer calls strp_process for each skb to be parsed.
*/
- if (sk) {
- struct socket *sock = sk->sk_socket;
-
- if (!sock->ops->read_sock || !sock->ops->peek_len)
- return -EAFNOSUPPORT;
- } else {
+ if (!sk) {
if (!cb->lock || !cb->unlock)
return -EINVAL;
}