Commit Graph

9867 Commits

Author SHA1 Message Date
Hungming Chen
23ee901e76 Do not start conntrack event monitor when running on R
Starting conntrack event monitor on R devices is unnecessary because
no code uses them.

Bug: 177884581
Test: atest TetheringCoverageTests
Change-Id: I036cb8e29b32a4e220da9a52849b978a6ab821e4
2021-03-16 14:18:32 +08:00
Remi NGUYEN VAN
e2c74e90a9 Merge "Update sources of Tethering module since it is renamed" 2021-03-15 01:32:47 +00:00
Lorenzo Colitti
f427d49541 Merge "Add a test for upstream selection." 2021-03-12 14:07:01 +00:00
Lorenzo Colitti
473399ceab Add a test for upstream selection.
Currently, upstream selection is split between the Tethering and
UpstreamNetworkMonitor classes. The UpstreamNetworkMonitor bits
are unit tested, but there are no tests for the interaction of
the two. Add a simple test.

In order to do this, remove the code that controls the
UpstreamNetworkMonitor spy from prepareUsbTethering. This is so
that the new test can call prepareUsbTethering but still rely on
the behaviour of the actual UpstreamNetworkMonitor.

Bug: 173068192
Test: atest TetheringTests
Change-Id: If2ef9af82bc0cbff9172e575ad3d7686e5b492da
2021-03-12 17:59:02 +09:00
Maciej Żenczykowski
3357388742 Merge changes from topic "attach_bpfprog_in_mainline"
* changes:
  [NFCT.TETHER.15] Attach BPF program in the mainline module
  [NFCT.TETHER.14] Clear the BPF maps in BpfCoordinator ctor
2021-03-12 00:21:01 +00:00
Remi NGUYEN VAN
ce2ab07074 Merge "Rename StringNetworkSpecifier to Ethernet" 2021-03-11 23:51:49 +00:00
Hungming Chen
3dbd4a1cc4 [NFCT.TETHER.15] Attach BPF program in the mainline module
Migrate Maze's BPF program attaching and detaching functions from
system/netd/server/OffloadUtils.{c, h} to tethering module.

Test: atest TetheringCoverageTests
Test case #1:
Enable WiFi hotspot and check tc filters are added or removed on both
wlan1 and rmnet_data#.

$ adb shell tc filter show dev wlan1 ingress
filter protocol ipv6 pref 1 bpf chain 0
filter protocol ipv6 pref 1 bpf chain 0 handle 0x1
prog_offload_schedcls_tether_upstream6_ether:[*fsobj] direct-action
not_in_hw id 2 tag 7cf020cc09a7c982
filter protocol ip pref 2 bpf chain 0
filter protocol ip pref 2 bpf chain 0 handle 0x1
prog_offload_schedcls_tether_upstream4_ether:[*fsobj] direct-action
not_in_hw id 7 tag 2f87d55b636c082c

$ adb shell tc filter show dev rmnet_data2 ingress;
filter protocol ipv6 pref 1 bpf chain 0
filter protocol ipv6 pref 1 bpf chain 0 handle 0x1
prog_offload_schedcls_tether_downstream6_rawip:[*fsobj] direct-action
not_in_hw id 3 tag 8b3885b75bd261de
filter protocol ip pref 2 bpf chain 0
filter protocol ip pref 2 bpf chain 0 handle 0x1
prog_offload_schedcls_tether_downstream4_rawip:[*fsobj] direct-action
not_in_hw id 6 tag b1c9478c91f8df9a

Test case #2:
Enable USB tethering and check tc filters are added or removed on both
rndis0 and rmnet_data#.

Test case #3:
Enable WiFi and USB tethering and check tc filter are added or removed
on rndis0, wlan1 and rmnet_data#.

Change-Id: I3f9a65043271bc8f5bf1b82ae505c471625ca9de
2021-03-11 17:49:42 +08:00
Aaron Huang
b401e58a1e Update sources of Tethering module since it is renamed
framework-tethering-shared-srcs is named to
framework-connectivity-shared-srcs so update
source section to include correct file group.

