Commit Graph

23 Commits

Author SHA1 Message Date
Treehugger Robot
662237f2f8 Merge "Improve RouterAdvertisementDaemonTest." 2021-04-08 04:07:14 +00:00
Xiao Ma
597d253f18 Improve RouterAdvertisementDaemonTest.
Add separate testing for unicast and multicast RAs.
Make the test more realistic by:
- Enabling forwarding. This ensures that the daemon actually
  receives the RS.
- Adding a link-local route. This ensures that the daemon is
  actually able to send a unicast response.

Bug: 154669942
Test: atest TetheringPrivilegedTests
Change-Id: Ibb1f51b5b1871657d7feff39335d3c71586cf64f
2021-04-08 11:02:02 +09:00
Nucca Chen
8ba40704f3 Merge changes I515be275,Ied159454,I5a29bdd1
* changes:
  bpf_progs - adjust for dstMac addition
  Populate the key destination mac address
  Set the limit whenever any IPv4 or IPv6 rule exists.
2021-04-07 14:08:37 +00:00
Maciej Żenczykowski
47851fc01b Merge "implement insertOrReplace()" 2021-04-06 08:17:42 +00:00
Maciej Żenczykowski
a36ea6fb19 implement insertOrReplace()
Test: atest com.android.networkstack.tethering.BpfMapTest
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: I4a40898f03293d6d79b57c35f743271c669a8ea7
2021-04-06 04:38:46 +00:00
Lorenzo Colitti
b6bffbca95 Fix DadProxyTest when forwarding is on.
When forwarding is on, DadProxyTest fails because forwarding
disables optimistic addresses. This results in the DAD proxy
getting EADDRNOTAVAIL.

Forwarding is on quite often on real hardware because many
solutions for wifi calling use forwarding.

Fix the test to retry after two seconds if the packet is not
forwarded on the first attempt.

It would also be possible to make this work more reliably in the
test by simply disabling DAD or disabling forwarding. However,
because DAD does happen in real usage (downstream interfaces
always disable DAD, but upstream interfaces don't), that seems
risky. For example, if the test disabled DAD, it would not catch
bugs where the DAD proxy crashed or stopped forwarding if it got
EADDRNOTAVAIL.

Test: atest TetheringPrivilegedTests on coral, which has forwarding on
Change-Id: I58280ef7c0e40371cd770ead4c8baa7190c288fd
2021-04-05 23:42:29 +09:00
Hungming Chen
9b8c60629f Populate the key destination mac address
Required because XDP offload needs input interface mac address
to be a part of the key. The mac address is used for checking
packets which are received from exceped input interface.

Test: atest TetheringCoverageTests, TetheringPrivilegedTests
Change-Id: Ied159454b516c0d70efe0a85744d1bb606892f2d
2021-04-01 18:30:43 +08:00
markchien
2af32e475f Add test for RouterAdvertisementDaemon.
bug: 154669942
Test: atest TetheringPrivilegedTests
Change-Id: I2bbea720c486d6bb47a8d86375847894e2b2f390
2021-03-15 08:20:57 +00:00
Lorenzo Colitti
ffb0ccd04b Add a BpfMap#clear method.
A caller can mostly already do this via forEach(), but having a
specific method is faster (since the code does not need to read
the value) and easier to use.

The semantics of this method (e.g., ignore ENOENT while deleting
a key, but throw on any other error) match those of the native
BpfMap::clear method.

Test: new unit tests
Change-Id: I5cd32efd0f87c823cd2d0a2fa3a95a83093fb6f9
2021-02-24 06:09:46 +00: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
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
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
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
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
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
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
Remi NGUYEN VAN
71b9e93a83 Use IpUtils, NetworkStackConstants in DadProxyTest
The test had TODOs to address to use IpUtils and NetworkStackConstants
classes once they were moved to frameworks/libs/net. This is now done,
so using the new classes.

Bug: 158042941
Test: atest TetheringPrivilegedTests
Change-Id: I536b4506dbc3b42547ba9cb4e7c3c7a3e9459dd1
2020-10-13 11:30:03 +09:00
Remi NGUYEN VAN
2494a06bb3 Move IpUtils to frameworks/libs/net
The utility classes are useful for mainline modules and their tests, for
example IpClientIntegrationTest.

Bug: 168868607
Test: m && atest NetworkStaticLibTests
Change-Id: If2b1613aa18a7990391e2d31cc2951ca93f1cf3c
2020-10-05 14:38:19 +09:00
Lorenzo Colitti
c99ef48090 Fix OffloadHardwareInterfaceTest.
r.android.com/1424920 changed the code but forgot to update the
unit test.

Also fix some lint errors.

Bug: 149109043
Test: atest TetheringTests TetheringPrivilegedTests
Change-Id: I53ca4b9877dcb4a759dee6ec63133653315d826f
2020-09-30 17:04:19 +09:00
Tyler Wear
7f70074abc tethering: offload: Netlink Req NfGen
Add the netfilter generic message header to
the netlink req. This is needed so the kernel
won't ignore the request for invalid params.

Bug: 149109043
Test: ConntrackSocketTest
Change-Id: I1757fdeb11a0cac5821021a22323cbd74fe22bdc
2020-09-30 15:07:47 +09:00
Tyler Wear
90e4063fd2 tethering: DAD Proxy Daemon
DAD proxy daemon responsible for forwarding NS/NA between
tethered iface and upstream iface.

Change-Id: I2e58e10e7fa7dba6a6f63ad03b000549f3afc37e
2020-09-22 11:58:49 -07:00