Commit Graph

1450 Commits

Author SHA1 Message Date
Maciej Żenczykowski
277bed477f Merge "add test for TetheringUtils::setupNsSocket()" am: d3bb5a544c am: b0c92ad6c8
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1638165

Change-Id: I8649019d166ccc13d37daacd1cd14dda398b6ca3
2021-03-16 07:07:46 +00:00
Lorenzo Colitti
d1107edddd Merge "Add a test for TetheringUtils.setupNaSocket." am: d5edbb9eb4 am: 706d7ffb3e
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1639699

Change-Id: Ib03fde8607b62802f897a5075ad0b638e9039fe6
2021-03-16 07:07:28 +00:00
Maciej Żenczykowski
d3bb5a544c Merge "add test for TetheringUtils::setupNsSocket()" 2021-03-16 06:23:06 +00:00
Lorenzo Colitti
d5edbb9eb4 Merge "Add a test for TetheringUtils.setupNaSocket." 2021-03-16 06:17:37 +00:00
Maciej Żenczykowski
e7c57368f8 add test for TetheringUtils::setupNsSocket()
Bug: 154669942
Test: test-only change
Change-Id: I33fe5a92667a0a6ee38bbcfdee40405cd37cc30f
2021-03-15 21:10:21 -07:00
Lorenzo Colitti
82d4b9956d Add a test for TetheringUtils.setupNaSocket.
Because most of the tethering tests are unprivileged, we cannot
test this code on real sockets. So use an AF_UNIX socketpair.

Bug: 154669942
Bug: 182785371
Test: test-only change
Change-Id: I843fddb3aaeab33628438f3bcd6a4166062de962
2021-03-15 21:01:42 -07:00
Remi NGUYEN VAN
016e0b9261 Merge changes from topic "conn_resources_cp"
* changes:
  Add ServiceConnectivityResources to in-process APEX
  Add ServiceConnectivityResources to tethering
2021-03-16 02:29:31 +00:00
Lorenzo Colitti
89c5bcf023 Merge "Add test for RouterAdvertisementDaemon." am: e8e91c1726 am: 464a83c23f
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1485809

MUST ONLY BE SUBMITTED BY AUTOMERGER

Change-Id: I7e75b2e2d80949864ec98ba2dc91012a8bc73793
2021-03-15 14:25:35 +00:00
Lorenzo Colitti
b0f7c1ce6a Merge "Do not open BPF maps when running on R." am: d12f867cb0 am: 9bcb23851b
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1635300

MUST ONLY BE SUBMITTED BY AUTOMERGER

Change-Id: Idf409e9d933b5a92e90597bcc3d8e9f16fa17b70
2021-03-15 14:25:29 +00:00
Lorenzo Colitti
e8e91c1726 Merge "Add test for RouterAdvertisementDaemon." 2021-03-15 13:21:03 +00:00
Lorenzo Colitti
3c228f4923 Do not open BPF maps when running on R.
Opening the maps on R devices is unnecessary (because no code
uses them) and unsafe (because the maps might actually be in a
different format than expected by the module).

Always return null when opening the maps, so the code will safely
fall back to using netd for anything.

This only affects dump(). The production code never opens the
maps except via the shim, and only the S shim opens the maps.
Also check isAtLeastS in dumpCounters, because it opens the map
directly.

Bug: 177884581
Test: builds, boots, "dumpsys tethering" shows expected output
Change-Id: I5884490a5cc40fc529a12100ae5baaeae6a18f30
2021-03-15 10:44:53 +00:00
markchien
2af32e475f Add test for RouterAdvertisementDaemon.
bug: 154669942
Test: atest TetheringPrivilegedTests
Change-Id: I2bbea720c486d6bb47a8d86375847894e2b2f390
2021-03-15 08:20:57 +00:00
Remi NGUYEN VAN
e2c74e90a9 Merge "Update sources of Tethering module since it is renamed" 2021-03-15 01:32:47 +00:00
Remi NGUYEN VAN
2fb22c2a2b Add ServiceConnectivityResources to in-process APEX
The APK was added to the standard APEX, but is missing in the
in-process APEX.

Bug: 182557971
Merged-In: Ic2491f04880ff66abc3b2d3aaee6168e18f6d68a
Merged-In: Ibf982ceb5f0fd61c822399e3eeeb1ef5e500604d

Change-Id: Ibf982ceb5f0fd61c822399e3eeeb1ef5e500604d
Test: m
2021-03-14 12:33:30 +09:00
Lorenzo Colitti
9bb23d6b44 Merge "Add a test for upstream selection." am: f427d49541 am: 939d48f96c
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1611320

MUST ONLY BE SUBMITTED BY AUTOMERGER

Change-Id: I661aa8582ded8e992aabb02b5cc403458e2b1508
2021-03-12 15:14:41 +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
Remi NGUYEN VAN
60f4c2f425 Add ServiceConnectivityResources to tethering
The resource package is used by service-connectivity to load its own
resources.

