From dad1c024aa7225e242e517ae44bb2f09f6825e97 Mon Sep 17 00:00:00 2001 From: Tobias Waldekranz Date: Thu, 20 Feb 2025 14:31:20 +0100 Subject: [PATCH] confd: Support interfaces that detach from their PHYs when down Some netdev drivers, e.g. the FEC found on many i.MX SoCs from NXP, will detach from their PHYs when configured down. This means that when confd tries to configure L1 settings for the link before bringing it up, ethtool fails - since there is no PHY to talk to. For interfaces that behave this way, delay the configuration until after NETDAG_INIT, when the interface is brought up. This is not optimal, since we are generating needless noise for the link partner, which is why we only fall back to it as a last resort. Fix #951 --- src/confd/src/ieee802-ethernet-interface.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/confd/src/ieee802-ethernet-interface.c b/src/confd/src/ieee802-ethernet-interface.c index 4529c915..74072795 100644 --- a/src/confd/src/ieee802-ethernet-interface.c +++ b/src/confd/src/ieee802-ethernet-interface.c @@ -35,9 +35,13 @@ static bool iface_uses_autoneg(struct lyd_node *cif) static int netdag_gen_ethtool_flow_control(struct dagger *net, struct lyd_node *cif) { const char *ifname = lydx_get_cattr(cif, "name"); + enum netdag_init phase = NETDAG_INIT_PHYS; FILE *fp; - fp = dagger_fopen_net_init(net, ifname, NETDAG_INIT_PHYS, "ethtool-flow-control.sh"); + if (iface_has_quirk(ifname, "phy-detached-when-down")) + phase = NETDAG_INIT_POST; + + fp = dagger_fopen_net_init(net, ifname, phase, "ethtool-flow-control.sh"); if (!fp) return -EIO; fprintf(fp, "[[ -n $(ethtool --json %s | jq '.[] | select(.\"supported-pause-frame-use\" == \"No\")') ]] && exit 0\n", ifname); @@ -52,11 +56,15 @@ static int netdag_gen_ethtool_autoneg(struct dagger *net, struct lyd_node *cif) { struct lyd_node *eth = lydx_get_child(cif, "ethernet"); const char *ifname = lydx_get_cattr(cif, "name"); + enum netdag_init phase = NETDAG_INIT_PHYS; const char *speed, *duplex; int mbps, err = 0; FILE *fp; - fp = dagger_fopen_net_init(net, ifname, NETDAG_INIT_PHYS, "ethtool-aneg.sh"); + if (iface_has_quirk(ifname, "phy-detached-when-down")) + phase = NETDAG_INIT_POST; + + fp = dagger_fopen_net_init(net, ifname, phase, "ethtool-aneg.sh"); if (!fp) return -EIO;