summaryrefslogtreecommitdiff
path: root/server/TetherController.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Refactor stoping process to one util APIWeiZhang2021-12-081-2/+1
| | | | | | | | Try SIGTERM with timeout first. If failure, use SIGKILL Use the stoping process API for clatd, dnsmasq, iptables-restore Change-Id: I299c2023d2661ffc6c9d7eacf1650cb233ed22e3
* use str.empty() to check for empty string instead of !str[0]Maciej Żenczykowski2021-11-181-1/+1
| | | | | | | | | | !str[0] is technically speaking reaching past the end of the 0-byte empty string, though there should normally be an extra 0 byte added to facilitate .c_str() Bug: 206703697 Test: TreeHugger, atest netd_unit_test Signed-off-by: Maciej Żenczykowski <maze@google.com> Change-Id: I88ddae1b00ff020bd833d057468f729fb530216d
* rename OffloadUtils to TcUtilsPatrick Rohr2021-10-151-1/+1
| | | | | Test: m Change-Id: I40082f7d56f4d3ba088ebcab9417b4d2da0d6ba2
* Add debug trace for netd stuck issueKen Chen2021-04-021-0/+2
| | | | | | | | | | Somehow netd may stuck during initialization. We don't have enough information to know which step it is stuck. Add traces to narrow down scope. Test: adb logcat | grep netd Bug: 183677095 Change-Id: Ib7bba4301e238c8cc3f6e8ea11bdcbe86f68f4e4
* TetherController - remove initMaps() and bpf mapsMaciej Żenczykowski2021-03-161-18/+0
| | | | | | | | | Finally remove the actual map variables themselves, since they are no longer used. Test: atest, TreeHugger Signed-off-by: Maciej Żenczykowski <maze@google.com> Change-Id: I8063af311d3acd33a754f2f388f35830f77b4a2c
* TetherController - remove setBpfLimit()Maciej Żenczykowski2021-03-161-43/+0
| | | | | | | | | This function is unused. True implementation is in the Tethering mainline module. Test: atest, TreeHugger Signed-off-by: Maciej Żenczykowski <maze@google.com> Change-Id: I53a4ba79890ce4cf3a4be6eb63ef844263bc96b1
* remove dead code compiler warns aboutMaciej Żenczykowski2021-03-161-24/+0
| | | | | | Test: atest, TreeHugger Signed-off-by: Maciej Żenczykowski <maze@google.com> Change-Id: I3374bfad70d2c492c05da6660a4aafdf05776362
* TetherController - remove a bunch of no longer used RPC support codeMaciej Żenczykowski2021-03-161-155/+0
| | | | | | | | | | | | This is now dead code - it is reimplemented in Java in the tethering mainline module. Test: git grep 'getTetherOffloadStats|getAndClearTetherOffloadStats|setTetherOffloadInterfaceQuota|addOffloadRule|removeOffloadRule|validateOffloadRule' finds nothing Test: atest, TreeHugger Signed-off-by: Maciej Żenczykowski <maze@google.com> Change-Id: Ic874726f8a99dd686f81bf7b536cd4840e7f7665
* TetherController - remove bpf dump codeMaciej Żenczykowski2021-03-161-102/+0
| | | | | | | | | There's bpf map dumping code in the Tethering mainline module. Additionally we don't want netd to have access to the tethering maps. Test: atest, TreeHugger Signed-off-by: Maciej Żenczykowski <maze@google.com> Change-Id: Ia6abe3cadcbb32a1a94cbeef26ed8957e09e60ab
* TetherController - remove bpf map clearsMaciej Żenczykowski2021-03-161-24/+6
| | | | | | | | | This action was recently moved into the Tethering mainline module. As such doing it again here is spurious. Test: atest, TreeHugger Signed-off-by: Maciej Żenczykowski <maze@google.com> Change-Id: I09c3206c06d49a91775a1b5deb72240046f21ee2
* TetherController - remove unused mBpfDownstream64MapMaciej Żenczykowski2021-03-161-6/+1
| | | | | | | | | We don't yet have any users of this (even the bpf programs don't yet use it). Either way it should be handled by the tethering mainline module. Test: atest, TreeHugger Signed-off-by: Maciej Żenczykowski <maze@google.com> Change-Id: Icef831e18acdf024251d992037b0d33b20c5c8ab
* TetherController: Remove the BPF program attachment stubsHungming Chen2021-03-111-68/+1
| | | | | | | | The BPF program attaching and detaching have moved to tethering module. Remove the stubs in netd. Test: atest netd_integration_test Change-Id: Iec05d41c8932c639eb2c694532b5a6a19d44cf76
* merge Tether{Up,Down}stream6Value -> Tether6ValueMaciej Żenczykowski2021-01-271-6/+5
| | | | | | Test: atest, TreeHugger Signed-off-by: Maciej Żenczykowski <maze@google.com> Change-Id: Id7738586b6c57f2d14ec94d2eb03e1ac82a41338
* Revert "TetherController - populate TetherUpstream6Map"Lorenzo Colitti2021-01-271-71/+8
| | | | | | | | | | This code is moving to BpfCoordinator in this topic. This reverts commit 419b1d4ad74d100416163bdb4a3e37af89f3eb56. Test: manual testing of IPv6 upstream tethering Test: dumpsys tethercontroller shows upstream map non-empty Change-Id: Ia78bc4df11080df0605484dd7472f2c69a3a12d4
* TetherController - populate TetherUpstream6MapMaciej Żenczykowski2021-01-231-8/+71
| | | | | | Test: atest, TreeHugger, installed on bonito with v6 only wifi Signed-off-by: Maciej Żenczykowski <maze@google.com> Change-Id: If6602995371a1ca4c509d1ec44bc6450451f0c42
* add code to dump the content of the tether offload upstream6 mapMaciej Żenczykowski2021-01-221-4/+32
| | | | | | Test: atest, TreeHugger Signed-off-by: Maciej Żenczykowski <maze@google.com> Change-Id: I69c4d20952927ddae4131faadf3e2fb8410c0a21
* TetherController - add bpf map objectsMaciej Żenczykowski2021-01-211-0/+21
| | | | | | Test: atest, TreeHugger Signed-off-by: Maciej Żenczykowski <maze@google.com> Change-Id: I7e174e62356d61cc2a4c77cdbbb906a5bd6f3628
* use proper types for tether limit/stats bpf map keys/valuesMaciej Żenczykowski2021-01-211-6/+7
| | | | | | Test: atest, TreeHugger Signed-off-by: Maciej Żenczykowski <maze@google.com> Change-Id: I6161efa2a59fd27ddb84483482f21acf7fdd7f59
* attach upstream ipv4 and ipv6 tether offload tc ebpf programsMaciej Żenczykowski2021-01-211-16/+19
| | | | | | Test: atest, TreeHugger Signed-off-by: Maciej Żenczykowski <maze@google.com> Change-Id: If3eb91ca9c241dbc43dcb4e1741fd2a55b4d3016
* attach downstream ipv4 tether offload tc ebpf programMaciej Żenczykowski2021-01-211-14/+31
| | | | | | Test: atest, TreeHugger Signed-off-by: Maciej Żenczykowski <maze@google.com> Change-Id: I0098dbb9e6cbe919d0e117155a175b5b2e506aff
* add functions to attach/detach tc ipv4 tether offload programsMaciej Żenczykowski2021-01-211-4/+4
| | | | | | Test: atest, TreeHugger Signed-off-by: Maciej Żenczykowski <maze@google.com> Change-Id: I0e77dbe8e8d195bb61de2500b51aeb7f1826067c
* OffloadUtils - tcFilterAddDevBpf() - add support for Tether Upstream6Maciej Żenczykowski2021-01-211-2/+2
| | | | | | Test: atest, TreeHugger Signed-off-by: Maciej Żenczykowski <maze@google.com> Change-Id: I4f4be18f4ac8cc73a4689d1fa4f60a7b7e78dfaf
* refactor: TetherIngress becomes TetherDownstream6 (and friends)Maciej Żenczykowski2021-01-201-30/+36
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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 undoing incorrect text string change in server/ClatdController.cpp (and using the automatic linter to fix whitespace issues) 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: I6bcf5a7ba8703e49590f86e5326f63ee7e63bdc0
* bpf is always supportedMaciej Żenczykowski2021-01-191-6/+0
| | | | | | | Test: builds, atest, TreeHugger Bug: 167500195 Signed-off-by: Maciej Żenczykowski <maze@google.com> Change-Id: Ia1a45de523bb20d451df2041a9cc3fe9930f6686
* Merge "TetherController - print iface names in bpf info"Maciej Żenczykowski2020-06-111-8/+16
|\
| * TetherController - print iface names in bpf infoMaciej Żenczykowski2020-06-111-8/+16
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Test: adb shell dumpsys netd --short | sed -rn '/^ TetherController$/,/^ *Log:$/p' TetherController Forwarding requests: Tethering DNS: netId 100 servers [198.224.173.135, 198.224.174.135, 2001:4888:68:ff00:608:d::, 2001:4888:61:ff00:604:d::] dnsmasq PID: 4395 Interface pairs: rmnet_data2 -> rndis0 ACTIVE BPF ingress map: iif(iface) v6addr -> oif(iface) srcmac dstmac ethertype [pmtu] 12(rmnet_data2) 2600:1010:b009:76c8:b0fc:57ff:fe6e:8cc4 -> 33(rndis0) be:b2:04:f9:1a:98 b2:fc:57:6e:8c:c4 86dd [1500] BPF stats (downlink): iif(iface) -> packets bytes errors 12(rmnet_data2) -> 1 104 0 BPF limit: iif(iface) -> bytes 12(rmnet_data2) -> 9223372036854775807 Bug: 150736748 Signed-off-by: Maciej Żenczykowski <maze@google.com> Change-Id: I19148e4b079ac1fd2e8a5bf983bd9d8aa1dc4305
* | TetherController: Remove default data limit in tethering startHungming Chen2020-06-091-3/+0
|/ | | | | | | | | | Don't need anymore because the tethering control plane is moved to the tethering service and the data limit is applied since the first rule is added. The tethering service has the responsibility to set the rule and the data limit now. Test: manual, atest netd_integration_test:NetdBinderTest#TetherOffloadForwarding Change-Id: Ie2b8d57680025be903ebfb3d33e8ef1e2e819ddd
* Add binder call tetherOffloadGetAndClearStatsHungming Chen2020-06-051-0/+40
| | | | | | | | | Provide binder calls for getting tethering statistics and clear the stats for the given upstream. Bug: 150736748 Test: None Change-Id: I7bb635ee39d658961cd9515cc37e23bc3f0cd38f
* Add binder call tetherOffloadSetInterfaceQuotaHungming Chen2020-06-051-0/+25
| | | | | | | | | Provide binder calls for setting the limit for the given upstream interface. Bug: 150736748 Test: atest Change-Id: I5def133022ee0ae232972c9ccffccd041b4b47a6
* Merge changes from topic "tether_offload_data_limit"Nucca Chen2020-06-011-29/+13
|\ | | | | | | | | | | * changes: Add com.android.tethering to be netd_aidl_interface's apex user Add binder call tetherOffloadGetStats
| * Add binder call tetherOffloadGetStatsHungming Chen2020-05-291-29/+13
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This binder call is separated from the existing call tetherGetStats and used for for BPF tether stats. Note that the default value of ifIndex of TetherStatsParcel.aidl is applied for backward compatibility because it is added from this commit. Make netd modules to use netd_aidl_interface-unstable-cpp. Both netd and libnetd_server use unstable aidl for new api tetherOffload* and modified parcel TetherStatsParcel. Generated with: m netd_aidl_interface-update-api Bug: 150736748 Test: atest Change-Id: Ie03834bc40992a4abdc8ef70150569982092b386
* | use/test pmtu from TetherOffloadRuleParcelMaciej Żenczykowski2020-06-011-1/+4
|/ | | | | | | Tested: atest Bug: 149816401 Signed-off-by: Maciej Żenczykowski <maze@google.com> Change-Id: Id8a91ed5c0176b41c079ede5533af90b8756de6b
* TetherIngressValue - add output path/route mtu fieldMaciej Żenczykowski2020-05-231-5/+6
| | | | | | | | | This doesn't actually change anything, since we initialize it with 1500 default just like we blindly assume it always is today. Tested: builds Signed-off-by: Maciej Żenczykowski <maze@google.com> Change-Id: Ie448a988c3a769be07f895621711fe4e59d4535c
* ebpf tethering - add a map to store data limit, part 3Maciej Żenczykowski2020-05-231-0/+46
| | | | | | | | | | | This actually starts enforcing the limit. Note: this requires netd to populate both stats & limit maps for offload to work. Bug: 150736748 Signed-off-by: Maciej Żenczykowski <maze@google.com> Change-Id: I13c21f455155480712fba9b1464b4392d5169a52
* ebpf tethering - add a map to store data limit, part 2Maciej Żenczykowski2020-05-101-1/+21
| | | | | | | | | This is higher level glue code, including dump support. Tested: builds Bug: 150736748 Signed-off-by: Maciej Żenczykowski <maze@google.com> Change-Id: I9777d38d319a0b9db265aa339b7e903c49b8a4df
* TetherController - use %u not %d for uint32_t formattingMaciej Żenczykowski2020-05-081-2/+2
| | | | | | | | | (not sure why this is not triggering a compiler warning of some kind) Tested: builds Bug: 150736748 Signed-off-by: Maciej Żenczykowski <maze@google.com> Change-Id: Icd20698fbc98dd8537921fe18d1a68f554095d9c
* TetherController - bpf offload should only be enabled once per upstreamMaciej Żenczykowski2020-04-071-7/+5
| | | | | | Bug: 153437886 Signed-off-by: Maciej Żenczykowski <maze@google.com> Change-Id: If8588c0ebc2893ccea89db3c68e9a08fbdec06fc
* Convert tethering offload IPCs from primitive args to a parcel.Lorenzo Colitti2020-04-061-25/+44
| | | | | | | | | | | | | | | | | Defining stable AIDL IPCs with primitive args is not future-proof because AIDL does not support method overloading, so any time a parameter is added a new method needs to be created. It's better to use parcelables for parameters instead, because parcelables can be extended in subsequent version. Define a TetherOffloadRuleParcel data structure to represent tethering offload rules, and switch the tethering offload IPCs to it before we freeze the INetd AIDL. Bug: 140541991 Test: atest netd_integration_test Change-Id: I6e84b14872d38a897eb6a10fd37d816ec7e6da64
* Merge "TetherController: A followup change refactors getTetherStats"Treehugger Robot2020-02-201-19/+28
|\
| * TetherController: A followup change refactors getTetherStatsHungming Chen2020-02-201-19/+28
| | | | | | | | | | Test: build, atest Change-Id: I2e72ae3e0c0d9e5fc8b52dc0d2f0c8f01e886789
* | TetherController - clear both ebpf tether offload maps on startupMaciej Żenczykowski2020-02-191-2/+4
|/ | | | | | | | | | This clears out any stale state from a potential previous run. (also fix a bug... get...MapFd() return -errno on error) Test: build, atest Signed-off-by: Maciej Żenczykowski <maze@google.com> Change-Id: I4a452280a3754ef05964630809efb8cca2bbb833
* TetherController: Process tether stats from bpf mapsHungming Chen2020-02-201-10/+44
| | | | | | | | Test: Manual test 1. Add two interface tether stats manually 2. Call getTetherStats() and check the content Change-Id: I5bf7e57e67cf61829ef71fd7caccdb60d4c35213
* TetherController - print less errors on bpf unsupporting devicesMaciej Żenczykowski2020-02-191-0/+4
| | | | | | Test: build, atest Signed-off-by: Maciej Żenczykowski <maze@google.com> Change-Id: I0b0bfeadb4a8596ea575c103937af83d5ff26027
* Add binder IPCs to add and remove downstream IPv6 tethering rulesLorenzo Colitti2020-02-181-0/+127
| | | | | Test: None Change-Id: Idcb6b9c80de499fafb29e4e8b9202d7b7386340c
* TetherController: attach/detach tether bpf program to upstream interfaceHungming Chen2020-02-181-0/+49
| | | | | | | | | | | | | | | | | | | | Test: build, atest Manual test steps: 1. Connect to FarEastone mobile 2. Enable WiFi hotspot 3. Get the upstream interface via logcat I netd : ipfwdAddInterfaceForward("wlan1", "rmnet_data1") 4. Check the tether BPF program attaching on upstream interface $ adb shell tc filter show dev rmnet_data1 ingress filter protocol ipv6 pref 1 bpf filter protocol ipv6 pref 1 bpf handle 0x1 prog_offload_schedcls_ingress_tether_rawip:[*fsobj] direct-action 5. Disable WiFi hotspot 6. Check the tether BPF program detaching on upstream interface by logcat Change-Id: I2acca0220a660fbaa235f8863237d526828c2af8
* Add a dump method to TetherControllerLorenzo Colitti2020-02-171-0/+32
| | | | | Test: manual Change-Id: I56834d4dd8afa49460e4e02e084b4f268a51d3fe
* Support enable/disable dns forwarding of dnsmasqLuke Huang2019-08-201-8/+26
| | | | | | | | Bugs: 128782815 Test: built, flashed, booted cd systen/netd && atest Change-Id: Id72341885d828e30296f20590c64ff614df63cee
* TetherController - fix missing calls to posix_*_destroy() on error pathsMaciej Żenczykowski2019-05-111-22/+17
| | | | | | | | | | | | | | This fixes a couple cases were errors can result in a missing calls to: posix_spawnattr_destroy(&attr); posix_spawn_file_actions_destroy(&fa); which potentially results in a memory leak. It's hard to accomplish this with helper functions, because if init fails, you shouldn't call destroy, but if adddup2/setflags fails you need to... Test: atest clatd_test libbpf_android_test libnetdbpf_test netd_integration_test netd_unit_test netdutils_test resolv_integration_test resolv_unit_test Signed-off-by: Maciej Żenczykowski <maze@google.com> Change-Id: If6e5d778e16e2ab69cd5f7d75824f320e1b0888c
* Move ResponseCode to libnetdutilsMike Yu2019-04-021-3/+2
| | | | | | | | | | | ResponseCode is necessary for libnetd_resolv, move it to libnetdutils to ease the cleanup of the include path system/netd/server for libnetd_resolv. Bug: 128662167 Test: system/netd/tests/runtests.sh passed Change-Id: Iae22cc6b4c642a190294fa4ce0ae406434e7ac3d
* Remove wrong and unnecessary check for setDnsForwardersLuke Huang2019-03-301-9/+1
| | | | | | | | | | | inet_pton could not parse link local address with zone id. Additionally, setDnsForwarders has already used getaddrinfo for address parsing. Bug: 129474773 Test: built, flashed, booted system/netd/tests/runtests.sh passes Change-Id: Iea8ccd234e81ff6ddd863d920033559d436bf0d0