From 53863d828bc6c94879ce01b4576e86b4653ed0b9 Mon Sep 17 00:00:00 2001 From: dlg Date: Thu, 8 Feb 2018 21:54:55 +0000 Subject: [PATCH] when using tunnelttl, let -1 mean "copy the ttl from the inner traffic". tunnelttl now accepts "copy" as an argument, and prints "copy" when it sees -1. ok claudio@ --- sbin/ifconfig/ifconfig.c | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/sbin/ifconfig/ifconfig.c b/sbin/ifconfig/ifconfig.c index 6cb2b394159..0bf921f5a5d 100644 --- a/sbin/ifconfig/ifconfig.c +++ b/sbin/ifconfig/ifconfig.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ifconfig.c,v 1.355 2018/02/08 13:15:32 mpi Exp $ */ +/* $OpenBSD: ifconfig.c,v 1.356 2018/02/08 21:54:55 dlg Exp $ */ /* $NetBSD: ifconfig.c,v 1.40 1997/10/01 02:19:43 enami Exp $ */ /* @@ -2742,8 +2742,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)) @@ -3265,9 +3269,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; -- 2.20.1