History log of /frameworks/base/services/net/java/android/net/apf/ApfFilter.java
Revision Date Author Comments (<<< Hide modified files) (Show modified files >>>)
8d65db32eba568be3df36247e02ee32f5284e89a 09-May-2018 Bernie Innocenti <codewiz@google.com> Disable APF memory clear on pre-APFv4 devices

Fixes a system crash on HU when connecting to a wifi AP.

Change-Id: I8b71323985b6c5fc8a75f99470c9f86343d57f90
Bug: 78905546
Test: manually on android auto device
/frameworks/base/services/net/java/android/net/apf/ApfFilter.java
3cc40ea6c50c976dd4e6485574a8be899867f610 23-Apr-2018 Bernie Innocenti <codewiz@google.com> apf: Add counters for dropped / passed packets

ApfFilter maintains separate counters for each reason why a packet was
passed or dropped by the filter logic.

There's also a total which should match the individual counters,
*unless* the APF interpreter aborted execution early due to an illegal
instruction or an out-of-bounds access.

Test: both on APFv2 and APFv4-capable device:
runtest -x tests/net/java/android/net/ip/IpClientTest.java
runtest -x tests/net/java/android/net/apf/ApfTest.java
manual tests connected to an AP
Bug: 73804303
Change-Id: I54b17fcbb95dfaea5db975d282314ce73d79d6ec
/frameworks/base/services/net/java/android/net/apf/ApfFilter.java
408dbda4c1fbee064c7878ef5cfb000e58027a5f 22-Mar-2018 Bernie Innocenti <codewiz@google.com> Teach ApfGenerator about the new opcodes for accessing data memory

Bug: 73804303
Bug: 36221302
Test: runtest -x tests/net/java/android/net/apf/ApfTest.java
Change-Id: Iaf92ca0bbebaaf66d0f2f7adc1a9014607f3ecf6
(cherry picked from commit a9949e9e2599c5f97bf83c12c8f4fa66be9dd294)
/frameworks/base/services/net/java/android/net/apf/ApfFilter.java
5be71dcb03ff689098d992c5455f0a1766c8a2e0 28-Mar-2018 Bernie Innocenti <codewiz@google.com> APF: drop multicast ICMPv6 while in doze mode

Some WiFi hotspots send excessive multicast IPv6 ping requests which
cause considerable power drain. Thus, drop all multicast ICMPv6 ping
requests while the device is in doze mode.

Bug: 66930077
Test: runtest -x tests/net/java/android/net/apf/ApfTest.java
Test: manual - compared generated APF bytecode using apf_disassembler
Test: manual - force idle mode while sending multicast pings to device
Change-Id: I25dbf99985cf4413b4d0e3920d281fe6d663197a
(cherry picked from commit e2c70f8a6092f740ea10e7476b33860d756cf94f)
/frameworks/base/services/net/java/android/net/apf/ApfFilter.java
bbab23ff97688f33c5cc41d5d0e134c0d9f58c6c 08-Feb-2018 Andreas Gampe <agampe@google.com> Frameworks: Annotate trivial @GuardedBy in services/ misc

Add @GuardedBy for simple functions that require a single lock
and are named XYZLocked.

Derived by errorprone.

Bug: 73000847
Test: m
Test: m javac-check-framework RUN_ERROR_PRONE=true
Change-Id: Id1d9fbe5018250e3b9d1466fc5f670d5ad902fa3
/frameworks/base/services/net/java/android/net/apf/ApfFilter.java
8bd00d5f7ced34a45173e45537dc3100d62ee6a5 08-Dec-2017 Erik Kline <ek@google.com> Refactor to InterfaceParams utility class

NetworkInterface throws Exceptions every time you look at it askance.
Try to make something we instantiate fully, once, and pass it around.

Partial MacAddress-ification as well, for good measure.

Test: as follows
- built
- flashed
- booted
- runtest frameworks-net passes
- basic IPv6 tethering works
Bug: 32163131
Bug: 62476366
Change-Id: I16c145fddb4e76387370338d792a438eed886d7f
/frameworks/base/services/net/java/android/net/apf/ApfFilter.java
7216636a621d413453947c1d40feaec9948fed73 13-Oct-2017 Hugo Benichi <hugobenichi@google.com> Refactor ApfFilter creation

