268 Commits

Author SHA1 Message Date
Hugo Benichi
42e608527a Merge "IpConn metrics: distinguish NUD_FAILED answers" into nyc-mr1-dev 2016-07-07 13:02:31 +00:00
Hugo Benichi
7643423521 IpConn metrics: add times to DHCP bound state
This patch adds DhcpClientEvent logging for:
 - time from init state to bound state
 - time from bound state to bound state when renewing

Example:
ConnectivityMetricsEvent(12:04:33.353, 0, 0): DhcpClientEvent(wlan0, WaitBeforeStartState, 94ms)
ConnectivityMetricsEvent(12:04:35.772, 0, 0): DhcpClientEvent(wlan0, DhcpInitState, 2417ms)
ConnectivityMetricsEvent(12:04:35.787, 0, 0): DhcpClientEvent(wlan0, DhcpRequestingState, 15ms)
ConnectivityMetricsEvent(12:04:35.793, 0, 0): DhcpClientEvent(wlan0, ConfiguringInterfaceState, 6ms)
ConnectivityMetricsEvent(12:04:35.811, 0, 0): DhcpClientEvent(wlan0, InitialBoundState, 2457ms)
ConnectivityMetricsEvent(12:05:35.791, 0, 0): DhcpClientEvent(wlan0, DhcpBoundState, 59998ms)
ConnectivityMetricsEvent(12:05:35.988, 0, 0): DhcpClientEvent(wlan0, WaitBeforeRenewalState, 196ms)
ConnectivityMetricsEvent(12:05:36.003, 0, 0): DhcpClientEvent(wlan0, DhcpRenewingState, 15ms)
ConnectivityMetricsEvent(12:05:36.010, 0, 0): DhcpClientEvent(wlan0, RenewingBoundState, 219ms)

Change-Id: I2540dd102a6509dff55936e38015265659b20760
2016-07-07 16:10:20 +09:00
Hugo Benichi
0d1c65b221 IpConn metrics: distinguish NUD_FAILED answers
This patch adds in IpReachabilityMonitor a timestamp variable set
everytime that probeAll() send NUD probe requests to RTNETLINK.
This allows to distinguish between:
  1) NUD_FAILED events resulting from such a forced NUD probe
  2) "organic" NUD_FAILED notifications from the kernel

This distinction is added to IpReachabilityEvent as a one-bit flag.

This patch also changes the formatting of ApfProgramEvent flags to use
'|' as a joining character, similarly to other flags formatting.

Bug: 21859053
Change-Id: I24c64a3f17fa283eace5bd0a05c21a90a2305359
2016-07-07 15:58:28 +09:00
Hugo Benichi
54756fdfd9 Merge "IpConn metrics: correctly read RA lifetimes" into nyc-mr1-dev 2016-07-05 12:25:55 +00:00
Hugo Benichi
176ed01a1f IpConn metrics: add dhcp transition times
This patch adds lifetime durations of DhcpClient states to
DhcpClientEvents.

To record the duration of a state, the event is now recorded when the
DhcpClient state machine exits that state.

In addition this patch removes event logging of StoppedState,
DhcpState and DhcpHaveLeaseState.

Change-Id: Ibd37b5e3070f35113b6b45942b1e1ff19c27a90b
2016-07-05 17:32:56 +09:00
Hugo Benichi
6ccd51a338 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
2016-07-05 13:52:24 +09:00
TreeHugger Robot
f5e3481951 Merge changes Ia28652e0,Id2eaafdc,I9c4c8286 into nyc-mr1-dev
* changes:
  Record events for RA option lifetimes
  Log RA listening statistics
  Log events at APF program generation
