Reset interface index before IpClientLinkObserver shuts down.

postpone clearing interface parameter from StoppedState#enter till
IpClient quits state machine, which sets interface index to 0(invalid
value). IpClient relies on receiving LinkProperties changes from
IpClientLinkObserver even after entering StoppingState. One example of
this is the code that tries to detect whether IP addresses were added
to the interface while IpClient was stopped.

For example, in the testIpClientClearingIpAddressState, intend to stop
IpClient and then add more IP addresses to simulate these IP addreses
were left due to something wrong happened, however, interface index has
been reset before next provisioning starts(actually tap interface is
still there), new RTM_NEWADDR/DELADDR won't be processed due to the
index mismatches.

Moving the ifindex cleanup to stopStateMachineUpdaters is correct
because it is the place where the code stops netlink notifications from
arriving (by calling mObserverRegistry.unregisterObserver). When
StoppedState is the initial state of IpClient on starting a new instance,
it doesn't change the behavior, since mIfindex is also initialized with
0; when StoppedState is the end state of IpClient(e.g., transition from
StoppingState), actually other CMDs received in the StoppedState don't
use ifindex neither.

Currently the only production use of the ifindex in IpClientLinkObserver
is the PREF64 RA option parsing(the code that processes RDNSS options
from netlink also uses it, but that code is currently flagged off). With
this fix, it allows a PREF64 RA option is received in StoppingState and
update the pref64 in LinkProperties.

Bug: 163492391
Test: atest NetworkStackTests NetworkStackIntegrationTests
Change-Id: I88d70d27b916a09baf183bf54751b40ebbda05ef
1 file changed