char oldpath[XPATH_MAXLEN];
char newpath[XPATH_MAXLEN];
- if_dnode = yang_dnode_getf(
- running_config->dnode,
- "/frr-interface:lib/interface[name='%s'][vrf='%s']/vrf",
- ifp->name, old_vrf->name);
+ snprintf(oldpath, sizeof(oldpath),
+ "/frr-interface:lib/interface[name='%s'][vrf='%s']",
+ ifp->name, old_vrf->name);
+ snprintf(newpath, sizeof(newpath),
+ "/frr-interface:lib/interface[name='%s'][vrf='%s']",
+ ifp->name, vrf->name);
+
+ if_dnode = yang_dnode_getf(running_config->dnode, "%s/vrf",
+ oldpath);
if (if_dnode) {
- yang_dnode_get_path(lyd_parent(if_dnode), oldpath,
- sizeof(oldpath));
yang_dnode_change_leaf(if_dnode, vrf->name);
- yang_dnode_get_path(lyd_parent(if_dnode), newpath,
- sizeof(newpath));
nb_running_move_tree(oldpath, newpath);
running_config->version++;
}
+
+ vty_update_xpath(oldpath, newpath);
}
}
/* Vector which store each vty structure. */
static vector vtyvec;
+/* Vector for vtysh connections. */
+static vector vtyshvec;
+
/* Vty timeout value. */
static unsigned long vty_timeout_val = VTY_TIMEOUT_DEFAULT;
vty->wfd = sock;
vty->type = VTY_SHELL_SERV;
vty->node = VIEW_NODE;
+ vector_set_index(vtyshvec, sock, vty);
vty_event(VTYSH_READ, vty);
}
/* Unset vector. */
- if (vty->fd != -1)
- vector_unset(vtyvec, vty->fd);
+ if (vty->fd != -1) {
+ if (vty->type == VTY_SHELL_SERV)
+ vector_unset(vtyshvec, vty->fd);
+ else
+ vector_unset(vtyvec, vty->fd);
+ }
if (vty->wfd > 0 && vty->type == VTY_FILE)
fsync(vty->wfd);
}
}
+static void update_xpath(struct vty *vty, const char *oldpath,
+ const char *newpath)
+{
+ int i;
+
+ for (i = 0; i < vty->xpath_index; i++) {
+ if (!frrstr_startswith(vty->xpath[i], oldpath))
+ break;
+
+ char *tmp = frrstr_replace(vty->xpath[i], oldpath, newpath);
+ strlcpy(vty->xpath[i], tmp, sizeof(vty->xpath[0]));
+ XFREE(MTYPE_TMP, tmp);
+ }
+}
+
+void vty_update_xpath(const char *oldpath, const char *newpath)
+{
+ struct vty *vty;
+ unsigned int i;
+
+ for (i = 0; i < vector_active(vtyshvec); i++) {
+ if ((vty = vector_slot(vtyshvec, i)) == NULL)
+ continue;
+
+ update_xpath(vty, oldpath, newpath);
+ }
+
+ for (i = 0; i < vector_active(vtyvec); i++) {
+ if ((vty = vector_slot(vtyvec, i)) == NULL)
+ continue;
+
+ update_xpath(vty, oldpath, newpath);
+ }
+}
+
int vty_config_enter(struct vty *vty, bool private_config, bool exclusive)
{
if (exclusive && nb_running_lock(NB_CLIENT_CLI, vty)) {
vty_save_cwd();
vtyvec = vector_init(VECTOR_MIN_SIZE);
+ vtyshvec = vector_init(VECTOR_MIN_SIZE);
vty_master = master_thread;
vtyvec = NULL;
Vvty_serv_thread = NULL;
}
+ if (vtyshvec) {
+ vector_free(vtyshvec);
+ vtyshvec = NULL;
+ }
}
extern char *vty_get_cwd(void);
extern void vty_log(const char *level, const char *proto, const char *msg,
struct timestamp_control *);
+extern void vty_update_xpath(const char *oldpath, const char *newpath);
extern int vty_config_enter(struct vty *vty, bool private_config,
bool exclusive);
extern void vty_config_exit(struct vty *);