4443. [func] Set TCP_MAXSEG in addition to IPV6_USE_MIN_MTU on

TCP sockets. [RT #42864]
This commit is contained in:
Mark Andrews
2016-08-16 07:42:25 +10:00
parent 42a14518ac
commit 7872d4d1c0
2 changed files with 18 additions and 1 deletions

View File

@@ -1,3 +1,6 @@
4443. [func] Set TCP_MAXSEG in addition to IPV6_USE_MIN_MTU on
TCP sockets. [RT #42864]
4442. [bug] Fix RPZ CIDR tree insertion bug that corrupted
tree data structure with overlapping networks
(longest prefix match was ineffective).

View File

@@ -73,6 +73,8 @@
#endif
#endif
#include <netinet/tcp.h>
#include "errno2result.h"
/* See task.c about the following definition: */
@@ -2556,6 +2558,15 @@ use_min_mtu(isc__socket_t *sock) {
#endif
}
static void
set_tcp_maxseg(isc__socket_t *sock, int size) {
#ifdef TCP_MAXSEG
if (sock->type == isc_sockettype_tcp)
(void)setsockopt(sock->fd, IPPROTO_TCP, TCP_MAXSEG,
(void *)&size, sizeof(size));
#endif
}
static isc_result_t
opensocket(isc__socketmgr_t *manager, isc__socket_t *sock,
isc__socket_t *dup_socket)
@@ -2761,8 +2772,10 @@ opensocket(isc__socketmgr_t *manager, isc__socket_t *sock,
/*
* Use minimum mtu if possible.
*/
if (sock->type == isc_sockettype_tcp)
if (sock->type == isc_sockettype_tcp && sock->pf == AF_INET6) {
use_min_mtu(sock);
set_tcp_maxseg(sock, 1280 - 20 - 40); /* 1280 - TCP - IPV6 */
}
#if defined(USE_CMSG) || defined(SO_RCVBUF)
if (sock->type == isc_sockettype_udp) {
@@ -3683,6 +3696,7 @@ internal_accept(isc_task_t *me, isc_event_t *ev) {
* Use minimum mtu if possible.
*/
use_min_mtu(NEWCONNSOCK(dev));
set_tcp_maxseg(NEWCONNSOCK(dev), 1280 - 20 - 40);
/*
* Ensure DSCP settings are inherited across accept.