Commit Graph

8155 Commits

Author SHA1 Message Date
Treehugger Robot
33848955b0 Merge "merge Tether{Down,Up}stream6Value -> Tether6Value" 2021-01-27 07:18:35 +00:00
Remi NGUYEN VAN
f0be057728 Merge "Move connectivity-sources to frameworks/base" 2021-01-27 07:15:05 +00:00
Maciej Żenczykowski
7dfbcf58d2 merge Tether{Down,Up}stream6Value -> Tether6Value
Test: atest TetheringTests TetheringCoverageTests
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: Ibdbba9ef6652dd11bb18eba316045dff440fcf9e
2021-01-27 06:41:59 +00:00
Lorenzo Colitti
0913a7a415 Merge changes Iaac422d7,Ia7638b31
* changes:
  Remove IpServer.Dependencies#getIfIndex.
  Address comments on aosp/1559686.
2021-01-27 03:04:23 +00:00
Maciej Żenczykowski
cff64c8561 fix comments
Test: N/A
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: Ic217e08484c39077bcc408195daa3311ed93ad28
2021-01-26 16:45:21 -08:00
Lorenzo Colitti
f3b201f819 Remove IpServer.Dependencies#getIfIndex.
This code is unused.

Test: atest TetheringTests
Change-Id: Iaac422d72e8538b67798cb3ae3737deb7b426401
2021-01-27 00:53:59 +09:00
Lorenzo Colitti
51c1a95c82 Address comments on aosp/1559686.
Also remove some unnecessary line wrapping.

Test: atest TetheringTests
Change-Id: Ia7638b3198d7811cdbb34e959c50608cf1a656bf
2021-01-27 00:53:59 +09:00
Lorenzo Colitti
77262cea76 Add an isEmpty convenience method to BpfMap.
Test: new unit test
Change-Id: Ibec09f328e24111aee4760af2f75ea5a80ba84c3
2021-01-27 00:53:56 +09:00
Lorenzo Colitti
7bf39e56e1 Address a TODO in BpfMapTest.
Test: test-only change
Change-Id: I9a47234979cbb161dfcd0c97c54c0476aa753c5e
2021-01-27 00:53:02 +09:00
Lorenzo Colitti
5b1ed508cf Program the upstream IPv6 map in BpfCoordinator.
- Add methods to start and stop IPv6 forwarding upstream
- Populate the upstream IPv6 map when the first rule for any
  upstream/downstream pair is created.
- Clear the upstream IPv6 map when the last rule for any
  upstream/downstream pair is deleted.

Test: Added coverage to IpServerTest and BpfCoordinatorTest
Change-Id: Ib041081e95f5f449489ab63138de034222ffac8f
2021-01-27 00:52:09 +09:00
Lorenzo Colitti
d69a886235 Rename TetherDownstream6Value to Tether6Value.
The two value types are identical so there is no need to have
separate classes for them.

Test: atest TetheringTests
Change-Id: Ia622b082d0a44373d21f51222f5e675e5bde08e0
2021-01-27 00:52:09 +09:00
Lorenzo Colitti
3c35666892 Merge changes from topic "bpf_tether4_rename"
* changes:
  merge Tether{Down,Up}stream4{Key,Value} - part 3 - fixups
  merge Tether{Down,Up}stream4{Key,Value} - part 2 - java
  merge Tether{Down,Up}stream4{Key,Value} - part 1 - C portion
2021-01-26 13:01:22 +00:00
Lorenzo Colitti
a36d65da0a Mark the EntitlementManager PendingIntents as immutable.
These are read-only intents and should not be mutated by any
app receiving them.

Bug: 178324405
Bug: 178249531
Test: atest TetheringTests TetheringCoverageTests GtsTetheringTestCases
Change-Id: I5395e7c19e6453640ad790f2b9a9ba22bbcefa88
2021-01-26 15:14:26 +09:00
Lorenzo Colitti
ae27ecf5ad Fix a WTF in IpServerTest.
Bug: 178324405
Test: atest TetheringTests
Change-Id: I2069ea79f982e6bb197388edd7820a05d1e651f1
2021-01-26 15:14:26 +09:00
Maciej Żenczykowski
911a7267f5 merge Tether{Down,Up}stream4{Key,Value} - part 3 - fixups
Test: atest, TreeHugger
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: Ia7840698e80ded33d8e0b59efe1ca7267254b892
2021-01-25 20:32:10 -08:00
Maciej Żenczykowski
32874eb6bc merge Tether{Down,Up}stream4{Key,Value} - part 2 - java
Generated via:
  git grep 'Tether(Down|Up)stream4(Key|Value)' | cut -d: -f1 | sort -u | while read i; do
    sed -r -i 's@TetherUpstream4Value@Tether4Value@g' "$i"
    sed -r -i 's@TetherDownstream4Value@Tether4Value@g' "$i"
    sed -r -i 's@TetherDownstream4Key@Tether4Key@g' "$i"
    sed -r -i 's@TetherUpstream4Key@Tether4Key@g' "$i"
  done

  cd Tethering/src/com/android/networkstack/tethering
  git mv TetherUpstream4Key.java Tether4Key.java
  git mv TetherUpstream4Value.java Tether4Value.java

  git diff TetherDownstream4Key.java Tether4Key.java
  git diff TetherDownstream4Value.java Tether4Value.java
  git rm TetherDownstream4Key.java
  git rm TetherDownstream4Value.java