This patch introduces a helper ApfConfiguration class for passing filter
parameters to the constructor of ApfFilter. The benefits are:
- less parameter boilerplate across IpManager, ApfFilter, ApfTest
- easier to add more parameters in the future (useful for hardware
counters options and further gservices configurable options)

There is no functional changes otherwise.

Test: runtest frameworks-net
Change-Id: I47231c21df80bc36b6d4e15369748017b50b8da1
/frameworks/base/services/net/java/android/net/apf/ApfFilter.java
1b2935806fbb3da7efda8d11bf8d00cdf4ec4c12 11-Oct-2017 Erik Kline <ek@google.com> Rename IpManager to IpClient

Test: as follows
- built
- flashed
- booted
- runtest frameworks-net passes
Bug: 62476366
Change-Id: I36255a2c8e1a2f52693716b445359cce0b4304af
/frameworks/base/services/net/java/android/net/apf/ApfFilter.java
fd424169a1ffb549806f27e5478aa0700416296a 02-Aug-2017 Ahmed ElArabawy <arabawy@google.com> Add APF black list for ether-type

Add a configurable black for protocols which packets are to be dropped
by APF. This enales an OEM to configure the APF to filter out un-needed
packets from reaching the host

Bug: 62415182
Test: runtest frameworks-net

Merged-In: I86335a0f854d5e83a2b2767978cd69b2cc25c2f8

Signed-off-by: Ahmed ElArabawy <arabawy@google.com>

(cherry picked from commit caffbe127726c6a9ab5dd023a9b09cfa43eac617)

Change-Id: I15a758d18464d73d24ba8364a867904bb3cd3b34
/frameworks/base/services/net/java/android/net/apf/ApfFilter.java
70291ef1d79d62f7c55bf147c878f45db9d1a490 20-Jul-2017 Ahmed ElArabawy <arabawy@google.com> Merge "Add Configuration to APF Policy"
am: d27a6d62c6

Change-Id: I491bad86e4e9ae7a813ac214b06273719a583079
8537c58cc8c07e39e016e217a4033a7652d84794 13-Jun-2017 Ahmed ElArabawy <arabawy@google.com> Add Configuration to APF Policy

in b/37702435 battery was drained due to reception of
Ethernet frames with Eth-type < 0x600 (non ehternet II frames)

This change adds an XML file to drop/allow these frames
Dropping helps tp avoid acquiring a wakelock for the
reception of these packets, while allowing them may be needed
for some protocols
The Change allow the OEM to override the system settings

Bug: 37702435
Test: runtest frameworks-net
Merged-In: Idb6c215896ef230a8136ff4ecefc90ccdc5c1c6d
Merged-In: I16346bb98a0b9259f7c3f51e318c472cfc1bb492

Signed-off-by: Ahmed ElArabawy <arabawy@google.com>

(cherry pick from commit 4dd7c58fc8fcc5a2c50de5e8eff05ddc5c3b0b8b)

Change-Id: Ie466baf1e6395d6c28245e41179232ea8e523845
/frameworks/base/services/net/java/android/net/apf/ApfFilter.java
5bb63befb8ce288a1d31bad4e19c1889fdb3e00d 25-May-2017 Joel Scherpelz <jscherpelz@google.com> Merge "Ignore flow label when comparing RAs in APF" am: 81fda77884 am: 6ccdb3fe19
am: ef0bd781b1

Change-Id: I53c2a493946ecc4e5617bcd3f5e64ff0b82fedf2
967dec794b1974574d95c9d2dea0a0133fa19717 24-May-2017 Joel Scherpelz <jscherpelz@google.com> Ignore flow label when comparing RAs in APF

This change modifies the RA filter generation code to ignore bytes 1-3
of the IPv6 header. It also updates testApfFilterRa such that it fails
without the updates to ApfFilter.

