Commit Graph

437 Commits

Author SHA1 Message Date
Remi NGUYEN VAN
bfd0aa022e Revert "Extract network observer code from NetworkManagementService."
This reverts commit d8bc829a85.

Reason for revert: Refactoring was unnecessary

Merged-In: Ib4e7da3274e49f25676505a08e6ce7e7b0dfdb8d
Change-Id: Iff332c680315b560f0b762c1d7311ec83d539115
2019-01-29 10:21:19 +00:00
Lorenzo Colitti
d8bc829a85 Extract network observer code from NetworkManagementService.
This will allow us to use network observers in the NetworkStack
app without duplicating too much code.

Bug: 112869080
Test: atest FrameworksNetTests
Test: builds, boots, wifi works
Change-Id: If54fa3a88110ffa815899d385dbb0d5770abaead
2019-01-25 00:41:57 +09:00
Remi NGUYEN VAN
e693d49c0a Merge changes I1250730c,I7d00848c
* changes:
  Create a wrapper for IpClient
  Move IpClient to NetworkStack
2019-01-23 15:05:00 +00:00
Lorenzo Colitti
e62097f71d Merge "Stop depending on the ConnectivityService default request." 2019-01-23 12:29:40 +00:00
Lorenzo Colitti
ed3168e9e3 Stop depending on the ConnectivityService default request.
This avoids the need to expose ConnectivityService implementation
details as @SystemApi and the complexities that would be required
to make NetworkCapabilities parcelable in stable AIDL.

Bug: 112869080
Test: atest FrameworksNetTests NetworkStackTests
Change-Id: Icd5d25b9b8e9b7a7d1899b000c92dc4976c3b3d7
2019-01-23 18:10:06 +09:00
Remi NGUYEN VAN
c6304b8741 Create a wrapper for IpClient
The wrapper allows migrating clients of the IpClient in the NetworkStack
independently.

Test: atest FrameworksNetTests NetworkStackTests FrameworksWifiTests
Bug: 112869080
Change-Id: I1250730c07166298bee2816f05351ba95416994a
2019-01-23 16:44:32 +09:00
Remi NGUYEN VAN
3c600a15a1 Move IpClient to NetworkStack
Test: atest FrameworksNetTests NetworkStackTests
Bug: b/112869080
Change-Id: I7d00848c052382cd1b6ce458868bed6a1e9e8ec5
2019-01-23 16:44:21 +09:00
Remi NGUYEN VAN
97f69c2f8d Add getAvoidBadWifi system API
This helps remove the dependency on MultinetworkPolicyTracker from
IpClient.

Test: atest FrameworksNetTests NetworkStackTests
Bug: 112869080
Change-Id: If56791dbed564772f25a859f301b8b52d84e38a3
2019-01-22 15:57:34 +00:00
Remi NGUYEN VAN
06adb08d27 Merge "Remove InterfaceController dependency on NMS" 2019-01-22 13:14:06 +00:00
Remi NGUYEN VAN
491f53523a Merge changes Ieef54d84,Ica3e88c2
* changes:
  Remove NetworkStack dependencies on hidden members
  Expose ServiceSpecificException as @SystemApi.
2019-01-22 13:00:10 +00:00
Remi NGUYEN VAN
91c81c13b6 Merge "Add SystemApi utility for raw sockets." 2019-01-22 12:38:33 +00:00
Remi NGUYEN VAN
d1b51a3228 Remove InterfaceController dependency on NMS
Test: atest FrameworksNetTests NetworkStackTests
Bug: 112869080
Change-Id: Ib3773068b087f58f4ac3394291cda132b00b2dcc
2019-01-22 20:25:48 +09:00
Remi NGUYEN VAN
c1c02dcb65 Remove NetworkStack dependencies on hidden members
- DhcpClient only shares its handler with IpClient, and NetworkMonitor
   has its own handler: remove Protocol.BASE_DHCP,
   Protocol.BASE_NETWORK_MONITOR
 - Remove dependency on Network.netid in NetworkMonitor
 - Remove dependency on Sets.newArraySet in DhcpServingParams
 - Remove dependency on formatDuration() in DhcpClient
 - Replace isMetered() with hasCapability() in NetworkMonitor
 - Use WifiManager.isScanAlwaysAvailable instead of reading setting

