Commit Graph

1091 Commits

Author SHA1 Message Date
Treehugger Robot
ff55bbf0f4 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: Ie672e82b07825833a1417f0ca67dd0e8e413eabf
2021-02-26 09:14:53 +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
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
Lorenzo Colitti
ad38d27ebb Add a BpfMap#clear method. am: ffb0ccd04b am: 10be22076e
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1604974

MUST ONLY BE SUBMITTED BY AUTOMERGER

Change-Id: I1e4d5e6005cdd006ddd814692714fb80a6c46936
2021-02-24 12:30:56 +00:00
Lorenzo Colitti
4d09a87075 Move definitions used by tethering bpf code into the module. am: 56be03eb28 am: 69b0769eb0
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1601855

MUST ONLY BE SUBMITTED BY AUTOMERGER

Change-Id: I842250d341916f7d5a1f48ba8ec09c4235d20d51
2021-02-24 06:59:26 +00:00
Lorenzo Colitti
ffb0ccd04b Add a BpfMap#clear method.
A caller can mostly already do this via forEach(), but having a
specific method is faster (since the code does not need to read
the value) and easier to use.

The semantics of this method (e.g., ignore ENOENT while deleting
a key, but throw on any other error) match those of the native
BpfMap::clear method.

Test: new unit tests
Change-Id: I5cd32efd0f87c823cd2d0a2fa3a95a83093fb6f9
2021-02-24 06:09:46 +00:00
Lorenzo Colitti
56be03eb28 Move definitions used by tethering bpf code into the module.
Bug: 167645754
Test: m com.android.tethering
Change-Id: Ia4fb1201e5f4e0c35baba7865b26b4cec0945a64
2021-02-24 12:16:05 +09:00
Bob Badour
a3f610a7b2 Merge "[LSC] Add LOCAL_LICENSE_KINDS to packages/modules/Connectivity" am: f5b346ed1d am: c384c677ef
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1587901

MUST ONLY BE SUBMITTED BY AUTOMERGER

Change-Id: I2f5af6eb56b232f1b79ff48ca6824f2ec726f01a
2021-02-19 07:48:38 +00:00
Bob Badour
f5b346ed1d Merge "[LSC] Add LOCAL_LICENSE_KINDS to packages/modules/Connectivity" 2021-02-19 06:23:22 +00:00
Tomasz Wasilczyk
6b10dc120d Merge "Don't crash Tethering service when WiFi feature is missing" am: 736f8ec55a am: 5278b64768
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1577289

MUST ONLY BE SUBMITTED BY AUTOMERGER

Change-Id: Ice05e20436c5bab99e72f61179df055c657cc248
2021-02-18 20:30:16 +00:00
Tomasz Wasilczyk
736f8ec55a Merge "Don't crash Tethering service when WiFi feature is missing" 2021-02-18 18:20:28 +00:00
Treehugger Robot
8f356c1608 Merge "Use networkstack_client instead of aidl_interface" am: 319064f284 am: 8cd484f656
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1560399

MUST ONLY BE SUBMITTED BY AUTOMERGER

Change-Id: I8695d8cc740df456cb1cc9e38dbfdb4432452f7e
2021-02-18 15:28:40 +00:00
Treehugger Robot
9b23f59e33 Merge "Add tethering-module-sdk build target." am: c4127ef16c am: f6f3456ae7
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1587662

MUST ONLY BE SUBMITTED BY AUTOMERGER

Change-Id: I8ebd51517170934130e27c28b86f794081cb5198
2021-02-18 14:58:23 +00:00
Treehugger Robot
319064f284 Merge "Use networkstack_client instead of aidl_interface" 2021-02-18 13:31:54 +00:00
Treehugger Robot
c4127ef16c Merge "Add tethering-module-sdk build target." 2021-02-18 12:05:46 +00:00
Treehugger Robot
d201e37561 Merge "Set updateable:false explicitly in apex rules." am: c72a6cae30 am: 89cd911569
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1590053

MUST ONLY BE SUBMITTED BY AUTOMERGER

Change-Id: I073da66ae98c1de75870ba2da1e5504a319902b2
2021-02-18 10:24:59 +00:00
Maciej Żenczykowski
aedd2eacd8 ebpf offload - rename PUNT/DROP to TC_PUNT/TC_DROP am: e982f091e1 am: 4248054e08
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1591369

MUST ONLY BE SUBMITTED BY AUTOMERGER

