Re: KITTEN: IETF 75 - 76

Nicolas Williams <Nicolas.Williams@sun.com> Wed, 02 September 2009 15:45 UTC

Return-Path: <Nicolas.Williams@sun.com>
X-Original-To: kitten@core3.amsl.com
Delivered-To: kitten@core3.amsl.com
Received: from localhost (localhost [127.0.0.1]) by core3.amsl.com (Postfix) with ESMTP id 8EC4328C12E for <kitten@core3.amsl.com>; Wed, 2 Sep 2009 08:45:47 -0700 (PDT)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -4.701
X-Spam-Level:
X-Spam-Status: No, score=-4.701 tagged_above=-999 required=5 tests=[AWL=-0.955, BAYES_00=-2.599, HELO_MISMATCH_COM=0.553, MANGLED_AVOID=2.3, RCVD_IN_DNSWL_MED=-4]
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 GNdJzBvZ3jFg for <kitten@core3.amsl.com>; Wed, 2 Sep 2009 08:45:46 -0700 (PDT)
Received: from sca-ea-mail-3.sun.com (sca-ea-mail-3.Sun.COM [192.18.43.21]) by core3.amsl.com (Postfix) with ESMTP id 6793328C0CF for <kitten@ietf.org>; Wed, 2 Sep 2009 08:45:45 -0700 (PDT)
Received: from dm-central-01.central.sun.com ([129.147.62.4]) by sca-ea-mail-3.sun.com (8.13.6+Sun/8.12.9) with ESMTP id n82FhcUE017920 for <kitten@ietf.org>; Wed, 2 Sep 2009 15:43:38 GMT
Received: from binky.Central.Sun.COM (binky.Central.Sun.COM [129.153.128.104]) by dm-central-01.central.sun.com (8.13.8+Sun/8.13.8/ENSMAIL, v2.2) with ESMTP id n82FhbTq016664 for <kitten@ietf.org>; Wed, 2 Sep 2009 09:43:37 -0600 (MDT)
Received: from binky.Central.Sun.COM (localhost [127.0.0.1]) by binky.Central.Sun.COM (8.14.3+Sun/8.14.3) with ESMTP id n82FWheO009101; Wed, 2 Sep 2009 10:32:43 -0500 (CDT)
Received: (from nw141292@localhost) by binky.Central.Sun.COM (8.14.3+Sun/8.14.3/Submit) id n82FWfHl009100; Wed, 2 Sep 2009 10:32:41 -0500 (CDT)
X-Authentication-Warning: binky.Central.Sun.COM: nw141292 set sender to Nicolas.Williams@sun.com using -f
Date: Wed, 02 Sep 2009 10:32:41 -0500
From: Nicolas Williams <Nicolas.Williams@sun.com>
To: "Stefan (metze) Metzmacher" <metze@samba.org>
Subject: Re: KITTEN: IETF 75 - 76
Message-ID: <20090902153241.GJ1033@Sun.COM>
References: <4A87A69A.3050408@sun.com> <4A87E02D.7030503@isode.com> <200908180013.29152.leifj@mnt.se> <20090901131202.137bdd90.miallen@ioplex.com> <20090901173110.GL1033@Sun.COM> <396484EF-9812-40CE-9221-F1A1319FD10B@kth.se> <20090901181307.fe1d4efa.miallen@ioplex.com> <98F14484-1B48-45A1-86E7-5E78383F5109@kth.se> <20090901214059.17a309e6.miallen@ioplex.com> <4A9E22D9.9050405@samba.org>
Mime-Version: 1.0
Content-Type: text/plain; charset="us-ascii"
Content-Disposition: inline
In-Reply-To: <4A9E22D9.9050405@samba.org>
User-Agent: Mutt/1.5.7i
Cc: "kitten@ietf.org" <kitten@ietf.org>, Volker Lendecke <vl@SerNet.DE>
X-BeenThere: kitten@ietf.org
X-Mailman-Version: 2.1.9
Precedence: list
List-Id: Common Authentication Technologies - Next Generation <kitten.ietf.org>
List-Unsubscribe: <https://www.ietf.org/mailman/listinfo/kitten>, <mailto:kitten-request@ietf.org?subject=unsubscribe>
List-Archive: <http://www.ietf.org/mail-archive/web/kitten>
List-Post: <mailto:kitten@ietf.org>
List-Help: <mailto:kitten-request@ietf.org?subject=help>
List-Subscribe: <https://www.ietf.org/mailman/listinfo/kitten>, <mailto:kitten-request@ietf.org?subject=subscribe>
X-List-Received-Date: Wed, 02 Sep 2009 15:45:47 -0000

