Bug 14258

Summary: IP_TOS and IP_TTL sockopt doesn't work on raw socket
Product: Base System Reporter: wim.livens <wim.livens>
Component: miscAssignee: ru <ru>
Status: Closed FIXED    
Severity: Affects Only Me    
Priority: Normal    
Version: 2.2.8-RELEASE   
Hardware: Any   
OS: Any   

Description wim.livens 1999-10-11 10:00:01 UTC
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.
Comment 1 Mike Heffner freebsd_committer freebsd_triage 2001-06-26 04:31:17 UTC
State Changed
From-To: open->closed

Fixed in sys/netinet/raw_ip.c,v 1.74.
Comment 2 ru freebsd_committer freebsd_triage 2001-06-26 08:12:19 UTC
Responsible Changed
From-To: freebsd-bugs->ru

Give more details on where and when this was fixed.