summaryrefslogtreecommitdiffstats
path: root/server/RouteController.cpp
Commit message (Collapse)AuthorAgeFilesLines
* rename OffloadUtils to TcUtilsPatrick Rohr2021-10-151-1/+1
| | | | | Test: m Change-Id: I40082f7d56f4d3ba088ebcab9417b4d2da0d6ba2
* Support subsidiary priority on UID rangesKen Chen2021-07-011-89/+114
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | Network preference per-profile and OEM network preferences can't be set at the same time, because it is unclear what should happen if both preferences are active for one given UID. Therefore, it needs a parameter for ConnectivityService to specify which preference is prior to others. In this commit: 1. Adds a pair of methods with parcelable parameter, which currently includes netId, UID range array and subsidiary priority. 2. The subsidiary priority will be used to adjust the original IP rule priority. UID ranges can applies to different network with different subsidiary priority. But a single UID should not apply to multiple networks with the same subsidiary priority. 3. The possible value of subsidiary priority for physical and unreachable networks is 0-999. 0 is the highest priority. 0 is also the default value. Virtual network supports only the default value. 4. Netd and its tests reference to latest AIDL version (unstable). Bug: 182460808 Test: m; flash; cd system/netd/; atest Test: atest FrameworksNetTests Test: atest HostsideVpnTests Change-Id: I94e8830d0a21ffcca17757fe4783a4be9438c8b4
* PANS - Support unreachable default networkKen Chen2021-03-261-0/+73
| | | | | | | | | | | | | | | | | | | | | | | | | | | Framework provides several preferences in PANS feature. To meet those preferences, Netd needs to support two operations for framework: (1) Set OEM-paid network as default network for apps. (2) Prohibit apps to use default network if it is not explicitly selected. The #1 is supported by previous commit already. This commit implements the #2, which adds a new IP rule priority for unconnected socket, reuses existing IP rule priorities in explicit and implicit network selection. Rules are looks like: 15000: from all fwmark 0x10034/0x1ffff iif lo uidrange x-y unreachable ... 22000: from all fwmark 0x34/0x1ffff iif lo uidrange x-y unreachable ... 27000: from all fwmark 0x0/0xffff iif lo uidrange x-y unreachable An UNREACHABLE network (netId 52) is created for framework to specify that the default network is unavailable for designated apps. Bug: 181579204 Test: atest Change-Id: I21530928a85870df673e2d1387fde130fe5a0104
* Unify similar functionsKen Chen2021-03-251-32/+14
| | | | | | | | | There are only slight differences between the implementations of modifyUidExplicitNetworkRule and modifyUidImplicitNetworkRule. Unity them into one function. No functionality changes. Test: atest netd_integration_test Change-Id: I552e870b32459ada24c84fb908fea188f47c510c
* Merge "Configurable per application default network"Maciej Żenczykowski2021-02-051-7/+113
|\
| * Configurable per application default networkKen Chen2021-02-021-7/+113
| | | | | | | | | | | | | | | | | | | | | | | | | | Extend networkAddUidRanges and networkRemoveUidRanges from virtual-network-only to physical network. With this change, the ConnectivityService can replace the default physical network for specified applications without changing applications' code. Bug: 176507580 Test: cd system/netd; atest Test: atest HostsideVpnTests Test: atest FrameworksNetTests Change-Id: I556043f4401746bcf844a0c15a7d92aec12faad3
* | bpf is always supportedMaciej Żenczykowski2021-01-191-2/+0
|/ | | | | | | Test: builds, atest, TreeHugger Bug: 167500195 Signed-off-by: Maciej Żenczykowski <maze@google.com> Change-Id: Ia1a45de523bb20d451df2041a9cc3fe9930f6686
* Move IP rule priorities to header fileKen Chen2021-01-121-17/+0
| | | | | | | Make constants visible for tests, rather than have copies. Test: atest Change-Id: Ibb70ae5c719e174ace4278d617564dfd48d1455d
* Add clsact filters to local_network interfaces as well.Lorenzo Colitti2021-01-061-1/+4
| | | | | | | | | | This is required for TC-BPF offload of upstream traffic. Bug: 176857251 Test: new tests in netd_integration_test Test: enabled wifi-to-wifi tethering Test: adb shell tc qdisc show 2>&1 | grep clsact Change-Id: I091d183682170d1ddf19ab9f04aa88413769de79
* Track local network ifindices in sInterfaceToTable as well.Lorenzo Colitti2020-04-261-4/+24
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | RouteController tracks in the sInterfaceToTable map the the interface indices of every interface used in physical and virtual networks. This ensures that when an interface is removed from a network (by passing in the interface name), the rules (which specify interface indices) are correctly deleted even if the interface has been deleted or has been deleted and re-added with a new interface index. Currently this does not happen for interfaces added to the local network. That means that when those interfaces are deleted, the rules might not be deleted. It also results in spurious messages logged by NetworkController such as: 03-24 00:38:47.553 16612 16635 E Netd : getIfIndex: cannot find interface testtap1 03-24 00:38:47.553 16612 16635 E Netd : inconceivable! added interface testtap1 with no index Note that since P this map is read by RouteController::getIfIndex and used by code that assumes this will always return an interface index. In the case of an interface in the local network, this is not possible because the map stores mappings between ifindex and routing table. In the case of the local network, the routing table is always ROUTE_TABLE_LOCAL_NETWORK, so there is no way to get the interface index. Fix these callers so they do not attempt do to this. Bug: 150644681 Test: TetheringIntegrationTests:EthernetTetheringTest Change-Id: I8042e5b91bcb3175d9ad540526df396a139976f0
* Move attaching and detaching clsact from ClatdController to RouteControllerHungming Chen2020-02-171-1/+38
| | | | | | | | | | | | | | | | | | | | | | | | | The clsact attaching and detaching control plane is moved to: RouteController::addInterfaceToPhysicalNetwork - add clsact RouteController::removeInterfaceFromPhysicalNetwork - del clsact The above change implies that the clsact lifetime for each interface has been extended from clat enabled time to interface lifetime. The only exception is that attaching clsact to v4- tun interface still lives in ClatdController. The reason is that clat is started before the v4- tun interface is added to the network and clat has already needed to add the bpf filters. After all, keep attaching and detaching clat {in, e}gress bpf filters in ClatdController. Test: manual clatd test 1. Connect to IPv6-Only WiFi hotspot 2. Browse 172.217.0.46 (google.com) successfully 3. Disconnect from WiFi Repeat the above steps three times. Change-Id: I971e105484c7678ac304788e5ffff7cc709c400d
* Tweak RTA_METRICS size calculation.Lorenzo Colitti2020-01-241-1/+2
| | | | | | | | | | Use the more correct RTA_SPACE macro instead of manually calculating the size, and the more appropriate size_t type instead of int. Bug: 142892223 Test: covered by existing unit tests Change-Id: I74dd5c912e2a13721e1bd6c90df4a579e826805f
* netd: Route MTUTyler Wear2020-01-231-24/+43
| | | | | | | | | | - Route may include optional MTU parameter - Change route is added so routes don't need to be deleted then re-added - Add/Del/Change functions to pass route info as parcel Bug: 142892223 Test: new unit tests Change-Id: Idc32ecb0520b1f4136b3fe0e3f7b6800fb3005a6
* [netd] fix -Wreorder-init-listNick Desaulniers2019-10-111-5/+5
| | | | | | | | | | C++20 will require members in a designated initializer to be in order unlike C99. Bug: 139945549 Test: mm Change-Id: I4b856942f5c323898cf572dc60622d62c6ffed94 Signed-off-by: Nick Desaulniers <ndesaulniers@google.com>
* Use C++17's [[nodiscard]] instead of WARN_UNUSED_RESULTBernie Innocenti2019-08-211-58/+53
| | | | | | | No functionality change. Also remove some header guards along the way. Test: m Change-Id: I1afdcaea95a3dd56f392c4e61d7670f43615792a
* Remove unused deps on liblogwrapBernie Innocenti2019-06-051-1/+0
| | | | | | | Nothing seems to be calling into it, so it can probably go. Test: rebuild everything, then run atest Change-Id: I6e446f98decd708f59e5994fa10f77be4476d02f
* Remove explicitlySelected bit for vpn fallthrough ruleLuke Huang2019-05-231-5/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Previously, netd use explicitlySelected bit to ensure that the VPN fallthrough rule does not match if a non-zero NetId was explicitly specified. This is inconsistent with the normal case of an application that is subject to the VPN, because in that case, the fallthrough rule does match. This commit removes the explicitlySelected bit and relax the guarantee. This ensure that the behaviour of an app that selects the VPN network is the same as the behaviour of an app that specifies no network but is subject to the VPN. VPN traffic will fallthrough default network if no route is hit in VPN route table. Assume vpn netId is 102, default network interface is wlan0 with no permisiion. Below is the result of route rule before/after this commit. Before: 21000: from all fwmark 0x10066/0x1ffff lookup wlan0 After: 21000: from all fwmark 0x66/0xffff lookup wlan0 Bug: 119216095 Test: built, flashed, booted system/netd/tests/runtests.sh Change-Id: I03411644dc82cabcaf1f3274a17f36ec4e173c2e
* netd: reorder the operations in getRouteTableForInterfaceLocked.mtk137992019-04-021-10/+18
| | | | | | | | | | | when network was switched quickly between wifi and cellular, netd should always use old ifindex to delete ip rule/route, and new ifindex to add ip rule/route. BUG: 128805131 Test: built, booted, datausage, Phone call, Internet under wifi and cellular data Change-Id: I2d88709a00d50e318b02362ffac543a1e7e40a81
* IPv6: allow the same prefix routing entries for link localJimmy Chen2019-03-081-0/+7
| | | | | | | | | | | | Allowing creating multiple link-local routes in the same table, so we can make IPv6 work on all interfaces in the local_network table. Bug: 126063997 Test: * enable hotspot & usb tethering * use ping6 to verify link local in both side of hotspot/usb tethering Change-Id: Ibe897004bd72bc88744c4bbac44ca512c0482f3b
* Refactor UidRange by using stable aidl structureLuke Huang2018-10-251-14/+13
| | | | | | | | | Use stable aidl generated structure instead of UidRange Test: built, flashed, booted system/netd/tests/runtests.sh passes Change-Id: I136afcff167eac7d3c4774b9e60f607e086488bf
* Move resolver public headers to separate include pathBernie Innocenti2018-10-181-2/+2
| | | | | | | | | | Additionally rename functions and structs to eliminate those ugly underscores from the public API (with the notable exception of __res_params, which will come in its own separate change to keep this one from growing too large). Test: build, flash, then 'atest netd_integration_test' Change-Id: I7e9b0ee6cdbec889e9c35b5a17b5daa65533686e
* Let lock_guard deduce its template argumentBernie Innocenti2018-08-101-4/+4
| | | | | | | | | | | | | | | No functional change, this is a cleanup. With C++17, it's no longer necessary to specify the teplate argument when it can be deduced from the types of constructor arguments. This allows de-cluttering our locking statements. To avoid typos, this patch was mechanically generated: perl -p -i -e 's/std::lock_guard<std::mutex>/std::lock_guard/g' \ $(find . -name '*.cpp' -o -name '*.h') Change-Id: Ibb15d9a6c5b1c861d81353e47d25474eb1d4c2df
* Modernize codebase by replacing NULL with nullptrYi Kong2018-07-251-8/+8
| | | | | | | | Fixes -Wzero-as-null-pointer-constant warning. Test: m Bug: 68236239 Change-Id: I226a0599db4f7c3557e55cade7869d00bd314949
* Refine lock of RouteController and add annotationsLuke Huang2018-07-111-5/+5
| | | | | | | Test: built, flashed, booted system/netd/tests/runtests.sh passes Change-Id: I855e044a2b7c9aae795edbcee717d61f58a7a21d
* Replace RW lock with mutex, shared_mutexLuke Huang2018-07-111-6/+6
| | | | | | Test: built, flashed, booted system/netd/tests/runtests.sh passes Change-Id: I42b52d815b6ba0ba6f93dc27e83a900d2abec715
* Do not destroy socket when VPN interface address is still in useRubin Xu2018-06-071-0/+12
| | | | | | | | | | | | | | | | | | | | Normally when an IP address is removed, all sockets associated with the addresses are destroyed. This patchset changes this behavior such that if the address in question is still being used by another interface that belongs to the same underlying virtual network, the destroy operation is skipped. This change is needed to support VPN seamless handover where the VPN app will establish a second TUN interface (with different config) before tearing down the existing interface. The intention is that during this handover existing socket connections should not be disturbed. There is a companion change in the framework side to make sure during such handover, the VPN netId remains unchanged so routing still works. Bug: 64692591 Test: cts-tradefed run commandAndExit cts-dev -m CtsHostsideNetworkTests -t com.android.cts.net.HostsideVpnTests Test: system/netd/tests/runtests.sh Change-Id: I02c6b0db5f15cd1aef3e3fa6f0c36e86b4f427fd Merged-In: I02c6b0db5f15cd1aef3e3fa6f0c36e86b4f427fd (cherry picked from commit acbb6b7bbea17c5653929ee5224bd4f8e16c0f69)
* Add "iif lo" to all IP rules for originated traffic.Lorenzo Colitti2018-03-151-6/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This ensures that these rules are not mistakenly used by forwarded traffic. Forwarded traffic should only use rules that specify an explicit iif. The rules change as follows: 0: from all lookup local 10000: from all fwmark 0xc0000/0xd0000 lookup legacy_system 10500: from all {+iif lo+} oif dummy0 uidrange 0-0 lookup dummy0 10500: from all {+iif lo+} oif wlan0 uidrange 0-0 lookup wlan0 10500: from all {+iif lo+} oif v4-wlan0 uidrange 0-0 lookup v4-wlan0 10500: from all {+iif lo+} oif rmnet_data0 uidrange 0-0 lookup rmnet_data0 13000: from all fwmark 0x10063/0x1ffff {+iif lo+} lookup local_network 13000: from all fwmark 0x10065/0x1ffff {+iif lo+} lookup wlan0 13000: from all fwmark 0x10065/0x1ffff {+iif lo+} lookup v4-wlan0 13000: from all fwmark 0x50064/0x5ffff {+iif lo+} lookup rmnet_data0 14000: from all {+iif lo+} oif dummy0 lookup dummy0 14000: from all {+iif lo+} oif wlan0 lookup wlan0 14000: from all {+iif lo+} oif v4-wlan0 lookup v4-wlan0 14000: from all fwmark 0x40000/0x40000 {+iif lo+} oif rmnet_data0 lookup rmnet_data0 15000: from all fwmark 0x0/0x10000 lookup legacy_system 16000: from all fwmark 0x0/0x10000 lookup legacy_network 17000: from all fwmark 0x0/0x10000 lookup local_network 19000: from all fwmark 0x65/0x1ffff {+iif lo+} lookup wlan0 19000: from all fwmark 0x65/0x1ffff {+iif lo+} lookup v4-wlan0 22000: from all fwmark 0x0/0xffff {+iif lo+} lookup v4-wlan0 22000: from all fwmark 0x0/0xffff {+iif lo+} lookup wlan0 32000: from all unreachable Bug: 64976379 Bug: 73642792 Bug: 73032258 Test: marlin builds, boots, networking works Test: IPv4/v6 USB tethering works concurrently with httpurl --nethandle <foo> Test: USB tethering correctly able to use non-default-network upstream Test: T-Mobile wifi calling works on walleye internal build Change-Id: I9383a7ea54c60b0f33db8de8c6331e2f820539e1
* Merge changes Icc35c917,I12899e03,Iff5a202cLorenzo Colitti2018-01-101-28/+44
|\ | | | | | | | | | | | | * changes: Tighten up locking in NetworkController. Add locking to RouteController. Change RouteController from free functions/members to class functions.
| * Add locking to RouteController.Lorenzo Colitti2017-11-241-3/+14
| | | | | | | | | | Test: netd_{unit,integration}_test passes Change-Id: I12899e0304d266b25b0b021ae28f9073c8b42604
| * Change RouteController from free functions/members to class functions.Lorenzo Colitti2017-11-241-27/+32
| | | | | | | | | | | | | | | | In a future change, this will make it more explicit which bits of state (e.g., locks) are part of the class and which are not. Test: netd_{unit,integration}_test passes Change-Id: Iff5a202cdcb26a7b6039dd95655cc2c26592fc36
* | [ipsec-qtaguid] Reserve mark, add ipsec bw exemptionsBenedict Wong2017-12-151-3/+5
| | | | | | | | | | | | | | | | | | | | | | | | This change reserves a mark denoting that a packet has already been accounted for, along with adding rules in BandwidthController to support IPSec packets being billed correctly. Bug: 62994731 Test: BandwidthControllerTest updated, passing. CTS tests also modified and passing Change-Id: I8b42975d1502a0d3b9e533bddc0892cfe1556bed
* | Don't create rules with NLM_F_EXCL.Lorenzo Colitti2017-11-301-3/+2
|/ | | | | | | | | | | | | | | | | | | | Some operations, such as changing a network's permissions, rely on make-before-break, and in some cases create rules that are identical to the ones that already exist. Starting around 4.9, the kernel fails these operations with EEXIST. We can't just ignore the EEXISTs because if we get EEXIST it means that the rule was not created, but we'll think it was, and later on we'll trip up trying to delete it. It would be possible to refactor the code to ensure that these no-op operations are never performed, but we would probably have to pass a lot more state around to deal with only a few corner cases. Fix: 69607866 Test: builds Change-Id: I1b563243b615daa73a2d9f527f77608df1f56251
* Don't look up the main table any more.Lorenzo Colitti2017-09-271-22/+1
| | | | | | | | | | | | | After https://android-review.googlesource.com/#/c/481397/ , directly-connected routes for all network types are added to the correct routing tables by ConnectivityService. So there should be no reason to look up the main table. Bug: 28825988 Test: bullhead builds, boots Test: netd_{unit,integration}_test pass Test: dual-stack wifi and IPv4-only mobile data work Change-Id: I64ba7dbf71478afcd9d2880440f93ef346116b6b
* Don't require permissions for high-priority oif rules.Lorenzo Colitti2017-09-261-2/+4
| | | | | | | | | | | | | | | The intent of the high-priority oif rules added in ag/644462 was to ensure that the kernel can send packets and forward packets to a given interface by specifying only the oif. However, if a network requires permissions, the high-priority oif rules we create require those permission bits in the firewall mark, which means the kernel cannot use them. Therefore, remove the permissions check. Test: builds Test: netd_{unit,integration}_test pass Change-Id: I73d7eb349c4c20d0d5efe05219a89cff5015a330
* Minor fixes in RouteController.Lorenzo Colitti2017-09-251-14/+2
| | | | | | | | | | - Remove the definition of fib_rule_uid_range, since it's now in the UAPI headers. - Fix the comment on PRIO_THROW, which is inaccurate. Test: bullhead builds, boots Test: netd_{unit,integration}_test pass Change-Id: I52ced26c4ea21925140d6ed86991e50cff7bd46a
* Invalidate dst caches when changing network permissions.Lorenzo Colitti2017-09-121-0/+13
| | | | | | | | | (cherry picked from commit 4662e16686954dd3ca80938efe6650227877fe44) Bug: 64103722 Test: builds Test: connected socket UDP traffic switches to wifi when cell goes into background Change-Id: I502575d51781cacace96e0c2d1edb6a5183aab70
* Don't allow seamless handover to networks requiring permissions.Lorenzo Colitti2017-09-121-5/+28
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Currently, implicitly-marked sockets continue to work when the network changes permission. This makes it so that UDP sockets connected on a foreground network will continue to work even if the network moves into the background (e.g., when the linger timer fires on cell data with mobile data always on). Instead, make it so that sockets implicitly marked to a network become unroutable when the network starts requiring permissions. Explicitly-marked sockets will continue to be routed on the network, as usual. This is consistent with what we do for TCP: when a network changes permissions, all implicitly-marked sockets on that network are closed using SOCK_DESTROY. This change should not affect any other behaviour because: - Netd only ever implicitly marks sockets to the default network or to a bypassable VPN that applies to the caller. - In both cases, at the time of marking, the network does not require permissions because: - VPNs don't support permissions. - The default network never requires any permissions: - ConnectivityService's mDefaultRequest specifies NOT_RESTRICTED. - The only case where a NOT_RESTRICTED network can require a permission is if it's a background network, and the default network is, by definition, never a background network. - VPNs can't change permissions. - If the network is still the default network, the lack of this implicit rule doesn't matter. Therefore, the only case where this rule can alter routing is if a socket is implicitly marked on the default network and that network, after ceasing to be the default, changes permissions. (cherry picked from commit 6bd4a48ed735c7fc5c1143bf0b2f06b8a2879e61) Bug: 64103722 Test: builds Test: manually observed IP rules while changing network permissions Change-Id: I944df3a97c8062e7c3af00f72e18e693bee0a3a6
* Clear incoming packet mark rules on netd startup.Lorenzo Colitti2017-03-281-2/+5
| | | | | | | | | | | | | | | Currently, we put the incoming packet mark rules directly into the INPUT chain of the mangle table, which is not cleared on netd start. Move these rules to their own chain. This makes them consistent with all the other iptables rules and makes it easy to clear them on startup using the existing mechanisms. Bug: 28362720 Test: bullhead builds, boots Test: netd_{unit,integration}_test pass Test: watch -n1 "adb shell iptables -v -n -t mangle -L INPUT" while switching networks Test: rules are cleared on netd restart Change-Id: I9130f997a96dcfdfdfdd950520a76f8473b5f603
* Use new-style UID routing.Lorenzo Colitti2017-03-281-20/+0
| | | | | | | | | | | | | | | | | | Kernel prebuilts for OC devices have been updated, so the legacy attributes are not being used. Use the new attributes only. This will ensure that devices aren't using the old code by mistake, as any such devices will fail the VPN CTS tests. (cherry picked from commit 882e467ff7b83de868fa0b9a9beb9036bf14aede) Cherry-picking this to AOSP now that most external kernels have been updated as well. Bug: 16355602 Test: bullhead builds, boots Test: netd_{unit,integration}_test pass Test: has been running in internal master for several weeks. Change-Id: I1c4e8c9281a843417a3a52294a1b7d3e6502bee6
* Use iptables-restore to set the incoming packet mark rule.Lorenzo Colitti2017-03-271-5/+8
| | | | | | | | | | | This speeds up network switching because one rule needs to be added/removed per interface. Bug: 28362720 Test: bullhead builds, boots Test: netd_{unit,integration}_test pass Test: watch -n1 "adb shell iptables -v -n -t mangle -L INPUT" while switching networks Change-Id: Ie536db6a50d018c88bb03c5f069965e99e0d162e
* Add a test for RouteController.Lorenzo Colitti2017-02-161-4/+0
| | | | | Test: netd_{unit,integration}_test pass. Change-Id: I19416fd8a79354303dabec042d090f7ae6962b1b
* Use our netlink code to flush routes as well.Lorenzo Colitti2017-02-161-124/+42
| | | | | | | | | | | Most of the CL is refactoring the rule flush code to be more generic and move it and various callback definitions to NetlinkCommands. After that, flushing routes is very simple. Test: bullhead builds, boots Test: netd_{unit,integration}_test pass Bug: 34873832 Change-Id: I0613d525f043d0a8b234a89982281b909011c7e5
* Don't complain when deleting non-existent tethering rules.Lorenzo Colitti2017-02-141-2/+6
| | | | | | | | | | | clearTetheringRules ignores errors when deleting rules, because tethering rules don't exist unless tethering was enabled on the interface. sendNetlinkRequest shouldn't log an error in this case, since the caller is ignoring that error. Bug: 34873832 Test: bullhead builds, boots, spurious error messages gone Change-Id: Ib327e8a3aecd3a38d624baa8bf320da87e6c4f7c
* Don't call NetlinkCallbacks with nullptr on NLMSG_DONE.Lorenzo Colitti2017-02-141-1/+0
| | | | | | | | | | No real callback uses this, and even the test code doesn't seem to use it for anything useful. Bug: 34873832 Test: bullhead builds, boots, rules flushed on netd restart Test: netd_{unit,integration}_test pass Change-Id: I195dd388864e9e596af9f4d08aee7b8ade078fb5
* Use netlink code to flush rules.Lorenzo Colitti2017-02-141-10/+61
| | | | | | | | | | | | This removes two calls to /sbin/ip on netd startup, which saves about 70ms. In the future we will be able to use this to flush routes as well, which will provide similar time savings on every network destroy operation. Bug: 34873832 Test: bullhead builds, boots Test: rules flushed correctly when netd is killed Change-Id: I4875ac7fec1a92dc5fa2cb68f8fab2a903348c20
* Move the netlink command code to a new NetlinkCommands file.Lorenzo Colitti2017-02-141-66/+1
| | | | | | | Test: bullhead builds, netd boots Test: netd_{unit,integration}_test pass Bug: 34873832 Change-Id: Ia6fcde63e1092a62cad1c5238bbb9a91a9f39080
* Put most of netd into the android::net namespace.Lorenzo Colitti2017-02-141-1/+7
| | | | | | | Test: netd_{unit,integration}_test pass Test: bullhead builds, boots Bug: 34873832 Change-Id: I0a252328041b342f9c03cd08c11a69d452b045b3
* Simplify and improve error logging in sendNetlinkRequest.Lorenzo Colitti2017-02-131-17/+42
| | | | | | | Bug: 32323979 Test: bullhead builds, boots, new error messages appear Test: unit tests continue to pass Change-Id: Ie60ed3a71fbd26b7a8a1d2f7fb8083b1b6b9626a
* Set both legacy and new UID routing attributes.Lorenzo Colitti2016-12-191-15/+31
| | | | | | | | | | | | This should work on kernels that support either, as long as they are older than 4.8. Test: netd_integration_test passes with updated iproute and kernel Test: netd_integration_test passes with existing iproute and kernel Test: ConnectivityManagerTest and HostsideVpnTests pass on existing kernel Test: ConnectivityManagerTest and HostsideVpnTests pass on updated kernel Bug: 16355602 Change-Id: I9a2ef08ba2782587f43ea7d0609f5f07f6c3adb0
* UidRanges: use class instead of pair<uid_t, uid_t>Robin Lee2016-12-061-8/+10
| | | | | | | | | | | | | | | | | | | | Reuse the UidRange that was introduced in 7.0 (NYC) to ease transition from CommandListener to binder which supports this as a parcelable type. There is a small difference in behaviour: UidRange uses signed int32_t vs. uid_t being unsigned and potentially a different size. This should not be a problem as all of the java-side code is converting from int. Updating to use int64_t in future would be a large effort and involve changing the java-side UidRange class to use longs, and not fixing the native side would cause unit tests to fail, so it shouldn't be possible to overlook if that happens. Committing this early with an appropriately loud warning so that it can get soak time over the next year. Test: runtest -x netd_integration_test.cpp Change-Id: I6c217b347724ba5bfe2df28d6142a4343cb06353