Test: atest FrameworksNetTests NetworkStackTests
Bug: 112869080
Change-Id: Ieef54d847ddc081fb33cbad0b050b06d2e52548e
2019-01-22 18:48:12 +09:00
Remi NGUYEN VAN
811f6385be Add SystemApi utility for raw sockets.
Test: atest FrameworksNetTests NetworkStackTests
Bug: 112869080
Change-Id: Id228bf3317b6933314174571697ee256b2f18452
2019-01-22 17:50:33 +09:00
Remi NGUYEN VAN
94a055737e Add LinkProps and NetworkCaps methods to SystemApi
Added methods are used by the NetworkStack.

Test: atest FrameworksNetTests NetworkStackTests
Bug: 112869080
Change-Id: I8822d43c1a4981ca39289525685b3f975fb0e8d5
2019-01-22 16:57:16 +09:00
Remi NGUYEN VAN
8586a43f31 Merge "Add NetworkStack metrics to system API" 2019-01-22 07:48:39 +00:00
Remi NGUYEN VAN
e7e9f2befe Fix lint errors for moving IpClient to NetworkStack
Test: checklint at upload, m
Bug: 112869080
Change-Id: I82fb9c9037cc0a9d3c80958d64552ff1ef0a90ab
2019-01-22 13:12:08 +09:00
Remi NGUYEN VAN
60b9ad2ec3 Merge "Add IIpClient API for IpClient" 2019-01-22 01:10:17 +00:00
Remi NGUYEN VAN
7b84fb336f Add NetworkStack metrics to system API
Test: atest FrameworksNetTests NetworkStackTests
Bug: 112869080
Change-Id: Ie52c55f248c173e2a5ee603ecd004fbac9004ac1
2019-01-21 23:24:41 +00:00
Remi NGUYEN VAN
79a6d5e30c Merge "Add fields used by NetworkStack to the API" 2019-01-21 23:20:26 +00:00
Remi NGUYEN VAN
31f1d0cd8d Add fields used by NetworkStack to the API
Test: m
Bug: 112869080
Change-Id: I59f6d5ae8a601b7496548b87f137a577f2365a37
2019-01-21 23:03:25 +09:00
Tobias Thierer
c2c7ee1963 Replace uses of libcore.io.SizeOf with X.BYTES.
libcore.io.SizeOf is an internal API and is going away soon.

Note: The files touched by this CL have some other unused
imports which I did not touch. Therefore I had to use
"repo upload --no-verify" to upload this CL to gerrit.

Bug: 123174577
Test: Manually checked that this CL applies cleanly in internal
      master and that no other uses of SizeOf then remain in
      internal master's frameworks/base
Test: Treehugger
Change-Id: Ib29a195f3dda2f21ebbe2f7073e0af4dbb524b19
2019-01-21 11:34:34 +00:00
Remi NGUYEN VAN
a5d31f53b6 Add IIpClient API for IpClient
The API will be used to interact with IpClient once it is moved to the
NetworkStack process.
This change keeps compatibility with the previous API so that clients
can be migrated independently.

