From 01e2145cca23fb4844c03db195dde8263846b9d4 Mon Sep 17 00:00:00 2001 From: dlg Date: Mon, 19 Feb 2018 00:23:57 +0000 Subject: [PATCH] add support for setting and displaying whether a tunnel allows fragmentation ifconfig will output "nodf" or "df" on tunnel interfaces that support the ioctl., and accepts "tunneldf" and "-tunneldf" as options to try and configure it. --- sbin/ifconfig/ifconfig.8 | 9 +++++++-- sbin/ifconfig/ifconfig.c | 28 +++++++++++++++++++++++++++- 2 files changed, 34 insertions(+), 3 deletions(-) diff --git a/sbin/ifconfig/ifconfig.8 b/sbin/ifconfig/ifconfig.8 index 68f24911b85..42990ad0dd9 100644 --- a/sbin/ifconfig/ifconfig.8 +++ b/sbin/ifconfig/ifconfig.8 @@ -1,4 +1,4 @@ -.\" $OpenBSD: ifconfig.8,v 1.299 2018/02/15 04:21:46 dlg Exp $ +.\" $OpenBSD: ifconfig.8,v 1.300 2018/02/19 00:23:57 dlg Exp $ .\" $NetBSD: ifconfig.8,v 1.11 1996/01/04 21:27:29 pk Exp $ .\" $FreeBSD: ifconfig.8,v 1.16 1998/02/01 07:03:29 steve Exp $ .\" @@ -31,7 +31,7 @@ .\" .\" @(#)ifconfig.8 8.4 (Berkeley) 6/1/94 .\" -.Dd $Mdocdate: February 15 2018 $ +.Dd $Mdocdate: February 19 2018 $ .Dt IFCONFIG 8 .Os .Sh NAME @@ -1603,6 +1603,7 @@ for a complete list of the available protocols. .Op Oo Fl Oc Ns Cm keepalive Ar period count .Op Oo Fl Oc Ns Cm tunnel Ar src_address dest_address .Op Cm tunneldomain Ar tableid +.Op Oo Fl Oc Ns Cm tunneldf .Op Cm tunnelttl Ar ttl .Op Oo Fl Oc Ns Cm vnetid Ar network-id .Ek @@ -1654,6 +1655,10 @@ interface itself. .Ar tableid can be set to any valid routing table ID; the corresponding routing domain is derived from this table. +.It Cm tunneldf +Do not allow fragmentation of encapsulated packets. +.It Cm -tunneldf +Allow fragmentation of the encapsulated packets. .It Cm tunnelttl Ar ttl Set the IP or multicast TTL of the tunnel packets. If supported by the tunnel protocol, diff --git a/sbin/ifconfig/ifconfig.c b/sbin/ifconfig/ifconfig.c index ac5705b2651..88956f0d7ff 100644 --- a/sbin/ifconfig/ifconfig.c +++ b/sbin/ifconfig/ifconfig.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ifconfig.c,v 1.357 2018/02/10 05:55:26 florian Exp $ */ +/* $OpenBSD: ifconfig.c,v 1.358 2018/02/19 00:23:57 dlg Exp $ */ /* $NetBSD: ifconfig.c,v 1.40 1997/10/01 02:19:43 enami Exp $ */ /* @@ -252,6 +252,8 @@ void setpfsync_syncpeer(const char *, int); void unsetpfsync_syncpeer(const char *, int); void setpfsync_defer(const char *, int); void pfsync_status(void); +void settunneldf(const char *, int); +void settunnelnodf(const char *, int); void setpppoe_dev(const char *,int); void setpppoe_svc(const char *,int); void setpppoe_ac(const char *,int); @@ -434,6 +436,8 @@ const struct cmd { { "deletetunnel", 0, 0, deletetunnel }, { "tunneldomain", NEXTARG, 0, settunnelinst }, { "tunnelttl", NEXTARG, 0, settunnelttl }, + { "tunneldf", 0, 0, settunneldf }, + { "-tunneldf", 0, 0, settunnelnodf }, { "pppoedev", NEXTARG, 0, setpppoe_dev }, { "pppoesvc", NEXTARG, 0, setpppoe_svc }, { "-pppoesvc", 1, 0, setpppoe_svc }, @@ -2750,6 +2754,10 @@ phys_status(int force) else if (ifr.ifr_ttl > 0) printf(" ttl %d", ifr.ifr_ttl); } + + if (ioctl(s, SIOCGLIFPHYDF, (caddr_t)&ifr) == 0) + printf(" %s", ifr.ifr_df ? "df" : "nodf"); + #ifndef SMALL if (ioctl(s, SIOCGLIFPHYRTABLE, (caddr_t)&ifr) == 0 && (rdomainid != 0 || ifr.ifr_rdomainid != 0)) @@ -3285,6 +3293,24 @@ settunnelttl(const char *id, int param) warn("SIOCSLIFPHYTTL"); } +void +settunneldf(const char *ignored, int alsoignored) +{ + strlcpy(ifr.ifr_name, name, sizeof(ifr.ifr_name)); + ifr.ifr_df = 1; + if (ioctl(s, SIOCSLIFPHYDF, (caddr_t)&ifr) < 0) + warn("SIOCSLIFPHYDF"); +} + +void +settunnelnodf(const char *ignored, int alsoignored) +{ + strlcpy(ifr.ifr_name, name, sizeof(ifr.ifr_name)); + ifr.ifr_df = 0; + if (ioctl(s, SIOCSLIFPHYDF, (caddr_t)&ifr) < 0) + warn("SIOCSLIFPHYDF"); +} + void mpe_status(void) { -- 2.20.1