Change-Id: Ie259ca96bd3e0e693cda96c89825675f0a2879b0
2021-02-18 10:24:50 +00:00
Maciej Żenczykowski
2ef44d9cef ebpf offload - add support for tethering of ipv4 udp am: e4a726a5c6 am: 1f6bed0155
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1591368

MUST ONLY BE SUBMITTED BY AUTOMERGER

Change-Id: Ib22a34dd4c0f1c072ccb2120eaeda51da79a44a3
2021-02-18 10:10:05 +00:00
Treehugger Robot
c72a6cae30 Merge "Set updateable:false explicitly in apex rules." 2021-02-18 09:30:33 +00:00
Maciej Żenczykowski
63a3a118b9 Merge "ebpf offload - do L4 header present check earlier" am: 2c0edb112f am: 9b833afa0a
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1591367

MUST ONLY BE SUBMITTED BY AUTOMERGER

Change-Id: Ida5efa2217eb8f25eb4a7a7b73b783aa56469e60
2021-02-18 07:52:08 +00:00
Maciej Żenczykowski
e982f091e1 ebpf offload - rename PUNT/DROP to TC_PUNT/TC_DROP
because it is not appropriate for use in XDP programs

Test: TreeHugger
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: Ibd5dac9676bae7aa5f10fbcfd777291f72bec819
2021-02-18 06:40:33 +00:00
Maciej Żenczykowski
e4a726a5c6 ebpf offload - add support for tethering of ipv4 udp
Test: TreeHugger
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: I6229e33cb219e9acd14f5b880cfa2ea0a34442f4
2021-02-18 06:38:36 +00:00
Maciej Żenczykowski
82ee26be75 ebpf offload - do L4 header present check earlier
and more importantly unconditionally.  This requires less effort
on the part of the in-kernel bpf verifier.

Test: TreeHugger
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: Ibaa94bf096fc81c4d984dfabf515131b1c81ef09
2021-02-18 06:23:32 +00:00
Tomasz Wasilczyk
3cbccdb6c3 Don't crash Tethering service when WiFi feature is missing
Bug: 175430552
Test: disable WiFi feature on device with wlan0

Change-Id: Ie8b422ed6e0a0a98eb1c7e6072464859d9083ba5
2021-02-17 15:36:05 -08:00
Mathew Inwood
adfc933979 Set updateable:false explicitly in apex rules.
Currently, this is the default so this is a no-op,
But the default is changing to true.

Bug: 180375550
Test: Treehugger
Change-Id: Ib841e474ab2b2ff2b54c160bb06c3bbbeea92675
2021-02-16 14:58:27 +00:00
Bob Badour
97e6be27f6 [LSC] Add LOCAL_LICENSE_KINDS to packages/modules/Connectivity
Added SPDX-license-identifier-Apache-2.0 to:
  Tethering/Android.bp
  Tethering/apex/Android.bp
  Tethering/bpf_progs/Android.bp
  Tethering/common/TetheringLib/Android.bp
  Tethering/tests/Android.bp
  Tethering/tests/integration/Android.bp
  Tethering/tests/mts/Android.bp
  Tethering/tests/privileged/Android.bp
  Tethering/tests/unit/Android.bp
  tests/cts/hostside/Android.bp
  tests/cts/hostside/aidl/Android.bp
  tests/cts/hostside/app/Android.bp
  tests/cts/hostside/app2/Android.bp
  tests/cts/hostside/certs/Android.bp
  tests/cts/net/Android.bp
  tests/cts/net/api23Test/Android.bp
  tests/cts/net/appForApi23/Android.bp
  tests/cts/net/jni/Android.bp
  tests/cts/net/native/dns/Android.bp
  tests/cts/net/native/qtaguid/Android.bp
  tests/cts/net/util/Android.bp
  tests/cts/tethering/Android.bp

Bug: 68860345
Bug: 151177513
Bug: 151953481

Test: m all

Exempt-From-Owner-Approval: janitorial work
Change-Id: I8534c580f0e2a17be146300b67b3604817b64507
2021-02-16 04:09:58 -08:00
Jeongik Cha
d05f990649 Use networkstack_client instead of aidl_interface
Bug: 150578172
Test: m
Change-Id: Ib5f28db973eb80942faafe1c1c5ddcaab54bf980
2021-02-16 08:20:12 +00:00
Maciej Żenczykowski
6224c0e30e offload ebpf - introduce 4.14+ ipv4 forwarding programs am: 36867351ec am: f335d68cb8
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1588019

