On Sat, Mar 30, 2013 at 02:30:55PM +0000, Stuart Henderson wrote:
> On 2013/03/30 14:39, Alexander Bluhm wrote:
> > Hi,
> > 
> > Using IO::Socket::INET6 fails when creating raw sockets.  Our
> > getaddrinfo() seems to behave more strictly.  This is not related
> > to new perl or new resolver.  I was also broken in OpenBSD 5.0.
> >
> > +The OpenBSD getaddrinfo() does not allow any port number for raw
> > +sockets.  Avoid a 'service not supported for ai_socktype' error and
> > +use '' instead of 0 in this case.
> 
> It looks like IO::Socket::INET in base perl would be affected too.

No.  Works for me.

> Most other OS are going to be using something closer to the libbind
> (ISC) resolver which allows this so I think it would make more sense to
> adjust getaddrinfo_async_run() to allow '0' for raw sockets, rather
> than patch users.

Makes sense.

> Thinking possibly something like this, but untested:

This fixes my problem.

> Index: getaddrinfo_async.c
> ===================================================================
> RCS file: /cvs/src/lib/libc/asr/getaddrinfo_async.c,v
> retrieving revision 1.12
> diff -u -p -r1.12 getaddrinfo_async.c
> --- getaddrinfo_async.c       28 Mar 2013 11:47:23 -0000      1.12
> +++ getaddrinfo_async.c       30 Mar 2013 14:28:18 -0000
> @@ -170,7 +170,9 @@ getaddrinfo_async_run(struct async *as, 
>               }
>  
>               if (ai->ai_socktype == SOCK_RAW &&
> -                 as->as.ai.servname != NULL) {
> +                 as->as.ai.servname != NULL &&
> +                 get_port(as->as.ai.servname, NULL,
> +                 as->as.ai.hints.ai_flags & AI_NUMERICSERV) != 0) {

Would get_port(as->as.ai.servname, NULL, AI_NUMERICSERV) != 0
be better?  There is no named service with port 0.

>                       ar->ar_gai_errno = EAI_SERVICE;
>                       async_set_state(as, ASR_STATE_HALT);
>                       break;
> 

bluhm

Reply via email to