Bug: 182125649
Test: atest FrameworksNetTests

Merged-In: I3c7fc6285f10318ecef05a64e1179054bb831d99
Merged-In: Ic2491f04880ff66abc3b2d3aaee6168e18f6d68a

Change-Id: I3c7fc6285f10318ecef05a64e1179054bb831d99
2021-03-12 17:50:41 +09:00
Maciej Żenczykowski
f0424798ce Merge changes from topic "attach_bpfprog_in_mainline" am: 3357388742 am: 5254c0c243
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1607973

MUST ONLY BE SUBMITTED BY AUTOMERGER

Change-Id: I041c6fbd65444d1a01387038e0dfabb6b33944ba
2021-03-12 01:37:01 +00:00
Hungming Chen
5af3ee5da0 [NFCT.TETHER.14] Clear the BPF maps in BpfCoordinator ctor am: 499d3cac73 am: 129077bd58
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1623669

MUST ONLY BE SUBMITTED BY AUTOMERGER

Change-Id: I6d09c8f877c717670cf2e1462ec0146b1a0106dd
2021-03-12 01:37:00 +00:00
Hungming Chen
129077bd58 [NFCT.TETHER.14] Clear the BPF maps in BpfCoordinator ctor am: 499d3cac73
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1623669

MUST ONLY BE SUBMITTED BY AUTOMERGER

Change-Id: I54098527fb72260c01c78d0b49282da4257f4a24
2021-03-12 01:01:36 +00: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
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
Maciej Żenczykowski
79c1df6e0e ebpf offload - beginnings of xdp implementation am: 90b81ac174 am: e416c69f76
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1622560

MUST ONLY BE SUBMITTED BY AUTOMERGER

Change-Id: Ife38a96fd8c76b4d7e6591bb9123135f1d373c98
2021-03-10 14:58:06 +00:00
Maciej Żenczykowski
cffaf88a09 ebpf offload - make it possible to boot on Q era 4.14/4.19 kernels am: acddd4f183 am: 973a01cae3
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1625739

MUST ONLY BE SUBMITTED BY AUTOMERGER

Change-Id: I4c57851d064079ee668b77949e7cade8eefc8238
2021-03-10 14:58:00 +00:00
Maciej Żenczykowski
b2dc6cfa40 ebpf offload - noop program reorder am: 2278aed207 am: 4e071fff2a
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1625238

MUST ONLY BE SUBMITTED BY AUTOMERGER

Change-Id: I47d783a5000bb63ee98886377a577c6229645554
2021-03-10 14:57:58 +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
Lorenzo Colitti
e8937ed7c2 Make TestConnectivityManager send CONNECTIVITY_ACTION. am: 57957fe8a1 am: 138c2578a8
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1611319

MUST ONLY BE SUBMITTED BY AUTOMERGER

Change-Id: I65d61ecc50dc7fc66367a5db52cca07024455ec3
2021-03-09 17:57:31 +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
Maciej Żenczykowski
993ede170f Merge "bpf offload - add a new 'tether_xdp_devmap'" am: b908e0c867 am: f5a9d32a73
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1612879

MUST ONLY BE SUBMITTED BY AUTOMERGER

Change-Id: Ia43b04a9974288f6447e453cd645831b8efe6ca6
2021-03-05 07:02:16 +00:00
Lorenzo Colitti
d1ea11ed6a Merge changes I968bfa76,Id46f1e5b,Iff9b6212,I6bdb090a am: bc87f8a9d9 am: 69b2de6e5a
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1611318

MUST ONLY BE SUBMITTED BY AUTOMERGER

Change-Id: I0260aa93cbf2e8179de8bb7a13b65ca47fb0493d
2021-03-05 07:02:12 +00:00
Maciej Żenczykowski
b908e0c867 Merge "bpf offload - add a new 'tether_xdp_devmap'" 2021-03-05 06:03:02 +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
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
Remi NGUYEN VAN
bc1bdf4a85 Merge "Add dependency on system API in connectivity" 2021-03-01 01:07:19 +00: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
Remi NGUYEN VAN
62a1ba2d1b Merge "Add flag to force choosing upstreams automatically" am: e43c960d50 am: a474b9edfa
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1596352

MUST ONLY BE SUBMITTED BY AUTOMERGER

Change-Id: Iaef23446e43ef557521785a23e5dcf81655d7f05
2021-02-26 10:01:35 +00:00
Treehugger Robot
f14f0783aa Merge "ebpf offload: bump size of ipv4 tethering maps" am: fcd5ec1971 am: f1a420808c
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1608893

MUST ONLY BE SUBMITTED BY AUTOMERGER

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

MUST ONLY BE SUBMITTED BY AUTOMERGER

Change-Id: Ifa82c02dee9bad56257d3834c16091f19f7cdd41
2021-02-26 06:57:05 +00:00
Remi NGUYEN VAN
e43c960d50 Merge "Add flag to force choosing upstreams automatically" 2021-02-26 06:42:00 +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