Merge pull request #2592 from babarosaM33/master

refine tos setsockopt in redir and udprelay
This commit is contained in:
Max Lv
2020-01-18 07:31:38 +08:00
committed by GitHub
2 changed files with 15 additions and 4 deletions
+7 -2
View File
@@ -752,8 +752,13 @@ accept_cb(EV_P_ ev_io *w, int revents)
setnonblocking(remotefd);
if (listener->tos >= 0) {
if (setsockopt(remotefd, IPPROTO_IP, IP_TOS, &listener->tos, sizeof(listener->tos)) != 0) {
ERROR("setsockopt IP_TOS");
int rc = setsockopt(remotefd, IPPROTO_IP, IP_TOS, &listener->tos, sizeof(listener->tos));
if (rc < 0 && errno != ENOPROTOOPT) {
LOGE("setting ipv4 dscp failed: %d", errno);
}
rc = setsockopt(remotefd, IPPROTO_IPV6, IPV6_TCLASS, &listener->tos, sizeof(listener->tos));
if (rc < 0 && errno != ENOPROTOOPT) {
LOGE("setting ipv6 dscp failed: %d", errno);
}
}
+8 -2
View File
@@ -497,8 +497,14 @@ create_server_socket(const char *host, const char *port)
#ifdef IP_TOS
// Set QoS flag
int tos = 46 << 2;
int proto = rp->ai_family == AF_INET6 ? IPPROTO_IP : IPPROTO_IPV6;
setsockopt(server_sock, proto, IP_TOS, &tos, sizeof(tos));
int rc = setsockopt(server_sock, IPPROTO_IP, IP_TOS, &tos, sizeof(tos));
if (rc < 0 && errno != ENOPROTOOPT) {
LOGE("setting ipv4 dscp failed: %d", errno);
}
rc = setsockopt(server_sock, IPPROTO_IPV6, IPV6_TCLASS, &tos, sizeof(tos));
if (rc < 0 && errno != ENOPROTOOPT) {
LOGE("setting ipv6 dscp failed: %d", errno);
}
#endif
#ifdef MODULE_REDIR