1 // SPDX-License-Identifier: GPL-2.0-or-later
3 * Copyright (C) 2016 by Open Source Routing.
19 static int ldp_config_write(struct vty
*);
20 static void ldp_af_iface_config_write(struct vty
*, int);
21 static void ldp_af_config_write(struct vty
*, int, struct ldpd_conf
*,
22 struct ldpd_af_conf
*);
23 static int ldp_l2vpn_config_write(struct vty
*);
24 static void ldp_l2vpn_pw_config_write(struct vty
*, struct l2vpn_pw
*);
25 static int ldp_vty_get_af(struct vty
*);
26 static int ldp_iface_is_configured(struct ldpd_conf
*, const char *);
28 struct cmd_node ldp_node
= {
31 .parent_node
= CONFIG_NODE
,
32 .prompt
= "%s(config-ldp)# ",
33 .config_write
= ldp_config_write
,
36 struct cmd_node ldp_ipv4_node
= {
38 .node
= LDP_IPV4_NODE
,
39 .parent_node
= LDP_NODE
,
40 .prompt
= "%s(config-ldp-af)# ",
43 struct cmd_node ldp_ipv6_node
= {
45 .node
= LDP_IPV6_NODE
,
46 .parent_node
= LDP_NODE
,
47 .prompt
= "%s(config-ldp-af)# ",
50 struct cmd_node ldp_ipv4_iface_node
= {
51 .name
= "ldp ipv4 interface",
52 .node
= LDP_IPV4_IFACE_NODE
,
53 .parent_node
= LDP_IPV4_NODE
,
54 .prompt
= "%s(config-ldp-af-if)# ",
57 struct cmd_node ldp_ipv6_iface_node
= {
58 .name
= "ldp ipv6 interface",
59 .node
= LDP_IPV6_IFACE_NODE
,
60 .parent_node
= LDP_IPV6_NODE
,
61 .prompt
= "%s(config-ldp-af-if)# ",
64 struct cmd_node ldp_l2vpn_node
= {
66 .node
= LDP_L2VPN_NODE
,
67 .parent_node
= CONFIG_NODE
,
68 .prompt
= "%s(config-l2vpn)# ",
69 .config_write
= ldp_l2vpn_config_write
,
72 struct cmd_node ldp_pseudowire_node
= {
74 .node
= LDP_PSEUDOWIRE_NODE
,
75 .parent_node
= LDP_L2VPN_NODE
,
76 .prompt
= "%s(config-l2vpn-pw)# ",
80 ldp_get_address(const char *str
, int *af
, union ldpd_addr
*addr
)
82 if (!str
|| !af
|| !addr
)
85 memset(addr
, 0, sizeof(*addr
));
87 if (inet_pton(AF_INET
, str
, &addr
->v4
) == 1) {
92 if (inet_pton(AF_INET6
, str
, &addr
->v6
) == 1) {
101 ldp_af_iface_config_write(struct vty
*vty
, int af
)
106 RB_FOREACH(iface
, iface_head
, &ldpd_conf
->iface_tree
) {
107 ia
= iface_af_get(iface
, af
);
111 vty_out (vty
, " !\n");
112 vty_out (vty
, " interface %s\n", iface
->name
);
114 if (ia
->hello_holdtime
!= LINK_DFLT_HOLDTIME
&&
115 ia
->hello_holdtime
!= 0)
116 vty_out (vty
, " discovery hello holdtime %u\n",
118 if (ia
->hello_interval
!= DEFAULT_HELLO_INTERVAL
&&
119 ia
->hello_interval
!= 0)
120 vty_out (vty
, " discovery hello interval %u\n",
123 vty_out (vty
, " exit\n");
128 ldp_af_config_write(struct vty
*vty
, int af
, struct ldpd_conf
*conf
,
129 struct ldpd_af_conf
*af_conf
)
133 if (!(af_conf
->flags
& F_LDPD_AF_ENABLED
))
136 vty_out (vty
, " !\n");
137 vty_out (vty
, " address-family %s\n", af_name(af
));
139 if (af_conf
->lhello_holdtime
!= LINK_DFLT_HOLDTIME
&&
140 af_conf
->lhello_holdtime
!= 0 )
141 vty_out (vty
, " discovery hello holdtime %u\n",
142 af_conf
->lhello_holdtime
);
143 if (af_conf
->lhello_interval
!= DEFAULT_HELLO_INTERVAL
&&
144 af_conf
->lhello_interval
!= 0)
145 vty_out (vty
, " discovery hello interval %u\n",
146 af_conf
->lhello_interval
);
148 if (af_conf
->flags
& F_LDPD_AF_THELLO_ACCEPT
) {
149 vty_out(vty
, " discovery targeted-hello accept");
150 if (af_conf
->acl_thello_accept_from
[0] != '\0')
151 vty_out(vty
, " from %s",
152 af_conf
->acl_thello_accept_from
);
156 if (af_conf
->thello_holdtime
!= TARGETED_DFLT_HOLDTIME
&&
157 af_conf
->thello_holdtime
!= 0)
158 vty_out (vty
, " discovery targeted-hello holdtime %u\n",
159 af_conf
->thello_holdtime
);
160 if (af_conf
->thello_interval
!= DEFAULT_HELLO_INTERVAL
&&
161 af_conf
->thello_interval
!= 0)
162 vty_out (vty
, " discovery targeted-hello interval %u\n",
163 af_conf
->thello_interval
);
165 if (ldp_addrisset(af
, &af_conf
->trans_addr
))
166 vty_out (vty
, " discovery transport-address %s\n",
167 log_addr(af
, &af_conf
->trans_addr
));
170 " ! Incomplete config, specify a discovery transport-address\n");
172 if ((af_conf
->flags
& F_LDPD_AF_ALLOCHOSTONLY
) ||
173 af_conf
->acl_label_allocate_for
[0] != '\0') {
174 vty_out(vty
, " label local allocate");
175 if (af_conf
->flags
& F_LDPD_AF_ALLOCHOSTONLY
)
176 vty_out(vty
, " host-routes");
178 vty_out(vty
, " for %s",
179 af_conf
->acl_label_allocate_for
);
183 if (af_conf
->acl_label_advertise_for
[0] != '\0' ||
184 af_conf
->acl_label_advertise_to
[0] != '\0') {
185 vty_out(vty
, " label local advertise");
186 if (af_conf
->acl_label_advertise_to
[0] != '\0')
187 vty_out(vty
, " to %s",
188 af_conf
->acl_label_advertise_to
);
189 if (af_conf
->acl_label_advertise_for
[0] != '\0')
190 vty_out(vty
, " for %s",
191 af_conf
->acl_label_advertise_for
);
195 if (af_conf
->flags
& F_LDPD_AF_EXPNULL
) {
196 vty_out(vty
, " label local advertise explicit-null");
197 if (af_conf
->acl_label_expnull_for
[0] != '\0')
198 vty_out(vty
, " for %s",
199 af_conf
->acl_label_expnull_for
);
203 if (af_conf
->acl_label_accept_for
[0] != '\0' ||
204 af_conf
->acl_label_accept_from
[0] != '\0') {
205 vty_out(vty
, " label remote accept");
206 if (af_conf
->acl_label_accept_from
[0] != '\0')
207 vty_out(vty
, " from %s",
208 af_conf
->acl_label_accept_from
);
209 if (af_conf
->acl_label_accept_for
[0] != '\0')
210 vty_out(vty
, " for %s",
211 af_conf
->acl_label_accept_for
);
215 if (af_conf
->flags
& F_LDPD_AF_NO_GTSM
)
216 vty_out (vty
, " ttl-security disable\n");
218 if (af_conf
->keepalive
!= DEFAULT_KEEPALIVE
)
219 vty_out (vty
, " session holdtime %u\n",af_conf
->keepalive
);
221 RB_FOREACH(tnbr
, tnbr_head
, &ldpd_conf
->tnbr_tree
) {
222 if (tnbr
->af
== af
) {
223 vty_out (vty
, " !\n");
224 vty_out (vty
, " neighbor %s targeted\n",
225 log_addr(tnbr
->af
, &tnbr
->addr
));
229 ldp_af_iface_config_write(vty
, af
);
231 vty_out(vty
, " !\n");
232 vty_out(vty
, " exit-address-family\n");
236 ldp_config_write(struct vty
*vty
)
238 struct nbr_params
*nbrp
;
240 if (!(ldpd_conf
->flags
& F_LDPD_ENABLED
))
243 vty_out (vty
, "mpls ldp\n");
245 if (ldpd_conf
->rtr_id
.s_addr
!= INADDR_ANY
)
246 vty_out(vty
, " router-id %pI4\n", &ldpd_conf
->rtr_id
);
248 if (ldpd_conf
->lhello_holdtime
!= LINK_DFLT_HOLDTIME
&&
249 ldpd_conf
->lhello_holdtime
!= 0)
250 vty_out (vty
, " discovery hello holdtime %u\n",
251 ldpd_conf
->lhello_holdtime
);
252 if (ldpd_conf
->lhello_interval
!= DEFAULT_HELLO_INTERVAL
&&
253 ldpd_conf
->lhello_interval
!= 0)
254 vty_out (vty
, " discovery hello interval %u\n",
255 ldpd_conf
->lhello_interval
);
257 if (ldpd_conf
->thello_holdtime
!= TARGETED_DFLT_HOLDTIME
&&
258 ldpd_conf
->thello_holdtime
!= 0)
259 vty_out (vty
, " discovery targeted-hello holdtime %u\n",
260 ldpd_conf
->thello_holdtime
);
261 if (ldpd_conf
->thello_interval
!= DEFAULT_HELLO_INTERVAL
&&
262 ldpd_conf
->thello_interval
!= 0)
263 vty_out (vty
, " discovery targeted-hello interval %u\n",
264 ldpd_conf
->thello_interval
);
266 if (ldpd_conf
->trans_pref
== DUAL_STACK_LDPOV4
)
268 " dual-stack transport-connection prefer ipv4\n");
270 if (ldpd_conf
->flags
& F_LDPD_DS_CISCO_INTEROP
)
271 vty_out (vty
, " dual-stack cisco-interop\n");
273 if (ldpd_conf
->flags
& F_LDPD_ORDERED_CONTROL
)
274 vty_out (vty
, " ordered-control\n");
276 if (ldpd_conf
->wait_for_sync_interval
!= DFLT_WAIT_FOR_SYNC
&&
277 ldpd_conf
->wait_for_sync_interval
!= 0)
278 vty_out (vty
, " wait-for-sync %u\n",
279 ldpd_conf
->wait_for_sync_interval
);
281 if (ldpd_conf
->flags
& F_LDPD_ALLOW_BROKEN_LSP
)
282 vty_out(vty
, " install allow-broken-lsp\n");
284 RB_FOREACH(nbrp
, nbrp_head
, &ldpd_conf
->nbrp_tree
) {
285 if (nbrp
->flags
& F_NBRP_KEEPALIVE
)
286 vty_out (vty
, " neighbor %pI4 session holdtime %u\n",
287 &nbrp
->lsr_id
,nbrp
->keepalive
);
289 if (nbrp
->flags
& F_NBRP_GTSM
) {
290 if (nbrp
->gtsm_enabled
)
291 vty_out (vty
, " neighbor %pI4 ttl-security hops %u\n", &nbrp
->lsr_id
,
294 vty_out (vty
, " neighbor %pI4 ttl-security disable\n",&nbrp
->lsr_id
);
297 if (nbrp
->auth
.method
== AUTH_MD5SIG
)
298 vty_out (vty
, " neighbor %pI4 password %s\n",
299 &nbrp
->lsr_id
,nbrp
->auth
.md5key
);
302 ldp_af_config_write(vty
, AF_INET
, ldpd_conf
, &ldpd_conf
->ipv4
);
303 ldp_af_config_write(vty
, AF_INET6
, ldpd_conf
, &ldpd_conf
->ipv6
);
304 vty_out (vty
, " !\n");
305 vty_out (vty
, "exit\n");
306 vty_out (vty
, "!\n");
312 ldp_l2vpn_pw_config_write(struct vty
*vty
, struct l2vpn_pw
*pw
)
314 int missing_lsrid
= 0;
315 int missing_pwid
= 0;
317 vty_out (vty
, " !\n");
318 vty_out (vty
, " member pseudowire %s\n", pw
->ifname
);
320 if (pw
->lsr_id
.s_addr
!= INADDR_ANY
)
321 vty_out (vty
, " neighbor lsr-id %pI4\n",&pw
->lsr_id
);
325 if (pw
->flags
& F_PW_STATIC_NBR_ADDR
)
326 vty_out (vty
, " neighbor address %s\n",
327 log_addr(pw
->af
, &pw
->addr
));
330 vty_out (vty
, " pw-id %u\n", pw
->pwid
);
334 if (!(pw
->flags
& F_PW_CWORD_CONF
))
335 vty_out (vty
, " control-word exclude\n");
337 if (!(pw
->flags
& F_PW_STATUSTLV_CONF
))
338 vty_out (vty
, " pw-status disable\n");
342 " ! Incomplete config, specify a neighbor lsr-id\n");
344 vty_out (vty
," ! Incomplete config, specify a pw-id\n");
346 vty_out (vty
, " exit\n");
350 ldp_l2vpn_config_write(struct vty
*vty
)
353 struct l2vpn_if
*lif
;
356 RB_FOREACH(l2vpn
, l2vpn_head
, &ldpd_conf
->l2vpn_tree
) {
357 vty_out (vty
, "l2vpn %s type vpls\n", l2vpn
->name
);
359 if (l2vpn
->pw_type
!= DEFAULT_PW_TYPE
)
360 vty_out (vty
, " vc type ethernet-tagged\n");
362 if (l2vpn
->mtu
!= DEFAULT_L2VPN_MTU
)
363 vty_out (vty
, " mtu %u\n", l2vpn
->mtu
);
365 if (l2vpn
->br_ifname
[0] != '\0')
366 vty_out (vty
, " bridge %s\n",l2vpn
->br_ifname
);
368 RB_FOREACH(lif
, l2vpn_if_head
, &l2vpn
->if_tree
)
369 vty_out (vty
, " member interface %s\n",lif
->ifname
);
371 RB_FOREACH(pw
, l2vpn_pw_head
, &l2vpn
->pw_tree
)
372 ldp_l2vpn_pw_config_write(vty
, pw
);
373 RB_FOREACH(pw
, l2vpn_pw_head
, &l2vpn
->pw_inactive_tree
)
374 ldp_l2vpn_pw_config_write(vty
, pw
);
376 vty_out (vty
, " !\n");
377 vty_out (vty
, "exit\n");
378 vty_out (vty
, "!\n");
385 ldp_vty_get_af(struct vty
*vty
)
389 case LDP_IPV4_IFACE_NODE
:
392 case LDP_IPV6_IFACE_NODE
:
395 fatalx("ldp_vty_get_af: unexpected node");
400 ldp_iface_is_configured(struct ldpd_conf
*xconf
, const char *ifname
)
404 if (if_lookup_name(xconf
, ifname
))
407 RB_FOREACH(l2vpn
, l2vpn_head
, &xconf
->l2vpn_tree
) {
408 if (l2vpn_if_find(l2vpn
, ifname
))
410 if (l2vpn_pw_find(l2vpn
, ifname
))
418 ldp_vty_mpls_ldp(struct vty
*vty
, const char *negate
)
421 vty_conf
->flags
&= ~F_LDPD_ENABLED
;
423 vty
->node
= LDP_NODE
;
424 vty_conf
->flags
|= F_LDPD_ENABLED
;
427 /* register / de-register to recv info from zebra */
428 ldp_zebra_regdereg_zebra_info(!negate
);
430 ldp_config_apply(vty
, vty_conf
);
432 return (CMD_SUCCESS
);
436 ldp_vty_address_family(struct vty
*vty
, const char *negate
, const char *af_str
)
438 struct ldpd_af_conf
*af_conf
;
442 return (CMD_WARNING_CONFIG_FAILED
);
444 if (strcmp(af_str
, "ipv4") == 0) {
446 af_conf
= &vty_conf
->ipv4
;
447 } else if (strcmp(af_str
, "ipv6") == 0) {
449 af_conf
= &vty_conf
->ipv6
;
451 return (CMD_WARNING_CONFIG_FAILED
);
454 af_conf
->flags
&= ~F_LDPD_AF_ENABLED
;
455 ldp_config_apply(vty
, vty_conf
);
456 return (CMD_SUCCESS
);
461 vty
->node
= LDP_IPV4_NODE
;
464 vty
->node
= LDP_IPV6_NODE
;
467 fatalx("ldp_vty_address_family: unknown af");
469 af_conf
->flags
|= F_LDPD_AF_ENABLED
;
471 ldp_config_apply(vty
, vty_conf
);
473 return (CMD_SUCCESS
);
476 int ldp_vty_disc_holdtime(struct vty
*vty
, const char *negate
,
477 enum hello_type hello_type
, long secs
)
479 struct ldpd_af_conf
*af_conf
;
486 switch (hello_type
) {
488 vty_conf
->lhello_holdtime
= LINK_DFLT_HOLDTIME
;
491 vty_conf
->thello_holdtime
=
492 TARGETED_DFLT_HOLDTIME
;
496 switch (hello_type
) {
498 vty_conf
->lhello_holdtime
= secs
;
501 vty_conf
->thello_holdtime
= secs
;
505 ldp_config_apply(vty
, vty_conf
);
509 af
= ldp_vty_get_af(vty
);
510 af_conf
= ldp_af_conf_get(vty_conf
, af
);
513 switch (hello_type
) {
515 af_conf
->lhello_holdtime
= 0;
518 af_conf
->thello_holdtime
= 0;
522 switch (hello_type
) {
524 af_conf
->lhello_holdtime
= secs
;
527 af_conf
->thello_holdtime
= secs
;
531 ldp_config_apply(vty
, vty_conf
);
533 case LDP_IPV4_IFACE_NODE
:
534 case LDP_IPV6_IFACE_NODE
:
535 af
= ldp_vty_get_af(vty
);
536 iface
= VTY_GET_CONTEXT(iface
);
537 VTY_CHECK_CONTEXT(iface
);
539 ia
= iface_af_get(iface
, af
);
541 ia
->hello_holdtime
= 0;
543 ia
->hello_holdtime
= secs
;
545 ldp_config_apply(vty
, vty_conf
);
548 fatalx("ldp_vty_disc_holdtime: unexpected node");
551 return (CMD_SUCCESS
);
555 ldp_vty_disc_interval(struct vty
*vty
, const char *negate
,
556 enum hello_type hello_type
, long secs
)
558 struct ldpd_af_conf
*af_conf
;
566 switch (hello_type
) {
568 vty_conf
->lhello_interval
=
569 DEFAULT_HELLO_INTERVAL
;
572 vty_conf
->thello_interval
=
573 DEFAULT_HELLO_INTERVAL
;
577 switch (hello_type
) {
579 vty_conf
->lhello_interval
= secs
;
582 vty_conf
->thello_interval
= secs
;
586 ldp_config_apply(vty
, vty_conf
);
590 af
= ldp_vty_get_af(vty
);
591 af_conf
= ldp_af_conf_get(vty_conf
, af
);
594 switch (hello_type
) {
596 af_conf
->lhello_interval
= 0;
599 af_conf
->thello_interval
= 0;
603 switch (hello_type
) {
605 af_conf
->lhello_interval
= secs
;
608 af_conf
->thello_interval
= secs
;
612 ldp_config_apply(vty
, vty_conf
);
614 case LDP_IPV4_IFACE_NODE
:
615 case LDP_IPV6_IFACE_NODE
:
616 af
= ldp_vty_get_af(vty
);
617 iface
= VTY_GET_CONTEXT(iface
);
618 VTY_CHECK_CONTEXT(iface
);
620 ia
= iface_af_get(iface
, af
);
622 ia
->hello_interval
= 0;
624 ia
->hello_interval
= secs
;
626 ldp_config_apply(vty
, vty_conf
);
629 fatalx("ldp_vty_disc_interval: unexpected node");
632 return (CMD_SUCCESS
);
636 ldp_vty_targeted_hello_accept(struct vty
*vty
, const char *negate
,
637 const char *acl_from_str
)
639 struct ldpd_af_conf
*af_conf
;
642 af
= ldp_vty_get_af(vty
);
643 af_conf
= ldp_af_conf_get(vty_conf
, af
);
646 af_conf
->flags
&= ~F_LDPD_AF_THELLO_ACCEPT
;
647 af_conf
->acl_thello_accept_from
[0] = '\0';
649 af_conf
->flags
|= F_LDPD_AF_THELLO_ACCEPT
;
651 strlcpy(af_conf
->acl_thello_accept_from
, acl_from_str
,
652 sizeof(af_conf
->acl_thello_accept_from
));
654 af_conf
->acl_thello_accept_from
[0] = '\0';
657 ldp_config_apply(vty
, vty_conf
);
659 return (CMD_SUCCESS
);
663 ldp_vty_nbr_session_holdtime(struct vty
*vty
, const char *negate
,
664 struct in_addr lsr_id
, long secs
)
666 struct nbr_params
*nbrp
;
668 if (bad_addr_v4(lsr_id
)) {
669 vty_out (vty
, "%% Malformed address\n");
670 return (CMD_WARNING_CONFIG_FAILED
);
673 nbrp
= nbr_params_find(vty_conf
, lsr_id
);
677 return (CMD_SUCCESS
);
680 nbrp
->flags
&= ~F_NBRP_KEEPALIVE
;
683 nbrp
= nbr_params_new(lsr_id
);
684 RB_INSERT(nbrp_head
, &vty_conf
->nbrp_tree
, nbrp
);
685 QOBJ_REG(nbrp
, nbr_params
);
686 } else if (nbrp
->keepalive
== secs
)
687 return (CMD_SUCCESS
);
689 nbrp
->keepalive
= secs
;
690 nbrp
->flags
|= F_NBRP_KEEPALIVE
;
693 ldp_config_apply(vty
, vty_conf
);
695 return (CMD_SUCCESS
);
699 ldp_vty_af_session_holdtime(struct vty
*vty
, const char *negate
, long secs
)
701 struct ldpd_af_conf
*af_conf
;
704 af
= ldp_vty_get_af(vty
);
705 af_conf
= ldp_af_conf_get(vty_conf
, af
);
708 af_conf
->keepalive
= DEFAULT_KEEPALIVE
;
710 af_conf
->keepalive
= secs
;
712 ldp_config_apply(vty
, vty_conf
);
714 return (CMD_SUCCESS
);
718 ldp_vty_interface(struct vty
*vty
, const char *negate
, const char *ifname
)
724 if (ifname
== NULL
) {
725 vty_out (vty
, "%% Missing IF name\n");
726 return (CMD_WARNING_CONFIG_FAILED
);
729 af
= ldp_vty_get_af(vty
);
730 iface
= if_lookup_name(vty_conf
, ifname
);
734 return (CMD_SUCCESS
);
736 ia
= iface_af_get(iface
, af
);
737 if (ia
->enabled
== 0)
738 return (CMD_SUCCESS
);
741 ia
->hello_holdtime
= 0;
742 ia
->hello_interval
= 0;
744 ldp_config_apply(vty
, vty_conf
);
746 return (CMD_SUCCESS
);
750 if (ldp_iface_is_configured(vty_conf
, ifname
)) {
751 vty_out (vty
,"%% Interface is already in use\n");
752 return (CMD_SUCCESS
);
755 iface
= if_new(ifname
);
756 ia
= iface_af_get(iface
, af
);
758 RB_INSERT(iface_head
, &vty_conf
->iface_tree
, iface
);
759 QOBJ_REG(iface
, iface
);
761 ldp_config_apply(vty
, vty_conf
);
763 ia
= iface_af_get(iface
, af
);
766 ldp_config_apply(vty
, vty_conf
);
772 VTY_PUSH_CONTEXT(LDP_IPV4_IFACE_NODE
, iface
);
775 VTY_PUSH_CONTEXT(LDP_IPV6_IFACE_NODE
, iface
);
781 return (CMD_SUCCESS
);
785 ldp_vty_trans_addr(struct vty
*vty
, const char *negate
, const char *addr_str
)
787 struct ldpd_af_conf
*af_conf
;
790 af
= ldp_vty_get_af(vty
);
791 af_conf
= ldp_af_conf_get(vty_conf
, af
);
794 memset(&af_conf
->trans_addr
, 0, sizeof(af_conf
->trans_addr
));
797 || inet_pton(af
, addr_str
, &af_conf
->trans_addr
) != 1
798 || bad_addr(af
, &af_conf
->trans_addr
)) {
799 vty_out (vty
, "%% Malformed address\n");
800 return (CMD_SUCCESS
);
804 ldp_config_apply(vty
, vty_conf
);
806 return (CMD_SUCCESS
);
810 ldp_vty_neighbor_targeted(struct vty
*vty
, const char *negate
, const char *addr_str
)
813 union ldpd_addr addr
;
816 af
= ldp_vty_get_af(vty
);
818 if (addr_str
== NULL
|| inet_pton(af
, addr_str
, &addr
) != 1 ||
819 bad_addr(af
, &addr
)) {
820 vty_out (vty
, "%% Malformed address\n");
821 return (CMD_WARNING_CONFIG_FAILED
);
823 if (af
== AF_INET6
&& IN6_IS_SCOPE_EMBED(&addr
.v6
)) {
824 vty_out (vty
, "%% Address can not be link-local\n");
825 return (CMD_WARNING_CONFIG_FAILED
);
828 tnbr
= tnbr_find(vty_conf
, af
, &addr
);
832 return (CMD_SUCCESS
);
835 RB_REMOVE(tnbr_head
, &vty_conf
->tnbr_tree
, tnbr
);
838 ldp_config_apply(vty
, vty_conf
);
840 return (CMD_SUCCESS
);
844 return (CMD_SUCCESS
);
846 tnbr
= tnbr_new(af
, &addr
);
847 tnbr
->flags
|= F_TNBR_CONFIGURED
;
848 RB_INSERT(tnbr_head
, &vty_conf
->tnbr_tree
, tnbr
);
849 QOBJ_REG(tnbr
, tnbr
);
851 ldp_config_apply(vty
, vty_conf
);
853 return (CMD_SUCCESS
);
857 ldp_vty_label_advertise(struct vty
*vty
, const char *negate
, const char *acl_to_str
,
858 const char *acl_for_str
)
860 struct ldpd_af_conf
*af_conf
;
863 af
= ldp_vty_get_af(vty
);
864 af_conf
= ldp_af_conf_get(vty_conf
, af
);
867 af_conf
->acl_label_advertise_to
[0] = '\0';
868 af_conf
->acl_label_advertise_for
[0] = '\0';
871 strlcpy(af_conf
->acl_label_advertise_to
, acl_to_str
,
872 sizeof(af_conf
->acl_label_advertise_to
));
874 af_conf
->acl_label_advertise_to
[0] = '\0';
876 strlcpy(af_conf
->acl_label_advertise_for
, acl_for_str
,
877 sizeof(af_conf
->acl_label_advertise_for
));
879 af_conf
->acl_label_advertise_for
[0] = '\0';
882 ldp_config_apply(vty
, vty_conf
);
884 return (CMD_SUCCESS
);
888 ldp_vty_label_allocate(struct vty
*vty
, const char *negate
, const char *host_routes
,
889 const char *acl_for_str
)
891 struct ldpd_af_conf
*af_conf
;
894 af
= ldp_vty_get_af(vty
);
895 af_conf
= ldp_af_conf_get(vty_conf
, af
);
897 af_conf
->flags
&= ~F_LDPD_AF_ALLOCHOSTONLY
;
898 af_conf
->acl_label_allocate_for
[0] = '\0';
901 af_conf
->flags
|= F_LDPD_AF_ALLOCHOSTONLY
;
903 strlcpy(af_conf
->acl_label_allocate_for
, acl_for_str
,
904 sizeof(af_conf
->acl_label_allocate_for
));
907 ldp_config_apply(vty
, vty_conf
);
909 return (CMD_SUCCESS
);
913 ldp_vty_label_expnull(struct vty
*vty
, const char *negate
, const char *acl_for_str
)
915 struct ldpd_af_conf
*af_conf
;
918 af
= ldp_vty_get_af(vty
);
919 af_conf
= ldp_af_conf_get(vty_conf
, af
);
922 af_conf
->flags
&= ~F_LDPD_AF_EXPNULL
;
923 af_conf
->acl_label_expnull_for
[0] = '\0';
925 af_conf
->flags
|= F_LDPD_AF_EXPNULL
;
927 strlcpy(af_conf
->acl_label_expnull_for
, acl_for_str
,
928 sizeof(af_conf
->acl_label_expnull_for
));
930 af_conf
->acl_label_expnull_for
[0] = '\0';
933 ldp_config_apply(vty
, vty_conf
);
935 return (CMD_SUCCESS
);
939 ldp_vty_label_accept(struct vty
*vty
, const char *negate
, const char *acl_from_str
,
940 const char *acl_for_str
)
942 struct ldpd_af_conf
*af_conf
;
945 af
= ldp_vty_get_af(vty
);
946 af_conf
= ldp_af_conf_get(vty_conf
, af
);
949 af_conf
->acl_label_accept_from
[0] = '\0';
950 af_conf
->acl_label_accept_for
[0] = '\0';
953 strlcpy(af_conf
->acl_label_accept_from
, acl_from_str
,
954 sizeof(af_conf
->acl_label_accept_from
));
956 af_conf
->acl_label_accept_from
[0] = '\0';
958 strlcpy(af_conf
->acl_label_accept_for
, acl_for_str
,
959 sizeof(af_conf
->acl_label_accept_for
));
961 af_conf
->acl_label_accept_for
[0] = '\0';
964 ldp_config_apply(vty
, vty_conf
);
966 return (CMD_SUCCESS
);
970 ldp_vty_ttl_security(struct vty
*vty
, const char *negate
)
972 struct ldpd_af_conf
*af_conf
;
975 af
= ldp_vty_get_af(vty
);
976 af_conf
= ldp_af_conf_get(vty_conf
, af
);
979 af_conf
->flags
&= ~F_LDPD_AF_NO_GTSM
;
981 af_conf
->flags
|= F_LDPD_AF_NO_GTSM
;
983 ldp_config_apply(vty
, vty_conf
);
985 return (CMD_SUCCESS
);
989 ldp_vty_router_id(struct vty
*vty
, const char *negate
, struct in_addr address
)
992 vty_conf
->rtr_id
.s_addr
= INADDR_ANY
;
994 if (bad_addr_v4(address
)) {
995 vty_out (vty
, "%% Malformed address\n");
996 return (CMD_SUCCESS
);
998 vty_conf
->rtr_id
= address
;
1001 ldp_config_apply(vty
, vty_conf
);
1003 return (CMD_SUCCESS
);
1007 ldp_vty_ordered_control(struct vty
*vty
, const char *negate
)
1010 vty_conf
->flags
&= ~F_LDPD_ORDERED_CONTROL
;
1012 vty_conf
->flags
|= F_LDPD_ORDERED_CONTROL
;
1014 ldp_config_apply(vty
, vty_conf
);
1016 return (CMD_SUCCESS
);
1019 int ldp_vty_wait_for_sync_interval(struct vty
*vty
, const char *negate
,
1022 switch (vty
->node
) {
1025 vty_conf
->wait_for_sync_interval
= DFLT_WAIT_FOR_SYNC
;
1027 vty_conf
->wait_for_sync_interval
= secs
;
1029 ldp_config_apply(vty
, vty_conf
);
1032 fatalx("ldp_vty_wait_for_sync_interval: unexpected node");
1034 return (CMD_SUCCESS
);
1038 ldp_vty_allow_broken_lsp(struct vty
*vty
, const char *negate
)
1041 vty_conf
->flags
&= ~F_LDPD_ALLOW_BROKEN_LSP
;
1043 vty_conf
->flags
|= F_LDPD_ALLOW_BROKEN_LSP
;
1045 ldp_config_apply(vty
, vty_conf
);
1047 return (CMD_SUCCESS
);
1051 ldp_vty_ds_cisco_interop(struct vty
*vty
, const char * negate
)
1054 vty_conf
->flags
&= ~F_LDPD_DS_CISCO_INTEROP
;
1056 vty_conf
->flags
|= F_LDPD_DS_CISCO_INTEROP
;
1058 ldp_config_apply(vty
, vty_conf
);
1060 return (CMD_SUCCESS
);
1064 ldp_vty_trans_pref_ipv4(struct vty
*vty
, const char *negate
)
1067 vty_conf
->trans_pref
= DUAL_STACK_LDPOV6
;
1069 vty_conf
->trans_pref
= DUAL_STACK_LDPOV4
;
1071 ldp_config_apply(vty
, vty_conf
);
1073 return (CMD_SUCCESS
);
1077 ldp_vty_neighbor_password(struct vty
*vty
, const char *negate
, struct in_addr lsr_id
,
1078 const char *password_str
)
1080 size_t password_len
;
1081 struct nbr_params
*nbrp
;
1083 if (password_str
== NULL
) {
1084 vty_out (vty
, "%% Missing password\n");
1085 return (CMD_WARNING_CONFIG_FAILED
);
1088 if (bad_addr_v4(lsr_id
)) {
1089 vty_out (vty
, "%% Malformed address\n");
1090 return (CMD_WARNING_CONFIG_FAILED
);
1093 nbrp
= nbr_params_find(vty_conf
, lsr_id
);
1097 return (CMD_SUCCESS
);
1099 memset(&nbrp
->auth
, 0, sizeof(nbrp
->auth
));
1100 nbrp
->auth
.method
= AUTH_NONE
;
1103 nbrp
= nbr_params_new(lsr_id
);
1104 RB_INSERT(nbrp_head
, &vty_conf
->nbrp_tree
, nbrp
);
1105 QOBJ_REG(nbrp
, nbr_params
);
1106 } else if (nbrp
->auth
.method
== AUTH_MD5SIG
&&
1107 strcmp(nbrp
->auth
.md5key
, password_str
) == 0)
1108 return (CMD_SUCCESS
);
1110 password_len
= strlcpy(nbrp
->auth
.md5key
, password_str
,
1111 sizeof(nbrp
->auth
.md5key
));
1112 if (password_len
>= sizeof(nbrp
->auth
.md5key
))
1113 vty_out(vty
, "%% password has been truncated to %zu characters.", sizeof(nbrp
->auth
.md5key
) - 1);
1114 nbrp
->auth
.md5key_len
= strlen(nbrp
->auth
.md5key
);
1115 nbrp
->auth
.method
= AUTH_MD5SIG
;
1118 ldp_config_apply(vty
, vty_conf
);
1120 return (CMD_SUCCESS
);
1124 ldp_vty_neighbor_ttl_security(struct vty
*vty
, const char *negate
,
1125 struct in_addr lsr_id
, const char *hops_str
)
1127 struct nbr_params
*nbrp
;
1131 if (bad_addr_v4(lsr_id
)) {
1132 vty_out (vty
, "%% Malformed address\n");
1133 return (CMD_WARNING_CONFIG_FAILED
);
1137 hops
= strtol(hops_str
, &ep
, 10);
1138 if (*ep
!= '\0' || hops
< 1 || hops
> 254) {
1139 vty_out (vty
, "%% Invalid hop count\n");
1140 return (CMD_SUCCESS
);
1144 nbrp
= nbr_params_find(vty_conf
, lsr_id
);
1148 return (CMD_SUCCESS
);
1150 nbrp
->flags
&= ~(F_NBRP_GTSM
|F_NBRP_GTSM_HOPS
);
1151 nbrp
->gtsm_enabled
= 0;
1152 nbrp
->gtsm_hops
= 0;
1155 nbrp
= nbr_params_new(lsr_id
);
1156 RB_INSERT(nbrp_head
, &vty_conf
->nbrp_tree
, nbrp
);
1157 QOBJ_REG(nbrp
, nbr_params
);
1160 nbrp
->flags
|= F_NBRP_GTSM
;
1161 nbrp
->flags
&= ~F_NBRP_GTSM_HOPS
;
1163 nbrp
->gtsm_enabled
= 1;
1164 nbrp
->gtsm_hops
= hops
;
1165 nbrp
->flags
|= F_NBRP_GTSM_HOPS
;
1167 nbrp
->gtsm_enabled
= 0;
1170 ldp_config_apply(vty
, vty_conf
);
1172 return (CMD_SUCCESS
);
1176 ldp_vty_l2vpn(struct vty
*vty
, const char *negate
, const char *name_str
)
1178 struct l2vpn
*l2vpn
;
1179 struct l2vpn_if
*lif
;
1180 struct l2vpn_pw
*pw
;
1182 if (name_str
== NULL
) {
1183 vty_out (vty
, "%% Missing name\n");
1184 return (CMD_WARNING_CONFIG_FAILED
);
1187 l2vpn
= l2vpn_find(vty_conf
, name_str
);
1191 return (CMD_SUCCESS
);
1193 RB_FOREACH(lif
, l2vpn_if_head
, &l2vpn
->if_tree
)
1195 RB_FOREACH(pw
, l2vpn_pw_head
, &l2vpn
->pw_tree
)
1197 RB_FOREACH(pw
, l2vpn_pw_head
, &l2vpn
->pw_inactive_tree
)
1200 RB_REMOVE(l2vpn_head
, &vty_conf
->l2vpn_tree
, l2vpn
);
1203 ldp_config_apply(vty
, vty_conf
);
1205 return (CMD_SUCCESS
);
1209 VTY_PUSH_CONTEXT(LDP_L2VPN_NODE
, l2vpn
);
1210 return (CMD_SUCCESS
);
1213 l2vpn
= l2vpn_new(name_str
);
1214 l2vpn
->type
= L2VPN_TYPE_VPLS
;
1215 RB_INSERT(l2vpn_head
, &vty_conf
->l2vpn_tree
, l2vpn
);
1216 QOBJ_REG(l2vpn
, l2vpn
);
1218 VTY_PUSH_CONTEXT(LDP_L2VPN_NODE
, l2vpn
);
1220 ldp_config_apply(vty
, vty_conf
);
1222 return (CMD_SUCCESS
);
1226 ldp_vty_l2vpn_bridge(struct vty
*vty
, const char *negate
, const char *ifname
)
1228 VTY_DECLVAR_CONTEXT(l2vpn
, l2vpn
);
1231 memset(l2vpn
->br_ifname
, 0, sizeof(l2vpn
->br_ifname
));
1233 if (ifname
== NULL
) {
1234 vty_out (vty
, "%% Missing IF name\n");
1235 return (CMD_WARNING_CONFIG_FAILED
);
1237 strlcpy(l2vpn
->br_ifname
, ifname
, sizeof(l2vpn
->br_ifname
));
1240 ldp_config_apply(vty
, vty_conf
);
1242 return (CMD_SUCCESS
);
1246 ldp_vty_l2vpn_mtu(struct vty
*vty
, const char *negate
, long mtu
)
1248 VTY_DECLVAR_CONTEXT(l2vpn
, l2vpn
);
1251 l2vpn
->mtu
= DEFAULT_L2VPN_MTU
;
1255 ldp_config_apply(vty
, vty_conf
);
1257 return (CMD_SUCCESS
);
1261 ldp_vty_l2vpn_pwtype(struct vty
*vty
, const char *negate
, const char *type_str
)
1263 VTY_DECLVAR_CONTEXT(l2vpn
, l2vpn
);
1266 if (type_str
== NULL
) {
1267 vty_out (vty
, "%% Missing type\n");
1268 return (CMD_WARNING_CONFIG_FAILED
);
1271 if (strcmp(type_str
, "ethernet") == 0)
1272 pw_type
= PW_TYPE_ETHERNET
;
1274 pw_type
= PW_TYPE_ETHERNET_TAGGED
;
1277 l2vpn
->pw_type
= DEFAULT_PW_TYPE
;
1279 l2vpn
->pw_type
= pw_type
;
1281 ldp_config_apply(vty
, vty_conf
);
1283 return (CMD_SUCCESS
);
1287 ldp_vty_l2vpn_interface(struct vty
*vty
, const char *negate
, const char *ifname
)
1289 VTY_DECLVAR_CONTEXT(l2vpn
, l2vpn
);
1290 struct l2vpn_if
*lif
;
1292 if (ifname
== NULL
) {
1293 vty_out (vty
, "%% Missing IF name\n");
1294 return (CMD_WARNING_CONFIG_FAILED
);
1297 lif
= l2vpn_if_find(l2vpn
, ifname
);
1301 return (CMD_SUCCESS
);
1304 RB_REMOVE(l2vpn_if_head
, &l2vpn
->if_tree
, lif
);
1307 ldp_config_apply(vty
, vty_conf
);
1309 return (CMD_SUCCESS
);
1313 return (CMD_SUCCESS
);
1315 if (ldp_iface_is_configured(vty_conf
, ifname
)) {
1316 vty_out (vty
, "%% Interface is already in use\n");
1317 return (CMD_SUCCESS
);
1320 lif
= l2vpn_if_new(l2vpn
, ifname
);
1321 RB_INSERT(l2vpn_if_head
, &l2vpn
->if_tree
, lif
);
1322 QOBJ_REG(lif
, l2vpn_if
);
1324 ldp_config_apply(vty
, vty_conf
);
1326 return (CMD_SUCCESS
);
1330 ldp_vty_l2vpn_pseudowire(struct vty
*vty
, const char *negate
, const char *ifname
)
1332 VTY_DECLVAR_CONTEXT(l2vpn
, l2vpn
);
1333 struct l2vpn_pw
*pw
;
1335 if (ifname
== NULL
) {
1336 vty_out (vty
, "%% Missing IF name\n");
1337 return (CMD_WARNING_CONFIG_FAILED
);
1340 pw
= l2vpn_pw_find(l2vpn
, ifname
);
1344 return (CMD_SUCCESS
);
1347 if (pw
->lsr_id
.s_addr
== INADDR_ANY
|| pw
->pwid
== 0)
1348 RB_REMOVE(l2vpn_pw_head
, &l2vpn
->pw_inactive_tree
, pw
);
1350 RB_REMOVE(l2vpn_pw_head
, &l2vpn
->pw_tree
, pw
);
1353 ldp_config_apply(vty
, vty_conf
);
1355 return (CMD_SUCCESS
);
1359 VTY_PUSH_CONTEXT_SUB(LDP_PSEUDOWIRE_NODE
, pw
);
1360 return (CMD_SUCCESS
);
1363 if (ldp_iface_is_configured(vty_conf
, ifname
)) {
1364 vty_out (vty
, "%% Interface is already in use\n");
1365 return (CMD_SUCCESS
);
1368 pw
= l2vpn_pw_new(l2vpn
, ifname
);
1369 pw
->flags
= F_PW_STATUSTLV_CONF
|F_PW_CWORD_CONF
;
1370 RB_INSERT(l2vpn_pw_head
, &l2vpn
->pw_inactive_tree
, pw
);
1371 QOBJ_REG(pw
, l2vpn_pw
);
1373 VTY_PUSH_CONTEXT_SUB(LDP_PSEUDOWIRE_NODE
, pw
);
1375 ldp_config_apply(vty
, vty_conf
);
1377 return (CMD_SUCCESS
);
1381 ldp_vty_l2vpn_pw_cword(struct vty
*vty
, const char *negate
, const char *preference_str
)
1383 VTY_DECLVAR_CONTEXT_SUB(l2vpn_pw
, pw
);
1386 pw
->flags
|= F_PW_CWORD_CONF
;
1388 if (!preference_str
) {
1389 vty_out (vty
, "%% Missing preference\n");
1390 return (CMD_WARNING_CONFIG_FAILED
);
1392 if (preference_str
[0] == 'e')
1393 pw
->flags
&= ~F_PW_CWORD_CONF
;
1395 pw
->flags
|= F_PW_CWORD_CONF
;
1398 ldp_config_apply(vty
, vty_conf
);
1400 return (CMD_SUCCESS
);
1404 ldp_vty_l2vpn_pw_nbr_addr(struct vty
*vty
, const char *negate
, const char *addr_str
)
1406 VTY_DECLVAR_CONTEXT_SUB(l2vpn_pw
, pw
);
1408 union ldpd_addr addr
;
1410 if (ldp_get_address(addr_str
, &af
, &addr
) == -1 ||
1411 bad_addr(af
, &addr
)) {
1412 vty_out (vty
, "%% Malformed address\n");
1413 return (CMD_WARNING_CONFIG_FAILED
);
1418 memset(&pw
->addr
, 0, sizeof(pw
->addr
));
1419 pw
->flags
&= ~F_PW_STATIC_NBR_ADDR
;
1423 pw
->flags
|= F_PW_STATIC_NBR_ADDR
;
1426 ldp_config_apply(vty
, vty_conf
);
1428 return (CMD_SUCCESS
);
1432 ldp_vty_l2vpn_pw_nbr_id(struct vty
*vty
, const char *negate
, struct in_addr lsr_id
)
1434 VTY_DECLVAR_CONTEXT_SUB(l2vpn_pw
, pw
);
1436 if (bad_addr_v4(lsr_id
)) {
1437 vty_out (vty
, "%% Malformed address\n");
1438 return (CMD_WARNING_CONFIG_FAILED
);
1442 pw
->lsr_id
.s_addr
= INADDR_ANY
;
1444 pw
->lsr_id
= lsr_id
;
1446 ldp_config_apply(vty
, vty_conf
);
1448 return (CMD_SUCCESS
);
1452 ldp_vty_l2vpn_pw_pwid(struct vty
*vty
, const char *negate
, long pwid
)
1454 VTY_DECLVAR_CONTEXT_SUB(l2vpn_pw
, pw
);
1461 ldp_config_apply(vty
, vty_conf
);
1463 return (CMD_SUCCESS
);
1467 ldp_vty_l2vpn_pw_pwstatus(struct vty
*vty
, const char *negate
)
1469 VTY_DECLVAR_CONTEXT_SUB(l2vpn_pw
, pw
);
1472 pw
->flags
|= F_PW_STATUSTLV_CONF
;
1474 pw
->flags
&= ~F_PW_STATUSTLV_CONF
;
1476 ldp_config_apply(vty
, vty_conf
);
1478 return (CMD_SUCCESS
);
1482 iface_new_api(struct ldpd_conf
*conf
, const char *name
)
1484 const char *ifname
= name
;
1485 struct iface
*iface
;
1487 if (ldp_iface_is_configured(conf
, ifname
))
1490 iface
= if_new(name
);
1491 RB_INSERT(iface_head
, &conf
->iface_tree
, iface
);
1492 QOBJ_REG(iface
, iface
);
1497 iface_del_api(struct ldpd_conf
*conf
, struct iface
*iface
)
1500 RB_REMOVE(iface_head
, &conf
->iface_tree
, iface
);
1505 tnbr_new_api(struct ldpd_conf
*conf
, int af
, union ldpd_addr
*addr
)
1509 if (af
== AF_INET6
&& IN6_IS_SCOPE_EMBED(&addr
->v6
))
1512 if (tnbr_find(conf
, af
, addr
))
1515 tnbr
= tnbr_new(af
, addr
);
1516 tnbr
->flags
|= F_TNBR_CONFIGURED
;
1517 RB_INSERT(tnbr_head
, &conf
->tnbr_tree
, tnbr
);
1518 QOBJ_REG(tnbr
, tnbr
);
1523 tnbr_del_api(struct ldpd_conf
*conf
, struct tnbr
*tnbr
)
1526 RB_REMOVE(tnbr_head
, &conf
->tnbr_tree
, tnbr
);
1531 nbrp_new_api(struct ldpd_conf
*conf
, struct in_addr lsr_id
)
1533 struct nbr_params
*nbrp
;
1535 if (nbr_params_find(conf
, lsr_id
))
1538 nbrp
= nbr_params_new(lsr_id
);
1539 RB_INSERT(nbrp_head
, &conf
->nbrp_tree
, nbrp
);
1540 QOBJ_REG(nbrp
, nbr_params
);
1545 nbrp_del_api(struct ldpd_conf
*conf
, struct nbr_params
*nbrp
)
1548 RB_REMOVE(nbrp_head
, &conf
->nbrp_tree
, nbrp
);
1553 l2vpn_new_api(struct ldpd_conf
*conf
, const char *name
)
1555 struct l2vpn
*l2vpn
;
1557 if (l2vpn_find(conf
, name
))
1560 l2vpn
= l2vpn_new(name
);
1561 l2vpn
->type
= L2VPN_TYPE_VPLS
;
1562 RB_INSERT(l2vpn_head
, &conf
->l2vpn_tree
, l2vpn
);
1563 QOBJ_REG(l2vpn
, l2vpn
);
1568 l2vpn_del_api(struct ldpd_conf
*conf
, struct l2vpn
*l2vpn
)
1570 struct l2vpn_if
*lif
;
1571 struct l2vpn_pw
*pw
;
1573 while (!RB_EMPTY(l2vpn_if_head
, &l2vpn
->if_tree
)) {
1574 lif
= RB_ROOT(l2vpn_if_head
, &l2vpn
->if_tree
);
1577 RB_REMOVE(l2vpn_if_head
, &l2vpn
->if_tree
, lif
);
1580 while (!RB_EMPTY(l2vpn_pw_head
, &l2vpn
->pw_tree
)) {
1581 pw
= RB_ROOT(l2vpn_pw_head
, &l2vpn
->pw_tree
);
1584 RB_REMOVE(l2vpn_pw_head
, &l2vpn
->pw_tree
, pw
);
1587 while (!RB_EMPTY(l2vpn_pw_head
, &l2vpn
->pw_inactive_tree
)) {
1588 pw
= RB_ROOT(l2vpn_pw_head
, &l2vpn
->pw_inactive_tree
);
1591 RB_REMOVE(l2vpn_pw_head
, &l2vpn
->pw_inactive_tree
, pw
);
1595 RB_REMOVE(l2vpn_head
, &conf
->l2vpn_tree
, l2vpn
);
1600 l2vpn_if_new_api(struct ldpd_conf
*conf
, struct l2vpn
*l2vpn
,
1603 struct l2vpn_if
*lif
;
1605 if (ldp_iface_is_configured(conf
, ifname
))
1608 lif
= l2vpn_if_new(l2vpn
, ifname
);
1609 RB_INSERT(l2vpn_if_head
, &l2vpn
->if_tree
, lif
);
1610 QOBJ_REG(lif
, l2vpn_if
);
1615 l2vpn_if_del_api(struct l2vpn
*l2vpn
, struct l2vpn_if
*lif
)
1618 RB_REMOVE(l2vpn_if_head
, &l2vpn
->if_tree
, lif
);
1623 l2vpn_pw_new_api(struct ldpd_conf
*conf
, struct l2vpn
*l2vpn
,
1626 struct l2vpn_pw
*pw
;
1628 if (ldp_iface_is_configured(conf
, ifname
))
1631 pw
= l2vpn_pw_new(l2vpn
, ifname
);
1632 pw
->flags
= F_PW_STATUSTLV_CONF
|F_PW_CWORD_CONF
;
1633 RB_INSERT(l2vpn_pw_head
, &l2vpn
->pw_inactive_tree
, pw
);
1634 QOBJ_REG(pw
, l2vpn_pw
);
1639 l2vpn_pw_del_api(struct l2vpn
*l2vpn
, struct l2vpn_pw
*pw
)
1642 RB_REMOVE(l2vpn_pw_head
, &l2vpn
->pw_inactive_tree
, pw
);