2016-06-30 14:03:22 +00:00
Hugo Benichi
cfbf7414a1 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
2016-06-30 18:26:39 +09:00
Hugo Benichi
647c86d70a 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
2016-06-30 18:26:33 +09:00
Hugo Benichi
4fc3ee5be2 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
2016-06-30 18:21:09 +09:00
Erik Kline
feadfda8a0 Make provisioning timeout apply to both IPv4 and IPv6
Bug: 29449295
Change-Id: I743533ca61914c11163ba5c5767a365def3a5461
2016-06-30 13:00:01 +09:00
Hugo Benichi
cfddd68792 Refactor IP connectivity event logging
This patch removes static methods for logging IP connectivity events
defined in android.net.metrics and replaces them with a single log()
instance method defined on IpConnectivityLog. Event constructors are
now public also. Every classes logging such events now create an
instance of IpConnectivityLog for logging event objects directly
instantiated with new.

Removing static dependencies allow straightforward testing of logging.

This patch also removes the base IpConnectivityEvent class which is not
needed any more.

Bug: 29035129
Change-Id: I3de700f93f46deaa48a759f938f7d00e1d8bff98
2016-06-29 14:28:51 +09:00
Lorenzo Colitti
8995d85b94 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
2016-06-23 15:43:34 +09:00
TreeHugger Robot
83e50327fc Merge "Don't drop IPv4 broadcast packets when WiFi multicast lock is held" into nyc-dev 2016-05-27 14:58:48 +00:00
Paul Jensen
f8a01e8431 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
2016-05-27 09:18:56 -04:00
Lorenzo Colitti
e67ec4eb01 Restore DHCP client logging.
Bug: 28955598
Change-Id: I2e2684a787061612471830e4d840ce422091bafb
2016-05-27 14:14:03 +09:00
Lorenzo Colitti
d954c6368f Merge "Support IPv6 multicast filtering in APF." into nyc-dev 2016-05-24 03:14:38 +00:00
Lorenzo Colitti
11e13e2175 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
2016-05-24 00:02:07 +09:00
Erik Kline
d8e1592e64 Support DHCPv4 rebinding state
Bug: 24837343
Change-Id: Id49e1c12ec3b11fedba42bb28348a00cb0b11169
2016-05-23 23:56:46 +09:00
Erik Kline
acda32c35f DHCPv4: lease expiration is fatal, renew failures are not
Bug: 24837343

Change-Id: Ib330864f8376b0907390d581b48cff5446b3392b
2016-05-18 16:17:03 +09:00
Paul Jensen
90ba8cf379 Merge "Use APF program to drop non-IP non-ARP broadcasts" into nyc-dev 2016-05-13 17:14:47 +00:00
Paul Jensen
b742495cf5 Merge "ApfFilter unit test" into nyc-dev 2016-05-13 14:33:25 +00:00
Erik Kline
2ec229a0ed Support IPv4-only and IPv6-only provisioning
Bug: 28437662
Change-Id: I95b2d6eeb48cc526c8e6e015c5130ff9141fb898
2016-05-13 13:21:25 +09:00
Paul Jensen
9132f34976 ApfFilter unit test
Bug: 26238573

Change-Id: I5171038228782bd54e91f5bcc663cc529d2c1150
2016-05-10 11:54:42 -04:00
Paul Jensen
dd7bee8772 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
2016-05-10 11:33:30 -04:00
Erik Kline
fc2e5b6703 IpManager: add distinct DhcpActionTimeoutAlarm
Track provisioning timeouts separately from "DHCP action" timeouts.

Bug: 17733693
Bug: 24837343
Change-Id: I6071699692e7d375155a4c4fe61c7ec0d89396c0
2016-04-28 16:52:10 +09:00
Lorenzo Colitti
adacedb1a8 Notify success before configuring the IP address.
This ensures that IpManager has a complete copy of DHCP state
before configuring the IPv4 address. That way, when the netlink
notification of the IPv4 address arrives, we are guaranteed to
have all DHCP information (including DNS servers and routes)
available and we will never send the IPv4 address before the DNS
servers.

