nghttpx: Set IP_PMTUDISC_DO explicitly

This commit is contained in:
Tatsuhiro Tsujikawa 2021-11-06 16:28:49 +09:00
parent 528d177847
commit 68b2295f4e
1 changed files with 25 additions and 0 deletions

View File

@ -833,6 +833,19 @@ int Worker::create_quic_server_socket(UpstreamAddr &faddr) {
close(fd); close(fd);
continue; continue;
} }
# if defined(IPV6_MTU_DISCOVER) && defined(IP_PMTUDISC_DO)
int mtu_disc = IP_PMTUDISC_DO;
if (setsockopt(fd, IPPROTO_IPV6, IPV6_MTU_DISCOVER, &mtu_disc,
static_cast<socklen_t>(sizeof(mtu_disc))) == -1) {
auto error = errno;
LOG(WARN)
<< "Failed to set IPV6_MTU_DISCOVER option to listener socket: "
<< xsi_strerror(error, errbuf.data(), errbuf.size());
close(fd);
continue;
}
# endif // defined(IPV6_MTU_DISCOVER) && defined(IP_PMTUDISC_DO)
} else { } else {
if (setsockopt(fd, IPPROTO_IP, IP_PKTINFO, &val, if (setsockopt(fd, IPPROTO_IP, IP_PKTINFO, &val,
static_cast<socklen_t>(sizeof(val))) == -1) { static_cast<socklen_t>(sizeof(val))) == -1) {
@ -842,6 +855,18 @@ int Worker::create_quic_server_socket(UpstreamAddr &faddr) {
close(fd); close(fd);
continue; continue;
} }
# if defined(IP_MTU_DISCOVER) && defined(IP_PMTUDISC_DO)
int mtu_disc = IP_PMTUDISC_DO;
if (setsockopt(fd, IPPROTO_IP, IP_MTU_DISCOVER, &mtu_disc,
static_cast<socklen_t>(sizeof(mtu_disc))) == -1) {
auto error = errno;
LOG(WARN) << "Failed to set IP_MTU_DISCOVER option to listener socket: "
<< xsi_strerror(error, errbuf.data(), errbuf.size());
close(fd);
continue;
}
# endif // defined(IP_MTU_DISCOVER) && defined(IP_PMTUDISC_DO)
} }
util::fd_set_recv_ecn(fd, faddr.family); util::fd_set_recv_ecn(fd, faddr.family);