Merge "Invert the order of SO_RCVBUFFORCE and SO_RCVBUFF" am: a3258252ad am: 2aa4643dca
am: d896787df7

Change-Id: I3b72e82b030c685d7e11fa00601774eaba3c241c
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;
     }