confd: recreate interfaces which do not have permaddr

Only physical interfaces have a permanent link address.  So in order to
restore the default MAC generated by the kernel for interfaces such as
bridges, veth pairs, VLAN interfaces, and link aggregates, we recreate
them.

This patch adds support for checking if the phys-address attribute has
been deleted from bridge, vlan, and veth interfaces.

The netdag_must_del() function has been refactorored slightly so each
interface type is responsible for returning true if its condiitions are
satisfied.

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
This commit is contained in:
Joachim Wiberg
2023-09-21 16:34:48 +02:00
parent 9a8251ec66
commit b0d36ca51d
+39 -11
View File
@@ -943,21 +943,49 @@ static int netdag_gen_afspec_set(struct dagger *net, struct lyd_node *dif,
return -ENOSYS;
}
static bool is_phys_addr_deleted(struct lyd_node *dif)
{
struct lyd_node *node;
node = lydx_get_child(dif, "phys-address");
if (node && lydx_get_op(node) == LYDX_OP_DELETE)
return true;
return false;
}
static bool netdag_must_del(struct lyd_node *dif, struct lyd_node *cif)
{
const char *iftype = lydx_get_cattr(cif, "type");
if (!strcmp(iftype, "infix-if-type:bridge"))
return 0;
if (!strcmp(iftype, "infix-if-type:vlan"))
return lydx_get_cattr(dif, "parent-interface") ||
lydx_get_descendant(lyd_child(dif),
"encapsulation",
"dot1q-vlan",
"outer-tag",
NULL);
if (!strcmp(iftype, "infix-if-type:veth"))
return lydx_get_descendant(lyd_child(dif), "peer", NULL);
if (!strcmp(iftype, "infix-if-type:bridge")) {
if (is_phys_addr_deleted(dif))
return true;
} else if (!strcmp(iftype, "infix-if-type:vlan")) {
if (is_phys_addr_deleted(dif))
return true;
if (lydx_get_cattr(dif, "parent-interface") ||
lydx_get_descendant(lyd_child(dif),
"encapsulation",
"dot1q-vlan",
"outer-tag",
NULL))
return true;
} else if (!strcmp(iftype, "infix-if-type:veth")) {
if (is_phys_addr_deleted(dif))
return true;
if (lydx_get_descendant(lyd_child(dif), "peer", NULL))
return true;
/*
} else if (!strcmp(iftype, "infix-if-type:lag")) {
if (is_phys_addr_deleted(dif))
return true;
... REMEMBER WHEN ADDING BOND SUPPORT ...
*/
}
return false;
}