MUST ONLY BE SUBMITTED BY AUTOMERGER

Change-Id: Ie736bc216988be768dad0f7229fbc51f4d7cc40e
2021-02-16 08:20:04 +00:00
Maciej Żenczykowski
36867351ec offload ebpf - introduce 4.14+ ipv4 forwarding programs
We've backported the necessary support to all 4.14+ ACK kernels,
but we can't actually enforce that these changes will be picked
up by all devices.  Thus we can only make the full featured
implementations optional on [4.14..5.8) kernels, with a tcp-only
version for those 4.14+ devices where the full featured version
fails to load.

Note: there's still a fair bit of implementation work left
in the do_forward4() function itself.  This is really just
the skeleton.

Test: atest, TreeHugger
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: If78123e00d55a77f2ecd7da1547581797e23f9b2
2021-02-16 05:48:55 +00:00
Maciej Żenczykowski
be444669e3 Merge "offload ebpf - do_forward4() - introduce updatetime argument" am: d74918c6d2 am: 623479f329
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1588018

MUST ONLY BE SUBMITTED BY AUTOMERGER

Change-Id: I696c7f791dc805b71b13c64cc442675f45803ce9
2021-02-15 13:33:32 +00:00
Maciej Żenczykowski
aefa0950b5 offload ebpf - do_forward4() - introduce updatetime argument
This will facilitate providing a tcp-only version of the programs
which due to TCP's very long timeouts will not need to use the
Linux 5.8+ bpf_ktime_get_boot_ns() helpers.

Test: atest, TreeHugger
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: I1e49b6758d3754782ac6f8820e0c15aa20e4c61d
2021-02-15 12:33:01 +00:00
Maciej Żenczykowski
5d6f744551 tethering offload ebpf - lower requirement from 5.9 to 5.8 am: b0ac41f0cd am: c456856971
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1588017

MUST ONLY BE SUBMITTED BY AUTOMERGER

Change-Id: I2a6be5ac4bbc887ef11b4fc8110115e11e947fa3
2021-02-15 12:20:22 +00:00
Maciej Żenczykowski
b0ac41f0cd tethering offload ebpf - lower requirement from 5.9 to 5.8
As this is the actual version that is required,
ie. the version that supports bpf_ktime_get_boot_ns() helper.

Test: atest, TreeHugger
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: I2ea4830597a0bed53950a5d0c483a47208959f35
2021-02-14 22:24:34 -08:00
Hai Zhang
6d71f109bc Add tethering-module-sdk build target.
Bug: 177884752
Test: m tethering-module-sdk
Change-Id: Idd4e6743001a6402f6a5dd6832601b08d7cc0236
2021-02-14 06:38:26 +00:00
Lorenzo Colitti
531fa9e0cc Merge "Load JNI in all classes that have native methods." am: af97e51c01 am: ceafffa6c0
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1581528

MUST ONLY BE SUBMITTED BY AUTOMERGER

Change-Id: I21f1af4785d1ee540ba6dea8416c2538e60a9228
2021-02-12 05:49:17 +00:00
Treehugger Robot
55e1cc23c6 Merge "fix TetheringCoverageTests" am: 6fc8229f16 am: 31ce8ad94d
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1584755

MUST ONLY BE SUBMITTED BY AUTOMERGER

Change-Id: If61cbbe8729451b53aea976540d388868cdde01a
2021-02-12 05:48:49 +00:00
Lorenzo Colitti
af97e51c01 Merge "Load JNI in all classes that have native methods." 2021-02-12 03:19:00 +00:00
Maciej Żenczykowski
c92e8ce636 fix TetheringCoverageTests
Test: atest TetheringCoverageTests now passes, TreeHugger
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: I0d83de14784f323400a83ce282cae1a3e7b4b396
2021-02-11 16:06:46 -08:00
Lorenzo Colitti
17b18ca6c2 Add IPv4 counters. am: d561b7f67c am: d2956a1964
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1580287

MUST ONLY BE SUBMITTED BY AUTOMERGER

Change-Id: Ic66884108ae7fde4c1688847f7b2092c8d6e941d
2021-02-10 06:54:53 +00:00
Lorenzo Colitti
6800811597 Load JNI in all classes that have native methods.
The tethering module uses JNI in various classes, but only calls
System.loadLibrary in TetheringService#makeTethering. This means
that:

1. Any test that uses a class that uses JNI must load the
   library itself.
