summaryrefslogtreecommitdiff
path: root/server/TetherController.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* refine test TestIpfwdEnableDisableStatusForwarding and some minor changes on ↵Luke Huang2019-03-151-2/+2
| | | | | | | | | | | | | | | test 1. fix flaky test for TestIpfwdEnableDisableStatusForwarding 2. fix time unit error in binder_test, set retry default interval as 50ms 3. refine naming in binder_test Bug: 128533612 Test: built, flashed, booted system/netd/tests/runtests.sh pass Change-Id: Ia03d0c30b49cdd233b627cce8bd2f3f05548798e
* TetherController: Fix a memory and fd leakGeorge Burgess IV2019-03-061-11/+10
| | | | | | | | | | | | | | | | | Error paths (e.g. the one for setPosixSpawnAttrFlags/etc.) didn't attempt to `free(args)`. Swapping to a vector neatly handles all of this for us. Caught by the static analyzer: system/netd/server/TetherController.cpp:271:9: warning: Potential leak of memory pointed to by 'args' [clang-analyzer-unix.Malloc] Also caught by reviewers: we appear to leak a few FDs here in error paths. This cleans those up, too. Bug: None Test: Ran the analyzer again. TreeHugger for functionality. Change-Id: Ie53b3cdf4745aafa6f1e1284ccb7433ff345838e
* Use posix_spawn instead of vforkLuke Huang2019-02-261-21/+37
| | | | | | | | | | | Also correct usage of posix_spawn Bug: 126128460 Test: built, flashed, booted system/netd/tests/runtests.sh pass manual test with remove dnsmasq, netd works fine Change-Id: Id48c7bf9c02ea27d3a4602efa3913785c0d5c87f
* Fix flaky netd_integration_test in CuttlefishLuke Huang2019-02-201-58/+65
| | | | | | | | | | | | | | | | Use vfork/posix_spawn instead of fork. Fix test items: netd_integration_test TetherStartStopStatus ClatdStartStop Bug: 124363517 Test: built, flashed, booted system/netd/tests/runtests.sh pass manual test with remove dnsmasq/clatd, netd works fine Change-Id: I43880bd8693112fab46a0931457ff468ae01b305
* Enable more clang-tidy checks and treat them as errorsBernie Innocenti2019-02-011-1/+0
| | | | | Test: tests/runtests.sh Change-Id: If59480cee6460847f5c1cef17e3ef036b8e75651
* Remove sscanf() in TetherController.waynema2019-01-151-46/+54
| | | | | Test: netd_unit_test, netd_integration_test, libnetd_resolv_test Change-Id: Ibff2d6cc5dbf4fb09fcd1862be1b71be3b1d9f8e
* Enable -Wsign-compare for netd and fix warningsBernie Innocenti2019-01-081-4/+3
| | | | | Test: atest netd_unit_test netd_integration_test resolv_integration_test Change-Id: I84347de8f3a3ec0dcc8979037b9c265d145a35f7
* Nat-related commands refineLuke Huang2018-11-191-15/+28
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | We need this to ensure that the tethering IPCs don't need to grab the lock in two different controllers The idea is that always having a global_alert rule in bw_global_alert chain. TetherController will enable/disable the reference of bw_global_alert chain. [childchain order of filter FORWARD chain] Chain FORWARD nm_mdmprxy_iface_pkt_fwder oem_fwd fw_FORWARD bw_FORWARD tetherctrl_FORWARD --Simple rule comparison-- [Before] Chain bw_FORWARD Alert rule ... other rules Chain tetherctrl_FORWARD ... other rules [After] Chain bw_FORWARD No Alert rule ... other rules Chain tetherctrl_FORWARD Jump to bw_global_alert ... other rules Chain bw_global_alert Alert rule The exact rule comparison is shown in the bug. Bug:119735985 Test: built, flashed, booted system/netd/tests/runtests.sh passes Change-Id: Ibf752d0c8de9170689fc74c89c0424d2642853ec
* Nat-related commands portingLuke Huang2018-11-191-11/+7
| | | | | | | Test: built, flashed, booted system/netd/tests/runtests.sh passes Change-Id: I14e80377bc1b7c08993c3cf8fbf2b6fd0f99f4ba
* Tether-related commands portingLuke Huang2018-09-261-11/+47
| | | | | | | Test: built, flashed, booted system/netd/tests/runtests.sh passes Change-Id: I5f0888f6e44d383bc52af01888d095e62a670d70
* Wrap InterfaceController into the android::net namespaceBernie Innocenti2018-09-121-3/+3
| | | | | | | No functionality changes, this is a cleanup. Test: m netd_unit_test Change-Id: I5c6667051b7b4b17171e6dcc6883f17db08eaa23
* netd: PPTP Helperhiroaki.yokoyama2018-08-271-11/+13
| | | | | | | | | | | | | | | | Enable the conntrack helper for PPTP connections when tethering is started. Bug: 112066349 Test: as follows - Boot device - Pass - Start tethering - Pass - Start PPTP on tethered host (USB) - Pass - make -j64 netd_unit_test adb shell /data/nativetest64/netd_unit_test/netd_unit_test - Pass Change-Id: I547f8b877661c137646b663429d29737678652bf
* Allow starting dnsmasq without DHCPRemi NGUYEN VAN2018-08-071-3/+3
| | | | | | | | | | | dnsmasq will not start DHCP if no --dhcp-range flag is set. Allow tethering start command to be called without DHCP ranges, so dnsmasq can be started without this flag. Bug: b/109584964 Test: manual: flashed a build with no --dhcp-range flag Change-Id: I109f64240690aef701deabd49120eab0aba0e8a8
* Merge "netd: Active FTP Helper"Treehugger Robot2018-08-011-0/+4
|\
| * netd: Active FTP HelperTyler Wear2018-06-141-0/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Enable conntrack helper for active FTP connections when tethering is started. Bug:69265432 CRs-fixed:2136660 Test: as follows - Boot device - Pass - Start tethering - Pass - Start active FTP on tethered host (USB) - Pass - Download file over FTP - Pass - make -j64 netd_unit_test adb shell /data/nativetest64/netd_unit_test/netd_unit_test - Pass Change-Id: I5c812afe9602e80ea1c42d0cafba40fe6019a995
* | Modernize codebase by replacing NULL with nullptrYi Kong2018-07-251-2/+2
| | | | | | | | | | | | | | | | Fixes -Wzero-as-null-pointer-constant warning. Test: m Bug: 68236239 Change-Id: I226a0599db4f7c3557e55cade7869d00bd314949
* | Add basic logging infrastructure for bugreportsErik Kline2018-07-101-4/+5
|/ | | | | | | | Test: as follows - built, flashed, booted - "adb shell dumpsys netd" shows logs - tests/runtests.sh passes Change-Id: I0e44da7f9a9cc53074ffc396b958e9e2dbcd2603
* netd: Enable clang-tidy and fix all warningsBernie Innocenti2018-06-071-21/+17
| | | | | | Bug: 65246407 Test: m netd && system/netd/tests/runtests.sh Change-Id: I1d22b2bc317fe7218ccde78859ed0623d6a1f8df
* Merge "Ensure icmp redirects are always ignored"Hugo Benichi2018-05-301-1/+9
|\
| * Ensure icmp redirects are always ignoredHugo Benichi2018-05-231-1/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | A side effect of disabling the ip forwarding sysconf on all interfaces is to re-enable the ICMP redirects sysconf on all interfaces. This patch ensures that ICMP redirects stays turned off when disabling ip forwarding in TetherController. Accepting ICMP redirects can allow an attacker to inject malicious routes into a host and it is therefore desirable to always reject them. Bug: 62387578 Bug: 77541904 Test: manual Change-Id: I1f9a950eebf2f65d047f33145feee40d3ab34bd9
* | Always push all state to dnsmasqErik Kline2018-05-221-11/+32
|/ | | | | | | | | | | Test: as follows - built, flashed, booted - manual use of tethering Bug: 31634369 Bug: 36988090 Bug: 64090733 Bug: 79956831 Change-Id: I27f572dab0e3ddbe4b7586363a0bd05a3e66403c
* Merge "Simplifying const/destructor in TetherController."Remi NGUYEN VAN2018-05-011-10/+0
|\
| * Simplifying const/destructor in TetherController.Remi NGUYEN VAN2018-03-291-10/+0
| | | | | | | | | | | | | | The current destructor is useless, and member initializers can be used. Test: netd_unit_test passing. Change-Id: I43d65ff5d4c5790e6322b769f111ec25fb97d767
* | Rename <cutils/log.h> to <log/log.h>Logan Chien2018-04-231-1/+1
|/ | | | | | Bug: 78370064 Test: lunch aosp_walleye-userdebug && cd system/netd && mma Change-Id: I495f7cdc3f2aab26947f10041fc559700367f2ea
* Support adding multiple tethering upstreams.Remi NGUYEN VAN2018-03-281-37/+108
| | | | | | | | | | | | | | | | | | | Currently, when the first tethering interface pair is added, we add MASQUERADE rules for the upstream and IPv6 counting rules. Continue to add IPv6 counting rules when the first interface pair is added, but change the code to add MASQUERADE rules every time a new upstream is added. This will allow us to support adding, say, v4-rmnet_data0 as an upstream once we're already using rmnet_data0 as an upstream. Bug: 38218697 Bug: 64382985 Bug: 64976379 Bug: 64995262 Bug: 64380515 Test: netd_unit_test passes, manual: IPv4 or 464xlat tethering works Change-Id: I84078b2241214b3b993ccaf2e590406018df00ff
* Run dnsmasq as dns_tether rather than nobodyErik Kline2018-02-221-22/+30
| | | | | | | | | | | | | AID_DNS_TETHER from android_filesystem_config.h is found and made "friendly" by fs_config_generator.py (strip off AID_ and lowercase). Test: as follows - built - flashed - booted Bug: 29881876 Bug: 70673901 Change-Id: I3335a40dcd8c276421a9d663b7e66aef3a13b46b
* Set nf_conntrack_tcp_be_liberal only when tethering is enabledErik Kline2017-10-231-0/+8
| | | | | | | | | | | | Test: as follows - built - flashed - booted - manually tested with tethering enabled - verified nf_conntrack_tcp_be_liberal == 0 when not tethering - verified nf_conntrack_tcp_be_liberal == 1 when tethering Bug: 67760792 Change-Id: I336439ba0760346c7c038d36d0ebdc8dc4f698f5
* Don't complain when finding no tether stats.Lorenzo Colitti2017-09-151-3/+1
| | | | | | | | | | | | | | | | | | | | | | TetherController::addForwardChainStats returns an error if it doesn't find any tethering stats. This was fine when we were still using CommandListener, which would not attempt to fetch the stats if tethering was not enabled. Instead of returning an error when no stats are found, return an error only if the output was empty (implying that no headers were found and thus the required rules do not exist). If the output contains headers but no stats, don't return an error. Returning an error was a necessity in the previous code because it had no unit or integration tests, but such measures are not necessary now that we have test coverage. Fix: 65550883 Bug: 65369386 Test: bullhead builds, boots Test: netd_{unit,integration}_test pass Change-Id: Ie32f4d941dd52c8dc9ff09fde26cc97cedf96bc3
* Swap TX and RX in addForwardChainStats for clarity.Lorenzo Colitti2017-09-051-4/+4
| | | | | | | | Bug: 32163131 Bug: 64995262 Test: netd_{unit,integration}_test pass Test: tethering data usage UI reflects actual data usage Change-Id: Icf5b66972d91e9e45e40d7b4989a15f970a78461
* Remove the gettetherstats command.Lorenzo Colitti2017-09-051-26/+4
| | | | | | | | Bug: 32163131 Bug: 64995262 Test: netd_{unit,integration}_test pass Test: tethering data usage UI reflects actual data usage Change-Id: I1722f64cf775e73d71df997f6bae4820133e67bf
* Add a binder RPC for tethering stats.Lorenzo Colitti2017-09-051-7/+22
| | | | | | | Bug: 32163131 Bug: 64995262 Test: netd_{unit,integration}_test pass Change-Id: I9c7dfdaf6b823840b1691761930b53c30a4dcbc3
* Rename natctrl_* iptables rules to tetherctrl_*Lorenzo Colitti2017-08-311-3/+3
| | | | | | | | Bug: 32163131 Bug: 64995262 Test: bullhead builds and boots Test: netd_{unit,integration}_test pass Change-Id: Ifd20920713b2b5b9c22f4c829ef037bbac024505
* Remove support for filtering tether stats.Lorenzo Colitti2017-08-311-79/+38
| | | | | | | | | | | | | | | | The framework does not use this filtering, so it's just dead code. It also requires that NatController publicly expose its list of interface pairs. Also make the parsing code a bit stricter - for example, return an error if any of the lines (except the headers) fail to parse. Bug: 32163131 Bug: 64995262 Test: bullhead builds and boots Test: netd_{unit,integration}_test pass Test: output of "adb shell ndc bandwidth gettetherstats" looks correct Change-Id: Ib7440f935809c59d8b48396764cc63eb95f509b4
* Move all tethering functionality into TetherController.Lorenzo Colitti2017-08-311-1/+413
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This includes the entirety of NatController and relevant parts of BandwidthController (specifically, getTetherStats and its dependencies). This will make the code easier to understand and allow netd to privide a simpler API to the framework (e.g., by providing higher-level methods that perform what today are multiple operations from the framework's point of view). It will also reduce duplication of state (e.g., interface pairs kept by NatController partially overlap with downstream interfaces kept by TetherController) and avoid dependencies between controllers. This CL makes no functional changes. The only code changes are the ones necessary for compilation. Specifically: - Move some methods into IptablesBaseTest.cpp so they can be used from two test classes. - Change TetherController::iptablesRestoreFunction to the three-argument used by the erstwhile BandwidthController tests. Where appropriate, variable names have been changed, but strings that actually appear on device, such as iptables rule names, are left as is and will be changed in a future CL. Bug: 32163131 Bug: 64995262 Test: bullhead builds, boots Test: netd_{unit,integration}_test pass Change-Id: Idc80bfd424ce011826305f84b1cc98e741698601
* Pass dnsmasq the socket mark to use for listen sockets.Lorenzo Colitti2017-05-091-2/+19
| | | | | | | | | | This allows us to configure dnsmasq to reply to DHCP requests and DNS queries when a VPN is up. Bug: 37778642 Test: bullhead builds and boots Test: succesfully tethered when a VPN was connected Change-Id: I7d5899f80fae856a52a2019550b155bccee2888a
* TetherController.cpp: add O_CLOEXECNick Kralevich2016-11-191-1/+1
| | | | | | | | | Don't leak open file descriptors across execs to netd's children. This can occur in the unlikely but theoretically possible event that one thread is in writeToFile() and another thread happens to call exec(). Test: device boots with no obvious problems. Change-Id: Iabd8eee46bf94d70894ca46e58484ccb8241513a
* Disable DAD for downstream interfaces when tetheringErik Kline2016-10-251-0/+4
| | | | | | | | Bug: 30298058 (cherry picked from commit 59d8c48cee74679d2305c535ab61d4a6f8258c64) Change-Id: I60929eecf4a890b9c23bf1ba1ba5273db3ccb493
* Setup interfaces for IPv6 tetheringErik Kline2016-10-251-45/+45
| | | | | | | | | | | | | | | | | Including: - set the interface for router mode (accept_ra = 0) - reset the interface for client mode (accept_ra = 1) - InterfaceController::setAcceptIPv6Ra() - InterfaceController::setAcceptIPv6Dad() - make InterfaceController static - refactor for more modern C++ usage here and there - sporadic style guide fixes Bug: 9580643 (cherry picked from commit 2c5aaa1876db659556c2e9605beccc670e6b7c0d) Change-Id: Ie5825ae3db19bbd8e03130d3bfd7815554214586
* Merge "Revert "Tell dnsmasq not to start wildcard sockets""Erik Kline2016-01-051-2/+1
|\
| * Revert "Tell dnsmasq not to start wildcard sockets"Erik Kline2016-01-051-2/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | This reverts commit f1dfabed0a9b6ee9c37b64db3bbcb656281d4771. The 3.4 kernel does not have SO_REUSEPORT functionality but the headers #define it, so dnsmasq tries to use it and setsockopt duly fails. This is not a problem on 3.10 and later kernels, but reverting anyway. Bug: 9580643 Bug: 26301652 Change-Id: I2322a80caa76ee4b7bb290f1665081b17d86fd43
* | Merge "Tell dnsmasq not to start wildcard sockets"Erik Kline2015-12-171-1/+2
|\|
| * Tell dnsmasq not to start wildcard socketsErik Kline2015-11-131-1/+2
| | | | | | | | | | Bug: 9580643 Change-Id: I8c95c15970d6ed72dc44cec42c4eb78e18ed46ba
* | Support scoped addresses as tethered DNS servers.Lorenzo Colitti2015-11-251-5/+7
|/ | | | | Bug: 9580643 Change-Id: Id086ff9194097fc1e0ab8e2e58e6ff843303f051
* Pass both IPv4 and IPv6 nameservers to dnsmasqErik Kline2015-11-131-3/+5
| | | | | | | | | | Additionally, store and return a list of strings for DNS forwarders, since that's what is most useful. These strings are guaranteed to be valid IP string literals by virtue of validation on input. Bug: 9580643 Change-Id: I4fbaf19835055b12e38d585c0bfba0d2b18b9717
* Change dnsmasq input command argument separatorErik Kline2015-11-131-10/+8
| | | | | | | | | | | | | | | | Heretofore netd issued commands to dnsmasq over a stdin channel using ":" as an argument separator. This make it very complicated to issue commands that involve IPv6 addresses. This changes the separator from ":" to "|". Additionally: - Pass DHCP range string literals through to startTethering(), still performing string literal to IPv4 address validation. Bug: 9580643 Change-Id: I210daf311a4c3d84dae3ed054b92c9fa399a791f
* Revert "Revert "Update for libbase.""Dan Albert2015-03-161-1/+0
| | | | | | | | This reverts commit 4a0ab5ff4a87cfc4a987da99546b01e44875a2e5. (cherry picked from commit 3e87c785434fdfed2fb00496cb391c411a426bdd) Change-Id: I042f485f3cc84206766298853491ddd26dbba13f
* Forgot this in merge resolution.Nicolas Geoffray2015-03-161-1/+14
| | | | Change-Id: Ieb26ec5fc333743b86d414ee558c978334647853
* resolved conflicts for merge of 6066d418 to masterNicolas Geoffray2015-03-161-4/+1
|\ | | | | | | Change-Id: I2aa9721365e96c363648dd8e9e15718ed50e3c12
| * Revert "Update for libbase."Nicolas Geoffray2015-03-161-6/+3
| | | | | | | | | | | | | | | | Breaks internal master. This reverts commit b67219a71d1d896bcb34c4a7a797824b88515b2c. Change-Id: I43145f0724ad2d669b65d20b6fd6ccc44b8f0a4f
* | Merge remote-tracking branch 'goog/mirror-m-wireless-internal-release'Vinit Deshpande2015-03-161-23/+45
|\ \ | |/ |/| | | Change-Id: I51337014e2851f47dd5e183c4bfdf39bafa59942