From nobody@FreeBSD.org  Fri Oct 17 00:19:29 2008
Return-Path: <nobody@FreeBSD.org>
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id 09964106568C
	for <freebsd-gnats-submit@FreeBSD.org>; Fri, 17 Oct 2008 00:19:29 +0000 (UTC)
	(envelope-from nobody@FreeBSD.org)
Received: from www.freebsd.org (www.freebsd.org [IPv6:2001:4f8:fff6::21])
	by mx1.freebsd.org (Postfix) with ESMTP id EBA528FC1B
	for <freebsd-gnats-submit@FreeBSD.org>; Fri, 17 Oct 2008 00:19:28 +0000 (UTC)
	(envelope-from nobody@FreeBSD.org)
Received: from www.freebsd.org (localhost [127.0.0.1])
	by www.freebsd.org (8.14.3/8.14.3) with ESMTP id m9H0JS5m085626
	for <freebsd-gnats-submit@FreeBSD.org>; Fri, 17 Oct 2008 00:19:28 GMT
	(envelope-from nobody@www.freebsd.org)
Received: (from nobody@localhost)
	by www.freebsd.org (8.14.3/8.14.3/Submit) id m9H0JSIq085625;
	Fri, 17 Oct 2008 00:19:28 GMT
	(envelope-from nobody)
Message-Id: <200810170019.m9H0JSIq085625@www.freebsd.org>
Date: Fri, 17 Oct 2008 00:19:28 GMT
From: Bruce Cran <bruce@cran.org.uk>
To: freebsd-gnats-submit@FreeBSD.org
Subject: [patch] [libc] add support for SCTP to getaddrinfo(3)
X-Send-Pr-Version: www-3.1
X-GNATS-Notify:

>Number:         128167
>Category:       bin
>Synopsis:       [patch] [libc] add support for SCTP to getaddrinfo(3)
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    ume
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Fri Oct 17 00:20:01 UTC 2008
>Closed-Date:    Sun Apr 12 19:22:32 UTC 2009
>Last-Modified:  Sun Apr 12 19:22:32 UTC 2009
>Originator:     Bruce Cran
>Release:        8.0-CURRENT
>Organization:
>Environment:
FreeBSD gluon.draftnet 8.0-CURRENT FreeBSD 8.0-CURRENT #2: Sun Oct 12 12:45:10 BST 2008 brucec@gluon.draftnet:/usr/obj/usr/src/sys/BOX i386
>Description:
The attached patch allows getaddrinfo(3) to be used with SCTP.
>How-To-Repeat:

>Fix:


Patch attached with submission follows:

--- getaddrinfo.c	2007-09-05 19:08:14.000000000 +0100
+++ getaddrinfo.c.new	2008-10-17 01:01:42.000000000 +0100
@@ -170,13 +170,19 @@
 #ifdef INET6
 	{ PF_INET6, SOCK_DGRAM, IPPROTO_UDP, "udp", 0x07 },
 	{ PF_INET6, SOCK_STREAM, IPPROTO_TCP, "tcp", 0x07 },
+	{ PF_INET6, SOCK_STREAM, IPPROTO_SCTP, "sctp", 0x07 },
+	{ PF_INET6, SOCK_SEQPACKET, IPPROTO_SCTP, "sctp", 0x07 },
 	{ PF_INET6, SOCK_RAW, ANY, NULL, 0x05 },
 #endif
 	{ PF_INET, SOCK_DGRAM, IPPROTO_UDP, "udp", 0x07 },
 	{ PF_INET, SOCK_STREAM, IPPROTO_TCP, "tcp", 0x07 },
+	{ PF_INET, SOCK_STREAM, IPPROTO_SCTP, "sctp", 0x07 },
+	{ PF_INET, SOCK_SEQPACKET, IPPROTO_SCTP, "sctp", 0x07 },
 	{ PF_INET, SOCK_RAW, ANY, NULL, 0x05 },
 	{ PF_UNSPEC, SOCK_DGRAM, IPPROTO_UDP, "udp", 0x07 },
 	{ PF_UNSPEC, SOCK_STREAM, IPPROTO_TCP, "tcp", 0x07 },
+	{ PF_UNSPEC, SOCK_STREAM, IPPROTO_SCTP, "sctp", 0x07 },
+	{ PF_UNSPEC, SOCK_SEQPACKET, IPPROTO_SCTP, "sctp", 0x07 },
 	{ PF_UNSPEC, SOCK_RAW, ANY, NULL, 0x05 },
 	{ -1, 0, 0, NULL, 0 },
 };
@@ -417,10 +423,12 @@
 				if (ex->e_protocol == ANY)
 					continue;
 				if (pai->ai_socktype == ex->e_socktype &&
-				    pai->ai_protocol != ex->e_protocol) {
-					ERR(EAI_BADHINTS);
-				}
+					pai->ai_protocol == ex->e_protocol)
+					break;
 			}
+
+			if (ex->e_af < 0)
+				ERR(EAI_BADHINTS);
 		}
 	}
 


>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: freebsd-bugs->freebsd-net 
Responsible-Changed-By: brucec 
Responsible-Changed-When: Mon Mar 23 21:18:26 UTC 2009 
Responsible-Changed-Why:  
Over to maintainer(s). 

http://www.freebsd.org/cgi/query-pr.cgi?pr=128167 
State-Changed-From-To: open->patched 
State-Changed-By: ume 
State-Changed-When: Wed Mar 25 16:27:38 UTC 2009 
State-Changed-Why:  
Thank you!  Committed it with modification.  At least Apache didn't 
work with getaddrinfo(3) which your patch is applied. 


