| Summary: | IP_TOS and IP_TTL sockopt doesn't work on raw socket | ||
|---|---|---|---|
| Product: | Base System | Reporter: | wim.livens <wim.livens> |
| Component: | misc | Assignee: | ru <ru> |
| Status: | Closed FIXED | ||
| Severity: | Affects Only Me | ||
| Priority: | Normal | ||
| Version: | 2.2.8-RELEASE | ||
| Hardware: | Any | ||
| OS: | Any | ||
State Changed From-To: open->closed Fixed in sys/netinet/raw_ip.c,v 1.74. Responsible Changed From-To: freebsd-bugs->ru Give more details on where and when this was fixed. |
I've noticed that the IP_TOS socket option doesn't work on raw sockets. There is no error returned and the TOS is stored in the protocol control block but when the packet headers are constructed, a hardcoded zero is put (instead of inp->inp_ip_tos). The same holds for the ttl. Fix: change the following line rip_output(m, so, dst): (in netinet/raw_ip.c) ip->ip_tos = 0; to ip->ip_tos = inp->inp_ip_tos; (similar for ip_ttl) How-To-Repeat: do something like : sendsock=socket(AF_INET, SOCK_RAW, IPPROTO_OSPFIGP); tos=0xf0; if(setsockopt(sendsock, IPPROTO_IP, IP_TOS, (void*)&tos, 4) == -1) { printf("can't set tos bits\n"); exit(1); } sendto(sendsock, &sendbuf, 12, 0, (struct sockaddr *) &dest, 16); Then look with tcpdump and you'll see that tos is still zero.