Ignore-AOSP-First: changes in topic has conflicts in sc-dev
Bug: 177046265
Test: FrameworksNetTests
Change-Id: I81e2af0cc3b37af16b03c1288eb0591b7ed65cc4
Merged-In: I81e2af0cc3b37af16b03c1288eb0591b7ed65cc4
Merged-In: Ic2491f04880ff66abc3b2d3aaee6168e18f6d68a
2021-03-11 07:36:55 +00:00
Sudheer Shanka
b94021ab6e Merge "Skipping printing AssumptionViolatedExceptions." 2021-03-10 14:26:18 +00:00
Maciej Żenczykowski
90b81ac174 ebpf offload - beginnings of xdp implementation
Test: TreeHugger
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: I6956e78bd325b63dc6dc813440f9f80c29aada36
2021-03-10 14:02:50 +00:00
Maciej Żenczykowski
acddd4f183 ebpf offload - make it possible to boot on Q era 4.14/4.19 kernels
by marking programs as optional and providing appropriate stub implementations.

Test: TreeHugger
Bug: 181045068
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: I021e7bcbfe4236242f517f067f89777fc08ecd8d
2021-03-10 13:59:46 +00:00
Maciej Żenczykowski
2278aed207 ebpf offload - noop program reorder
This is just a cut'n'paste reordering of programs.
Goal is to put rawip programs above ether ones.
This will enable next change to be easier to read.

Test: TreeHugger
Bug: 181045068
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: Icebf4bf0505136e97b7b6950fb0b790582eb495e
2021-03-10 13:59:00 +00:00
Hungming Chen
499d3cac73 [NFCT.TETHER.14] Clear the BPF maps in BpfCoordinator ctor
Needed while the system server has recovered from crash.

Test: atest TetheringCoverageTests
Change-Id: Idbed4887f5396537f0d0df97de8b482266dffbb7
2021-03-09 16:11:22 +08:00
Lorenzo Colitti
57957fe8a1 Make TestConnectivityManager send CONNECTIVITY_ACTION.
The tethering code still depends on CONNECTIVITY_ACTION for
upstream selection. Make TestConnectivityManager send these
broadcasts.

Bug: 173068192
Test: atest TetheringTests
Change-Id: I6a32e99fafef9d6d2abec438ffc68164ab4c5bdf
2021-03-09 01:16:35 +09:00
Sudheer Shanka
c19cd34a35 Skipping printing AssumptionViolatedExceptions.
Right now, if there are any failures along with
the cases where we skip the test, we end up printing
failure exception and all AssumptionViolatedExceptions
which makes it hard to find the actual failures.

Bug: 181686645
Test: atest ./tests/cts/hostside/src/com/android/cts/net/HostsideRestrictBackgroundNetworkTests.java
Change-Id: Ib3f1622fc259ad4966789cfafdc54203c2559471
2021-03-05 09:30:34 +00:00
Maciej Żenczykowski
b908e0c867 Merge "bpf offload - add a new 'tether_xdp_devmap'" 2021-03-05 06:03:02 +00:00
Lorenzo Colitti
bc87f8a9d9 Merge changes I968bfa76,Id46f1e5b,Iff9b6212,I6bdb090a
* changes:
  Use TestConnectivityManager in TetheringTest.
  Support building different UpstreamNetworkState test objects.
  Change TetheringTest's UpstreamNetworkMonitor from mock to spy.
  Make TestConnectivityManager usable by other tethering tests.
2021-03-05 05:11:10 +00:00
Lorenzo Colitti
66287d3551 Use TestConnectivityManager in TetheringTest.
The changes required are:
- Change all usages of when(mCm.method()).thenReturn(...) to
  doReturn(...).when(mCm).method() because spies must use the
  latter syntax.
