Add Fwmark to TCP socket dumps interface
This allows TcpSocketMonitor to prints netid and mark values for all
sockets dumped.
Bug: 64147860
Test: manual tests with newly introduced commands
Change-Id: Id9ec716be5933615b2532dffb10267770e9ae101
diff --git a/server/SockDiag.cpp b/server/SockDiag.cpp
index 2f55e90..d2bf49e 100644
--- a/server/SockDiag.cpp
+++ b/server/SockDiag.cpp
@@ -31,7 +31,6 @@
#include <android-base/strings.h>
#include <cutils/log.h>
-#include "Fwmark.h"
#include "NetdConstants.h"
#include "Permission.h"
#include "SockDiag.h"
@@ -217,6 +216,7 @@
int SockDiag::readDiagMsgWithTcpInfo(const TcpInfoReader& tcpInfoReader) {
NetlinkDumpCallback callback = [tcpInfoReader] (nlmsghdr *nlh) {
+ Fwmark mark;
struct tcp_info *tcpinfo = nullptr;
inet_diag_msg *msg = reinterpret_cast<inet_diag_msg *>(NLMSG_DATA(nlh));
uint32_t attr_len = nlh->nlmsg_len - NLMSG_LENGTH(sizeof(*msg));
@@ -224,12 +224,14 @@
while (RTA_OK(attr, attr_len)) {
if (attr->rta_type == INET_DIAG_INFO) {
tcpinfo = reinterpret_cast<struct tcp_info*>(RTA_DATA(attr));
- break;
+ }
+ if (attr->rta_type == INET_DIAG_MARK) {
+ mark.intValue = *reinterpret_cast<uint32_t*>(RTA_DATA(attr));
}
attr = RTA_NEXT(attr, attr_len);
}
- tcpInfoReader(msg, tcpinfo);
+ tcpInfoReader(mark, msg, tcpinfo);
};
return processNetlinkDump(mSock, callback);