mirror of
https://github.com/kernelkit/infix.git
synced 2026-08-03 14:23:02 +02:00
src/confd: fix invalid xpath, 'enabled' not available per address
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
This commit is contained in:
@@ -65,6 +65,8 @@ static int ifchange(sr_session_ctx_t *session, uint32_t sub_id, const char *modu
|
||||
"/proc/sys/net/ipv4/conf/%s/forwarding", ifname);
|
||||
|
||||
systemf("ip addr flush dev %s", ifname);
|
||||
if (!srx_enabled(session, "%s//ietf-ip:ipv4/enabled", xpath))
|
||||
goto ipv6;
|
||||
|
||||
snprintf(path, sizeof(path), "%s/ietf-ip:ipv4/address", xpath);
|
||||
rc = sr_get_items(session, path, 0, 0, &addr, &addrcnt);
|
||||
@@ -81,18 +83,17 @@ static int ifchange(sr_session_ctx_t *session, uint32_t sub_id, const char *modu
|
||||
free(netmask);
|
||||
}
|
||||
}
|
||||
if (plen > 0) {
|
||||
char *add = "add";
|
||||
|
||||
if (!srx_enabled(session, "%s/enabled", addr[j].xpath))
|
||||
add = "del";
|
||||
|
||||
ERROR("Preparing to %s addess %s", add, address);
|
||||
if (plen == 0)
|
||||
ERROR("%s: missing netmask or invalid prefix-length", address);
|
||||
else
|
||||
systemf("ip addr add %s/%d dev %s", address, plen, ifname);
|
||||
}
|
||||
free(address);
|
||||
}
|
||||
|
||||
ipv6:
|
||||
/* XXX todo */
|
||||
|
||||
systemf("ip link set %s %s", ifname, srx_enabled(session, "%s/enabled", xpath) ? "up" : "down");
|
||||
free(ifname);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user