Commit Graph

1427 Commits

Author SHA1 Message Date
Treehugger Robot
137e40cc1d Merge "Set updateable:false explicitly in apex rules." am: c72a6cae30 am: 89cd911569 am: d201e37561
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1590053

MUST ONLY BE SUBMITTED BY AUTOMERGER

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

MUST ONLY BE SUBMITTED BY AUTOMERGER

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

MUST ONLY BE SUBMITTED BY AUTOMERGER

Change-Id: Id5d6f075b4453556e62df9cf510af0e4022b7f8e
2021-02-18 10:28:49 +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
6895171a2a Merge "ebpf offload - do L4 header present check earlier" am: 2c0edb112f am: 9b833afa0a am: 63a3a118b9
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1591367

MUST ONLY BE SUBMITTED BY AUTOMERGER

Change-Id: Id2265f3af2e6c96a88c70c19a1342071a7cdca08
2021-02-18 08:32:31 +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
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
Maciej Żenczykowski
717ad84e6a offload ebpf - introduce 4.14+ ipv4 forwarding programs am: 36867351ec am: f335d68cb8 am: 6224c0e30e
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1588019

MUST ONLY BE SUBMITTED BY AUTOMERGER

Change-Id: I03fe8635ca089f7fab9ddca890599169d38b1441
2021-02-16 08:52:38 +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
3a03e10b4a Merge "offload ebpf - do_forward4() - introduce updatetime argument" am: d74918c6d2 am: 623479f329 am: be444669e3
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1588018

MUST ONLY BE SUBMITTED BY AUTOMERGER

Change-Id: I5d48503b3c2367271448c928cd0ba357db5e2f6b
2021-02-16 02:24:27 +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
914da3d1ba tethering offload ebpf - lower requirement from 5.9 to 5.8 am: b0ac41f0cd am: c456856971 am: 5d6f744551
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1588017

MUST ONLY BE SUBMITTED BY AUTOMERGER

Change-Id: I24f542f0096677320f1b0f30a55a884a2fa1e5fc
2021-02-15 12:36:33 +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
Lorenzo Colitti
c785e87cb5 Merge "Load JNI in all classes that have native methods." am: af97e51c01 am: ceafffa6c0 am: 531fa9e0cc
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1581528

MUST ONLY BE SUBMITTED BY AUTOMERGER

Change-Id: I140bce0fdff60614b246c67ffdcb724389532612
2021-02-12 06:14:22 +00:00
Treehugger Robot
0f8b31c929 Merge "fix TetheringCoverageTests" am: 6fc8229f16 am: 31ce8ad94d am: 55e1cc23c6
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1584755

MUST ONLY BE SUBMITTED BY AUTOMERGER

Change-Id: Ic8d683a42f73acfad318119e34e2e28fa87127ce
2021-02-12 06:14:17 +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
cdde4d0c32 Add IPv4 counters. am: d561b7f67c am: d2956a1964 am: 17b18ca6c2
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1580287

MUST ONLY BE SUBMITTED BY AUTOMERGER

Change-Id: I56217d9b73e22372e8bdf61e96fa99593b324c24
2021-02-10 07:45:58 +00: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
d8f76bb096 Dump counters in "dumpsys tethering bpf". am: 4e92da06fa am: e033a1e543 am: 7081e9f184
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1575051

MUST ONLY BE SUBMITTED BY AUTOMERGER

Change-Id: I7d74c663b554f5f6f1562d4e6dc2a13f67adb9c0
2021-02-10 06:19:33 +00: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
6281d65f61 Don't leak map fds in BpfCoordinator#dump. am: 555472a186 am: a6c9626b5d am: a47891732f
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1581523

MUST ONLY BE SUBMITTED BY AUTOMERGER

Change-Id: I7f92f0c2768775ab51018ec76feef9cab6e273c4
2021-02-09 23:43:52 +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
c0cdf4c0dc Merge "offload - finish ipv4 tethering" am: 4431655a4d am: 76a663683c am: 29f8e3550b
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1562765

MUST ONLY BE SUBMITTED BY AUTOMERGER

Change-Id: I93b9040903b96f79144cb591677fed22fa9edafc
2021-02-09 13:54:08 +00: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
e2cecc4349 Improve BPF tethering counters. am: 72ec3ba88a am: 66609d3f3e am: b9b629f273
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1580284

MUST ONLY BE SUBMITTED BY AUTOMERGER

Change-Id: Ic04ac7bf95106f5f1b02ae360f4b90da68fe7e5a
2021-02-09 07:50:47 +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
3e6764900e Merge changes I3fcd7eb8,I4bf2c762 am: d46b3d8ef8 am: 0681ae3e9a am: 79079db8af
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1575050

MUST ONLY BE SUBMITTED BY AUTOMERGER

Change-Id: I3b105b58eb6d19f6d6b2f2120530ecd16df6a259
2021-02-09 05:02:26 +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
Maciej Żenczykowski
d46b3d8ef8 Merge changes I3fcd7eb8,I4bf2c762
* changes:
  Add error counters for various failures.
  Add a bpf_tethering_headers lib used by the programs and JNI.
2021-02-09 02:57:24 +00:00
Lorenzo Colitti
b81584dbe5 Add error counters for various failures.
Currently, debugging the tethering programs is not easy because
in case of any failure they simply return TC_ACT_OK. This CL adds
a number of counters that the program can increment in the case
of interesting events such as malformed packets.

At the moment the counters are stored in a global tethering error
map, which is an ARRAY map of 32-bit counters. This should not
take up much space because there are only a dozen of these.

We might not need all of these counters. In future CLs we can
reduce the number of counters, or perhaps move them to a map of
maps so as to have separate counters on a per-interface basis.

Test: manual
Change-Id: I3fcd7eb8d318700092949ff2f39987bf4ba3656c
2021-02-09 02:56:52 +00:00
Lorenzo Colitti
734b14e07d Add a bpf_tethering_headers lib used by the programs and JNI.
This provides a place to store common definitions that can be
used by both the programs and by JNI code in the tethering
module.

Over time much of the tethering-specific code in bpf_shared.h
could move here.

Test: m
Bug: 177884581
Change-Id: I4bf2c762d61cd5db003d59880e6bf7d107ff1a07
2021-02-09 01:54:52 +00:00
Martin Stjernholm
423a270abb Revert "Don't crash Tethering service when WiFi feature is missing" am: 199641d451 am: b329062b20 am: b9e5c3b247
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1575305

MUST ONLY BE SUBMITTED BY AUTOMERGER

Change-Id: I786ef0fee68b2e4310b45b63cd54286f8a168a3f
2021-02-05 15:50:01 +00:00