confd: skip veth peer also when deleting interfaces

When adding interfaces over NETCONF/RESTCONF, confd has a check to
ensure the peer end is skipped, since creating one end also create
the other.

This patch adds the corresponding skip when deleting a VETH pair.

Fixes #658

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
This commit is contained in:
Joachim Wiberg
2024-09-27 13:00:02 +02:00
parent a06436a8c8
commit 35eeae55f4
3 changed files with 22 additions and 0 deletions
+5
View File
@@ -136,6 +136,11 @@ void dagger_skip_iface(struct dagger *d, const char *ifname)
touchf("%s/%d/skip/%s", d->path, d->next, ifname);
}
void dagger_skip_current_iface(struct dagger *d, const char *ifname)
{
touchf("%s/%d/skip/%s", d->path, d->current, ifname);
}
int dagger_should_skip(struct dagger *d, const char *ifname)
{
return fexistf("%s/%d/skip/%s", d->path, d->next, ifname);
+1
View File
@@ -28,6 +28,7 @@ int dagger_evolve(struct dagger *d);
int dagger_evolve_or_abandon(struct dagger *d);
void dagger_skip_iface(struct dagger *d, const char *ifname);
void dagger_skip_current_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);
+16
View File
@@ -1648,6 +1648,7 @@ static int netdag_gen_iface_del(struct dagger *net, struct lyd_node *dif,
struct lyd_node *cif, bool fixed)
{
const char *ifname = lydx_get_cattr(dif, "name");
const char *iftype = lydx_get_cattr(dif, "type");
FILE *ip;
DEBUG_IFACE(dif, "");
@@ -1656,6 +1657,21 @@ static int netdag_gen_iface_del(struct dagger *net, struct lyd_node *dif,
if (dagger_should_skip_current(net, ifname))
return 0;
if (!strcmp(iftype, "infix-if-type:veth")) {
struct lyd_node *node;
const char *peer;
node = lydx_get_descendant(lyd_child(dif), "veth", NULL);
if (!node)
return -EINVAL;
peer = lydx_get_cattr(node, "peer");
if (!peer)
return -EINVAL;
dagger_skip_current_iface(net, peer);
}
ip = dagger_fopen_current(net, "exit", ifname, 50, "exit.ip");
if (!ip)
return -EIO;