diff options
author | Kevin Krakauer <krakauer@google.com> | 2018-05-04 16:21:38 -0700 |
---|---|---|
committer | Shentubot <shentubot@google.com> | 2018-05-04 16:22:31 -0700 |
commit | d70787d340b3967fd691fbbd079dece329f7a65c (patch) | |
tree | 87418e05036d36e28021cb3842808ae485dd60cc /pkg/sentry | |
parent | f47174f06b9904b830268d46a7e817053b6235c8 (diff) |
sentry: Adds the SIOCGIFNETMASK ioctl to epsocket.
PiperOrigin-RevId: 195489319
Change-Id: I0841d41d042c6f91aa8d7f62c127213aa7953eac
Diffstat (limited to 'pkg/sentry')
-rw-r--r-- | pkg/sentry/socket/epsocket/epsocket.go | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/pkg/sentry/socket/epsocket/epsocket.go b/pkg/sentry/socket/epsocket/epsocket.go index 5701ecfac..a45dcd551 100644 --- a/pkg/sentry/socket/epsocket/epsocket.go +++ b/pkg/sentry/socket/epsocket/epsocket.go @@ -1109,7 +1109,20 @@ func (s *SocketOperations) interfaceIoctl(ctx context.Context, io usermem.IO, ar case syscall.SIOCGIFNETMASK: // Gets the network mask of a device. - // TODO: Implement. + for _, addr := range s.stack.InterfaceAddrs()[index] { + // This ioctl is only compatible with AF_INET addresses. + if addr.Family != linux.AF_INET { + continue + } + // Populate ifr.ifr_netmask (type sockaddr). + usermem.ByteOrder.PutUint16(ifr.Data[0:2], uint16(linux.AF_INET)) + usermem.ByteOrder.PutUint16(ifr.Data[2:4], 0) + var mask uint32 = 0xffffffff << (32 - addr.PrefixLen) + // Netmask is expected to be returned as a big endian + // value. + binary.BigEndian.PutUint32(ifr.Data[4:8], mask) + break + } default: // Not a valid call. |