diff options
| author | Renato Westphal <renato@opensourcerouting.org> | 2017-03-30 11:33:08 -0300 |
|---|---|---|
| committer | Renato Westphal <renato@opensourcerouting.org> | 2017-03-31 13:51:53 -0300 |
| commit | 1d75a89d8553caab99e58668af30a9803d40d49b (patch) | |
| tree | bdfdc77f6f84973d2fe3e27a1da6d0fa1b75a322 /ldpd/ldp_vty_conf.c | |
| parent | 7d0eeac1a154b76ff55c1ad53ae97a05a3ca977a (diff) | |
ldpd: do not consume vty_conf when updating the configuration
David Lamparter gave the idea of keeping vty_conf as a permanent copy of
ldpd_conf in order to simplify the CLI code and facilitate the integration
with his cap'n proto framework in the future. Doing this demanded quite
some effort but it was worth it as the code looks much better now.
Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
Diffstat (limited to 'ldpd/ldp_vty_conf.c')
| -rw-r--r-- | ldpd/ldp_vty_conf.c | 232 |
1 files changed, 74 insertions, 158 deletions
diff --git a/ldpd/ldp_vty_conf.c b/ldpd/ldp_vty_conf.c index 4c6cfcd4a3..e4fc7b0054 100644 --- a/ldpd/ldp_vty_conf.c +++ b/ldpd/ldp_vty_conf.c @@ -36,17 +36,11 @@ static void ldp_af_iface_config_write(struct vty *, int); static void ldp_af_config_write(struct vty *, int, struct ldpd_conf *, struct ldpd_af_conf *); static void ldp_l2vpn_pw_config_write(struct vty *, struct l2vpn_pw *); -static void ldp_vty_push_node(struct vty *, int, void *); -static void *ldp_vty_get_node(struct vty *, void *, int); static int ldp_vty_get_af(struct vty *); static int ldp_iface_is_configured(struct ldpd_conf *, const char *); static int ldp_vty_nbr_session_holdtime(struct vty *, struct vty_arg *[]); static int ldp_vty_af_session_holdtime(struct vty *, struct vty_arg *[]); -static struct iface *vty_iface; -static struct l2vpn *vty_l2vpn; -static struct l2vpn_pw *vty_pw; - struct cmd_node ldp_node = { LDP_NODE, @@ -391,94 +385,6 @@ ldp_l2vpn_config_write(struct vty *vty) return (0); } -void -ldp_vty_push_node(struct vty *vty, int node, void *ptr) -{ - if (global.sighup) { - switch (node) { - case LDP_IPV4_IFACE_NODE: - case LDP_IPV6_IFACE_NODE: - vty_iface = ptr; - break; - case LDP_L2VPN_NODE: - vty_l2vpn = ptr; - break; - case LDP_PSEUDOWIRE_NODE: - vty_pw = ptr; - break; - default: - fatalx("ldp_vty_push_node: unexpected node"); - } - vty->node = node; - return; - } - - switch (node) { - case LDP_IPV4_IFACE_NODE: - case LDP_IPV6_IFACE_NODE: - VTY_PUSH_CONTEXT(node, (struct iface *)ptr); - break; - case LDP_L2VPN_NODE: - VTY_PUSH_CONTEXT(node, (struct l2vpn *)ptr); - break; - case LDP_PSEUDOWIRE_NODE: - VTY_PUSH_CONTEXT_SUB(node, (struct l2vpn_pw *)ptr); - break; - default: - fatalx("ldp_vty_push_node: unexpected node"); - } -} - -void * -ldp_vty_get_node(struct vty *vty, void *parent, int node) -{ - struct iface *iface; - struct l2vpn *l2vpn; - struct l2vpn_pw *pw; - - if (global.sighup) { - switch (node) { - case LDP_IPV4_IFACE_NODE: - case LDP_IPV6_IFACE_NODE: - return (vty_iface); - case LDP_L2VPN_NODE: - return (vty_l2vpn); - case LDP_PSEUDOWIRE_NODE: - return (vty_pw); - default: - fatalx("ldp_vty_get_node: unexpected node"); - } - } - - /* - * Since VTY_GET_CONTEXT() returns a pointer to an element of ldpd_conf, - * we have to find the equivalent element inside vty_conf (which should - * always exist as vty_conf is a duplicate of ldpd_conf). - */ - switch (node) { - case LDP_IPV4_IFACE_NODE: - case LDP_IPV6_IFACE_NODE: - iface = VTY_GET_CONTEXT(iface); - if (iface) - return (if_lookup_name(vty_conf, iface->name)); - break; - case LDP_L2VPN_NODE: - l2vpn = VTY_GET_CONTEXT(l2vpn); - if (l2vpn) - return (l2vpn_find(vty_conf, l2vpn->name)); - break; - case LDP_PSEUDOWIRE_NODE: - pw = VTY_GET_CONTEXT_SUB(l2vpn_pw); - if (pw) - return (l2vpn_pw_find(parent, pw->ifname)); - break; - default: - fatalx("ldp_vty_get_node: unexpected node"); - } - - return (NULL); -} - static int ldp_vty_get_af(struct vty *vty) { @@ -656,7 +562,7 @@ ldp_vty_disc_holdtime(struct vty *vty, struct vty_arg *args[]) case LDP_IPV4_IFACE_NODE: case LDP_IPV6_IFACE_NODE: af = ldp_vty_get_af(vty); - iface = ldp_vty_get_node(vty, NULL, vty->node); + iface = VTY_GET_CONTEXT(iface); VTY_CHECK_CONTEXT(iface); ia = iface_af_get(iface, af); @@ -664,6 +570,7 @@ ldp_vty_disc_holdtime(struct vty *vty, struct vty_arg *args[]) ia->hello_holdtime = 0; else ia->hello_holdtime = secs; + ldp_reload(vty_conf); break; default: @@ -756,7 +663,7 @@ ldp_vty_disc_interval(struct vty *vty, struct vty_arg *args[]) case LDP_IPV4_IFACE_NODE: case LDP_IPV6_IFACE_NODE: af = ldp_vty_get_af(vty); - iface = ldp_vty_get_node(vty, NULL, vty->node); + iface = VTY_GET_CONTEXT(iface); VTY_CHECK_CONTEXT(iface); ia = iface_af_get(iface, af); @@ -764,6 +671,7 @@ ldp_vty_disc_interval(struct vty *vty, struct vty_arg *args[]) ia->hello_interval = 0; else ia->hello_interval = secs; + ldp_reload(vty_conf); break; default: @@ -825,14 +733,14 @@ ldp_vty_nbr_session_holdtime(struct vty *vty, struct vty_arg *args[]) return (CMD_WARNING); } - nbrp = nbr_params_find(vty_conf, lsr_id); - secs = strtol(seconds_str, &ep, 10); if (*ep != '\0' || secs < MIN_KEEPALIVE || secs > MAX_KEEPALIVE) { vty_out(vty, "%% Invalid holdtime%s", VTY_NEWLINE); return (CMD_SUCCESS); } + nbrp = nbr_params_find(vty_conf, lsr_id); + if (disable) { if (nbrp == NULL) return (CMD_SUCCESS); @@ -843,6 +751,7 @@ ldp_vty_nbr_session_holdtime(struct vty *vty, struct vty_arg *args[]) if (nbrp == NULL) { nbrp = nbr_params_new(lsr_id); RB_INSERT(nbrp_head, &vty_conf->nbrp_tree, nbrp); + QOBJ_REG(nbrp, nbr_params); } else if (nbrp->keepalive == secs) return (CMD_SUCCESS); @@ -927,7 +836,9 @@ ldp_vty_interface(struct vty *vty, struct vty_arg *args[]) ia->enabled = 0; ia->hello_holdtime = 0; ia->hello_interval = 0; + ldp_reload(vty_conf); + return (CMD_SUCCESS); } @@ -942,6 +853,8 @@ ldp_vty_interface(struct vty *vty, struct vty_arg *args[]) ia = iface_af_get(iface, af); ia->enabled = 1; RB_INSERT(iface_head, &vty_conf->iface_tree, iface); + QOBJ_REG(iface, iface); + ldp_reload(vty_conf); } else { ia = iface_af_get(iface, af); @@ -953,10 +866,10 @@ ldp_vty_interface(struct vty *vty, struct vty_arg *args[]) switch (af) { case AF_INET: - ldp_vty_push_node(vty, LDP_IPV4_IFACE_NODE, iface); + VTY_PUSH_CONTEXT(LDP_IPV4_IFACE_NODE, iface); break; case AF_INET6: - ldp_vty_push_node(vty, LDP_IPV6_IFACE_NODE, iface); + VTY_PUSH_CONTEXT(LDP_IPV6_IFACE_NODE, iface); break; default: break; @@ -1024,9 +937,12 @@ ldp_vty_neighbor_targeted(struct vty *vty, struct vty_arg *args[]) if (tnbr == NULL) return (CMD_SUCCESS); + QOBJ_UNREG(tnbr); RB_REMOVE(tnbr_head, &vty_conf->tnbr_tree, tnbr); free(tnbr); + ldp_reload(vty_conf); + return (CMD_SUCCESS); } @@ -1036,6 +952,7 @@ ldp_vty_neighbor_targeted(struct vty *vty, struct vty_arg *args[]) tnbr = tnbr_new(af, &addr); tnbr->flags |= F_TNBR_CONFIGURED; RB_INSERT(tnbr_head, &vty_conf->tnbr_tree, tnbr); + QOBJ_REG(tnbr, tnbr); ldp_reload(vty_conf); @@ -1290,6 +1207,7 @@ ldp_vty_neighbor_password(struct vty *vty, struct vty_arg *args[]) if (nbrp == NULL) { nbrp = nbr_params_new(lsr_id); RB_INSERT(nbrp_head, &vty_conf->nbrp_tree, nbrp); + QOBJ_REG(nbrp, nbr_params); } else if (nbrp->auth.method == AUTH_MD5SIG && strcmp(nbrp->auth.md5key, password_str) == 0) return (CMD_SUCCESS); @@ -1350,6 +1268,7 @@ ldp_vty_neighbor_ttl_security(struct vty *vty, struct vty_arg *args[]) if (nbrp == NULL) { nbrp = nbr_params_new(lsr_id); RB_INSERT(nbrp_head, &vty_conf->nbrp_tree, nbrp); + QOBJ_REG(nbrp, nbr_params); } nbrp->flags |= F_NBRP_GTSM; @@ -1371,6 +1290,8 @@ int ldp_vty_l2vpn(struct vty *vty, struct vty_arg *args[]) { struct l2vpn *l2vpn; + struct l2vpn_if *lif; + struct l2vpn_pw *pw; const char *name_str; int disable; @@ -1383,23 +1304,34 @@ ldp_vty_l2vpn(struct vty *vty, struct vty_arg *args[]) if (l2vpn == NULL) return (CMD_SUCCESS); + RB_FOREACH(lif, l2vpn_if_head, &l2vpn->if_tree) + QOBJ_UNREG(lif); + RB_FOREACH(pw, l2vpn_pw_head, &l2vpn->pw_tree) + QOBJ_UNREG(pw); + RB_FOREACH(pw, l2vpn_pw_head, &l2vpn->pw_inactive_tree) + QOBJ_UNREG(pw); + QOBJ_UNREG(l2vpn); RB_REMOVE(l2vpn_head, &vty_conf->l2vpn_tree, l2vpn); l2vpn_del(l2vpn); + ldp_reload(vty_conf); + return (CMD_SUCCESS); } if (l2vpn) { - ldp_vty_push_node(vty, LDP_L2VPN_NODE, l2vpn); + VTY_PUSH_CONTEXT(LDP_L2VPN_NODE, l2vpn); return (CMD_SUCCESS); } l2vpn = l2vpn_new(name_str); l2vpn->type = L2VPN_TYPE_VPLS; RB_INSERT(l2vpn_head, &vty_conf->l2vpn_tree, l2vpn); + QOBJ_REG(l2vpn, l2vpn); + + VTY_PUSH_CONTEXT(LDP_L2VPN_NODE, l2vpn); ldp_reload(vty_conf); - ldp_vty_push_node(vty, LDP_L2VPN_NODE, l2vpn); return (CMD_SUCCESS); } @@ -1407,16 +1339,13 @@ ldp_vty_l2vpn(struct vty *vty, struct vty_arg *args[]) int ldp_vty_l2vpn_bridge(struct vty *vty, struct vty_arg *args[]) { - struct l2vpn *l2vpn; + VTY_DECLVAR_CONTEXT(l2vpn, l2vpn); const char *ifname; int disable; disable = (vty_get_arg_value(args, "no")) ? 1 : 0; ifname = vty_get_arg_value(args, "ifname"); - l2vpn = ldp_vty_get_node(vty, NULL, LDP_L2VPN_NODE); - VTY_CHECK_CONTEXT(l2vpn); - if (disable) memset(l2vpn->br_ifname, 0, sizeof(l2vpn->br_ifname)); else @@ -1430,7 +1359,7 @@ ldp_vty_l2vpn_bridge(struct vty *vty, struct vty_arg *args[]) int ldp_vty_l2vpn_mtu(struct vty *vty, struct vty_arg *args[]) { - struct l2vpn *l2vpn; + VTY_DECLVAR_CONTEXT(l2vpn, l2vpn); char *ep; int mtu; const char *mtu_str; @@ -1445,9 +1374,6 @@ ldp_vty_l2vpn_mtu(struct vty *vty, struct vty_arg *args[]) return (CMD_WARNING); } - l2vpn = ldp_vty_get_node(vty, NULL, LDP_L2VPN_NODE); - VTY_CHECK_CONTEXT(l2vpn); - if (disable) l2vpn->mtu = DEFAULT_L2VPN_MTU; else @@ -1461,7 +1387,7 @@ ldp_vty_l2vpn_mtu(struct vty *vty, struct vty_arg *args[]) int ldp_vty_l2vpn_pwtype(struct vty *vty, struct vty_arg *args[]) { - struct l2vpn *l2vpn; + VTY_DECLVAR_CONTEXT(l2vpn, l2vpn); int pw_type; const char *type_str; int disable; @@ -1474,9 +1400,6 @@ ldp_vty_l2vpn_pwtype(struct vty *vty, struct vty_arg *args[]) else pw_type = PW_TYPE_ETHERNET_TAGGED; - l2vpn = ldp_vty_get_node(vty, NULL, LDP_L2VPN_NODE); - VTY_CHECK_CONTEXT(l2vpn); - if (disable) l2vpn->pw_type = DEFAULT_PW_TYPE; else @@ -1490,7 +1413,7 @@ ldp_vty_l2vpn_pwtype(struct vty *vty, struct vty_arg *args[]) int ldp_vty_l2vpn_interface(struct vty *vty, struct vty_arg *args[]) { - struct l2vpn *l2vpn; + VTY_DECLVAR_CONTEXT(l2vpn, l2vpn); struct l2vpn_if *lif; const char *ifname; int disable; @@ -1498,17 +1421,18 @@ ldp_vty_l2vpn_interface(struct vty *vty, struct vty_arg *args[]) disable = (vty_get_arg_value(args, "no")) ? 1 : 0; ifname = vty_get_arg_value(args, "ifname"); - l2vpn = ldp_vty_get_node(vty, NULL, LDP_L2VPN_NODE); - VTY_CHECK_CONTEXT(l2vpn); lif = l2vpn_if_find(l2vpn, ifname); if (disable) { if (lif == NULL) return (CMD_SUCCESS); + QOBJ_UNREG(lif); RB_REMOVE(l2vpn_if_head, &l2vpn->if_tree, lif); free(lif); + ldp_reload(vty_conf); + return (CMD_SUCCESS); } @@ -1522,6 +1446,7 @@ ldp_vty_l2vpn_interface(struct vty *vty, struct vty_arg *args[]) lif = l2vpn_if_new(l2vpn, ifname); RB_INSERT(l2vpn_if_head, &l2vpn->if_tree, lif); + QOBJ_REG(lif, l2vpn_if); ldp_reload(vty_conf); @@ -1531,7 +1456,7 @@ ldp_vty_l2vpn_interface(struct vty *vty, struct vty_arg *args[]) int ldp_vty_l2vpn_pseudowire(struct vty *vty, struct vty_arg *args[]) { - struct l2vpn *l2vpn; + VTY_DECLVAR_CONTEXT(l2vpn, l2vpn); struct l2vpn_pw *pw; const char *ifname; int disable; @@ -1539,22 +1464,26 @@ ldp_vty_l2vpn_pseudowire(struct vty *vty, struct vty_arg *args[]) disable = (vty_get_arg_value(args, "no")) ? 1 : 0; ifname = vty_get_arg_value(args, "ifname"); - l2vpn = ldp_vty_get_node(vty, NULL, LDP_L2VPN_NODE); - VTY_CHECK_CONTEXT(l2vpn); pw = l2vpn_pw_find(l2vpn, ifname); if (disable) { if (pw == NULL) return (CMD_SUCCESS); - RB_REMOVE(l2vpn_pw_head, &l2vpn->pw_inactive_tree, pw); + QOBJ_UNREG(pw); + if (pw->lsr_id.s_addr == INADDR_ANY || pw->pwid == 0) + RB_REMOVE(l2vpn_pw_head, &l2vpn->pw_inactive_tree, pw); + else + RB_REMOVE(l2vpn_pw_head, &l2vpn->pw_tree, pw); free(pw); + ldp_reload(vty_conf); + return (CMD_SUCCESS); } if (pw) { - ldp_vty_push_node(vty, LDP_PSEUDOWIRE_NODE, pw); + VTY_PUSH_CONTEXT_SUB(LDP_PSEUDOWIRE_NODE, pw); return (CMD_SUCCESS); } @@ -1566,9 +1495,11 @@ ldp_vty_l2vpn_pseudowire(struct vty *vty, struct vty_arg *args[]) pw = l2vpn_pw_new(l2vpn, ifname); pw->flags = F_PW_STATUSTLV_CONF|F_PW_CWORD_CONF; RB_INSERT(l2vpn_pw_head, &l2vpn->pw_inactive_tree, pw); + QOBJ_REG(pw, l2vpn_pw); + + VTY_PUSH_CONTEXT_SUB(LDP_PSEUDOWIRE_NODE, pw); ldp_reload(vty_conf); - ldp_vty_push_node(vty, LDP_PSEUDOWIRE_NODE, pw); return (CMD_SUCCESS); } @@ -1576,19 +1507,13 @@ ldp_vty_l2vpn_pseudowire(struct vty *vty, struct vty_arg *args[]) int ldp_vty_l2vpn_pw_cword(struct vty *vty, struct vty_arg *args[]) { - struct l2vpn *l2vpn; - struct l2vpn_pw *pw; + VTY_DECLVAR_CONTEXT_SUB(l2vpn_pw, pw); const char *preference_str; int disable; disable = (vty_get_arg_value(args, "no")) ? 1 : 0; preference_str = vty_get_arg_value(args, "preference"); - l2vpn = ldp_vty_get_node(vty, NULL, LDP_L2VPN_NODE); - VTY_CHECK_CONTEXT(l2vpn); - pw = ldp_vty_get_node(vty, l2vpn, LDP_PSEUDOWIRE_NODE); - VTY_CHECK_CONTEXT(pw); - if (disable) pw->flags |= F_PW_CWORD_CONF; else { @@ -1606,8 +1531,7 @@ ldp_vty_l2vpn_pw_cword(struct vty *vty, struct vty_arg *args[]) int ldp_vty_l2vpn_pw_nbr_addr(struct vty *vty, struct vty_arg *args[]) { - struct l2vpn *l2vpn; - struct l2vpn_pw *pw; + VTY_DECLVAR_CONTEXT_SUB(l2vpn_pw, pw); int af; union ldpd_addr addr; const char *addr_str; @@ -1622,11 +1546,6 @@ ldp_vty_l2vpn_pw_nbr_addr(struct vty *vty, struct vty_arg *args[]) return (CMD_WARNING); } - l2vpn = ldp_vty_get_node(vty, NULL, LDP_L2VPN_NODE); - VTY_CHECK_CONTEXT(l2vpn); - pw = ldp_vty_get_node(vty, l2vpn, LDP_PSEUDOWIRE_NODE); - VTY_CHECK_CONTEXT(pw); - if (disable) { pw->af = AF_UNSPEC; memset(&pw->addr, 0, sizeof(pw->addr)); @@ -1645,8 +1564,7 @@ ldp_vty_l2vpn_pw_nbr_addr(struct vty *vty, struct vty_arg *args[]) int ldp_vty_l2vpn_pw_nbr_id(struct vty *vty, struct vty_arg *args[]) { - struct l2vpn *l2vpn; - struct l2vpn_pw *pw; + VTY_DECLVAR_CONTEXT_SUB(l2vpn_pw, pw); struct in_addr lsr_id; const char *lsr_id_str; int disable; @@ -1660,11 +1578,6 @@ ldp_vty_l2vpn_pw_nbr_id(struct vty *vty, struct vty_arg *args[]) return (CMD_WARNING); } - l2vpn = ldp_vty_get_node(vty, NULL, LDP_L2VPN_NODE); - VTY_CHECK_CONTEXT(l2vpn); - pw = ldp_vty_get_node(vty, l2vpn, LDP_PSEUDOWIRE_NODE); - VTY_CHECK_CONTEXT(pw); - if (disable) pw->lsr_id.s_addr = INADDR_ANY; else @@ -1678,8 +1591,7 @@ ldp_vty_l2vpn_pw_nbr_id(struct vty *vty, struct vty_arg *args[]) int ldp_vty_l2vpn_pw_pwid(struct vty *vty, struct vty_arg *args[]) { - struct l2vpn *l2vpn; - struct l2vpn_pw *pw; + VTY_DECLVAR_CONTEXT_SUB(l2vpn_pw, pw); char *ep; uint32_t pwid; const char *pwid_str; @@ -1694,11 +1606,6 @@ ldp_vty_l2vpn_pw_pwid(struct vty *vty, struct vty_arg *args[]) return (CMD_WARNING); } - l2vpn = ldp_vty_get_node(vty, NULL, LDP_L2VPN_NODE); - VTY_CHECK_CONTEXT(l2vpn); - pw = ldp_vty_get_node(vty, l2vpn, LDP_PSEUDOWIRE_NODE); - VTY_CHECK_CONTEXT(pw); - if (disable) pw->pwid = 0; else @@ -1712,17 +1619,11 @@ ldp_vty_l2vpn_pw_pwid(struct vty *vty, struct vty_arg *args[]) int ldp_vty_l2vpn_pw_pwstatus(struct vty *vty, struct vty_arg *args[]) { - struct l2vpn *l2vpn; - struct l2vpn_pw *pw; + VTY_DECLVAR_CONTEXT_SUB(l2vpn_pw, pw); int disable; disable = (vty_get_arg_value(args, "no")) ? 1 : 0; - l2vpn = ldp_vty_get_node(vty, NULL, LDP_L2VPN_NODE); - VTY_CHECK_CONTEXT(l2vpn); - pw = ldp_vty_get_node(vty, l2vpn, LDP_PSEUDOWIRE_NODE); - VTY_CHECK_CONTEXT(pw); - if (disable) pw->flags |= F_PW_STATUSTLV_CONF; else @@ -1744,12 +1645,14 @@ iface_new_api(struct ldpd_conf *conf, const char *name) iface = if_new(name); RB_INSERT(iface_head, &conf->iface_tree, iface); + QOBJ_REG(iface, iface); return (iface); } void iface_del_api(struct ldpd_conf *conf, struct iface *iface) { + QOBJ_UNREG(iface); RB_REMOVE(iface_head, &conf->iface_tree, iface); free(iface); } @@ -1768,12 +1671,14 @@ tnbr_new_api(struct ldpd_conf *conf, int af, union ldpd_addr *addr) tnbr = tnbr_new(af, addr); tnbr->flags |= F_TNBR_CONFIGURED; RB_INSERT(tnbr_head, &conf->tnbr_tree, tnbr); + QOBJ_REG(tnbr, tnbr); return (tnbr); } void tnbr_del_api(struct ldpd_conf *conf, struct tnbr *tnbr) { + QOBJ_UNREG(tnbr); RB_REMOVE(tnbr_head, &conf->tnbr_tree, tnbr); free(tnbr); } @@ -1788,12 +1693,14 @@ nbrp_new_api(struct ldpd_conf *conf, struct in_addr lsr_id) nbrp = nbr_params_new(lsr_id); RB_INSERT(nbrp_head, &conf->nbrp_tree, nbrp); + QOBJ_REG(nbrp, nbr_params); return (nbrp); } void nbrp_del_api(struct ldpd_conf *conf, struct nbr_params *nbrp) { + QOBJ_UNREG(nbrp); RB_REMOVE(nbrp_head, &conf->nbrp_tree, nbrp); free(nbrp); } @@ -1809,6 +1716,7 @@ l2vpn_new_api(struct ldpd_conf *conf, const char *name) l2vpn = l2vpn_new(name); l2vpn->type = L2VPN_TYPE_VPLS; RB_INSERT(l2vpn_head, &conf->l2vpn_tree, l2vpn); + QOBJ_REG(l2vpn, l2vpn); return (l2vpn); } @@ -1819,17 +1727,21 @@ l2vpn_del_api(struct ldpd_conf *conf, struct l2vpn *l2vpn) struct l2vpn_pw *pw; while ((lif = RB_ROOT(&l2vpn->if_tree)) != NULL) { + QOBJ_UNREG(lif); RB_REMOVE(l2vpn_if_head, &l2vpn->if_tree, lif); free(lif); } while ((pw = RB_ROOT(&l2vpn->pw_tree)) != NULL) { + QOBJ_UNREG(pw); RB_REMOVE(l2vpn_pw_head, &l2vpn->pw_tree, pw); free(pw); } while ((pw = RB_ROOT(&l2vpn->pw_inactive_tree)) != NULL) { + QOBJ_UNREG(pw); RB_REMOVE(l2vpn_pw_head, &l2vpn->pw_inactive_tree, pw); free(pw); } + QOBJ_UNREG(l2vpn); RB_REMOVE(l2vpn_head, &conf->l2vpn_tree, l2vpn); free(l2vpn); } @@ -1845,12 +1757,14 @@ l2vpn_if_new_api(struct ldpd_conf *conf, struct l2vpn *l2vpn, lif = l2vpn_if_new(l2vpn, ifname); RB_INSERT(l2vpn_if_head, &l2vpn->if_tree, lif); + QOBJ_REG(lif, l2vpn_if); return (lif); } void l2vpn_if_del_api(struct l2vpn *l2vpn, struct l2vpn_if *lif) { + QOBJ_UNREG(lif); RB_REMOVE(l2vpn_if_head, &l2vpn->if_tree, lif); free(lif); } @@ -1867,12 +1781,14 @@ l2vpn_pw_new_api(struct ldpd_conf *conf, struct l2vpn *l2vpn, pw = l2vpn_pw_new(l2vpn, ifname); pw->flags = F_PW_STATUSTLV_CONF|F_PW_CWORD_CONF; RB_INSERT(l2vpn_pw_head, &l2vpn->pw_inactive_tree, pw); + QOBJ_REG(pw, l2vpn_pw); return (pw); } void l2vpn_pw_del_api(struct l2vpn *l2vpn, struct l2vpn_pw *pw) { + QOBJ_UNREG(pw); RB_REMOVE(l2vpn_pw_head, &l2vpn->pw_inactive_tree, pw); free(pw); } |
