Rebase: fuel-mirror upstream changes
[armband.git] / patches / opnfv-fuel / 0054-net-check-add-support-for-faulty-operstate.patch
1 From: Stefan Sicleru <stefan.sicleru@enea.com>
2 Date: Tue, 30 Aug 2016 17:53:41 +0200
3 Subject: [PATCH] net-check: add support for faulty operstate
4
5 Some eth drivers, such as those for APM X-Gene Mustang Board's NICs, do
6 not advertise operstate properly in sysfs, ie. it is advertised as
7 "unknown" whereas ethtool shows the NIC as fully functional with link
8 detected. This further affects "ip link show" output which is parsed
9 within _check_iface_ready() method.
10
11 Replace "ip link show" command with "ethtool" in order to obtain proper
12 results when operstate is unknown.
13
14 Signed-off-by: Stefan Sicleru <stefan.sicleru@enea.com>
15 ---
16  ...et-check-add-support-for-faulty-operstate.patch | 38 ++++++++++++++++++++++
17  1 file changed, 38 insertions(+)
18  create mode 100644 build/patch-repos/build/repos/network-checker/0010-net-check-add-support-for-faulty-operstate.patch
19
20 diff --git a/build/patch-repos/build/repos/network-checker/0010-net-check-add-support-for-faulty-operstate.patch b/build/patch-repos/build/repos/network-checker/0010-net-check-add-support-for-faulty-operstate.patch
21 new file mode 100644
22 index 0000000..71e7b73
23 --- /dev/null
24 +++ b/build/patch-repos/build/repos/network-checker/0010-net-check-add-support-for-faulty-operstate.patch
25 @@ -0,0 +1,38 @@
26 +From: Stefan Sicleru <stefan.sicleru@enea.com>
27 +Date: Tue, 30 Aug 2016 17:30:24 +0200
28 +Subject: [PATCH] net-check: add support for faulty operstate
29 +
30 +Some eth drivers, such as those for APM X-Gene Mustang Board's NICs, do
31 +not advertise operstate properly in sysfs, ie. it is advertised as
32 +"unknown" whereas ethtool shows the NIC as fully functional with link
33 +detected. This further affects "ip link show" output which is parsed
34 +within _check_iface_ready() method.
35 +
36 +Replace "ip link show" command with "ethtool" in order to obtain proper
37 +results when operstate is unknown.
38 +
39 +Signed-off-by: Stefan Sicleru <stefan.sicleru@enea.com>
40 +---
41 + network_checker/net_check/api.py | 9 ++++++++-
42 + 1 file changed, 8 insertions(+), 1 deletion(-)
43 +
44 +diff --git a/network_checker/net_check/api.py b/network_checker/net_check/api.py
45 +index e3c3b4e..87aa257 100755
46 +--- a/network_checker/net_check/api.py
47 ++++ b/network_checker/net_check/api.py
48 +@@ -195,7 +195,14 @@ class Actor(object):
49 +     def _check_iface_ready(self, iface, vid=None):
50 +         check_iface = self._iface_name(iface, vid)
51 +         output = self._execute(['ip', '-o', 'link', 'show', check_iface])
52 +-        return 'state UP' in '\n'.join(output)
53 ++        if 'state UP' in '\n'.join(output):
54 ++            return True
55 ++
56 ++        if 'state UNKNOWN' in '\n'.join(output) and vid == None:
57 ++            output = self._execute(['ethtool', check_iface])
58 ++            return 'Link detected: yes' in '\n'.join(output).replace('\n', ' ')
59 ++
60 ++        return False
61
62 +     def _ensure_iface_up(self, iface, vid=None):
63 +         """Ensures interface is with vid up."""