Commit Graph

8129 Commits

Author SHA1 Message Date
Hungming Chen
dd833dee31 [NFCT.TETHER.10] Add/delete IPv4 offload BPF rules to/from BPF map
Access the IPv4 downstream and upstream BPF map with the built rules.

Test: atest TetheringCoverageTests
Change-Id: I8cd6e49b377c72250988019eea57f93cccd78309
2021-01-25 20:13:47 +08:00
Hungming Chen
347dd90620 [NFCT.TETHER.9] Build IPv4 offload BPF rules for raw ip
Build the upstream and upstream rules when the conntrack event is
received.

Test: atest TetheringCoverageTests
Change-Id: Ibb52c7b75812bd586091d809e260bc9206c06262
2021-01-22 19:37:37 +08:00
Hungming Chen
8784a60eab [NFCT.TETHER.8] Prepare the upstream information for IPv4 offload rule
Add upstream interface index and its IPv4 address mapping

Required for building IPv4 forwarding rule when a conntrack event is
received.

Test: atest TetheringCoverageTests
Change-Id: I73f304777704f09481b80d18751e0bab5bab2edc
2021-01-22 19:37:31 +08:00
Hungming Chen
d71c06ec71 [NFCT.TETHER.7] Prepare the downstream information for IPv4 offload rule
Add and remove downstream client information to BpfCoordinator

Required for building IPv4 forwarding rule when a conntrack event is
received. The IpServer provides the following elements of a rule which
is not included in conntrack event:
- Downstream interface index
- Downstream Mac address
- Client IP address to Client Mac address

Test: atest TetheringCoverageTests
Change-Id: I84db13acc047ace5730d17f0d3dd99544f516084
2021-01-22 19:37:24 +08:00
Nucca Chen
168a96643d Merge "[NFCT.TETHER.1] Add conntrack monitor to BpfCoordinator" 2021-01-22 11:29:09 +00:00
Maciej Żenczykowski
30a2d8232b adjust to changes in map location
Test: atest, TreeHugger
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: Idaaa1ede7c239655f5ec489532533c363d297864
2021-01-21 17:51:20 -08:00
Hungming Chen
46c30b1fd4 [NFCT.TETHER.1] Add conntrack monitor to BpfCoordinator
A preparation for starting monitoring conntrack event which is required
by IPv4 tethering offload.

Test: atest TetheringCoverageTests
Change-Id: Ied46aeca193554f52a90889dfdf92827e94845d6
2021-01-21 21:25:18 +08: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
73dc23c4ea Merge changes from topic "v6_tether"
* changes:
  switch bpf programs to group network_stack
  Add tethering programs for upstream.
2021-01-21 00:50:47 +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
a0e2c0445d refactor: continued
Test: builds, atest, TreeHugger
  git grep 'makeIngressKey|makeIngressValue|BpfIngressMap|TETHER_INGRESS_FS_PATH'
  no longer finds anything
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: I27200d33cbc4ea2094b18e05bf93ab54c564da0b
2021-01-20 11:34:48 +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
Maciej Żenczykowski
3bf519f279 Merge "BpfMapTest - adjust paths for bpfloader change" 2021-01-20 07:12:35 +00: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
7928fde758 BpfMapTest - adjust paths for bpfloader change
that puts tethering mainline module maps and programs
under /sys/fs/bpf/tethering

Test: builds, boots, atest, TreeHugger
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: If57e737168cefe9fe0fe180114c1d61918d20d21
2021-01-20 05:13:08 +00:00
Maciej Żenczykowski
b213e84170 add maze to OWNERS
since there's now bpf code in tethering portion of the codebase.

Test: N/A
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: I679b7ba6d5fff49bad4fb2fe7d251875e4cb94b5
2021-01-19 18:31:52 -08:00
Lorenzo Colitti
fab97c22b2 Merge changes Id87b88f6,I67dfba75
* changes:
  [NFCT.TETHER.6] Migrate tetherOffloadGetAndClearStats from netd to mainline
  [NFCT.TETHER.5] Migrate tetherOffloadSetInterfaceQuota from netd to mainline