On Wed, Sep 02, 2009 at 09:46:33AM +0200, Stefan (metze) Metzmacher wrote:
> Michael B Allen schrieb:
> > When you call the function with the flag GSS_C_NOWAIT, the
> > implementation transmits the network request [1] and then checks to
> > see if data can be read (such as by using select(2)). If data is not
> > available, the function simply returns a status of EAGAIN. Now the
> > caller is free to perform other work (and thus it is async). But the
> > caller now knows that the function needs to be called again to
> > complete the operation. So later, it calls the function again. If
> > the network response has been received, it returns success.
> > Otherwise, if GSS_C_NOWAIT was supplied, it again returns EAGAIN. If
> > GSS_C_NOWAIT was not supplied, it waits for the operation to
> > complete (e.g. for a network response to be received) just like the
> > non-async call. In fact async and non-async uses the same function -
> > the GSS_C_NOWAIT flag alone controls async behavior.
> 
> That is true for system calls like send() and recv(), where the caller
> is supposed to call select. But for gssapi the caller would have to poll
> like this:
> 
> while (1) {
> 
> 	ret = gss_call(&minor, ...);
> 	if (ret != 0 && minor == EAGAIN) {
> 		continue;
> 	}
> 	...
> 	break;
> }
> 
> Or the application needs to try every few milli seconds...

Absolutely no polling.

Async I/O is not rocket science.  We can quibble over details, but we've
only got so many workable models.  And we have to be mindful that not
one model will result in fully portable application code.

Here are some reasonable models:

 - Completion callback (or, rather, a callback indicating that there's
   work to do, not necessarily completion)

   This implies either a threaded process model or an async I/O process
   model with one common event loop provided by the OS.

   This model is the simplest for apps to use, and it will be portable
   to Linux, *BSD, Solaris, Windows.  But not necessarily to embedded
   devices, real-time OSes, etc...

 - Return handles to I/O resources that the app can feed into its event
   loop.

   This is much more OS-specific.  On Unix/Unix-like OSes this means
   returning an array of file descriptors.  On Windows it means
   returning and array of file handles.  This too may not be terribly
   portable.  And it requires that the application plug the returned
   resources into its event loop, and take them out, on every call to
   these GSS functions.

I much prefer the callback model.  It will yield the most portable and
simplest code, even if it does not yield universally portable code.

> If the gss_init_sec_context implementation has finished the work
> it notifies the callback that it's done. But to get the actual results
> the caller needs to call the gss_init_sec_context_async() function again
> (or the gss_init_sec_context_output() function) and pass the same async
> cookie.

The partially established context argument is suitable for use as a
"cookie", therefore we don't need an extra cookie.

Callers of GISC and GASC today already have to ensure they're using all
the same input arguments (except for input tokens, of course), on every
call related to one security context establishement.  Therefore it seems
to me that it's not much to ask that async callers do the same.  That
means we can keep the callback prototype simple: it should take one, at
most two, arguments: a void * private data argument, and possibly the
"cookie" that you mention, which in this case would be the partially
established security context.

> I think something like this would make the api at least useful for Samba.

Anything that will actually work will, indeed, be useful to Samba.

Note that Samba can implement such a thing _now_ by using a worker
thread.