Lorenzo Colitti
d561b7f67c
Add IPv4 counters.
...
Test: dumpsys tethering bpf
Change-Id: Ie21fee8ad12430ecd21c3903587d25b8dd2a96c4
2021-02-10 04:44:35 +00:00
Lorenzo Colitti
4431655a4d
Merge "offload - finish ipv4 tethering"
2021-02-09 11:08:06 +00:00
Lorenzo Colitti
72ec3ba88a
Improve BPF tethering counters.
...
Test: m
Change-Id: I53961e1e16bf90d76f16b9416c55b65e8374373d
2021-02-09 03:36:40 +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
Maciej Żenczykowski
ec5f67d97e
offload - finish ipv4 tethering
...
Test: atest, TreeHugger
Signed-off-by: Maciej Żenczykowski <maze@google.com >
Change-Id: I88f14938c7c4f66190a3afa2acd9104284e27927
2021-01-27 17:54:07 -08:00
Maciej Żenczykowski
7dfbcf58d2
merge Tether{Down,Up}stream6Value -> Tether6Value
...
Test: atest TetheringTests TetheringCoverageTests
Signed-off-by: Maciej Żenczykowski <maze@google.com >
Change-Id: Ibdbba9ef6652dd11bb18eba316045dff440fcf9e
2021-01-27 06:41:59 +00:00
Maciej Żenczykowski
1feb8b4ac8
merge Tether{Down,Up}stream4{Key,Value} - part 1 - C portion
...
The keys are identical, and the values nearly so, this will make everyone's life easier.
Test: git grep 'Tether(Down|Up)stream4(Key|Value)' finds nothing
(note this requires follow up commits)
Signed-off-by: Maciej Żenczykowski <maze@google.com >
Change-Id: Ifbff2c617ac5834ea80f827eaf89ca81e862baec
2021-01-25 20:31:11 -08:00
Maciej Żenczykowski
c2b0146045
offload - begin ipv4 tethering implementation
...
Test: atest, TreeHugger
Signed-off-by: Maciej Żenczykowski <maze@google.com >
Change-Id: I0ad143be954d55d0ed39853031c7bd364378e1ec
2021-01-25 19:07:40 +00:00
Maciej Żenczykowski
18552e8fb3
offload - ignore ethernet packets not destined for us
...
Test: atest, TreeHugger
Signed-off-by: Maciej Żenczykowski <maze@google.com >
Change-Id: Icabd1db48a1189425a941384d534c0f18bf20827
2021-01-24 19:59:21 -08:00
Maciej Żenczykowski
bf8ec1a21d
rename do_forward to do_forward6
...
Test: atest, TreeHugger
Signed-off-by: Maciej Żenczykowski <maze@google.com >
Change-Id: I649dc490b1883a1e97f748370a77c956f1315e2e
2021-01-24 19:59:16 -08:00
Maciej Żenczykowski
fc4f6540be
bpf tether offload - do not offload TCP SYN/FIN/RST packets
...
We want connection establishment/shutdown to flow through
the kernel code path so connection tracking state is at least
somewhat correct.
Test: atest, TreeHugger
Signed-off-by: Maciej Żenczykowski <maze@google.com >
Change-Id: Iee97baa65750188f3436937b16c9b320f0495a5a
2021-01-23 07:11:07 +00:00
Maciej Żenczykowski
b199742d73
add placeholder ebpf programs for XDP tethering
...
Test: atest, TreeHugger, the programs load
Signed-off-by: Maciej Żenczykowski <maze@google.com >
Change-Id: Idcacf0502719336c1b6a959fe6b782f2bce9d6b5
2021-01-21 05:12:35 +00:00
Maciej Żenczykowski
088fe1983b
add placeholder ipv4 ebpf tethering offload programs
...
Additionally better document tether stats/limit keys/value.
Test: atest, TreeHugger, the programs load
Signed-off-by: Maciej Żenczykowski <maze@google.com >
Change-Id: I1e1832fc4f5a6704e00ea99ca377988c52a82eb1
2021-01-21 05:12:21 +00:00
Maciej Żenczykowski
5b00fbd618
switch bpf programs to group network_stack
...
Test: atest, TreeHugger, the programs load
Signed-off-by: Maciej Żenczykowski <maze@google.com >
Change-Id: I3ab4383978acb2681a0fd5aee2700d12c62c2769
2021-01-20 18:09:32 +00:00
Maciej Żenczykowski
bca0c85822
Add tethering programs for upstream.
...
Test: atest, TreeHugger, the programs load
Signed-off-by: Maciej Żenczykowski <maze@google.com >
Change-Id: I26bc60c1066ed7317bda48ec3fa701c36e0b46dd
2021-01-20 18:05:52 +00:00
Maciej Żenczykowski
770e0a7a8f
refactor: TetherIngress becomes TetherDownstream6 (and friends)
...
Generated via:
#!/bin/bash
do_replace() {
pushd "$1" >/dev/null
shift
git grep "$1" | cut -d: -f1 | sort -u | while read f; do
sed -i -r "s@$1@$2@g" "${f}"
git add "${f}"
done
popd >/dev/null
}
replace() {
do_replace packages/modules/Connectivity/Tethering "$@"
do_replace system/netd "$@"
}
do_reset() {
pushd "$1" >/dev/null
git rhh
popd >/dev/null
}
main() {
do_reset packages/modules/Connectivity/Tethering
do_reset system/netd
replace TetherIngressKey TetherDownstream6Key
replace TetherIngressValue TetherDownstream6Value
pushd packages/modules/Connectivity/Tethering/src/com/android/networkstack/tethering >/dev/null
git mv TetherIngressKey.java TetherDownstream6Key.java
git mv TetherIngressValue.java TetherDownstream6Value.java
popd >/dev/null
replace TETHER_INGRESS_PROG TETHER_DOWNSTREAM6_TC_PROG
replace ingress_tether tether_downstream6
replace ingress/tether_ tether_downstream6_
replace TETHER_INGRESS_MAP TETHER_DOWNSTREAM6_MAP
replace tether_ingress_map tether_downstream6_map
replace getTetherIngressMapFd getTetherDownstream6MapFd
replace getTetherIngressProgFd getTetherDownstream6TcProgFd
replace mBpfIngressMap mBpfDownstream6Map
replace bpfIngressMap bpfDownstream6Map
replace printIngressMap printDownstream6Map
replace 'BPF ingress map' 'BPF downstream ipv6 map'
}
main "$@"; exit
Followed by:
cd system/netd
# change regexp in tests/binder_test.cpp:3374
git add tests/binder_test.cpp
(and whitespace adjustments to prevent lines from going over 100 characters)
Afterwards we have:
$ adbz shell ls /sys/fs/bpf/tethering
map_offload_tether_downstream6_map
map_offload_tether_limit_map
map_offload_tether_stats_map
map_test_tether_downstream6_map
prog_offload_schedcls_tether_downstream6_ether
prog_offload_schedcls_tether_downstream6_rawip
prog_test_xdp_drop_ipv4_udp_ether
Test: atest, TreeHugger
Signed-off-by: Maciej Żenczykowski <maze@google.com >
Change-Id: Ib04dc0c6e3d034461f3f84e09f6fa93a862e1bb2
2021-01-19 23:18:46 -08:00
Treehugger Robot
d4bcf54678
Merge "add a test xdp program that drops all IPv4/UDP packets"
2021-01-20 06:42:51 +00:00
Maciej Żenczykowski
8c7cd343a4
add a test xdp program that drops all IPv4/UDP packets
...
Test: builds, boots, program present
Signed-off-by: Maciej Żenczykowski <maze@google.com >
Change-Id: Id5be48ec172366296929875856a3d17ecc87e84b
2021-01-20 05:20:05 +00:00
Maciej Żenczykowski
6b7829f2c1
switch from SEC() to DEFINE_BPF_PROG()
...
I keep on failing to find this using grep because it
doesn't match how all the other programs are defined,
so change it for consistency.
Test: builds, atest, TreeHugger
Signed-off-by: Maciej Żenczykowski<maze@google.com >
Change-Id: Ib61b375bef84d2b489080866b2411c84880e4ef2
2021-01-20 05:18:50 +00:00
Maciej Żenczykowski
e9810ffef1
move bpf test map into a separate file
...
This allows for better separation of test vs production code:
we will add more test maps and programs here later.
Test: builds
Signed-off-by: Maciej Żenczykowski <maze@google.com >
Change-Id: I7b22e3e148ebf43fdf43dc68d0dea354f7627688
2021-01-18 18:36:00 -08:00
markchien
7052688dde
Provide a easy way to access bpf maps from java
...
A wrapper for bpf map opening, reading/writing, and iteration.
Bug: 173167302
Test: atest BpfMapTest
Change-Id: I792b41978b322c9e4969cd7b6c35d6978ab86bc4
2021-01-11 17:43:27 +08:00
Hungming Chen
56c632caed
Move BPF offload program from netd to mainline
...
Test: as the follows.
$ adb shell ls sys/fs/bpf | grep offload
map_offload_tether_ingress_map
map_offload_tether_limit_map
map_offload_tether_stats_map
prog_offload_schedcls_ingress_tether_ether
prog_offload_schedcls_ingress_tether_rawip
$ adb shell dumpsys netd --short
TetherController
BPF ingress map: iif(iface) v6addr -> oif(iface) srcmac ..
13(rmnet_data3) 2401:e180:8842:6e3:bc6a:2e45:c30:f418 -> ..
BPF stats (downlink): iif(iface) -> packets bytes errors
13(rmnet_data3) -> 7 488 0
BPF limit: iif(iface) -> bytes
13(rmnet_data3) -> 9223372036854775807
Log:
bpfloader: Loaded object: /apex/com.android.tethering/etc/bpf/offload.o
Change-Id: I71b7efb1f4bd6eb1cd469a0e1e4a56342dc6e579
2020-09-16 20:38:14 +08:00