2
0
mirror of https://gitlab.isc.org/isc-projects/bind9 synced 2025-08-29 13:38:26 +00:00

4435. [tuning] Only set IPV6_USE_MIN_MTU for UDP when the message

will not fit into a single IPv4 encapsulated IPv6
                        UDP packet when transmitted over a Ethernet link.
                        [RT #42871]
This commit is contained in:
Mark Andrews 2016-08-12 09:41:59 +10:00
parent bf2238b064
commit 31ffec1541
4 changed files with 34 additions and 16 deletions

View File

@ -1,3 +1,8 @@
4435. [tuning] Only set IPV6_USE_MIN_MTU for UDP when the message
will not fit into a single IPv4 encapsulated IPv6
UDP packet when transmitted over a Ethernet link.
[RT #42871]
4434. [protocol] Return EDNS EXPIRE option for master zones in addition 4434. [protocol] Return EDNS EXPIRE option for master zones in addition
to slave zones. [RT #43008] to slave zones. [RT #43008]

View File

@ -923,6 +923,15 @@ client_sendpkg(ns_client_t *client, isc_buffer_t *buffer) {
isc_buffer_usedregion(buffer, &r); isc_buffer_usedregion(buffer, &r);
/*
* If this is a UDP client and the IPv6 packet can't be
* encapsulated without generating a PTB on a 1500 octet
* MTU link force fragmentation at 1280 if it is a IPv6
* response.
*/
if (!TCP_CLIENT(client) && r.length > 1432)
client->sendevent->attributes |= ISC_SOCKEVENTATTR_USEMINMTU;
CTRACE("sendto"); CTRACE("sendto");
result = isc_socket_sendto2(sock, &r, client->task, result = isc_socket_sendto2(sock, &r, client->task,

View File

@ -251,6 +251,7 @@ struct isc_socket_connev {
* _PKTINFO: The pktinfo member is valid. * _PKTINFO: The pktinfo member is valid.
* _MULTICAST: The UDP packet was received via a multicast transmission. * _MULTICAST: The UDP packet was received via a multicast transmission.
* _DSCP: The UDP DSCP value is valid. * _DSCP: The UDP DSCP value is valid.
* _USEMINMTU: Set the per packet IPV6_USE_MIN_MTU flag.
*/ */
#define ISC_SOCKEVENTATTR_ATTACHED 0x80000000U /* internal */ #define ISC_SOCKEVENTATTR_ATTACHED 0x80000000U /* internal */
#define ISC_SOCKEVENTATTR_TRUNC 0x00800000U /* public */ #define ISC_SOCKEVENTATTR_TRUNC 0x00800000U /* public */
@ -259,6 +260,7 @@ struct isc_socket_connev {
#define ISC_SOCKEVENTATTR_PKTINFO 0x00100000U /* public */ #define ISC_SOCKEVENTATTR_PKTINFO 0x00100000U /* public */
#define ISC_SOCKEVENTATTR_MULTICAST 0x00080000U /* public */ #define ISC_SOCKEVENTATTR_MULTICAST 0x00080000U /* public */
#define ISC_SOCKEVENTATTR_DSCP 0x00040000U /* public */ #define ISC_SOCKEVENTATTR_DSCP 0x00040000U /* public */
#define ISC_SOCKEVENTATTR_USEMINMTU 0x00020000U /* public */
/*@}*/ /*@}*/
#define ISC_SOCKEVENT_ANYEVENT (0) #define ISC_SOCKEVENT_ANYEVENT (0)

View File

@ -6,8 +6,6 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. * file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/ */
/* $Id$ */
/*! \file */ /*! \file */
#include <config.h> #include <config.h>
@ -1505,12 +1503,12 @@ build_msghdr_send(isc__socket_t *sock, isc_socketevent_t *dev,
msg->msg_control = NULL; msg->msg_control = NULL;
msg->msg_controllen = 0; msg->msg_controllen = 0;
msg->msg_flags = 0; msg->msg_flags = 0;
#if defined(USE_CMSG) && defined(ISC_PLATFORM_HAVEIN6PKTINFO) #if defined(USE_CMSG)
if ((sock->type == isc_sockettype_udp)
&& ((dev->attributes & ISC_SOCKEVENTATTR_PKTINFO) != 0)) { #if defined(ISC_PLATFORM_HAVEIN6PKTINFO)
#if defined(IPV6_USE_MIN_MTU) if ((sock->type == isc_sockettype_udp) &&
int use_min_mtu = 1; /* -1, 0, 1 */ ((dev->attributes & ISC_SOCKEVENTATTR_PKTINFO) != 0))
#endif {
struct in6_pktinfo *pktinfop; struct in6_pktinfo *pktinfop;
socket_log(sock, NULL, TRACE, socket_log(sock, NULL, TRACE,
@ -1528,12 +1526,15 @@ build_msghdr_send(isc__socket_t *sock, isc_socketevent_t *dev,
cmsgp->cmsg_len = cmsg_len(sizeof(struct in6_pktinfo)); cmsgp->cmsg_len = cmsg_len(sizeof(struct in6_pktinfo));
pktinfop = (struct in6_pktinfo *)CMSG_DATA(cmsgp); pktinfop = (struct in6_pktinfo *)CMSG_DATA(cmsgp);
memmove(pktinfop, &dev->pktinfo, sizeof(struct in6_pktinfo)); memmove(pktinfop, &dev->pktinfo, sizeof(struct in6_pktinfo));
}
#endif
#if defined(IPV6_USE_MIN_MTU) #if defined(IPV6_USE_MIN_MTU)
/* if ((sock->type == isc_sockettype_udp) &&
* Set IPV6_USE_MIN_MTU as a per packet option as FreeBSD ((dev->attributes & ISC_SOCKEVENTATTR_USEMINMTU) != 0))
* ignores setsockopt(IPV6_USE_MIN_MTU) when IPV6_PKTINFO {
* is used. int use_min_mtu = 1; /* -1, 0, 1 */
*/
cmsgp = (struct cmsghdr *)(sock->sendcmsgbuf + cmsgp = (struct cmsghdr *)(sock->sendcmsgbuf +
msg->msg_controllen); msg->msg_controllen);
msg->msg_controllen += cmsg_space(sizeof(use_min_mtu)); msg->msg_controllen += cmsg_space(sizeof(use_min_mtu));
@ -1543,8 +1544,8 @@ build_msghdr_send(isc__socket_t *sock, isc_socketevent_t *dev,
cmsgp->cmsg_type = IPV6_USE_MIN_MTU; cmsgp->cmsg_type = IPV6_USE_MIN_MTU;
cmsgp->cmsg_len = cmsg_len(sizeof(use_min_mtu)); cmsgp->cmsg_len = cmsg_len(sizeof(use_min_mtu));
memmove(CMSG_DATA(cmsgp), &use_min_mtu, sizeof(use_min_mtu)); memmove(CMSG_DATA(cmsgp), &use_min_mtu, sizeof(use_min_mtu));
#endif
} }
#endif
if (isc_dscp_check_value > -1) { if (isc_dscp_check_value > -1) {
if (sock->type == isc_sockettype_udp) if (sock->type == isc_sockettype_udp)
@ -1622,7 +1623,7 @@ build_msghdr_send(isc__socket_t *sock, isc_socketevent_t *dev,
} }
#endif #endif
} }
#endif /* USE_CMSG && ISC_PLATFORM_HAVEIPV6 */ #endif /* USE_CMSG */
#else /* ISC_NET_BSD44MSGHDR */ #else /* ISC_NET_BSD44MSGHDR */
msg->msg_accrights = NULL; msg->msg_accrights = NULL;
msg->msg_accrightslen = 0; msg->msg_accrightslen = 0;
@ -2756,6 +2757,7 @@ opensocket(isc__socketmgr_t *manager, isc__socket_t *sock,
/* /*
* Use minimum mtu if possible. * Use minimum mtu if possible.
*/ */
if (sock->type == isc_sockettype_tcp)
use_min_mtu(sock); use_min_mtu(sock);
#if defined(USE_CMSG) || defined(SO_RCVBUF) #if defined(USE_CMSG) || defined(SO_RCVBUF)