- In setDataSaverEnabled, set the mocked return value before
  sending the broadcast. Otherwise, the first time the method is
  called, the spy will attempt to send the broadcast, and will
  crash because it does not have permission to do so.

This does not do anything useful yet, but it will be used in
future CLs.

Bug: 173068192
Test: atest TetheringTests
Change-Id: I968bfa76ead25b2d45ed1c0e8ede32df81401579
2021-03-04 23:06:52 +09:00
Lorenzo Colitti
b424a2794e Support building different UpstreamNetworkState test objects.
TetheringTest is only able to build UpstreamNetworkState objects
for mobile Internet networks. Support building wifi and dun
versions as well.

Bug: 173068192
Test: atest TetheringTests
Change-Id: Id46f1e5b65dbe04e84a5f56343821af260e2539e
2021-03-04 23:02:40 +09:00
Lorenzo Colitti
bf69824479 Change TetheringTest's UpstreamNetworkMonitor from mock to spy.
This allows future tests that want to exercise the interactions
between Tethering and UNM to do so.

Also verify what happens when UNM is initialized, and in setUp,
capture the NetworkCallback it files to track the default
network, so tests can send it NetworkCallbacks. (This callback
is only ever filed once.)

Test: test-only change
Change-Id: Iff9b62120cced41cc61263bfd4fa34f575d0ac00
2021-03-04 23:02:40 +09:00
Lorenzo Colitti
d025c562f0 Make TestConnectivityManager usable by other tethering tests.
Currently, this class is a static inner class of
UpstreamNetworkMonitorTest. Extract it to its own top-level class
so it can be used by other tests.

Bug: 173068192
Test: atest TetheringTests
Change-Id: I6bdb090a99781ac2530b3924ac5c4cf78de315b0
2021-03-04 23:02:40 +09:00
Remi NGUYEN VAN
71de00d339 Rename StringNetworkSpecifier to Ethernet
Tests just need a specifier to verify general NetworkSpecifier
functionality. They can use EthernetNetworkSpecifier the same way they
use StringNetworkSpecifier.

To keep the tests passing on Q and R, add a CompatUtil class that will
keep creating StringNetworkSpecifiers (now removed) instead.

Bug: 179329291
Test: atest CtsNetTestCases
Merged-In: Ic6bf611ba36b555e4e0bb1bd3fa0053fe29dc8cf

Change-Id: I38fa9eed5915264a53cc70e8f170c003eefe04e2
2021-03-03 18:28:38 +09:00
Maciej Żenczykowski
db2cff5cdf bpf offload - add a new 'tether_xdp_devmap'
It will map device ifindex to itself (but note that internally in the
kernel this is optimized into a map from ifindex to direct device
pointer), but only for xdp transmit capable devices (other devices
will not have an entry).

This will allow the use of bpf_redirect_map() from xdp tethering programs.

Test: atest, TreeHugger
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: I29684e6761727d1115e9b4d75486eccbca3d5e33
2021-03-01 23:42:43 -08:00
Treehugger Robot
c7d509804b Merge "Make ConnectivityManagerTest use the API shims." am: c8761c98ae
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1611323

MUST ONLY BE SUBMITTED BY AUTOMERGER

Change-Id: Ie3de6a218eabeab2532d6ee4d27c7f2ee65b6065
2021-03-01 19:30:24 +00:00
Treehugger Robot
c8761c98ae Merge "Make ConnectivityManagerTest use the API shims." 2021-03-01 17:50:10 +00:00
Remi NGUYEN VAN
94358c4c9e Add CtsNetTestCases to TEST_MAPPING am: ad380c1de6
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1612014

MUST ONLY BE SUBMITTED BY AUTOMERGER

Change-Id: I35c8e85d9c321a96703e879ff2ce230749d7f9dd
2021-03-01 09:02:25 +00:00
Lorenzo Colitti
8060dfed23 Make ConnectivityManagerTest use the API shims.
This is required for the code to be identical in AOSP and
mainline-prod.

