summaryrefslogtreecommitdiff
path: root/common
AgeCommit message (Collapse)Author
2022-06-21support per-map/prog selinux context and cross .o map sharingandroid13-devMaciej Żenczykowski
Tested in pieces in aosp/master and it still successfully boots. So the struct extension infrastructure works as desired. This is a sqaush of 2 aosp/master commits: 64005dd91b0cf1722ccd1767f805e0524010920e a5c641141ff74bba025a65451628308c6cbb7e0f Ignore-AOSP-First: squash of 2 aosp/master patches Bug: 218408035 Test: TreeHugger Signed-off-by: Maciej Żenczykowski <maze@google.com> Change-Id: I7136253086eaccf79cf39e7a0143b425a1019390
2022-06-21BpfMap - add BpfMapRO.init() supportMaciej Żenczykowski
Really we need to fix the inheritance to make BpfMapRO the parent class of BpfMap: but that's a far more difficult thing to do, so in the short term we punt like this. This makes BpfMapRO a little bit more usable, and allows a slow transition across the codebase... Bug: 218408035 Test: TreeHugger Signed-off-by: Maciej Żenczykowski <maze@google.com> Change-Id: I1c5112db70e9e523c113cba536fbe19422b4d3f3 (cherry picked from commit b54659706758641a0ff01770644cb189e3959b29) Merged-In: I1c5112db70e9e523c113cba536fbe19422b4d3f3
2022-06-21Merge "bpf_helpers.h - add #define's for S/T bpfloader versions" into tm-devMaciej Żenczykowski
2022-06-21bpf_helpers.h - add #define's for S/T bpfloader versionsMaciej Żenczykowski
(by request from Lorenzo) Bug: 218408035 Test: TreeHugger Signed-off-by: Maciej Żenczykowski <maze@google.com> Change-Id: I802d2aae8b103375d7cbe0ed5c35f0abf6c04ac9 (cherry picked from commit 974ee86ff71fdfaaa0305d1623efcef1d9a16b21) Merged-In: I802d2aae8b103375d7cbe0ed5c35f0abf6c04ac9
2022-06-21BpfMap key/value access size verificationMaciej Żenczykowski
(beginning there of) Bug: 218408035 Test: TreeHugger Signed-off-by: Maciej Żenczykowski <maze@google.com> Change-Id: Ie7cf8cd51b4e272fc76a281df6231ed27955ed3f (cherry picked from commit 62315472e581ea119fb8f44d3a03b41a8ca80b3b) Merged-In: Ie7cf8cd51b4e272fc76a281df6231ed27955ed3f
2022-06-21cache kernelVersion(), make isAtLeastKernelVersion() cheaperMaciej Żenczykowski
not perfect due to this being in a header file, so multiple copies potentially exist, but it's really simple, and works nearly as well. Bug: 218408035 Test: TreeHugger Signed-off-by: Maciej Żenczykowski <maze@google.com> Change-Id: Id90c6933d57bc12f4dd640c8918fd0885c7474cf (cherry picked from commit 9d481287aa69200a36c997200e71232b77234b0a) Merged-In: Id90c6933d57bc12f4dd640c8918fd0885c7474cf
2022-06-20BpfMap: simplify .init() mMapFd assignmentMaciej Żenczykowski
this way is more obviously not calling dup_with_cloexec Bug: 218408035 Test: TreeHugger Signed-off-by: Maciej Żenczykowski <maze@google.com> Change-Id: I4e1ce3b0a42ccea638332ae451e291e025d57895 (cherry picked from commit 703e4682444dcab121f9657dc5c1605a7bcce65e) Merged-In: I4e1ce3b0a42ccea638332ae451e291e025d57895
2022-06-16Add an int constant for CLAT_MARK and freeze INetd v10.Lorenzo Colitti
Test: m Bug: 235778483 Change-Id: I45a0bd6be39022a913bc6cff8216df0b6559cd4b (cherry picked from commit 80664c52df2cf24fa4332084586324fd4a93de81) Merged-In: I45a0bd6be39022a913bc6cff8216df0b6559cd4b
2022-06-16Freeze netd_aidl_interface V9Hungming Chen
Deprecate APIs which were moved the implementation to mainline module. - clatdStart (since T) - clatdStop (since T) - tetherOffloadRuleAdd (since S) - tetherOffloadRuleRemove (since S) - tetherOffloadGetStats (since S) - tetherOffloadSetInterfaceQuota (since S) - tetherOffloadGetAndClearStats (since S) Bug: 212345928 Test: cd system/netd; atest Change-Id: I7916512c7174a7b50833036bc89df37a266ca67e (cherry picked from commit 7b29319fcfeed3f9423fd583da705bf35ed34126) Merged-In: I7916512c7174a7b50833036bc89df37a266ca67e
2022-06-13Fix DevSdkIgnoreRule target SDK annotation processing.Lorenzo Colitti
The code added to DevSdkIgnoreRule to process the max target SDK annotations in aosp/2110064 was incorrect. It is trying to match the annotation name, but ::class.simpleName returns something like Proxy$3, not the actual name of the annotation. Use annotationClass.simpleName instead, which actually works. This was not caught in aosp/2110064 because it contained an even worse error which broke DevSdkIgnoreRule completely. That was fixed in aosp/2114653. Bug: 233553525 Test: LinkPropertiesTest#testExcludedRoutesDisabled passes on user build Change-Id: If9220e5ef00fafea556604b251b2106d15d063f8 (cherry picked from commit 3af9b34bad03ac0a7ad061bac64a1ace9e1aac7a) Merged-In: If9220e5ef00fafea556604b251b2106d15d063f8
2022-06-09Add handlePacketReadError method in FdEventsReader.Xiao Ma
This method allows the subclasses of FdEventsReader to decide whether it should stop reading packet and unregister the fd immediately or just ignore when some specific error other than EAGAIN or EINTR happens such as ENOBUFS. Bug: 232680956 Test: m Merged-In: I19ee9390e78dcd0140e45fed75a1a36942450407 Change-Id: I19ee9390e78dcd0140e45fed75a1a36942450407
2022-06-08BpfMap: introduce resetMap(type, entries, flags)Maciej Żenczykowski
to replace less safe uses of BpfMap.reset(create(type, keysize, valuesize, entries, flags)) Meant to be used in tests only. Bug: 235286176 Test: TreeHugger Signed-off-by: Maciej Żenczykowski <maze@google.com> Change-Id: I869f1f935bcf5d00702c42bc46d6094ea552addc (cherry picked from commit d2dec08c73b2bc1dd2a3969ccb504a59e9cb223f) Merged-In: I869f1f935bcf5d00702c42bc46d6094ea552addc
2022-06-08Merge "Make net-utils-device-common-bpf only available for module and tests" ↵Maciej Żenczykowski
into tm-dev
2022-06-02Add IPPrefix.contains()Chiachang
Add helper methods to check whether the specified prefix is entirely contained in this prefix, or the specified address is contained in this prefix. Bug: 184750836 Test: atest IPPrefixTest Change-Id: I838510b347ac5741c589ee8f3983111209155588 (cherry picked from commit abe2e7fab4702113df60511f4642a6277321eb20) Merged-In: I838510b347ac5741c589ee8f3983111209155588
2022-06-02Run tests using DevSdkIgnoreRuleRemi NGUYEN VAN
Tests using DevSdkIgnoreRule are currently not being run at all, as the call to base.evaluate() was removed. Bug: 233553525 Bug: 234680138 Ignore-AOSP-First: fix urgent test breakage Change-Id: Ice2d1c85f5b886b1fcd5214046ae554d6c66134b Test: atest
2022-06-02Merge changes from topic ↵Nucca Chen
"cherrypicker-L41500000954817786:N47600001269435138" into tm-dev * changes: DeviceInfoUtils: add class and helper for three-part version number Move DeviceInfoUtilsTest from NetworkStack to frameworks/lib/net
2022-06-01Make net-utils-device-common-bpf only available for module and testsMark Chien
net-utils-device-common-bpf is design for connectivity module only, change the visibility to avoid someone outside of the module use it inadvertently. Bug: 234160319 Change-Id: I3c7c48b60414f19bad8be0bda38ea5af3dc99c86 Test: TH (cherry picked from commit 72cd1a9ef29d2b908f8ad066b84b4a0f17cc2de7) Merged-In: I3c7c48b60414f19bad8be0bda38ea5af3dc99c86
2022-06-01Make FdEventsReader#isRunning method as protected.Xiao Ma
This allows subclasses of FdEventsReader can access isRunning() method directly without maintaining its own mechanism to check if the instance of FdEventsReader is still running. Bug: 232680956 Bug: 233191218 Test: m Merged-In: Iaaa07328f9804580cc2e413b5a50c0d69d8cfb2f Change-Id: Iaaa07328f9804580cc2e413b5a50c0d69d8cfb2f
2022-06-01Add an annotation to skip tests if the APK has target SDK > 31.Lorenzo Colitti
This skips a test if the APK it's running in targets an SDK above 31. This allows us to add such tests to CtsNetTestCases, which is currently targeting SDK 33. By using the annotation as an include-annotation filter in AndroidTestTemplate.xml, this makes it very easy to create a clone of CtsNetTestCases that targets SDK 31 and which only runs tests annotated with this annotation. Thus, CtsNetTestCases and CtsNetTestCasesLatestSdk will run all tests that pass if target SDK is 33, and CtsNetTestCasesMaxTargetSdk31 will only run the tests that requires target SDK 31. See other CL in topic. Bug: 233553525 Test: atest CtsNetTestCasesMaxTargetSdk31:android.net.LinkPropertiesTest Test: atest CtsNetTestCasesLatestSdk:android.net.LinkPropertiesTest Change-Id: Ib5df3bbc659d6a737a846fdf57cddee002e4e9ae (cherry picked from commit 8459c69a22cf4aae0c3cce59efc05f66d564da70) Merged-In: Ib5df3bbc659d6a737a846fdf57cddee002e4e9ae
2022-05-28DeviceInfoUtils: add class and helper for three-part version numberTreehugger Robot
Add a class Version and string helper for handling a three-part kernel version number. Test: atest com.android.testutils.DeviceInfoUtilsTest Bug: 232332847 Original change: https://android-review.googlesource.com/c/platform/frameworks/libs/net/+/2108204 Merged-In: I0f229e935bd8332ef2ef93fc910a576df9c054ae Change-Id: I70fedb33582a2f157b93ad0ab5be8f305feb3b21 Signed-off-by: Nucca Chen <nuccachen@google.com> (cherry picked from commit 3a7e53b03034b71985e905915d3eeb07d80b77c7)
2022-05-28Move DeviceInfoUtilsTest from NetworkStack to frameworks/lib/netHungming Chen
Test: atest com.android.testutils.DeviceInfoUtilsTest Change-Id: Ib45dea951980eae0c1576d37842477192539a740 (cherry picked from commit 9f26c843618aad57a27e2eff976c2ff521739fac) Merged-In: Ib45dea951980eae0c1576d37842477192539a740
2022-05-27When parsing a netlink message, always advance to the end.Lorenzo Colitti
NetlinkEvent#parse relies on message-specific classes to parse the payload of the message. If these classes do not consume the entire message, parse does not advance to the end of the message. This means that any code that loops over a ByteBuffer parsing messages one at a time (e.g., NetlinkMonitor) will think that there is still a message left to parse, and will attempt to parse the remainder of the message as a new netlink message. This is obviously incorrect for any buffer that contains more than one netlink message. Bug: 163492391 Test: existing unit tests Change-Id: Ifdb9748068857f75ca00c58f0c40f19809aae5c9 (cherry picked from commit 0bf51a89b2fbb6cc60668a39189ef2a90bea4c5b) Merged-In: Ifdb9748068857f75ca00c58f0c40f19809aae5c9
2022-05-27Add test to verify parsing multiple netlink messages in one buffer.Xiao Ma
Currently the netlink parsing code doesn't advance to the end of message if it doesn't consume the entire message, that results in the remaining attributes will be considered as a new netlink message, parsing the attributes will fail and return null. Have a testcase to verify this case. Bug: 163492391 Test: atest NetworkStaticLibsTests Change-Id: I2719cd917f9932d5e77002e615845076784139a2 (cherry picked from commit a8b53fd42b5f198e77733b292473c4bbe5ea80d8) Merged-In: I2719cd917f9932d5e77002e615845076784139a2
2022-05-20BpfMap: cache bpf map file descriptorsMaciej Żenczykowski
We switch back to int from ParcelFileDescriptor, and eliminate all calls to close(). Bpf Map FDs now live till process exit. Bug: 230880517 Test: TreeHugger, atest com.android.networkstack.tethering.BpfMapTest Signed-off-by: Maciej Żenczykowski <maze@google.com> Change-Id: I89b6dc88ea56cb1e50695f8daf54ed79bce3fba2 (cherry picked from commit 8888c198daa8141988ee806adcf54b43e68b1076) Merged-In: I89b6dc88ea56cb1e50695f8daf54ed79bce3fba2
2022-05-16Address comments at ag/18372083Junyu Lai
This includes: 1. Fix synchronization error 2. Disallow 0 as maximum counter value 3. Fix comments Test: atest NetworkStaticLibTests:com.android.net.moduletests.util.PerUidCounterTest Test: atest ConnectivityCoverageTests:android.net.connectivity.com.android.net.module.util.PerUidCounterTest Bug: 229103088 Change-Id: I54c6017ffc62341d1a5da6591e5a045d687601d4 (cherry picked from commit 3103fb626a804c5d4a8ec15ac22a575bf7da314e) Merged-In: I54c6017ffc62341d1a5da6591e5a045d687601d4
2022-05-16Add PerUidCounterJunyu Lai
The class keeps track of the counters under different uid, fire exception if the counter exceeded the specified maximum value. This is reimplemented and generalized based on the one inside ConnectivityService. Test: atest NetworkStaticLibTests:com.android.net.moduletests.util.PerUidCounterTest Test: atest ConnectivityCoverageTests:android.net.connectivity.com.android.net.module.util.PerUidCounterTest Bug: 229103088 Change-Id: I7dfb16342e3ca4eab45bb40f2e1355981e04b44b (cherry picked from commit fe8cf1d1e9817afc804a05148dcb39f7ae24c360) Merged-In: I7dfb16342e3ca4eab45bb40f2e1355981e04b44b
2022-05-12BpfMap: wrap native fd with ParcelFileDescriptor to avoid fd leakHungming Chen
ParcelFileDescriptor has implemented finalize(). Wrap native fd into ParcelFileDescriptor which helps to release fd automatically. Bug: 230880517 Test: manual test Steps: 1. Connect to IPv6 only wifi and clat maps are created $ adb shell cmd wifi set-wifi-enabled enabled 05-12 13:53:41.182 1793 2031 W BpfMap : open /sys/fs/bpf/net_shared/map_clatd_clat_ingress6_map..: 493 05-12 13:53:41.182 1793 2031 W BpfMap : open /sys/fs/bpf/net_shared/map_clatd_clat_egress4_map..: 546 $ adb shell ls -all proc/1793/fd | grep bpf .. system system 64 2022-05-12 13:55:35 .. 493 -> anon_inode:bpf-map .. system system 64 2022-05-12 13:55:35 .. 546 -> anon_inode:bpf-map $ adb shell dumpsys connectivity Forwarding rules: BPF ingress map: iif nat64Prefix v6Addr -> v4Addr oif 47 /64:ff9b::/96 /2a00:79e1:abc:6f02:6efd:1d4b:f05e:25bd -> /192.0.0.4 54 BPF egress map: iif v4Addr -> v6Addr nat64Prefix oif 54 /192.0.0.4 -> /2a00:79e1:abc:6f02:6efd:1d4b:f05e:25bd /64:ff9b::/96 47 ether 2. Disconnect from IPv6 only wifi, force GC and clat map fds are released $ adb shell cmd wifi set-wifi-enabled disabled $ adb shell kill -10 1793 $ adb shell ls -all proc/1793/fd | grep bpf (fd 493 and 546 are removed) Change-Id: I26bbafbd73eccab6f4ae2c71690ecad12bbef7df (cherry picked from commit ef5e791312fbed4ead02809893039d8e21b43a03) Merged-In: I26bbafbd73eccab6f4ae2c71690ecad12bbef7df
2022-05-08Migrate compareMajorMinorVersion from ConnectivityManagerTestHungming Chen
Move compareMajorMinorVersion() and getVersionFromString() from ConnectivityManagerTest.java. Test: atest DeviceInfoUtilsTest Change-Id: Ib8245890856a3e4518e48e0afeada746a24e8b22 (cherry picked from commit 5c3d6e0d708ce8248d63d671f3db383169ee63f8) Merged-In: Ib8245890856a3e4518e48e0afeada746a24e8b22
2022-04-28Add null check for mProviderMotomu Utsumi
mProvider is null before register is called. But toString call mProvider.getProviderId() without null check and caused NullPointerException. This commit add null check and fix this issue. Original change: https://android-review.googlesource.com/c/platform/frameworks/libs/net/+/2076539 Bug: 228796405 Test: m Ignore-AOSP-First: manual cherry-pick from AOSP Change-Id: Ic8e23b21d11705219f1a8fddd544941fbddb183e
2022-04-24Merge "Add wrappers for the latest stable version of netd_aidl_interface-V*-cpp"Ken Chen
2022-04-21Add wrappers for the latest stable version of netd_aidl_interface-V*-cppKen Chen
Currently, we need to update linked AILD interface in several places when we freeze a new interface version. Otherwise, it will have multiple versions of an AIDL lib and waste space/memory (b/220392885). To avoid manually update all AILD interface users every time, adds wrappers for the latest version of netd_aidl_interface-V*-cpp. The reason to use cc_default as a wrapper instead of cc_library is that it doesn't create an extra .so. Bug: 220392885 Test: TH Change-Id: I281b2e5f7d04fadfae0ede4db7565e9f222dbe95
2022-04-19Merge "Move TetherStatsKey and TetherStatsValue to common libs"Treehugger Robot
2022-04-08Create RouterAdvertisementResponderPatrick Rohr
This is useful for tests that need a provisioned tap interface. Test: TH Change-Id: I9a2eb3d8697bbcbfdb65563da609534b929a0715
2022-04-07Merge changes from topic "MDns_AIDL"Paul Hu
* changes: Freeze Mdns AIDL interface to V1 Add MDNS aidl
2022-04-04Move TetherStatsKey and TetherStatsValue to common libsHungming Chen
EthernetTetheringTest needs to parse BPF map content for bpf stats tests. Move the struct class files to common libs. Compare TetherStats{Key, Value}.java between frameworks/libs/net/common and packages/modules/Connectivity/Tethering. There is only the package name change as expected. $ diff packages/modules/Connectivity/Tethering/src/com/android/networkstack/tethering/TetherStatsKey.java frameworks/libs/net/common/device/com/android/net/module/util/bpf/TetherStatsKey.java 17c17 < package com.android.networkstack.tethering; Bug: 227159997 Test: atest TetheringCoverageTests Change-Id: I6ed3b1626d8efd3920130f0af0cd9de75ee0bd7f
2022-04-04Freeze Mdns AIDL interface to V1paulhu
- Also add mdns_aidl_interface-lateststable-java lib for Connectivity module usage. Bug: 209894875 Test: m mdns_aidl_interface-freeze-api Change-Id: I58364dcf6d0377fbac7533eb95d2aacddd120092
2022-04-03Add MDNS aidlpaulhu
- Add MDNS aidl that NsdService can communicate with mdns service via binder call instead of using ndc. - Add mdns_aidl_interface to separate the mdns aidl from netd_aidl_interface. Bug: 209894875 Test: atest FrameworksNetTests CtsNetTestCases Change-Id: I7bcbd6146269bdd9ac973d651a676bd9d126ae2d
2022-03-30Merge "Make libtcutils visible to netd tests"Maciej Żenczykowski
2022-03-30Make libtcutils visible to netd testsPatrick Rohr
Test: TH Change-Id: I71943cfd2fb72dca8a7ffd5d063860b89be47ca1
2022-03-28Check RouteInfo type in NetUtils#selectBestRouteTaras Antoshchuk
Change #selectBestRoute to account for non-unicast routes. Method is used to detect if the address is reachable and via which gateway. From that point of view, address being best matched by a non-unicast route is equivalent to the address not being matched by any route at all. Method's implementation is adjusted to reflect the above logic. This allows to avoid changing method's usages. Bug: 186082280 Test: atest NetworkStaticLibTests:NetUtilsTest Change-Id: I03f19d611fd8c7019cf13062bbeb1662d41402f4
2022-03-24Merge "Clear apex.go entries for bluetooth libs"Treehugger Robot
2022-03-18Clear apex.go entries for bluetooth libsWilliam Escande
The module availability to Bluetooth is currently hard-coded in apex.go. We are in the process of cleaning the apex.go by adding the availability in each required module Test: Build + TH + boot phone & use bluetooth Bug: 216433795 Change-Id: I7b9e2a95e9fda0f25786e113d78bca81a4406abf
2022-03-17TcUtils: add tcQdiscAddDevClsactHungming Chen
Support tc command: $ tc qdisc add dev .. clsact Test: TreeHugger Change-Id: I98abcb59418ab12b6e4de0f42a18ded4677ddbfc
2022-03-16Merge "[DU04-3]Appropriate changes to the NetworkPolicyManager API"Frank Li
2022-03-16[DU04-3]Appropriate changes to the NetworkPolicyManager APIFrank
Divide the NetworkPolicyManager API notifyStatsProviderWarningOrLimitReached into the following two APIs: 1. notifyStatsProviderWarningReached() 2. notifyStatsProviderLimitReached() Bug: 216474563 Test: atest NetworkStatsServiceTest NetworkPolicyManagerTest NetworkPolicyManagerServiceTest OffloadControllerTest Change-Id: I9d399ea32b656727bf155283265693d3f0d4b9cf
2022-03-15Merge changes from topic "access_clat_bpf_map_from_clatcoordinator"Nucca Chen
* changes: Add struct ClatIngress6Value Add struct ClatIngress6Key Add struct ClatEgress4Value Add struct ClatEgress4Key
2022-03-11Merge "Allow use of shared bpf headers by recovery"Maciej Żenczykowski
2022-03-10Merge "Add DisableConfigSyncTargetPreparer"Remi NGUYEN VAN
2022-03-09Allow use of shared bpf headers by recoveryStephane Lee
This will allow healthd to filter uevent packets, if needed Bug: 203462310 Test: Ensure that healthd can build if it uses bpf filters Change-Id: I97bfe9509a6934444f656508176495bba38381be
2022-03-09Add DisableConfigSyncTargetPreparerRemi NGUYEN VAN
The TargetPreparer disables DeviceConfig sync before a test module, and attempts to reset it to its original state afterwards. It only supports S+ as the associated commands are not available on R-. The format of commands has also changed in some T branches , so support legacy format if the newer format is not supported by the device. Bug: 210377950 Test: atest CtsNetTestCases using the preparer, verify setting set during the test. Change-Id: Iaabaa1050b024e1378ab1cf87a394cc8ebab227b