Browse Source
Merge pull request #2592 from babarosaM33/master
refine tos setsockopt in redir and udprelay
pull/2604/head
Max Lv
5 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with
15 additions and
4 deletions
-
src/redir.c
-
src/udprelay.c
|
|
@ -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); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
@ -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 |
|
|
|