Bug: 167645754
Test: atest CtsNetTestCases passes on AOSP device
Test: atest CtsNetTestCasesLatestSdk passes on AOSP device
Test: atest CtsNetTestCasesLatestSdk passes on R device
Change-Id: I094906e535d710a46a3fa833b6aa48cb007d6b63
2021-03-01 15:59:40 +09:00
Remi NGUYEN VAN
ad380c1de6 Add CtsNetTestCases to TEST_MAPPING
CtsNetTestCases is identical to CtsNetTestCasesLatestSdk,
with a newer target_sdk and newer API shims.

Bug: 167645754
Change-Id: Ib4e281bf84cb6ba0e7b904d57cef7c985dec2132
Test: atest CtsNetTestCases
2021-03-01 06:54:57 +00:00
Remi NGUYEN VAN
68b759c2c1 Merge "Add dependency on system API in connectivity" am: bc1bdf4a85
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1552320

MUST ONLY BE SUBMITTED BY AUTOMERGER

Change-Id: Ib1db46318bbccfc496f5fcc9481e177d66e9b46a
2021-03-01 02:10:04 +00:00
Remi NGUYEN VAN
bc1bdf4a85 Merge "Add dependency on system API in connectivity" 2021-03-01 01:07:19 +00:00
Lorenzo Colitti
894c6ff74a Use NET_CAPABILITY_NOT_VCN_MANAGED from ConstantsShim. am: 589d0ad195
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1611315

MUST ONLY BE SUBMITTED BY AUTOMERGER

Change-Id: I0b6636bd7b8a6419341bcf1e0c65a62dea27e0b0
2021-03-01 00:46:54 +00:00
Lorenzo Colitti
589d0ad195 Use NET_CAPABILITY_NOT_VCN_MANAGED from ConstantsShim.
This is required to build in mainline-prod, which does not have
access to in-progress S APIs.

Bug: 167645754
Test: m NetworkStack CtsNetTestCasesLatestSdk CtsHostsideNetworkTests CtsHostsideNetworkTestsApp
Change-Id: If40ebfadbf6d3ee86a58a55711fbc146a8599fdb
Merged-In: If40ebfadbf6d3ee86a58a55711fbc146a8599fdb
2021-03-01 00:16:36 +09:00
Remi NGUYEN VAN
74b274424a Add dependency on system API in connectivity
The system API are moved to the connectivity module: add dependency on
the stubs from framework-tethering.

This only allows tethering to depend on system API defined by the
connectivity classes, not on any private code, even if they are
eventually bundled in the same APEX.

Bug: 171540887
Test: m

Merged-In: Iebfb3e01c5d2480e84edcfc76cf489520bd60237
Merged-In: Ic2491f04880ff66abc3b2d3aaee6168e18f6d68a
(clean cherry-pick from internal branch)

Change-Id: Iebfb3e01c5d2480e84edcfc76cf489520bd60237
2021-02-26 19:36:06 +09:00
Junyu Lai
3ec8882370 Merge "Fix CTS test failed on R device" am: 75d28bee27
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1602480

MUST ONLY BE SUBMITTED BY AUTOMERGER

Change-Id: I76b422a0f86a5ca63021d1cb88db37089a310280
2021-02-26 09:31:05 +00:00
Remi NGUYEN VAN
a474b9edfa Merge "Add flag to force choosing upstreams automatically" am: e43c960d50
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1596352

MUST ONLY BE SUBMITTED BY AUTOMERGER

Change-Id: If6b4415a3a3f507101d63b53296925b3572ebf1e
2021-02-26 09:30:57 +00:00
Junyu Lai
75d28bee27 Merge "Fix CTS test failed on R device" 2021-02-26 07:17:47 +00:00
Remi NGUYEN VAN
e43c960d50 Merge "Add flag to force choosing upstreams automatically" 2021-02-26 06:42:00 +00:00
Treehugger Robot
f1a420808c Merge "ebpf offload: bump size of ipv4 tethering maps" am: fcd5ec1971
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1608893

