Merge fd_set_recv_ecn to create_quic_server_socket and handle errors
This commit is contained in:
parent
68b2295f4e
commit
2aed077761
|
@ -834,6 +834,15 @@ int Worker::create_quic_server_socket(UpstreamAddr &faddr) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (setsockopt(fd, IPPROTO_IPV6, IPV6_RECVTCLASS, &val,
|
||||||
|
static_cast<socklen_t>(sizeof(val))) == -1) {
|
||||||
|
auto error = errno;
|
||||||
|
LOG(WARN) << "Failed to set IPV6_RECVTCLASS option to listener socket: "
|
||||||
|
<< xsi_strerror(error, errbuf.data(), errbuf.size());
|
||||||
|
close(fd);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
# if defined(IPV6_MTU_DISCOVER) && defined(IP_PMTUDISC_DO)
|
# if defined(IPV6_MTU_DISCOVER) && defined(IP_PMTUDISC_DO)
|
||||||
int mtu_disc = IP_PMTUDISC_DO;
|
int mtu_disc = IP_PMTUDISC_DO;
|
||||||
if (setsockopt(fd, IPPROTO_IPV6, IPV6_MTU_DISCOVER, &mtu_disc,
|
if (setsockopt(fd, IPPROTO_IPV6, IPV6_MTU_DISCOVER, &mtu_disc,
|
||||||
|
@ -856,6 +865,15 @@ int Worker::create_quic_server_socket(UpstreamAddr &faddr) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (setsockopt(fd, IPPROTO_IP, IP_RECVTOS, &val,
|
||||||
|
static_cast<socklen_t>(sizeof(val))) == -1) {
|
||||||
|
auto error = errno;
|
||||||
|
LOG(WARN) << "Failed to set IP_RECVTOS option to listener socket: "
|
||||||
|
<< xsi_strerror(error, errbuf.data(), errbuf.size());
|
||||||
|
close(fd);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
# if defined(IP_MTU_DISCOVER) && defined(IP_PMTUDISC_DO)
|
# if defined(IP_MTU_DISCOVER) && defined(IP_PMTUDISC_DO)
|
||||||
int mtu_disc = IP_PMTUDISC_DO;
|
int mtu_disc = IP_PMTUDISC_DO;
|
||||||
if (setsockopt(fd, IPPROTO_IP, IP_MTU_DISCOVER, &mtu_disc,
|
if (setsockopt(fd, IPPROTO_IP, IP_MTU_DISCOVER, &mtu_disc,
|
||||||
|
@ -869,8 +887,6 @@ int Worker::create_quic_server_socket(UpstreamAddr &faddr) {
|
||||||
# endif // defined(IP_MTU_DISCOVER) && defined(IP_PMTUDISC_DO)
|
# endif // defined(IP_MTU_DISCOVER) && defined(IP_PMTUDISC_DO)
|
||||||
}
|
}
|
||||||
|
|
||||||
util::fd_set_recv_ecn(fd, faddr.family);
|
|
||||||
|
|
||||||
if (bind(fd, rp->ai_addr, rp->ai_addrlen) == -1) {
|
if (bind(fd, rp->ai_addr, rp->ai_addrlen) == -1) {
|
||||||
auto error = errno;
|
auto error = errno;
|
||||||
LOG(WARN) << "bind() syscall failed: "
|
LOG(WARN) << "bind() syscall failed: "
|
||||||
|
|
23
src/util.cc
23
src/util.cc
|
@ -1748,29 +1748,6 @@ unsigned int msghdr_get_ecn(msghdr *msg, int family) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int fd_set_recv_ecn(int fd, int family) {
|
|
||||||
unsigned int tos = 1;
|
|
||||||
|
|
||||||
switch (family) {
|
|
||||||
case AF_INET:
|
|
||||||
if (setsockopt(fd, IPPROTO_IP, IP_RECVTOS, &tos,
|
|
||||||
static_cast<socklen_t>(sizeof(tos))) == -1) {
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
case AF_INET6:
|
|
||||||
if (setsockopt(fd, IPPROTO_IPV6, IPV6_RECVTCLASS, &tos,
|
|
||||||
static_cast<socklen_t>(sizeof(tos))) == -1) {
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
int fd_set_send_ecn(int fd, int family, unsigned int ecn) {
|
int fd_set_send_ecn(int fd, int family, unsigned int ecn) {
|
||||||
switch (family) {
|
switch (family) {
|
||||||
case AF_INET:
|
case AF_INET:
|
||||||
|
|
|
@ -921,8 +921,6 @@ int msghdr_get_local_addr(Address &dest, msghdr *msg, int family);
|
||||||
|
|
||||||
unsigned int msghdr_get_ecn(msghdr *msg, int family);
|
unsigned int msghdr_get_ecn(msghdr *msg, int family);
|
||||||
|
|
||||||
int fd_set_recv_ecn(int fd, int family);
|
|
||||||
|
|
||||||
int fd_set_send_ecn(int fd, int family, unsigned int ecn);
|
int fd_set_send_ecn(int fd, int family, unsigned int ecn);
|
||||||
#endif // ENABLE_HTTP3
|
#endif // ENABLE_HTTP3
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue