From nobody@FreeBSD.ORG Mon Oct 11 01:58:53 1999
Return-Path: <nobody@FreeBSD.ORG>
Received: by hub.freebsd.org (Postfix, from userid 32767)
	id 4C24014D52; Mon, 11 Oct 1999 01:58:53 -0700 (PDT)
Message-Id: <19991011085853.4C24014D52@hub.freebsd.org>
Date: Mon, 11 Oct 1999 01:58:53 -0700 (PDT)
From: wim.livens@alcatel.be
Sender: nobody@FreeBSD.ORG
To: freebsd-gnats-submit@freebsd.org
Subject: IP_TOS and IP_TTL sockopt doesn't work on raw socket
X-Send-Pr-Version: www-1.0

>Number:         14258
>Category:       misc
>Synopsis:       IP_TOS and IP_TTL sockopt doesn't work on raw socket
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    ru
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Mon Oct 11 02:00:01 PDT 1999
>Closed-Date:    Mon Jun 25 20:31:17 PDT 2001
>Last-Modified:  Tue Jun 26 00:14:26 PDT 2001
>Originator:     Wim Livens
>Release:        2.2.8-RELEASE
>Organization:
Alcatel
>Environment:
FreeBSD btm22v.rc.bel.alcatel.be 2.2.8-RELEASE FreeBSD 2.2.8-RELEASE #5: Fri Oct  8 15:54:19 CEST 1999     livensw@btm22v.rc.bel.alcatel.be:/home/users/livensw/work/sys/compile/ALTQ  i386
>Description:
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.

>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.

>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)

>Release-Note:
>Audit-Trail:
State-Changed-From-To: open->closed 
State-Changed-By: mikeh 
State-Changed-When: Mon Jun 25 20:31:17 PDT 2001 
State-Changed-Why:  
Fixed in sys/netinet/raw_ip.c,v 1.74.

http://www.FreeBSD.org/cgi/query-pr.cgi?pr=14258 
Responsible-Changed-From-To: freebsd-bugs->ru 
Responsible-Changed-By: ru 
Responsible-Changed-When: Tue Jun 26 00:12:19 PDT 2001 
Responsible-Changed-Why:  
Give more details on where and when this was fixed. 

http://www.FreeBSD.org/cgi/query-pr.cgi?pr=14258 
>Unformatted:
