This can happen for alias "interfaces", e.g: "eth0:1" (which aren't really an interface, but are a deprecated method of adding multiple IP addresses to a single interface). Since only the base interface ("eth0") is really a device, only it has an entry in /sys/class/net.
It's not important that such interfaces have truly meaningful information in their <link> element (as we don't really have any truly meaningful state, and haven't historically provided other status for alias interfaces (e.g. IP address). What *is* important is that we don't return an error, as this breaks applications that rely on being able to get back a successful (if empty) status for any interface listed.
This resolves the regression with virt-manager described here:
https://bugzilla.redhat.com/show_bug.cgi?id=1185850 --- src/dutil_linux.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-)
diff --git a/src/dutil_linux.c b/src/dutil_linux.c index 19e36ca..00c378f 100644 --- a/src/dutil_linux.c +++ b/src/dutil_linux.c @@ -1081,8 +1081,14 @@ static void add_link_info(struct netcf *ncf, xasprintf(&path, "/sys/class/net/%s/operstate", ifname); ERR_NOMEM(!path, ncf); state = read_file(path, &length); - ERR_THROW_STRERROR(!state, ncf, EFILE, "Failed to read %s : %s", - path, errbuf); + if (!state) { + /* missing operstate is *not* an error. It could be due to an + * alias interface, which has not entry in /sys/class/net at + * all, for example. + */ + state = strdup(""); + ERR_NOMEM(!state, ncf); + } if ((nl = strchr(state, '\n'))) *nl = 0; prop = xmlSetProp(link_node, BAD_CAST "state", BAD_CAST state);
On 01/27/2015 10:48 AM, Laine Stump wrote:
This can happen for alias "interfaces", e.g: "eth0:1" (which aren't really an interface, but are a deprecated method of adding multiple IP addresses to a single interface). Since only the base interface ("eth0") is really a device, only it has an entry in /sys/class/net.
- if (!state) {
/* missing operstate is *not* an error. It could be due to an
* alias interface, which has not entry in /sys/class/net at
s/not/no/
ACK with that tweak.
On 01/27/2015 12:56 PM, Eric Blake wrote:
On 01/27/2015 10:48 AM, Laine Stump wrote:
This can happen for alias "interfaces", e.g: "eth0:1" (which aren't really an interface, but are a deprecated method of adding multiple IP addresses to a single interface). Since only the base interface ("eth0") is really a device, only it has an entry in /sys/class/net.
- if (!state) {
/* missing operstate is *not* an error. It could be due to an
* alias interface, which has not entry in /sys/class/net at
s/not/no/
ACK with that tweak.
Thanks for the quick response! I've pushed this patch (as well as the one from yesterday).
netcf-devel@lists.fedorahosted.org