Test: atest FrameworksNetTests NetworkStackTests
Bug: b/112869080
Change-Id: I57d8164afae849230bbc0e25f17859c0b22d0f29
2019-01-21 18:25:46 +09:00
Remi NGUYEN VAN
6b0b2b735e Add stable AIDL parcelables for IIpClient API
Test: atest FrameworksNetTests NetworkStackTests
Bug: b/112869080
Change-Id: Ia4ac1eb482850a06c4dc1b6c1fe55d33d4087388
2019-01-21 12:54:24 +09:00
Remi NGUYEN VAN
4855a2e2c6 Add stable AIDL parcelables for LinkProperties
Test: atest android.net.shared.LinkPropertiesParcelableUtilTest
Bug: b/112869080
Change-Id: I2b69980e25bae9f51fb5b8cd3cafb403e6bd53da
2019-01-17 13:11:12 +09:00
Remi NGUYEN VAN
e67b0c3aee Move NetworkMonitor to NetworkStack
Bug: b/112869080
Test: atest FrameworksNetTests NetworkStackTests
Change-Id: I1b8b6a3f4390adbabf92fb9e48da61c47b08b2ec
2019-01-11 09:59:11 +09:00
Remi NGUYEN VAN
0e3d0923a6 Move DhcpServer to NetworkStack app
Test: atest FrameworksNetTests && atest NetworkStackTests
Bug: b/112869080

Change-Id: I96c40e63e9ceb37b67705bdd4d120307e114715b
2019-01-09 15:42:16 +09:00
Remi NGUYEN VAN
73105e1143 Fix linter errors in IpServer and its dependencies
Test: atest FrameworksNetTests NetworkStackTests
Change-Id: I534b391458433ac24dffe78f287e3c83a264acfd
2019-01-08 11:07:58 +09:00
Remi NGUYEN VAN
761198a05d Add parceling for DhcpServingParams
Introduce a stable AIDL parcel class, DhcpServingParamsParcel, and
methods to convert to and from that class to DhcpServingParams.
This will be used to move DhcpServer to the NetworkStack app.

Test: atest FrameworksNetTests
Bug: b/112869080
Change-Id: I276b7affccb938059769c90a53f0f6beb26e6ede
2019-01-07 12:07:18 +09:00
Remi NGUYEN VAN
9d5e00321f Merge "Replace InterfaceParams with ifName in DhcpServer" 2018-12-18 03:38:24 +00:00
Remi NGUYEN VAN
155da48519 Replace InterfaceParams with ifName in DhcpServer
The current code only uses InterfaceParams#name, and InterfaceParams is
defined in services/net which DhcpServer cannot depend on once moved to
a separate app.

Test: atest FrameworksNetTests
Bug: b/112869080
Change-Id: I94c7dce33200c111666a9dddde82ac2e66a6794f
2018-12-17 15:15:16 +09:00
Aaron Huang
04ed6a3592 apf: Drop ARP reply if SPA is 0.0.0.0
Some network re-writing packet from broadcast MACs to unicast,
result in this kind of packets cannot be dropped by APF filter.
Thus, drop ARP reply if source IP is 0.0.0.0.

Note: Linux kernel always ignores such replies in the function arp_process().

Bug: 118044271
Test: runtest frameworks-net -c android.net.apf.ApfTest
Change-Id: Id293bf231913d9b483ce7d8dd909e05fa927ccd7
2018-12-10 14:18:14 +00:00
Aaron Huang
785e5f1f96 Add an APF unit test to drop all packets in the pcap file
Read a pcap file and runs it through APF filter, then checks whether all
packets in the file are dropped.

Test: runtest frameworks-net -c android.net.apf.ApfTest
Change-Id: I7fc59864608762cd2bc84131817183846b0bf5b5
2018-12-10 21:05:14 +08:00
Treehugger Robot
2a520365da Merge "Remove unused imports of libcore.io.Libcore." 2018-10-13 00:47:45 +00:00
Neil Fuller
031dfa6f33 Remove unused import
StructGroupReq is imported but not used.
The import can be removed.