2021-01-20 02:19:14 +00:00
Nucca Chen
2668d4a0e2 Merge changes I969d6182,Ie73f7b4d
* changes:
  [NFCT.TETHER.4] Migrate tetherOffloadRuleRemove from netd to mainline
  [NFCT.TETHER.3] Migrate tetherOffloadGetStats from netd to mainline
2021-01-19 11:29:22 +00:00
Maciej Żenczykowski
ab44322f9c Merge "move bpf test map into a separate file" 2021-01-19 11:25:13 +00:00
Junyu Lai
f555f4bca7 Merge "Revert "[VCN06.1] Add CTS for request background network"" 2021-01-19 10:24:47 +00:00
Junyu Lai
3660b71c11 Revert "[VCN06.1] Add CTS for request background network"
Revert "[VCN06] Support request background network"

Revert submission 1545847-vcn06

Reason for revert: b/177876289 presubmit failure
Reverted Changes:
I8042ce197:[VCN06.1] Add CTS for request background network
If9aaa87b7:[VCN06] Support request background network

Change-Id: Icd01643cae86c4448eb7105ef0f238b1f10ebc19
2021-01-19 09:06:00 +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
Junyu Lai
5b39b66544 Merge "[VCN06.1] Add CTS for request background network" 2021-01-19 01:04:20 +00:00
junyulai
f8370c08be [VCN06.1] Add CTS for request background network
Test: android.net.cts.ConnectivityManagerTest#testRequestBackgroundNetwork
Bug: 175662146
Change-Id: I8042ce1971c728a9f900d090c0c4cabd994820bf
2021-01-18 16:32:33 +08:00
Nucca Chen
6bc18e6d2c Merge "[NFCT.TETHER.2] Migrate tetherOffloadRuleAdd from netd to mainline" 2021-01-18 06:37:23 +00:00
Les Lee
7e9e19c1ea Merge "wifi: Add bridged pre-fix for tethering interface" 2021-01-18 01:21:45 +00:00
lesl
6a953ef4d3 wifi: Add bridged pre-fix for tethering interface
In bridged mode, the tethered interface will include the prefix ap_br_

Bug: 162686273
Test: Manual Test - bridged AP enabled success
and client can connected it and get the IP address
Test: atest -c NetworkStackTests
Test: atest -c FrameworksNetTests
Test: atest -c CtsNetTestCasesLatestSdk
Change-Id: I89ae178c658a42f902199afaed89ec798de54643
2021-01-18 01:21:32 +00:00
Hungming Chen
6971e91d62 [NFCT.TETHER.6] Migrate tetherOffloadGetAndClearStats from netd to mainline
A preparation for updating BPF map in mainline module.

Test: atest TetheringCoverageTests
Change-Id: Id87b88f6dfcdfe5765756442ed880933cd1c6baf
2021-01-15 18:40:55 +08:00
Hungming Chen
67c14b549f [NFCT.TETHER.5] Migrate tetherOffloadSetInterfaceQuota from netd to mainline
A preparation for updating BPF map in mainline module.

Test: atest TetheringCoverageTests
Change-Id: I67dfba750c7303e4aeaf65f5086db1290d176b4d
2021-01-15 18:40:48 +08:00
Hungming Chen
5ea9c4b64a [NFCT.TETHER.4] Migrate tetherOffloadRuleRemove from netd to mainline
A preparation for updating BPF map in mainline module.

Test: atest TetheringCoverageTests
Change-Id: I969d6182a307f46c8ed0a30960deb460ecedd8ea
2021-01-15 18:40:40 +08:00
Hungming Chen
b350d7589f [NFCT.TETHER.3] Migrate tetherOffloadGetStats from netd to mainline
A preparation for updating BPF map in mainline module.

Test: TetheringCoverageTests
Change-Id: Ie73f7b4d9b191e62cfdfe2cfa3360cc7210f17e8
2021-01-15 17:11:12 +08:00
Hungming Chen
dd55b91228 [NFCT.TETHER.2] Migrate tetherOffloadRuleAdd from netd to mainline
A preparation for updating BPF map in mainline module.

