Penned by Stuart Henderson on 20110516  5:59.19, we have:
| 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");

This solution is much better than what I've been doing in hostname.if(5) files:

 !ifconfig \$if inet6 tunnel ...

This looks ok to me, I really like this solution.
-- 
Todd Fries .. [email protected]

 _____________________________________________
|                                             \  1.636.410.0632 (voice)
| Free Daemon Consulting, LLC                 \  1.405.227.9094 (voice)
| http://FreeDaemonConsulting.com             \  1.866.792.3418 (FAX)
| 2525 NW Expy #525, Oklahoma City, OK 73112  \  sip:[email protected]
| "..in support of free software solutions."  \  sip:[email protected]
 \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
                                                 
              37E7 D3EB 74D0 8D66 A68D  B866 0326 204E 3F42 004A
                        http://todd.fries.net/pgp.txt

Reply via email to