Try SO_RCVBUF before SO_RCVBUFFORCE.
When running in a container, the process might be in a user/net
namespace, which would cause setting the SO_RCVBUFFORCE socket option to
fail with EPERM. But rmem_max is set to a high enough value which allows
SO_RCVBUF to succeed.
Bug: 62417946
Test: Run android in a new user and network namespace, vold does not
abort here.
Change-Id: I2b678ddd886a406a3394d9fdd33f9c8800ef78a3
Signed-off-by: Junichi Uekawa <uekawa@google.com>
(cherry picked from commit b41155d4af0e00fc6f65d7d67b80e7b866f847d6)
diff --git a/NetlinkManager.cpp b/NetlinkManager.cpp
index b5069a6..0ad182e 100644
--- a/NetlinkManager.cpp
+++ b/NetlinkManager.cpp
@@ -64,8 +64,11 @@
return -1;
}
- if (setsockopt(mSock, SOL_SOCKET, SO_RCVBUFFORCE, &sz, sizeof(sz)) < 0) {
- SLOGE("Unable to set uevent socket SO_RCVBUFFORCE option: %s", strerror(errno));
+ // When running in a net/user namespace, SO_RCVBUFFORCE is not available.
+ // Try using SO_RCVBUF first.
+ if ((setsockopt(mSock, SOL_SOCKET, SO_RCVBUF, &sz, sizeof(sz)) < 0) &&
+ (setsockopt(mSock, SOL_SOCKET, SO_RCVBUFFORCE, &sz, sizeof(sz)) < 0)) {
+ SLOGE("Unable to set uevent socket SO_RCVBUF/SO_RCVBUFFORCE option: %s", strerror(errno));
goto out;
}