From marka@isc.org  Mon Mar 25 04:04:28 2013
Return-Path: <marka@isc.org>
Received: from mx1.freebsd.org (mx1.FreeBSD.org [8.8.178.115])
	by hub.freebsd.org (Postfix) with ESMTP id 6E0EB9E7
	for <FreeBSD-gnats-submit@freebsd.org>; Mon, 25 Mar 2013 04:04:28 +0000 (UTC)
	(envelope-from marka@isc.org)
Received: from mx.ams1.isc.org (mx.ams1.isc.org [IPv6:2001:500:60::65])
	by mx1.freebsd.org (Postfix) with ESMTP id 2F0917F1
	for <FreeBSD-gnats-submit@freebsd.org>; Mon, 25 Mar 2013 04:04:27 +0000 (UTC)
Received: from bikeshed.isc.org (bikeshed.isc.org [IPv6:2001:4f8:3:d::19])
	(using TLSv1 with cipher DHE-RSA-CAMELLIA256-SHA (256/256 bits))
	(Client CN "mail.isc.org", Issuer "RapidSSL CA" (not verified))
	by mx.ams1.isc.org (Postfix) with ESMTPS id B47825F9887
	for <FreeBSD-gnats-submit@freebsd.org>; Mon, 25 Mar 2013 04:04:16 +0000 (UTC)
	(envelope-from marka@isc.org)
Received: from sex.dv.isc.org (c211-30-172-21.carlnfd1.nsw.optusnet.com.au [211.30.172.21])
	(using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits))
	(Client did not present a certificate)
	by bikeshed.isc.org (Postfix) with ESMTPSA id 7BEE1216C3B
	for <FreeBSD-gnats-submit@freebsd.org>; Mon, 25 Mar 2013 04:04:14 +0000 (UTC)
	(envelope-from marka@isc.org)
Received: from sex.dv.isc.org (localhost [127.0.0.1])
	by sex.dv.isc.org (8.14.6/8.14.6) with ESMTP id r2P43xxB049988
	for <FreeBSD-gnats-submit@freebsd.org>; Mon, 25 Mar 2013 15:03:59 +1100 (EST)
	(envelope-from marka@sex.dv.isc.org)
Received: (from root@localhost)
	by sex.dv.isc.org (8.14.6/8.14.6/Submit) id r2P43xtG049987;
	Mon, 25 Mar 2013 15:03:59 +1100 (EST)
	(envelope-from marka)
Message-Id: <201303250403.r2P43xtG049987@sex.dv.isc.org>
Date: Mon, 25 Mar 2013 15:03:59 +1100 (EST)
From: Mark Andrews <marka@isc.org>
Reply-To: Mark Andrews <marka@isc.org>
To: FreeBSD-gnats-submit@freebsd.org
Cc:
Subject: Wrong control used to return TOS. [patch]
X-Send-Pr-Version: 3.114
X-GNATS-Notify:

>Number:         177362
>Category:       kern
>Synopsis:       [netinet] [patch] Wrong control used to return TOS
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-net
>State:          feedback
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Mon Mar 25 04:10:00 UTC 2013
>Closed-Date:    
>Last-Modified:  Tue May 07 04:45:24 UTC 2013
>Originator:     Mark Andrews
>Release:        FreeBSD 8.4-BETA1 i386
>Organization:
ISC
>Environment:
System: FreeBSD sex.dv.isc.org 8.4-BETA1 FreeBSD 8.4-BETA1 #25 r248493M: Tue Mar 19 21:43:37 EST 2013 marka@sex.dv.isc.org:/usr/obj/usr/src/sys/DEBUG i386


>Description:

	TOS is return using wrong control.  It should be IP_TOS, IPPROTO_IP
	not IP_RECVTOS, IPPROTO_IP.  The latter is the flag to turn returning
	the value on or off.

	Compare with TCLASS in IPv6.  The value is returned using 
	IPPROTO_IPV6 and IPV6_TCLASS not IPPROTO_IPV6 and IPV6_RECVTCLASS.

>How-To-Repeat:

>Fix:

Index: sys/netinet/ip_input.c
===================================================================
--- sys/netinet/ip_input.c	(revision 248693)
+++ sys/netinet/ip_input.c	(working copy)
@@ -1713,7 +1713,7 @@
 	}
 	if (inp->inp_flags & INP_RECVTOS) {
 		*mp = sbcreatecontrol((caddr_t) &ip->ip_tos,
-		    sizeof(u_char), IP_RECVTOS, IPPROTO_IP);
+		    sizeof(u_char), IP_TOS, IPPROTO_IP);
 		if (*mp)
 			mp = &(*mp)->m_next;
 	}