Bug: 27605330
Change-Id: I732424dfe2408be9e40028563e99d610b541e12d
2016-04-28 13:56:50 +09:00
Erik Kline
9c51583daf Merge "IpManager: add a provisioning timeout option" into nyc-dev 2016-04-27 09:40:08 +00:00
Erik Kline
741b15dc75 IpManager: add a provisioning timeout option
Relatedly: remove the provisioning timeout from DhcpClient.

Bug: 17733693
Bug: 24837343
Change-Id: I6d5b835b4ca70ba6fd06df359fc2128a0df46252
2016-04-27 16:27:44 +09:00
TreeHugger Robot
24b6e2bcc8 Merge changes I8de95add,Ia6f4ccfd into nyc-dev
* changes:
  Remove unused event tags of IpConnectivityEvent
  Better ConnectivityMetricsEvent printing
2016-04-27 01:49:53 +00:00
Hugo Benichi
5df9d729f6 Better ConnectivityMetricsEvent printing
This patch adds more information printing for IpConnectivity event
classes in android.net.metrics.

example:

ConnectivityMetricsEvent(14:36:35.799, 0, 1026): DhcpClientEvent(wlan0, DhcpRequestingState)
ConnectivityMetricsEvent(14:36:35.805, 0, 1026): DhcpClientEvent(wlan0, DhcpHaveAddressState)
ConnectivityMetricsEvent(14:36:35.809, 0, 4096): IpManagerEvent(wlan0, PROVISIONING_OK, 155ms)
ConnectivityMetricsEvent(14:36:35.810, 0, 1026): DhcpClientEvent(wlan0, DhcpBoundState)
ConnectivityMetricsEvent(14:36:35.871, 0, 2048): NetworkEvent(101, NETWORK_CONNECTED, 0ms)
ConnectivityMetricsEvent(14:36:35.874, 0, 2051): ValidationProbeEvent(101, PROBE_HTTP:599, 3ms)
ConnectivityMetricsEvent(14:36:35.874, 0, 2048): NetworkEvent(101, NETWORK_VALIDATION_FAILED, 0ms)
ConnectivityMetricsEvent(14:36:35.928, 0, 3072): DefaultNetworkEvent(0 -> 101, [WIFI], IPv4: false, IPv6: false)
ConnectivityMetricsEvent(14:36:37.008, 0, 2051): ValidationProbeEvent(101, PROBE_HTTP:204, 134ms)
ConnectivityMetricsEvent(14:36:37.008, 0, 2050): NetworkEvent(101, NETWORK_VALIDATED, 1137ms)

Also fixes a couple of event logging issues:
  - do no record spurious receive DhcpErrorEvent when a network goes down.
  - add an eventType field to IpManagerEvent instead of using the
    loggger component tag.

Bug: 28204408
Change-Id: Ia6f4ccfd7a0c63a5ccec18825f226c0b5781217b
2016-04-27 09:11:29 +09:00
Erik Kline
5b76623a0e Move IPv4 address setting to IpManager
Bug: 24837343
Bug: 27605330
Change-Id: I19ac80e45b3e9200f81d1166ac6094fd19aee963
2016-04-26 17:19:44 +09:00
Erik Kline
b2ff48bd71 IpManager: delete dead getLinkProperties() code
Now that it's long since been unused also delete the locking that was
introduced to make it possible.

Bug: 17733693
Bug: 24837343
Change-Id: Iee817a7c2e1d1dc9c080d3124d5986232dcda00f
2016-04-26 15:54:12 +09:00
Erik Kline
a84572b503 Add state and callback logs for IpManager dump
Bug: 27605330
Change-Id: I2e659d08fa9acd57a71901f28c85a92c0876c663
2016-04-25 13:11:58 +09:00
Erik Kline
c2827857aa IpManager,DhcpClient: catch some errors and better logging
Bug: 28196843
Change-Id: Ia91e926da569bf9c503ea00e1e0f767d196547da
2016-04-21 21:13:59 +09:00
TreeHugger Robot
b99d6af3ab Merge "Expand NetworkMonitor metrics" into nyc-dev 2016-04-21 05:24:40 +00:00
Erik Kline
a488c23dd5 Expand NetworkMonitor metrics
- add netid to CaptivePortalStateChangeEvent
    - add NetworkMonitorEvent for simple duration measurements