Test: as follows
- built
- flashed
- booted
- sent RAs from OS X with differing flow labels and observed
that they were filtered
- ApfTest passes
Bug: 31166495

(cherry picked from commit 7006bd4fe5eba4b6fad43dd28d9cad2d26ce140a)

Change-Id: I32153238193ac13a0e59be1875d983a0567c41c7
/frameworks/base/services/net/java/android/net/apf/ApfFilter.java
7a0191b355f8374480c695a13c7b7bec9ce23d52 24-Apr-2017 Hugo Benichi <hugobenichi@google.com> Merge "Move byte logics from ApfFilter into BitsUtil" am: 21b9b3a8ff am: 12c1074c8b
am: a80bb82b4e

Change-Id: I5f13b006b57cc8a3ab0560626077d003ce4fe8c8
495a17b332e57ea4c0162a4ae63d820b947e3719 12-Jan-2017 Hugo Benichi <hugobenichi@google.com> Move byte logics from ApfFilter into BitsUtil

This patch extracts into BitUtils byte manipulation helper methods
and unsigned type manipulation helper methods from ApfFilter into
an independent and reusable structure.

Test: $ runtest frameworks-net
Change-Id: I0f33af10457a63dbde5983f14353a79b8cd877d9
/frameworks/base/services/net/java/android/net/apf/ApfFilter.java
22d9b2d430c9a4fe17b54811bb77289b821e32db 22-Feb-2017 Hugo Benichi <hugobenichi@google.com> IP connectivity metrics: add new APF counters.

This patch adds a few missing counters to APF events:
- an actual lifetime duration to ApfProgramEvent.
- counters for total number of updates to ApfStatistics.

ApfProgramEvents are now recorded at program removal in order to
populate the actual lifetime of the program. ApfProgramEvents whose
actual lifetime was less than 1 second are filtered out.

Finally, instance fields of ApfProgramEvent and ApfStats classes are
made mutable to allow for simple record-like creation. This was not
possible when these classes were tagged @SystemApi.

Test: - manually verified output of $ dumpsys connmetrics list
- unit tests updated.
Bug: 34901696

Change-Id: I02694ebb9421ce1c2aa757fa6aa209d19a654dcd
/frameworks/base/services/net/java/android/net/apf/ApfFilter.java
4456f33a958a7f09e608399da83c4d12b2e7d191 19-Dec-2016 Hugo Benichi <hugobenichi@google.com> ApfTest: fix flaky testApfFilterRa.

testApfFilterRa is failing with probabiliy 1/10 ~ 1/15 on the following
assert: assertDrop(program, packet, lifetime/6), for lifetime values
that are multiple of 6, where 6 is the hardcoded fraction of RA lifetime
to filter in ApfFilter.java.

When the lifetime is not a multiple of 6, the remainder of 1 to 5
seconds gives enough margin so that when the APF program is simulated
the faked lifetime of the program is less than lifetime/6 away and the
packet is dropped.

However for lifetimes which are exact multiples of 6, this margin is
always 0s and that result in nondeterminism in the result. This is
consistent with the obervation that the only failed assert was for a
lifetime of 300s, the only multiple of 6.

This can be observed by detecting the age limit at which the filter
stops dropping packet oscillating between lifetime/6 and lifetime/6 + 1
for lifetimes which are multiple of 6.

This patch fixes the flakyness by freezing the flow of time in tests so
that the expected filter age threshold is consistent and stable.

Test: no failure observed in 1000 runs.
Bug: 32561414
Change-Id: I5251d047039f34b82ce8a5d20ae46563e1e0cce8
/frameworks/base/services/net/java/android/net/apf/ApfFilter.java
02428988ad90a2bd294b9ce752c2fced5b649519 02-Dec-2016 Hugo Benichi <hugobenichi@google.com> DO NOT MERGE: APF: also drop any ICMPv6 RSs

Test: new unit test + $ runtest franeworks-net
Bug: 32833400

(cherry picked from commit f98182ef5e80ede5de7f2c2a5f40fc92a46c9704)

