When sending a udp packet from an IPv6 socket to an IPv4 mapped address, I would expect the setting for IPV6_TCLASS to be used in the TOS IP header field. It does not appear to be. A similar mapping for TTL should be present, though I did not check for that. Can be seen with a simple c program and wireshark: #include <stdio.h> #include <string.h> #include <netinet/in.h> #include <sys/types.h> #include <sys/socket.h> #include <netdb.h> int main() { int s = socket(PF_INET6, SOCK_DGRAM, IPPROTO_UDP); if (s < 0) { perror("socket"); return -1; } int value = (40 << 2) & 0xFC; int ret = setsockopt(s, IPPROTO_IPV6, IPV6_TCLASS, &value, sizeof(value)); if (ret < 0) { perror("setsockopt"); return -2; } struct addrinfo hints; memset(&hints, 0, sizeof(hints)); struct addrinfo *res = NULL; ret = getaddrinfo("::ffff:10.10.10.10", "1234", &hints, &res); if (ret != 0) { perror("getaddrinfo"); return -3; } const char *msg = "hello world"; ssize_t n = sendto(s, msg, strlen(msg), 0, res->ai_addr, res->ai_addrlen); if (n < 0) { freeaddrinfo(res); perror("sendto"); return -4; } freeaddrinfo(res); return 0; }
Created attachment 193614 [details] Patch to set tos interval value when tclass is set This patch seems to fix the issue for me. I'm not sure if this is the right way to fix this though.