From 4b12a8dd338dc640cb1965125feefdee0ac8f625 Mon Sep 17 00:00:00 2001 From: Yu Watanabe Date: Fri, 8 Sep 2023 00:54:08 +0900 Subject: [PATCH] network/sr-iov: ignore -EINVAL in reading dev_port sysfs attribute Fixes #27369. --- src/network/networkd-sriov.c | 6 ++++++ 1 file changed, 6 insertions(+) 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; -- 2.47.3