Bug: 113148576
Test: build only
Change-Id: I6b2ec5eb3f6c6e298fcde8e47dfd0979f889ca1d
2018-10-10 17:17:56 +01:00
Tobias Thierer
30ff7a093e Remove unused imports of libcore.io.Libcore.
Test: Treehugger
Bug: 115503977
Bug: 117548625
Change-Id: I122fa68ddc2bd531f627dcac00834b47249bd56e
2018-10-10 15:49:51 +00:00
Remi NGUYEN VAN
3b12359e4c Merge "Send hostname and MTU options in DHCP ACK/OFFER" 2018-10-04 01:08:19 +00:00
Remi NGUYEN VAN
f90a92bb7b Send hostname and MTU options in DHCP ACK/OFFER
The hostname option is only sent when requested in the requested
parameters option. This matches current behavior.

Test: with aosp/763982, regression tests now all pass
      atest FrameworksNetTest
Bug: b/109584964
Change-Id: I793173fa893750ddbe72be09f4c2d70e5b285837
2018-10-01 11:01:39 +09:00
Remi NGUYEN VAN
f5d65c521c Don't throw a NPE in SharedLog#e
Some DhcpServer error code paths could cause a NPE, when the logError
callback was called without an exception. Allowing SharedLog#e to be
called with a null Throwable is less error-prone.

Bug: b/109584964
Test: atest FrameworksNetTests
Change-Id: Idbcdd330a9d1951b27aaf525aaf12e52e102872c
2018-09-27 12:20:15 +09:00
Jeffrey Vander Stoep
f8529dc891 Merge "Add ConnectivityManager.getConnectionOwnerUid()" 2018-09-21 21:04:20 +00:00
Jeff Vander Stoep
0ac2c0945b Add ConnectivityManager.getConnectionOwnerUid()
Allow VPN apps to lookup the UID owner of a network connection.

Requires specifying the:
 - IP address and port for both the source and destination of a TCP
   connection.
 - IP address and port for either source and destination or just
   source for a UDP connection.
Only TCP and UDP protocols are supported. Only connections for UIDs
that apply to the calling VPN app will be resolved. This is intended
to replace direct app access to /proc/net/{tcp,tcp6,udp,udp6}.

The implementation uses netlink inet_diag sockets[1] to perform
the lookup on TCP sockets as well as UDP sockets when supported
(kernel has CONFIG_INET_UDP_DIAG=y).

[1] http://man7.org/linux/man-pages/man7/sock_diag.7.html

Bug: 9496886
Bug: 109758967
Test: atest HostsideVpnTests
Test: atest InetDiagSocketTest on Taimen with CONFIG_INET_UDP_DIAG
    and on Sailfish without CONFIG_INET_UDP_DIAG.
Change-Id: I2bbc7072dd091e2e653dadf6dc05024c04180f34
2018-09-21 06:16:09 +00:00
Erik Kline
8e492f8de4 Use IPv6 hop limit from upstream interface.
Test: as follows
    - built, flashed, booted
    - runtest frameworks-net passes
    - manually setting /proc/sys/net/ipv6/<upiface>/conf/hop_limit
      to various value yields RAs with expected hop limit settings
      in downstream RAs
Bug: 32163131
Change-Id: I248154ca9d836318bf21a2971d0884040525d9fc
2018-09-14 18:46:25 +09:00
Erik Kline
7a4ccc69d0 Initial rename to IpServer
Rename TetherInterfaceStateMachine to IpServer. IControlsTethering
is folded into IpServer.Callback and some of the dependencies in
TetheringDependencies are moved into IpServer.Dependencies.

Several things still need fixing, including:
    - convert message passing into method calls
    - the calls that enable forwarding should be moved up out of
      IpServer into the Tethering layer above it

Test: as follows
    - built, flashed, booted
    - runtest frameworks-net passes
Change-Id: I015f800ed23c8aa5c8c81a74d7b508abfcaab659
2018-09-13 15:46:01 +09:00
Erik Kline
95999bda8d Remove the last of the ResolvUtil uses
This is the completion of cleanup work started in aosp/674269.
Consequently, also remove ResolvUtil.

