On Mon, May 16, 2011 at 12:59 PM, Stuart Henderson <s...@spacehopper.org>
wrote:
> Re http://permalink.gmane.org/gmane.os.openbsd.misc/185629
> To set IPv6 tunnel endpoints for gif/gre, you have to use
> syntax like "ifconfig gif0 inet6 tunnel 1::1 2::2" rather
> than just "ifconfig gif0 tunnel 1::1 2::2".
>
> This is because settunnel provides an af hint to getaddrinfo,
> so it only considers addresses of a specified family.
>
> The code already checks that the families match, so the hint
> seems to be pointless. How about this diff? Works as expected
> in my tests with v4 and v6.
>
>
> Index: ifconfig.c
> ===================================================================
> RCS file: /cvs/src/sbin/ifconfig/ifconfig.c,v
> retrieving revision 1.246
> diff -u -p -u -7 -r1.246 ifconfig.c
> --- ifconfig.c  23 Mar 2011 18:36:41 -0000      1.246
> +++ ifconfig.c  16 May 2011 10:53:39 -0000
> @@ -3151,27 +3151,23 @@ in6_status(int force)
>  }
>  #endif /*INET6*/
>
>  #ifndef SMALL
>  void
>  settunnel(const char *src, const char *dst)
>  {
> -       struct addrinfo hints, *srcres, *dstres;
> +       struct addrinfo *srcres, *dstres;
>        int ecode;
>        struct if_laddrreq req;
>
> -       memset(&hints, 0, sizeof(hints));
> -       hints.ai_family = afp->af_af;
> -       hints.ai_socktype = SOCK_DGRAM; /*dummy*/
> -
> -       if ((ecode = getaddrinfo(src, NULL, &hints, &srcres)) != 0)
> +       if ((ecode = getaddrinfo(src, NULL, NULL, &srcres)) != 0)
>                errx(1, "error in parsing address string: %s",
>                    gai_strerror(ecode));
>
> -       if ((ecode = getaddrinfo(dst, NULL, &hints, &dstres)) != 0)
> +       if ((ecode = getaddrinfo(dst, NULL, NULL, &dstres)) != 0)
>                errx(1, "error in parsing address string: %s",
>                    gai_strerror(ecode));
>
>        if (srcres->ai_addr->sa_family != dstres->ai_addr->sa_family)
>                errx(1,
>                    "source and destination address families do not match");
>
>

Seems sane. Ok for me.

Ciao,
David

Reply via email to