Skip to content

Commit

Permalink
net: early init support for strparser
Browse files Browse the repository at this point in the history
It is useful to allow strparser to init sockets before the read_sock
callback has been established.

Signed-off-by: John Fastabend <[email protected]>
Signed-off-by: David S. Miller <[email protected]>
  • Loading branch information
jrfastab authored and davem330 committed Aug 16, 2017
1 parent d369bca commit f26de11
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions net/strparser/strparser.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down Expand Up @@ -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;
}
Expand Down

0 comments on commit f26de11

Please sign in to comment.