Change-Id: Ifaf6e778c811c7d865c790a293b1fce3f43cad1c
/frameworks/base/services/net/java/android/net/apf/ApfFilter.java
dafc44ea11972b3152e67dc305a98d658f1465ba 17-Oct-2016 Hugo Benichi <hugobenichi@google.com> DO NOT MERGE: ApfFilter: use elapsedRealTime for RA lifetime

This patch replaces System.currentTimeMillis() with
SystemClock.elapsedRealTime() to make RA lifetime computation more
resilient to various external events inducing jumps in
currentTimeMillis().

Test: ApfTest passes.

(cherry picked from commit 305af8e98a4fce712c1a93daf3b050dac2e8b91a)

Change-Id: If19011fc0c905948f2e42b975cfcc5f8672a95fb
/frameworks/base/services/net/java/android/net/apf/ApfFilter.java
4104ff922040540b73f79f0f89dab3ae42b50462 13-Oct-2016 Hugo Benichi <hugobenichi@google.com> DO NOT MERGE: ApfFilter: systematically use u8, u16, u32 getters

This patch adds a getUint8 getter for ByteBuffers and changes ApfFilter
to make uses of getUint8/16/32 everywhere.

The return types of getUint16 is also changed from long to int, which
will expand gracefully to long as an unsigned int as it is guaranteed to
be positive after getUint16.

Test: ApfTest passes

(cherry picked from commit 995dd94673005b43d32456e2de5fda0090b23576)

Change-Id: I606ebc5aedfcacde400d27cc6bc37145769b122c
/frameworks/base/services/net/java/android/net/apf/ApfFilter.java
0668a61d82a424fb3714b6222f0e4213c18fc7b1 06-Oct-2016 Hugo Benichi <hugobenichi@google.com> DO NOT MERGE: Add fuzzing tests to ApfFilter RA processing

Test: added new unit tests

(cherry picked from commit 8acea76a2b7555b3bd5ca1170cca9d09e979fafc)

Change-Id: I847d7e4895766042043c0bba1c9b9a698a705d87
/frameworks/base/services/net/java/android/net/apf/ApfFilter.java
7d21eaedade0e01bed665dd2e4ba15e0c217237c 02-Sep-2016 Hugo Benichi <hugobenichi@google.com> ApfFilter: take into account IPv4 subnet prefix

When IPv4 is provisioned on an interface with Apf capabilities,
ApfFilter will only keep track of the raw ipv4 address, with no
information about the subnet or prefix length.

This patch adds the missing prefix length information to ApfFilter. This
allows to calculate the subnet broadcast ipv4 address for more
precise ipv4 broadcast filtering when the multicast lock is not held.

Bug: 30231088

Change-Id: Iebaec040703647c4ced30bb585be173e97a1fae5
/frameworks/base/services/net/java/android/net/apf/ApfFilter.java
0dc1d314709d579ccdc3fc59a5f66557f6cd319d 01-Sep-2016 Hugo Benichi <hugobenichi@google.com> ApfFilter: more precise IPv4 broadcast filter

This patch refines the Apf IPv4 filter for interfaces with Apf
capabilities to drop packets when:
- the multicast lock is not held
- the packet is an IPv4 packet
- the packet is not a DHCP packet addressed to us
- the packet is L2 broadcast, or IPv4 multicast, or IPv4 broadcast
- caveat: subnet broadcast address is not checked.

This allows to drop IPv4 broadcast packets whose MAC destination
address is not the L2 broadcast address but the current address of the
interface. Such packets can be received on network that rewrite L2
addresses and can put significant pressure on battery by waking up the
phone unnecessarily.

Bug: 30231088

Change-Id: I8b1785fc5ceadaa1f2881765983e502135dcbc46
/frameworks/base/services/net/java/android/net/apf/ApfFilter.java
961ca49fd67b39d8076ea49d12d2fda73f581399 02-Sep-2016 Hugo Benichi <hugobenichi@google.com> Better IPv4 multicast coverage in ApfTest

This patch improves the test coverage of ApfFilter for IPv4 broadcast and
multicast traffic.

