Invert the order of SO_RCVBUFFORCE and SO_RCVBUFF
This change swaps the order of SO_RCVBUFFORCE and SO_RCVBUFF, because
the latter is silently capped to sysctl_rmem_max. So, just try
SO_RCVBUFF if the former failed.
Bug: 62417946
Test: Run android in a new user and network namespace, vold does not
abort here.
Change-Id: Iac2ddae6fbb80ba84afe5414eade978cd795ef3c
diff --git a/NetlinkManager.cpp b/NetlinkManager.cpp
index 0ad182e..90e3c6c 100644
--- a/NetlinkManager.cpp
+++ b/NetlinkManager.cpp
@@ -64,10 +64,11 @@
return -1;
}
- // 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)) {
+ // When running in a net/user namespace, SO_RCVBUFFORCE will fail because
+ // it will check for the CAP_NET_ADMIN capability in the root namespace.
+ // Try using SO_RCVBUF if that fails.
+ if ((setsockopt(mSock, SOL_SOCKET, SO_RCVBUFFORCE, &sz, sizeof(sz)) < 0) &&
+ (setsockopt(mSock, SOL_SOCKET, SO_RCVBUF, &sz, sizeof(sz)) < 0)) {
SLOGE("Unable to set uevent socket SO_RCVBUF/SO_RCVBUFFORCE option: %s", strerror(errno));
goto out;
}