Re: sockets APIs extensions for Host Identity Protocol

Keith Moore <moore@cs.utk.edu> Fri, 11 May 2007 14:52 UTC

Return-path: <discuss-bounces@apps.ietf.org>
Received: from [127.0.0.1] (helo=stiedprmman1.va.neustar.com) by megatron.ietf.org with esmtp (Exim 4.43) id 1HmWTY-0006uM-4s; Fri, 11 May 2007 10:52:08 -0400
Received: from discuss by megatron.ietf.org with local (Exim 4.43) id 1HmWTW-0006o5-Hh for discuss-confirm+ok@megatron.ietf.org; Fri, 11 May 2007 10:52:06 -0400
Received: from [10.91.34.44] (helo=ietf-mx.ietf.org) by megatron.ietf.org with esmtp (Exim 4.43) id 1HmWTW-0006nx-8A for discuss@apps.ietf.org; Fri, 11 May 2007 10:52:06 -0400
Received: from ka.cs.utk.edu ([160.36.56.221]) by ietf-mx.ietf.org with esmtp (Exim 4.43) id 1HmWTV-0001X2-U3 for discuss@apps.ietf.org; Fri, 11 May 2007 10:52:06 -0400
Received: from localhost (localhost [127.0.0.1]) by ka.cs.utk.edu (Postfix) with ESMTP id 5ABC2CB3D9; Fri, 11 May 2007 10:52:03 -0400 (EDT)
X-Virus-Scanned: by amavisd-new with ClamAV and SpamAssasin at cs.utk.edu
Received: from ka.cs.utk.edu ([127.0.0.1]) by localhost (ka.cs.utk.edu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 52pfQ5hBMclp; Fri, 11 May 2007 10:51:58 -0400 (EDT)
Received: from lust.indecency.org (user-119b1dm.biz.mindspring.com [66.149.133.182]) by ka.cs.utk.edu (Postfix) with ESMTP id E4EDFCB3C0; Fri, 11 May 2007 10:51:57 -0400 (EDT)
Message-ID: <4644830D.7050302@cs.utk.edu>
Date: Fri, 11 May 2007 10:51:57 -0400
From: Keith Moore <moore@cs.utk.edu>
User-Agent: Thunderbird 2.0.0.0 (Macintosh/20070326)
MIME-Version: 1.0
To: der Mouse <mouse@Rodents.Montreal.QC.CA>
Subject: Re: sockets APIs extensions for Host Identity Protocol
References: <Pine.SOL.4.64.0705041801060.14418@kekkonen.cs.hut.fi> <20070507082737.GB21759@nic.fr> <46413DD7.8020702@cs.utk.edu> <20070509121703.GA21070@nic.fr> <4641CA52.70504@cs.utk.edu> <Pine.LNX.4.64.0705091449360.26169@hermes-1.csi.cam.ac.uk> <4641D94C.9070304@cs.utk.edu> <Pine.SOL.4.64.0705102013550.10049@kekkonen.cs.hut.fi> <46436B10.5090706@cs.utk.edu> <Pine.SOL.4.64.0705102159020.10049@kekkonen.cs.hut.fi> <4643F873.3000501@cs.utk.edu> <Pine.SOL.4.64.0705110851440.24038@kekkonen.cs.hut.fi> <46442588.7020405@cs.utk.edu> <200705111314.JAA17866@Sparkle.Rodents.Montreal.QC.CA>
In-Reply-To: <200705111314.JAA17866@Sparkle.Rodents.Montreal.QC.CA>
X-Enigmail-Version: 0.95.0
OpenPGP: id=E1473978
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 7bit
X-Spam-Score: 0.1 (/)
X-Scan-Signature: 4b800b1eab964a31702fa68f1ff0e955
Cc: discuss@apps.ietf.org
X-BeenThere: discuss@apps.ietf.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: general discussion of application-layer protocols <discuss.apps.ietf.org>
List-Unsubscribe: <https://www1.ietf.org/mailman/listinfo/discuss>, <mailto:discuss-request@apps.ietf.org?subject=unsubscribe>
List-Post: <mailto:discuss@apps.ietf.org>
List-Help: <mailto:discuss-request@apps.ietf.org?subject=help>
List-Subscribe: <https://www1.ietf.org/mailman/listinfo/discuss>, <mailto:discuss-request@apps.ietf.org?subject=subscribe>
Errors-To: discuss-bounces@apps.ietf.org

der Mouse wrote:
>> more generally, getaddrinfo() sucks so bad that any excuse to get rid
>> of it is worth considering.
>>     
>
> What do you see as wrong with it?  (Not that I disagree; I see it as
> having problems too.  But I sure see it as a lot better than forcing
> application code to know about all the possible address families - sort
> of "the worst interface available except for all the others".  I'm just
> interested in what might be wrong with it that I haven't noticed.)
>   
I suspect I could write an RFC about what's wrong with getaddrinfo().

the nice thing about it is that it does two things for you.  one is that
it completely initializes sockaddr structures for you.   the other is
that (at least in recent versions?) it can take either a DNS name or an
address literal and do the right thing with it.  so if you want to use
that name or literal to initialize a sockaddr to open up a connection,
it can do that.

in a nutshell, the downsides are these (note, this is probably not a
complete list, just what's off the top of my head):

- it's actually more difficult to set the parameters for getaddrinfo()
to get it to do what you want, than it is to initialize the fields in a
sockaddr_in*

- getaddrinfo encourages use of string constants to specify ports,
rather than numeric constants, which is wrong -  it adds an extra layer
of indirection that can (and does) fail, and it tempts people to try to
use that layer of indirection to do things that violate protocol
specifications (like do a SRV lookup for protocols that aren't specified
to use SRV) or otherwise try to be too clever. for instance, I've seen
an implementation of getaddrinfo fail when given a numeric string
constant for the port, because that port couldn't be found in /etc/services.

- it has no way to be used asynchronously other than to put each call to
getaddrinfo in a separate thread, and even then, many implementations
are not thread-safe.

- it's not specified to use DNS.   so if a protocol is specified to use
DNS in some particular way, and the implementation of the protocol uses
getaddrinfo(), the implementation may fail to strictly follow the
protocol spec.  (yes, this is propagating an error that was present in
gethostbyname(), but getaddrinfo() missed the opportunity to fix it. 
some implementations do have a flag that insists that DNS be used)

- the handling of v4 vs v6 vs mapped v4 addresses is confusing.

 - it can lookup address literals but you still need to set the
AI_NUMERICHOST bit in the flags if the name field is an address literal,
if you want the code to work portably.  so in the common case where
you're passed a string that could either be a name or an address
literal, you still have to parse that string to determine whether it's
an address in order to know how to set that bit.  the default should be
to accept either a DNS name or address literal.  there could still be
options that would cause it to fail if the name parameter weren't a DNS
name or address literal.

- similarly for AI_NUMERICPORT for implementations that support that flag

- various platforms shipped with getaddrinfo() implementations based on
early specifications, so there's a fair amount of variation from one
platform to another in what features are actually supported.  it can be
a challenge to write portable code that uses it.

- address ordering often produces suboptimal results.  arguably this is
not the fault of getaddrinfo() except that it creates the expectation
that the API or kernel can do a good job of address ordering.