Bug: 30231088
Change-Id: I2e1d5d5a7cbae17f3d5978a4cf5f10666b5c6104
/frameworks/base/services/net/java/android/net/apf/ApfFilter.java
4b545b04f6533b5e0377f2d2dec219ad816e47ed 20-Jul-2016 Paul Jensen <pauljensen@google.com> Sanity check ICMP6 router advertisement packets

There is a chance a packet can slip by before we install the filter
on our socket listening for RAs, so add some basic sanity checking
to make sure we've recieved an RA.

Change-Id: I14cf84a0814896a41e00f50af376dfc4988d36cb
Fixes: 29586253
/frameworks/base/services/net/java/android/net/apf/ApfFilter.java
38db976514ff2ad12d207a927219762eab179882 12-Jul-2016 Hugo Benichi <hugobenichi@google.com> APF: filter unwanted ARP replies

This patch adds APF filtering of ARP replies for interfaces with APF.

- when the interface has no IPv4 address, broadcast ARP replies with a
0.0.0.0 target ip are dropped (GARP), ARP requests with a 0.0.0.0
target ip are dropped.

- when the interface has an IPv4 address, broadcast ARP replies to a
different ip are dropped (including GARPs to 0.0.0.0), ARP requests to
a different ip are dropped.

Bug: 29404209
Bug: 30080487
Change-Id: I82613eb865c7f38b6260997fe2caf2aff382ad78
/frameworks/base/services/net/java/android/net/apf/ApfFilter.java
6ccd51a338fed39217cb3a5c0f229ed547918634 04-Jul-2016 Hugo Benichi <hugobenichi@google.com> IpConn metrics: correctly read RA lifetimes

This patch
- adds a Builder class for RaEvent.
- uses this Builder class for correctly recording the minimum
lifetime seen for every ICMP6 options tracked, instead of
recording the last lifetime seen.
- adds unit test coverage for RaEvent logging.

Change-Id: I6443932f5cf7a613a5c695c65a60eab01e60602a
/frameworks/base/services/net/java/android/net/apf/ApfFilter.java
cfbf7414a14cf91d1b5c83154aab54c32d6be76a 23-Jun-2016 Hugo Benichi <hugobenichi@google.com> Record events for RA option lifetimes

This patch defines a new android.net.metrics.RaEvent class carrying
lifetime values contained in RA packets. RaEvent are recorded when
ApfFilter processes a new RA for which there is no match.

Example:
ConnectivityMetricsEvent(15:39:39.808, 0, 0): RaEvent(lifetimes: router=3600s, prefix_valid=2592000s, prefix_preferred=604800s, route_info=-1s, dnssl=-1s, rdnss=3600s)

Change-Id: Ia28652e03ed442d5f2a686ef5b3fafbcb77c503a
/frameworks/base/services/net/java/android/net/apf/ApfFilter.java
647c86d70a0f2162dcc95854e9dccb925c16ecf3 07-Jun-2016 Hugo Benichi <hugobenichi@google.com> Log RA listening statistics

This patch adds a new ApfStats event class that counts RA packet
reception statistics on the RA listener thread of ApfFilter and reports
the maximum program size advertised by hardware.

Statistics are gathered for the lifetime of a network with APF
capabilities and uploaded at network teardown when the listener thread
exits.

Example event:
ConnectivityMetricsEvent(15:44:23.741, 0, 0): ApfStats(284945ms 2048B RA: 2 received, 0 matching, 0 ignored, 0 expired, 0 parse errors, 2 program updates)

Bug: 28204408
Change-Id: Id2eaafdca97f61152a4b66d06061c971bc0aba4c
/frameworks/base/services/net/java/android/net/apf/ApfFilter.java
4fc3ee5be223122792ebc0ee8a05c93d93e26a52 02-Jun-2016 Hugo Benichi <hugobenichi@google.com> Log events at APF program generation