>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: freebsd-bugs->freebsd-net 
Responsible-Changed-By: linimon 
Responsible-Changed-When: Wed Mar 27 01:45:58 UTC 2013 
Responsible-Changed-Why:  
Over to maintainer(s). 

http://www.freebsd.org/cgi/query-pr.cgi?pr=177362 

From: Michael Tuexen <tuexen@freebsd.org>
To: bug-followup@FreeBSD.org,
 marka@isc.org
Cc:  
Subject: Re: kern/177362: [netinet] [patch] Wrong control used to return TOS
Date: Wed, 27 Mar 2013 10:45:48 +0100

 It was not done by accident. The returned cmsg_type is IP_RECVTOS =
 instead of
 IP_TOS to keep it consistent with the handling of the IP_RECVTTL socket =
 option.
 I found it more important to be consistent within the same protocol =
 family
 than across different ones.
 I think that unfortunately IP_RECVTOS is not defined in any standard.
 
 Best regards
 Michael=

From: Mark Andrews <marka@isc.org>
To: Michael Tuexen <tuexen@freebsd.org>
Cc: bug-followup@FreeBSD.org
Subject: Re: kern/177362: [netinet] [patch] Wrong control used to return TOS
Date: Wed, 27 Mar 2013 22:54:06 +1100

 In message <25EB2335-645C-42ED-B90A-6D07A33280DB@freebsd.org>, Michael Tuexen w
 rites:
 > It was not done by accident. The returned cmsg_type is IP_RECVTOS instead 
 > of IP_TOS to keep it consistent with the handling of the IP_RECVTTL socket 
 > option.
 > I found it more important to be consistent within the same protocol family
 > than across different ones.
 > I think that unfortunately IP_RECVTOS is not defined in any standard.
 > 
 > Best regards
 > Michael
 
 And Linux uses IP_TOS to return the value.
 
 -- 
 Mark Andrews, ISC
 1 Seymour St., Dundas Valley, NSW 2117, Australia
 PHONE: +61 2 9871 4742                 INTERNET: marka@isc.org

From: Michael Tuexen <tuexen@freebsd.org>
To: Mark Andrews <marka@isc.org>
Cc: bug-followup@FreeBSD.org
Subject: Re: kern/177362: [netinet] [patch] Wrong control used to return TOS
Date: Wed, 27 Mar 2013 13:16:30 +0100

 On Mar 27, 2013, at 12:54 PM, Mark Andrews wrote:
 
 >=20
 > In message <25EB2335-645C-42ED-B90A-6D07A33280DB@freebsd.org>, Michael =
 Tuexen w
 > rites:
 >> It was not done by accident. The returned cmsg_type is IP_RECVTOS =
 instead=20
 >> of IP_TOS to keep it consistent with the handling of the IP_RECVTTL =
 socket=20
 >> option.
 >> I found it more important to be consistent within the same protocol =
 family
 >> than across different ones.
 >> I think that unfortunately IP_RECVTOS is not defined in any standard.
 >>=20
 >> Best regards
 >> Michael
 >=20
 > And Linux uses IP_TOS to return the value.
 ... which is consistent with the IP_RECVTTL socket option on Linux, =
 where it returns
 a cmsg with cmsg_type IP_TTL, which is also different from how this is =
 handled in
 FreeBSD.
 
 I think Solaris uses for IPv4 socket options the same cmsg_type
 as the optname for the socket option to enable the reception of the =
 cmsg.
 
 So it looks like there is no standard here, Linux, FreeBSD and Solaris
 are each consistent with itself, but Linux does it differently from
 FreeBSD and Solaris.
 
 Best regards
 Michael
 >=20
 > --=20
 > Mark Andrews, ISC
 > 1 Seymour St., Dundas Valley, NSW 2117, Australia
 > PHONE: +61 2 9871 4742                 INTERNET: marka@isc.org
 >=20
 
State-Changed-From-To: open->feedback 
State-Changed-By: hiren 
State-Changed-When: Tue May 7 04:42:42 UTC 2013 
State-Changed-Why:  
tuexen@ does not see a need for code change. 
Waiting for submitter feedback. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=177362 
>Unformatted:
