diff options
author | Android Build Coastguard Worker <android-build-coastguard-worker@google.com> | 2023-05-15 23:23:02 +0000 |
---|---|---|
committer | Android Build Coastguard Worker <android-build-coastguard-worker@google.com> | 2023-05-15 23:23:02 +0000 |
commit | a7e9ea54ec2c84f8d0996053015c078383db1d06 (patch) | |
tree | 4b72979d4b7b367f4a241132a37a7ed8be85157c | |
parent | a346872d3b817a8bc68ee6321da042468f618ddb (diff) | |
parent | b73b5e5183dde337f6a8f0b2939c3e07d7bc9db8 (diff) | |
download | net-a7e9ea54ec2c84f8d0996053015c078383db1d06.tar.gz |
Snap for 10136934 from b73b5e5183dde337f6a8f0b2939c3e07d7bc9db8 to udc-release
Change-Id: Ieabd4388cd51c8e3fd03a1f68b037e09a3e97c3d
-rw-r--r-- | common/device/com/android/net/module/util/netlink/InetDiagMessage.java | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/common/device/com/android/net/module/util/netlink/InetDiagMessage.java b/common/device/com/android/net/module/util/netlink/InetDiagMessage.java index d462c53a..e69a844c 100644 --- a/common/device/com/android/net/module/util/netlink/InetDiagMessage.java +++ b/common/device/com/android/net/module/util/netlink/InetDiagMessage.java @@ -468,6 +468,23 @@ public class InetDiagMessage extends NetlinkMessage { && !isAdbSocket(diagMsg)); } + /** + * Close tcp sockets that match the following condition + * 1. TCP status is one of TCP_ESTABLISHED, TCP_SYN_SENT, and TCP_SYN_RECV + * 2. Owner uid of socket is in the targetUids + * 3. Socket is not loopback + * 4. Socket is not adb socket + * + * @param ownerUids target uids to close sockets + */ + public static void destroyLiveTcpSocketsByOwnerUids(Set<Integer> ownerUids) + throws SocketException, InterruptedIOException, ErrnoException { + destroySockets(IPPROTO_TCP, TCP_ALIVE_STATE_FILTER, + (diagMsg) -> ownerUids.contains(diagMsg.inetDiagMsg.idiag_uid) + && !isLoopback(diagMsg) + && !isAdbSocket(diagMsg)); + } + @Override public String toString() { return "InetDiagMessage{ " |