Example:
ConnectivityMetricsEvent(15:24:52.018, 0, 0): ApfProgramEvent(0/0 RAs 121B forever FLAG_MULTICAST_FILTER_ON)
ConnectivityMetricsEvent(15:24:53.036, 0, 0): ApfProgramEvent(1/1 RAs 334B 600s)
ConnectivityMetricsEvent(15:24:53.590, 0, 0): ApfProgramEvent(1/1 RAs 360B 600s FLAG_MULTICAST_FILTER_ON, FLAG_HAS_IPV4_ADDRESS)
ConnectivityMetricsEvent(15:24:58.157, 0, 0): ApfProgramEvent(1/1 RAs 294B 599s FLAG_HAS_IPV4_ADDRESS)

Bug: 28204408
Change-Id: I9c4c82861cf42eb2c7e7bf5471f05e8ff2fc560c
/frameworks/base/services/net/java/android/net/apf/ApfFilter.java
8995d85b9432387520c9f04a69251536754b996b 23-Jun-2016 Lorenzo Colitti <lorenzo@google.com> Don't loop forever on 0-length options.

A malformed RA could cause the Ra constructor in ApfFilter to
enter an infinite loop while holding the class lock. This blocks
IpManager until reboot and drains the battery.

Bug: 29586253
Change-Id: Idaa46b3bc50371db076630881883807c2fa21674
/frameworks/base/services/net/java/android/net/apf/ApfFilter.java
f8a01e84317fcb9d27a294e95603b846143c7fcb 26-May-2016 Paul Jensen <pauljensen@google.com> Don't drop IPv4 broadcast packets when WiFi multicast lock is held

IPv4 broadcast packets can be very common (e.g. every 2s) so they
need to be dropped in the general case. They also may be critical
for certain discovery protocols, so allow them through with APF
when the WiFi multicast lock is held.

Bug: 26238573
Change-Id: I03e09a2b9c779da5da775e78b95e9e0339720eaf
/frameworks/base/services/net/java/android/net/apf/ApfFilter.java
11e13e2175674389ed18c2b1e1af69c5ad931e8f 19-May-2016 Lorenzo Colitti <lorenzo@google.com> Support IPv6 multicast filtering in APF.

For now this just drops all non-ICMPv6 packets to ff00::/8 when
mMulticastFilter is true. Multicast ICMPv6 is already mostly
dealt with by other filters - the L2 multicast filter, the RA
filter, the multicast NA filter, and ND offload.

Bug: 28393601
Change-Id: Ia7b0d4f00fac6710093befe6a726b46677a5f20b
/frameworks/base/services/net/java/android/net/apf/ApfFilter.java
90ba8cf3799fa60138d212e092cc7f0a5e79374f 13-May-2016 Paul Jensen <pauljensen@google.com> Merge "Use APF program to drop non-IP non-ARP broadcasts" into nyc-dev
9132f34976f16a626c2ec1d3d90624d71e054346 13-Apr-2016 Paul Jensen <pauljensen@google.com> ApfFilter unit test

Bug: 26238573

Change-Id: I5171038228782bd54e91f5bcc663cc529d2c1150
/frameworks/base/services/net/java/android/net/apf/ApfFilter.java
dd7bee87725795d0d71c5f6a309dda78df957d8a 06-May-2016 Paul Jensen <pauljensen@google.com> Use APF program to drop non-IP non-ARP broadcasts

This used to be done by some WiFi firmwares but should now be done by APF
for consistency across the board.

Bug: 28304368
Change-Id: Ic75f408affc1f56e1ecf4d347d0c287aa72250bf
/frameworks/base/services/net/java/android/net/apf/ApfFilter.java
91723d7f7ecc07e9bfa84c445213acf1dec0664f 14-Apr-2016 Paul Jensen <pauljensen@google.com> Avoid APF JNEBS instruction with R1 as it doesn't work

APF version 2 and prior versions fail to execute JNEBS with R1 argument.
The APF interpreter tries to use R1's value as the number of bytes to
compare, as well as the offset within the packet to compare at.
This change makes ApfFilter avoid using this and makes the APF generator
throw if this is used. This was limiting the IPv4 filter, causing it to
only drop multicast (when multicast filtering was enabled), rather than
a wider range of broadcast packets.