Test: as follows
    - built, flashed, booted
    - runtest frameworks-net passes
    - presubmit
Bug: 64133961
Bug: 72345192
Bug: 73872000
Bug: 78548486
Change-Id: I980f8a9b67f3f06f2d97a60f8e58e92c36316d40
2018-09-12 14:58:58 +09:00
Jacob Abrams
56fbfc0460 Fix ConcurrentModificationException crash due to race in IpClient
Bug: https://issuetracker.google.com/issues/114838819

Test: manual
Change-Id: Ifd1522ccaca10c0416fc2d00641c4effee37fc6c
2018-09-12 00:23:26 +00:00
Treehugger Robot
666bb5cf28 Merge "Try to set the hop limit to something suitable for 64share" 2018-09-11 05:55:37 +00:00
Erik Kline
5b43cea3c8 Tighten up neighbor timers if IpReachabilityMonitor is in use
Currently the kernel sends 3 probes, 1000ms apart when a neighbor is
in NUD_PROBE state (either naturally or artificially moved to that
state when, for example, confirming network configuration following
an AP association/roam).

With this change the device sends 5 probes at 750ms apart.  This
gives the network infrastructure a chance to respond to any of
5 probes instead of any of only 3, at a cost of increasing the total
probe time from 3s to 3.75s.

Future changes may read these values from settings (or from somewhere
else) so that experiments may be conducted or values adjusted based on
other information.

Test: as follows
    - built, flashed, booted
    - runtest frameworks-net passes
    - examinaton of /proc settings on wifi shows updated values
    - connected to a test network, disconnected the backhaul, ran
      "adb shell dumpsys wifi ipclient confirm" while watching
      "adb shell tcpdump -n -i wlan0 -l -vv arp", and observed
      5 ARP who-has ("solicits") ~750ms apart.
Bug: 62476366
Bug: 62845299
Change-Id: Ib805531b08624805bb63703a5b338b9ff48171d4
2018-09-06 11:41:39 +09:00
Erik Kline
abb70339ea Try to set the hop limit to something suitable for 64share
Introduce hopLimit into RaParams so in future the value can be passed
in from the control plane up in Tethering.

Test: as follows
    - built, flashed, booted
    - runtest frameworks-net passes
Bug: 32163131
Change-Id: I8d2f056dcd55d76e89199db1196754fb690250e8
2018-09-05 17:08:07 +09:00
Remi NGUYEN VAN
e1a1dcc994 Ignore DHCP discover and request w/ invalid giaddr
This matches previous behavior, and there could be situations where
another server on the network would be configured to reply to such
requests, so not replying is better than sending NAKs as done now.

Also refactoring requests in DhcpLeaseRepositoryTest and replacing some
INETADDR_UNSPEC usages for giaddr with INET4_ANY (giaddr is a BOOTP
field and can't be unspecified, only empty).

Test: Following DhcpServerTest.py regression tests pass:
      test_request_selecting_giaddr_outside_subnet
      test_discover_requestaddress_giaddr_outside_subnet
      test_discover_knownaddress_giaddr_outside_subnet
      test_discover_giaddr_outside_subnet
      Also: atest FrameworksNetTests passes
Change-Id: I4decffccfc64d5e0e29c9ce1cf1446644fcf8190
2018-08-31 13:23:39 +09:00
Remi NGUYEN VAN
8975ab6322 Send ciaddr in DHCP server ACK if set by client
RFC2131#4.3.1 specifies that ciaddr should be set to the "'ciaddr' from
DHCPREQUEST or 0". Previous behavior sets ciaddr if provided by the
client in DHCPREQUEST, so keeping this behavior.

Bug: b/109584964
Test: DhcpServerTest.py debian/macos/win10 renewing test pass
Change-Id: I283e88b1f66f39d24589c5af4518cf9a2e77b95d
2018-08-30 18:23:23 +09:00