From: Yu Watanabe Date: Thu, 7 Sep 2023 15:54:08 +0000 (+0900) Subject: network/sr-iov: ignore -EINVAL in reading dev_port sysfs attribute X-Git-Tag: v255-rc1~541^2~1 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=4b12a8dd338dc640cb1965125feefdee0ac8f625;p=thirdparty%2Fsystemd.git network/sr-iov: ignore -EINVAL in reading dev_port sysfs attribute Fixes #27369. --- diff --git a/src/network/networkd-sriov.c b/src/network/networkd-sriov.c index 1f205b7468e..562a53b7ddb 100644 --- a/src/network/networkd-sriov.c +++ b/src/network/networkd-sriov.c @@ -209,7 +209,11 @@ static int link_set_sr_iov_phys_port(Link *link) { if (!link->dev) return -ENODEV; + /* This may return -EINVAL or -ENODEV, instead of -ENOENT, if the device has been removed or is being + * removed. Let's map -EINVAL to -ENODEV, as the caller will ignore -ENODEV. */ r = sd_device_get_sysattr_value(link->dev, "dev_port", &dev_port); + if (r == -EINVAL) + return -ENODEV; if (r < 0) return r; @@ -242,6 +246,8 @@ static int link_set_sr_iov_virt_ports(Link *link) { return -ENODEV; r = sd_device_get_sysattr_value(link->dev, "dev_port", &dev_port); + if (r == -EINVAL) + return -ENODEV; if (r < 0) return r;