From 7ced95ef525c329f947c424859cf2b0a3b731f8c Mon Sep 17 00:00:00 2001 From: Tom Herbert Date: Mon, 7 Mar 2016 14:11:10 -0800 Subject: 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 Signed-off-by: David S. Miller --- net/kcm/kcmproc.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'net/kcm/kcmproc.c') diff --git a/net/kcm/kcmproc.c b/net/kcm/kcmproc.c index 5eb9809c0f59..7638b3555b17 100644 --- a/net/kcm/kcmproc.c +++ b/net/kcm/kcmproc.c @@ -331,7 +331,7 @@ static int kcm_stats_seq_show(struct seq_file *seq, void *v) mux_stats.rx_ready_drops); seq_printf(seq, - "%-8s %-10s %-16s %-10s %-16s %-10s %-10s %-10s %-10s %-10s %-10s %-10s\n", + "%-8s %-10s %-16s %-10s %-16s %-10s %-10s %-10s %-10s %-10s %-10s %-10s %-10s\n", "Psock", "RX-Msgs", "RX-Bytes", @@ -343,10 +343,11 @@ static int kcm_stats_seq_show(struct seq_file *seq, void *v) "RX-MemFail", "RX-NeedMor", "RX-BadLen", + "RX-TooBig", "TX-Aborts"); seq_printf(seq, - "%-8s %-10llu %-16llu %-10llu %-16llu %-10llu %-10llu %-10u %-10u %-10u %-10u %-10u\n", + "%-8s %-10llu %-16llu %-10llu %-16llu %-10llu %-10llu %-10u %-10u %-10u %-10u %-10u %-10u\n", "", psock_stats.rx_msgs, psock_stats.rx_bytes, @@ -358,6 +359,7 @@ static int kcm_stats_seq_show(struct seq_file *seq, void *v) psock_stats.rx_mem_fail, psock_stats.rx_need_more_hdr, psock_stats.rx_bad_hdr_len, + psock_stats.rx_msg_too_big, psock_stats.tx_aborts); return 0; -- cgit v1.2.3