check_ethernet: don't ping via "down" links

I've noticed that we have some timing problems since:

https://chromium-review.googlesource.com/1637489

where we're holding /run/autotest_pause_ethernet_hook for upwards of 25
seconds. One reason: we're wasting a lot of time when there are
un-connected links (e.g., Chromeboxes with built-in Ethernet, but the
lab uses a USB dongle). Don't bother pinging anything if the operational
state is not "up".

Per Linux documentation:

  Indicates the interface RFC2863 operational state as a string.
  Possible values are:
  "unknown", "notpresent", "down", "lowerlayerdown", "testing",
  "dormant", "up".

BUG=none
TEST=plug in an unused USB ethernet dongle; ensure only eth1 is active;
     then watch how long check_ethernet.hook takes

Change-Id: I8c1288c36cc9b15347dc8ea86cafb2e4bf12fb9f
Reviewed-on: https://chromium-review.googlesource.com/1669972
Tested-by: Brian Norris <briannorris@chromium.org>
Commit-Ready: Brian Norris <briannorris@chromium.org>
Legacy-Commit-Queue: Commit Bot <commit-bot@chromium.org>
Reviewed-by: Grant Grundler <grundler@chromium.org>
1 file changed