Instead, rely on the indirection through "capability_util", which is platform
agnostic. This ensures tests can be run against Linux and Fuchsia.
PiperOrigin-RevId: 884457389
As described in the comments, this is the only feasible way of really
checking CAP_NET_RAW properly. This is what Fuchsia
(test/util/fuchsia_capability_util.cc) uses as well.
This also allows us to more granularly check raw socket capabilities. For
example, it is possible to have caps for socket(AF_INET, SOCK_RAW, IPPROTO_RAW)
but *not* for socket(AF_INET, SOCK_RAW, IPPROTO_UDP).
Fixes test failures where the test was being run in a new userns but
the netns had the initial userns. So the test effectively could
open raw sockets.
Cleanup:
- Cleaned up some redundant SKIP_IF(Have[RawIP/Packet]SocketCapability())
from various TEST_P/TEST_F tests whose test class's SetUp() was already
calling GTEST_SKIP() when the capability was not available.
- Removed redundant EPERM checks after Have[RawIP/Packet]SocketCapability()
returned false. Now the implementation only returns false if socket creation
results in EPERM. So the EPERM check again was redundant.
PiperOrigin-RevId: 881067665
SOL_UDP is used when get/set-ing socket options to specify the socket
level. When creating normal UDP sockets, the protocol need not be
specified. When creating RAW IP sockets for UDP, use IPPROTO_UDP.
PiperOrigin-RevId: 396675986
...if bound to an address.
We previously checked the source of a packet instead of the destination
of a packet when bound to an address.
PiperOrigin-RevId: 396497647
+ Do not check for CAP_NET_RAW on Fuchsia
Fuchsia does not support capabilities the same way Linux does. Instead
emulate the check for CAP_NET_RAW by checking if a packet socket may
be created.
Bug: https://fxbug.dev/79016, https://fxbug.dev/81592
PiperOrigin-RevId: 390263666
+ Do not check for CAP_NET_RAW on Fuchsia
Fuchsia does not support capabilities the same way Linux does. Instead
emulate the check for CAP_NET_RAW by checking if a raw IP sockets may
be created.
PiperOrigin-RevId: 389663218
This CL moves {S,G}etsockopt of SO_SNDBUF from all endpoints to socketops. For
unix sockets, we do not support setting of this option.
PiperOrigin-RevId: 353871484
We do not rely on error for getsockopt options(which have boolean values)
anymore. This will cause issue in sendmsg where we used to return error
for IPV6_V6Only option. Fix the panic by returning error (for sockets other
than TCP and UDP) if the address does not match the type(AF_INET/AF_INET6) of
the socket.
PiperOrigin-RevId: 347063838