chiark
/
gitweb
/
~mdw
/
tripe
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Set the socket send and receive buffers to maximum. At least this way,
[tripe]
/
peer.c
diff --git
a/peer.c
b/peer.c
index 2f3d09ab2308bb5eee508d262c5059865d5379e7..f60f887fc6e247a5778a3efa4e81e30360b25b27 100644
(file)
--- a/
peer.c
+++ b/
peer.c
@@
-1,6
+1,6
@@
/* -*-c-*-
*
/* -*-c-*-
*
- * $Id: peer.c,v 1.
4 2001/02/16 21:40:24
mdw Exp $
+ * $Id: peer.c,v 1.
5 2001/03/03 11:15:19
mdw Exp $
*
* Communication with the peer
*
*
* Communication with the peer
*
@@
-29,6
+29,13
@@
/*----- Revision history --------------------------------------------------*
*
* $Log: peer.c,v $
/*----- Revision history --------------------------------------------------*
*
* $Log: peer.c,v $
+ * Revision 1.5 2001/03/03 11:15:19 mdw
+ * Set the socket send and receive buffers to maximum. At least this way,
+ * we won't drop large packets on the floor. If the administrator wants to
+ * prevent fragmentation of TrIPE messages, he can lower the MTU on the
+ * tunnel interface. Getting path-MTU stuff out of the kernel is too much
+ * system-specific hard work for this program.
+ *
* Revision 1.4 2001/02/16 21:40:24 mdw
* Change key exchange message interface. Maintain statistics.
*
* Revision 1.4 2001/02/16 21:40:24 mdw
* Change key exchange message interface. Maintain statistics.
*
@@
-273,6
+280,15
@@
void p_init(unsigned port)
{
int fd;
struct sockaddr_in sin;
{
int fd;
struct sockaddr_in sin;
+ int len = 65536;
+
+ /* --- Note on socket buffer sizes --- *
+ *
+ * For some bizarre reason, Linux 2.2 (at least) doubles the socket buffer
+ * sizes I pass to @setsockopt@. I'm not putting special-case code here
+ * for Linux: BSD (at least TCPv2) does what I tell it rather than second-
+ * guessing me.
+ */
if ((fd = socket(PF_INET, SOCK_DGRAM, 0)) < 0)
die(EXIT_FAILURE, "socket creation failed: %s", strerror(errno));
if ((fd = socket(PF_INET, SOCK_DGRAM, 0)) < 0)
die(EXIT_FAILURE, "socket creation failed: %s", strerror(errno));
@@
-282,6
+298,11
@@
void p_init(unsigned port)
sin.sin_port = htons(port);
if (bind(fd, (struct sockaddr *)&sin, sizeof(sin)))
die(EXIT_FAILURE, "bind failed: %s", strerror(errno));
sin.sin_port = htons(port);
if (bind(fd, (struct sockaddr *)&sin, sizeof(sin)))
die(EXIT_FAILURE, "bind failed: %s", strerror(errno));
+ if (setsockopt(fd, SOL_SOCKET, SO_RCVBUF, &len, sizeof(len)) ||
+ setsockopt(fd, SOL_SOCKET, SO_SNDBUF, &len, sizeof(len))) {
+ die(EXIT_FAILURE, "failed to set socket buffer sizes: %s",
+ strerror(errno));
+ }
fdflags(fd, O_NONBLOCK, O_NONBLOCK, FD_CLOEXEC, FD_CLOEXEC);
sel_initfile(&sel, &sock, fd, SEL_READ, p_read, 0);
sel_addfile(&sock);
fdflags(fd, O_NONBLOCK, O_NONBLOCK, FD_CLOEXEC, FD_CLOEXEC);
sel_initfile(&sel, &sock, fd, SEL_READ, p_read, 0);
sel_addfile(&sock);