Test: atest TetheringCoverageTests
Change-Id: I6f8667bf110dae3e2805c2752ff59e7284a7bce0
2021-01-15 17:10:58 +08:00
Remi NGUYEN VAN
4bf203d065 Skip NetworkAgentTest on R-
NetworkAgent is not updatable on R-, so there is no need to run tests
compiled against S on older platforms. They are also incompatible
because NetworkAgent stopped using AsyncChannel in S.

This only affects MTS, and CTS used to test S+ devices. CTS for R-
devices is already cut in a branch that this change will not merge to.

Bug: 177290955
Change-Id: I85c137a1b5fd7ef701fba4623566df5a8fb707a3
Test: atest CtsNetTestCasesLatestSdk
2021-01-15 07:45:29 +00:00
Maciej Żenczykowski
539d0e27cf Merge "Use header module bpf_syscall_wrappers" 2021-01-14 07:36:50 +00:00
Treehugger Robot
26b0cf3261 Merge "Net CTS: move NsdManagerTest from Wifi CTS" 2021-01-14 03:51:17 +00:00
David Su
cd1851e0a2 Net CTS: move NsdManagerTest from Wifi CTS
NsdManagerTest is not owned by Wifi, so it doesn't
belong in Wifi CTS.

Bug: 176902925
Test: atest CtsNetTestCases
Change-Id: I8eb3cba7a3b2ff24a012cca8d3fdff173e88c69a
2021-01-14 03:47:25 +00:00
Hungming Chen
400702b6bb Use header module bpf_syscall_wrappers
Use the versioned header library instead of just including
the header files.

Test: atest BpfMapTest
Change-Id: Icf23dcdc051a4ead6a7c6e925159cdc27f49eac2
2021-01-13 14:31:28 +08:00
Patrick Rohr
99f6c312ef Merge "Add CTS test for Restricted Networking Mode" 2021-01-12 17:41:19 +00:00
Hungming Chen
7d05e6fddd Follow-up CL to the change at aosp/1498277
1. Correct the API annotation.
2. The entry deletion failure causes the exception in cleanTestMap().
3. Use AtomicInteger to be the counter in the lambda.

Test: atest BpfMapTest
Change-Id: I4a56038881a38bda993ef5303b71f0e2a99f03d1
2021-01-12 19:08:15 +08:00
Nucca Chen
12067258b2 Merge "Provide a easy way to access bpf maps from java" 2021-01-12 08:06:03 +00:00
Remi NGUYEN VAN
73fa31b404 Merge "Revert^2 "Add service-connectivity to tethering APEX"" 2021-01-12 01:35:30 +00: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
Patrick Rohr
4df8a7aef1 Add CTS test for Restricted Networking Mode
Test: atest com.android.cts.net.HostsideRestrictBackgroundNetworkTests
Bug: 175281879
Bug: 170323671
Change-Id: Ic69e7e029debeea1f131242fb2baad2796d4768c
2021-01-11 09:47:04 +01:00
lucaslin
ee661dfb59 Move BaseNetdUnsolicitedEventListener to frameworks/libs/net
Move BaseNetdUnsolicitedEventListener to frameworks/libs/net and
create a new library - netd-client for using.
Also remove netd_aidl_interface-unstable-java since netd-client
links to the stable one.

Bug: 174837473
Test: Manual test and check the log.
Change-Id: Id65142b8c13a6cccbfe387d4ab757967497546e6
2021-01-08 01:55:53 +00:00
Remi NGUYEN VAN
2812f607a0 Revert^2 "Add service-connectivity to tethering APEX"
Add the connectivity service JAR to the tethering APEX.
This change should not be released in monthly updates until the
modularization work is done, so will be reverted in module release
branches.

This rolls forward the change. The original topic was reverted because
of a bad merged-in clause; this is fixed and re-verified in this topic.

Test: Boot, wifi connects and has internet access
Bug: 171540887

Change-Id: Ib0ac49609e444a53a6fee4575f5078e15f364eef
2021-01-08 01:24:36 +00:00
Sudheer Shanka
edb6669cf1 Merge "Increase the wait timeout for meteredness to change." 2021-01-07 22:56:48 +00:00