summaryrefslogtreecommitdiffhomepage
path: root/pkg/sentry/devices/tundev/tundev.go
diff options
context:
space:
mode:
authorKevin Krakauer <krakauer@google.com>2021-03-15 18:47:41 -0700
committergVisor bot <gvisor-bot@google.com>2021-03-15 18:49:59 -0700
commitb1d57877264c2b94e3024375efc9914881f0bbe8 (patch)
treefcc3ee1d6ff597411847c4beacd3d8349d33178a /pkg/sentry/devices/tundev/tundev.go
parentec45d969236bb98a83e7da0466bd67e540c5e8b5 (diff)
Make netstack (//pkg/tcpip) buildable for 32 bit
Doing so involved breaking dependencies between //pkg/tcpip and the rest of gVisor, which are discouraged anyways. Tested on the Go branch via: gvisor.dev/gvisor/pkg/tcpip/... Addresses #1446. PiperOrigin-RevId: 363081778
Diffstat (limited to 'pkg/sentry/devices/tundev/tundev.go')
-rw-r--r--pkg/sentry/devices/tundev/tundev.go15
1 files changed, 7 insertions, 8 deletions
diff --git a/pkg/sentry/devices/tundev/tundev.go b/pkg/sentry/devices/tundev/tundev.go
index d8f4e1d35..c43158aa4 100644
--- a/pkg/sentry/devices/tundev/tundev.go
+++ b/pkg/sentry/devices/tundev/tundev.go
@@ -87,19 +87,18 @@ func (fd *tunFD) Ioctl(ctx context.Context, uio usermem.IO, args arch.SyscallArg
if _, err := req.CopyIn(t, data); err != nil {
return 0, err
}
- flags := usermem.ByteOrder.Uint16(req.Data[:])
+
+ // Validate flags.
+ flags, err := netstack.LinuxToTUNFlags(usermem.ByteOrder.Uint16(req.Data[:]))
+ if err != nil {
+ return 0, err
+ }
return 0, fd.device.SetIff(stack.Stack, req.Name(), flags)
case linux.TUNGETIFF:
var req linux.IFReq
-
copy(req.IFName[:], fd.device.Name())
-
- // Linux adds IFF_NOFILTER (the same value as IFF_NO_PI unfortunately) when
- // there is no sk_filter. See __tun_chr_ioctl() in net/drivers/tun.c.
- flags := fd.device.Flags() | linux.IFF_NOFILTER
- usermem.ByteOrder.PutUint16(req.Data[:], flags)
-
+ usermem.ByteOrder.PutUint16(req.Data[:], netstack.TUNFlagsToLinux(fd.device.Flags()))
_, err := req.CopyOut(t, data)
return 0, err