summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Gwynne <dlg@cvs.openbsd.org>2018-02-08 21:54:56 +0000
committerDavid Gwynne <dlg@cvs.openbsd.org>2018-02-08 21:54:56 +0000
commita5ccb0348d81cce64b5d37508d5fc907690cba49 (patch)
tree2147f9d62a6b118b2fa67177a5846020faf9389b
parent8b198f260b527d316e64e6ff3cb77a0064c5eead (diff)
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@
-rw-r--r--sbin/ifconfig/ifconfig.c20
1 files 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;