Return ENOPROTOOPT for all SOL_PACKET options.

This is required to make tcpdump work. tcpdump falls back to not using things
like PACKET_RX_RING if setsockopt returns ENOPROTOOPT. This used to be the case
before https://github.com/google/gvisor/commit/6f8fb7e0db2790ff1f5ba835780c03fe245e437f.

Fixes #3981

PiperOrigin-RevId: 332326517
This commit is contained in:
Bhasker Hariharan
2020-09-17 15:16:54 -07:00
committed by gVisor bot
parent d796b100ec
commit a4db85fff2
+8 -2
View File
@@ -1768,10 +1768,16 @@ func SetSockOpt(t *kernel.Task, s socket.SocketOps, ep commonEndpoint, level int
case linux.SOL_IP:
return setSockOptIP(t, s, ep, name, optVal)
case linux.SOL_PACKET:
// gVisor doesn't support any SOL_PACKET options just return not
// supported. Returning nil here will result in tcpdump thinking AF_PACKET
// features are supported and proceed to use them and break.
t.Kernel().EmitUnimplementedEvent(t)
return syserr.ErrProtocolNotAvailable
case linux.SOL_UDP,
linux.SOL_ICMPV6,
linux.SOL_RAW,
linux.SOL_PACKET:
linux.SOL_RAW:
t.Kernel().EmitUnimplementedEvent(t)
}