Bug: 28204408
Change-Id: I62035e07d64013878a0bce30c67c929c2c7e7a85
2016-04-21 13:02:55 +09:00
Hugo Benichi
25bf8f5d56 Various fixes in IpReachability event logging
- fold IpReachabilityMonitor* classes into a single IpReachabilityEvent.
- only log an event for NUD_FAILED Netlink answers.
- distinguish between NUD_FAILED with or without lost of provisioning.
- do not record host ip addresses.
- record interface name instead of interface index when losing
  provisioning.

- also return an error code when probeNeighbor fails, and log this error
  code in IpReachability events.

Bug: 28204408
Change-Id: I5f0def0ab1ace7e467a0c69b3b82d07ef2252307
2016-04-21 09:18:50 +09:00
Paul Jensen
520ae86666 Merge "Avoid APF JNEBS instruction with R1 as it doesn't work" into nyc-dev 2016-04-18 10:56:14 +00:00
Hugo Benichi
2677b1957b Fix spurious DHCP parse error logging.
This patch moves the event logging of DHCP response packet parse errors
to DHCPClient in a single place. It also logs receive IO errors as
DHCPErrors instead of DHCPClientEvents.

BUG=28197345

Change-Id: I7ad666cff4d8b97915880477347fbb3f588fdb2a
2016-04-18 11:27:35 +09:00
Paul Jensen
91723d7f7e 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
2016-04-15 13:18:19 +00:00
Hugo Benichi
fc18b6f360 Merge "Add DHCP error event class and record DHCP errors." into nyc-dev 2016-04-14 08:01:31 +00:00
Hugo Benichi
6241874355 Add DHCP error event class and record DHCP errors.
This patch adds an event class derived from IpConnectivityEvent that
records parsing errors of DHCP response packets.

Change-Id: I19516cf05e3419c4262e3236899e52987e5f2264
2016-04-14 15:40:10 +09:00
Hugo Benichi
fbd47caf40 Merge "Add volatile qualifier to boolean variable" into nyc-dev 2016-04-14 04:19:50 +00:00
Erik Kline
5b25a0f796 Add some more metrics: IpManager, IpReachabilityMonitor
Change-Id: Ibb7150c849715a42fc2c879589eaaf86e8a007e7
2016-04-14 10:53:30 +09:00
Erik Kline
0a0e1dcdc6 Also consider loss of IPv6 default route to be fatal
Bug: 27962810
Change-Id: I735d71ddc71da701eebbb9969f6e1cbffd7e1a1c
2016-04-13 19:47:26 +09:00
Hugo Benichi
67530d6585 Add volatile qualifier to boolean variable
DHCP receive thread was spinning on a boolean variable to know when to
stop. That variable had no volatile qualifier, potentially preventing
the thread from stopping at all. Without a volatile qualifier, the reads
and writes in halt() could be reordered in such a way that the running
thread is interrupted before mStopped is set t true. Also, the optimizer
could decide to hoist mStopped in a register inside the running thread,
preventing the loop from exiting.

Change-Id: I5b30c1247808114f0e5b46e230978ee7ea18ab8e
2016-04-13 11:16:51 +09:00
Erik Kline
071b6dfdee Trigger enabling of NDO when startProvisioning() is called.
Bug: 26238390
Bug: 27598285
Change-Id: I1f63bdd27defd43f994d259d07a943872df4f47c
2016-04-12 23:01:23 +09:00
Lorenzo Colitti
059e2bb376 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
2016-04-08 23:09:25 +09:00
Lorenzo Colitti
19e84f7b75 Merge changes Ibb63f6b4,Ib64559a5 into nyc-dev
* changes:
  Clean up netd state when tethering fails.
  Clear LinkProperties on interface removed.
2016-04-05 13:35:09 +00:00