On Thu, Feb 08, 2018 at 04:27:57PM +1000, David Gwynne wrote:
> some interfaces could support copying the ttl from an inner packet to an 
> outer one, but there's no obvious way to configure that at the moment.
> 
> this borrows the semantic of using -1 for a special thing from
> vnetid. this could let you go "ifconfig gre0 ttl copy" to enable
> it. this also changes ifconfig to show copy if the value is -1. eg,
> mobileip implicitly copies ttl, so it's output would be:
> 
> mobileip0: flags=8051<UP,POINTOPOINT,RUNNING,MULTICAST> mtu 1488
>       index 8 priority 0 llprio 3
>       groups: mobileip
>       tunnel: inet 192.168.96.40 -> 192.168.96.54 ttl copy
>       inet 100.64.2.2 --> 100.64.2.1 netmask 0xffffffff
> 
> this makes a point of not touching ttl 0. the validity of ttl 0 is
> a discussion for another time.
> 
> ok?

OK claudio@
 
> Index: ifconfig.c
> ===================================================================
> RCS file: /cvs/src/sbin/ifconfig/ifconfig.c,v
> retrieving revision 1.353
> diff -u -p -r1.353 ifconfig.c
> --- ifconfig.c        16 Jan 2018 10:33:55 -0000      1.353
> +++ ifconfig.c        8 Feb 2018 06:03:14 -0000
> @@ -2738,8 +2733,12 @@ phys_status(int force)
>  
>       if (dstport)
>               printf(":%u", ntohs(dstport));
> -     if (ioctl(s, SIOCGLIFPHYTTL, (caddr_t)&ifr) == 0 && ifr.ifr_ttl > 0)
> -             printf(" ttl %d", ifr.ifr_ttl);
> +     if (ioctl(s, SIOCGLIFPHYTTL, (caddr_t)&ifr) == 0) {
> +             if (ifr.ifr_ttl == -1)
> +                     printf(" ttl copy");
> +             else if (ifr.ifr_ttl > 0)
> +                     printf(" ttl %d", ifr.ifr_ttl);
> +     }
>  #ifndef SMALL
>       if (ioctl(s, SIOCGLIFPHYRTABLE, (caddr_t)&ifr) == 0 &&
>           (rdomainid != 0 || ifr.ifr_rdomainid != 0))
> @@ -3261,9 +3260,13 @@ settunnelttl(const char *id, int param)
>       const char *errmsg = NULL;
>       int ttl;
>  
> -     ttl = strtonum(id, 0, 0xff, &errmsg);
> -     if (errmsg)
> -             errx(1, "tunnelttl %s: %s", id, errmsg);
> +     if (strcmp(id, "copy") == 0)
> +             ttl = -1;
> +     else {
> +             ttl = strtonum(id, 0, 0xff, &errmsg);
> +             if (errmsg)
> +                     errx(1, "tunnelttl %s: %s", id, errmsg);
> +     }
>  
>       strlcpy(ifr.ifr_name, name, sizeof(ifr.ifr_name));
>       ifr.ifr_ttl = ttl;
> 

-- 
:wq Claudio

Reply via email to