Responsible-Changed-From-To: freebsd-net->ume 
Responsible-Changed-By: ume 
Responsible-Changed-When: Wed Mar 25 16:27:38 UTC 2009 
Responsible-Changed-Why:  
Thank you!  Committed it with modification.  At least Apache didn't 
work with getaddrinfo(3) which your patch is applied. 

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

From: dfilter@FreeBSD.ORG (dfilter service)
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: bin/128167: commit references a PR
Date: Wed, 25 Mar 2009 16:23:55 +0000 (UTC)

 Author: ume
 Date: Wed Mar 25 16:23:43 2009
 New Revision: 190416
 URL: http://svn.freebsd.org/changeset/base/190416
 
 Log:
   Add support for SCTP to getaddrinfo(3).
   Now, getaddrinfo(3) returns two SOCK_STREAMs, IPPROTO_TCP and
   IPPROTO_SCTP.  It confuses some programs.  If getaddrinfo(3) returns
   IPPROTO_SCTP when SOCK_STREAM is specified by hints.ai_socktype, at
   least Apache doesn't work.  So, I made getaddrinfo(3) to return
   IPPROTO_SCTP with SOCK_STREAM only when IPPROTO_SCTP is specified
   explicitly by hints.ai_protocol.
   
   PR:		bin/128167
   Submitted by:	Bruce Cran <bruce__at__cran.org.uk> (partly)
   MFC after:	2 week
 
 Modified:
   head/lib/libc/net/getaddrinfo.c
 
 Modified: head/lib/libc/net/getaddrinfo.c
 ==============================================================================
 --- head/lib/libc/net/getaddrinfo.c	Wed Mar 25 15:42:07 2009	(r190415)
 +++ head/lib/libc/net/getaddrinfo.c	Wed Mar 25 16:23:43 2009	(r190416)
 @@ -165,18 +165,24 @@ struct explore {
  
  static const struct explore explore[] = {
  #if 0
 -	{ PF_LOCAL, 0, ANY, ANY, NULL, 0x01 },
 +	{ PF_LOCAL, ANY, ANY, NULL, 0x01 },
  #endif
  #ifdef INET6
  	{ PF_INET6, SOCK_DGRAM, IPPROTO_UDP, "udp", 0x07 },
  	{ PF_INET6, SOCK_STREAM, IPPROTO_TCP, "tcp", 0x07 },
 +	{ PF_INET6, SOCK_STREAM, IPPROTO_SCTP, "sctp", 0x03 },
 +	{ PF_INET6, SOCK_SEQPACKET, IPPROTO_SCTP, "sctp", 0x07 },
  	{ PF_INET6, SOCK_RAW, ANY, NULL, 0x05 },
  #endif
  	{ PF_INET, SOCK_DGRAM, IPPROTO_UDP, "udp", 0x07 },
  	{ PF_INET, SOCK_STREAM, IPPROTO_TCP, "tcp", 0x07 },
 +	{ PF_INET, SOCK_STREAM, IPPROTO_SCTP, "sctp", 0x03 },
 +	{ PF_INET, SOCK_SEQPACKET, IPPROTO_SCTP, "sctp", 0x07 },
  	{ PF_INET, SOCK_RAW, ANY, NULL, 0x05 },
  	{ PF_UNSPEC, SOCK_DGRAM, IPPROTO_UDP, "udp", 0x07 },
  	{ PF_UNSPEC, SOCK_STREAM, IPPROTO_TCP, "tcp", 0x07 },
 +	{ PF_UNSPEC, SOCK_STREAM, IPPROTO_SCTP, "sctp", 0x03 },
 +	{ PF_UNSPEC, SOCK_SEQPACKET, IPPROTO_SCTP, "sctp", 0x07 },
  	{ PF_UNSPEC, SOCK_RAW, ANY, NULL, 0x05 },
  	{ -1, 0, 0, NULL, 0 },
  };
 @@ -417,10 +423,12 @@ getaddrinfo(const char *hostname, const 
  				if (ex->e_protocol == ANY)
  					continue;
  				if (pai->ai_socktype == ex->e_socktype &&
 -				    pai->ai_protocol != ex->e_protocol) {
 -					ERR(EAI_BADHINTS);
 -				}
 +				    pai->ai_protocol == ex->e_protocol)
 +					break;
  			}
 +
 +			if (ex->e_af < 0)
 +				ERR(EAI_BADHINTS);
  		}
  	}
  
 @@ -1344,6 +1352,7 @@ get_port(struct addrinfo *ai, const char
  		return EAI_SERVICE;
  	case SOCK_DGRAM:
  	case SOCK_STREAM:
 +	case SOCK_SEQPACKET:
  		allownumeric = 1;
  		break;
  	case ANY:
 @@ -1373,13 +1382,17 @@ get_port(struct addrinfo *ai, const char
  	} else {
  		if (ai->ai_flags & AI_NUMERICSERV)
  			return EAI_NONAME;
 -		switch (ai->ai_socktype) {
 -		case SOCK_DGRAM:
 +
 +		switch (ai->ai_protocol) {
 +		case IPPROTO_UDP:
  			proto = "udp";
  			break;
 -		case SOCK_STREAM:
 +		case IPPROTO_TCP:
  			proto = "tcp";
  			break;
 +		case IPPROTO_SCTP:
 +			proto = "sctp";
 +			break;
  		default:
  			proto = NULL;
  			break;
 _______________________________________________
 svn-src-all@freebsd.org mailing list
 http://lists.freebsd.org/mailman/listinfo/svn-src-all
 To unsubscribe, send any mail to "svn-src-all-unsubscribe@freebsd.org"
 
State-Changed-From-To: patched->closed 
State-Changed-By: ume 
State-Changed-When: Sun Apr 12 19:21:58 UTC 2009 
State-Changed-Why:  
I've MFC'ed it into RELENG_7.  Thanks again. 

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