set_dscp(int fd, uint8_t dscp)
{
int val;
+ bool success;
if (dscp > 63) {
return EINVAL;
}
+ /* Note: this function is used for both of IPv4 and IPv6 sockets */
+ success = false;
val = dscp << 2;
if (setsockopt(fd, IPPROTO_IP, IP_TOS, &val, sizeof val)) {
- return sock_errno();
+ if (sock_errno() != ENOPROTOOPT) {
+ return sock_errno();
+ }
+ } else {
+ success = true;
+ }
+ if (setsockopt(fd, IPPROTO_IPV6, IPV6_TCLASS, &val, sizeof val)) {
+ if (sock_errno() != ENOPROTOOPT) {
+ return sock_errno();
+ }
+ } else {
+ success = true;
+ }
+ if (!success) {
+ return ENOPROTOOPT;
}
return 0;
* connect(), the handshake SYN frames will be sent with a TOS of 0. */
error = set_dscp(fd, dscp);
if (error) {
- VLOG_ERR("%s: socket: %s", target, sock_strerror(error));
+ VLOG_ERR("%s: set_dscp: %s", target, sock_strerror(error));
goto exit;
}
* connect(), the handshake SYN frames will be sent with a TOS of 0. */
error = set_dscp(fd, dscp);
if (error) {
- VLOG_ERR("%s: socket: %s", target, sock_strerror(error));
+ VLOG_ERR("%s: set_dscp: %s", target, sock_strerror(error));
goto error;
}
}
}
+#ifndef _WIN32
void
xpipe(int fds[2])
{
xset_nonblocking(fds[0]);
xset_nonblocking(fds[1]);
}
+#endif
static int
getsockopt_int(int fd, int level, int option, const char *optname, int *valuep)