mirror of
https://gitlab.isc.org/isc-projects/bind9
synced 2025-08-30 22:15:20 +00:00
Disable the Path MTU Discover on UDP Sockets
Instead of disabling the fragmentation on the UDP sockets, we now disable the Path MTU Discovery by setting IP(V6)_MTU_DISCOVER socket option to IP_PMTUDISC_OMIT on Linux and disabling IP(V6)_DONTFRAG socket option on FreeBSD. This option sets DF=0 in the IP header and also ignores the Path MTU Discovery. As additional mitigation on Linux, we recommend setting net.ipv4.ip_no_pmtu_disc to Mode 3: Mode 3 is a hardend pmtu discover mode. The kernel will only accept fragmentation-needed errors if the underlying protocol can verify them besides a plain socket lookup. Current protocols for which pmtu events will be honored are TCP, SCTP and DCCP as they verify e.g. the sequence number or the association. This mode should not be enabled globally but is only intended to secure e.g. name servers in namespaces where TCP path mtu must still work but path MTU information of other protocols should be discarded. If enabled globally this mode could break other protocols.
This commit is contained in:
committed by
Michał Kępień
parent
69243a0f56
commit
87d5c8ab7c
@@ -3044,20 +3044,20 @@ isc__nm_socket_incoming_cpu(uv_os_sock_t fd) {
|
||||
}
|
||||
|
||||
isc_result_t
|
||||
isc__nm_socket_dontfrag(uv_os_sock_t fd, sa_family_t sa_family) {
|
||||
isc__nm_socket_disable_pmtud(uv_os_sock_t fd, sa_family_t sa_family) {
|
||||
/*
|
||||
* Set the Don't Fragment flag on IP packets
|
||||
* Disable the Path MTU Discovery on IP packets
|
||||
*/
|
||||
if (sa_family == AF_INET6) {
|
||||
#if defined(IPV6_DONTFRAG)
|
||||
if (setsockopt_on(fd, IPPROTO_IPV6, IPV6_DONTFRAG) == -1) {
|
||||
if (setsockopt_off(fd, IPPROTO_IPV6, IPV6_DONTFRAG) == -1) {
|
||||
return (ISC_R_FAILURE);
|
||||
} else {
|
||||
return (ISC_R_SUCCESS);
|
||||
}
|
||||
#elif defined(IPV6_MTU_DISCOVER)
|
||||
#elif defined(IPV6_MTU_DISCOVER) && defined(IP_PMTUDISC_OMIT)
|
||||
if (setsockopt(fd, IPPROTO_IPV6, IPV6_MTU_DISCOVER,
|
||||
&(int){ IP_PMTUDISC_DO }, sizeof(int)) == -1)
|
||||
&(int){ IP_PMTUDISC_OMIT }, sizeof(int)) == -1)
|
||||
{
|
||||
return (ISC_R_FAILURE);
|
||||
} else {
|
||||
@@ -3068,14 +3068,14 @@ isc__nm_socket_dontfrag(uv_os_sock_t fd, sa_family_t sa_family) {
|
||||
#endif
|
||||
} else if (sa_family == AF_INET) {
|
||||
#if defined(IP_DONTFRAG)
|
||||
if (setsockopt_on(fd, IPPROTO_IP, IP_DONTFRAG) == -1) {
|
||||
if (setsockopt_off(fd, IPPROTO_IP, IP_DONTFRAG) == -1) {
|
||||
return (ISC_R_FAILURE);
|
||||
} else {
|
||||
return (ISC_R_SUCCESS);
|
||||
}
|
||||
#elif defined(IP_MTU_DISCOVER)
|
||||
#elif defined(IP_MTU_DISCOVER) && defined(IP_PMTUDISC_OMIT)
|
||||
if (setsockopt(fd, IPPROTO_IP, IP_MTU_DISCOVER,
|
||||
&(int){ IP_PMTUDISC_DO }, sizeof(int)) == -1)
|
||||
&(int){ IP_PMTUDISC_OMIT }, sizeof(int)) == -1)
|
||||
{
|
||||
return (ISC_R_FAILURE);
|
||||
} else {
|
||||
|
Reference in New Issue
Block a user