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 void ldp_af_iface_config_write(struct vty
*, int);
34 static void ldp_af_config_write(struct vty
*, int, struct ldpd_conf
*,
35 struct ldpd_af_conf
*);
36 static void ldp_l2vpn_pw_config_write(struct vty
*, struct l2vpn_pw
*);
37 static int ldp_vty_get_af(struct vty
*);
38 static int ldp_iface_is_configured(struct ldpd_conf
*, const char *);
40 struct cmd_node ldp_node
=
47 struct cmd_node ldp_ipv4_node
=
50 "%s(config-ldp-af)# ",
54 struct cmd_node ldp_ipv6_node
=
57 "%s(config-ldp-af)# ",
61 struct cmd_node ldp_ipv4_iface_node
=
64 "%s(config-ldp-af-if)# ",
68 struct cmd_node ldp_ipv6_iface_node
=
71 "%s(config-ldp-af-if)# ",
75 struct cmd_node ldp_l2vpn_node
=
82 struct cmd_node ldp_pseudowire_node
=
85 "%s(config-l2vpn-pw)# ",
90 ldp_get_address(const char *str
, int *af
, union ldpd_addr
*addr
)
92 memset(addr
, 0, sizeof(*addr
));
94 if (inet_pton(AF_INET
, str
, &addr
->v4
) == 1) {
99 if (inet_pton(AF_INET6
, str
, &addr
->v6
) == 1) {
108 ldp_af_iface_config_write(struct vty
*vty
, int af
)
113 RB_FOREACH(iface
, iface_head
, &ldpd_conf
->iface_tree
) {
114 ia
= iface_af_get(iface
, af
);
118 vty_out(vty
, " !%s", VTY_NEWLINE
);
119 vty_out(vty
, " interface %s%s", iface
->name
, VTY_NEWLINE
);
121 if (ia
->hello_holdtime
!= LINK_DFLT_HOLDTIME
&&
122 ia
->hello_holdtime
!= 0)
123 vty_out(vty
, " discovery hello holdtime %u%s",
124 ia
->hello_holdtime
, VTY_NEWLINE
);
125 if (ia
->hello_interval
!= DEFAULT_HELLO_INTERVAL
&&
126 ia
->hello_interval
!= 0)
127 vty_out(vty
, " discovery hello interval %u%s",
128 ia
->hello_interval
, VTY_NEWLINE
);
133 ldp_af_config_write(struct vty
*vty
, int af
, struct ldpd_conf
*conf
,
134 struct ldpd_af_conf
*af_conf
)
138 if (!(af_conf
->flags
& F_LDPD_AF_ENABLED
))
141 vty_out(vty
, " !%s", VTY_NEWLINE
);
142 vty_out(vty
, " address-family %s%s", af_name(af
), VTY_NEWLINE
);
144 if (af_conf
->lhello_holdtime
!= LINK_DFLT_HOLDTIME
&&
145 af_conf
->lhello_holdtime
!= 0 )
146 vty_out(vty
, " discovery hello holdtime %u%s",
147 af_conf
->lhello_holdtime
, VTY_NEWLINE
);
148 if (af_conf
->lhello_interval
!= DEFAULT_HELLO_INTERVAL
&&
149 af_conf
->lhello_interval
!= 0)
150 vty_out(vty
, " discovery hello interval %u%s",
151 af_conf
->lhello_interval
, VTY_NEWLINE
);
153 if (af_conf
->flags
& F_LDPD_AF_THELLO_ACCEPT
) {
154 vty_out(vty
, " discovery targeted-hello accept");
155 if (af_conf
->acl_thello_accept_from
[0] != '\0')
156 vty_out(vty
, " from %s",
157 af_conf
->acl_thello_accept_from
);
158 vty_out(vty
, "%s", VTY_NEWLINE
);
161 if (af_conf
->thello_holdtime
!= TARGETED_DFLT_HOLDTIME
&&
162 af_conf
->thello_holdtime
!= 0)
163 vty_out(vty
, " discovery targeted-hello holdtime %u%s",
164 af_conf
->thello_holdtime
, VTY_NEWLINE
);
165 if (af_conf
->thello_interval
!= DEFAULT_HELLO_INTERVAL
&&
166 af_conf
->thello_interval
!= 0)
167 vty_out(vty
, " discovery targeted-hello interval %u%s",
168 af_conf
->thello_interval
, VTY_NEWLINE
);
170 if (ldp_addrisset(af
, &af_conf
->trans_addr
))
171 vty_out(vty
, " discovery transport-address %s%s",
172 log_addr(af
, &af_conf
->trans_addr
), VTY_NEWLINE
);
174 vty_out(vty
, " ! Incomplete config, specify a discovery "
175 "transport-address%s", VTY_NEWLINE
);
177 if ((af_conf
->flags
& F_LDPD_AF_ALLOCHOSTONLY
) ||
178 af_conf
->acl_label_allocate_for
[0] != '\0') {
179 vty_out(vty
, " label local allocate");
180 if (af_conf
->flags
& F_LDPD_AF_ALLOCHOSTONLY
)
181 vty_out(vty
, " host-routes");
183 vty_out(vty
, " for %s",
184 af_conf
->acl_label_allocate_for
);
185 vty_out(vty
, "%s", VTY_NEWLINE
);
188 if (af_conf
->acl_label_advertise_for
[0] != '\0' ||
189 af_conf
->acl_label_advertise_to
[0] != '\0') {
190 vty_out(vty
, " label local advertise");
191 if (af_conf
->acl_label_advertise_to
[0] != '\0')
192 vty_out(vty
, " to %s",
193 af_conf
->acl_label_advertise_to
);
194 if (af_conf
->acl_label_advertise_for
[0] != '\0')
195 vty_out(vty
, " for %s",
196 af_conf
->acl_label_advertise_for
);
197 vty_out(vty
, "%s", VTY_NEWLINE
);
200 if (af_conf
->flags
& F_LDPD_AF_EXPNULL
) {
201 vty_out(vty
, " label local advertise explicit-null");
202 if (af_conf
->acl_label_expnull_for
[0] != '\0')
203 vty_out(vty
, " for %s",
204 af_conf
->acl_label_expnull_for
);
205 vty_out(vty
, "%s", VTY_NEWLINE
);
208 if (af_conf
->acl_label_accept_for
[0] != '\0' ||
209 af_conf
->acl_label_accept_from
[0] != '\0') {
210 vty_out(vty
, " label remote accept");
211 if (af_conf
->acl_label_accept_from
[0] != '\0')
212 vty_out(vty
, " from %s",
213 af_conf
->acl_label_accept_from
);
214 if (af_conf
->acl_label_accept_for
[0] != '\0')
215 vty_out(vty
, " for %s",
216 af_conf
->acl_label_accept_for
);
217 vty_out(vty
, "%s", VTY_NEWLINE
);
220 if (af_conf
->flags
& F_LDPD_AF_NO_GTSM
)
221 vty_out(vty
, " ttl-security disable%s", VTY_NEWLINE
);
223 if (af_conf
->keepalive
!= DEFAULT_KEEPALIVE
)
224 vty_out(vty
, " session holdtime %u%s", af_conf
->keepalive
,
227 RB_FOREACH(tnbr
, tnbr_head
, &ldpd_conf
->tnbr_tree
) {
228 if (tnbr
->af
== af
) {
229 vty_out(vty
, " !%s", VTY_NEWLINE
);
230 vty_out(vty
, " neighbor %s targeted%s",
231 log_addr(tnbr
->af
, &tnbr
->addr
), VTY_NEWLINE
);
235 ldp_af_iface_config_write(vty
, af
);
237 vty_out(vty
, " !%s", VTY_NEWLINE
);
241 ldp_config_write(struct vty
*vty
)
243 struct nbr_params
*nbrp
;
245 if (!(ldpd_conf
->flags
& F_LDPD_ENABLED
))
248 vty_out(vty
, "mpls ldp%s", VTY_NEWLINE
);
250 if (ldpd_conf
->rtr_id
.s_addr
!= 0)
251 vty_out(vty
, " router-id %s%s",
252 inet_ntoa(ldpd_conf
->rtr_id
), VTY_NEWLINE
);
254 if (ldpd_conf
->lhello_holdtime
!= LINK_DFLT_HOLDTIME
&&
255 ldpd_conf
->lhello_holdtime
!= 0)
256 vty_out(vty
, " discovery hello holdtime %u%s",
257 ldpd_conf
->lhello_holdtime
, VTY_NEWLINE
);
258 if (ldpd_conf
->lhello_interval
!= DEFAULT_HELLO_INTERVAL
&&
259 ldpd_conf
->lhello_interval
!= 0)
260 vty_out(vty
, " discovery hello interval %u%s",
261 ldpd_conf
->lhello_interval
, VTY_NEWLINE
);
263 if (ldpd_conf
->thello_holdtime
!= TARGETED_DFLT_HOLDTIME
&&
264 ldpd_conf
->thello_holdtime
!= 0)
265 vty_out(vty
, " discovery targeted-hello holdtime %u%s",
266 ldpd_conf
->thello_holdtime
, VTY_NEWLINE
);
267 if (ldpd_conf
->thello_interval
!= DEFAULT_HELLO_INTERVAL
&&
268 ldpd_conf
->thello_interval
!= 0)
269 vty_out(vty
, " discovery targeted-hello interval %u%s",
270 ldpd_conf
->thello_interval
, VTY_NEWLINE
);
272 if (ldpd_conf
->trans_pref
== DUAL_STACK_LDPOV4
)
273 vty_out(vty
, " dual-stack transport-connection prefer ipv4%s",
276 if (ldpd_conf
->flags
& F_LDPD_DS_CISCO_INTEROP
)
277 vty_out(vty
, " dual-stack cisco-interop%s", VTY_NEWLINE
);
279 RB_FOREACH(nbrp
, nbrp_head
, &ldpd_conf
->nbrp_tree
) {
280 if (nbrp
->flags
& F_NBRP_KEEPALIVE
)
281 vty_out(vty
, " neighbor %s session holdtime %u%s",
282 inet_ntoa(nbrp
->lsr_id
), nbrp
->keepalive
,
285 if (nbrp
->flags
& F_NBRP_GTSM
) {
286 if (nbrp
->gtsm_enabled
)
287 vty_out(vty
, " neighbor %s ttl-security hops "
288 "%u%s", inet_ntoa(nbrp
->lsr_id
),
289 nbrp
->gtsm_hops
, VTY_NEWLINE
);
291 vty_out(vty
, " neighbor %s ttl-security "
292 "disable%s", inet_ntoa(nbrp
->lsr_id
),
296 if (nbrp
->auth
.method
== AUTH_MD5SIG
)
297 vty_out(vty
, " neighbor %s password %s%s",
298 inet_ntoa(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
, " !%s", VTY_NEWLINE
);
305 vty_out(vty
, "!%s", VTY_NEWLINE
);
311 ldp_l2vpn_pw_config_write(struct vty
*vty
, struct l2vpn_pw
*pw
)
313 int missing_lsrid
= 0;
314 int missing_pwid
= 0;
316 vty_out(vty
, " !%s", VTY_NEWLINE
);
317 vty_out(vty
, " member pseudowire %s%s", pw
->ifname
, VTY_NEWLINE
);
319 if (pw
->lsr_id
.s_addr
!= INADDR_ANY
)
320 vty_out(vty
, " neighbor lsr-id %s%s", inet_ntoa(pw
->lsr_id
),
325 if (pw
->flags
& F_PW_STATIC_NBR_ADDR
)
326 vty_out(vty
, " neighbor address %s%s", log_addr(pw
->af
,
327 &pw
->addr
), VTY_NEWLINE
);
330 vty_out(vty
, " pw-id %u%s", pw
->pwid
, VTY_NEWLINE
);
334 if (!(pw
->flags
& F_PW_CWORD_CONF
))
335 vty_out(vty
, " control-word exclude%s", VTY_NEWLINE
);
337 if (!(pw
->flags
& F_PW_STATUSTLV_CONF
))
338 vty_out(vty
, " pw-status disable%s", VTY_NEWLINE
);
341 vty_out(vty
, " ! Incomplete config, specify a neighbor "
342 "lsr-id%s", VTY_NEWLINE
);
344 vty_out(vty
, " ! Incomplete config, specify a pw-id%s",
349 ldp_l2vpn_config_write(struct vty
*vty
)
352 struct l2vpn_if
*lif
;
355 RB_FOREACH(l2vpn
, l2vpn_head
, &ldpd_conf
->l2vpn_tree
) {
356 vty_out(vty
, "l2vpn %s type vpls%s", l2vpn
->name
, VTY_NEWLINE
);
358 if (l2vpn
->pw_type
!= DEFAULT_PW_TYPE
)
359 vty_out(vty
, " vc type ethernet-tagged%s", VTY_NEWLINE
);
361 if (l2vpn
->mtu
!= DEFAULT_L2VPN_MTU
)
362 vty_out(vty
, " mtu %u%s", l2vpn
->mtu
, VTY_NEWLINE
);
364 if (l2vpn
->br_ifname
[0] != '\0')
365 vty_out(vty
, " bridge %s%s", l2vpn
->br_ifname
,
368 RB_FOREACH(lif
, l2vpn_if_head
, &l2vpn
->if_tree
)
369 vty_out(vty
, " member interface %s%s", lif
->ifname
,
372 RB_FOREACH(pw
, l2vpn_pw_head
, &l2vpn
->pw_tree
)
373 ldp_l2vpn_pw_config_write(vty
, pw
);
374 RB_FOREACH(pw
, l2vpn_pw_head
, &l2vpn
->pw_inactive_tree
)
375 ldp_l2vpn_pw_config_write(vty
, pw
);
377 vty_out(vty
, " !%s", VTY_NEWLINE
);
378 vty_out(vty
, "!%s", VTY_NEWLINE
);
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
, int disable
)
421 vty_conf
->flags
&= ~F_LDPD_ENABLED
;
423 vty
->node
= LDP_NODE
;
424 vty_conf
->flags
|= F_LDPD_ENABLED
;
427 ldp_config_apply(vty
, vty_conf
);
429 return (CMD_SUCCESS
);
433 ldp_vty_address_family(struct vty
*vty
, int disable
, const char *af_str
)
435 struct ldpd_af_conf
*af_conf
;
438 if (strcmp(af_str
, "ipv4") == 0) {
440 af_conf
= &vty_conf
->ipv4
;
441 } else if (strcmp(af_str
, "ipv6") == 0) {
443 af_conf
= &vty_conf
->ipv6
;
445 return (CMD_WARNING
);
448 af_conf
->flags
&= ~F_LDPD_AF_ENABLED
;
449 ldp_config_apply(vty
, vty_conf
);
450 return (CMD_SUCCESS
);
455 vty
->node
= LDP_IPV4_NODE
;
458 vty
->node
= LDP_IPV6_NODE
;
461 fatalx("ldp_vty_address_family: unknown af");
463 af_conf
->flags
|= F_LDPD_AF_ENABLED
;
465 ldp_config_apply(vty
, vty_conf
);
467 return (CMD_SUCCESS
);
471 ldp_vty_disc_holdtime(struct vty
*vty
, int disable
, const char *hello_type_str
,
472 const char *seconds_str
)
474 struct ldpd_af_conf
*af_conf
;
480 enum hello_type hello_type
;
482 secs
= strtol(seconds_str
, &ep
, 10);
483 if (*ep
!= '\0' || secs
< MIN_HOLDTIME
|| secs
> MAX_HOLDTIME
) {
484 vty_out(vty
, "%% Invalid holdtime%s", VTY_NEWLINE
);
485 return (CMD_WARNING
);
488 if (hello_type_str
[0] == 'h')
489 hello_type
= HELLO_LINK
;
491 hello_type
= HELLO_TARGETED
;
496 switch (hello_type
) {
498 vty_conf
->lhello_holdtime
= LINK_DFLT_HOLDTIME
;
501 vty_conf
->thello_holdtime
=
502 TARGETED_DFLT_HOLDTIME
;
506 switch (hello_type
) {
508 vty_conf
->lhello_holdtime
= secs
;
511 vty_conf
->thello_holdtime
= secs
;
515 ldp_config_apply(vty
, vty_conf
);
519 af
= ldp_vty_get_af(vty
);
520 af_conf
= ldp_af_conf_get(vty_conf
, af
);
523 switch (hello_type
) {
525 af_conf
->lhello_holdtime
= 0;
528 af_conf
->thello_holdtime
= 0;
532 switch (hello_type
) {
534 af_conf
->lhello_holdtime
= secs
;
537 af_conf
->thello_holdtime
= secs
;
541 ldp_config_apply(vty
, vty_conf
);
543 case LDP_IPV4_IFACE_NODE
:
544 case LDP_IPV6_IFACE_NODE
:
545 af
= ldp_vty_get_af(vty
);
546 iface
= VTY_GET_CONTEXT(iface
);
547 VTY_CHECK_CONTEXT(iface
);
549 ia
= iface_af_get(iface
, af
);
551 ia
->hello_holdtime
= 0;
553 ia
->hello_holdtime
= secs
;
555 ldp_config_apply(vty
, vty_conf
);
558 fatalx("ldp_vty_disc_holdtime: unexpected node");
561 return (CMD_SUCCESS
);
565 ldp_vty_disc_interval(struct vty
*vty
, int disable
, const char *hello_type_str
,
566 const char *seconds_str
)
568 struct ldpd_af_conf
*af_conf
;
574 enum hello_type hello_type
;
576 secs
= strtol(seconds_str
, &ep
, 10);
577 if (*ep
!= '\0' || secs
< MIN_HELLO_INTERVAL
||
578 secs
> MAX_HELLO_INTERVAL
) {
579 vty_out(vty
, "%% Invalid interval%s", VTY_NEWLINE
);
580 return (CMD_WARNING
);
583 if (hello_type_str
[0] == 'h')
584 hello_type
= HELLO_LINK
;
586 hello_type
= HELLO_TARGETED
;
591 switch (hello_type
) {
593 vty_conf
->lhello_interval
= LINK_DFLT_HOLDTIME
;
596 vty_conf
->thello_interval
=
597 TARGETED_DFLT_HOLDTIME
;
601 switch (hello_type
) {
603 vty_conf
->lhello_interval
= secs
;
606 vty_conf
->thello_interval
= secs
;
610 ldp_config_apply(vty
, vty_conf
);
614 af
= ldp_vty_get_af(vty
);
615 af_conf
= ldp_af_conf_get(vty_conf
, af
);
618 switch (hello_type
) {
620 af_conf
->lhello_interval
= 0;
623 af_conf
->thello_interval
= 0;
627 switch (hello_type
) {
629 af_conf
->lhello_interval
= secs
;
632 af_conf
->thello_interval
= secs
;
636 ldp_config_apply(vty
, vty_conf
);
638 case LDP_IPV4_IFACE_NODE
:
639 case LDP_IPV6_IFACE_NODE
:
640 af
= ldp_vty_get_af(vty
);
641 iface
= VTY_GET_CONTEXT(iface
);
642 VTY_CHECK_CONTEXT(iface
);
644 ia
= iface_af_get(iface
, af
);
646 ia
->hello_interval
= 0;
648 ia
->hello_interval
= secs
;
650 ldp_config_apply(vty
, vty_conf
);
653 fatalx("ldp_vty_disc_interval: unexpected node");
656 return (CMD_SUCCESS
);
660 ldp_vty_targeted_hello_accept(struct vty
*vty
, int disable
,
661 const char *acl_from_str
)
663 struct ldpd_af_conf
*af_conf
;
666 af
= ldp_vty_get_af(vty
);
667 af_conf
= ldp_af_conf_get(vty_conf
, af
);
670 af_conf
->flags
&= ~F_LDPD_AF_THELLO_ACCEPT
;
671 af_conf
->acl_thello_accept_from
[0] = '\0';
673 af_conf
->flags
|= F_LDPD_AF_THELLO_ACCEPT
;
675 strlcpy(af_conf
->acl_thello_accept_from
, acl_from_str
,
676 sizeof(af_conf
->acl_thello_accept_from
));
678 af_conf
->acl_thello_accept_from
[0] = '\0';
681 ldp_config_apply(vty
, vty_conf
);
683 return (CMD_SUCCESS
);
687 ldp_vty_nbr_session_holdtime(struct vty
*vty
, int disable
,
688 const char *lsr_id_str
, const char *seconds_str
)
692 struct in_addr lsr_id
;
693 struct nbr_params
*nbrp
;
695 if (inet_pton(AF_INET
, lsr_id_str
, &lsr_id
) != 1 ||
696 bad_addr_v4(lsr_id
)) {
697 vty_out(vty
, "%% Malformed address%s", VTY_NEWLINE
);
698 return (CMD_WARNING
);
701 secs
= strtol(seconds_str
, &ep
, 10);
702 if (*ep
!= '\0' || secs
< MIN_KEEPALIVE
|| secs
> MAX_KEEPALIVE
) {
703 vty_out(vty
, "%% Invalid holdtime%s", VTY_NEWLINE
);
704 return (CMD_SUCCESS
);
707 nbrp
= nbr_params_find(vty_conf
, lsr_id
);
711 return (CMD_SUCCESS
);
714 nbrp
->flags
&= ~F_NBRP_KEEPALIVE
;
717 nbrp
= nbr_params_new(lsr_id
);
718 RB_INSERT(nbrp_head
, &vty_conf
->nbrp_tree
, nbrp
);
719 QOBJ_REG(nbrp
, nbr_params
);
720 } else if (nbrp
->keepalive
== secs
)
721 return (CMD_SUCCESS
);
723 nbrp
->keepalive
= secs
;
724 nbrp
->flags
|= F_NBRP_KEEPALIVE
;
727 ldp_config_apply(vty
, vty_conf
);
729 return (CMD_SUCCESS
);
733 ldp_vty_af_session_holdtime(struct vty
*vty
, int disable
,
734 const char *seconds_str
)
736 struct ldpd_af_conf
*af_conf
;
741 secs
= strtol(seconds_str
, &ep
, 10);
742 if (*ep
!= '\0' || secs
< MIN_KEEPALIVE
|| secs
> MAX_KEEPALIVE
) {
743 vty_out(vty
, "%% Invalid holdtime%s", VTY_NEWLINE
);
744 return (CMD_SUCCESS
);
747 af
= ldp_vty_get_af(vty
);
748 af_conf
= ldp_af_conf_get(vty_conf
, af
);
751 af_conf
->keepalive
= DEFAULT_KEEPALIVE
;
753 af_conf
->keepalive
= secs
;
755 ldp_config_apply(vty
, vty_conf
);
757 return (CMD_SUCCESS
);
761 ldp_vty_interface(struct vty
*vty
, int disable
, const char *ifname
)
767 af
= ldp_vty_get_af(vty
);
768 iface
= if_lookup_name(vty_conf
, ifname
);
772 return (CMD_SUCCESS
);
774 ia
= iface_af_get(iface
, af
);
775 if (ia
->enabled
== 0)
776 return (CMD_SUCCESS
);
779 ia
->hello_holdtime
= 0;
780 ia
->hello_interval
= 0;
782 ldp_config_apply(vty
, vty_conf
);
784 return (CMD_SUCCESS
);
788 if (ldp_iface_is_configured(vty_conf
, ifname
)) {
789 vty_out(vty
, "%% Interface is already in use%s",
791 return (CMD_SUCCESS
);
794 iface
= if_new(ifname
);
795 ia
= iface_af_get(iface
, af
);
797 RB_INSERT(iface_head
, &vty_conf
->iface_tree
, iface
);
798 QOBJ_REG(iface
, iface
);
800 ldp_config_apply(vty
, vty_conf
);
802 ia
= iface_af_get(iface
, af
);
805 ldp_config_apply(vty
, vty_conf
);
811 VTY_PUSH_CONTEXT(LDP_IPV4_IFACE_NODE
, iface
);
814 VTY_PUSH_CONTEXT(LDP_IPV6_IFACE_NODE
, iface
);
820 return (CMD_SUCCESS
);
824 ldp_vty_trans_addr(struct vty
*vty
, int disable
, const char *addr_str
)
826 struct ldpd_af_conf
*af_conf
;
829 af
= ldp_vty_get_af(vty
);
830 af_conf
= ldp_af_conf_get(vty_conf
, af
);
833 memset(&af_conf
->trans_addr
, 0, sizeof(af_conf
->trans_addr
));
835 if (inet_pton(af
, addr_str
, &af_conf
->trans_addr
) != 1 ||
836 bad_addr(af
, &af_conf
->trans_addr
)) {
837 vty_out(vty
, "%% Malformed address%s", VTY_NEWLINE
);
838 return (CMD_SUCCESS
);
842 ldp_config_apply(vty
, vty_conf
);
844 return (CMD_SUCCESS
);
848 ldp_vty_neighbor_targeted(struct vty
*vty
, int disable
, const char *addr_str
)
851 union ldpd_addr addr
;
854 af
= ldp_vty_get_af(vty
);
856 if (inet_pton(af
, addr_str
, &addr
) != 1 ||
857 bad_addr(af
, &addr
)) {
858 vty_out(vty
, "%% Malformed address%s", VTY_NEWLINE
);
859 return (CMD_WARNING
);
861 if (af
== AF_INET6
&& IN6_IS_SCOPE_EMBED(&addr
.v6
)) {
862 vty_out(vty
, "%% Address can not be link-local%s", VTY_NEWLINE
);
863 return (CMD_WARNING
);
866 tnbr
= tnbr_find(vty_conf
, af
, &addr
);
870 return (CMD_SUCCESS
);
873 RB_REMOVE(tnbr_head
, &vty_conf
->tnbr_tree
, tnbr
);
876 ldp_config_apply(vty
, vty_conf
);
878 return (CMD_SUCCESS
);
882 return (CMD_SUCCESS
);
884 tnbr
= tnbr_new(af
, &addr
);
885 tnbr
->flags
|= F_TNBR_CONFIGURED
;
886 RB_INSERT(tnbr_head
, &vty_conf
->tnbr_tree
, tnbr
);
887 QOBJ_REG(tnbr
, tnbr
);
889 ldp_config_apply(vty
, vty_conf
);
891 return (CMD_SUCCESS
);
895 ldp_vty_label_advertise(struct vty
*vty
, int disable
, const char *acl_to_str
,
896 const char *acl_for_str
)
898 struct ldpd_af_conf
*af_conf
;
901 af
= ldp_vty_get_af(vty
);
902 af_conf
= ldp_af_conf_get(vty_conf
, af
);
905 af_conf
->acl_label_advertise_to
[0] = '\0';
906 af_conf
->acl_label_advertise_for
[0] = '\0';
909 strlcpy(af_conf
->acl_label_advertise_to
, acl_to_str
,
910 sizeof(af_conf
->acl_label_advertise_to
));
912 af_conf
->acl_label_advertise_to
[0] = '\0';
914 strlcpy(af_conf
->acl_label_advertise_for
, acl_for_str
,
915 sizeof(af_conf
->acl_label_advertise_for
));
917 af_conf
->acl_label_advertise_for
[0] = '\0';
920 ldp_config_apply(vty
, vty_conf
);
922 return (CMD_SUCCESS
);
926 ldp_vty_label_allocate(struct vty
*vty
, int disable
, int host_routes
,
927 const char *acl_for_str
)
929 struct ldpd_af_conf
*af_conf
;
932 af
= ldp_vty_get_af(vty
);
933 af_conf
= ldp_af_conf_get(vty_conf
, af
);
935 af_conf
->flags
&= ~F_LDPD_AF_ALLOCHOSTONLY
;
936 af_conf
->acl_label_allocate_for
[0] = '\0';
939 af_conf
->flags
|= F_LDPD_AF_ALLOCHOSTONLY
;
941 strlcpy(af_conf
->acl_label_allocate_for
, acl_for_str
,
942 sizeof(af_conf
->acl_label_allocate_for
));
945 ldp_config_apply(vty
, vty_conf
);
947 return (CMD_SUCCESS
);
951 ldp_vty_label_expnull(struct vty
*vty
, int disable
, const char *acl_for_str
)
953 struct ldpd_af_conf
*af_conf
;
956 af
= ldp_vty_get_af(vty
);
957 af_conf
= ldp_af_conf_get(vty_conf
, af
);
960 af_conf
->flags
&= ~F_LDPD_AF_EXPNULL
;
961 af_conf
->acl_label_expnull_for
[0] = '\0';
963 af_conf
->flags
|= F_LDPD_AF_EXPNULL
;
965 strlcpy(af_conf
->acl_label_expnull_for
, acl_for_str
,
966 sizeof(af_conf
->acl_label_expnull_for
));
968 af_conf
->acl_label_expnull_for
[0] = '\0';
971 ldp_config_apply(vty
, vty_conf
);
973 return (CMD_SUCCESS
);
977 ldp_vty_label_accept(struct vty
*vty
, int disable
, const char *acl_from_str
,
978 const char *acl_for_str
)
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
->acl_label_accept_from
[0] = '\0';
988 af_conf
->acl_label_accept_for
[0] = '\0';
991 strlcpy(af_conf
->acl_label_accept_from
, acl_from_str
,
992 sizeof(af_conf
->acl_label_accept_from
));
994 af_conf
->acl_label_accept_from
[0] = '\0';
996 strlcpy(af_conf
->acl_label_accept_for
, acl_for_str
,
997 sizeof(af_conf
->acl_label_accept_for
));
999 af_conf
->acl_label_accept_for
[0] = '\0';
1002 ldp_config_apply(vty
, vty_conf
);
1004 return (CMD_SUCCESS
);
1008 ldp_vty_ttl_security(struct vty
*vty
, int disable
)
1010 struct ldpd_af_conf
*af_conf
;
1013 af
= ldp_vty_get_af(vty
);
1014 af_conf
= ldp_af_conf_get(vty_conf
, af
);
1017 af_conf
->flags
&= ~F_LDPD_AF_NO_GTSM
;
1019 af_conf
->flags
|= F_LDPD_AF_NO_GTSM
;
1021 ldp_config_apply(vty
, vty_conf
);
1023 return (CMD_SUCCESS
);
1027 ldp_vty_router_id(struct vty
*vty
, int disable
, const char *addr_str
)
1030 vty_conf
->rtr_id
.s_addr
= INADDR_ANY
;
1032 if (inet_pton(AF_INET
, addr_str
, &vty_conf
->rtr_id
) != 1 ||
1033 bad_addr_v4(vty_conf
->rtr_id
)) {
1034 vty_out(vty
, "%% Malformed address%s", VTY_NEWLINE
);
1035 return (CMD_SUCCESS
);
1039 ldp_config_apply(vty
, vty_conf
);
1041 return (CMD_SUCCESS
);
1045 ldp_vty_ds_cisco_interop(struct vty
*vty
, int disable
)
1048 vty_conf
->flags
&= ~F_LDPD_DS_CISCO_INTEROP
;
1050 vty_conf
->flags
|= F_LDPD_DS_CISCO_INTEROP
;
1052 ldp_config_apply(vty
, vty_conf
);
1054 return (CMD_SUCCESS
);
1058 ldp_vty_trans_pref_ipv4(struct vty
*vty
, int disable
)
1061 vty_conf
->trans_pref
= DUAL_STACK_LDPOV6
;
1063 vty_conf
->trans_pref
= DUAL_STACK_LDPOV4
;
1065 ldp_config_apply(vty
, vty_conf
);
1067 return (CMD_SUCCESS
);
1071 ldp_vty_neighbor_password(struct vty
*vty
, int disable
, const char *lsr_id_str
,
1072 const char *password_str
)
1074 struct in_addr lsr_id
;
1075 size_t password_len
;
1076 struct nbr_params
*nbrp
;
1078 if (inet_pton(AF_INET
, lsr_id_str
, &lsr_id
) != 1 ||
1079 bad_addr_v4(lsr_id
)) {
1080 vty_out(vty
, "%% Malformed address%s", VTY_NEWLINE
);
1081 return (CMD_WARNING
);
1084 nbrp
= nbr_params_find(vty_conf
, lsr_id
);
1088 return (CMD_SUCCESS
);
1090 memset(&nbrp
->auth
, 0, sizeof(nbrp
->auth
));
1091 nbrp
->auth
.method
= AUTH_NONE
;
1094 nbrp
= nbr_params_new(lsr_id
);
1095 RB_INSERT(nbrp_head
, &vty_conf
->nbrp_tree
, nbrp
);
1096 QOBJ_REG(nbrp
, nbr_params
);
1097 } else if (nbrp
->auth
.method
== AUTH_MD5SIG
&&
1098 strcmp(nbrp
->auth
.md5key
, password_str
) == 0)
1099 return (CMD_SUCCESS
);
1101 password_len
= strlcpy(nbrp
->auth
.md5key
, password_str
,
1102 sizeof(nbrp
->auth
.md5key
));
1103 if (password_len
>= sizeof(nbrp
->auth
.md5key
))
1104 vty_out(vty
, "%% password has been truncated to %zu "
1105 "characters.", sizeof(nbrp
->auth
.md5key
) - 1);
1106 nbrp
->auth
.md5key_len
= password_len
;
1107 nbrp
->auth
.method
= AUTH_MD5SIG
;
1110 ldp_config_apply(vty
, vty_conf
);
1112 return (CMD_SUCCESS
);
1116 ldp_vty_neighbor_ttl_security(struct vty
*vty
, int disable
,
1117 const char *lsr_id_str
, const char *hops_str
)
1119 struct in_addr lsr_id
;
1120 struct nbr_params
*nbrp
;
1124 if (inet_pton(AF_INET
, lsr_id_str
, &lsr_id
) != 1 ||
1125 bad_addr_v4(lsr_id
)) {
1126 vty_out(vty
, "%% Malformed address%s", VTY_NEWLINE
);
1127 return (CMD_WARNING
);
1131 hops
= strtol(hops_str
, &ep
, 10);
1132 if (*ep
!= '\0' || hops
< 1 || hops
> 254) {
1133 vty_out(vty
, "%% Invalid hop count%s", VTY_NEWLINE
);
1134 return (CMD_SUCCESS
);
1138 nbrp
= nbr_params_find(vty_conf
, lsr_id
);
1142 return (CMD_SUCCESS
);
1144 nbrp
->flags
&= ~(F_NBRP_GTSM
|F_NBRP_GTSM_HOPS
);
1145 nbrp
->gtsm_enabled
= 0;
1146 nbrp
->gtsm_hops
= 0;
1149 nbrp
= nbr_params_new(lsr_id
);
1150 RB_INSERT(nbrp_head
, &vty_conf
->nbrp_tree
, nbrp
);
1151 QOBJ_REG(nbrp
, nbr_params
);
1154 nbrp
->flags
|= F_NBRP_GTSM
;
1155 nbrp
->flags
&= ~F_NBRP_GTSM_HOPS
;
1157 nbrp
->gtsm_enabled
= 1;
1158 nbrp
->gtsm_hops
= hops
;
1159 nbrp
->flags
|= F_NBRP_GTSM_HOPS
;
1161 nbrp
->gtsm_enabled
= 0;
1164 ldp_config_apply(vty
, vty_conf
);
1166 return (CMD_SUCCESS
);
1170 ldp_vty_l2vpn(struct vty
*vty
, int disable
, const char *name_str
)
1172 struct l2vpn
*l2vpn
;
1173 struct l2vpn_if
*lif
;
1174 struct l2vpn_pw
*pw
;
1176 l2vpn
= l2vpn_find(vty_conf
, name_str
);
1180 return (CMD_SUCCESS
);
1182 RB_FOREACH(lif
, l2vpn_if_head
, &l2vpn
->if_tree
)
1184 RB_FOREACH(pw
, l2vpn_pw_head
, &l2vpn
->pw_tree
)
1186 RB_FOREACH(pw
, l2vpn_pw_head
, &l2vpn
->pw_inactive_tree
)
1189 RB_REMOVE(l2vpn_head
, &vty_conf
->l2vpn_tree
, l2vpn
);
1192 ldp_config_apply(vty
, vty_conf
);
1194 return (CMD_SUCCESS
);
1198 VTY_PUSH_CONTEXT(LDP_L2VPN_NODE
, l2vpn
);
1199 return (CMD_SUCCESS
);
1202 l2vpn
= l2vpn_new(name_str
);
1203 l2vpn
->type
= L2VPN_TYPE_VPLS
;
1204 RB_INSERT(l2vpn_head
, &vty_conf
->l2vpn_tree
, l2vpn
);
1205 QOBJ_REG(l2vpn
, l2vpn
);
1207 VTY_PUSH_CONTEXT(LDP_L2VPN_NODE
, l2vpn
);
1209 ldp_config_apply(vty
, vty_conf
);
1211 return (CMD_SUCCESS
);
1215 ldp_vty_l2vpn_bridge(struct vty
*vty
, int disable
, const char *ifname
)
1217 VTY_DECLVAR_CONTEXT(l2vpn
, l2vpn
);
1220 memset(l2vpn
->br_ifname
, 0, sizeof(l2vpn
->br_ifname
));
1222 strlcpy(l2vpn
->br_ifname
, ifname
, sizeof(l2vpn
->br_ifname
));
1224 ldp_config_apply(vty
, vty_conf
);
1226 return (CMD_SUCCESS
);
1230 ldp_vty_l2vpn_mtu(struct vty
*vty
, int disable
, const char *mtu_str
)
1232 VTY_DECLVAR_CONTEXT(l2vpn
, l2vpn
);
1236 mtu
= strtol(mtu_str
, &ep
, 10);
1237 if (*ep
!= '\0' || mtu
< MIN_L2VPN_MTU
|| mtu
> MAX_L2VPN_MTU
) {
1238 vty_out(vty
, "%% Invalid MTU%s", VTY_NEWLINE
);
1239 return (CMD_WARNING
);
1243 l2vpn
->mtu
= DEFAULT_L2VPN_MTU
;
1247 ldp_config_apply(vty
, vty_conf
);
1249 return (CMD_SUCCESS
);
1253 ldp_vty_l2vpn_pwtype(struct vty
*vty
, int disable
, const char *type_str
)
1255 VTY_DECLVAR_CONTEXT(l2vpn
, l2vpn
);
1258 if (strcmp(type_str
, "ethernet") == 0)
1259 pw_type
= PW_TYPE_ETHERNET
;
1261 pw_type
= PW_TYPE_ETHERNET_TAGGED
;
1264 l2vpn
->pw_type
= DEFAULT_PW_TYPE
;
1266 l2vpn
->pw_type
= pw_type
;
1268 ldp_config_apply(vty
, vty_conf
);
1270 return (CMD_SUCCESS
);
1274 ldp_vty_l2vpn_interface(struct vty
*vty
, int disable
, const char *ifname
)
1276 VTY_DECLVAR_CONTEXT(l2vpn
, l2vpn
);
1277 struct l2vpn_if
*lif
;
1279 lif
= l2vpn_if_find(l2vpn
, ifname
);
1283 return (CMD_SUCCESS
);
1286 RB_REMOVE(l2vpn_if_head
, &l2vpn
->if_tree
, lif
);
1289 ldp_config_apply(vty
, vty_conf
);
1291 return (CMD_SUCCESS
);
1295 return (CMD_SUCCESS
);
1297 if (ldp_iface_is_configured(vty_conf
, ifname
)) {
1298 vty_out(vty
, "%% Interface is already in use%s", VTY_NEWLINE
);
1299 return (CMD_SUCCESS
);
1302 lif
= l2vpn_if_new(l2vpn
, ifname
);
1303 RB_INSERT(l2vpn_if_head
, &l2vpn
->if_tree
, lif
);
1304 QOBJ_REG(lif
, l2vpn_if
);
1306 ldp_config_apply(vty
, vty_conf
);
1308 return (CMD_SUCCESS
);
1312 ldp_vty_l2vpn_pseudowire(struct vty
*vty
, int disable
, const char *ifname
)
1314 VTY_DECLVAR_CONTEXT(l2vpn
, l2vpn
);
1315 struct l2vpn_pw
*pw
;
1317 pw
= l2vpn_pw_find(l2vpn
, ifname
);
1321 return (CMD_SUCCESS
);
1324 if (pw
->lsr_id
.s_addr
== INADDR_ANY
|| pw
->pwid
== 0)
1325 RB_REMOVE(l2vpn_pw_head
, &l2vpn
->pw_inactive_tree
, pw
);
1327 RB_REMOVE(l2vpn_pw_head
, &l2vpn
->pw_tree
, pw
);
1330 ldp_config_apply(vty
, vty_conf
);
1332 return (CMD_SUCCESS
);
1336 VTY_PUSH_CONTEXT_SUB(LDP_PSEUDOWIRE_NODE
, pw
);
1337 return (CMD_SUCCESS
);
1340 if (ldp_iface_is_configured(vty_conf
, ifname
)) {
1341 vty_out(vty
, "%% Interface is already in use%s", VTY_NEWLINE
);
1342 return (CMD_SUCCESS
);
1345 pw
= l2vpn_pw_new(l2vpn
, ifname
);
1346 pw
->flags
= F_PW_STATUSTLV_CONF
|F_PW_CWORD_CONF
;
1347 RB_INSERT(l2vpn_pw_head
, &l2vpn
->pw_inactive_tree
, pw
);
1348 QOBJ_REG(pw
, l2vpn_pw
);
1350 VTY_PUSH_CONTEXT_SUB(LDP_PSEUDOWIRE_NODE
, pw
);
1352 ldp_config_apply(vty
, vty_conf
);
1354 return (CMD_SUCCESS
);
1358 ldp_vty_l2vpn_pw_cword(struct vty
*vty
, int disable
, const char *preference_str
)
1360 VTY_DECLVAR_CONTEXT_SUB(l2vpn_pw
, pw
);
1363 pw
->flags
|= F_PW_CWORD_CONF
;
1365 if (preference_str
[0] == 'e')
1366 pw
->flags
&= ~F_PW_CWORD_CONF
;
1368 pw
->flags
|= F_PW_CWORD_CONF
;
1371 ldp_config_apply(vty
, vty_conf
);
1373 return (CMD_SUCCESS
);
1377 ldp_vty_l2vpn_pw_nbr_addr(struct vty
*vty
, int disable
, const char *addr_str
)
1379 VTY_DECLVAR_CONTEXT_SUB(l2vpn_pw
, pw
);
1381 union ldpd_addr addr
;
1383 if (ldp_get_address(addr_str
, &af
, &addr
) == -1 ||
1384 bad_addr(af
, &addr
)) {
1385 vty_out(vty
, "%% Malformed address%s", VTY_NEWLINE
);
1386 return (CMD_WARNING
);
1391 memset(&pw
->addr
, 0, sizeof(pw
->addr
));
1392 pw
->flags
&= ~F_PW_STATIC_NBR_ADDR
;
1396 pw
->flags
|= F_PW_STATIC_NBR_ADDR
;
1399 ldp_config_apply(vty
, vty_conf
);
1401 return (CMD_SUCCESS
);
1405 ldp_vty_l2vpn_pw_nbr_id(struct vty
*vty
, int disable
, const char *lsr_id_str
)
1407 VTY_DECLVAR_CONTEXT_SUB(l2vpn_pw
, pw
);
1408 struct in_addr lsr_id
;
1410 if (inet_pton(AF_INET
, lsr_id_str
, &lsr_id
) != 1 ||
1411 bad_addr_v4(lsr_id
)) {
1412 vty_out(vty
, "%% Malformed address%s", VTY_NEWLINE
);
1413 return (CMD_WARNING
);
1417 pw
->lsr_id
.s_addr
= INADDR_ANY
;
1419 pw
->lsr_id
= lsr_id
;
1421 ldp_config_apply(vty
, vty_conf
);
1423 return (CMD_SUCCESS
);
1427 ldp_vty_l2vpn_pw_pwid(struct vty
*vty
, int disable
, const char *pwid_str
)
1429 VTY_DECLVAR_CONTEXT_SUB(l2vpn_pw
, pw
);
1433 pwid
= strtol(pwid_str
, &ep
, 10);
1434 if (*ep
!= '\0' || pwid
< MIN_PWID_ID
|| pwid
> MAX_PWID_ID
) {
1435 vty_out(vty
, "%% Invalid pw-id%s", VTY_NEWLINE
);
1436 return (CMD_WARNING
);
1444 ldp_config_apply(vty
, vty_conf
);
1446 return (CMD_SUCCESS
);
1450 ldp_vty_l2vpn_pw_pwstatus(struct vty
*vty
, int disable
)
1452 VTY_DECLVAR_CONTEXT_SUB(l2vpn_pw
, pw
);
1455 pw
->flags
|= F_PW_STATUSTLV_CONF
;
1457 pw
->flags
&= ~F_PW_STATUSTLV_CONF
;
1459 ldp_config_apply(vty
, vty_conf
);
1461 return (CMD_SUCCESS
);
1465 iface_new_api(struct ldpd_conf
*conf
, const char *name
)
1467 const char *ifname
= name
;
1468 struct iface
*iface
;
1470 if (ldp_iface_is_configured(conf
, ifname
))
1473 iface
= if_new(name
);
1474 RB_INSERT(iface_head
, &conf
->iface_tree
, iface
);
1475 QOBJ_REG(iface
, iface
);
1480 iface_del_api(struct ldpd_conf
*conf
, struct iface
*iface
)
1483 RB_REMOVE(iface_head
, &conf
->iface_tree
, iface
);
1488 tnbr_new_api(struct ldpd_conf
*conf
, int af
, union ldpd_addr
*addr
)
1492 if (af
== AF_INET6
&& IN6_IS_SCOPE_EMBED(&addr
->v6
))
1495 if (tnbr_find(conf
, af
, addr
))
1498 tnbr
= tnbr_new(af
, addr
);
1499 tnbr
->flags
|= F_TNBR_CONFIGURED
;
1500 RB_INSERT(tnbr_head
, &conf
->tnbr_tree
, tnbr
);
1501 QOBJ_REG(tnbr
, tnbr
);
1506 tnbr_del_api(struct ldpd_conf
*conf
, struct tnbr
*tnbr
)
1509 RB_REMOVE(tnbr_head
, &conf
->tnbr_tree
, tnbr
);
1514 nbrp_new_api(struct ldpd_conf
*conf
, struct in_addr lsr_id
)
1516 struct nbr_params
*nbrp
;
1518 if (nbr_params_find(conf
, lsr_id
))
1521 nbrp
= nbr_params_new(lsr_id
);
1522 RB_INSERT(nbrp_head
, &conf
->nbrp_tree
, nbrp
);
1523 QOBJ_REG(nbrp
, nbr_params
);
1528 nbrp_del_api(struct ldpd_conf
*conf
, struct nbr_params
*nbrp
)
1531 RB_REMOVE(nbrp_head
, &conf
->nbrp_tree
, nbrp
);
1536 l2vpn_new_api(struct ldpd_conf
*conf
, const char *name
)
1538 struct l2vpn
*l2vpn
;
1540 if (l2vpn_find(conf
, name
))
1543 l2vpn
= l2vpn_new(name
);
1544 l2vpn
->type
= L2VPN_TYPE_VPLS
;
1545 RB_INSERT(l2vpn_head
, &conf
->l2vpn_tree
, l2vpn
);
1546 QOBJ_REG(l2vpn
, l2vpn
);
1551 l2vpn_del_api(struct ldpd_conf
*conf
, struct l2vpn
*l2vpn
)
1553 struct l2vpn_if
*lif
;
1554 struct l2vpn_pw
*pw
;
1556 while ((lif
= RB_ROOT(l2vpn_if_head
, &l2vpn
->if_tree
)) != NULL
) {
1558 RB_REMOVE(l2vpn_if_head
, &l2vpn
->if_tree
, lif
);
1561 while ((pw
= RB_ROOT(l2vpn_pw_head
, &l2vpn
->pw_tree
)) != NULL
) {
1563 RB_REMOVE(l2vpn_pw_head
, &l2vpn
->pw_tree
, pw
);
1566 while ((pw
= RB_ROOT(l2vpn_pw_head
,
1567 &l2vpn
->pw_inactive_tree
)) != NULL
) {
1569 RB_REMOVE(l2vpn_pw_head
, &l2vpn
->pw_inactive_tree
, pw
);
1573 RB_REMOVE(l2vpn_head
, &conf
->l2vpn_tree
, l2vpn
);
1578 l2vpn_if_new_api(struct ldpd_conf
*conf
, struct l2vpn
*l2vpn
,
1581 struct l2vpn_if
*lif
;
1583 if (ldp_iface_is_configured(conf
, ifname
))
1586 lif
= l2vpn_if_new(l2vpn
, ifname
);
1587 RB_INSERT(l2vpn_if_head
, &l2vpn
->if_tree
, lif
);
1588 QOBJ_REG(lif
, l2vpn_if
);
1593 l2vpn_if_del_api(struct l2vpn
*l2vpn
, struct l2vpn_if
*lif
)
1596 RB_REMOVE(l2vpn_if_head
, &l2vpn
->if_tree
, lif
);
1601 l2vpn_pw_new_api(struct ldpd_conf
*conf
, struct l2vpn
*l2vpn
,
1604 struct l2vpn_pw
*pw
;
1606 if (ldp_iface_is_configured(conf
, ifname
))
1609 pw
= l2vpn_pw_new(l2vpn
, ifname
);
1610 pw
->flags
= F_PW_STATUSTLV_CONF
|F_PW_CWORD_CONF
;
1611 RB_INSERT(l2vpn_pw_head
, &l2vpn
->pw_inactive_tree
, pw
);
1612 QOBJ_REG(pw
, l2vpn_pw
);
1617 l2vpn_pw_del_api(struct l2vpn
*l2vpn
, struct l2vpn_pw
*pw
)
1620 RB_REMOVE(l2vpn_pw_head
, &l2vpn
->pw_inactive_tree
, pw
);