2. Any code that runs before TetheringService#makeTethering could
   potentially crash if it uses JNI. We may never have such code
   though.

Instead, make every class that has a native method load the JNI
library itself at static initialization time. This guarantees
that the class will have the JNI code available in any context
(production, test, etc.)

System.loadLibrary is documented not to do anything if called
more than once with the same library name:
https://docs.oracle.com/javase/7/docs/api/java/lang/Runtime.html#loadLibrary(java.lang.String)

and the implementation has a lock so it is safe to call from
multiple threads concurrently.

Test: builds, boots, tethering starts
Test: atest TetheringCoverageTests
Change-Id: I9c0147ae9a28877f416aaff387b426d304ae552d
2021-02-10 15:43:38 +09:00
Lorenzo Colitti
7081e9f184 Dump counters in "dumpsys tethering bpf". am: 4e92da06fa am: e033a1e543
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1575051

MUST ONLY BE SUBMITTED BY AUTOMERGER

Change-Id: Ib449565583901259f0c21764d566637eace5f5f8
2021-02-10 05:31:03 +00:00
Lorenzo Colitti
d561b7f67c Add IPv4 counters.
Test: dumpsys tethering bpf
Change-Id: Ie21fee8ad12430ecd21c3903587d25b8dd2a96c4
2021-02-10 04:44:35 +00:00
Lorenzo Colitti
4e92da06fa Dump counters in "dumpsys tethering bpf".
This CL adds the counters collected by the tethering programs to
the output of "dumpsys tethering bpf". The counter names are
fetched by JNI code at startup and then read by the debugging
code on demand.

Example from my device:

  Forwarding errors:
    TCP_CONTROL_PACKET: 67
    NON_GLOBAL_SRC: 13
    NON_GLOBAL_DST: 17
    LOCAL_SRC_DST: 7

Test: manual (debug-only code)
Change-Id: I7ec7992612556a4bca5f1b6bb52c655d6d870201
2021-02-10 04:43:03 +00:00
Lorenzo Colitti
a47891732f Don't leak map fds in BpfCoordinator#dump. am: 555472a186 am: a6c9626b5d
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1581523

MUST ONLY BE SUBMITTED BY AUTOMERGER

Change-Id: Id5a3c980a0f9409b9342672935b9567c89422305
2021-02-09 22:50:01 +00:00
Lorenzo Colitti
555472a186 Don't leak map fds in BpfCoordinator#dump.
Currently, the dump methods open BpfMap objects and never close
them. This leaks filedescriptors, and if dump is called often
enough, will crash the networkstack process.

Fix this by using try-with-resources statements that
automatically close the map when exiting the try block.

Change the signature of BpfMap#close from "throws Exception" to
"throws ErrnoException" since it does not throw any other type
of checked exceptions.

Test: "lsof | grep network_st" while running "dumpsys tethering bpf" in a loop
Change-Id: I66c407454c2715bf41bf3a2e81bd582f9ea5a905
2021-02-09 23:30:25 +09:00
Lorenzo Colitti
29f8e3550b Merge "offload - finish ipv4 tethering" am: 4431655a4d am: 76a663683c
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1562765

MUST ONLY BE SUBMITTED BY AUTOMERGER

Change-Id: I386c9e5230fb978856437a9afc0b3920edfcf051
2021-02-09 13:00:08 +00:00
Lorenzo Colitti
4431655a4d Merge "offload - finish ipv4 tethering" 2021-02-09 11:08:06 +00:00
Lorenzo Colitti
b9b629f273 Improve BPF tethering counters. am: 72ec3ba88a am: 66609d3f3e
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1580284

MUST ONLY BE SUBMITTED BY AUTOMERGER

Change-Id: I19117620a162ecf6a3c14118cebf3413ffbe667b
2021-02-09 07:06:44 +00:00
Maciej Żenczykowski
79079db8af Merge changes I3fcd7eb8,I4bf2c762 am: d46b3d8ef8 am: 0681ae3e9a
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1575050

MUST ONLY BE SUBMITTED BY AUTOMERGER

Change-Id: I187698dad1d3bf8641e7b9987be3e6e4aeba55b5
2021-02-09 04:25:48 +00:00
Lorenzo Colitti
72ec3ba88a Improve BPF tethering counters.
Test: m
Change-Id: I53961e1e16bf90d76f16b9416c55b65e8374373d
2021-02-09 03:36:40 +00:00