Re: [Hipsec] draft-ietf-hip-native-api-09-pre

Miika Komu <miika.komu@hiit.fi> Tue, 25 August 2009 07:44 UTC

Return-Path: <miika.komu@hiit.fi>
X-Original-To: hipsec@core3.amsl.com
Delivered-To: hipsec@core3.amsl.com
Received: from localhost (localhost [127.0.0.1]) by core3.amsl.com (Postfix) with ESMTP id B5EB13A6B9E for <hipsec@core3.amsl.com>; Tue, 25 Aug 2009 00:44:33 -0700 (PDT)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -2.599
X-Spam-Level:
X-Spam-Status: No, score=-2.599 tagged_above=-999 required=5 tests=[BAYES_00=-2.599]
Received: from mail.ietf.org ([64.170.98.32]) by localhost (core3.amsl.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id nApGf9scpEWF for <hipsec@core3.amsl.com>; Tue, 25 Aug 2009 00:44:32 -0700 (PDT)
Received: from argo.otaverkko.fi (argo.otaverkko.fi [212.68.0.2]) by core3.amsl.com (Postfix) with ESMTP id 74C213A6A2C for <hipsec@ietf.org>; Tue, 25 Aug 2009 00:44:32 -0700 (PDT)
Received: from [192.168.1.2] (cs27101111.pp.htv.fi [89.27.101.111]) by argo.otaverkko.fi (Postfix) with ESMTP id 234C225ED11; Tue, 25 Aug 2009 10:44:38 +0300 (EEST)
Message-ID: <4A93966C.2000002@hiit.fi>
Date: Tue, 25 Aug 2009 10:44:44 +0300
From: Miika Komu <miika.komu@hiit.fi>
User-Agent: Thunderbird 2.0.0.23 (X11/20090817)
MIME-Version: 1.0
To: Andrew McGregor <andrew@indranet.co.nz>
References: <4A8DBB16.3010705@hiit.fi> <0DF156EE7414494187B087A3C279BDB404AD7C73@XCH-NW-6V1.nw.nos.boeing.com> <4A8E25C6.1090100@hiit.fi> <0DF156EE7414494187B087A3C279BDB404AD7C75@XCH-NW-6V1.nw.nos.boeing.com> <4A930581.8080100@hiit.fi> <EAD6D1A8-EB90-4921-9428-1094BA00DAC0@indranet.co.nz> <0DF156EE7414494187B087A3C279BDB404AD7C7C@XCH-NW-6V1.nw.nos.boeing.com> <DED135E8-7FAD-49EE-B712-BFF2EDC53735@indranet.co.nz>
In-Reply-To: <DED135E8-7FAD-49EE-B712-BFF2EDC53735@indranet.co.nz>
Content-Type: text/plain; charset="ISO-8859-1"; format="flowed"
Content-Transfer-Encoding: 7bit
Cc: hip WG <hipsec@ietf.org>
Subject: Re: [Hipsec] draft-ietf-hip-native-api-09-pre
X-BeenThere: hipsec@ietf.org
X-Mailman-Version: 2.1.9
Precedence: list
Reply-To: miika.komu@hiit.fi
List-Id: "This is the official IETF Mailing List for the HIP Working Group." <hipsec.ietf.org>
List-Unsubscribe: <https://www.ietf.org/mailman/listinfo/hipsec>, <mailto:hipsec-request@ietf.org?subject=unsubscribe>
List-Archive: <http://www.ietf.org/mail-archive/web/hipsec>
List-Post: <mailto:hipsec@ietf.org>
List-Help: <mailto:hipsec-request@ietf.org?subject=help>
List-Subscribe: <https://www.ietf.org/mailman/listinfo/hipsec>, <mailto:hipsec-request@ietf.org?subject=subscribe>
X-List-Received-Date: Tue, 25 Aug 2009 07:44:33 -0000

Andrew McGregor wrote:

Hi,

> On 25/08/2009, at 10:24 AM, Ahrenholz, Jeffrey M wrote:
> 
>>>> Based on this discussion, it appears that the best way for future
>>>> proofing is to include a flag for getaddrinfo() in the hints
>>>> arguments that will result in sockaddr_hip_long structures instead
>>>> of sockaddr_hip. This way, applications get exactly what they want
>>>> and can store the HITs easily in their ACLs. I'd also remove the
>>>> extra space reserved space because it seems that it's not very
>>>> usable for future proofing as it is now.
>>>>
>>>> Jeff, how do you feel about this or do you have a better suggestion?
>>>
>>> I think you'd be better to define more than a flag... an
>>> explicit size
>>> (or enum) would be better.  That way if some other odd size
>>> becomes a
>>> requirement later, it's not such an annoyance to fit in to the API
>>
>> yes, a size or flag makes sense; looks like struct addrinfo already has
>> "size_t ai_addrlen;" but that field must be zero when used as hints
>> (looking at getaddrinfo(3) man)
>>
>> other calls such as connect(), bind(), and sendto() already take a
>> "socklen_t addrlen" argument

the socket address structure already contains the size of the socket 
within the first field. Having yet another size within the structure or 
a variable length socket address structure is confusing for people used 
to constant size structures such as sockaddr_in, sockaddr_in6 and 
sockaddr_storage.

Have a look at section "EXAMPLES" on getaddrinfo() FreeBSD man pages:

http://www.gsp.com/cgi-bin/man.cgi?section=3&topic=getaddrinfo

If there is an additional length field and it must be used in socket 
calls, it disrupts the flow of the client side example.

> Ah, in that case... getaddrinfo should return whatever it can, and 
> applications should be required to check lengths if they care.  That 
> avoids coding in bugs early.

The problem is that they do have check lengths when the applications 
fill in the socket address structures by themselves. I think it also a 
show stopper for allocations from the heap (struct addrinfo foo;). 
Dynamic allocations get somewhat tricky because defining the allocated 
size is not trivial.

A way to avoid the memory-related problem and "client flow" problem 
would be to define sockaddr_hip to contain the maximum number of bytes 
similarly as sockaddr_storage does. Would that work for you?

We would still need the actual HIT field to be defined as an union to 
facilitate naming of larger HITs withing the structure in a backwards 
compatible way. Right?