2 * Copyright (C) 2016 by Open Source Routing.
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful, but
10 * WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; see the file COPYING; if not, write to the
16 * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,
33 static int ldp_config_write(struct vty
*);
34 static void ldp_af_iface_config_write(struct vty
*, int);
35 static void ldp_af_config_write(struct vty
*, int, struct ldpd_conf
*,
36 struct ldpd_af_conf
*);
37 static int ldp_l2vpn_config_write(struct vty
*);
38 static void ldp_l2vpn_pw_config_write(struct vty
*, struct l2vpn_pw
*);
39 static int ldp_vty_get_af(struct vty
*);
40 static int ldp_iface_is_configured(struct ldpd_conf
*, const char *);
42 struct cmd_node ldp_node
= {
45 .parent_node
= CONFIG_NODE
,
46 .prompt
= "%s(config-ldp)# ",
47 .config_write
= ldp_config_write
,
50 struct cmd_node ldp_ipv4_node
= {
52 .node
= LDP_IPV4_NODE
,
53 .parent_node
= LDP_NODE
,
54 .prompt
= "%s(config-ldp-af)# ",
57 struct cmd_node ldp_ipv6_node
= {
59 .node
= LDP_IPV6_NODE
,
60 .parent_node
= LDP_NODE
,
61 .prompt
= "%s(config-ldp-af)# ",
64 struct cmd_node ldp_ipv4_iface_node
= {
65 .name
= "ldp ipv4 interface",
66 .node
= LDP_IPV4_IFACE_NODE
,
67 .parent_node
= LDP_IPV4_NODE
,
68 .prompt
= "%s(config-ldp-af-if)# ",
71 struct cmd_node ldp_ipv6_iface_node
= {
72 .name
= "ldp ipv6 interface",
73 .node
= LDP_IPV6_IFACE_NODE
,
74 .parent_node
= LDP_IPV6_NODE
,
75 .prompt
= "%s(config-ldp-af-if)# ",
78 struct cmd_node ldp_l2vpn_node
= {
80 .node
= LDP_L2VPN_NODE
,
81 .parent_node
= CONFIG_NODE
,
82 .prompt
= "%s(config-l2vpn)# ",
83 .config_write
= ldp_l2vpn_config_write
,
86 struct cmd_node ldp_pseudowire_node
= {
88 .node
= LDP_PSEUDOWIRE_NODE
,
89 .parent_node
= LDP_L2VPN_NODE
,
90 .prompt
= "%s(config-l2vpn-pw)# ",
94 ldp_get_address(const char *str
, int *af
, union ldpd_addr
*addr
)
96 if (!str
|| !af
|| !addr
)
99 memset(addr
, 0, sizeof(*addr
));
101 if (inet_pton(AF_INET
, str
, &addr
->v4
) == 1) {
106 if (inet_pton(AF_INET6
, str
, &addr
->v6
) == 1) {
115 ldp_af_iface_config_write(struct vty
*vty
, int af
)
120 RB_FOREACH(iface
, iface_head
, &ldpd_conf
->iface_tree
) {
121 ia
= iface_af_get(iface
, af
);
125 vty_out (vty
, " !\n");
126 vty_out (vty
, " interface %s\n", iface
->name
);
128 if (ia
->hello_holdtime
!= LINK_DFLT_HOLDTIME
&&
129 ia
->hello_holdtime
!= 0)
130 vty_out (vty
, " discovery hello holdtime %u\n",
132 if (ia
->hello_interval
!= DEFAULT_HELLO_INTERVAL
&&
133 ia
->hello_interval
!= 0)
134 vty_out (vty
, " discovery hello interval %u\n",
140 ldp_af_config_write(struct vty
*vty
, int af
, struct ldpd_conf
*conf
,
141 struct ldpd_af_conf
*af_conf
)
145 if (!(af_conf
->flags
& F_LDPD_AF_ENABLED
))
148 vty_out (vty
, " !\n");
149 vty_out (vty
, " address-family %s\n", af_name(af
));
151 if (af_conf
->lhello_holdtime
!= LINK_DFLT_HOLDTIME
&&
152 af_conf
->lhello_holdtime
!= 0 )
153 vty_out (vty
, " discovery hello holdtime %u\n",
154 af_conf
->lhello_holdtime
);
155 if (af_conf
->lhello_interval
!= DEFAULT_HELLO_INTERVAL
&&
156 af_conf
->lhello_interval
!= 0)
157 vty_out (vty
, " discovery hello interval %u\n",
158 af_conf
->lhello_interval
);
160 if (af_conf
->flags
& F_LDPD_AF_THELLO_ACCEPT
) {
161 vty_out(vty
, " discovery targeted-hello accept");
162 if (af_conf
->acl_thello_accept_from
[0] != '\0')
163 vty_out(vty
, " from %s",
164 af_conf
->acl_thello_accept_from
);
168 if (af_conf
->thello_holdtime
!= TARGETED_DFLT_HOLDTIME
&&
169 af_conf
->thello_holdtime
!= 0)
170 vty_out (vty
, " discovery targeted-hello holdtime %u\n",
171 af_conf
->thello_holdtime
);
172 if (af_conf
->thello_interval
!= DEFAULT_HELLO_INTERVAL
&&
173 af_conf
->thello_interval
!= 0)
174 vty_out (vty
, " discovery targeted-hello interval %u\n",
175 af_conf
->thello_interval
);
177 if (ldp_addrisset(af
, &af_conf
->trans_addr
))
178 vty_out (vty
, " discovery transport-address %s\n",
179 log_addr(af
, &af_conf
->trans_addr
));
182 " ! Incomplete config, specify a discovery transport-address\n");
184 if ((af_conf
->flags
& F_LDPD_AF_ALLOCHOSTONLY
) ||
185 af_conf
->acl_label_allocate_for
[0] != '\0') {
186 vty_out(vty
, " label local allocate");
187 if (af_conf
->flags
& F_LDPD_AF_ALLOCHOSTONLY
)
188 vty_out(vty
, " host-routes");
190 vty_out(vty
, " for %s",
191 af_conf
->acl_label_allocate_for
);
195 if (af_conf
->acl_label_advertise_for
[0] != '\0' ||
196 af_conf
->acl_label_advertise_to
[0] != '\0') {
197 vty_out(vty
, " label local advertise");
198 if (af_conf
->acl_label_advertise_to
[0] != '\0')
199 vty_out(vty
, " to %s",
200 af_conf
->acl_label_advertise_to
);
201 if (af_conf
->acl_label_advertise_for
[0] != '\0')
202 vty_out(vty
, " for %s",
203 af_conf
->acl_label_advertise_for
);
207 if (af_conf
->flags
& F_LDPD_AF_EXPNULL
) {
208 vty_out(vty
, " label local advertise explicit-null");
209 if (af_conf
->acl_label_expnull_for
[0] != '\0')
210 vty_out(vty
, " for %s",
211 af_conf
->acl_label_expnull_for
);
215 if (af_conf
->acl_label_accept_for
[0] != '\0' ||
216 af_conf
->acl_label_accept_from
[0] != '\0') {
217 vty_out(vty
, " label remote accept");
218 if (af_conf
->acl_label_accept_from
[0] != '\0')
219 vty_out(vty
, " from %s",
220 af_conf
->acl_label_accept_from
);
221 if (af_conf
->acl_label_accept_for
[0] != '\0')
222 vty_out(vty
, " for %s",
223 af_conf
->acl_label_accept_for
);
227 if (af_conf
->flags
& F_LDPD_AF_NO_GTSM
)
228 vty_out (vty
, " ttl-security disable\n");
230 if (af_conf
->keepalive
!= DEFAULT_KEEPALIVE
)
231 vty_out (vty
, " session holdtime %u\n",af_conf
->keepalive
);
233 RB_FOREACH(tnbr
, tnbr_head
, &ldpd_conf
->tnbr_tree
) {
234 if (tnbr
->af
== af
) {
235 vty_out (vty
, " !\n");
236 vty_out (vty
, " neighbor %s targeted\n",
237 log_addr(tnbr
->af
, &tnbr
->addr
));
241 ldp_af_iface_config_write(vty
, af
);
243 vty_out(vty
, " !\n");
244 vty_out(vty
, " exit-address-family\n");
248 ldp_config_write(struct vty
*vty
)
250 struct nbr_params
*nbrp
;
252 if (!(ldpd_conf
->flags
& F_LDPD_ENABLED
))
255 vty_out (vty
, "mpls ldp\n");
257 if (ldpd_conf
->rtr_id
.s_addr
!= INADDR_ANY
)
258 vty_out(vty
, " router-id %pI4\n", &ldpd_conf
->rtr_id
);
260 if (ldpd_conf
->lhello_holdtime
!= LINK_DFLT_HOLDTIME
&&
261 ldpd_conf
->lhello_holdtime
!= 0)
262 vty_out (vty
, " discovery hello holdtime %u\n",
263 ldpd_conf
->lhello_holdtime
);
264 if (ldpd_conf
->lhello_interval
!= DEFAULT_HELLO_INTERVAL
&&
265 ldpd_conf
->lhello_interval
!= 0)
266 vty_out (vty
, " discovery hello interval %u\n",
267 ldpd_conf
->lhello_interval
);
269 if (ldpd_conf
->thello_holdtime
!= TARGETED_DFLT_HOLDTIME
&&
270 ldpd_conf
->thello_holdtime
!= 0)
271 vty_out (vty
, " discovery targeted-hello holdtime %u\n",
272 ldpd_conf
->thello_holdtime
);
273 if (ldpd_conf
->thello_interval
!= DEFAULT_HELLO_INTERVAL
&&
274 ldpd_conf
->thello_interval
!= 0)
275 vty_out (vty
, " discovery targeted-hello interval %u\n",
276 ldpd_conf
->thello_interval
);
278 if (ldpd_conf
->trans_pref
== DUAL_STACK_LDPOV4
)
280 " dual-stack transport-connection prefer ipv4\n");
282 if (ldpd_conf
->flags
& F_LDPD_DS_CISCO_INTEROP
)
283 vty_out (vty
, " dual-stack cisco-interop\n");
285 if (ldpd_conf
->flags
& F_LDPD_ORDERED_CONTROL
)
286 vty_out (vty
, " ordered-control\n");
288 if (ldpd_conf
->wait_for_sync_interval
!= DFLT_WAIT_FOR_SYNC
&&
289 ldpd_conf
->wait_for_sync_interval
!= 0)
290 vty_out (vty
, " wait-for-sync %u\n",
291 ldpd_conf
->wait_for_sync_interval
);
293 if (ldpd_conf
->flags
& F_LDPD_ALLOW_BROKEN_LSP
)
294 vty_out(vty
, " install allow-broken-lsp\n");
296 RB_FOREACH(nbrp
, nbrp_head
, &ldpd_conf
->nbrp_tree
) {
297 if (nbrp
->flags
& F_NBRP_KEEPALIVE
)
298 vty_out (vty
, " neighbor %pI4 session holdtime %u\n",
299 &nbrp
->lsr_id
,nbrp
->keepalive
);
301 if (nbrp
->flags
& F_NBRP_GTSM
) {
302 if (nbrp
->gtsm_enabled
)
303 vty_out (vty
, " neighbor %pI4 ttl-security hops %u\n", &nbrp
->lsr_id
,
306 vty_out (vty
, " neighbor %pI4 ttl-security disable\n",&nbrp
->lsr_id
);
309 if (nbrp
->auth
.method
== AUTH_MD5SIG
)
310 vty_out (vty
, " neighbor %pI4 password %s\n",
311 &nbrp
->lsr_id
,nbrp
->auth
.md5key
);
314 ldp_af_config_write(vty
, AF_INET
, ldpd_conf
, &ldpd_conf
->ipv4
);
315 ldp_af_config_write(vty
, AF_INET6
, ldpd_conf
, &ldpd_conf
->ipv6
);
316 vty_out (vty
, " !\n");
317 vty_out (vty
, "!\n");
323 ldp_l2vpn_pw_config_write(struct vty
*vty
, struct l2vpn_pw
*pw
)
325 int missing_lsrid
= 0;
326 int missing_pwid
= 0;
328 vty_out (vty
, " !\n");
329 vty_out (vty
, " member pseudowire %s\n", pw
->ifname
);
331 if (pw
->lsr_id
.s_addr
!= INADDR_ANY
)
332 vty_out (vty
, " neighbor lsr-id %pI4\n",&pw
->lsr_id
);
336 if (pw
->flags
& F_PW_STATIC_NBR_ADDR
)
337 vty_out (vty
, " neighbor address %s\n",
338 log_addr(pw
->af
, &pw
->addr
));
341 vty_out (vty
, " pw-id %u\n", pw
->pwid
);
345 if (!(pw
->flags
& F_PW_CWORD_CONF
))
346 vty_out (vty
, " control-word exclude\n");
348 if (!(pw
->flags
& F_PW_STATUSTLV_CONF
))
349 vty_out (vty
, " pw-status disable\n");
353 " ! Incomplete config, specify a neighbor lsr-id\n");
355 vty_out (vty
," ! Incomplete config, specify a pw-id\n");
359 ldp_l2vpn_config_write(struct vty
*vty
)
362 struct l2vpn_if
*lif
;
365 RB_FOREACH(l2vpn
, l2vpn_head
, &ldpd_conf
->l2vpn_tree
) {
366 vty_out (vty
, "l2vpn %s type vpls\n", l2vpn
->name
);
368 if (l2vpn
->pw_type
!= DEFAULT_PW_TYPE
)
369 vty_out (vty
, " vc type ethernet-tagged\n");
371 if (l2vpn
->mtu
!= DEFAULT_L2VPN_MTU
)
372 vty_out (vty
, " mtu %u\n", l2vpn
->mtu
);
374 if (l2vpn
->br_ifname
[0] != '\0')
375 vty_out (vty
, " bridge %s\n",l2vpn
->br_ifname
);
377 RB_FOREACH(lif
, l2vpn_if_head
, &l2vpn
->if_tree
)
378 vty_out (vty
, " member interface %s\n",lif
->ifname
);
380 RB_FOREACH(pw
, l2vpn_pw_head
, &l2vpn
->pw_tree
)
381 ldp_l2vpn_pw_config_write(vty
, pw
);
382 RB_FOREACH(pw
, l2vpn_pw_head
, &l2vpn
->pw_inactive_tree
)
383 ldp_l2vpn_pw_config_write(vty
, pw
);
385 vty_out (vty
, " !\n");
386 vty_out (vty
, "!\n");
393 ldp_vty_get_af(struct vty
*vty
)
397 case LDP_IPV4_IFACE_NODE
:
400 case LDP_IPV6_IFACE_NODE
:
403 fatalx("ldp_vty_get_af: unexpected node");
408 ldp_iface_is_configured(struct ldpd_conf
*xconf
, const char *ifname
)
412 if (if_lookup_name(xconf
, ifname
))
415 RB_FOREACH(l2vpn
, l2vpn_head
, &xconf
->l2vpn_tree
) {
416 if (l2vpn_if_find(l2vpn
, ifname
))
418 if (l2vpn_pw_find(l2vpn
, ifname
))
426 ldp_vty_mpls_ldp(struct vty
*vty
, const char *negate
)
429 vty_conf
->flags
&= ~F_LDPD_ENABLED
;
431 vty
->node
= LDP_NODE
;
432 vty_conf
->flags
|= F_LDPD_ENABLED
;
435 /* register / de-register to recv info from zebra */
436 ldp_zebra_regdereg_zebra_info(!negate
);
438 ldp_config_apply(vty
, vty_conf
);
440 return (CMD_SUCCESS
);
444 ldp_vty_address_family(struct vty
*vty
, const char *negate
, const char *af_str
)
446 struct ldpd_af_conf
*af_conf
;
450 return (CMD_WARNING_CONFIG_FAILED
);
452 if (strcmp(af_str
, "ipv4") == 0) {
454 af_conf
= &vty_conf
->ipv4
;
455 } else if (strcmp(af_str
, "ipv6") == 0) {
457 af_conf
= &vty_conf
->ipv6
;
459 return (CMD_WARNING_CONFIG_FAILED
);
462 af_conf
->flags
&= ~F_LDPD_AF_ENABLED
;
463 ldp_config_apply(vty
, vty_conf
);
464 return (CMD_SUCCESS
);
469 vty
->node
= LDP_IPV4_NODE
;
472 vty
->node
= LDP_IPV6_NODE
;
475 fatalx("ldp_vty_address_family: unknown af");
477 af_conf
->flags
|= F_LDPD_AF_ENABLED
;
479 ldp_config_apply(vty
, vty_conf
);
481 return (CMD_SUCCESS
);
484 int ldp_vty_disc_holdtime(struct vty
*vty
, const char *negate
,
485 enum hello_type hello_type
, long secs
)
487 struct ldpd_af_conf
*af_conf
;
494 switch (hello_type
) {
496 vty_conf
->lhello_holdtime
= LINK_DFLT_HOLDTIME
;
499 vty_conf
->thello_holdtime
=
500 TARGETED_DFLT_HOLDTIME
;
504 switch (hello_type
) {
506 vty_conf
->lhello_holdtime
= secs
;
509 vty_conf
->thello_holdtime
= secs
;
513 ldp_config_apply(vty
, vty_conf
);
517 af
= ldp_vty_get_af(vty
);
518 af_conf
= ldp_af_conf_get(vty_conf
, af
);
521 switch (hello_type
) {
523 af_conf
->lhello_holdtime
= 0;
526 af_conf
->thello_holdtime
= 0;
530 switch (hello_type
) {
532 af_conf
->lhello_holdtime
= secs
;
535 af_conf
->thello_holdtime
= secs
;
539 ldp_config_apply(vty
, vty_conf
);
541 case LDP_IPV4_IFACE_NODE
:
542 case LDP_IPV6_IFACE_NODE
:
543 af
= ldp_vty_get_af(vty
);
544 iface
= VTY_GET_CONTEXT(iface
);
545 VTY_CHECK_CONTEXT(iface
);
547 ia
= iface_af_get(iface
, af
);
549 ia
->hello_holdtime
= 0;
551 ia
->hello_holdtime
= secs
;
553 ldp_config_apply(vty
, vty_conf
);
556 fatalx("ldp_vty_disc_holdtime: unexpected node");
559 return (CMD_SUCCESS
);
563 ldp_vty_disc_interval(struct vty
*vty
, const char *negate
,
564 enum hello_type hello_type
, long secs
)
566 struct ldpd_af_conf
*af_conf
;
574 switch (hello_type
) {
576 vty_conf
->lhello_interval
=
577 DEFAULT_HELLO_INTERVAL
;
580 vty_conf
->thello_interval
=
581 DEFAULT_HELLO_INTERVAL
;
585 switch (hello_type
) {
587 vty_conf
->lhello_interval
= secs
;
590 vty_conf
->thello_interval
= secs
;
594 ldp_config_apply(vty
, vty_conf
);
598 af
= ldp_vty_get_af(vty
);
599 af_conf
= ldp_af_conf_get(vty_conf
, af
);
602 switch (hello_type
) {
604 af_conf
->lhello_interval
= 0;
607 af_conf
->thello_interval
= 0;
611 switch (hello_type
) {
613 af_conf
->lhello_interval
= secs
;
616 af_conf
->thello_interval
= secs
;
620 ldp_config_apply(vty
, vty_conf
);
622 case LDP_IPV4_IFACE_NODE
:
623 case LDP_IPV6_IFACE_NODE
:
624 af
= ldp_vty_get_af(vty
);
625 iface
= VTY_GET_CONTEXT(iface
);
626 VTY_CHECK_CONTEXT(iface
);
628 ia
= iface_af_get(iface
, af
);
630 ia
->hello_interval
= 0;
632 ia
->hello_interval
= secs
;
634 ldp_config_apply(vty
, vty_conf
);
637 fatalx("ldp_vty_disc_interval: unexpected node");
640 return (CMD_SUCCESS
);
644 ldp_vty_targeted_hello_accept(struct vty
*vty
, const char *negate
,
645 const char *acl_from_str
)
647 struct ldpd_af_conf
*af_conf
;
650 af
= ldp_vty_get_af(vty
);
651 af_conf
= ldp_af_conf_get(vty_conf
, af
);
654 af_conf
->flags
&= ~F_LDPD_AF_THELLO_ACCEPT
;
655 af_conf
->acl_thello_accept_from
[0] = '\0';
657 af_conf
->flags
|= F_LDPD_AF_THELLO_ACCEPT
;
659 strlcpy(af_conf
->acl_thello_accept_from
, acl_from_str
,
660 sizeof(af_conf
->acl_thello_accept_from
));
662 af_conf
->acl_thello_accept_from
[0] = '\0';
665 ldp_config_apply(vty
, vty_conf
);
667 return (CMD_SUCCESS
);
671 ldp_vty_nbr_session_holdtime(struct vty
*vty
, const char *negate
,
672 struct in_addr lsr_id
, long secs
)
674 struct nbr_params
*nbrp
;
676 if (bad_addr_v4(lsr_id
)) {
677 vty_out (vty
, "%% Malformed address\n");
678 return (CMD_WARNING_CONFIG_FAILED
);
681 nbrp
= nbr_params_find(vty_conf
, lsr_id
);
685 return (CMD_SUCCESS
);
688 nbrp
->flags
&= ~F_NBRP_KEEPALIVE
;
691 nbrp
= nbr_params_new(lsr_id
);
692 RB_INSERT(nbrp_head
, &vty_conf
->nbrp_tree
, nbrp
);
693 QOBJ_REG(nbrp
, nbr_params
);
694 } else if (nbrp
->keepalive
== secs
)
695 return (CMD_SUCCESS
);
697 nbrp
->keepalive
= secs
;
698 nbrp
->flags
|= F_NBRP_KEEPALIVE
;
701 ldp_config_apply(vty
, vty_conf
);
703 return (CMD_SUCCESS
);
707 ldp_vty_af_session_holdtime(struct vty
*vty
, const char *negate
, long secs
)
709 struct ldpd_af_conf
*af_conf
;
712 af
= ldp_vty_get_af(vty
);
713 af_conf
= ldp_af_conf_get(vty_conf
, af
);
716 af_conf
->keepalive
= DEFAULT_KEEPALIVE
;
718 af_conf
->keepalive
= secs
;
720 ldp_config_apply(vty
, vty_conf
);
722 return (CMD_SUCCESS
);
726 ldp_vty_interface(struct vty
*vty
, const char *negate
, const char *ifname
)
732 if (ifname
== NULL
) {
733 vty_out (vty
, "%% Missing IF name\n");
734 return (CMD_WARNING_CONFIG_FAILED
);
737 af
= ldp_vty_get_af(vty
);
738 iface
= if_lookup_name(vty_conf
, ifname
);
742 return (CMD_SUCCESS
);
744 ia
= iface_af_get(iface
, af
);
745 if (ia
->enabled
== 0)
746 return (CMD_SUCCESS
);
749 ia
->hello_holdtime
= 0;
750 ia
->hello_interval
= 0;
752 ldp_config_apply(vty
, vty_conf
);
754 return (CMD_SUCCESS
);
758 if (ldp_iface_is_configured(vty_conf
, ifname
)) {
759 vty_out (vty
,"%% Interface is already in use\n");
760 return (CMD_SUCCESS
);
763 iface
= if_new(ifname
);
764 ia
= iface_af_get(iface
, af
);
766 RB_INSERT(iface_head
, &vty_conf
->iface_tree
, iface
);
767 QOBJ_REG(iface
, iface
);
769 ldp_config_apply(vty
, vty_conf
);
771 ia
= iface_af_get(iface
, af
);
774 ldp_config_apply(vty
, vty_conf
);
780 VTY_PUSH_CONTEXT(LDP_IPV4_IFACE_NODE
, iface
);
783 VTY_PUSH_CONTEXT(LDP_IPV6_IFACE_NODE
, iface
);
789 return (CMD_SUCCESS
);
793 ldp_vty_trans_addr(struct vty
*vty
, const char *negate
, const char *addr_str
)
795 struct ldpd_af_conf
*af_conf
;
798 af
= ldp_vty_get_af(vty
);
799 af_conf
= ldp_af_conf_get(vty_conf
, af
);
802 memset(&af_conf
->trans_addr
, 0, sizeof(af_conf
->trans_addr
));
805 || inet_pton(af
, addr_str
, &af_conf
->trans_addr
) != 1
806 || bad_addr(af
, &af_conf
->trans_addr
)) {
807 vty_out (vty
, "%% Malformed address\n");
808 return (CMD_SUCCESS
);
812 ldp_config_apply(vty
, vty_conf
);
814 return (CMD_SUCCESS
);
818 ldp_vty_neighbor_targeted(struct vty
*vty
, const char *negate
, const char *addr_str
)
821 union ldpd_addr addr
;
824 af
= ldp_vty_get_af(vty
);
826 if (addr_str
== NULL
|| inet_pton(af
, addr_str
, &addr
) != 1 ||
827 bad_addr(af
, &addr
)) {
828 vty_out (vty
, "%% Malformed address\n");
829 return (CMD_WARNING_CONFIG_FAILED
);
831 if (af
== AF_INET6
&& IN6_IS_SCOPE_EMBED(&addr
.v6
)) {
832 vty_out (vty
, "%% Address can not be link-local\n");
833 return (CMD_WARNING_CONFIG_FAILED
);
836 tnbr
= tnbr_find(vty_conf
, af
, &addr
);
840 return (CMD_SUCCESS
);
843 RB_REMOVE(tnbr_head
, &vty_conf
->tnbr_tree
, tnbr
);
846 ldp_config_apply(vty
, vty_conf
);
848 return (CMD_SUCCESS
);
852 return (CMD_SUCCESS
);
854 tnbr
= tnbr_new(af
, &addr
);
855 tnbr
->flags
|= F_TNBR_CONFIGURED
;
856 RB_INSERT(tnbr_head
, &vty_conf
->tnbr_tree
, tnbr
);
857 QOBJ_REG(tnbr
, tnbr
);
859 ldp_config_apply(vty
, vty_conf
);
861 return (CMD_SUCCESS
);
865 ldp_vty_label_advertise(struct vty
*vty
, const char *negate
, const char *acl_to_str
,
866 const char *acl_for_str
)
868 struct ldpd_af_conf
*af_conf
;
871 af
= ldp_vty_get_af(vty
);
872 af_conf
= ldp_af_conf_get(vty_conf
, af
);
875 af_conf
->acl_label_advertise_to
[0] = '\0';
876 af_conf
->acl_label_advertise_for
[0] = '\0';
879 strlcpy(af_conf
->acl_label_advertise_to
, acl_to_str
,
880 sizeof(af_conf
->acl_label_advertise_to
));
882 af_conf
->acl_label_advertise_to
[0] = '\0';
884 strlcpy(af_conf
->acl_label_advertise_for
, acl_for_str
,
885 sizeof(af_conf
->acl_label_advertise_for
));
887 af_conf
->acl_label_advertise_for
[0] = '\0';
890 ldp_config_apply(vty
, vty_conf
);
892 return (CMD_SUCCESS
);
896 ldp_vty_label_allocate(struct vty
*vty
, const char *negate
, const char *host_routes
,
897 const char *acl_for_str
)
899 struct ldpd_af_conf
*af_conf
;
902 af
= ldp_vty_get_af(vty
);
903 af_conf
= ldp_af_conf_get(vty_conf
, af
);
905 af_conf
->flags
&= ~F_LDPD_AF_ALLOCHOSTONLY
;
906 af_conf
->acl_label_allocate_for
[0] = '\0';
909 af_conf
->flags
|= F_LDPD_AF_ALLOCHOSTONLY
;
911 strlcpy(af_conf
->acl_label_allocate_for
, acl_for_str
,
912 sizeof(af_conf
->acl_label_allocate_for
));
915 ldp_config_apply(vty
, vty_conf
);
917 return (CMD_SUCCESS
);
921 ldp_vty_label_expnull(struct vty
*vty
, const char *negate
, const char *acl_for_str
)
923 struct ldpd_af_conf
*af_conf
;
926 af
= ldp_vty_get_af(vty
);
927 af_conf
= ldp_af_conf_get(vty_conf
, af
);
930 af_conf
->flags
&= ~F_LDPD_AF_EXPNULL
;
931 af_conf
->acl_label_expnull_for
[0] = '\0';
933 af_conf
->flags
|= F_LDPD_AF_EXPNULL
;
935 strlcpy(af_conf
->acl_label_expnull_for
, acl_for_str
,
936 sizeof(af_conf
->acl_label_expnull_for
));
938 af_conf
->acl_label_expnull_for
[0] = '\0';
941 ldp_config_apply(vty
, vty_conf
);
943 return (CMD_SUCCESS
);
947 ldp_vty_label_accept(struct vty
*vty
, const char *negate
, const char *acl_from_str
,
948 const char *acl_for_str
)
950 struct ldpd_af_conf
*af_conf
;
953 af
= ldp_vty_get_af(vty
);
954 af_conf
= ldp_af_conf_get(vty_conf
, af
);
957 af_conf
->acl_label_accept_from
[0] = '\0';
958 af_conf
->acl_label_accept_for
[0] = '\0';
961 strlcpy(af_conf
->acl_label_accept_from
, acl_from_str
,
962 sizeof(af_conf
->acl_label_accept_from
));
964 af_conf
->acl_label_accept_from
[0] = '\0';
966 strlcpy(af_conf
->acl_label_accept_for
, acl_for_str
,
967 sizeof(af_conf
->acl_label_accept_for
));
969 af_conf
->acl_label_accept_for
[0] = '\0';
972 ldp_config_apply(vty
, vty_conf
);
974 return (CMD_SUCCESS
);
978 ldp_vty_ttl_security(struct vty
*vty
, const char *negate
)
980 struct ldpd_af_conf
*af_conf
;
983 af
= ldp_vty_get_af(vty
);
984 af_conf
= ldp_af_conf_get(vty_conf
, af
);
987 af_conf
->flags
&= ~F_LDPD_AF_NO_GTSM
;
989 af_conf
->flags
|= F_LDPD_AF_NO_GTSM
;
991 ldp_config_apply(vty
, vty_conf
);
993 return (CMD_SUCCESS
);
997 ldp_vty_router_id(struct vty
*vty
, const char *negate
, struct in_addr address
)
1000 vty_conf
->rtr_id
.s_addr
= INADDR_ANY
;
1002 if (bad_addr_v4(address
)) {
1003 vty_out (vty
, "%% Malformed address\n");
1004 return (CMD_SUCCESS
);
1006 vty_conf
->rtr_id
= address
;
1009 ldp_config_apply(vty
, vty_conf
);
1011 return (CMD_SUCCESS
);
1015 ldp_vty_ordered_control(struct vty
*vty
, const char *negate
)
1018 vty_conf
->flags
&= ~F_LDPD_ORDERED_CONTROL
;
1020 vty_conf
->flags
|= F_LDPD_ORDERED_CONTROL
;
1022 ldp_config_apply(vty
, vty_conf
);
1024 return (CMD_SUCCESS
);
1027 int ldp_vty_wait_for_sync_interval(struct vty
*vty
, const char *negate
,
1030 switch (vty
->node
) {
1033 vty_conf
->wait_for_sync_interval
= DFLT_WAIT_FOR_SYNC
;
1035 vty_conf
->wait_for_sync_interval
= secs
;
1037 ldp_config_apply(vty
, vty_conf
);
1040 fatalx("ldp_vty_wait_for_sync_interval: unexpected node");
1042 return (CMD_SUCCESS
);
1046 ldp_vty_allow_broken_lsp(struct vty
*vty
, const char *negate
)
1049 vty_conf
->flags
&= ~F_LDPD_ALLOW_BROKEN_LSP
;
1051 vty_conf
->flags
|= F_LDPD_ALLOW_BROKEN_LSP
;
1053 ldp_config_apply(vty
, vty_conf
);
1055 return (CMD_SUCCESS
);
1059 ldp_vty_ds_cisco_interop(struct vty
*vty
, const char * negate
)
1062 vty_conf
->flags
&= ~F_LDPD_DS_CISCO_INTEROP
;
1064 vty_conf
->flags
|= F_LDPD_DS_CISCO_INTEROP
;
1066 ldp_config_apply(vty
, vty_conf
);
1068 return (CMD_SUCCESS
);
1072 ldp_vty_trans_pref_ipv4(struct vty
*vty
, const char *negate
)
1075 vty_conf
->trans_pref
= DUAL_STACK_LDPOV6
;
1077 vty_conf
->trans_pref
= DUAL_STACK_LDPOV4
;
1079 ldp_config_apply(vty
, vty_conf
);
1081 return (CMD_SUCCESS
);
1085 ldp_vty_neighbor_password(struct vty
*vty
, const char *negate
, struct in_addr lsr_id
,
1086 const char *password_str
)
1088 size_t password_len
;
1089 struct nbr_params
*nbrp
;
1091 if (password_str
== NULL
) {
1092 vty_out (vty
, "%% Missing password\n");
1093 return (CMD_WARNING_CONFIG_FAILED
);
1096 if (bad_addr_v4(lsr_id
)) {
1097 vty_out (vty
, "%% Malformed address\n");
1098 return (CMD_WARNING_CONFIG_FAILED
);
1101 nbrp
= nbr_params_find(vty_conf
, lsr_id
);
1105 return (CMD_SUCCESS
);
1107 memset(&nbrp
->auth
, 0, sizeof(nbrp
->auth
));
1108 nbrp
->auth
.method
= AUTH_NONE
;
1111 nbrp
= nbr_params_new(lsr_id
);
1112 RB_INSERT(nbrp_head
, &vty_conf
->nbrp_tree
, nbrp
);
1113 QOBJ_REG(nbrp
, nbr_params
);
1114 } else if (nbrp
->auth
.method
== AUTH_MD5SIG
&&
1115 strcmp(nbrp
->auth
.md5key
, password_str
) == 0)
1116 return (CMD_SUCCESS
);
1118 password_len
= strlcpy(nbrp
->auth
.md5key
, password_str
,
1119 sizeof(nbrp
->auth
.md5key
));
1120 if (password_len
>= sizeof(nbrp
->auth
.md5key
))
1121 vty_out(vty
, "%% password has been truncated to %zu characters.", sizeof(nbrp
->auth
.md5key
) - 1);
1122 nbrp
->auth
.md5key_len
= strlen(nbrp
->auth
.md5key
);
1123 nbrp
->auth
.method
= AUTH_MD5SIG
;
1126 ldp_config_apply(vty
, vty_conf
);
1128 return (CMD_SUCCESS
);
1132 ldp_vty_neighbor_ttl_security(struct vty
*vty
, const char *negate
,
1133 struct in_addr lsr_id
, const char *hops_str
)
1135 struct nbr_params
*nbrp
;
1139 if (bad_addr_v4(lsr_id
)) {
1140 vty_out (vty
, "%% Malformed address\n");
1141 return (CMD_WARNING_CONFIG_FAILED
);
1145 hops
= strtol(hops_str
, &ep
, 10);
1146 if (*ep
!= '\0' || hops
< 1 || hops
> 254) {
1147 vty_out (vty
, "%% Invalid hop count\n");
1148 return (CMD_SUCCESS
);
1152 nbrp
= nbr_params_find(vty_conf
, lsr_id
);
1156 return (CMD_SUCCESS
);
1158 nbrp
->flags
&= ~(F_NBRP_GTSM
|F_NBRP_GTSM_HOPS
);
1159 nbrp
->gtsm_enabled
= 0;
1160 nbrp
->gtsm_hops
= 0;
1163 nbrp
= nbr_params_new(lsr_id
);
1164 RB_INSERT(nbrp_head
, &vty_conf
->nbrp_tree
, nbrp
);
1165 QOBJ_REG(nbrp
, nbr_params
);
1168 nbrp
->flags
|= F_NBRP_GTSM
;
1169 nbrp
->flags
&= ~F_NBRP_GTSM_HOPS
;
1171 nbrp
->gtsm_enabled
= 1;
1172 nbrp
->gtsm_hops
= hops
;
1173 nbrp
->flags
|= F_NBRP_GTSM_HOPS
;
1175 nbrp
->gtsm_enabled
= 0;
1178 ldp_config_apply(vty
, vty_conf
);
1180 return (CMD_SUCCESS
);
1184 ldp_vty_l2vpn(struct vty
*vty
, const char *negate
, const char *name_str
)
1186 struct l2vpn
*l2vpn
;
1187 struct l2vpn_if
*lif
;
1188 struct l2vpn_pw
*pw
;
1190 if (name_str
== NULL
) {
1191 vty_out (vty
, "%% Missing name\n");
1192 return (CMD_WARNING_CONFIG_FAILED
);
1195 l2vpn
= l2vpn_find(vty_conf
, name_str
);
1199 return (CMD_SUCCESS
);
1201 RB_FOREACH(lif
, l2vpn_if_head
, &l2vpn
->if_tree
)
1203 RB_FOREACH(pw
, l2vpn_pw_head
, &l2vpn
->pw_tree
)
1205 RB_FOREACH(pw
, l2vpn_pw_head
, &l2vpn
->pw_inactive_tree
)
1208 RB_REMOVE(l2vpn_head
, &vty_conf
->l2vpn_tree
, l2vpn
);
1211 ldp_config_apply(vty
, vty_conf
);
1213 return (CMD_SUCCESS
);
1217 VTY_PUSH_CONTEXT(LDP_L2VPN_NODE
, l2vpn
);
1218 return (CMD_SUCCESS
);
1221 l2vpn
= l2vpn_new(name_str
);
1222 l2vpn
->type
= L2VPN_TYPE_VPLS
;
1223 RB_INSERT(l2vpn_head
, &vty_conf
->l2vpn_tree
, l2vpn
);
1224 QOBJ_REG(l2vpn
, l2vpn
);
1226 VTY_PUSH_CONTEXT(LDP_L2VPN_NODE
, l2vpn
);
1228 ldp_config_apply(vty
, vty_conf
);
1230 return (CMD_SUCCESS
);
1234 ldp_vty_l2vpn_bridge(struct vty
*vty
, const char *negate
, const char *ifname
)
1236 VTY_DECLVAR_CONTEXT(l2vpn
, l2vpn
);
1239 memset(l2vpn
->br_ifname
, 0, sizeof(l2vpn
->br_ifname
));
1241 if (ifname
== NULL
) {
1242 vty_out (vty
, "%% Missing IF name\n");
1243 return (CMD_WARNING_CONFIG_FAILED
);
1245 strlcpy(l2vpn
->br_ifname
, ifname
, sizeof(l2vpn
->br_ifname
));
1248 ldp_config_apply(vty
, vty_conf
);
1250 return (CMD_SUCCESS
);
1254 ldp_vty_l2vpn_mtu(struct vty
*vty
, const char *negate
, long mtu
)
1256 VTY_DECLVAR_CONTEXT(l2vpn
, l2vpn
);
1259 l2vpn
->mtu
= DEFAULT_L2VPN_MTU
;
1263 ldp_config_apply(vty
, vty_conf
);
1265 return (CMD_SUCCESS
);
1269 ldp_vty_l2vpn_pwtype(struct vty
*vty
, const char *negate
, const char *type_str
)
1271 VTY_DECLVAR_CONTEXT(l2vpn
, l2vpn
);
1274 if (type_str
== NULL
) {
1275 vty_out (vty
, "%% Missing type\n");
1276 return (CMD_WARNING_CONFIG_FAILED
);
1279 if (strcmp(type_str
, "ethernet") == 0)
1280 pw_type
= PW_TYPE_ETHERNET
;
1282 pw_type
= PW_TYPE_ETHERNET_TAGGED
;
1285 l2vpn
->pw_type
= DEFAULT_PW_TYPE
;
1287 l2vpn
->pw_type
= pw_type
;
1289 ldp_config_apply(vty
, vty_conf
);
1291 return (CMD_SUCCESS
);
1295 ldp_vty_l2vpn_interface(struct vty
*vty
, const char *negate
, const char *ifname
)
1297 VTY_DECLVAR_CONTEXT(l2vpn
, l2vpn
);
1298 struct l2vpn_if
*lif
;
1300 if (ifname
== NULL
) {
1301 vty_out (vty
, "%% Missing IF name\n");
1302 return (CMD_WARNING_CONFIG_FAILED
);
1305 lif
= l2vpn_if_find(l2vpn
, ifname
);
1309 return (CMD_SUCCESS
);
1312 RB_REMOVE(l2vpn_if_head
, &l2vpn
->if_tree
, lif
);
1315 ldp_config_apply(vty
, vty_conf
);
1317 return (CMD_SUCCESS
);
1321 return (CMD_SUCCESS
);
1323 if (ldp_iface_is_configured(vty_conf
, ifname
)) {
1324 vty_out (vty
, "%% Interface is already in use\n");
1325 return (CMD_SUCCESS
);
1328 lif
= l2vpn_if_new(l2vpn
, ifname
);
1329 RB_INSERT(l2vpn_if_head
, &l2vpn
->if_tree
, lif
);
1330 QOBJ_REG(lif
, l2vpn_if
);
1332 ldp_config_apply(vty
, vty_conf
);
1334 return (CMD_SUCCESS
);
1338 ldp_vty_l2vpn_pseudowire(struct vty
*vty
, const char *negate
, const char *ifname
)
1340 VTY_DECLVAR_CONTEXT(l2vpn
, l2vpn
);
1341 struct l2vpn_pw
*pw
;
1343 if (ifname
== NULL
) {
1344 vty_out (vty
, "%% Missing IF name\n");
1345 return (CMD_WARNING_CONFIG_FAILED
);
1348 pw
= l2vpn_pw_find(l2vpn
, ifname
);
1352 return (CMD_SUCCESS
);
1355 if (pw
->lsr_id
.s_addr
== INADDR_ANY
|| pw
->pwid
== 0)
1356 RB_REMOVE(l2vpn_pw_head
, &l2vpn
->pw_inactive_tree
, pw
);
1358 RB_REMOVE(l2vpn_pw_head
, &l2vpn
->pw_tree
, pw
);
1361 ldp_config_apply(vty
, vty_conf
);
1363 return (CMD_SUCCESS
);
1367 VTY_PUSH_CONTEXT_SUB(LDP_PSEUDOWIRE_NODE
, pw
);
1368 return (CMD_SUCCESS
);
1371 if (ldp_iface_is_configured(vty_conf
, ifname
)) {
1372 vty_out (vty
, "%% Interface is already in use\n");
1373 return (CMD_SUCCESS
);
1376 pw
= l2vpn_pw_new(l2vpn
, ifname
);
1377 pw
->flags
= F_PW_STATUSTLV_CONF
|F_PW_CWORD_CONF
;
1378 RB_INSERT(l2vpn_pw_head
, &l2vpn
->pw_inactive_tree
, pw
);
1379 QOBJ_REG(pw
, l2vpn_pw
);
1381 VTY_PUSH_CONTEXT_SUB(LDP_PSEUDOWIRE_NODE
, pw
);
1383 ldp_config_apply(vty
, vty_conf
);
1385 return (CMD_SUCCESS
);
1389 ldp_vty_l2vpn_pw_cword(struct vty
*vty
, const char *negate
, const char *preference_str
)
1391 VTY_DECLVAR_CONTEXT_SUB(l2vpn_pw
, pw
);
1394 pw
->flags
|= F_PW_CWORD_CONF
;
1396 if (!preference_str
) {
1397 vty_out (vty
, "%% Missing preference\n");
1398 return (CMD_WARNING_CONFIG_FAILED
);
1400 if (preference_str
[0] == 'e')
1401 pw
->flags
&= ~F_PW_CWORD_CONF
;
1403 pw
->flags
|= F_PW_CWORD_CONF
;
1406 ldp_config_apply(vty
, vty_conf
);
1408 return (CMD_SUCCESS
);
1412 ldp_vty_l2vpn_pw_nbr_addr(struct vty
*vty
, const char *negate
, const char *addr_str
)
1414 VTY_DECLVAR_CONTEXT_SUB(l2vpn_pw
, pw
);
1416 union ldpd_addr addr
;
1418 if (ldp_get_address(addr_str
, &af
, &addr
) == -1 ||
1419 bad_addr(af
, &addr
)) {
1420 vty_out (vty
, "%% Malformed address\n");
1421 return (CMD_WARNING_CONFIG_FAILED
);
1426 memset(&pw
->addr
, 0, sizeof(pw
->addr
));
1427 pw
->flags
&= ~F_PW_STATIC_NBR_ADDR
;
1431 pw
->flags
|= F_PW_STATIC_NBR_ADDR
;
1434 ldp_config_apply(vty
, vty_conf
);
1436 return (CMD_SUCCESS
);
1440 ldp_vty_l2vpn_pw_nbr_id(struct vty
*vty
, const char *negate
, struct in_addr lsr_id
)
1442 VTY_DECLVAR_CONTEXT_SUB(l2vpn_pw
, pw
);
1444 if (bad_addr_v4(lsr_id
)) {
1445 vty_out (vty
, "%% Malformed address\n");
1446 return (CMD_WARNING_CONFIG_FAILED
);
1450 pw
->lsr_id
.s_addr
= INADDR_ANY
;
1452 pw
->lsr_id
= lsr_id
;
1454 ldp_config_apply(vty
, vty_conf
);
1456 return (CMD_SUCCESS
);
1460 ldp_vty_l2vpn_pw_pwid(struct vty
*vty
, const char *negate
, long pwid
)
1462 VTY_DECLVAR_CONTEXT_SUB(l2vpn_pw
, pw
);
1469 ldp_config_apply(vty
, vty_conf
);
1471 return (CMD_SUCCESS
);
1475 ldp_vty_l2vpn_pw_pwstatus(struct vty
*vty
, const char *negate
)
1477 VTY_DECLVAR_CONTEXT_SUB(l2vpn_pw
, pw
);
1480 pw
->flags
|= F_PW_STATUSTLV_CONF
;
1482 pw
->flags
&= ~F_PW_STATUSTLV_CONF
;
1484 ldp_config_apply(vty
, vty_conf
);
1486 return (CMD_SUCCESS
);
1490 iface_new_api(struct ldpd_conf
*conf
, const char *name
)
1492 const char *ifname
= name
;
1493 struct iface
*iface
;
1495 if (ldp_iface_is_configured(conf
, ifname
))
1498 iface
= if_new(name
);
1499 RB_INSERT(iface_head
, &conf
->iface_tree
, iface
);
1500 QOBJ_REG(iface
, iface
);
1505 iface_del_api(struct ldpd_conf
*conf
, struct iface
*iface
)
1508 RB_REMOVE(iface_head
, &conf
->iface_tree
, iface
);
1513 tnbr_new_api(struct ldpd_conf
*conf
, int af
, union ldpd_addr
*addr
)
1517 if (af
== AF_INET6
&& IN6_IS_SCOPE_EMBED(&addr
->v6
))
1520 if (tnbr_find(conf
, af
, addr
))
1523 tnbr
= tnbr_new(af
, addr
);
1524 tnbr
->flags
|= F_TNBR_CONFIGURED
;
1525 RB_INSERT(tnbr_head
, &conf
->tnbr_tree
, tnbr
);
1526 QOBJ_REG(tnbr
, tnbr
);
1531 tnbr_del_api(struct ldpd_conf
*conf
, struct tnbr
*tnbr
)
1534 RB_REMOVE(tnbr_head
, &conf
->tnbr_tree
, tnbr
);
1539 nbrp_new_api(struct ldpd_conf
*conf
, struct in_addr lsr_id
)
1541 struct nbr_params
*nbrp
;
1543 if (nbr_params_find(conf
, lsr_id
))
1546 nbrp
= nbr_params_new(lsr_id
);
1547 RB_INSERT(nbrp_head
, &conf
->nbrp_tree
, nbrp
);
1548 QOBJ_REG(nbrp
, nbr_params
);
1553 nbrp_del_api(struct ldpd_conf
*conf
, struct nbr_params
*nbrp
)
1556 RB_REMOVE(nbrp_head
, &conf
->nbrp_tree
, nbrp
);
1561 l2vpn_new_api(struct ldpd_conf
*conf
, const char *name
)
1563 struct l2vpn
*l2vpn
;
1565 if (l2vpn_find(conf
, name
))
1568 l2vpn
= l2vpn_new(name
);
1569 l2vpn
->type
= L2VPN_TYPE_VPLS
;
1570 RB_INSERT(l2vpn_head
, &conf
->l2vpn_tree
, l2vpn
);
1571 QOBJ_REG(l2vpn
, l2vpn
);
1576 l2vpn_del_api(struct ldpd_conf
*conf
, struct l2vpn
*l2vpn
)
1578 struct l2vpn_if
*lif
;
1579 struct l2vpn_pw
*pw
;
1581 while (!RB_EMPTY(l2vpn_if_head
, &l2vpn
->if_tree
)) {
1582 lif
= RB_ROOT(l2vpn_if_head
, &l2vpn
->if_tree
);
1585 RB_REMOVE(l2vpn_if_head
, &l2vpn
->if_tree
, lif
);
1588 while (!RB_EMPTY(l2vpn_pw_head
, &l2vpn
->pw_tree
)) {
1589 pw
= RB_ROOT(l2vpn_pw_head
, &l2vpn
->pw_tree
);
1592 RB_REMOVE(l2vpn_pw_head
, &l2vpn
->pw_tree
, pw
);
1595 while (!RB_EMPTY(l2vpn_pw_head
, &l2vpn
->pw_inactive_tree
)) {
1596 pw
= RB_ROOT(l2vpn_pw_head
, &l2vpn
->pw_inactive_tree
);
1599 RB_REMOVE(l2vpn_pw_head
, &l2vpn
->pw_inactive_tree
, pw
);
1603 RB_REMOVE(l2vpn_head
, &conf
->l2vpn_tree
, l2vpn
);
1608 l2vpn_if_new_api(struct ldpd_conf
*conf
, struct l2vpn
*l2vpn
,
1611 struct l2vpn_if
*lif
;
1613 if (ldp_iface_is_configured(conf
, ifname
))
1616 lif
= l2vpn_if_new(l2vpn
, ifname
);
1617 RB_INSERT(l2vpn_if_head
, &l2vpn
->if_tree
, lif
);
1618 QOBJ_REG(lif
, l2vpn_if
);
1623 l2vpn_if_del_api(struct l2vpn
*l2vpn
, struct l2vpn_if
*lif
)
1626 RB_REMOVE(l2vpn_if_head
, &l2vpn
->if_tree
, lif
);
1631 l2vpn_pw_new_api(struct ldpd_conf
*conf
, struct l2vpn
*l2vpn
,
1634 struct l2vpn_pw
*pw
;
1636 if (ldp_iface_is_configured(conf
, ifname
))
1639 pw
= l2vpn_pw_new(l2vpn
, ifname
);
1640 pw
->flags
= F_PW_STATUSTLV_CONF
|F_PW_CWORD_CONF
;
1641 RB_INSERT(l2vpn_pw_head
, &l2vpn
->pw_inactive_tree
, pw
);
1642 QOBJ_REG(pw
, l2vpn_pw
);
1647 l2vpn_pw_del_api(struct l2vpn
*l2vpn
, struct l2vpn_pw
*pw
)
1650 RB_REMOVE(l2vpn_pw_head
, &l2vpn
->pw_inactive_tree
, pw
);