src/solaris/native/java/net/net_util_md.c
Print this page
rev 7400 : 8029607: Type of Service (TOS) cannot be set in IPv6 header
Reviewed-by: alanb
@@ -1349,11 +1349,11 @@
* 1. IPv6 on Solaris/Mac OS: no-op and will be set
* in flowinfo field when connecting TCP socket,
* or sending UDP packet.
* 2. IPv6 on Linux: By default Linux ignores flowinfo
* field so enable IPV6_FLOWINFO_SEND so that flowinfo
- * will be examined.
+ * will be examined. We also set the IPv4 TOS option in this case.
* 3. IPv4: set socket option based on ToS and Precedence
* fields (otherwise get invalid argument)
*/
if (level == IPPROTO_IP && opt == IP_TOS) {
int *iptos;
@@ -1365,13 +1365,15 @@
#endif
#if defined(AF_INET6) && defined(__linux__)
if (ipv6_available()) {
int optval = 1;
- return setsockopt(fd, IPPROTO_IPV6, IPV6_FLOWINFO_SEND,
- (void *)&optval, sizeof(optval));
+ if (setsockopt(fd, IPPROTO_IPV6, IPV6_FLOWINFO_SEND,
+ (void *)&optval, sizeof(optval)) < 0) {
+ return -1;
}
+ }
#endif
iptos = (int *)arg;
*iptos &= (IPTOS_TOS_MASK | IPTOS_PREC_MASK);
}