networkd: report error if lease file cannot be loaded and ignore
On my system, networkd would report that interface ve-rawhide is "Failed"
without anything in the logs:
systemd-networkd[651095]: ve-rawhide: Trying to reconfigure the interface.
systemd-networkd[651095]: ve-rawhide: Gained IPv6LL
systemd-networkd[651095]: ve-rawhide: Link DOWN
systemd-networkd[651095]: ve-rawhide: Lost carrier
systemd-networkd[651095]: ve-rawhide: Configuring with /usr/lib/systemd/network/80-container-ve.network.
systemd-networkd[651095]: ve-rawhide: Link UP
systemd-networkd[651095]: ve-rawhide: Gained carrier
systemd-networkd[651095]: ve-rawhide: Failed
At debug level:
systemd-networkd[799993]: dhcp-server-lease/ve-rawhide:1:1: Missing object field 'Address'.
$ jq </var/lib/systemd/network/dhcp-server-lease/ve-rawhide
{
"BootID": "5d86b34b98894322bfd4ae8443ce59b3",
"Leases": [
{
"ClientId": [ ... ],
"Address": [ 192, 168, 120, 179 ],
"Hostname": "rawhide",
"ExpirationUSec": 966046821158,
"ExpirationRealtimeUSec": 1711203197266940
}
]
}
I'm not sure why "Address" is missing, but anyway, in this case, we should ignore the
lease file rather than refusing to configure the interface. Also, warn at the point
where we know what the filename is.
This commit is contained in:
committed by
Yu Watanabe
parent
ef6bf96749
commit
f50be1870d
@@ -1496,7 +1496,7 @@ static int address_acquire(Link *link, const Address *address, union in_addr_uni
|
||||
assert(ret);
|
||||
|
||||
r = address_acquire_from_dhcp_server_leases_file(link, address, ret);
|
||||
if (r != -ENOENT)
|
||||
if (!IN_SET(r, -ENOENT, -ENXIO, -EINVAL))
|
||||
return r;
|
||||
|
||||
r = address_pool_acquire(link->manager, address->family, address->prefixlen, &a);
|
||||
|
||||
@@ -197,8 +197,14 @@ int address_acquire_from_dhcp_server_leases_file(Link *link, const Address *addr
|
||||
lease_file,
|
||||
&a,
|
||||
&prefixlen);
|
||||
if (r < 0)
|
||||
if (r == -ENOENT)
|
||||
return r;
|
||||
if (r < 0)
|
||||
return log_warning_errno(r, "Failed to load lease file %s: %s",
|
||||
lease_file,
|
||||
r == -ENXIO ? "expected JSON content not found" :
|
||||
r == -EINVAL ? "invalid JSON" :
|
||||
STRERROR(r));
|
||||
|
||||
if (prefixlen != address->prefixlen)
|
||||
return -ENOENT;
|
||||
|
||||
Reference in New Issue
Block a user