Only Log Netlink Messages on Eng Builds
Convert from allowing logging of the XFRM
Netlink messages in all debuggable builds
to only logging them in engineering builds.
Bug: 109715719
Test: tested eng and userdebug with
netd_integration_test and checked logs.
Change-Id: Ic81e9737f4e0744faccb3aa1f132d64301aef5b0
diff --git a/server/XfrmController.cpp b/server/XfrmController.cpp
index e229cf8..d034f1a 100644
--- a/server/XfrmController.cpp
+++ b/server/XfrmController.cpp
@@ -44,11 +44,6 @@
#include <linux/xfrm.h>
#define LOG_TAG "XfrmController"
-#include "android-base/stringprintf.h"
-#include "android-base/strings.h"
-#include "android-base/unique_fd.h"
-#include <android/net/INetd.h>
-#include <log/log_properties.h>
#include "InterfaceController.h"
#include "NetdConstants.h"
#include "NetlinkCommands.h"
@@ -57,8 +52,14 @@
#include "netdutils/Fd.h"
#include "netdutils/Slice.h"
#include "netdutils/Syscalls.h"
+#include <android-base/properties.h>
+#include <android-base/stringprintf.h>
+#include <android-base/strings.h>
+#include <android-base/unique_fd.h>
+#include <android/net/INetd.h>
#include <cutils/properties.h>
#include <log/log.h>
+#include <log/log_properties.h>
#include <logwrap/logwrap.h>
using android::net::INetd;
@@ -87,6 +88,11 @@
constexpr uint32_t INVALID_SPI = 0;
+static inline bool isEngBuild() {
+ static const std::string sBuildType = android::base::GetProperty("ro.build.type", "user");
+ return sBuildType == "eng";
+}
+
#define XFRM_MSG_TRANS(x) \
case x: \
return #x;
@@ -126,18 +132,18 @@
void* kPadBytes = static_cast<void*>(kPadBytesArray);
#define LOG_HEX(__desc16__, __buf__, __len__) \
- if (__android_log_is_debuggable()) { \
- do { \
+ do { \
+ if (isEngBuild()) { \
logHex(__desc16__, __buf__, __len__); \
- } while (0); \
- }
+ } \
+ } while (0)
#define LOG_IOV(__iov__) \
- if (__android_log_is_debuggable()) { \
- do { \
+ do { \
+ if (isEngBuild()) { \
logIov(__iov__); \
- } while (0); \
- }
+ } \
+ } while (0)
void logHex(const char* desc16, const char* buf, size_t len) {
char* printBuf = new char[len * 2 + 1 + 26]; // len->ascii, +newline, +prefix strlen