From 1e87a30147b3cec2b0c9553a2b2a6fdf6cbc078e Mon Sep 17 00:00:00 2001 From: Joachim Wiberg Date: Tue, 13 Feb 2024 14:47:29 +0100 Subject: [PATCH] confd: skip ethtool command for etherlike interfaces When "plopping" back an interface from another network namespace, e.g., when removing a container network interface, we cannot just rely on the 'ethernet' node *not* being available for an interface. Experience shows that sysrepo might send us a curve ball (see comment) which we interpret to be a true Ethernet interface. Signed-off-by: Joachim Wiberg --- src/confd/src/ietf-interfaces.c | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/src/confd/src/ietf-interfaces.c b/src/confd/src/ietf-interfaces.c index fa1d5899..00ceefd8 100644 --- a/src/confd/src/ietf-interfaces.c +++ b/src/confd/src/ietf-interfaces.c @@ -710,8 +710,26 @@ out: static int netdag_gen_ethtool(struct dagger *net, struct lyd_node *cif, struct lyd_node *dif) { struct lyd_node *eth = lydx_get_child(dif, "ethernet"); + const char *type = lydx_get_cattr(cif, "type"); int err; + /* + * Story time: when assigning a physical interface to a container, and then + * removing it, even though our type may be 'etherlike' we will + * get the following from sysrepo: + * + * "ieee802-ethernet-interface:ethernet": { + * "@": { + * "yang:operation": "delete" + * }, + * "duplex": "full" + * }, + * + * Hence this "redundant" check. + */ + if (strcmp(type, "infix-if-type:ethernet")) + return 0; + if (lydx_get_descendant(lyd_child(eth), "auto-negotiation", "enable", NULL) || lydx_get_child(eth, "speed") || lydx_get_child(eth, "duplex")) { @@ -1040,6 +1058,7 @@ static int netdag_gen_afspec_add(struct dagger *net, struct lyd_node *dif, static int netdag_gen_afspec_set(struct dagger *net, struct lyd_node *dif, struct lyd_node *cif, FILE *ip) { + const char *ifname = lydx_get_cattr(cif, "name"); const char *iftype = lydx_get_cattr(cif, "type"); DEBUG_IFACE(dif, ""); @@ -1051,7 +1070,7 @@ static int netdag_gen_afspec_set(struct dagger *net, struct lyd_node *dif, if (!strcmp(iftype, "infix-if-type:veth")) return 0; - ERROR("unsupported interface type \"%s\"", iftype); + ERROR("unsupported interface type \"%s\" for %s", iftype, ifname); return -ENOSYS; }