confd: Make physical port detection compatible with Linux 6.1

The old assumption was that only virtual links would have specific
"linkinfo" data. However, somewhere between 5.19 and 6.1, DSA ports
gained the ability to report its "conduit" interface via the
"linkinfo" attribute. That's great, but unfortunately it broke our
heuristic assumptions.

The new assumption is that only physical ports will report a
"parentbus" attribute. Let's see how long that will last :)
This commit is contained in:
Tobias Waldekranz
2023-08-30 12:45:51 +02:00
committed by Joachim Wiberg
parent 4a4733354b
commit 93118b02fe
2 changed files with 2 additions and 2 deletions
@@ -19,7 +19,7 @@ phys_ifaces=$(ip -d -j link show | jq -r '
.[] |
select(.link_type == "ether") |
select(.group != "internal") |
select(has("linkinfo") | not) |
select(has("parentbus")) |
.ifname')
cat <<EOF
+1 -1
View File
@@ -50,7 +50,7 @@ static bool iface_is_phys(const char *ifname)
if (strcmp(attr, "ether"))
goto out_free;
if (!json_unpack(link, "[{s: { s:s }}]", "linkinfo", "info_kind", &attr))
if (json_unpack(link, "[{s:s}]", "parentbus", &attr))
goto out_free;
is_phys = true;