Bug: 28206777

Change-Id: I8d116e024e8bd641b21053c6b1defc734d744467
/frameworks/base/services/net/java/android/net/apf/ApfFilter.java
059e2bb376418aeb16551866c384dd1be032db62 08-Apr-2016 Lorenzo Colitti <lorenzo@google.com> More APF debuggability.

1. Decode RDNSS options.
2. Keep track of how many times the program was updated.
3. Remove the leading / from the IPv4 address.

Change-Id: Ida0518a94ea7d952c82c8181b09044eff907b714
/frameworks/base/services/net/java/android/net/apf/ApfFilter.java
cd404a2fc34a967f0763fb3b6b43f56a5d8014e8 05-Apr-2016 Lorenzo Colitti <lorenzo@google.com> Merge "Add APF code to drop ARP IPv4 requests not for us" into nyc-dev
a8458c0363851c7324a8e64efe9f73d0bb6ef0b4 25-Mar-2016 Paul Jensen <pauljensen@google.com> Add APF code to drop ARP IPv4 requests not for us

The WiFi chipset's ARP offload may handle this when the
AP is asleep, but when the AP is awake and the chipset is in
wake-on-wifi mode use APF to filter these packets.

Bug: 27477163
Change-Id: I180c08bd7301a1af9c3f728ff3cba06ca4e1022d
/frameworks/base/services/net/java/android/net/apf/ApfFilter.java
10d70bff61af5b9c88ce2a3124b2ffbc3a3424fb 05-Apr-2016 Paul Jensen <pauljensen@google.com> Merge "Fix potential ApfFilter bugs by careful ByteBuffer use" into nyc-dev
2e074db972355a77f91378b5b1daceb500dde019 25-Mar-2016 Paul Jensen <pauljensen@google.com> Plumb WiFi multicast filter through to ApfFilter

Use APF to implement WifiManager.MulticastLock, if APF isn't available
fallback to the present behavior of using DRIVER RXFILTER. Since we
don't know whether APF is supported until we're connected, postpone
enabling/disabling the multicast filter until then; this should be
fine as there isn't much need to filter packets if there aren't any
packets going by since we're not connected.

Bug: 26238573
Change-Id: I862c053f1c8c3a41de50c2951cf14b3ca6923a2a
/frameworks/base/services/net/java/android/net/apf/ApfFilter.java
1c71cb3e728c5f7b3bc76daf581e108ed5c0fa3c 25-Mar-2016 Paul Jensen <pauljensen@google.com> Fix potential ApfFilter bugs by careful ByteBuffer use

Avoid adjusting ApfFilter.Ra.mPacket's postion() and limit()
in matches(). This avoids potential bugs in other parts of
the code that previously relied on limit() being reset.
Also for good measure change some limit() calls to capacity()
as it's more final.

Change-Id: I466e87ce6838f68654b24f2c9543a6cd547d3f87
/frameworks/base/services/net/java/android/net/apf/ApfFilter.java
f21b4dc1d6e9cc3fc164828e9eba33445c0801d0 18-Mar-2016 Paul Jensen <pauljensen@google.com> Move ApfFilter from ConnectivityService to IpManager

There's a few advantages to having ApfFilter in IpManager:
1. If things go wrong, crashing a particular transport is less bad then
crashing ConnectivityService. We also don't want to use
ConnectivityService as a dumping ground for transport-specific logic.
2. This makes implementing WifiManager.MulticastLock a lot simpler and
safer because enabling/disabling it doesn't have to go through the
NetworkAgent, which could risk various races (e.g. installing a filter
into the wrong WiFi network).
3. IpManager is the ultimate source for LinkProperties for a particular
transport and since ApfFilter uses the LinkProperties it's better to
have it closely paired with the IpManager. Likewise, ApfFilter needs
to know the APF capabilities of the transport, so having it in
the transport avoids having to parcel this information through the
NetworkAgent.

Bug: 26238573
Change-Id: I99b85f2b64972f0e7572170ec5d1926081aa3429
/frameworks/base/services/net/java/android/net/apf/ApfFilter.java