Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 1446afad authored by Chiachang Wang's avatar Chiachang Wang Committed by android-build-merger
Browse files

Merge "Avoid incorrect nlmsg_type in returned INetDiagMessage" am: ed4e6885 am: a26755b1

am: 064b1d53

Change-Id: I325a986462eba0006046c6a3e2e769513ea988b8
parents f68bac2d 064b1d53
Loading
Loading
Loading
Loading
+8 −0
Original line number Diff line number Diff line
@@ -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;
@@ -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
+2 −2
Original line number Diff line number Diff line
@@ -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)
@@ -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)