NET_SetSockOpt applies (IPTOS_TOS_MASK | IPTOS_PREC_MASK) mask to TOS value. This behaviour is from RFC 1349 TOS scheme which is no longer used by modern Linux kernel (and other systems like BSD, OS X), which instead uses an incompatible scheme from RFC 3260 (Diffserv/ECN).
This program prints 122 instead of the correct 123.
import java.net.*;
public class IptosBug {
public static void main(String[] args) throws Throwable {
DatagramSocket s = new DatagramSocket();
s.setTrafficClass(123);
System.out.println(s.getTrafficClass());
}
}
Suggested fix: remove the line
net_util_md.c:1360: *iptos &= (IPTOS_TOS_MASK | IPTOS_PREC_MASK);
(filed on behalf of networking engineers at Google)
This program prints 122 instead of the correct 123.
import java.net.*;
public class IptosBug {
public static void main(String[] args) throws Throwable {
DatagramSocket s = new DatagramSocket();
s.setTrafficClass(123);
System.out.println(s.getTrafficClass());
}
}
Suggested fix: remove the line
net_util_md.c:1360: *iptos &= (IPTOS_TOS_MASK | IPTOS_PREC_MASK);
(filed on behalf of networking engineers at Google)