about summary refs log tree commit diff
diff options
context:
space:
mode:
authorAlyssa Ross <hi@alyssa.is>2019-12-15 22:41:23 +0000
committerAlyssa Ross <hi@alyssa.is>2019-12-15 23:01:14 +0000
commita44798c342e387812ef7194b447f3ad6669ed2be (patch)
treea4eeaaa7932dbac36ba4c69f5c3cfc6d3bd74e89
parent2757c8c7901a5fce763a074907afd47fe81e9023 (diff)
downloadmktuntap-a44798c342e387812ef7194b447f3ad6669ed2be.tar
mktuntap-a44798c342e387812ef7194b447f3ad6669ed2be.tar.gz
mktuntap-a44798c342e387812ef7194b447f3ad6669ed2be.tar.bz2
mktuntap-a44798c342e387812ef7194b447f3ad6669ed2be.tar.lz
mktuntap-a44798c342e387812ef7194b447f3ad6669ed2be.tar.xz
mktuntap-a44798c342e387812ef7194b447f3ad6669ed2be.tar.zst
mktuntap-a44798c342e387812ef7194b447f3ad6669ed2be.zip
Set IFF_NO_PI by default; add -P flag to disable
-rw-r--r--mktuntap.89
-rw-r--r--mktuntap.c11
2 files changed, 18 insertions, 2 deletions
diff --git a/mktuntap.8 b/mktuntap.8
index 6ce1ea9..909ff30 100644
--- a/mktuntap.8
+++ b/mktuntap.8
@@ -24,6 +24,7 @@
 .Nm
 .Fl ( n | p )
 .Op Fl v
+.Op Fl P
 .Op Fl E
 .Op Fl i Ar ifr_name
 .Ar fd
@@ -37,6 +38,10 @@ set the TUNTAP_NAME variable in the environment to the name of the
 opened device, and then exec into
 .Ar prog .
 .Pp
+By default, the
+.Dv IF_NO_PI
+flag is set on the device.
+.Pp
 The arguments are as follows:
 .Bl -tag -width Ds
 .It Fl p
@@ -49,6 +54,10 @@ Create a TUN device.  Mutually exclusive with
 Set the
 .Dv IFF_VNET_HDR
 flag on the device.
+.It Fl P
+Don't set the
+.Dv IFF_NO_PI
+flag on the device.
 .It Fl E
 Don't set the
 .Ev TUNTAP_NAME
diff --git a/mktuntap.c b/mktuntap.c
index 8cbc335..76b02c7 100644
--- a/mktuntap.c
+++ b/mktuntap.c
@@ -61,10 +61,12 @@ void ex_usage()
 int main(int argc, char **argv)
 {
 	char *ifr_name_in = NULL;
-	bool name_env = true, tap = false, tun = false, vnet_hdr = false;
+	bool name_env = true;
+	bool tap = false, tun = false;
+	bool vnet_hdr = false, no_pi = true;
 
 	int c;
-	while ((c = getopt(argc, argv, "+npvEi:")) != -1) {
+	while ((c = getopt(argc, argv, "+npvPEi:")) != -1) {
 		switch (c) {
 		case 'n':
 			tun = true;
@@ -75,6 +77,9 @@ int main(int argc, char **argv)
 		case 'v':
 			vnet_hdr = true;
 			break;
+		case 'P':
+			no_pi = false;
+			break;
 		case 'E':
 			name_env = false;
 			break;
@@ -117,6 +122,8 @@ int main(int argc, char **argv)
 	int target_fd = (int)target_fd_l;
 
 	short flags = tap ? IFF_TAP : IFF_TUN;
+	if (no_pi)
+		flags |= IFF_NO_PI;
 	if (vnet_hdr)
 		flags |= IFF_VNET_HDR;
 	int tuntap_fd = tuntap_alloc(ifr_name_, flags);