Re: [PATCH net-next 0/3] strp: Generalize stream parser to work with other socket types

2016-08-29 Thread Tom Herbert
On Sun, Aug 28, 2016 at 8:34 PM, David Miller  wrote:
> From: Tom Herbert 
> Date: Sun, 28 Aug 2016 14:43:16 -0700
>
>> Add a read_sock protocol operation function that allows something like
>> tcp_read_sock to be called for other protocol types.
>>
>> Specific changes in this patch set:
>>   - Add read_sock function to proto_ops. This has the same signature as
>> tcp_read_sock. sk_read_actor_t is also defined in net.h.
>>   - Set peek_len and read_sock proto_op functions for TCPv4 and TCPv6
>> stream ops.
>>   - Remove references to tcp in strparser.
>>   - Call peek_len and read_sock operations from strparser instead of
>> calling TCP specific functions.
>
> I'll apply this, but I want you to shore up these new ops.
>
> A check has to happen somewhere to make sure the proto_ops in
> question have a non-NULL read_sock and peek_len method before
> starting to use it.

Is the check in strp_init not enough?...

@@ -424,9 +429,14 @@ static void strp_rx_msg_timeout(unsigned long arg)
 int strp_init(struct strparser *strp, struct sock *csk,
  struct strp_callbacks *cb)
 {
+   struct socket *sock = csk->sk_socket;
+
if (!cb || !cb->rcv_msg || !cb->parse_msg)
return -EINVAL;

+   if (!sock->ops->read_sock || !sock->ops->peek_len)
+   return -EAFNOSUPPORT;
+


Re: [PATCH net-next 0/3] strp: Generalize stream parser to work with other socket types

2016-08-28 Thread David Miller
From: Tom Herbert 
Date: Sun, 28 Aug 2016 14:43:16 -0700

> Add a read_sock protocol operation function that allows something like
> tcp_read_sock to be called for other protocol types.
> 
> Specific changes in this patch set:
>   - Add read_sock function to proto_ops. This has the same signature as
> tcp_read_sock. sk_read_actor_t is also defined in net.h.
>   - Set peek_len and read_sock proto_op functions for TCPv4 and TCPv6
> stream ops.
>   - Remove references to tcp in strparser.
>   - Call peek_len and read_sock operations from strparser instead of
> calling TCP specific functions.

I'll apply this, but I want you to shore up these new ops.

A check has to happen somewhere to make sure the proto_ops in
question have a non-NULL read_sock and peek_len method before
starting to use it.


[PATCH net-next 0/3] strp: Generalize stream parser to work with other socket types

2016-08-28 Thread Tom Herbert
Add a read_sock protocol operation function that allows something like
tcp_read_sock to be called for other protocol types.

Specific changes in this patch set:
  - Add read_sock function to proto_ops. This has the same signature as
tcp_read_sock. sk_read_actor_t is also defined in net.h.
  - Set peek_len and read_sock proto_op functions for TCPv4 and TCPv6
stream ops.
  - Remove references to tcp in strparser.
  - Call peek_len and read_sock operations from strparser instead of
calling TCP specific functions.

Tom Herbert (3):
  net: Add read_sock proto_op
  tcp: Set read_sock and peek_len proto_ops
  kcm: Remove TCP specific references from kcm and strparser

 include/linux/net.h   |  6 ++
 include/net/strparser.h   |  2 +-
 include/net/tcp.h |  4 ++--
 net/ipv4/af_inet.c|  2 ++
 net/ipv4/tcp.c|  6 ++
 net/ipv6/af_inet6.c   |  2 ++
 net/kcm/kcmsock.c | 30 +
 net/strparser/strparser.c | 48 ---
 8 files changed, 61 insertions(+), 39 deletions(-)

-- 
2.8.0.rc2