[ccan] [PATCH 2/2] net: Extend to allow convenient binding to a specified local address

David Gibson david at gibson.dropbear.id.au
Thu Sep 26 19:35:44 EST 2013


On Wed, Sep 25, 2013 at 12:44:28PM +0930, Paul 'Rusty' Russell wrote:
> David Gibson <david at gibson.dropbear.id.au> writes:
> > On Tue, Sep 24, 2013 at 02:12:20PM +0930, Paul 'Rusty' Russell wrote:
> >> David Gibson <david at gibson.dropbear.id.au> writes:
> >> > Currently the server/bind side functions in the net module always bind to
> >> > the "wildcard" address listening on all interfaces / local addresses.  This
> >> > patch adds a new net_server_lookup_addr() function to also allow listening
> >> > on only a specified local address.
> >> >
> >> > Signed-off-by: David Gibson <david at gibson.dropbear.id.au>
> >> 
> >> Gah, getaddrinfo() is a terrible interface.
> >> 
> >> What you really want to do is specify an interface to use (ie. loopback
> >> in your examples).  By specifying addr as "127.0.0.1" it's unclear to me
> >> if we'll see any IPv6 addresses.
> >
> > Well.  The interface I have in mind here does take an explicit address
> > (well, optionally) in which case, yes, you'll only get either an IPv4
> > or an IPv6 address.
> >
> > I did think of taking an interface name and binding to all addresses
> > (v4 or v6) on that interface as a possible extension.  But for the use
> > I have in mind, I really do want to specify a single address.
> 
> But the whole point of this module is to be v6 and v4 transparent?
>
> Since we accept standard struct addrinfo *, you should probably just
> getaddrinfo() yourself if you want anything unusual, rather than using
> net_server_lookup(), which is really just a minor helper.

Ah, good point.

> I think net_server_lookup_iface() or net_server_lookup_local() would be
> a good addition.
> 
> >> Yet if we really want to join to struct addrinfo, the user can't use
> >> freeaddrinfo() on it: we need to supply a free function.  I guess we'll
> >> do that, too.
> >
> > I'm not sure what you mean here.
> 
> We tell people they can call freeaddrinfo() on the return from
> net_server_lookup().  If we have to generate struct addrinfo *'s
> ourselves, they can't call freeaddrinfo() on them...

Ah.

-- 
David Gibson			| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au	| minimalist, thank you.  NOT _the_ _other_
				| _way_ _around_!
http://www.ozlabs.org/~dgibson
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: not available
URL: <http://lists.ozlabs.org/pipermail/ccan/attachments/20130926/4dcda530/attachment.sig>


More information about the ccan mailing list