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
This commit is contained in:
Tobias Waldekranz
2025-02-20 14:39:05 +01:00
parent f92d3846db
commit dad1c024aa
+10 -2
View File
@@ -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;