From 5e2475c74201be67b2727a177f4ff34fca8f66db Mon Sep 17 00:00:00 2001 From: Tobias Waldekranz Date: Mon, 29 Apr 2024 13:53:20 +0200 Subject: [PATCH] confd: Avoid needless Ethernet flow-control reconfigurations Unless some configuration has changed that affects flow-control (only auto-neg for now, until we allow actual configuration of flow-control itself), do not issue any commands that might trigger a link down/up cycle. Additionally, make sure that we always configure it on boot, as the driver defaults might not necessarily line up with our defaults. --- src/confd/src/dagger.c | 4 ++++ src/confd/src/dagger.h | 1 + src/confd/src/ietf-interfaces.c | 16 +++++++++++----- 3 files changed, 16 insertions(+), 5 deletions(-) diff --git a/src/confd/src/dagger.c b/src/confd/src/dagger.c index 634f6757..4e7bd49e 100644 --- a/src/confd/src/dagger.c +++ b/src/confd/src/dagger.c @@ -127,6 +127,10 @@ int dagger_should_skip_current(struct dagger *d, const char *ifname) return fexistf("%s/%d/skip/%s", d->path, d->current, ifname); } +int dagger_is_bootstrap(struct dagger *d) +{ + return d->next == 0; +} int dagger_claim(struct dagger *d, const char *path) { diff --git a/src/confd/src/dagger.h b/src/confd/src/dagger.h index fa4ae7a6..35d39079 100644 --- a/src/confd/src/dagger.h +++ b/src/confd/src/dagger.h @@ -30,6 +30,7 @@ int dagger_evolve_or_abandon(struct dagger *d); void dagger_skip_iface(struct dagger *d, const char *ifname); int dagger_should_skip(struct dagger *d, const char *ifname); int dagger_should_skip_current(struct dagger *d, const char *ifname); +int dagger_is_bootstrap(struct dagger *d); int dagger_claim(struct dagger *d, const char *path); diff --git a/src/confd/src/ietf-interfaces.c b/src/confd/src/ietf-interfaces.c index 457613fa..ba0ab441 100644 --- a/src/confd/src/ietf-interfaces.c +++ b/src/confd/src/ietf-interfaces.c @@ -775,12 +775,18 @@ static int netdag_gen_ethtool(struct dagger *net, struct lyd_node *cif, struct l if (strcmp(type, "infix-if-type:ethernet")) return 0; - /* XXX: add configurable flow-control support <> */ - err = netdag_gen_ethtool_flow_control(net, cif); - if (err) - return err; + if (!eth) + return 0; - if (lydx_get_descendant(lyd_child(eth), "auto-negotiation", "enable", NULL) || + if (dagger_is_bootstrap(net) || + lydx_get_descendant(lyd_child(eth), "auto-negotiation", "enable", NULL)) { + err = netdag_gen_ethtool_flow_control(net, cif); + if (err) + return err; + } + + if (dagger_is_bootstrap(net) || + lydx_get_descendant(lyd_child(eth), "auto-negotiation", "enable", NULL) || lydx_get_child(eth, "speed") || lydx_get_child(eth, "duplex")) { err = netdag_gen_ethtool_autoneg(net, cif);