Currently you can change a tun interface from being point to point to
being a broadcast interface. Why?
This cuts out the ability to change it. Note that the ioctl code is
shared by tap, so it still has IFF_BROADCAST code that gets run, you
should just not be able to change the flags, only read them.
With the above in mind, this also removes the ability to make a tap
interface point to point. Why would you want that too?
This was noticed by tedu while playing with wg, and it confused me. But
that is true for a lot of tap stuff atm. Does anyone really use all the
ioctl buttons that tap provides?
ok?
Index: if_tun.c
===================================================================
RCS file: /cvs/src/sys/net/if_tun.c,v
retrieving revision 1.184
diff -u -p -r1.184 if_tun.c
--- if_tun.c 3 Feb 2019 23:04:49 -0000 1.184
+++ if_tun.c 4 Feb 2019 02:00:14 -0000
@@ -104,7 +104,7 @@ int tundebug = TUN_DEBUG;
#endif
/* Only these IFF flags are changeable by TUNSIFINFO */
-#define TUN_IFF_FLAGS (IFF_UP|IFF_POINTOPOINT|IFF_MULTICAST|IFF_BROADCAST)
+#define TUN_IFF_FLAGS (IFF_UP)
void tunattach(int);
@@ -650,15 +650,9 @@ tun_dev_ioctl(struct tun_softc *tp, u_lo
break;
#endif
case TUNSIFMODE:
- switch (*(int *)data & (IFF_POINTOPOINT|IFF_BROADCAST)) {
- case IFF_POINTOPOINT:
- case IFF_BROADCAST:
- tp->tun_if.if_flags &= ~TUN_IFF_FLAGS;
- tp->tun_if.if_flags |= *(int *)data & TUN_IFF_FLAGS;
- break;
- default:
+ if ((*(int *)data & (IFF_POINTOPOINT|IFF_BROADCAST)) !=
+ (tp->tun_if.if_flags & (IFF_POINTOPOINT|IFF_BROADCAST)))
return (EINVAL);
- }
break;
case FIONBIO: