ethernet: read running flag before bringing up interface

Previously, the "running" flag was checked right after calling
setInterfaceUp(), which caused an updateInterfaceState(UP) event to be
generated at the end of addInterface(). This "artificial" link up
notification is only needed for interfaces that already had link before
being added (as in this case, no RTM_NEWLINK callbacks are received, and
link state needs to "manually" be set to UP to start configuring the
interface). This could happen when system server crashes and gets
restarted, or when ethernet is temporarily disabled via the
EthernetManager API.

Reading the running flag before bringing up the interface ensures the
updateInterfaceState(UP) event is not generated for interfaces that were
just brought up.
This fix gets rid of the up/up/down/up callback when a new interface is
added.

Test: atest EthernetManagerTest
Change-Id: I122dc886a94222c575f44182b943e64b435c03e8
2 files changed