Commit graph android_packages_modules_Co.../service/native
Message SHA1
libclat_test: use static libc++
shot in the dark fix for mainline T test failure:

libclat_test did not report any run:
CANNOT LINK EXECUTABLE "/data/local/tmp/libclat_test": cannot locate symbol "_ZTVNSt3__118basic_stringstreamIcNS_11char_traitsIcEENS_9allocatorIcEEEE" referenced by "/data/local/tmp/libclat_test"...

Bug: 398136085
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: I10fea4441898a19430941ef4aa1951817cc350ba

Maciej Żenczykowski   commited 2025-02-21 11:59:49 -08:00
0558e3cde8
[DON'T BLOCK] Test ownership migration rules
This CL is created as a best effort to migrate test targets
to the new android ownership model. If you find incorrect or unnecessary
attribution in this CL, please create a separate CL to fix that.

For more details please refer to the link below,
<add g3 doc link>

Bug: 304529413
Test: N/A
Change-Id: I243f17b3f0ad7af9ffa15ca242456e36688733f5
Merged-In: I243f17b3f0ad7af9ffa15ca242456e36688733f5

Aditya Choudhary   commited 2024-01-31 12:34:50 +00:00
01b5ede2b2
Remove service/native/include/Common.h
Move the remaining contents of Common.h to clatutils_test.cpp and remove
Common.h

Bug: 217624062
Test: TH
Change-Id: Ie0615b42a3a1bf4c07e9196128fe0850a448fb35

Motomu Utsumi   commited 2023-11-08 16:58:59 +09:00
3b477129dd
Remove unused enums for firewall in Common.h
They are used by TrafficController which was removed by aosp/2817123

Bug: 217624062
Test: TH
Change-Id: I561f135b43e7d15e6f45e95b502fc3c90c4b3ddf

Motomu Utsumi   commited 2023-11-08 14:44:17 +09:00
b51381e0e1
Remove TrafficController
BpfNetMaps now updates bpf map by Java library and does not use
TrafficController.

Bug: 217624062
Test: TH
Change-Id: Id727cf7b79592e913c967156e6e224de338f5f65

Motomu Utsumi   commited 2023-11-07 20:25:24 +09:00
424038fe25
Fix misc-unused-using-decls clang-tidy warning
packages/modules/Connectivity/service/native/TrafficController.cpp:58:18: error: using decl 'DumpWriter' is unused [misc-unused-using-decls,-warnings-as-errors]
using netdutils::DumpWriter;
^
packages/modules/Connectivity/service/native/TrafficController.cpp:58:18: note: remove the using
using netdutils::DumpWriter;
~~~~~~~~~~~~~~~~^~~~~~~~~~~
packages/modules/Connectivity/service/native/TrafficController.cpp:61:18: error: using decl 'ScopedIndent' is unused [misc-unused-using-decls,-warnings-as-errors]
using netdutils::ScopedIndent;
^
packages/modules/Connectivity/service/native/TrafficController.cpp:61:18: note: remove the using
using netdutils::ScopedIndent;
~~~~~~~~~~~~~~~~^~~~~~~~~~~~~

Test: presubmit
Change-Id: I1871139fed31c57a5c15a8ab4f88aa7c695ff360

Yi Kong   commited 2023-09-12 13:06:33 +09:00
a669de72d3
remove TrafficController::dump
Test: TreeHugger
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: I399ac8dfc4992f4c604f1d32c2f1b8ae06710808

Maciej Żenczykowski   commited 2023-09-06 16:50:06 +00:00
d70a33061e
TrafficController - trivialize dump()
The goal is to be able to remove getMap() from BpfMap.h,
as it effectively leaks (what should be an) internal fd.

In practice the dump() operation isn't useful,
as initMaps() and thus native_init() already
guarantee all these maps have valid file descriptors.

Test: TreeHugger
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: If89c28923d3ae030dfac0b3b0ab8b15117db3f30

Maciej Żenczykowski   commited 2023-08-20 19:25:07 +00:00
7d2a4e9d47
TrafficController - remove dead code
Test: TreeHugger
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: Id3a128cd72f467fa60213f57c6dd942a0629ba1d

Maciej Żenczykowski   commited 2023-08-20 18:48:48 +00:00
29c8830417
Merge "clat: use AF_PACKET/SOCK_RAW not SOCK_DGRAM sockets"
Maciej Żenczykowski   authored and   Gerrit Code Review   commited 2023-03-14 03:01:08 +00:00
cc5b26dffe
clat: use AF_PACKET/SOCK_RAW not SOCK_DGRAM sockets
This switches incoming packets from L3 to L2,
ie. they now include the ethernet header for non-rawip cases
(like wifi)

Note: depends on userspace clatd change to offset packet
processing index by tpacket_auxdata->tp_net L3 header offset,
an increase in the read buffer size,  and on change to use
IPv6 header relative cBPF for ingress packet filtering!

Test: TreeHugger, atest libclat_test, ping 1.1.1.1 on v6-only wifi
Bug: 265591307
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: Ie5893d18b0dd796751f95150680a0d4cd5f64c3c

Maciej Żenczykowski   commited 2023-03-14 00:50:18 +00:00
2460294974
clat: switch to relative cbpf filter
Needed to support AF_PACKET/SOCK_RAW sockets

Test: TreeHugger, ping on ipv6-only wifi works
Bug: 265591307
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: If324ee1e97a90b1a0a2ee0fabe1d91ef0603fdac

Maciej Żenczykowski   commited 2023-03-10 23:46:15 +00:00
f3440dd85e
clatutils - code cleanup
add const, etc.

Test: TreeHugger
Bug: 265591307
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: I8daa05891759370f6f5d7369a283d8ffc543a790

Maciej Żenczykowski   commited 2023-03-10 23:25:41 +00:00
26b8e85a14
clat: just always set mark unconditionally, part 2
Setting SO_MARK to MARK_UNSET, ie. 0, is harmless,
since the default for a brand new socket is already 0.

See ClatCoordinator.java getFwMark() for the mark we actually pass in,
which is guaranteed to have at least 4 bits (16,17,18,19) set.

See also:
  https://android-review.git.corp.google.com/c/platform/packages/modules/Connectivity/+/2392272

Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: I3b4eebc0a5ad20390a13efcc58cecf94868686ba

Maciej Żenczykowski   commited 2023-01-30 19:31:27 +00:00
8bf5967d1e
clat: just return max uint32 from AF_PACKET cbpf filter
kernel's net/packet/af_packet.c packet_rcv() does (paraphrased):

  unsigned int snaplen = skb->len;
  unsigned int res = run_filter(skb, sk, snaplen);
  if (!res) goto drop_n_restore;
  if (snaplen > res) snaplen = res;

which makes it clear that cbpf filter returning 0 means drop,
while any other unsigned int (ie. u32) value means capture that
many bytes - but no more than packet length.

Might as well just use the maximum u32 as the snaplen,
since it will be truncated to skb->len as needed.

Of course additionally IPv6 packets can have a payload size of 65535
(which does not include the IPv6 header itself, and assumes we
don't bother with IPv6 jumbograms, which we can't translate to IPv4
anyways), so the L3 mtu should actually be 65535 + 40.
Except that is also too large to translate to ipv4,
so instead the max L3 mtu should be 65535 - 20 + 40 + 8
(which is the max IPv4 packet size - sizeof ipv4 header + sizeof
ipv6 header + sizeof ipv6 fragmentation extension header).

Since the cBPF currently deals with L3 packets it should return
an L3 length (ie. not including L2 headers), but this will change
when we switch to using L2 af_packet sockets (this change will
mean we will not need to change this code at that point in time).

Furthermore, this should have always returned MAXMTU, and not
PACKETLEN, as it does not care about the tun_pi extra header
(which is added later).

ie. this *should* have always been:
  #define MAXMTU (0xFFFF + 28)
  BPF_STMT(BPF_RET | BPF_K, MAXMTU)
but:
  BPF_STMT(BPF_RET | BPF_K, 0xFFFFFFFFu)
is even simpler.

Bug: 259872525
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: I2cc4960f0092720b5ee196e8716f07826bd7f362

Maciej Żenczykowski   commited 2023-01-29 18:48:08 +00:00
4fcf8a0061
rename bpf_shared.h to netd.h
Test: TreeHugger
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: I2e1569c8d70e98f9a3fdbab41fd2ba7f7b84dd37

Maciej Żenczykowski   commited 2022-12-18 20:02:52 +00:00
513474c1a7
Bypass VPN lockdown for clat initialization
This allows clat to initialize properly when VPNs are configured
with "Block connections without VPN", rather than to error out with
"no IPv6 addresses were available for clat".

This issue primarily affects particular mobile networks configured
with NAT64 (without direct IPv4 connectivity).

Bug: 255040839
Change-Id: I4a8ee0295e0f5d1e330f7529856347b8bd10360c

t-m-w   authored and   Maciej Żenczykowski   commited 2022-10-25 01:54:51 +00:00
130e75b0ab
Move CookieTag map dump to BpfNetMaps
Also removes dump tests in TrafficController

Bug: 217624062
Test: atest BpfNetMaps TagSocketTest
Change-Id: I92adad60c55443435d7c7a0bfc84b38162fd51b0

Motomu Utsumi   commited 2022-10-05 18:28:13 +09:00
ef546a9bd5
Move Interface stats map dump to NetworkStatsService
Bug: 217624062
Test: dumpsys netstats, atest NetworkStatsServiceTest
Change-Id: Ie0357a79925c0bbb34aa05442f727c776f434f88

Motomu Utsumi   commited 2022-10-05 17:33:02 +09:00
809a316035
Move ownerMatch config dump to BpfNetMaps
Information in the dump does not change
....
current ownerMatch configuration: 516 DOZABLE_MATCH OEM_DENY_1_MATCH
....

Bug: 217624062
Test: dumpsys connectivity trafficcontroller, atest BpfNetMapsTest
Change-Id: I5f7b56e4ba03256414f49d0e82d65477fb97f05a

Motomu Utsumi   commited 2022-10-04 15:02:43 +09:00
372c9b45ee
Move current StatsMap dump to BpfNetMaps
Information in the dump does not change
....
current statsMap configuration: 0 SELECT_MAP_A
....

Bug: 217624062
Test: dumpsys connectivity trafficcontroller, atest BpfNetMapsTest
Change-Id: I42a844227f258b91ba5b368d8e8abf82a773a801

Motomu Utsumi   commited 2022-10-04 15:02:43 +09:00
c675d6fc01
Move uidOwnerMap dump to BpfNetMaps
Before this CL
....
mUidOwnerMap:
10050  IIF_MATCH LOCKDOWN_VPN_MATCH 0
10061  HAPPY_BOX_MATCH
10091  HAPPY_BOX_MATCH IIF_MATCH LOCKDOWN_VPN_MATCH 0
....

After this CL
....
sUidOwnerMap:
  10050 IIF_MATCH LOCKDOWN_VPN_MATCH 0
  10061 HAPPY_BOX_MATCH
  10091 HAPPY_BOX_MATCH IIF_MATCH LOCKDOWN_VPN_MATCH 0
....

Bug: 217624062
Test: dumpsys connectivity trafficcontroller, atest BpfNetMapsTest
Change-Id: I0e2358e462824273a89fcba6e19e75a233f9fe18

Motomu Utsumi   commited 2022-10-04 15:02:41 +09:00
956d86ccdf
Move uidPermissionMap dump to BpfNetMaps
Also remove the dump of mPrivilegedUser because this is not used now and
the information is duplicated with uidPermissionMap dump.

Before this CL
....
mUidPermissionMap:
10049 PERMISSION_NONE
10027  BPF_PERMISSION_INTERNET BPF_PERMISSION_UPDATE_DEVICE_STATS
1041  BPF_PERMISSION_UPDATE_DEVICE_STATS
....

After this CL
....
sUidPermissionMap:
  10049 PERMISSION_NONE
  10027 PERMISSION_INTERNET PERMISSION_UPDATE_DEVICE_STATS
  1041 PERMISSION_UPDATE_DEVICE_STATS
....

Bug: 217624062
Test: dumpsys connectivity trafficcontroller, atest BpfNetMapsTest
Change-Id: I416501d5a28a5443f954f9c8c58ea255e5cdc897

Motomu Utsumi   commited 2022-10-04 15:00:34 +09:00
310850f210
Move Interface index name map dump to NetworkStatsService
Map status dump will do access check if map is null.
This could show different message from the current dump output.

Information in map content dump does not change
$ dumpsys connectivity trafficcontroller
....
     mIfaceIndexNameMap:
      ifaceIndex=5 ifaceName=ip6_vti0
      ifaceIndex=19 ifaceName=r_rmnet_data3
      ifaceIndex=17 ifaceName=r_rmnet_data1
      ifaceIndex=18 ifaceName=r_rmnet_data2
      ifaceIndex=23 ifaceName=wifi-aware0
....

$ dumpsys netstats
....
  BPF map content:
    ifaceIndex=5 ifaceName=ip6_vti0
    ifaceIndex=19 ifaceName=r_rmnet_data3
    ifaceIndex=17 ifaceName=r_rmnet_data1
    ifaceIndex=18 ifaceName=r_rmnet_data2
    ifaceIndex=8 ifaceName=rmnet_ipa0
....

Bug: 217624062
Test: dumpsys netstats, atest
com.android.server.net.BpfInterfaceMapUpdaterTest

Change-Id: If182bd97f72713b6347028668cf7bd4676b8aea4

Motomu Utsumi   commited 2022-09-12 16:53:51 +09:00
fdb601603d
Move stats map A/B dump to NetworkStatsService
Map status dump will do access check if map is null.
This could show different message from the current dump output.

Information in map content dump does not change
$ dumpsys connectivity trafficcontroller
....
      mStatsMapA:
      ifaceIndex ifaceName tag_hex uid_int cnt_set rxBytes rxPackets txBytes txPackets
      20 wlan0 0x0 1051 0 144 2 312 4
      10 rmnet_data0 0x0 0 0 0 0 48 1
      20 wlan0 0x0 0 0 0 0 136 2
      20 wlan0 0xffffff82 1051 0 144 2 312 4

      mStatsMapB:
      ifaceIndex ifaceName tag_hex uid_int cnt_set rxBytes rxPackets txBytes txPackets
....

$ dumpsys netstats
....
  mStatsMapA:
    ifaceIndex ifaceName tag_hex uid_int cnt_set rxBytes rxPackets txBytes txPackets
    20 wlan0 0x0 1051 0 144 2 312 4
    10 rmnet_data0 0x0 0 0 0 0 48 1
    20 wlan0 0x0 0 0 0 0 136 2
    20 wlan0 0xffffff82 1051 0 144 2 312 4
  mStatsMapB:
    ifaceIndex ifaceName tag_hex uid_int cnt_set rxBytes rxPackets txBytes txPackets
....

Bug: 217624062
Test: dumpsys netstats, dumpstate, atest NetworkStatsServiceTest

Change-Id: Ifbd45f0ad6dd9c519a15a7680cf0ea99fb5f5dcf

Motomu Utsumi   commited 2022-09-12 16:53:48 +09:00
608c32c782
Add startSkDestroyListener flag to native_init
This CL prepares for upcoming CL.
Upcoming CL will add SkDestroyListener with Java BpfMap and switch
current C SkDestroyListener and new Java SkDestroyListener based on the
experiment flag.

Bug: 217624062
Test: atest SkDestroyListenerTest
Change-Id: I5ebb319d1b2262199d4ef6a3549894fee24c4ccf

Motomu Utsumi   commited 2022-09-06 11:23:13 +09:00
3af8f0e8d6
Remove unuseful program status dump in TrafficController
netd makes sure netd can open all bpf programs at startup and exit if it
fails.
So, program status is always OK if netd starts successflly.

Bug: 241787285
Bug: 217624062
Test: atest TrafficControllerTest, dumpsys connectivityservice
trafficcontroller

Change-Id: Ida29dcbb2612e84f7030389050e2a3d2830c73ff

Motomu Utsumi   commited 2022-08-12 09:05:42 +00:00
1e4d24993e
Revert bpf map status dump in TrafficController
status dump was removed in aosp/2167962 and aosp/2165825.
But TrafficController still open these maps in init and hold them, so
dump should show the status of them.

Bug: 217624062
Bug: 241787285
Test: atest TrafficControllerTest, dumpsys connectivityservice
trafficcontroller

Change-Id: Icc1f255a619b22174abb2a7d323b7e3c4d42909f

Motomu Utsumi   commited 2022-08-12 09:05:37 +00:00
f3e5a28485
Revert mCookieTagMap dump in TrafficController
aosp/2167063 moved mCookieTagMap dump from TrafficController to
NetworkStatsService.
But this dump was used from Cts TagSocketTest.
So, this CL re-adds mCookieTagMap dump to TrafficController to avoid
failure of released Cts.
Upcoming CL will update Cts test to check dump both from
TrafficController and NetworkStatsService.
And after the old Cts support period is over, mCookieTagMap dump in
TrafficController can be removed.

Bug: 241787285
Test: atest TagSocketTest TrafficControllerTest
Change-Id: Ie2ef09fa7d91cf96f56c5efcbe9d863dd68a1020

Motomu Utsumi   commited 2022-08-10 03:51:40 +00:00
872c369ecc
Merge changes I71988117,Ia70379a3
* changes:
  Move app uid stats map dump to NetworkStatsService
  Move uid counter set map dump to NetworkStatsService

Motomu Utsumi   authored and   Gerrit Code Review   commited 2022-08-03 11:34:39 +00:00
31b48fa787
Merge "Move cookie tag bpf map dump to NetworkStatsService"
Motomu Utsumi   authored and   Gerrit Code Review   commited 2022-08-03 07:43:13 +00:00
e441f7025c
Merge "Set default value to bpf maps with Java Bpf Map"
Motomu Utsumi   authored and   Gerrit Code Review   commited 2022-08-03 07:41:52 +00:00
db323cb73b
Move app uid stats map dump to NetworkStatsService
Map status dump will do access check if map is null.
This could show different message from the current dump output.

Information in map content dump does not change
$ dumpsys connectivity trafficcontroller
....
      mAppUidStatsMap::
      uid rxBytes rxPackets txBytes txPackets
      0 135 1 3602 47
      1001 2414 8 385 6
      1021 76 1 76 1
      1000 290 2 260 3
....
$ dumpsys netstats
....
  mAppUidStatsMap:
    uid rxBytes rxPackets txBytes txPackets
    0 135 1 3602 47
    1001 2414 8 385 6
    1021 76 1 76 1
    1000 290 2 260 3
....

Bug: 217624062
Test: dumpsys netstats, dumpstate, atest NetworkStatsServiceTest
Change-Id: I71988117c6dc3033f710b26a15d15879b35d50a4

Motomu Utsumi   commited 2022-08-02 09:41:46 +00:00
b8dd98e4d1
Move uid counter set map dump to NetworkStatsService
Map status dump will do access check if map is null.
This could show different message from the current dump output.

Information in map content dump does not change
$ dumpsys connectivity trafficcontroller
....
mUidCounterSetMap:
      10093 1
      10060 1
      1073 1
      1001 1
      10089 1
....
$ dumpsys netstats
....
  mUidCounterSetMap:
    uid=10093 set=1
    uid=10090 set=1
    uid=1073 set=1
    uid=10089 set=1
    uid=1000 set=1
....

Bug: 217624062
Test: dumpsys netstats, dumpstate, atest NetworkStatsServiceTest
Change-Id: Ia70379a3cee820f3f05d1f036947b357d9da4bd7

Motomu Utsumi   commited 2022-08-02 09:41:23 +00:00
7013b92a22
Move cookie tag bpf map dump to NetworkStatsService
Map status dump will do access check if map is null.
This could show different message from the current dump output.

Information in map content dump does not change
$ dumpsys connectivity trafficcontroller
....
      mCookieTagMap:
      cookie=1398 tag=0x0 uid=1029
      cookie=1433 tag=0xffffff82 uid=1051
      cookie=1166 tag=0xfffffe01 uid=1073

$ dumpsys netstats
....
  mCookieTagMap:
    cookie=1144 tag=0xfffffe01 uid=1073
    cookie=1376 tag=0x0 uid=1029
    cookie=1408 tag=0xffffff82 uid=1051

Bug: 217624062
Test: dumpsys netstats, dumpstate, atest NetworkStatsServiceTest
Change-Id: I14dd6f969a0b5eb24ace62361ce2484cf18b7470

Motomu Utsumi   commited 2022-08-02 09:41:03 +00:00
cedfab91c6
Revert "Remove unused codes that was used in setChildChain"
This reverts commit b1144d7671.

Reason for revert: We decided to have experiment and switch old code path and new code path based on a flag. So the codes removed by this CL is needed.

Bug: 217624062
Test: m

Change-Id: Icb8a353a74935ed97f8e102ba54020825676b817

Motomu Utsumi   commited 2022-08-01 08:42:39 +00:00
114cd9cf73
Set default value to bpf maps with Java Bpf Map
Bug: 217624062
Test: m, flash, boot
Change-Id: Ib6c435cc6a35dec3fe86c7ddde8671eb7de631c1

Motomu Utsumi   commited 2022-08-01 08:41:37 +00:00
ba2fa15641
Remove unused codes that was used in setChildChain
Previous commit update BpfNetMaps#setChildChain to use Java BpfMap.
This commit remove the code that is no longer used due to the previous
commit.

Bug: 217624062
Test: atest BpfNetMapsTest android.net.cts.ConnectivityManagerTest#testFirewallBlocking
Change-Id: I02656096c8752daf20d3578f209778c5adae9b0c

Motomu Utsumi   commited 2022-06-24 09:11:58 +00:00
b1144d7671
Merge "Remove unused functions in TrafficController"
Motomu Utsumi   authored and   Gerrit Code Review   commited 2022-06-17 02:38:57 +00:00
ea95231d63
Merge "switch netd_configuration_map from hash map to array"
Maciej Żenczykowski   authored and   Gerrit Code Review   commited 2022-06-16 23:54:15 +00:00
a899aa253a
switch netd_configuration_map from hash map to array
This eliminates the need for netd_updatable BpfHandler.cpp
to initialize the hash map with a zero.

On startup the map will be freshly initialized and thus zero.

On restart it might not be empty, but it doesn't matter to netd.
Furthermore the mainline component of the system server will
re-initialize it again anyway:
see service/native/TrafficController.cpp initMaps()

This does remove the ability to call deleteValue on a key,
since that would always return -EINVAL, but since we don't
currently do that, that's really a feature.

(It does suggest though that we should have a BpfMapNonNullable
 class which is writeable, but without a deleteValue() function)

Additionally BpfMap arrays are more efficient for the kernel bpf jit
compiler, as - on newer kernels - it can optimize the read/write
into a simple memory access (as opposed to a bpf helper call).

Before:
  $ adb shell ls -l /sys/fs/bpf/netd_shared/map_netd_configuration_map
  -rw-rw---- 1 root net_bw_acct 0 2022-06-11 08:20 /sys/fs/bpf/netd_shared/ map_netd_configuration_map

After:
  $ adbz shell ls -l /sys/fs/bpf/netd_shared/map_netd_configuration_map
  -r--rw---- 1 root net_bw_acct 0 2022-06-16 15:03 /sys/fs/bpf/netd_shared/map_netd_configuration_map

Bug: 235590615
Test: TreeHugger
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: I21730e4fa22fbf0c94ab0ca5c5db03aa000b7680

Maciej Żenczykowski   commited 2022-06-16 22:53:42 +00:00
b10e055f4b
verify CLAT_MARK matches aidl constant.
Bug: 235778483
Test: TreeHugger
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: Ife3ad35b2e5451727a3795a0e78dd820293c0eae

Maciej Żenczykowski   commited 2022-06-16 21:39:32 +00:00
ce9108f01a
Remove unused functions in TrafficController
addInterface and hasUpdateDeviceStatsPermission are not used

Test: m & flush & boot
Bug: 217624062
Change-Id: I8a0f84f607a4f35512bc72e732df8f689b8ed1c9

Motomu Utsumi   commited 2022-06-16 09:13:46 +00:00
bd94efc14a
Merge changes Ic6ff7a3d,Iff9b9792
* changes:
  Refactor code and improve tests for VPN filtering
  Remove LOCKDOWN from FirewallChain IntDef

Motomu Utsumi   authored and   Gerrit Code Review   commited 2022-06-16 01:32:20 +00:00
5d787feef0
Merge changes from topic "bpfmap1"
* changes:
  netd.c - reduce privs on maps
  BpfHandler.h - switch mStatsMapB from BpfMap to BpfMapRO
  BpfNetworkStatsTest - cleanup
  TEST_BPF_MAP -> BPF_MAP_MAKE_VISIBLE_FOR_TESTING
  BpfHandlerTest - minor fixups
  TrafficController - minor cleanup

Maciej Żenczykowski   authored and   Gerrit Code Review   commited 2022-06-14 06:18:46 +00:00
8f03c4495e
TEST_BPF_MAP -> BPF_MAP_MAKE_VISIBLE_FOR_TESTING
Per request of Lorenzo on:
  https://googleplex-android-review.git.corp.google.com/c/platform/frameworks/libs/net/+/18694820
  https://googleplex-android-review.git.corp.google.com/c/platform/packages/modules/Connectivity/+/18695355

Although he'd suggested 'BPF_MAP_TEST_ONLY',
but I think this is even clearer.

Test: TreeHugger
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: I796c939cba8866aca15f3dfff5a27ba986f74df6

Maciej Żenczykowski   commited 2022-06-13 19:39:06 -07:00
01319d931a
TrafficController - minor cleanup
as requested by Patrick on:
  https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/2006750

Test: TreeHugger
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: I65d9d1fe883fe183d386a0810b19e20a99ed5811

Maciej Żenczykowski   commited 2022-06-13 19:39:06 -07:00
93406acf63
Cleanup dead code in TrafficControllerTest
Test: atest TrafficControllerTest
Change-Id: I26c61b120ef773144562b7d72a3cf2230d5aff7a

Wayne Ma   commited 2022-06-13 17:05:25 +08:00
6e0b747c7b
Remove LOCKDOWN from FirewallChain IntDef
LOCKDOWN_VPN was in the FirewallChain IntDef but this was not a right
place because LOCKDOWN_VPN was not a valid value for Connectivity APIs
that take an argument annotated with @FirewallChain(setUidFirewallRule,
setFirewallChainEnabled, replaceFirewallChain).

LOCKDOWN_VPN was in the FirewallChain IntDef because
BpfNetMaps#setUidRule was used to add/remove LOCKDOWN_VPN entries.
This commit adds BpfNetMaps#updateUidLockdownRule and uses this to
add/remove LOCKDOWN_VPN entries instead of BpfNetMaps#setUidRule and
removes LOCKDOWN from FirewallChain.

Bug: 206482423
Test: atest TrafficControllerTest ConnectivityServiceTest
PermissionMonitorTest HostsideVpnTests#testBlockIncomingPacket

Change-Id: Iff9b9792fc0f208f153e10e396c6d5034b412d7c

Motomu Utsumi   commited 2022-06-10 02:49:25 +00:00
8b42e6d431
TrafficControllerTest: improve error declaration in dumpsysInvalidMaps
Test: atest TrafficControllerTest
Change-Id: Id2b2e8edefed615ccb3e94667bc91bc03e14ad81

Hungming Chen   authored and   Nucca Chen   commited 2022-06-09 05:38:37 +00:00
56b9013bcb