ethernet: unregister NetworkAgent before stopping IpClient

When NetworkAgent unregisters, it invokes destroyNativeNetwork() which
deletes all routes. This process is not synchronized with IpClient. So
on an IpClient restart, it can happen that destroyNativeNetwork()
executes after the IpClient has restarted, which causes the new routes
to be deleted.

Moving NetworkAgent#unregister() to before stopping IpClient hopefully
improves this situation.

Test: atest EthernetManagerTest
Bug: 240323229
Change-Id: I68f5b35ba48d5892db0e03fa34b1884b4612485a
1 file changed