summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorstevesk <stevesk@openbsd.org>2002-01-24 21:09:25 +0000
committerstevesk <stevesk@openbsd.org>2002-01-24 21:09:25 +0000
commite469dfb64b5a2d8339e16f8f93d6ab9d98b5b62f (patch)
tree2356ee73abfd159120681e35b52b2df75043f13a
parentadd a note about the old stty (diff)
downloadwireguard-openbsd-e469dfb64b5a2d8339e16f8f93d6ab9d98b5b62f.tar.xz
wireguard-openbsd-e469dfb64b5a2d8339e16f8f93d6ab9d98b5b62f.zip
add set_nodelay() to set TCP_NODELAY on a socket (prep for nagle tuning).
no nagle changes just yet; ok djm@ markus@
-rw-r--r--usr.bin/ssh/channels.c14
-rw-r--r--usr.bin/ssh/misc.c15
-rw-r--r--usr.bin/ssh/misc.h3
-rw-r--r--usr.bin/ssh/packet.c7
4 files changed, 22 insertions, 17 deletions
diff --git a/usr.bin/ssh/channels.c b/usr.bin/ssh/channels.c
index 5b2c8b0b9ca..dae031949d0 100644
--- a/usr.bin/ssh/channels.c
+++ b/usr.bin/ssh/channels.c
@@ -39,7 +39,7 @@
*/
#include "includes.h"
-RCSID("$OpenBSD: channels.c,v 1.161 2002/01/21 23:27:10 markus Exp $");
+RCSID("$OpenBSD: channels.c,v 1.162 2002/01/24 21:09:25 stevesk Exp $");
#include "ssh.h"
#include "ssh1.h"
@@ -986,7 +986,7 @@ channel_post_x11_listener(Channel *c, fd_set * readset, fd_set * writeset)
{
Channel *nc;
struct sockaddr addr;
- int newsock, on = 1;
+ int newsock;
socklen_t addrlen;
char buf[16384], *remote_ipaddr;
int remote_port;
@@ -1004,10 +1004,7 @@ channel_post_x11_listener(Channel *c, fd_set * readset, fd_set * writeset)
error("accept: %.100s", strerror(errno));
return;
}
- if (setsockopt(newsock, IPPROTO_TCP, TCP_NODELAY, &on,
- sizeof on) == -1)
- error("setsockopt TCP_NODELAY: %.100s",
- strerror(errno));
+ set_nodelay(newsock);
remote_ipaddr = get_peer_ipaddr(newsock);
remote_port = get_peer_port(newsock);
snprintf(buf, sizeof buf, "X11 connection from %.200s port %d",
@@ -2475,7 +2472,7 @@ connect_local_xsocket(u_int dnr)
int
x11_connect_display(void)
{
- int display_number, sock = 0, on = 1;
+ int display_number, sock = 0;
const char *display;
char buf[1024], *cp;
struct addrinfo hints, *ai, *aitop;
@@ -2563,8 +2560,7 @@ x11_connect_display(void)
strerror(errno));
return -1;
}
- if (setsockopt(sock, IPPROTO_TCP, TCP_NODELAY, &on, sizeof on) == -1)
- error("setsockopt TCP_NODELAY: %.100s", strerror(errno));
+ set_nodelay(sock);
return sock;
}
diff --git a/usr.bin/ssh/misc.c b/usr.bin/ssh/misc.c
index 9fffc10a6f3..a5447b4dacd 100644
--- a/usr.bin/ssh/misc.c
+++ b/usr.bin/ssh/misc.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: misc.c,v 1.14 2001/12/19 07:18:56 deraadt Exp $ */
+/* $OpenBSD: misc.c,v 1.15 2002/01/24 21:09:25 stevesk Exp $ */
/*
* Copyright (c) 2000 Markus Friedl. All rights reserved.
@@ -25,7 +25,7 @@
*/
#include "includes.h"
-RCSID("$OpenBSD: misc.c,v 1.14 2001/12/19 07:18:56 deraadt Exp $");
+RCSID("$OpenBSD: misc.c,v 1.15 2002/01/24 21:09:25 stevesk Exp $");
#include "misc.h"
#include "log.h"
@@ -92,6 +92,17 @@ unset_nonblock(int fd)
fd, strerror(errno));
}
+/* disable nagle on socket */
+void
+set_nodelay(int fd)
+{
+ int on = 1;
+
+ debug("fd %d setting TCP_NODELAY", fd);
+ if (setsockopt(fd, IPPROTO_TCP, TCP_NODELAY, &on, sizeof on) == -1)
+ error("setsockopt TCP_NODELAY: %.100s", strerror(errno));
+}
+
/* Characters considered whitespace in strsep calls. */
#define WHITESPACE " \t\r\n"
diff --git a/usr.bin/ssh/misc.h b/usr.bin/ssh/misc.h
index 7400d627fbd..d28b8650988 100644
--- a/usr.bin/ssh/misc.h
+++ b/usr.bin/ssh/misc.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: misc.h,v 1.10 2001/06/26 17:27:24 markus Exp $ */
+/* $OpenBSD: misc.h,v 1.11 2002/01/24 21:09:25 stevesk Exp $ */
/*
* Author: Tatu Ylonen <ylo@cs.hut.fi>
@@ -16,6 +16,7 @@ char *chop(char *);
char *strdelim(char **);
void set_nonblock(int);
void unset_nonblock(int);
+void set_nodelay(int);
int a2port(const char *);
char *cleanhostname(char *);
char *colon(char *);
diff --git a/usr.bin/ssh/packet.c b/usr.bin/ssh/packet.c
index 68668bd2144..a542df1814d 100644
--- a/usr.bin/ssh/packet.c
+++ b/usr.bin/ssh/packet.c
@@ -37,7 +37,7 @@
*/
#include "includes.h"
-RCSID("$OpenBSD: packet.c,v 1.85 2002/01/18 18:14:17 stevesk Exp $");
+RCSID("$OpenBSD: packet.c,v 1.86 2002/01/24 21:09:25 stevesk Exp $");
#include "xmalloc.h"
#include "buffer.h"
@@ -1189,7 +1189,6 @@ packet_set_interactive(int interactive)
static int called = 0;
int lowdelay = IPTOS_LOWDELAY;
int throughput = IPTOS_THROUGHPUT;
- int on = 1;
if (called)
return;
@@ -1215,9 +1214,7 @@ packet_set_interactive(int interactive)
error("setsockopt IPTOS_LOWDELAY: %.100s",
strerror(errno));
}
- if (setsockopt(connection_in, IPPROTO_TCP, TCP_NODELAY, (void *) &on,
- sizeof(on)) < 0)
- error("setsockopt TCP_NODELAY: %.100s", strerror(errno));
+ set_nodelay(connection_in);
} else if (packet_connection_is_ipv4()) {
/*
* Set IP options for a non-interactive connection. Use