Fixup resulting 'import' duplication
  mcedit Tethering/apishim/31/com/android/networkstack/tethering/apishim/api31/BpfCoordinatorShimImpl.java
  mcedit Tethering/apishim/30/com/android/networkstack/tethering/apishim/api30/BpfCoordinatorShimImpl.java
  mcedit Tethering/apishim/common/com/android/networkstack/tethering/apishim/common/BpfCoordinatorShim.java
  mcedit Tethering/tests/unit/src/android/net/ip/IpServerTest.java

Test: N/A, requires follow up commit
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: I1dfc3108ca4bbd0cefc3420bc7e421594b62619c
2021-01-25 20:32:05 -08:00
Maciej Żenczykowski
1feb8b4ac8 merge Tether{Down,Up}stream4{Key,Value} - part 1 - C portion
The keys are identical, and the values nearly so, this will make everyone's life easier.

Test: git grep 'Tether(Down|Up)stream4(Key|Value)' finds nothing
  (note this requires follow up commits)
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: Ifbff2c617ac5834ea80f827eaf89ca81e862baec
2021-01-25 20:31:11 -08:00
Lorenzo Colitti
dc4189f0e4 Merge changes I8cd6e49b,Ibb52c7b7
* changes:
  [NFCT.TETHER.10] Add/delete IPv4 offload BPF rules to/from BPF map
  [NFCT.TETHER.9] Build IPv4 offload BPF rules for raw ip
2021-01-26 00:30:15 +00:00
Maciej Żenczykowski
c2b0146045 offload - begin ipv4 tethering implementation
Test: atest, TreeHugger
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: I0ad143be954d55d0ed39853031c7bd364378e1ec
2021-01-25 19:07:40 +00:00
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
Maciej Żenczykowski
18552e8fb3 offload - ignore ethernet packets not destined for us
Test: atest, TreeHugger
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: Icabd1db48a1189425a941384d534c0f18bf20827
2021-01-24 19:59:21 -08:00
Maciej Żenczykowski
bf8ec1a21d rename do_forward to do_forward6
Test: atest, TreeHugger
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: I649dc490b1883a1e97f748370a77c956f1315e2e
2021-01-24 19:59:16 -08:00
Remi NGUYEN VAN
36840ee2d3 Move connectivity-sources to frameworks/base
All sources for the connectivity module are being moved to
frameworks/base/packages/Connectivity, so that they can all be moved to
packages/modules/Connectivity in one move keeping history.

INetworkAgent and INetworkAgentRegistry were created in
packages/modules/Connectivity directly, but this makes managing the
sources until the move harder as the module needs to pull sources from
two different locations. Considering that they do not have history to
move, just move them to frameworks/base/packages/Connectivity without
the commit history.

Bug: 171540887
Test: m
Change-Id: I1c7e83267014bff29eb938c002d6441332101248
2021-01-25 11:47:28 +09:00
Nucca Chen
2f1c2b25cd Merge changes I73f30477,I84db13ac
* changes:
  [NFCT.TETHER.8] Prepare the upstream information for IPv4 offload rule
  [NFCT.TETHER.7] Prepare the downstream information for IPv4 offload rule
2021-01-23 13:40:30 +00:00
Maciej Żenczykowski
fc4f6540be bpf tether offload - do not offload TCP SYN/FIN/RST packets
We want connection establishment/shutdown to flow through
the kernel code path so connection tracking state is at least
somewhat correct.

Test: atest, TreeHugger
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: Iee97baa65750188f3436937b16c9b320f0495a5a
2021-01-23 07:11:07 +00:00
Roland Levillain
86654be2d8 Merge "Added aidl for qos callback" 2021-01-22 14:19:58 +00:00
Daniel Bright
c16bfcc7f7 Added aidl for qos callback
Bug: 155176305
Change-Id: I62958d041a8f544dbd98d5434e97ce89f843c5cb
2021-01-22 14:03:47 +00: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