MUST ONLY BE SUBMITTED BY AUTOMERGER

Change-Id: Iccd3542628882fdaa25ed0a5b2c073f596ea198b
2021-02-26 06:05:10 +00:00
Treehugger Robot
9ea87036a8 Merge "ebpf offload: mark as critical for tethering not netd" am: 4945772ba7
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1607252

MUST ONLY BE SUBMITTED BY AUTOMERGER

Change-Id: I8d58bccf80be1fa6346922abd769c1b96e4274be
2021-02-26 06:04:04 +00:00
Treehugger Robot
fcd5ec1971 Merge "ebpf offload: bump size of ipv4 tethering maps" 2021-02-26 05:43:07 +00:00
Treehugger Robot
4945772ba7 Merge "ebpf offload: mark as critical for tethering not netd" 2021-02-26 05:39:07 +00:00
Maciej Żenczykowski
8549af9f17 ebpf offload: bump size of ipv4 tethering maps
For ipv6 we need 1 entry per client, so 64 seems like plenty,
while for ipv4 we need 1 entry per flow, so even 1024 seems
like it might not be enough, but it's much better than 64.

Nucca says:
  # cat proc/sys/net/netfilter/nf_conntrack_buckets
  65536
  # cat proc/sys/net/netfilter/nf_conntrack_max
  262144

  per https://www.kernel.org/doc/Documentation/networking/nf_conntrack-sysctl.txt
  the default “nf_conntrack_max” is “nf_conntrack_buckets * 4”.

Test: TreeHugger
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: Ib7d1d8c19bc688c442d842cf5c9f45cdf1241754
2021-02-25 19:11:39 -08:00
Maciej Żenczykowski
607d6dda0d ebpf offload: mark as critical for tethering not netd
Test: TreeHugger
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: I5bccfcbababb09a412ac1093513ad93c254b349b
2021-02-25 19:10:01 -08:00
Junyu Lai
b209d3a2a7 Merge "[VCN07.1] Add test for bypassing VCN for non-internet request" am: 3f134a3805
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1597477

MUST ONLY BE SUBMITTED BY AUTOMERGER

Change-Id: Idfe60822e28968c52514497e43537cb6e9c0fae3
2021-02-25 11:03:33 +00:00
Junyu Lai
3f134a3805 Merge "[VCN07.1] Add test for bypassing VCN for non-internet request" 2021-02-25 10:16:03 +00:00
Chalard Jean
d3e8ae1f88 Merge "Release test network in a test" am: 26c11595bc
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1605235

MUST ONLY BE SUBMITTED BY AUTOMERGER

Change-Id: Iae36d7f39bd1ff5287311df965829f6dee3de0d4
2021-02-25 08:46:15 +00:00
Chalard Jean
26c11595bc Merge "Release test network in a test" 2021-02-25 08:06:15 +00:00
Daulet Zhanguzin
c4f27ccd99 Use unbundled version of BouncyCastle in Ike cts tests am: bb540131b7
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1605037

MUST ONLY BE SUBMITTED BY AUTOMERGER

Change-Id: I46509df9b0f5c69d698f14c5a253b75fd4f71729
2021-02-25 07:24:03 +00:00
junyulai
d69d7c815c Fix CTS test failed on R device
The test failed since the API is not available on R device.
Add conditions to ignore it.

Test: atest CtsHostsideNetworkTests:com.android.cts.net.HostsideVpnTests
      on R device
Bug: None
Change-Id: I05a1f63adec72e89382cb095db714bccbdff0058
2021-02-25 08:39:28 +08:00
Chalard Jean
8a8bf7434c Release test network in a test
This causes failures in subsequent tests that expect
only one test network to be up.

Bug: 181033598
Test: this
Change-Id: I74444f4aff7750a5bbd2564e5e22714d73c72d8b
2021-02-24 23:07:13 +09:00