From e8dceddeec89515ee0ea53e6ad3d92bb5d63d623 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maciej=20=C5=BBenczykowski?= Date: Thu, 9 Jun 2022 23:27:32 +0000 Subject: [PATCH] enable NETLINK_EXT_ACK extended error reporting MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit (we don't yet do anything with it, but at least in strace we should now see more detailed errors from the kernel) Test: TreeHugger Signed-off-by: Maciej Żenczykowski Change-Id: I6a34a0e7e866bbde41daef23870ad90dceee6ded --- staticlibs/native/tcutils/tcutils.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/staticlibs/native/tcutils/tcutils.cpp b/staticlibs/native/tcutils/tcutils.cpp index 144a4c940a..4101885f6d 100644 --- a/staticlibs/native/tcutils/tcutils.cpp +++ b/staticlibs/native/tcutils/tcutils.cpp @@ -386,6 +386,12 @@ int sendAndProcessNetlinkResponse(const void *req, int len) { return -error; } + if (setsockopt(fd, SOL_NETLINK, NETLINK_EXT_ACK, &on, sizeof(on))) { + int error = errno; + ALOGW("setsockopt(fd, SOL_NETLINK, NETLINK_EXT_ACK, 1): %d", error); + // will fail on 4.9 kernels so don't: return -error; + } + // this is needed to get valid strace netlink parsing, it allocates the pid if (bind(fd, (const struct sockaddr *)&KERNEL_NLADDR, sizeof(KERNEL_NLADDR))) {