Loading src/com/android/networkstack/netlink/TcpSocketTracker.java +8 −0 Original line number Diff line number Diff line Loading @@ -20,6 +20,7 @@ import static android.net.netlink.NetlinkConstants.INET_DIAG_MEMINFO; import static android.net.netlink.NetlinkConstants.NLA_ALIGNTO; import static android.net.netlink.NetlinkConstants.NLMSG_DONE; import static android.net.netlink.NetlinkConstants.SOCKDIAG_MSG_HEADER_SIZE; import static android.net.netlink.NetlinkConstants.SOCK_DIAG_BY_FAMILY; import static android.net.netlink.StructNlMsgHdr.NLM_F_DUMP; import static android.net.netlink.StructNlMsgHdr.NLM_F_REQUEST; import static android.net.util.DataStallUtils.CONFIG_MIN_PACKETS_THRESHOLD; Loading Loading @@ -180,8 +181,15 @@ public class TcpSocketTracker { } final int nlmsgLen = nlmsghdr.nlmsg_len; log("pollSocketsInfo: nlmsghdr=" + nlmsghdr); // End of the message. Stop parsing. if (nlmsghdr.nlmsg_type == NLMSG_DONE) break; if (nlmsghdr.nlmsg_type != SOCK_DIAG_BY_FAMILY) { Log.e(TAG, "Expect to get family " + family + " SOCK_DIAG_BY_FAMILY message but get " + nlmsghdr.nlmsg_type); break; } if (isValidInetDiagMsgSize(nlmsgLen)) { // Get the socket cookie value. Composed by two Integers value. // Corresponds to inet_diag_sockid in Loading tests/unit/src/com/android/networkstack/netlink/TcpSocketTrackerTest.java +2 −2 Original line number Diff line number Diff line Loading @@ -56,7 +56,7 @@ public class TcpSocketTrackerTest { private static final String DIAG_MSG_HEX = // struct nlmsghdr. "00000058" + // length = 88 "0020" + // type = SOCK_DIAG_BY_FAMILY "0014" + // type = SOCK_DIAG_BY_FAMILY "0103" + // flags = NLM_F_REQUEST | NLM_F_DUMP "00000000" + // seqno "00000000" + // pid (0 == kernel) Loading @@ -83,7 +83,7 @@ public class TcpSocketTrackerTest { private static final String SOCK_DIAG_TCP_INET_HEX = // struct nlmsghdr. "00000114" + // length = 276 "0020" + // type = SOCK_DIAG_BY_FAMILY "0014" + // type = SOCK_DIAG_BY_FAMILY "0103" + // flags = NLM_F_REQUEST | NLM_F_DUMP "00000000" + // seqno "00000000" + // pid (0 == kernel) Loading Loading
src/com/android/networkstack/netlink/TcpSocketTracker.java +8 −0 Original line number Diff line number Diff line Loading @@ -20,6 +20,7 @@ import static android.net.netlink.NetlinkConstants.INET_DIAG_MEMINFO; import static android.net.netlink.NetlinkConstants.NLA_ALIGNTO; import static android.net.netlink.NetlinkConstants.NLMSG_DONE; import static android.net.netlink.NetlinkConstants.SOCKDIAG_MSG_HEADER_SIZE; import static android.net.netlink.NetlinkConstants.SOCK_DIAG_BY_FAMILY; import static android.net.netlink.StructNlMsgHdr.NLM_F_DUMP; import static android.net.netlink.StructNlMsgHdr.NLM_F_REQUEST; import static android.net.util.DataStallUtils.CONFIG_MIN_PACKETS_THRESHOLD; Loading Loading @@ -180,8 +181,15 @@ public class TcpSocketTracker { } final int nlmsgLen = nlmsghdr.nlmsg_len; log("pollSocketsInfo: nlmsghdr=" + nlmsghdr); // End of the message. Stop parsing. if (nlmsghdr.nlmsg_type == NLMSG_DONE) break; if (nlmsghdr.nlmsg_type != SOCK_DIAG_BY_FAMILY) { Log.e(TAG, "Expect to get family " + family + " SOCK_DIAG_BY_FAMILY message but get " + nlmsghdr.nlmsg_type); break; } if (isValidInetDiagMsgSize(nlmsgLen)) { // Get the socket cookie value. Composed by two Integers value. // Corresponds to inet_diag_sockid in Loading
tests/unit/src/com/android/networkstack/netlink/TcpSocketTrackerTest.java +2 −2 Original line number Diff line number Diff line Loading @@ -56,7 +56,7 @@ public class TcpSocketTrackerTest { private static final String DIAG_MSG_HEX = // struct nlmsghdr. "00000058" + // length = 88 "0020" + // type = SOCK_DIAG_BY_FAMILY "0014" + // type = SOCK_DIAG_BY_FAMILY "0103" + // flags = NLM_F_REQUEST | NLM_F_DUMP "00000000" + // seqno "00000000" + // pid (0 == kernel) Loading @@ -83,7 +83,7 @@ public class TcpSocketTrackerTest { private static final String SOCK_DIAG_TCP_INET_HEX = // struct nlmsghdr. "00000114" + // length = 276 "0020" + // type = SOCK_DIAG_BY_FAMILY "0014" + // type = SOCK_DIAG_BY_FAMILY "0103" + // flags = NLM_F_REQUEST | NLM_F_DUMP "00000000" + // seqno "00000000" + // pid (0 == kernel) Loading