]> git.baikalelectronics.ru Git - kernel.git/commit
kcm: Add memory limit for receive message construction
authorTom Herbert <tom@herbertland.com>
Mon, 7 Mar 2016 22:11:10 +0000 (14:11 -0800)
committerDavid S. Miller <davem@davemloft.net>
Wed, 9 Mar 2016 21:36:15 +0000 (16:36 -0500)
commitf2702bf8edd67e53a566abf721776d20b8d21a92
treebdbbbc12cf0b1b82f4c07b36d1c45262c2dd3af3
parent52e57a953d3da3b074c9d62df91306061cf8d204
kcm: Add memory limit for receive message construction

Message assembly is performed on the TCP socket. This is logically
equivalent of an application that performs a peek on the socket to find
out how much memory is needed for a receive buffer. The receive socket
buffer also provides the maximum message size which is checked.

The receive algorithm is something like:

   1) Receive the first skbuf for a message (or skbufs if multiple are
      needed to determine message length).
   2) Check the message length against the number of bytes in the TCP
      receive queue (tcp_inq()).
- If all the bytes of the message are in the queue (incluing the
  skbuf received), then proceed with message assembly (it should
  complete with the tcp_read_sock)
        - Else, mark the psock with the number of bytes needed to
  complete the message.
   3) In TCP data ready function, if the psock indicates that we are
      waiting for the rest of the bytes of a messages, check the number
      of queued bytes against that.
        - If there are still not enough bytes for the message, just
  return
        - Else, clear the waiting bytes and proceed to receive the
  skbufs.  The message should now be received in one
  tcp_read_sock

Signed-off-by: Tom Herbert <tom@herbertland.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
include/net/kcm.h
net/kcm/kcmproc.c
net/kcm/kcmsock.c