aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChris Luke <chrisy@flirble.org>2018-09-05 21:00:52 -0400
committerFlorin Coras <florin.coras@gmail.com>2018-09-06 14:40:15 +0000
commita9cf6afa3e2cbc881a41ee6930e2a7d1797c8cf0 (patch)
tree83714061158318416460ac55dcd86e2ab4452a97
parent483a54b8d0886ed9f5f97b0b377d7adb4c810f29 (diff)
Fix Telnet option processing issue
- A check for the length of the buffer should have used the provided 'len' variable, not 'vec_len' since the buffer pointer may be within a vector, but not the start of one. 'vec_len' reports 0 in that case, causing premature exit from the options processing loop and a wait for further input before it checks the next option. - Also add TCP_NODELAY to CLI sockets to disable Nagle on TCP connections for a possible improvement in interactive response. Change-Id: Ie1f53c003ca7d66bed51f437d298183215bad38c Signed-off-by: Chris Luke <chrisy@flirble.org>
-rw-r--r--src/vlib/unix/cli.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/src/vlib/unix/cli.c b/src/vlib/unix/cli.c
index b268db57448..42c13740e20 100644
--- a/src/vlib/unix/cli.c
+++ b/src/vlib/unix/cli.c
@@ -60,6 +60,7 @@
#include <sys/types.h>
#include <unistd.h>
#include <limits.h>
+#include <netinet/tcp.h>
/** ANSI escape code. */
#define ESC "\x1b"
@@ -1294,7 +1295,7 @@ unix_cli_process_telnet (unix_main_t * um,
case DO:
case DONT:
/* Expect 3 bytes */
- if (vec_len (input_vector) < 3)
+ if (len < 3)
return -1; /* want more bytes */
consume = 2;
@@ -2763,11 +2764,17 @@ unix_cli_listen_read_ready (clib_file_t * uf)
clib_error_t *error;
unix_cli_file_t *cf;
u32 cf_index;
+ int one;
error = clib_socket_accept (s, &client);
if (error)
return error;
+ /* Disable Nagle, ignore any errors doing so eg on PF_LOCAL socket */
+ one = 1;
+ setsockopt (client.fd, IPPROTO_TCP, TCP_NODELAY,
+ (void *) &one, sizeof (one));
+
client_name = (char *) format (0, "%U%c", format_sockaddr, &client.peer, 0);
cf_index = unix_cli_file_add (cm, client_name, client.fd);