diff options
author | Nathan Harold <nharold@google.com> | 2018-06-05 11:41:41 -0700 |
---|---|---|
committer | Lorenzo Colitti <lorenzo@google.com> | 2018-06-06 21:46:37 +0900 |
commit | 8cc2bb61280c5ee79edc866e2726fb999b7a5aa5 (patch) | |
tree | b2835eebf1162493dcb7a4e0a7709f787358bbb4 | |
parent | c5066b4a78c3fdbaaa8fc7f4896d11d111a653a4 (diff) | |
download | netd-8cc2bb61280c5ee79edc866e2726fb999b7a5aa5.tar.gz |
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
Merged-In: Ic81e9737f4e0744faccb3aa1f132d64301aef5b0
-rw-r--r-- | server/XfrmController.cpp | 31 |
1 files changed, 18 insertions, 13 deletions
diff --git a/server/XfrmController.cpp b/server/XfrmController.cpp index 8a891eb7..b9a5a415 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,6 +52,11 @@ #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/log.h> #include <cutils/properties.h> #include <logwrap/logwrap.h> @@ -87,6 +87,11 @@ constexpr uint32_t RAND_SPI_MAX = 0xFFFFFFFE; 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 +131,18 @@ uint8_t kPadBytesArray[] = {0, 0, 0}; 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 |