[CLATJ#31] ClatCoordinator: tag raw socket to uid AID_CLAT
Tag socket as uid AID_CLAT to avoid duplicated data usage counting by
bpf program.
Test: atest FrameworksNetTests
Test: check dumpsys for tag mapping and check logging for socket cookie
$ adb shell dumpsys connectivity trafficcontroller
mCookieTagMap:
cookie=28831 tag=0x0 uid=1029
03-02 22:43:13.201 1719 1921 I jniClatCoordinator: tag uid AID_CLAT to socket fd 609, cookie 28831
03-02 22:43:13.217 5496 5496 I clatd : tunnel.write_fd6 609, cookie 28831, flags 0x0 (debug only)
Bug: 218407445
Change-Id: I67b9f30b143e791ddf59d5627e068ec3107e3328
This commit is contained in:
@@ -82,6 +82,7 @@ public class ClatCoordinatorTest {
|
||||
private static final int TUN_FD = 534;
|
||||
private static final int RAW_SOCK_FD = 535;
|
||||
private static final int PACKET_SOCK_FD = 536;
|
||||
private static final long RAW_SOCK_COOKIE = 27149;
|
||||
private static final ParcelFileDescriptor TUN_PFD = new ParcelFileDescriptor(
|
||||
new FileDescriptor());
|
||||
private static final ParcelFileDescriptor RAW_SOCK_PFD = new ParcelFileDescriptor(
|
||||
@@ -258,12 +259,25 @@ public class ClatCoordinatorTest {
|
||||
/**
|
||||
* Stop clatd.
|
||||
*/
|
||||
@Override
|
||||
public void stopClatd(@NonNull String iface, @NonNull String pfx96, @NonNull String v4,
|
||||
@NonNull String v6, int pid) throws IOException {
|
||||
if (pid == -1) {
|
||||
fail("unsupported arg: " + pid);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Tag socket as clat.
|
||||
*/
|
||||
@Override
|
||||
public long tagSocketAsClat(@NonNull FileDescriptor sock) throws IOException {
|
||||
if (Objects.equals(RAW_SOCK_PFD.getFileDescriptor(), sock)) {
|
||||
return RAW_SOCK_COOKIE;
|
||||
}
|
||||
fail("unsupported arg: " + sock);
|
||||
return 0;
|
||||
}
|
||||
};
|
||||
|
||||
@NonNull
|
||||
@@ -326,6 +340,8 @@ public class ClatCoordinatorTest {
|
||||
inOrder.verify(mDeps).addAnycastSetsockopt(
|
||||
argThat(fd -> Objects.equals(RAW_SOCK_PFD.getFileDescriptor(), fd)),
|
||||
eq(XLAT_LOCAL_IPV6ADDR_STRING), eq(BASE_IFINDEX));
|
||||
inOrder.verify(mDeps).tagSocketAsClat(
|
||||
argThat(fd -> Objects.equals(RAW_SOCK_PFD.getFileDescriptor(), fd)));
|
||||
inOrder.verify(mDeps).configurePacketSocket(
|
||||
argThat(fd -> Objects.equals(PACKET_SOCK_PFD.getFileDescriptor(), fd)),
|
||||
eq(XLAT_LOCAL_IPV6ADDR_STRING), eq(BASE_IFINDEX));
|
||||
|
||||
Reference in New Issue
Block a user