int
ldp_vty_mpls_ldp(struct vty *vty, struct vty_arg *args[])
{
- struct ldpd_conf *vty_conf;
int disable;
- vty_conf = ldp_dup_config(ldpd_conf);
-
disable = (vty_get_arg_value(args, "no")) ? 1 : 0;
if (disable)
int
ldp_vty_address_family(struct vty *vty, struct vty_arg *args[])
{
- struct ldpd_conf *vty_conf;
struct ldpd_af_conf *af_conf;
int af;
const char *af_str;
disable = (vty_get_arg_value(args, "no")) ? 1 : 0;
af_str = vty_get_arg_value(args, "address-family");
- vty_conf = ldp_dup_config(ldpd_conf);
if (strcmp(af_str, "ipv4") == 0) {
af = AF_INET;
af_conf = &vty_conf->ipv4;
} else if (strcmp(af_str, "ipv6") == 0) {
af = AF_INET6;
af_conf = &vty_conf->ipv6;
- } else {
- ldp_clear_config(vty_conf);
+ } else
return (CMD_WARNING);
- }
if (disable) {
af_conf->flags &= ~F_LDPD_AF_ENABLED;
int
ldp_vty_disc_holdtime(struct vty *vty, struct vty_arg *args[])
{
- struct ldpd_conf *vty_conf;
struct ldpd_af_conf *af_conf;
struct iface *iface;
struct iface_af *ia;
switch (vty->node) {
case LDP_NODE:
- vty_conf = ldp_dup_config(ldpd_conf);
if (disable) {
switch (hello_type) {
case HELLO_LINK:
break;
case LDP_IPV4_NODE:
case LDP_IPV6_NODE:
- vty_conf = ldp_dup_config(ldpd_conf);
af = ldp_vty_get_af(vty);
af_conf = ldp_af_conf_get(vty_conf, af);
case LDP_IPV6_IFACE_NODE:
af = ldp_vty_get_af(vty);
iface = VTY_GET_CONTEXT(iface);
- vty_conf = ldp_dup_config_ref(ldpd_conf, (void **)&iface);
ia = iface_af_get(iface, af);
if (disable)
ia->hello_holdtime = 0;
else
ia->hello_holdtime = secs;
- ldp_reload_ref(vty_conf, (void **)&iface);
+ ldp_reload(vty_conf);
break;
default:
fatalx("ldp_vty_disc_holdtime: unexpected node");
int
ldp_vty_disc_interval(struct vty *vty, struct vty_arg *args[])
{
- struct ldpd_conf *vty_conf;
struct ldpd_af_conf *af_conf;
struct iface *iface;
struct iface_af *ia;
switch (vty->node) {
case LDP_NODE:
- vty_conf = ldp_dup_config(ldpd_conf);
if (disable) {
switch (hello_type) {
case HELLO_LINK:
break;
case LDP_IPV4_NODE:
case LDP_IPV6_NODE:
- vty_conf = ldp_dup_config(ldpd_conf);
af = ldp_vty_get_af(vty);
af_conf = ldp_af_conf_get(vty_conf, af);
case LDP_IPV6_IFACE_NODE:
af = ldp_vty_get_af(vty);
iface = VTY_GET_CONTEXT(iface);
- vty_conf = ldp_dup_config_ref(ldpd_conf, (void **)&iface);
ia = iface_af_get(iface, af);
if (disable)
ia->hello_interval = 0;
else
ia->hello_interval = secs;
- ldp_reload_ref(vty_conf, (void **)&iface);
+ ldp_reload(vty_conf);
break;
default:
fatalx("ldp_vty_disc_interval: unexpected node");
int
ldp_vty_targeted_hello_accept(struct vty *vty, struct vty_arg *args[])
{
- struct ldpd_conf *vty_conf;
struct ldpd_af_conf *af_conf;
int af;
const char *acl_from_str;
int disable;
- vty_conf = ldp_dup_config(ldpd_conf);
-
disable = (vty_get_arg_value(args, "no")) ? 1 : 0;
acl_from_str = vty_get_arg_value(args, "from_acl");
static int
ldp_vty_nbr_session_holdtime(struct vty *vty, struct vty_arg *args[])
{
- struct ldpd_conf *vty_conf;
char *ep;
long int secs;
struct in_addr lsr_id;
return (CMD_WARNING);
}
- vty_conf = ldp_dup_config(ldpd_conf);
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);
- goto cancel;
+ return (CMD_SUCCESS);
}
if (disable) {
if (nbrp == NULL)
- goto cancel;
+ return (CMD_SUCCESS);
nbrp->keepalive = 0;
nbrp->flags &= ~F_NBRP_KEEPALIVE;
nbrp = nbr_params_new(lsr_id);
RB_INSERT(nbrp_head, &vty_conf->nbrp_tree, nbrp);
} else if (nbrp->keepalive == secs)
- goto cancel;
+ return (CMD_SUCCESS);
nbrp->keepalive = secs;
nbrp->flags |= F_NBRP_KEEPALIVE;
ldp_reload(vty_conf);
return (CMD_SUCCESS);
-
-cancel:
- ldp_clear_config(vty_conf);
- return (CMD_SUCCESS);
}
static int
ldp_vty_af_session_holdtime(struct vty *vty, struct vty_arg *args[])
{
- struct ldpd_conf *vty_conf;
struct ldpd_af_conf *af_conf;
int af;
char *ep;
return (CMD_SUCCESS);
}
- vty_conf = ldp_dup_config(ldpd_conf);
af = ldp_vty_get_af(vty);
af_conf = ldp_af_conf_get(vty_conf, af);
int
ldp_vty_interface(struct vty *vty, struct vty_arg *args[])
{
- struct ldpd_conf *vty_conf;
int af;
struct iface *iface;
struct iface_af *ia;
disable = (vty_get_arg_value(args, "no")) ? 1 : 0;
ifname = vty_get_arg_value(args, "ifname");
- vty_conf = ldp_dup_config(ldpd_conf);
af = ldp_vty_get_af(vty);
iface = if_lookup_name(vty_conf, ifname);
if (disable) {
if (iface == NULL)
- goto cancel;
+ return (CMD_SUCCESS);
ia = iface_af_get(iface, af);
if (ia->enabled == 0)
- goto cancel;
+ return (CMD_SUCCESS);
ia->enabled = 0;
ia->hello_holdtime = 0;
if (ldp_iface_is_configured(vty_conf, ifname)) {
vty_out(vty, "%% Interface is already in use%s",
VTY_NEWLINE);
- goto cancel;
+ return (CMD_SUCCESS);
}
ifp = if_lookup_by_name(ifname, VRF_DEFAULT);
ia = iface_af_get(iface, af);
ia->enabled = 1;
RB_INSERT(iface_head, &vty_conf->iface_tree, iface);
- ldp_reload_ref(vty_conf, (void **)&iface);
+ ldp_reload(vty_conf);
} else {
memset(&kif, 0, sizeof(kif));
strlcpy(kif.ifname, ifname, sizeof(kif.ifname));
ia = iface_af_get(iface, af);
if (!ia->enabled) {
ia->enabled = 1;
- ldp_reload_ref(vty_conf, (void **)&iface);
- } else
- ldp_clear_config(vty_conf);
+ ldp_reload(vty_conf);
+ }
}
switch (af) {
}
return (CMD_SUCCESS);
-
-cancel:
- ldp_clear_config(vty_conf);
- return (CMD_SUCCESS);
}
int
ldp_vty_trans_addr(struct vty *vty, struct vty_arg *args[])
{
- struct ldpd_conf *vty_conf;
struct ldpd_af_conf *af_conf;
int af;
const char *addr_str;
disable = (vty_get_arg_value(args, "no")) ? 1 : 0;
addr_str = vty_get_arg_value(args, "addr");
- vty_conf = ldp_dup_config(ldpd_conf);
af = ldp_vty_get_af(vty);
af_conf = ldp_af_conf_get(vty_conf, af);
if (inet_pton(af, addr_str, &af_conf->trans_addr) != 1 ||
bad_addr(af, &af_conf->trans_addr)) {
vty_out(vty, "%% Malformed address%s", VTY_NEWLINE);
- goto cancel;
+ return (CMD_SUCCESS);
}
}
ldp_reload(vty_conf);
return (CMD_SUCCESS);
-
-cancel:
- ldp_clear_config(vty_conf);
- return (CMD_SUCCESS);
}
int
ldp_vty_neighbor_targeted(struct vty *vty, struct vty_arg *args[])
{
- struct ldpd_conf *vty_conf;
int af;
union ldpd_addr addr;
struct tnbr *tnbr;
return (CMD_WARNING);
}
- vty_conf = ldp_dup_config(ldpd_conf);
tnbr = tnbr_find(vty_conf, af, &addr);
if (disable) {
if (tnbr == NULL)
- goto cancel;
+ return (CMD_SUCCESS);
RB_REMOVE(tnbr_head, &vty_conf->tnbr_tree, tnbr);
free(tnbr);
}
if (tnbr)
- goto cancel;
+ return (CMD_SUCCESS);
tnbr = tnbr_new(af, &addr);
tnbr->flags |= F_TNBR_CONFIGURED;
ldp_reload(vty_conf);
return (CMD_SUCCESS);
-
-cancel:
- ldp_clear_config(vty_conf);
- return (CMD_SUCCESS);
}
int
ldp_vty_label_advertise(struct vty *vty, struct vty_arg *args[])
{
- struct ldpd_conf *vty_conf;
struct ldpd_af_conf *af_conf;
int af;
const char *acl_to_str;
acl_to_str = vty_get_arg_value(args, "to_acl");
acl_for_str = vty_get_arg_value(args, "for_acl");
- vty_conf = ldp_dup_config(ldpd_conf);
af = ldp_vty_get_af(vty);
af_conf = ldp_af_conf_get(vty_conf, af);
int
ldp_vty_label_allocate(struct vty *vty, struct vty_arg *args[])
{
- struct ldpd_conf *vty_conf;
struct ldpd_af_conf *af_conf;
int af;
const char *acl_for_str;
acl_for_str = vty_get_arg_value(args, "for_acl");
host_routes_str = vty_get_arg_value(args, "host-routes");
- vty_conf = ldp_dup_config(ldpd_conf);
af = ldp_vty_get_af(vty);
af_conf = ldp_af_conf_get(vty_conf, af);
int
ldp_vty_label_expnull(struct vty *vty, struct vty_arg *args[])
{
- struct ldpd_conf *vty_conf;
struct ldpd_af_conf *af_conf;
int af;
const char *acl_for_str;
disable = (vty_get_arg_value(args, "no")) ? 1 : 0;
acl_for_str = vty_get_arg_value(args, "for_acl");
- vty_conf = ldp_dup_config(ldpd_conf);
af = ldp_vty_get_af(vty);
af_conf = ldp_af_conf_get(vty_conf, af);
int
ldp_vty_label_accept(struct vty *vty, struct vty_arg *args[])
{
- struct ldpd_conf *vty_conf;
struct ldpd_af_conf *af_conf;
int af;
const char *acl_from_str;
acl_from_str = vty_get_arg_value(args, "from_acl");
acl_for_str = vty_get_arg_value(args, "for_acl");
- vty_conf = ldp_dup_config(ldpd_conf);
af = ldp_vty_get_af(vty);
af_conf = ldp_af_conf_get(vty_conf, af);
int
ldp_vty_ttl_security(struct vty *vty, struct vty_arg *args[])
{
- struct ldpd_conf *vty_conf;
struct ldpd_af_conf *af_conf;
int af;
int disable;
disable = (vty_get_arg_value(args, "no")) ? 1 : 0;
- vty_conf = ldp_dup_config(ldpd_conf);
af = ldp_vty_get_af(vty);
af_conf = ldp_af_conf_get(vty_conf, af);
int
ldp_vty_router_id(struct vty *vty, struct vty_arg *args[])
{
- struct ldpd_conf *vty_conf;
const char *addr_str;
int disable;
disable = (vty_get_arg_value(args, "no")) ? 1 : 0;
addr_str = vty_get_arg_value(args, "addr");
- vty_conf = ldp_dup_config(ldpd_conf);
-
if (disable)
vty_conf->rtr_id.s_addr = INADDR_ANY;
else {
if (inet_pton(AF_INET, addr_str, &vty_conf->rtr_id) != 1 ||
bad_addr_v4(vty_conf->rtr_id)) {
vty_out(vty, "%% Malformed address%s", VTY_NEWLINE);
- goto cancel;
+ return (CMD_SUCCESS);
}
}
ldp_reload(vty_conf);
return (CMD_SUCCESS);
-
-cancel:
- ldp_clear_config(vty_conf);
- return (CMD_SUCCESS);
}
int
ldp_vty_ds_cisco_interop(struct vty *vty, struct vty_arg *args[])
{
- struct ldpd_conf *vty_conf;
int disable;
disable = (vty_get_arg_value(args, "no")) ? 1 : 0;
- vty_conf = ldp_dup_config(ldpd_conf);
-
if (disable)
vty_conf->flags &= ~F_LDPD_DS_CISCO_INTEROP;
else
int
ldp_vty_trans_pref_ipv4(struct vty *vty, struct vty_arg *args[])
{
- struct ldpd_conf *vty_conf;
int disable;
disable = (vty_get_arg_value(args, "no")) ? 1 : 0;
- vty_conf = ldp_dup_config(ldpd_conf);
-
if (disable)
vty_conf->trans_pref = DUAL_STACK_LDPOV6;
else
int
ldp_vty_neighbor_password(struct vty *vty, struct vty_arg *args[])
{
- struct ldpd_conf *vty_conf;
struct in_addr lsr_id;
size_t password_len;
struct nbr_params *nbrp;
return (CMD_WARNING);
}
- vty_conf = ldp_dup_config(ldpd_conf);
nbrp = nbr_params_find(vty_conf, lsr_id);
if (disable) {
if (nbrp == NULL)
- goto cancel;
+ return (CMD_SUCCESS);
memset(&nbrp->auth, 0, sizeof(nbrp->auth));
nbrp->auth.method = AUTH_NONE;
RB_INSERT(nbrp_head, &vty_conf->nbrp_tree, nbrp);
} else if (nbrp->auth.method == AUTH_MD5SIG &&
strcmp(nbrp->auth.md5key, password_str) == 0)
- goto cancel;
+ return (CMD_SUCCESS);
password_len = strlcpy(nbrp->auth.md5key, password_str,
sizeof(nbrp->auth.md5key));
ldp_reload(vty_conf);
return (CMD_SUCCESS);
-
-cancel:
- ldp_clear_config(vty_conf);
- return (CMD_SUCCESS);
}
int
ldp_vty_neighbor_ttl_security(struct vty *vty, struct vty_arg *args[])
{
- struct ldpd_conf *vty_conf;
struct in_addr lsr_id;
struct nbr_params *nbrp;
long int hops = 0;
}
}
- vty_conf = ldp_dup_config(ldpd_conf);
nbrp = nbr_params_find(vty_conf, lsr_id);
if (disable) {
if (nbrp == NULL)
- goto cancel;
+ return (CMD_SUCCESS);
nbrp->flags &= ~(F_NBRP_GTSM|F_NBRP_GTSM_HOPS);
nbrp->gtsm_enabled = 0;
ldp_reload(vty_conf);
return (CMD_SUCCESS);
-
-cancel:
- ldp_clear_config(vty_conf);
- return (CMD_SUCCESS);
}
int
ldp_vty_l2vpn(struct vty *vty, struct vty_arg *args[])
{
- struct ldpd_conf *vty_conf;
struct l2vpn *l2vpn;
const char *name_str;
int disable;
disable = (vty_get_arg_value(args, "no")) ? 1 : 0;
name_str = vty_get_arg_value(args, "name");
- vty_conf = ldp_dup_config(ldpd_conf);
l2vpn = l2vpn_find(vty_conf, name_str);
if (disable) {
if (l2vpn == NULL)
- goto cancel;
+ return (CMD_SUCCESS);
RB_REMOVE(l2vpn_head, &vty_conf->l2vpn_tree, l2vpn);
l2vpn_del(l2vpn);
if (l2vpn) {
VTY_PUSH_CONTEXT(LDP_L2VPN_NODE, l2vpn);
- goto cancel;
+ return (CMD_SUCCESS);
}
l2vpn = l2vpn_new(name_str);
l2vpn->type = L2VPN_TYPE_VPLS;
RB_INSERT(l2vpn_head, &vty_conf->l2vpn_tree, l2vpn);
- ldp_reload_ref(vty_conf, (void **)&l2vpn);
+ ldp_reload(vty_conf);
VTY_PUSH_CONTEXT(LDP_L2VPN_NODE, l2vpn);
return (CMD_SUCCESS);
-
-cancel:
- ldp_clear_config(vty_conf);
- return (CMD_SUCCESS);
}
int
ldp_vty_l2vpn_bridge(struct vty *vty, struct vty_arg *args[])
{
- struct ldpd_conf *vty_conf;
struct l2vpn *l2vpn;
const char *ifname;
int disable;
ifname = vty_get_arg_value(args, "ifname");
l2vpn = VTY_GET_CONTEXT(l2vpn);
- vty_conf = ldp_dup_config_ref(ldpd_conf, (void **)&l2vpn);
+ l2vpn = l2vpn_find(vty_conf, l2vpn->name);
if (disable)
memset(l2vpn->br_ifname, 0, sizeof(l2vpn->br_ifname));
else
strlcpy(l2vpn->br_ifname, ifname, sizeof(l2vpn->br_ifname));
- ldp_reload_ref(vty_conf, (void **)&l2vpn);
+ ldp_reload(vty_conf);
return (CMD_SUCCESS);
}
int
ldp_vty_l2vpn_mtu(struct vty *vty, struct vty_arg *args[])
{
- struct ldpd_conf *vty_conf;
struct l2vpn *l2vpn;
char *ep;
int mtu;
}
l2vpn = VTY_GET_CONTEXT(l2vpn);
- vty_conf = ldp_dup_config_ref(ldpd_conf, (void **)&l2vpn);
+ l2vpn = l2vpn_find(vty_conf, l2vpn->name);
if (disable)
l2vpn->mtu = DEFAULT_L2VPN_MTU;
else
l2vpn->mtu = mtu;
- ldp_reload_ref(vty_conf, (void **)&l2vpn);
+ ldp_reload(vty_conf);
return (CMD_SUCCESS);
}
int
ldp_vty_l2vpn_pwtype(struct vty *vty, struct vty_arg *args[])
{
- struct ldpd_conf *vty_conf;
struct l2vpn *l2vpn;
int pw_type;
const char *type_str;
pw_type = PW_TYPE_ETHERNET_TAGGED;
l2vpn = VTY_GET_CONTEXT(l2vpn);
- vty_conf = ldp_dup_config_ref(ldpd_conf, (void **)&l2vpn);
+ l2vpn = l2vpn_find(vty_conf, l2vpn->name);
if (disable)
l2vpn->pw_type = DEFAULT_PW_TYPE;
else
l2vpn->pw_type = pw_type;
- ldp_reload_ref(vty_conf, (void **)&l2vpn);
+ ldp_reload(vty_conf);
return (CMD_SUCCESS);
}
int
ldp_vty_l2vpn_interface(struct vty *vty, struct vty_arg *args[])
{
- struct ldpd_conf *vty_conf;
struct l2vpn *l2vpn;
struct l2vpn_if *lif;
struct interface *ifp;
ifname = vty_get_arg_value(args, "ifname");
l2vpn = VTY_GET_CONTEXT(l2vpn);
- vty_conf = ldp_dup_config_ref(ldpd_conf, (void **)&l2vpn);
l2vpn = l2vpn_find(vty_conf, l2vpn->name);
lif = l2vpn_if_find_name(l2vpn, ifname);
if (disable) {
if (lif == NULL)
- goto cancel;
+ return (CMD_SUCCESS);
RB_REMOVE(l2vpn_if_head, &l2vpn->if_tree, lif);
free(lif);
}
if (lif)
- goto cancel;
+ return (CMD_SUCCESS);
if (ldp_iface_is_configured(vty_conf, ifname)) {
vty_out(vty, "%% Interface is already in use%s", VTY_NEWLINE);
- goto cancel;
+ return (CMD_SUCCESS);
}
ifp = if_lookup_by_name(ifname, VRF_DEFAULT);
lif = l2vpn_if_new(l2vpn, &kif);
RB_INSERT(l2vpn_if_head, &l2vpn->if_tree, lif);
- ldp_reload_ref(vty_conf, (void **)&l2vpn);
-
- return (CMD_SUCCESS);
+ ldp_reload(vty_conf);
-cancel:
- ldp_clear_config(vty_conf);
return (CMD_SUCCESS);
}
int
ldp_vty_l2vpn_pseudowire(struct vty *vty, struct vty_arg *args[])
{
- struct ldpd_conf *vty_conf;
struct l2vpn *l2vpn;
struct l2vpn_pw *pw;
struct interface *ifp;
ifname = vty_get_arg_value(args, "ifname");
l2vpn = VTY_GET_CONTEXT(l2vpn);
- vty_conf = ldp_dup_config_ref(ldpd_conf, (void **)&l2vpn);
+ l2vpn = l2vpn_find(vty_conf, l2vpn->name);
pw = l2vpn_pw_find_name(l2vpn, ifname);
if (disable) {
if (pw == NULL)
- goto cancel;
+ return (CMD_SUCCESS);
RB_REMOVE(l2vpn_pw_head, &l2vpn->pw_inactive_tree, pw);
free(pw);
if (pw) {
VTY_PUSH_CONTEXT_SUB(LDP_PSEUDOWIRE_NODE, pw);
- goto cancel;
+ return (CMD_SUCCESS);
}
if (ldp_iface_is_configured(vty_conf, ifname)) {
vty_out(vty, "%% Interface is already in use%s", VTY_NEWLINE);
- goto cancel;
+ return (CMD_SUCCESS);
}
ifp = if_lookup_by_name(ifname, VRF_DEFAULT);
pw->flags = F_PW_STATUSTLV_CONF|F_PW_CWORD_CONF;
RB_INSERT(l2vpn_pw_head, &l2vpn->pw_inactive_tree, pw);
- ldp_reload_ref(vty_conf, (void **)&pw);
+ ldp_reload(vty_conf);
VTY_PUSH_CONTEXT_SUB(LDP_PSEUDOWIRE_NODE, pw);
return (CMD_SUCCESS);
-
-cancel:
- ldp_clear_config(vty_conf);
- return (CMD_SUCCESS);
}
int
ldp_vty_l2vpn_pw_cword(struct vty *vty, struct vty_arg *args[])
{
- struct ldpd_conf *vty_conf;
+ struct l2vpn *l2vpn;
struct 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 = VTY_GET_CONTEXT(l2vpn);
+ l2vpn = l2vpn_find(vty_conf, l2vpn->name);
pw = VTY_GET_CONTEXT_SUB(l2vpn_pw);
- vty_conf = ldp_dup_config_ref(ldpd_conf, (void **)&pw);
+ pw = l2vpn_pw_find_name(l2vpn, pw->ifname);
if (disable)
pw->flags |= F_PW_CWORD_CONF;
pw->flags |= F_PW_CWORD_CONF;
}
- ldp_reload_ref(vty_conf, (void **)&pw);
+ ldp_reload(vty_conf);
return (CMD_SUCCESS);
}
int
ldp_vty_l2vpn_pw_nbr_addr(struct vty *vty, struct vty_arg *args[])
{
- struct ldpd_conf *vty_conf;
+ struct l2vpn *l2vpn;
struct l2vpn_pw *pw;
int af;
union ldpd_addr addr;
return (CMD_WARNING);
}
+ l2vpn = VTY_GET_CONTEXT(l2vpn);
+ l2vpn = l2vpn_find(vty_conf, l2vpn->name);
pw = VTY_GET_CONTEXT_SUB(l2vpn_pw);
- vty_conf = ldp_dup_config_ref(ldpd_conf, (void **)&pw);
+ pw = l2vpn_pw_find_name(l2vpn, pw->ifname);
if (disable) {
pw->af = AF_UNSPEC;
pw->flags |= F_PW_STATIC_NBR_ADDR;
}
- ldp_reload_ref(vty_conf, (void **)&pw);
+ ldp_reload(vty_conf);
return (CMD_SUCCESS);
}
int
ldp_vty_l2vpn_pw_nbr_id(struct vty *vty, struct vty_arg *args[])
{
- struct ldpd_conf *vty_conf;
+ struct l2vpn *l2vpn;
struct l2vpn_pw *pw;
struct in_addr lsr_id;
const char *lsr_id_str;
return (CMD_WARNING);
}
+ l2vpn = VTY_GET_CONTEXT(l2vpn);
+ l2vpn = l2vpn_find(vty_conf, l2vpn->name);
pw = VTY_GET_CONTEXT_SUB(l2vpn_pw);
- vty_conf = ldp_dup_config_ref(ldpd_conf, (void **)&pw);
+ pw = l2vpn_pw_find_name(l2vpn, pw->ifname);
if (disable)
pw->lsr_id.s_addr = INADDR_ANY;
else
pw->lsr_id = lsr_id;
- ldp_reload_ref(vty_conf, (void **)&pw);
+ ldp_reload(vty_conf);
return (CMD_SUCCESS);
}
int
ldp_vty_l2vpn_pw_pwid(struct vty *vty, struct vty_arg *args[])
{
- struct ldpd_conf *vty_conf;
+ struct l2vpn *l2vpn;
struct l2vpn_pw *pw;
char *ep;
uint32_t pwid;
return (CMD_WARNING);
}
+ l2vpn = VTY_GET_CONTEXT(l2vpn);
+ l2vpn = l2vpn_find(vty_conf, l2vpn->name);
pw = VTY_GET_CONTEXT_SUB(l2vpn_pw);
- vty_conf = ldp_dup_config_ref(ldpd_conf, (void **)&pw);
+ pw = l2vpn_pw_find_name(l2vpn, pw->ifname);
if (disable)
pw->pwid = 0;
else
pw->pwid = pwid;
- ldp_reload_ref(vty_conf, (void **)&pw);
+ ldp_reload(vty_conf);
return (CMD_SUCCESS);
}
int
ldp_vty_l2vpn_pw_pwstatus(struct vty *vty, struct vty_arg *args[])
{
- struct ldpd_conf *vty_conf;
+ struct l2vpn *l2vpn;
struct l2vpn_pw *pw;
int disable;
disable = (vty_get_arg_value(args, "no")) ? 1 : 0;
+ l2vpn = VTY_GET_CONTEXT(l2vpn);
+ l2vpn = l2vpn_find(vty_conf, l2vpn->name);
pw = VTY_GET_CONTEXT_SUB(l2vpn_pw);
- vty_conf = ldp_dup_config_ref(ldpd_conf, (void **)&pw);
+ pw = l2vpn_pw_find_name(l2vpn, pw->ifname);
if (disable)
pw->flags |= F_PW_STATUSTLV_CONF;
else
pw->flags &= ~F_PW_STATUSTLV_CONF;
- ldp_reload_ref(vty_conf, (void **)&pw);
+ ldp_reload(vty_conf);
return (CMD_SUCCESS);
}
static void main_imsg_send_net_sockets(int);
static void main_imsg_send_net_socket(int, enum socket_type);
static int main_imsg_send_config(struct ldpd_conf *);
-static void ldp_config_normalize(struct ldpd_conf *, void **);
-static void ldp_config_reset_main(struct ldpd_conf *, void **);
-static void ldp_config_reset_af(struct ldpd_conf *, int, void **);
-static void merge_config_ref(struct ldpd_conf *, struct ldpd_conf *, void **);
+static void ldp_config_normalize(struct ldpd_conf *);
+static void ldp_config_reset_main(struct ldpd_conf *);
+static void ldp_config_reset_af(struct ldpd_conf *, int);
static void merge_global(struct ldpd_conf *, struct ldpd_conf *);
static void merge_af(int, struct ldpd_af_conf *,
struct ldpd_af_conf *);
-static void merge_ifaces(struct ldpd_conf *, struct ldpd_conf *, void **);
+static void merge_ifaces(struct ldpd_conf *, struct ldpd_conf *);
static void merge_iface_af(struct iface_af *, struct iface_af *);
-static void merge_tnbrs(struct ldpd_conf *, struct ldpd_conf *, void **);
-static void merge_nbrps(struct ldpd_conf *, struct ldpd_conf *, void **);
-static void merge_l2vpns(struct ldpd_conf *, struct ldpd_conf *, void **);
+static void merge_tnbrs(struct ldpd_conf *, struct ldpd_conf *);
+static void merge_nbrps(struct ldpd_conf *, struct ldpd_conf *);
+static void merge_l2vpns(struct ldpd_conf *, struct ldpd_conf *);
static void merge_l2vpn(struct ldpd_conf *, struct l2vpn *,
- struct l2vpn *, void **);
+ struct l2vpn *);
DEFINE_QOBJ_TYPE(iface)
DEFINE_QOBJ_TYPE(tnbr)
DEFINE_QOBJ_TYPE(ldpd_conf)
struct ldpd_global global;
-struct ldpd_conf *ldpd_conf;
+struct ldpd_conf *ldpd_conf, *vty_conf;
static struct imsgev *iev_ldpe, *iev_ldpe_sync;
static struct imsgev *iev_lde, *iev_lde_sync;
ldp_vty_if_init();
ldp_zebra_init(master);
- /* Get configuration file. */
+ /* create base configuration with sane defaults */
ldpd_conf = config_new_empty();
- ldp_config_reset_main(ldpd_conf, NULL);
+ ldp_config_reset_main(ldpd_conf);
QOBJ_REG(ldpd_conf, ldpd_conf);
+
+ /*
+ * Create vty_conf as a duplicate of the main configuration. All
+ * configuration requests (e.g. CLI) act on vty_conf and then call
+ * ldp_reload() to merge the changes into ldpd_conf.
+ */
+ vty_conf = ldp_dup_config(ldpd_conf);
+
+ /* read configuration file and daemonize */
frr_config_fork();
/* setup pipes to children */
}
int
-ldp_reload_ref(struct ldpd_conf *xconf, void **ref)
+ldp_reload(struct ldpd_conf *xconf)
{
- ldp_config_normalize(xconf, ref);
+ ldp_config_normalize(xconf);
if (main_imsg_send_config(xconf) == -1)
return (-1);
- merge_config_ref(ldpd_conf, xconf, ref);
+ merge_config(ldpd_conf, xconf);
- return (0);
-}
+ vty_conf = ldp_dup_config(ldpd_conf);
-int
-ldp_reload(struct ldpd_conf *xconf)
-{
- return ldp_reload_ref(xconf, NULL);
+ return (0);
}
static void
-ldp_config_normalize(struct ldpd_conf *xconf, void **ref)
+ldp_config_normalize(struct ldpd_conf *xconf)
{
struct l2vpn *l2vpn;
struct l2vpn_pw *pw;
if (!(xconf->flags & F_LDPD_ENABLED))
- ldp_config_reset_main(xconf, ref);
+ ldp_config_reset_main(xconf);
else {
if (!(xconf->ipv4.flags & F_LDPD_AF_ENABLED))
- ldp_config_reset_af(xconf, AF_INET, ref);
+ ldp_config_reset_af(xconf, AF_INET);
if (!(xconf->ipv6.flags & F_LDPD_AF_ENABLED))
- ldp_config_reset_af(xconf, AF_INET6, ref);
+ ldp_config_reset_af(xconf, AF_INET6);
}
RB_FOREACH(l2vpn, l2vpn_head, &xconf->l2vpn_tree) {
}
static void
-ldp_config_reset_main(struct ldpd_conf *conf, void **ref)
+ldp_config_reset_main(struct ldpd_conf *conf)
{
struct iface *iface;
struct nbr_params *nbrp;
while ((iface = RB_ROOT(&conf->iface_tree)) != NULL) {
- if (ref && *ref == iface)
- *ref = NULL;
RB_REMOVE(iface_head, &conf->iface_tree, iface);
free(iface);
}
while ((nbrp = RB_ROOT(&conf->nbrp_tree)) != NULL) {
- if (ref && *ref == nbrp)
- *ref = NULL;
RB_REMOVE(nbrp_head, &conf->nbrp_tree, nbrp);
free(nbrp);
}
conf->rtr_id.s_addr = INADDR_ANY;
- ldp_config_reset_af(conf, AF_INET, ref);
- ldp_config_reset_af(conf, AF_INET6, ref);
+ ldp_config_reset_af(conf, AF_INET);
+ ldp_config_reset_af(conf, AF_INET6);
conf->lhello_holdtime = LINK_DFLT_HOLDTIME;
conf->lhello_interval = DEFAULT_HELLO_INTERVAL;
conf->thello_holdtime = TARGETED_DFLT_HOLDTIME;
}
static void
-ldp_config_reset_af(struct ldpd_conf *conf, int af, void **ref)
+ldp_config_reset_af(struct ldpd_conf *conf, int af)
{
struct ldpd_af_conf *af_conf;
struct iface *iface;
if (tnbr->af != af)
continue;
- if (ref && *ref == tnbr)
- *ref = NULL;
RB_REMOVE(tnbr_head, &conf->tnbr_tree, tnbr);
free(tnbr);
}
}
struct ldpd_conf *
-ldp_dup_config_ref(struct ldpd_conf *conf, void **ref)
+ldp_dup_config(struct ldpd_conf *conf)
{
struct ldpd_conf *xconf;
struct iface *iface, *xi;
if (a == NULL) \
fatal(__func__); \
*a = *b; \
- if (ref && *ref == b) *ref = a; \
} while (0)
COPY(xconf, conf);
return (xconf);
}
-struct ldpd_conf *
-ldp_dup_config(struct ldpd_conf *conf)
-{
- return ldp_dup_config_ref(conf, NULL);
-}
-
void
ldp_clear_config(struct ldpd_conf *xconf)
{
free(xconf);
}
-static void
-merge_config_ref(struct ldpd_conf *conf, struct ldpd_conf *xconf, void **ref)
+void
+merge_config(struct ldpd_conf *conf, struct ldpd_conf *xconf)
{
merge_global(conf, xconf);
merge_af(AF_INET, &conf->ipv4, &xconf->ipv4);
merge_af(AF_INET6, &conf->ipv6, &xconf->ipv6);
- merge_ifaces(conf, xconf, ref);
- merge_tnbrs(conf, xconf, ref);
- merge_nbrps(conf, xconf, ref);
- merge_l2vpns(conf, xconf, ref);
- if (ref && *ref == xconf)
- *ref = conf;
+ merge_ifaces(conf, xconf);
+ merge_tnbrs(conf, xconf);
+ merge_nbrps(conf, xconf);
+ merge_l2vpns(conf, xconf);
free(xconf);
}
-void
-merge_config(struct ldpd_conf *conf, struct ldpd_conf *xconf)
-{
- merge_config_ref(conf, xconf, NULL);
-}
-
static void
merge_global(struct ldpd_conf *conf, struct ldpd_conf *xconf)
{
}
static void
-merge_ifaces(struct ldpd_conf *conf, struct ldpd_conf *xconf, void **ref)
+merge_ifaces(struct ldpd_conf *conf, struct ldpd_conf *xconf)
{
struct iface *iface, *itmp, *xi;
merge_iface_af(&iface->ipv4, &xi->ipv4);
merge_iface_af(&iface->ipv6, &xi->ipv6);
RB_REMOVE(iface_head, &xconf->iface_tree, xi);
- if (ref && *ref == xi)
- *ref = iface;
free(xi);
}
}
}
static void
-merge_tnbrs(struct ldpd_conf *conf, struct ldpd_conf *xconf, void **ref)
+merge_tnbrs(struct ldpd_conf *conf, struct ldpd_conf *xconf)
{
struct tnbr *tnbr, *ttmp, *xt;
if (!(tnbr->flags & F_TNBR_CONFIGURED))
tnbr->flags |= F_TNBR_CONFIGURED;
RB_REMOVE(tnbr_head, &xconf->tnbr_tree, xt);
- if (ref && *ref == xt)
- *ref = tnbr;
free(xt);
}
}
static void
-merge_nbrps(struct ldpd_conf *conf, struct ldpd_conf *xconf, void **ref)
+merge_nbrps(struct ldpd_conf *conf, struct ldpd_conf *xconf)
{
struct nbr_params *nbrp, *ntmp, *xn;
struct nbr *nbr;
}
}
RB_REMOVE(nbrp_head, &xconf->nbrp_tree, xn);
- if (ref && *ref == xn)
- *ref = nbrp;
free(xn);
}
}
static void
-merge_l2vpns(struct ldpd_conf *conf, struct ldpd_conf *xconf, void **ref)
+merge_l2vpns(struct ldpd_conf *conf, struct ldpd_conf *xconf)
{
struct l2vpn *l2vpn, *ltmp, *xl;
struct l2vpn_if *lif;
}
/* update existing l2vpns */
- merge_l2vpn(conf, l2vpn, xl, ref);
+ merge_l2vpn(conf, l2vpn, xl);
RB_REMOVE(l2vpn_head, &xconf->l2vpn_tree, xl);
- if (ref && *ref == xl)
- *ref = l2vpn;
free(xl);
}
}
static void
-merge_l2vpn(struct ldpd_conf *xconf, struct l2vpn *l2vpn, struct l2vpn *xl, void **ref)
+merge_l2vpn(struct ldpd_conf *xconf, struct l2vpn *l2vpn, struct l2vpn *xl)
{
struct l2vpn_if *lif, *ftmp, *xf;
struct l2vpn_pw *pw, *ptmp, *xp;
}
RB_REMOVE(l2vpn_if_head, &xl->if_tree, xf);
- if (ref && *ref == xf)
- *ref = lif;
free(xf);
}
}
RB_REMOVE(l2vpn_pw_head, &xl->pw_tree, xp);
- if (ref && *ref == xp)
- *ref = pw;
free(xp);
}
}
RB_REMOVE(l2vpn_pw_head, &xl->pw_inactive_tree, xp);
- if (ref && *ref == xp)
- *ref = pw;
free(xp);
}