3 * Copyright 2009-2016, LabN Consulting, L.L.C.
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version 2
9 * of the License, or (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
21 #include "lib/zebra.h"
23 #include "lib/command.h"
24 #include "lib/prefix.h"
25 #include "lib/memory.h"
26 #include "lib/linklist.h"
27 #include "lib/table.h"
28 #include "lib/plist.h"
29 #include "lib/routemap.h"
31 #include "bgpd/bgpd.h"
32 #include "bgpd/bgp_attr.h"
33 #include "bgpd/bgp_route.h"
34 #include "bgpd/bgp_mplsvpn.h"
36 #include "bgpd/bgp_ecommunity.h"
37 #include "bgpd/rfapi/rfapi.h"
38 #include "bgpd/rfapi/bgp_rfapi_cfg.h"
39 #include "bgpd/rfapi/rfapi_backend.h"
40 #include "bgpd/rfapi/rfapi_import.h"
41 #include "bgpd/rfapi/rfapi_private.h"
42 #include "bgpd/rfapi/rfapi_monitor.h"
43 #include "bgpd/rfapi/vnc_zebra.h"
44 #include "bgpd/rfapi/vnc_export_bgp.h"
45 #include "bgpd/rfapi/vnc_export_bgp_p.h"
46 #include "bgpd/rfapi/rfapi_vty.h"
47 #include "bgpd/rfapi/vnc_import_bgp.h"
48 #include "bgpd/rfapi/vnc_debug.h"
52 #undef BGP_VNC_DEBUG_MATCH_GROUP
55 DEFINE_MGROUP(RFAPI
, "rfapi")
56 DEFINE_MTYPE(RFAPI
, RFAPI_CFG
, "NVE Configuration")
57 DEFINE_MTYPE(RFAPI
, RFAPI_GROUP_CFG
, "NVE Group Configuration")
58 DEFINE_MTYPE(RFAPI
, RFAPI_L2_CFG
, "RFAPI L2 Group Configuration")
59 DEFINE_MTYPE(RFAPI
, RFAPI_RFP_GROUP_CFG
, "RFAPI RFP Group Configuration")
60 DEFINE_MTYPE(RFAPI
, RFAPI
, "RFAPI Generic")
61 DEFINE_MTYPE(RFAPI
, RFAPI_DESC
, "RFAPI Descriptor")
62 DEFINE_MTYPE(RFAPI
, RFAPI_IMPORTTABLE
, "RFAPI Import Table")
63 DEFINE_MTYPE(RFAPI
, RFAPI_MONITOR
, "RFAPI Monitor VPN")
64 DEFINE_MTYPE(RFAPI
, RFAPI_MONITOR_ENCAP
, "RFAPI Monitor Encap")
65 DEFINE_MTYPE(RFAPI
, RFAPI_NEXTHOP
, "RFAPI Next Hop")
66 DEFINE_MTYPE(RFAPI
, RFAPI_VN_OPTION
, "RFAPI VN Option")
67 DEFINE_MTYPE(RFAPI
, RFAPI_UN_OPTION
, "RFAPI UN Option")
68 DEFINE_MTYPE(RFAPI
, RFAPI_WITHDRAW
, "RFAPI Withdraw")
69 DEFINE_MTYPE(RFAPI
, RFAPI_RFG_NAME
, "RFAPI RFGName")
70 DEFINE_MTYPE(RFAPI
, RFAPI_ADB
, "RFAPI Advertisement Data")
71 DEFINE_MTYPE(RFAPI
, RFAPI_ETI
, "RFAPI Export Table Info")
72 DEFINE_MTYPE(RFAPI
, RFAPI_NVE_ADDR
, "RFAPI NVE Address")
73 DEFINE_MTYPE(RFAPI
, RFAPI_PREFIX_BAG
, "RFAPI Prefix Bag")
74 DEFINE_MTYPE(RFAPI
, RFAPI_IT_EXTRA
, "RFAPI IT Extra")
75 DEFINE_MTYPE(RFAPI
, RFAPI_INFO
, "RFAPI Info")
76 DEFINE_MTYPE(RFAPI
, RFAPI_ADDR
, "RFAPI Addr")
77 DEFINE_MTYPE(RFAPI
, RFAPI_UPDATED_RESPONSE_QUEUE
, "RFAPI Updated Rsp Queue")
78 DEFINE_MTYPE(RFAPI
, RFAPI_RECENT_DELETE
, "RFAPI Recently Deleted Route")
79 DEFINE_MTYPE(RFAPI
, RFAPI_L2ADDR_OPT
, "RFAPI L2 Address Option")
80 DEFINE_MTYPE(RFAPI
, RFAPI_AP
, "RFAPI Advertised Prefix")
81 DEFINE_MTYPE(RFAPI
, RFAPI_MONITOR_ETH
, "RFAPI Monitor Ethernet")
83 DEFINE_QOBJ_TYPE(rfapi_nve_group_cfg
)
84 DEFINE_QOBJ_TYPE(rfapi_l2_group_cfg
)
85 /***********************************************************************
87 ***********************************************************************/
91 * compaitibility to old quagga_time call
92 * time_t value in terms of stabilised absolute time.
93 * replacement for POSIX time()
96 rfapi_time (time_t *t
)
98 time_t clock
= bgp_clock();
105 nve_group_to_nve_list (
106 struct rfapi_nve_group_cfg
*rfg
,
108 uint8_t family
) /* AF_INET, AF_INET6 */
110 struct listnode
*hln
;
111 struct rfapi_descriptor
*rfd
;
114 * loop over nves in this grp, add to list
116 for (ALL_LIST_ELEMENTS_RO (rfg
->nves
, hln
, rfd
))
118 if (rfd
->vn_addr
.addr_family
== family
)
122 listnode_add (*nves
, rfd
);
128 struct rfapi_nve_group_cfg
*
129 bgp_rfapi_cfg_match_group (
130 struct rfapi_cfg
*hc
,
134 struct rfapi_nve_group_cfg
*rfg_vn
= NULL
;
135 struct rfapi_nve_group_cfg
*rfg_un
= NULL
;
137 struct route_table
*rt_vn
;
138 struct route_table
*rt_un
;
139 struct route_node
*rn_vn
;
140 struct route_node
*rn_un
;
142 struct rfapi_nve_group_cfg
*rfg
;
143 struct listnode
*node
, *nnode
;
148 rt_vn
= &(hc
->nve_groups_vn
[AFI_IP
]);
151 rt_vn
= &(hc
->nve_groups_vn
[AFI_IP6
]);
160 rt_un
= &(hc
->nve_groups_un
[AFI_IP
]);
163 rt_un
= &(hc
->nve_groups_un
[AFI_IP6
]);
169 rn_vn
= route_node_match (rt_vn
, vn
); /* NB locks node */
172 rfg_vn
= rn_vn
->info
;
173 route_unlock_node (rn_vn
);
176 rn_un
= route_node_match (rt_un
, un
); /* NB locks node */
179 rfg_un
= rn_un
->info
;
180 route_unlock_node (rn_un
);
183 #if BGP_VNC_DEBUG_MATCH_GROUP
187 prefix2str (vn
, buf
, BUFSIZ
);
188 vnc_zlog_debug_verbose ("%s: vn prefix: %s", __func__
, buf
);
190 prefix2str (un
, buf
, BUFSIZ
);
191 vnc_zlog_debug_verbose ("%s: un prefix: %s", __func__
, buf
);
193 vnc_zlog_debug_verbose ("%s: rn_vn=%p, rn_un=%p, rfg_vn=%p, rfg_un=%p",
194 __func__
, rn_vn
, rn_un
, rfg_vn
, rfg_un
);
199 if (rfg_un
== rfg_vn
) /* same group */
201 if (!rfg_un
) /* un doesn't match, return vn-matched grp */
203 if (!rfg_vn
) /* vn doesn't match, return un-matched grp */
207 * Two different nve groups match: the group configured earlier wins.
208 * For now, just walk the sequential list and pick the first one.
209 * If this approach is too slow, then store serial numbers in the
210 * nve group structures as they are defined and just compare
213 for (ALL_LIST_ELEMENTS (hc
->nve_groups_sequential
, node
, nnode
, rfg
))
215 if ((rfg
== rfg_un
) || (rfg
== rfg_vn
))
220 vnc_zlog_debug_verbose ("%s: shouldn't happen, returning NULL when un and vn match",
222 return NULL
; /* shouldn't happen */
225 /*------------------------------------------
226 * rfapi_get_rfp_start_val
228 * Returns value passed to rfapi on rfp_start
231 * void * bgp structure
235 *------------------------------------------*/
237 rfapi_get_rfp_start_val (void *bgpv
)
239 struct bgp
*bgp
= bgpv
;
240 if (bgp
== NULL
|| bgp
->rfapi
== NULL
)
242 return bgp
->rfapi
->rfp
;
245 /*------------------------------------------
246 * bgp_rfapi_is_vnc_configured
248 * Returns if VNC (BGP VPN messaging /VPN & encap SAFIs) are configured
251 * bgp NULL (=use default instance)
255 * return value: If VNC is configured for the bgpd instance
257 * ENXIO VNC not configured
258 --------------------------------------------*/
260 bgp_rfapi_is_vnc_configured (struct bgp
*bgp
)
263 bgp
= bgp_get_default ();
265 if (bgp
&& bgp
->rfapi_cfg
)
268 struct peer_group
*group
;
269 struct listnode
*node
, *nnode
;
270 /* if have configured VPN neighbors, assume running VNC */
271 for (ALL_LIST_ELEMENTS (bgp
->group
, node
, nnode
, group
))
273 if (group
->conf
->afc
[AFI_IP
][SAFI_MPLS_VPN
] ||
274 group
->conf
->afc
[AFI_IP6
][SAFI_MPLS_VPN
])
277 for (ALL_LIST_ELEMENTS (bgp
->peer
, node
, nnode
, peer
))
279 if (peer
->afc
[AFI_IP
][SAFI_MPLS_VPN
] ||
280 peer
->afc
[AFI_IP6
][SAFI_MPLS_VPN
])
287 /***********************************************************************
288 * VNC Configuration/CLI
289 ***********************************************************************/
292 DEFUN (vnc_advertise_un_method
,
293 vnc_advertise_un_method_cmd
,
294 "vnc advertise-un-method <encap-safi|encap-attr>",
296 "Method of advertising UN addresses\n"
297 "Via Encapsulation SAFI\n"
298 "Via Tunnel Encap attribute (in VPN SAFI)\n")
300 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
304 vty_out (vty
, "VNC not configured%s", VTY_NEWLINE
);
309 if (!strncmp (argv
[2]->arg
, "encap-safi", 7))
311 bgp
->rfapi_cfg
->flags
|= BGP_VNC_CONFIG_ADV_UN_METHOD_ENCAP
;
315 bgp
->rfapi_cfg
->flags
&= ~BGP_VNC_CONFIG_ADV_UN_METHOD_ENCAP
;
321 /*-------------------------------------------------------------------------
323 *-----------------------------------------------------------------------*/
326 DEFUN_NOSH (vnc_defaults
,
328 "vnc defaults", VNC_CONFIG_STR
"Configure default NVE group\n")
330 vty
->node
= BGP_VNC_DEFAULTS_NODE
;
338 struct cmd_token
**argv
,
339 struct ecommunity
**list
)
341 struct ecommunity
*ecom
= NULL
;
342 struct ecommunity
*ecomadd
;
344 for (; argc
; --argc
, ++argv
)
347 ecomadd
= ecommunity_str2com (argv
[0]->arg
, ECOMMUNITY_ROUTE_TARGET
, 0);
350 vty_out (vty
, "Malformed community-list value%s", VTY_NEWLINE
);
352 ecommunity_free (&ecom
);
358 ecommunity_merge (ecom
, ecomadd
);
359 ecommunity_free (&ecomadd
);
369 ecommunity_free (&*list
);
376 DEFUN (vnc_defaults_rt_import
,
377 vnc_defaults_rt_import_cmd
,
378 "rt import RTLIST...",
379 "Specify default route targets\n"
381 "Space separated route target list (A.B.C.D:MN|EF:OPQR|GHJK:MN)\n")
383 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
384 return set_ecom_list (vty
, argc
- 2, argv
+ 2,
385 &bgp
->rfapi_cfg
->default_rt_import_list
);
388 DEFUN (vnc_defaults_rt_export
,
389 vnc_defaults_rt_export_cmd
,
390 "rt export RTLIST...",
391 "Configure default route targets\n"
393 "Space separated route target list (A.B.C.D:MN|EF:OPQR|GHJK:MN)\n")
395 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
396 return set_ecom_list (vty
, argc
- 2, argv
+ 2,
397 &bgp
->rfapi_cfg
->default_rt_export_list
);
400 DEFUN (vnc_defaults_rt_both
,
401 vnc_defaults_rt_both_cmd
,
403 "Configure default route targets\n"
404 "Export+import filters\n"
405 "Space separated route target list (A.B.C.D:MN|EF:OPQR|GHJK:MN)\n")
407 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
410 rc
= set_ecom_list (vty
, argc
- 2, argv
+ 2,
411 &bgp
->rfapi_cfg
->default_rt_import_list
);
412 if (rc
!= CMD_SUCCESS
)
414 return set_ecom_list (vty
, argc
- 2, argv
+ 2,
415 &bgp
->rfapi_cfg
->default_rt_export_list
);
418 DEFUN (vnc_defaults_rd
,
420 "rd ASN:nn_or_IP-address:nn",
421 "Specify default route distinguisher\n"
422 "Route Distinguisher (<as-number>:<number> | <ip-address>:<number> | auto:vn:<number> )\n")
424 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
426 struct prefix_rd prd
;
428 if (!strncmp (argv
[1]->arg
, "auto:vn:", 8))
431 * use AF_UNIX to designate automatically-assigned RD
432 * auto:vn:nn where nn is a 2-octet quantity
435 uint32_t value32
= strtoul (argv
[1]->arg
+ 8, &end
, 10);
436 uint16_t value
= value32
& 0xffff;
438 if (!argv
[1]->arg
[8] || *end
)
440 vty_out (vty
, "%% Malformed rd%s", VTY_NEWLINE
);
443 if (value32
> 0xffff)
445 vty_out (vty
, "%% Malformed rd (must be less than %u%s",
446 0x0ffff, VTY_NEWLINE
);
450 memset (&prd
, 0, sizeof (prd
));
451 prd
.family
= AF_UNIX
;
453 prd
.val
[0] = (RD_TYPE_IP
>> 8) & 0x0ff;
454 prd
.val
[1] = RD_TYPE_IP
& 0x0ff;
455 prd
.val
[6] = (value
>> 8) & 0x0ff;
456 prd
.val
[7] = value
& 0x0ff;
462 ret
= str2prefix_rd (argv
[1]->arg
, &prd
);
465 vty_out (vty
, "%% Malformed rd%s", VTY_NEWLINE
);
470 bgp
->rfapi_cfg
->default_rd
= prd
;
474 DEFUN (vnc_defaults_l2rd
,
475 vnc_defaults_l2rd_cmd
,
476 "l2rd <(1-255)|auto-vn>",
477 "Specify default Local Nve ID value to use in RD for L2 routes\n"
478 "Fixed value 1-255\n"
479 "use the low-order octet of the NVE's VN address\n")
481 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
484 if (!strcmp (argv
[1]->arg
, "auto-vn"))
491 unsigned long value_l
= strtoul (argv
[1]->arg
, &end
, 10);
493 value
= value_l
& 0xff;
494 if (!argv
[1]->arg
[0] || *end
)
496 vty_out (vty
, "%% Malformed l2 nve ID \"%s\"%s", argv
[1]->arg
,
500 if ((value_l
< 1) || (value_l
> 0xff))
503 "%% Malformed l2 nve id (must be greater than 0 and less than %u%s",
508 bgp
->rfapi_cfg
->flags
|= BGP_VNC_CONFIG_L2RD
;
509 bgp
->rfapi_cfg
->default_l2rd
= value
;
514 DEFUN (vnc_defaults_no_l2rd
,
515 vnc_defaults_no_l2rd_cmd
,
518 "Specify default Local Nve ID value to use in RD for L2 routes\n")
520 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
522 bgp
->rfapi_cfg
->default_l2rd
= 0;
523 bgp
->rfapi_cfg
->flags
&= ~BGP_VNC_CONFIG_L2RD
;
528 DEFUN (vnc_defaults_responselifetime
,
529 vnc_defaults_responselifetime_cmd
,
530 "response-lifetime <LIFETIME|infinite>",
531 "Specify default response lifetime\n"
532 "Response lifetime in seconds\n" "Infinite response lifetime\n")
534 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
536 struct rfapi
*h
= NULL
;
537 struct listnode
*hdnode
;
538 struct rfapi_descriptor
*rfd
;
544 if (!strcmp (argv
[1]->arg
, "infinite"))
546 rspint
= RFAPI_INFINITE_LIFETIME
;
550 VTY_GET_INTEGER ("Response Lifetime", rspint
, argv
[1]->arg
);
551 if (rspint
> INT32_MAX
)
552 rspint
= INT32_MAX
; /* is really an int, not an unsigned int */
555 bgp
->rfapi_cfg
->default_response_lifetime
= rspint
;
557 for (ALL_LIST_ELEMENTS_RO (&h
->descriptors
, hdnode
, rfd
))
558 if (rfd
->rfg
&& !(rfd
->rfg
->flags
& RFAPI_RFG_RESPONSE_LIFETIME
))
559 rfd
->response_lifetime
= rfd
->rfg
->response_lifetime
= rspint
;
564 struct rfapi_nve_group_cfg
*
565 bgp_rfapi_cfg_match_byname (struct bgp
*bgp
, const char *name
,
566 rfapi_group_cfg_type_t type
) /* _MAX = any */
568 struct rfapi_nve_group_cfg
*rfg
;
569 struct listnode
*node
, *nnode
;
571 for (ALL_LIST_ELEMENTS
572 (bgp
->rfapi_cfg
->nve_groups_sequential
, node
, nnode
, rfg
))
574 if ((type
== RFAPI_GROUP_CFG_MAX
|| type
== rfg
->type
) &&
575 !strcmp (rfg
->name
, name
))
581 static struct rfapi_nve_group_cfg
*
582 rfapi_group_new (struct bgp
*bgp
,
583 rfapi_group_cfg_type_t type
,
586 struct rfapi_nve_group_cfg
*rfg
;
588 rfg
= XCALLOC (MTYPE_RFAPI_GROUP_CFG
, sizeof (struct rfapi_nve_group_cfg
));
592 rfg
->name
= strdup (name
);
593 /* add to tail of list */
594 listnode_add (bgp
->rfapi_cfg
->nve_groups_sequential
, rfg
);
596 rfg
->label
= MPLS_LABEL_ILLEGAL
;
597 QOBJ_REG (rfg
, rfapi_nve_group_cfg
);
602 static struct rfapi_l2_group_cfg
*
603 rfapi_l2_group_lookup_byname (struct bgp
*bgp
, const char *name
)
605 struct rfapi_l2_group_cfg
*rfg
;
606 struct listnode
*node
, *nnode
;
608 if (bgp
->rfapi_cfg
->l2_groups
== NULL
) /* not the best place for this */
609 bgp
->rfapi_cfg
->l2_groups
= list_new ();
611 for (ALL_LIST_ELEMENTS (bgp
->rfapi_cfg
->l2_groups
, node
, nnode
, rfg
))
613 if (!strcmp (rfg
->name
, name
))
619 static struct rfapi_l2_group_cfg
*
620 rfapi_l2_group_new ()
622 struct rfapi_l2_group_cfg
*rfg
;
624 rfg
= XCALLOC (MTYPE_RFAPI_L2_CFG
, sizeof (struct rfapi_l2_group_cfg
));
625 QOBJ_REG (rfg
, rfapi_l2_group_cfg
);
631 rfapi_l2_group_del (struct rfapi_l2_group_cfg
*rfg
)
634 XFREE (MTYPE_RFAPI_L2_CFG
, rfg
);
638 rfapi_str2route_type (
647 if (!strcmp (l3str
, "ipv4"))
653 if (!strcmp (l3str
, "ipv6"))
659 if (!strcmp (pstr
, "connected"))
660 *type
= ZEBRA_ROUTE_CONNECT
;
661 if (!strcmp (pstr
, "kernel"))
662 *type
= ZEBRA_ROUTE_KERNEL
;
663 if (!strcmp (pstr
, "static"))
664 *type
= ZEBRA_ROUTE_STATIC
;
665 if (!strcmp (pstr
, "bgp"))
666 *type
= ZEBRA_ROUTE_BGP
;
667 if (!strcmp (pstr
, "bgp-direct"))
668 *type
= ZEBRA_ROUTE_BGP_DIRECT
;
669 if (!strcmp (pstr
, "bgp-direct-to-nve-groups"))
670 *type
= ZEBRA_ROUTE_BGP_DIRECT_EXT
;
672 if (!strcmp (pstr
, "rip"))
675 *type
= ZEBRA_ROUTE_RIP
;
677 *type
= ZEBRA_ROUTE_RIPNG
;
680 if (!strcmp (pstr
, "ripng"))
684 *type
= ZEBRA_ROUTE_RIPNG
;
687 if (!strcmp (pstr
, "ospf"))
690 *type
= ZEBRA_ROUTE_OSPF
;
692 *type
= ZEBRA_ROUTE_OSPF6
;
695 if (!strcmp (pstr
, "ospf6"))
699 *type
= ZEBRA_ROUTE_OSPF6
;
705 /*-------------------------------------------------------------------------
707 *-----------------------------------------------------------------------*/
709 #define VNC_REDIST_ENABLE(bgp, afi, type) do { \
711 case ZEBRA_ROUTE_BGP_DIRECT: \
712 vnc_import_bgp_redist_enable((bgp), (afi)); \
714 case ZEBRA_ROUTE_BGP_DIRECT_EXT: \
715 vnc_import_bgp_exterior_redist_enable((bgp), (afi));\
718 vnc_redistribute_set((bgp), (afi), (type)); \
723 #define VNC_REDIST_DISABLE(bgp, afi, type) do { \
725 case ZEBRA_ROUTE_BGP_DIRECT: \
726 vnc_import_bgp_redist_disable((bgp), (afi)); \
728 case ZEBRA_ROUTE_BGP_DIRECT_EXT: \
729 vnc_import_bgp_exterior_redist_disable((bgp), (afi));\
732 vnc_redistribute_unset((bgp), (afi), (type)); \
737 static uint8_t redist_was_enabled
[AFI_MAX
][ZEBRA_ROUTE_MAX
];
740 vnc_redistribute_prechange (struct bgp
*bgp
)
745 vnc_zlog_debug_verbose ("%s: entry", __func__
);
746 memset (redist_was_enabled
, 0, sizeof (redist_was_enabled
));
749 * Look to see if we have any redistribution enabled. If so, flush
750 * the corresponding routes and turn off redistribution temporarily.
751 * We need to do it because the RD's used for the redistributed
752 * routes depend on the nve group.
754 for (afi
= AFI_IP
; afi
< AFI_MAX
; ++afi
)
756 for (type
= 0; type
< ZEBRA_ROUTE_MAX
; ++type
)
758 if (bgp
->rfapi_cfg
->redist
[afi
][type
])
760 redist_was_enabled
[afi
][type
] = 1;
761 VNC_REDIST_DISABLE (bgp
, afi
, type
);
765 vnc_zlog_debug_verbose ("%s: return", __func__
);
769 vnc_redistribute_postchange (struct bgp
*bgp
)
774 vnc_zlog_debug_verbose ("%s: entry", __func__
);
776 * If we turned off redistribution above, turn it back on. Doing so
777 * will tell zebra to resend the routes to us
779 for (afi
= AFI_IP
; afi
< AFI_MAX
; ++afi
)
781 for (type
= 0; type
< ZEBRA_ROUTE_MAX
; ++type
)
783 if (redist_was_enabled
[afi
][type
])
785 VNC_REDIST_ENABLE (bgp
, afi
, type
);
789 vnc_zlog_debug_verbose ("%s: return", __func__
);
792 DEFUN (vnc_redistribute_rh_roo_localadmin
,
793 vnc_redistribute_rh_roo_localadmin_cmd
,
794 "vnc redistribute resolve-nve roo-ec-local-admin (0-65535)",
796 "Redistribute routes into VNC\n"
798 "Route Origin Extended Community Local Admin Field\n" "Field value\n")
800 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
806 vty_out (vty
, "RFAPI not configured%s", VTY_NEWLINE
);
810 localadmin
= strtoul (argv
[4]->arg
, &endptr
, 0);
811 if (!argv
[4]->arg
[0] || *endptr
)
813 vty_out (vty
, "%% Malformed value%s", VTY_NEWLINE
);
817 if (localadmin
> 0xffff)
819 vty_out (vty
, "%% Value out of range (0-%d)%s", 0xffff, VTY_NEWLINE
);
823 if (bgp
->rfapi_cfg
->resolve_nve_roo_local_admin
== localadmin
)
826 if ((bgp
->rfapi_cfg
->flags
& BGP_VNC_CONFIG_EXPORT_BGP_MODE_BITS
) ==
827 BGP_VNC_CONFIG_EXPORT_BGP_MODE_CE
)
830 vnc_export_bgp_prechange (bgp
);
832 vnc_redistribute_prechange (bgp
);
834 bgp
->rfapi_cfg
->resolve_nve_roo_local_admin
= localadmin
;
836 if ((bgp
->rfapi_cfg
->flags
& BGP_VNC_CONFIG_EXPORT_BGP_MODE_BITS
) ==
837 BGP_VNC_CONFIG_EXPORT_BGP_MODE_CE
)
840 vnc_export_bgp_postchange (bgp
);
842 vnc_redistribute_postchange (bgp
);
848 DEFUN (vnc_redistribute_mode
,
849 vnc_redistribute_mode_cmd
,
850 "vnc redistribute mode <nve-group|plain|resolve-nve>",
852 "Redistribute routes into VNC\n"
853 "Redistribution mode\n"
854 "Based on redistribute nve-group\n"
855 "Unmodified\n" "Resolve each nexthop to connected NVEs\n")
857 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
858 vnc_redist_mode_t newmode
;
862 vty_out (vty
, "RFAPI not configured%s", VTY_NEWLINE
);
867 switch (argv
[3]->arg
[0])
870 newmode
= VNC_REDIST_MODE_RFG
;
874 newmode
= VNC_REDIST_MODE_PLAIN
;
878 newmode
= VNC_REDIST_MODE_RESOLVE_NVE
;
882 vty_out (vty
, "unknown redistribute mode%s", VTY_NEWLINE
);
886 if (newmode
!= bgp
->rfapi_cfg
->redist_mode
)
888 vnc_redistribute_prechange (bgp
);
889 bgp
->rfapi_cfg
->redist_mode
= newmode
;
890 vnc_redistribute_postchange (bgp
);
896 DEFUN (vnc_redistribute_protocol
,
897 vnc_redistribute_protocol_cmd
,
898 "vnc redistribute <ipv4|ipv6> <bgp|bgp-direct|bgp-direct-to-nve-groups|connected|kernel|ospf|rip|static>",
900 "Redistribute routes into VNC\n"
904 "From BGP without Zebra\n"
905 "From BGP without Zebra, only to configured NVE groups\n"
906 "Connected interfaces\n"
907 "From kernel routes\n"
908 "From Open Shortest Path First (OSPF)\n"
909 "From Routing Information Protocol (RIP)\n" "From Static routes\n")
911 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
912 int type
= ZEBRA_ROUTE_MAX
; /* init to bogus value */
917 vty_out (vty
, "RFAPI not configured%s", VTY_NEWLINE
);
921 if (rfapi_str2route_type (argv
[2]->arg
, argv
[3]->arg
, &afi
, &type
))
923 vty_out (vty
, "%% Invalid route type%s", VTY_NEWLINE
);
927 if (type
== ZEBRA_ROUTE_BGP_DIRECT_EXT
)
929 if (bgp
->rfapi_cfg
->redist_bgp_exterior_view_name
)
931 VNC_REDIST_DISABLE (bgp
, afi
, type
); /* disabled view implicitly */
932 free (bgp
->rfapi_cfg
->redist_bgp_exterior_view_name
);
933 bgp
->rfapi_cfg
->redist_bgp_exterior_view_name
= NULL
;
935 bgp
->rfapi_cfg
->redist_bgp_exterior_view
= bgp
;
938 VNC_REDIST_ENABLE (bgp
, afi
, type
);
943 DEFUN (vnc_no_redistribute_protocol
,
944 vnc_no_redistribute_protocol_cmd
,
945 "no vnc redistribute <ipv4|ipv6> <bgp|bgp-direct|bgp-direct-to-nve-groups|connected|kernel|ospf|rip|static>",
948 "Redistribute from other protocol\n"
952 "From BGP without Zebra\n"
953 "From BGP without Zebra, only to configured NVE groups\n"
954 "Connected interfaces\n"
955 "From kernel routes\n"
956 "From Open Shortest Path First (OSPF)\n"
957 "From Routing Information Protocol (RIP)\n" "From Static routes\n")
959 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
965 vty_out (vty
, "RFAPI not configured%s", VTY_NEWLINE
);
969 if (rfapi_str2route_type (argv
[3]->arg
, argv
[4]->arg
, &afi
, &type
))
971 vty_out (vty
, "%% Invalid route type%s", VTY_NEWLINE
);
975 VNC_REDIST_DISABLE (bgp
, afi
, type
);
977 if (type
== ZEBRA_ROUTE_BGP_DIRECT_EXT
)
979 if (bgp
->rfapi_cfg
->redist_bgp_exterior_view_name
)
981 free (bgp
->rfapi_cfg
->redist_bgp_exterior_view_name
);
982 bgp
->rfapi_cfg
->redist_bgp_exterior_view_name
= NULL
;
984 bgp
->rfapi_cfg
->redist_bgp_exterior_view
= NULL
;
990 DEFUN (vnc_redistribute_bgp_exterior
,
991 vnc_redistribute_bgp_exterior_cmd
,
992 "vnc redistribute <ipv4|ipv6> bgp-direct-to-nve-groups view NAME",
994 "Redistribute routes into VNC\n"
997 "From BGP without Zebra, only to configured NVE groups\n"
998 "From BGP view\n" "BGP view name\n")
1000 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1004 if (!bgp
->rfapi_cfg
)
1006 vty_out (vty
, "RFAPI not configured%s", VTY_NEWLINE
);
1010 if (rfapi_str2route_type (argv
[2]->arg
, "bgp-direct-to-nve-groups", &afi
, &type
))
1012 vty_out (vty
, "%% Invalid route type%s", VTY_NEWLINE
);
1016 if (bgp
->rfapi_cfg
->redist_bgp_exterior_view_name
)
1017 free (bgp
->rfapi_cfg
->redist_bgp_exterior_view_name
);
1018 bgp
->rfapi_cfg
->redist_bgp_exterior_view_name
= strdup (argv
[5]->arg
);
1019 /* could be NULL if name is not defined yet */
1020 bgp
->rfapi_cfg
->redist_bgp_exterior_view
= bgp_lookup_by_name (argv
[5]->arg
);
1022 VNC_REDIST_ENABLE (bgp
, afi
, type
);
1027 DEFUN (vnc_redistribute_nvegroup
,
1028 vnc_redistribute_nvegroup_cmd
,
1029 "vnc redistribute nve-group NAME",
1031 "Assign a NVE group to routes redistributed from another routing protocol\n"
1032 "NVE group\n" "Group name\n")
1034 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1036 if (!bgp
->rfapi_cfg
)
1038 vty_out (vty
, "rfapi not configured%s", VTY_NEWLINE
);
1042 vnc_redistribute_prechange (bgp
);
1045 * OK if nve group doesn't exist yet; we'll set the pointer
1046 * when the group is defined later
1048 bgp
->rfapi_cfg
->rfg_redist
= bgp_rfapi_cfg_match_byname (bgp
, argv
[3]->arg
,
1049 RFAPI_GROUP_CFG_NVE
);
1050 if (bgp
->rfapi_cfg
->rfg_redist_name
)
1051 free (bgp
->rfapi_cfg
->rfg_redist_name
);
1052 bgp
->rfapi_cfg
->rfg_redist_name
= strdup (argv
[3]->arg
);
1054 vnc_redistribute_postchange (bgp
);
1059 DEFUN (vnc_redistribute_no_nvegroup
,
1060 vnc_redistribute_no_nvegroup_cmd
,
1061 "no vnc redistribute nve-group",
1064 "Redistribute from other protocol\n"
1065 "Assign a NVE group to routes redistributed from another routing protocol\n")
1067 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1069 if (!bgp
->rfapi_cfg
)
1071 vty_out (vty
, "rfapi not configured%s", VTY_NEWLINE
);
1075 vnc_redistribute_prechange (bgp
);
1077 bgp
->rfapi_cfg
->rfg_redist
= NULL
;
1078 if (bgp
->rfapi_cfg
->rfg_redist_name
)
1079 free (bgp
->rfapi_cfg
->rfg_redist_name
);
1080 bgp
->rfapi_cfg
->rfg_redist_name
= NULL
;
1082 vnc_redistribute_postchange (bgp
);
1088 DEFUN (vnc_redistribute_lifetime
,
1089 vnc_redistribute_lifetime_cmd
,
1090 "vnc redistribute lifetime <LIFETIME|infinite>",
1093 "Assign a lifetime to routes redistributed from another routing protocol\n"
1094 "lifetime value (32 bit)\n"
1095 "Allow lifetime to never expire\n")
1097 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1099 if (!bgp
->rfapi_cfg
)
1101 vty_out (vty
, "rfapi not configured%s", VTY_NEWLINE
);
1105 vnc_redistribute_prechange (bgp
);
1107 if (!strcmp (argv
[3]->arg
, "infinite"))
1109 bgp
->rfapi_cfg
->redist_lifetime
= RFAPI_INFINITE_LIFETIME
;
1113 VTY_GET_INTEGER ("Response Lifetime", bgp
->rfapi_cfg
->redist_lifetime
,
1117 vnc_redistribute_postchange (bgp
);
1122 /*-- redist policy, non-nvegroup start --*/
1124 DEFUN (vnc_redist_bgpdirect_no_prefixlist
,
1125 vnc_redist_bgpdirect_no_prefixlist_cmd
,
1126 "no vnc redistribute <bgp-direct|bgp-direct-to-nve-groups> <ipv4|ipv6> prefix-list",
1129 "Redistribute from other protocol\n"
1130 "Redistribute from BGP directly\n"
1131 "Redistribute from BGP without Zebra, only to configured NVE groups\n"
1133 "IPv6 routes\n" "Prefix-list for filtering redistributed routes\n")
1135 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1137 struct rfapi_cfg
*hc
;
1138 uint8_t route_type
= 0;
1140 if (!(hc
= bgp
->rfapi_cfg
))
1142 vty_out (vty
, "rfapi not configured%s", VTY_NEWLINE
);
1146 if (!strcmp (argv
[3]->arg
, "bgp-direct"))
1148 route_type
= ZEBRA_ROUTE_BGP_DIRECT
;
1152 route_type
= ZEBRA_ROUTE_BGP_DIRECT_EXT
;
1155 if (!strcmp (argv
[4]->arg
, "ipv4"))
1164 vnc_redistribute_prechange (bgp
);
1166 if (hc
->plist_redist_name
[route_type
][afi
])
1167 free (hc
->plist_redist_name
[route_type
][afi
]);
1168 hc
->plist_redist_name
[route_type
][afi
] = NULL
;
1169 hc
->plist_redist
[route_type
][afi
] = NULL
;
1171 vnc_redistribute_postchange (bgp
);
1176 DEFUN (vnc_redist_bgpdirect_prefixlist
,
1177 vnc_redist_bgpdirect_prefixlist_cmd
,
1178 "vnc redistribute <bgp-direct|bgp-direct-to-nve-groups> <ipv4|ipv6> prefix-list NAME",
1180 "Redistribute from other protocol\n"
1181 "Redistribute from BGP directly\n"
1182 "Redistribute from BGP without Zebra, only to configured NVE groups\n"
1185 "Prefix-list for filtering redistributed routes\n"
1186 "prefix list name\n")
1188 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1189 struct rfapi_cfg
*hc
;
1191 uint8_t route_type
= 0;
1193 if (!(hc
= bgp
->rfapi_cfg
))
1195 vty_out (vty
, "rfapi not configured%s", VTY_NEWLINE
);
1199 if (!strcmp (argv
[2]->arg
, "bgp-direct"))
1201 route_type
= ZEBRA_ROUTE_BGP_DIRECT
;
1205 route_type
= ZEBRA_ROUTE_BGP_DIRECT_EXT
;
1208 if (!strcmp (argv
[3]->arg
, "ipv4"))
1217 vnc_redistribute_prechange (bgp
);
1219 if (hc
->plist_redist_name
[route_type
][afi
])
1220 free (hc
->plist_redist_name
[route_type
][afi
]);
1221 hc
->plist_redist_name
[route_type
][afi
] = strdup (argv
[5]->arg
);
1222 hc
->plist_redist
[route_type
][afi
] = prefix_list_lookup (afi
, argv
[5]->arg
);
1224 vnc_redistribute_postchange (bgp
);
1229 DEFUN (vnc_redist_bgpdirect_no_routemap
,
1230 vnc_redist_bgpdirect_no_routemap_cmd
,
1231 "no vnc redistribute <bgp-direct|bgp-direct-to-nve-groups> route-map",
1234 "Redistribute from other protocols\n"
1235 "Redistribute from BGP directly\n"
1236 "Redistribute from BGP without Zebra, only to configured NVE groups\n"
1237 "Route-map for filtering redistributed routes\n")
1239 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1240 struct rfapi_cfg
*hc
;
1241 uint8_t route_type
= 0;
1243 if (!(hc
= bgp
->rfapi_cfg
))
1245 vty_out (vty
, "rfapi not configured%s", VTY_NEWLINE
);
1249 if (!strcmp (argv
[3]->arg
, "bgp-direct"))
1251 route_type
= ZEBRA_ROUTE_BGP_DIRECT
;
1255 route_type
= ZEBRA_ROUTE_BGP_DIRECT_EXT
;
1258 vnc_redistribute_prechange (bgp
);
1260 if (hc
->routemap_redist_name
[route_type
])
1261 free (hc
->routemap_redist_name
[route_type
]);
1262 hc
->routemap_redist_name
[route_type
] = NULL
;
1263 hc
->routemap_redist
[route_type
] = NULL
;
1265 vnc_redistribute_postchange (bgp
);
1270 DEFUN (vnc_redist_bgpdirect_routemap
,
1271 vnc_redist_bgpdirect_routemap_cmd
,
1272 "vnc redistribute <bgp-direct|bgp-direct-to-nve-groups> route-map NAME",
1274 "Redistribute from other protocols\n"
1275 "Redistribute from BGP directly\n"
1276 "Redistribute from BGP without Zebra, only to configured NVE groups\n"
1277 "Route-map for filtering exported routes\n" "route map name\n")
1279 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1280 struct rfapi_cfg
*hc
;
1281 uint8_t route_type
= 0;
1283 if (!(hc
= bgp
->rfapi_cfg
))
1285 vty_out (vty
, "rfapi not configured%s", VTY_NEWLINE
);
1289 if (!strcmp (argv
[2]->arg
, "bgp-direct"))
1291 route_type
= ZEBRA_ROUTE_BGP_DIRECT
;
1295 route_type
= ZEBRA_ROUTE_BGP_DIRECT_EXT
;
1298 vnc_redistribute_prechange (bgp
);
1300 if (hc
->routemap_redist_name
[route_type
])
1301 free (hc
->routemap_redist_name
[route_type
]);
1302 hc
->routemap_redist_name
[route_type
] = strdup (argv
[4]->arg
);
1303 hc
->routemap_redist
[route_type
] = route_map_lookup_by_name (argv
[4]->arg
);
1305 vnc_redistribute_postchange (bgp
);
1310 /*-- redist policy, non-nvegroup end --*/
1312 /*-- redist policy, nvegroup start --*/
1314 DEFUN (vnc_nve_group_redist_bgpdirect_no_prefixlist
,
1315 vnc_nve_group_redist_bgpdirect_no_prefixlist_cmd
,
1316 "no redistribute bgp-direct <ipv4|ipv6> prefix-list",
1318 "Redistribute from other protocol\n"
1319 "Redistribute from BGP directly\n"
1320 "Disable redistribute filter\n"
1322 "IPv6 routes\n" "Prefix-list for filtering redistributed routes\n")
1324 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1325 VTY_DECLVAR_CONTEXT_SUB(rfapi_nve_group_cfg
, rfg
)
1328 if (!bgp
->rfapi_cfg
)
1330 vty_out (vty
, "rfapi not configured%s", VTY_NEWLINE
);
1334 /* make sure it's still in list */
1335 if (!listnode_lookup (bgp
->rfapi_cfg
->nve_groups_sequential
, rfg
))
1337 /* Not in list anymore */
1338 vty_out (vty
, "Current NVE group no longer exists%s", VTY_NEWLINE
);
1342 if (!strcmp (argv
[3]->arg
, "ipv4"))
1351 vnc_redistribute_prechange (bgp
);
1353 if (rfg
->plist_redist_name
[ZEBRA_ROUTE_BGP_DIRECT
][afi
])
1354 free (rfg
->plist_redist_name
[ZEBRA_ROUTE_BGP_DIRECT
][afi
]);
1355 rfg
->plist_redist_name
[ZEBRA_ROUTE_BGP_DIRECT
][afi
] = NULL
;
1356 rfg
->plist_redist
[ZEBRA_ROUTE_BGP_DIRECT
][afi
] = NULL
;
1358 vnc_redistribute_postchange (bgp
);
1363 DEFUN (vnc_nve_group_redist_bgpdirect_prefixlist
,
1364 vnc_nve_group_redist_bgpdirect_prefixlist_cmd
,
1365 "redistribute bgp-direct <ipv4|ipv6> prefix-list NAME",
1366 "Redistribute from other protocol\n"
1367 "Redistribute from BGP directly\n"
1370 "Prefix-list for filtering redistributed routes\n"
1371 "prefix list name\n")
1373 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1374 VTY_DECLVAR_CONTEXT_SUB(rfapi_nve_group_cfg
, rfg
);
1377 if (!bgp
->rfapi_cfg
)
1379 vty_out (vty
, "rfapi not configured%s", VTY_NEWLINE
);
1383 /* make sure it's still in list */
1384 if (!listnode_lookup (bgp
->rfapi_cfg
->nve_groups_sequential
, rfg
))
1386 /* Not in list anymore */
1387 vty_out (vty
, "Current NVE group no longer exists%s", VTY_NEWLINE
);
1391 if (!strcmp (argv
[2]->arg
, "ipv4"))
1400 vnc_redistribute_prechange (bgp
);
1402 if (rfg
->plist_redist_name
[ZEBRA_ROUTE_BGP_DIRECT
][afi
])
1403 free (rfg
->plist_redist_name
[ZEBRA_ROUTE_BGP_DIRECT
][afi
]);
1404 rfg
->plist_redist_name
[ZEBRA_ROUTE_BGP_DIRECT
][afi
] = strdup (argv
[4]->arg
);
1405 rfg
->plist_redist
[ZEBRA_ROUTE_BGP_DIRECT
][afi
] =
1406 prefix_list_lookup (afi
, argv
[4]->arg
);
1408 vnc_redistribute_postchange (bgp
);
1413 DEFUN (vnc_nve_group_redist_bgpdirect_no_routemap
,
1414 vnc_nve_group_redist_bgpdirect_no_routemap_cmd
,
1415 "no redistribute bgp-direct route-map",
1417 "Redistribute from other protocols\n"
1418 "Redistribute from BGP directly\n"
1419 "Disable redistribute filter\n"
1420 "Route-map for filtering redistributed routes\n")
1422 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1423 VTY_DECLVAR_CONTEXT_SUB(rfapi_nve_group_cfg
, rfg
);
1425 if (!bgp
->rfapi_cfg
)
1427 vty_out (vty
, "rfapi not configured%s", VTY_NEWLINE
);
1431 /* make sure it's still in list */
1432 if (!listnode_lookup (bgp
->rfapi_cfg
->nve_groups_sequential
, rfg
))
1434 /* Not in list anymore */
1435 vty_out (vty
, "Current NVE group no longer exists%s", VTY_NEWLINE
);
1439 vnc_redistribute_prechange (bgp
);
1441 if (rfg
->routemap_redist_name
[ZEBRA_ROUTE_BGP_DIRECT
])
1442 free (rfg
->routemap_redist_name
[ZEBRA_ROUTE_BGP_DIRECT
]);
1443 rfg
->routemap_redist_name
[ZEBRA_ROUTE_BGP_DIRECT
] = NULL
;
1444 rfg
->routemap_redist
[ZEBRA_ROUTE_BGP_DIRECT
] = NULL
;
1446 vnc_redistribute_postchange (bgp
);
1451 DEFUN (vnc_nve_group_redist_bgpdirect_routemap
,
1452 vnc_nve_group_redist_bgpdirect_routemap_cmd
,
1453 "redistribute bgp-direct route-map NAME",
1454 "Redistribute from other protocols\n"
1455 "Redistribute from BGP directly\n"
1456 "Route-map for filtering exported routes\n" "route map name\n")
1458 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1459 VTY_DECLVAR_CONTEXT_SUB(rfapi_nve_group_cfg
, rfg
);
1461 if (!bgp
->rfapi_cfg
)
1463 vty_out (vty
, "rfapi not configured%s", VTY_NEWLINE
);
1467 /* make sure it's still in list */
1468 if (!listnode_lookup (bgp
->rfapi_cfg
->nve_groups_sequential
, rfg
))
1470 /* Not in list anymore */
1471 vty_out (vty
, "Current NVE group no longer exists%s", VTY_NEWLINE
);
1475 vnc_redistribute_prechange (bgp
);
1477 if (rfg
->routemap_redist_name
[ZEBRA_ROUTE_BGP_DIRECT
])
1478 free (rfg
->routemap_redist_name
[ZEBRA_ROUTE_BGP_DIRECT
]);
1479 rfg
->routemap_redist_name
[ZEBRA_ROUTE_BGP_DIRECT
] = strdup (argv
[3]->arg
);
1480 rfg
->routemap_redist
[ZEBRA_ROUTE_BGP_DIRECT
] =
1481 route_map_lookup_by_name (argv
[3]->arg
);
1483 vnc_redistribute_postchange (bgp
);
1488 /*-- redist policy, nvegroup end --*/
1490 /*-------------------------------------------------------------------------
1492 *-----------------------------------------------------------------------*/
1494 DEFUN (vnc_export_mode
,
1495 vnc_export_mode_cmd
,
1496 "vnc export <bgp|zebra> mode <group-nve|ce|none|registering-nve>",
1498 "Export to other protocols\n"
1500 "Export to Zebra (experimental)\n"
1501 "Select export mode\n"
1502 "Export routes with nve-group next-hops\n"
1503 "Export routes with NVE connected router next-hops\n"
1504 "Disable export\n" "Export routes with registering NVE as next-hop\n")
1506 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1507 uint32_t oldmode
= 0;
1508 uint32_t newmode
= 0;
1510 if (!bgp
->rfapi_cfg
)
1512 vty_out (vty
, "VNC not configured%s", VTY_NEWLINE
);
1516 if (argv
[2]->arg
[0] == 'b')
1518 oldmode
= bgp
->rfapi_cfg
->flags
& BGP_VNC_CONFIG_EXPORT_BGP_MODE_BITS
;
1519 switch (argv
[4]->arg
[0])
1522 newmode
= BGP_VNC_CONFIG_EXPORT_BGP_MODE_GRP
;
1525 newmode
= BGP_VNC_CONFIG_EXPORT_BGP_MODE_CE
;
1531 newmode
= BGP_VNC_CONFIG_EXPORT_BGP_MODE_RH
;
1534 vty_out (vty
, "Invalid mode specified%s", VTY_NEWLINE
);
1538 if (newmode
== oldmode
)
1540 vty_out (vty
, "Mode unchanged%s", VTY_NEWLINE
);
1544 vnc_export_bgp_prechange (bgp
);
1546 bgp
->rfapi_cfg
->flags
&= ~BGP_VNC_CONFIG_EXPORT_BGP_MODE_BITS
;
1547 bgp
->rfapi_cfg
->flags
|= newmode
;
1549 vnc_export_bgp_postchange (bgp
);
1556 * export to zebra with RH mode is not yet implemented
1558 vty_out (vty
, "Changing modes for zebra export not implemented yet%s",
1562 oldmode
= bgp
->rfapi_cfg
->flags
& BGP_VNC_CONFIG_EXPORT_ZEBRA_MODE_BITS
;
1563 bgp
->rfapi_cfg
->flags
&= ~BGP_VNC_CONFIG_EXPORT_ZEBRA_MODE_BITS
;
1564 switch (argv
[4]->arg
[0])
1567 if (oldmode
== BGP_VNC_CONFIG_EXPORT_ZEBRA_MODE_RH
)
1571 bgp
->rfapi_cfg
->flags
|= BGP_VNC_CONFIG_EXPORT_ZEBRA_MODE_GRP
;
1572 if (oldmode
!= BGP_VNC_CONFIG_EXPORT_ZEBRA_MODE_GRP
)
1578 if (oldmode
== BGP_VNC_CONFIG_EXPORT_ZEBRA_MODE_RH
)
1582 if (oldmode
== BGP_VNC_CONFIG_EXPORT_ZEBRA_MODE_GRP
)
1588 if (oldmode
== BGP_VNC_CONFIG_EXPORT_ZEBRA_MODE_GRP
)
1592 bgp
->rfapi_cfg
->flags
|= BGP_VNC_CONFIG_EXPORT_ZEBRA_MODE_RH
;
1593 if (oldmode
!= BGP_VNC_CONFIG_EXPORT_ZEBRA_MODE_RH
)
1599 vty_out (vty
, "Invalid mode%s", VTY_NEWLINE
);
1607 static struct rfapi_rfg_name
*
1610 return XCALLOC (MTYPE_RFAPI_RFG_NAME
, sizeof (struct rfapi_rfg_name
));
1614 rfgn_free (struct rfapi_rfg_name
*rfgn
)
1616 XFREE (MTYPE_RFAPI_RFG_NAME
, rfgn
);
1619 DEFUN (vnc_export_nvegroup
,
1620 vnc_export_nvegroup_cmd
,
1621 "vnc export <bgp|zebra> group-nve group NAME",
1623 "Export to other protocols\n"
1625 "Export to Zebra (experimental)\n"
1626 "NVE group, used in 'group-nve' export mode\n"
1627 "NVE group\n" "Group name\n")
1629 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1630 struct rfapi_nve_group_cfg
*rfg_new
;
1632 if (!bgp
->rfapi_cfg
)
1634 vty_out (vty
, "rfapi not configured%s", VTY_NEWLINE
);
1638 rfg_new
= bgp_rfapi_cfg_match_byname (bgp
, argv
[5]->arg
, RFAPI_GROUP_CFG_NVE
);
1640 if (argv
[2]->arg
[0] == 'b')
1643 struct listnode
*node
;
1644 struct rfapi_rfg_name
*rfgn
;
1647 * Set group for export to BGP Direct
1650 /* see if group is already included in export list */
1651 for (ALL_LIST_ELEMENTS_RO (bgp
->rfapi_cfg
->rfg_export_direct_bgp_l
,
1655 if (!strcmp (rfgn
->name
, argv
[5]->arg
))
1657 /* already in the list: we're done */
1663 rfgn
->name
= strdup (argv
[5]->arg
);
1664 rfgn
->rfg
= rfg_new
; /* OK if not set yet */
1666 listnode_add (bgp
->rfapi_cfg
->rfg_export_direct_bgp_l
, rfgn
);
1668 vnc_zlog_debug_verbose ("%s: testing rfg_new", __func__
);
1671 vnc_zlog_debug_verbose ("%s: testing bgp grp mode enabled", __func__
);
1672 if (VNC_EXPORT_BGP_GRP_ENABLED (bgp
->rfapi_cfg
))
1673 vnc_zlog_debug_verbose ("%s: calling vnc_direct_bgp_add_group", __func__
);
1674 vnc_direct_bgp_add_group (bgp
, rfg_new
);
1681 struct listnode
*node
;
1682 struct rfapi_rfg_name
*rfgn
;
1685 * Set group for export to Zebra
1688 /* see if group is already included in export list */
1689 for (ALL_LIST_ELEMENTS_RO (bgp
->rfapi_cfg
->rfg_export_zebra_l
,
1693 if (!strcmp (rfgn
->name
, argv
[5]->arg
))
1695 /* already in the list: we're done */
1701 rfgn
->name
= strdup (argv
[5]->arg
);
1702 rfgn
->rfg
= rfg_new
; /* OK if not set yet */
1704 listnode_add (bgp
->rfapi_cfg
->rfg_export_zebra_l
, rfgn
);
1708 if (VNC_EXPORT_ZEBRA_GRP_ENABLED (bgp
->rfapi_cfg
))
1709 vnc_zebra_add_group (bgp
, rfg_new
);
1717 * This command applies to routes exported from VNC to BGP directly
1718 * without going though zebra
1720 DEFUN (vnc_no_export_nvegroup
,
1721 vnc_no_export_nvegroup_cmd
,
1722 "vnc export <bgp|zebra> group-nve no group NAME",
1724 "Export to other protocols\n"
1726 "Export to Zebra (experimental)\n"
1727 "NVE group, used in 'group-nve' export mode\n"
1728 "Disable export of VNC routes\n" "NVE group\n" "Group name\n")
1730 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1731 struct listnode
*node
, *nnode
;
1732 struct rfapi_rfg_name
*rfgn
;
1734 if (!bgp
->rfapi_cfg
)
1736 vty_out (vty
, "rfapi not configured%s", VTY_NEWLINE
);
1740 if (argv
[2]->arg
[0] == 'b')
1742 for (ALL_LIST_ELEMENTS (bgp
->rfapi_cfg
->rfg_export_direct_bgp_l
,
1746 if (rfgn
->name
&& !strcmp (rfgn
->name
, argv
[6]->arg
))
1748 vnc_zlog_debug_verbose ("%s: matched \"%s\"", __func__
, rfgn
->name
);
1750 vnc_direct_bgp_del_group (bgp
, rfgn
->rfg
);
1752 list_delete_node (bgp
->rfapi_cfg
->rfg_export_direct_bgp_l
,
1761 for (ALL_LIST_ELEMENTS (bgp
->rfapi_cfg
->rfg_export_zebra_l
,
1765 vnc_zlog_debug_verbose ("does rfg \"%s\" match?", rfgn
->name
);
1766 if (rfgn
->name
&& !strcmp (rfgn
->name
, argv
[6]->arg
))
1769 vnc_zebra_del_group (bgp
, rfgn
->rfg
);
1771 list_delete_node (bgp
->rfapi_cfg
->rfg_export_zebra_l
, node
);
1780 DEFUN (vnc_nve_group_export_no_prefixlist
,
1781 vnc_nve_group_export_no_prefixlist_cmd
,
1782 "no export <bgp|zebra> <ipv4|ipv6> prefix-list [NAME]",
1784 "Export to other protocols\n"
1786 "Export to Zebra (experimental)\n"
1789 "Prefix-list for filtering exported routes\n" "prefix list name\n")
1791 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1792 VTY_DECLVAR_CONTEXT_SUB(rfapi_nve_group_cfg
, rfg
);
1795 if (!bgp
->rfapi_cfg
)
1797 vty_out (vty
, "rfapi not configured%s", VTY_NEWLINE
);
1801 /* make sure it's still in list */
1802 if (!listnode_lookup (bgp
->rfapi_cfg
->nve_groups_sequential
, rfg
))
1804 /* Not in list anymore */
1805 vty_out (vty
, "Current NVE group no longer exists%s", VTY_NEWLINE
);
1809 if (!strcmp (argv
[3]->arg
, "ipv4"))
1818 if (argv
[2]->arg
[0] == 'b')
1821 && !strcmp (argv
[5]->arg
, rfg
->plist_export_bgp_name
[afi
]))
1825 if (rfg
->plist_export_bgp_name
[afi
])
1826 free (rfg
->plist_export_bgp_name
[afi
]);
1827 rfg
->plist_export_bgp_name
[afi
] = NULL
;
1828 rfg
->plist_export_bgp
[afi
] = NULL
;
1830 vnc_direct_bgp_reexport_group_afi (bgp
, rfg
, afi
);
1836 && !strcmp (argv
[5]->arg
, rfg
->plist_export_zebra_name
[afi
]))
1839 if (rfg
->plist_export_zebra_name
[afi
])
1840 free (rfg
->plist_export_zebra_name
[afi
]);
1841 rfg
->plist_export_zebra_name
[afi
] = NULL
;
1842 rfg
->plist_export_zebra
[afi
] = NULL
;
1844 vnc_zebra_reexport_group_afi (bgp
, rfg
, afi
);
1850 DEFUN (vnc_nve_group_export_prefixlist
,
1851 vnc_nve_group_export_prefixlist_cmd
,
1852 "export <bgp|zebra> <ipv4|ipv6> prefix-list NAME",
1853 "Export to other protocols\n"
1855 "Export to Zebra (experimental)\n"
1858 "Prefix-list for filtering exported routes\n" "prefix list name\n")
1860 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1861 VTY_DECLVAR_CONTEXT_SUB(rfapi_nve_group_cfg
, rfg
);
1864 if (!bgp
->rfapi_cfg
)
1866 vty_out (vty
, "rfapi not configured%s", VTY_NEWLINE
);
1870 /* make sure it's still in list */
1871 if (!listnode_lookup (bgp
->rfapi_cfg
->nve_groups_sequential
, rfg
))
1873 /* Not in list anymore */
1874 vty_out (vty
, "Current NVE group no longer exists%s", VTY_NEWLINE
);
1878 if (!strcmp (argv
[2]->arg
, "ipv4"))
1887 if (argv
[1]->arg
[0] == 'b')
1889 if (rfg
->plist_export_bgp_name
[afi
])
1890 free (rfg
->plist_export_bgp_name
[afi
]);
1891 rfg
->plist_export_bgp_name
[afi
] = strdup (argv
[4]->arg
);
1892 rfg
->plist_export_bgp
[afi
] = prefix_list_lookup (afi
, argv
[4]->arg
);
1894 vnc_direct_bgp_reexport_group_afi (bgp
, rfg
, afi
);
1899 if (rfg
->plist_export_zebra_name
[afi
])
1900 free (rfg
->plist_export_zebra_name
[afi
]);
1901 rfg
->plist_export_zebra_name
[afi
] = strdup (argv
[4]->arg
);
1902 rfg
->plist_export_zebra
[afi
] = prefix_list_lookup (afi
, argv
[4]->arg
);
1904 vnc_zebra_reexport_group_afi (bgp
, rfg
, afi
);
1909 DEFUN (vnc_nve_group_export_no_routemap
,
1910 vnc_nve_group_export_no_routemap_cmd
,
1911 "no export <bgp|zebra> route-map [NAME]",
1913 "Export to other protocols\n"
1915 "Export to Zebra (experimental)\n"
1916 "Route-map for filtering exported routes\n" "route map name\n")
1918 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1919 VTY_DECLVAR_CONTEXT_SUB(rfapi_nve_group_cfg
, rfg
);
1921 if (!bgp
->rfapi_cfg
)
1923 vty_out (vty
, "rfapi not configured%s", VTY_NEWLINE
);
1927 /* make sure it's still in list */
1928 if (!listnode_lookup (bgp
->rfapi_cfg
->nve_groups_sequential
, rfg
))
1930 /* Not in list anymore */
1931 vty_out (vty
, "Current NVE group no longer exists%s", VTY_NEWLINE
);
1935 if (argv
[2]->arg
[0] == 'b')
1938 && !strcmp (argv
[4]->arg
, rfg
->routemap_export_bgp_name
))
1942 if (rfg
->routemap_export_bgp_name
)
1943 free (rfg
->routemap_export_bgp_name
);
1944 rfg
->routemap_export_bgp_name
= NULL
;
1945 rfg
->routemap_export_bgp
= NULL
;
1947 vnc_direct_bgp_reexport_group_afi (bgp
, rfg
, AFI_IP
);
1948 vnc_direct_bgp_reexport_group_afi (bgp
, rfg
, AFI_IP6
);
1954 && !strcmp (argv
[4]->arg
, rfg
->routemap_export_zebra_name
))
1957 if (rfg
->routemap_export_zebra_name
)
1958 free (rfg
->routemap_export_zebra_name
);
1959 rfg
->routemap_export_zebra_name
= NULL
;
1960 rfg
->routemap_export_zebra
= NULL
;
1962 vnc_zebra_reexport_group_afi (bgp
, rfg
, AFI_IP
);
1963 vnc_zebra_reexport_group_afi (bgp
, rfg
, AFI_IP6
);
1969 DEFUN (vnc_nve_group_export_routemap
,
1970 vnc_nve_group_export_routemap_cmd
,
1971 "export <bgp|zebra> route-map NAME",
1972 "Export to other protocols\n"
1974 "Export to Zebra (experimental)\n"
1975 "Route-map for filtering exported routes\n" "route map name\n")
1977 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1978 VTY_DECLVAR_CONTEXT_SUB(rfapi_nve_group_cfg
, rfg
);
1980 if (!bgp
->rfapi_cfg
)
1982 vty_out (vty
, "rfapi not configured%s", VTY_NEWLINE
);
1986 /* make sure it's still in list */
1987 if (!listnode_lookup (bgp
->rfapi_cfg
->nve_groups_sequential
, rfg
))
1989 /* Not in list anymore */
1990 vty_out (vty
, "Current NVE group no longer exists%s", VTY_NEWLINE
);
1994 if (argv
[1]->arg
[0] == 'b')
1996 if (rfg
->routemap_export_bgp_name
)
1997 free (rfg
->routemap_export_bgp_name
);
1998 rfg
->routemap_export_bgp_name
= strdup (argv
[3]->arg
);
1999 rfg
->routemap_export_bgp
= route_map_lookup_by_name (argv
[3]->arg
);
2000 vnc_direct_bgp_reexport_group_afi (bgp
, rfg
, AFI_IP
);
2001 vnc_direct_bgp_reexport_group_afi (bgp
, rfg
, AFI_IP6
);
2005 if (rfg
->routemap_export_zebra_name
)
2006 free (rfg
->routemap_export_zebra_name
);
2007 rfg
->routemap_export_zebra_name
= strdup (argv
[3]->arg
);
2008 rfg
->routemap_export_zebra
= route_map_lookup_by_name (argv
[3]->arg
);
2009 vnc_zebra_reexport_group_afi (bgp
, rfg
, AFI_IP
);
2010 vnc_zebra_reexport_group_afi (bgp
, rfg
, AFI_IP6
);
2015 DEFUN (vnc_nve_export_no_prefixlist
,
2016 vnc_nve_export_no_prefixlist_cmd
,
2017 "no vnc export <bgp|zebra> <ipv4|ipv6> prefix-list [NAME]",
2020 "Export to other protocols\n"
2022 "Export to Zebra (experimental)\n"
2025 "Prefix-list for filtering exported routes\n" "Prefix list name\n")
2027 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2028 struct rfapi_cfg
*hc
;
2031 if (!(hc
= bgp
->rfapi_cfg
))
2033 vty_out (vty
, "rfapi not configured%s", VTY_NEWLINE
);
2037 if (!strcmp (argv
[4]->arg
, "ipv4"))
2046 if (argv
[3]->arg
[0] == 'b')
2049 && !strcmp (argv
[6]->arg
, hc
->plist_export_bgp_name
[afi
]))
2053 if (hc
->plist_export_bgp_name
[afi
])
2054 free (hc
->plist_export_bgp_name
[afi
]);
2055 hc
->plist_export_bgp_name
[afi
] = NULL
;
2056 hc
->plist_export_bgp
[afi
] = NULL
;
2057 vnc_direct_bgp_reexport (bgp
, afi
);
2063 && !strcmp (argv
[6]->arg
, hc
->plist_export_zebra_name
[afi
]))
2067 if (hc
->plist_export_zebra_name
[afi
])
2068 free (hc
->plist_export_zebra_name
[afi
]);
2069 hc
->plist_export_zebra_name
[afi
] = NULL
;
2070 hc
->plist_export_zebra
[afi
] = NULL
;
2071 /* TBD vnc_zebra_rh_reexport(bgp, afi); */
2077 DEFUN (vnc_nve_export_prefixlist
,
2078 vnc_nve_export_prefixlist_cmd
,
2079 "vnc export <bgp|zebra> <ipv4|ipv6> prefix-list NAME",
2081 "Export to other protocols\n"
2083 "Export to Zebra (experimental)\n"
2084 "Filters, used in 'registering-nve' export mode\n"
2087 "Prefix-list for filtering exported routes\n" "Prefix list name\n")
2089 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2090 struct rfapi_cfg
*hc
;
2093 if (!(hc
= bgp
->rfapi_cfg
))
2095 vty_out (vty
, "rfapi not configured%s", VTY_NEWLINE
);
2099 if (!strcmp (argv
[3]->arg
, "ipv4"))
2108 if (argv
[2]->arg
[0] == 'b')
2110 if (hc
->plist_export_bgp_name
[afi
])
2111 free (hc
->plist_export_bgp_name
[afi
]);
2112 hc
->plist_export_bgp_name
[afi
] = strdup (argv
[5]->arg
);
2113 hc
->plist_export_bgp
[afi
] = prefix_list_lookup (afi
, argv
[5]->arg
);
2114 vnc_direct_bgp_reexport (bgp
, afi
);
2118 if (hc
->plist_export_zebra_name
[afi
])
2119 free (hc
->plist_export_zebra_name
[afi
]);
2120 hc
->plist_export_zebra_name
[afi
] = strdup (argv
[5]->arg
);
2121 hc
->plist_export_zebra
[afi
] = prefix_list_lookup (afi
, argv
[5]->arg
);
2122 /* TBD vnc_zebra_rh_reexport(bgp, afi); */
2127 DEFUN (vnc_nve_export_no_routemap
,
2128 vnc_nve_export_no_routemap_cmd
,
2129 "no vnc export <bgp|zebra> route-map [NAME]",
2132 "Export to other protocols\n"
2134 "Export to Zebra (experimental)\n"
2135 "Route-map for filtering exported routes\n" "Route map name\n")
2137 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2138 struct rfapi_cfg
*hc
;
2140 if (!(hc
= bgp
->rfapi_cfg
))
2142 vty_out (vty
, "rfapi not configured%s", VTY_NEWLINE
);
2146 if (argv
[3]->arg
[0] == 'b')
2149 && !strcmp (argv
[5]->arg
, hc
->routemap_export_bgp_name
))
2153 if (hc
->routemap_export_bgp_name
)
2154 free (hc
->routemap_export_bgp_name
);
2155 hc
->routemap_export_bgp_name
= NULL
;
2156 hc
->routemap_export_bgp
= NULL
;
2157 vnc_direct_bgp_reexport (bgp
, AFI_IP
);
2158 vnc_direct_bgp_reexport (bgp
, AFI_IP6
);
2164 && !strcmp (argv
[5]->arg
, hc
->routemap_export_zebra_name
))
2168 if (hc
->routemap_export_zebra_name
)
2169 free (hc
->routemap_export_zebra_name
);
2170 hc
->routemap_export_zebra_name
= NULL
;
2171 hc
->routemap_export_zebra
= NULL
;
2172 /* TBD vnc_zebra_rh_reexport(bgp, AFI_IP); */
2173 /* TBD vnc_zebra_rh_reexport(bgp, AFI_IP6); */
2179 DEFUN (vnc_nve_export_routemap
,
2180 vnc_nve_export_routemap_cmd
,
2181 "vnc export <bgp|zebra> route-map NAME",
2183 "Export to other protocols\n"
2185 "Export to Zebra (experimental)\n"
2186 "Filters, used in 'registering-nve' export mode\n"
2187 "Route-map for filtering exported routes\n" "Route map name\n")
2189 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2190 struct rfapi_cfg
*hc
;
2192 if (!(hc
= bgp
->rfapi_cfg
))
2194 vty_out (vty
, "rfapi not configured%s", VTY_NEWLINE
);
2198 if (argv
[2]->arg
[0] == 'b')
2200 if (hc
->routemap_export_bgp_name
)
2201 free (hc
->routemap_export_bgp_name
);
2202 hc
->routemap_export_bgp_name
= strdup (argv
[4]->arg
);
2203 hc
->routemap_export_bgp
= route_map_lookup_by_name (argv
[4]->arg
);
2204 vnc_direct_bgp_reexport (bgp
, AFI_IP
);
2205 vnc_direct_bgp_reexport (bgp
, AFI_IP6
);
2209 if (hc
->routemap_export_zebra_name
)
2210 free (hc
->routemap_export_zebra_name
);
2211 hc
->routemap_export_zebra_name
= strdup (argv
[4]->arg
);
2212 hc
->routemap_export_zebra
= route_map_lookup_by_name (argv
[4]->arg
);
2213 /* TBD vnc_zebra_rh_reexport(bgp, AFI_IP); */
2214 /* TBD vnc_zebra_rh_reexport(bgp, AFI_IP6); */
2221 * respond to changes in the global prefix list configuration
2224 vnc_prefix_list_update (struct bgp
*bgp
)
2228 struct rfapi_nve_group_cfg
*rfg
;
2229 struct rfapi_cfg
*hc
;
2234 vnc_zlog_debug_verbose ("%s: No BGP process is configured", __func__
);
2238 if (!(hc
= bgp
->rfapi_cfg
))
2240 vnc_zlog_debug_verbose ("%s: rfapi not configured", __func__
);
2244 for (afi
= AFI_IP
; afi
< AFI_MAX
; afi
++)
2247 * Loop over nve groups
2249 for (ALL_LIST_ELEMENTS_RO (bgp
->rfapi_cfg
->nve_groups_sequential
,
2253 if (rfg
->plist_export_bgp_name
[afi
])
2255 rfg
->plist_export_bgp
[afi
] =
2256 prefix_list_lookup (afi
, rfg
->plist_export_bgp_name
[afi
]);
2258 if (rfg
->plist_export_zebra_name
[afi
])
2260 rfg
->plist_export_zebra
[afi
] =
2261 prefix_list_lookup (afi
, rfg
->plist_export_zebra_name
[afi
]);
2263 for (i
= 0; i
< ZEBRA_ROUTE_MAX
; ++i
)
2265 if (rfg
->plist_redist_name
[i
][afi
])
2267 rfg
->plist_redist
[i
][afi
] =
2268 prefix_list_lookup (afi
, rfg
->plist_redist_name
[i
][afi
]);
2272 vnc_direct_bgp_reexport_group_afi (bgp
, rfg
, afi
);
2273 /* TBD vnc_zebra_reexport_group_afi(bgp, rfg, afi); */
2279 if (hc
->plist_export_bgp_name
[afi
])
2281 hc
->plist_export_bgp
[afi
] =
2282 prefix_list_lookup (afi
, hc
->plist_export_bgp_name
[afi
]);
2284 if (hc
->plist_export_zebra_name
[afi
])
2286 hc
->plist_export_zebra
[afi
] =
2287 prefix_list_lookup (afi
, hc
->plist_export_zebra_name
[afi
]);
2290 for (i
= 0; i
< ZEBRA_ROUTE_MAX
; ++i
)
2292 if (hc
->plist_redist_name
[i
][afi
])
2294 hc
->plist_redist
[i
][afi
] =
2295 prefix_list_lookup (afi
, hc
->plist_redist_name
[i
][afi
]);
2301 vnc_direct_bgp_reexport (bgp
, AFI_IP
);
2302 vnc_direct_bgp_reexport (bgp
, AFI_IP6
);
2304 /* TBD vnc_zebra_rh_reexport(bgp, AFI_IP); */
2305 /* TBD vnc_zebra_rh_reexport(bgp, AFI_IP6); */
2307 vnc_redistribute_prechange (bgp
);
2308 vnc_redistribute_postchange (bgp
);
2312 * respond to changes in the global route map configuration
2315 vnc_routemap_update (struct bgp
*bgp
, const char *unused
)
2318 struct rfapi_nve_group_cfg
*rfg
;
2319 struct rfapi_cfg
*hc
;
2322 vnc_zlog_debug_verbose ("%s(arg=%s)", __func__
, unused
);
2326 vnc_zlog_debug_verbose ("%s: No BGP process is configured", __func__
);
2330 if (!(hc
= bgp
->rfapi_cfg
))
2332 vnc_zlog_debug_verbose ("%s: rfapi not configured", __func__
);
2337 * Loop over nve groups
2339 for (ALL_LIST_ELEMENTS_RO (bgp
->rfapi_cfg
->nve_groups_sequential
, n
, rfg
))
2342 if (rfg
->routemap_export_bgp_name
)
2344 rfg
->routemap_export_bgp
=
2345 route_map_lookup_by_name (rfg
->routemap_export_bgp_name
);
2347 if (rfg
->routemap_export_zebra_name
)
2349 rfg
->routemap_export_bgp
=
2350 route_map_lookup_by_name (rfg
->routemap_export_zebra_name
);
2352 for (i
= 0; i
< ZEBRA_ROUTE_MAX
; ++i
)
2354 if (rfg
->routemap_redist_name
[i
])
2356 rfg
->routemap_redist
[i
] =
2357 route_map_lookup_by_name (rfg
->routemap_redist_name
[i
]);
2361 vnc_direct_bgp_reexport_group_afi (bgp
, rfg
, AFI_IP
);
2362 vnc_direct_bgp_reexport_group_afi (bgp
, rfg
, AFI_IP6
);
2363 /* TBD vnc_zebra_reexport_group_afi(bgp, rfg, afi); */
2369 if (hc
->routemap_export_bgp_name
)
2371 hc
->routemap_export_bgp
=
2372 route_map_lookup_by_name (hc
->routemap_export_bgp_name
);
2374 if (hc
->routemap_export_zebra_name
)
2376 hc
->routemap_export_bgp
=
2377 route_map_lookup_by_name (hc
->routemap_export_zebra_name
);
2379 for (i
= 0; i
< ZEBRA_ROUTE_MAX
; ++i
)
2381 if (hc
->routemap_redist_name
[i
])
2383 hc
->routemap_redist
[i
] =
2384 route_map_lookup_by_name (hc
->routemap_redist_name
[i
]);
2388 vnc_direct_bgp_reexport (bgp
, AFI_IP
);
2389 vnc_direct_bgp_reexport (bgp
, AFI_IP6
);
2391 /* TBD vnc_zebra_rh_reexport(bgp, AFI_IP); */
2392 /* TBD vnc_zebra_rh_reexport(bgp, AFI_IP6); */
2394 vnc_redistribute_prechange (bgp
);
2395 vnc_redistribute_postchange (bgp
);
2397 vnc_zlog_debug_verbose ("%s done", __func__
);
2401 vnc_routemap_event (route_map_event_t type
, /* ignored */
2402 const char *rmap_name
) /* ignored */
2404 struct listnode
*mnode
, *mnnode
;
2407 vnc_zlog_debug_verbose ("%s(event type=%d)", __func__
, type
);
2408 if (bm
->bgp
== NULL
) /* may be called during cleanup */
2411 for (ALL_LIST_ELEMENTS (bm
->bgp
, mnode
, mnnode
, bgp
))
2412 vnc_routemap_update (bgp
, rmap_name
);
2414 vnc_zlog_debug_verbose ("%s: done", __func__
);
2417 /*-------------------------------------------------------------------------
2419 *-----------------------------------------------------------------------*/
2422 DEFUN_NOSH (vnc_nve_group
,
2424 "vnc nve-group NAME",
2425 VNC_CONFIG_STR
"Configure a NVE group\n" "Group name\n")
2427 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2428 struct rfapi_nve_group_cfg
*rfg
;
2429 struct listnode
*node
, *nnode
;
2430 struct rfapi_rfg_name
*rfgn
;
2432 /* Search for name */
2433 rfg
= bgp_rfapi_cfg_match_byname (bgp
, argv
[2]->arg
, RFAPI_GROUP_CFG_NVE
);
2437 rfg
= rfapi_group_new (bgp
, RFAPI_GROUP_CFG_NVE
, argv
[2]->arg
);
2440 /* Error out of memory */
2441 vty_out (vty
, "Can't allocate memory for NVE group%s", VTY_NEWLINE
);
2445 /* Copy defaults from struct rfapi_cfg */
2446 rfg
->rd
= bgp
->rfapi_cfg
->default_rd
;
2447 if (bgp
->rfapi_cfg
->flags
& BGP_VNC_CONFIG_L2RD
)
2449 rfg
->l2rd
= bgp
->rfapi_cfg
->default_l2rd
;
2450 rfg
->flags
|= RFAPI_RFG_L2RD
;
2452 rfg
->rd
= bgp
->rfapi_cfg
->default_rd
;
2453 rfg
->response_lifetime
= bgp
->rfapi_cfg
->default_response_lifetime
;
2455 if (bgp
->rfapi_cfg
->default_rt_export_list
)
2457 rfg
->rt_export_list
=
2458 ecommunity_dup (bgp
->rfapi_cfg
->default_rt_export_list
);
2461 if (bgp
->rfapi_cfg
->default_rt_import_list
)
2463 rfg
->rt_import_list
=
2464 ecommunity_dup (bgp
->rfapi_cfg
->default_rt_import_list
);
2465 rfg
->rfapi_import_table
=
2466 rfapiImportTableRefAdd (bgp
, rfg
->rt_import_list
, rfg
);
2470 * If a redist nve group was named but the group was not defined,
2471 * make the linkage now
2473 if (!bgp
->rfapi_cfg
->rfg_redist
)
2475 if (bgp
->rfapi_cfg
->rfg_redist_name
&&
2476 !strcmp (bgp
->rfapi_cfg
->rfg_redist_name
, rfg
->name
))
2479 vnc_redistribute_prechange (bgp
);
2480 bgp
->rfapi_cfg
->rfg_redist
= rfg
;
2481 vnc_redistribute_postchange (bgp
);
2487 * Same treatment for bgp-direct export group
2489 for (ALL_LIST_ELEMENTS (bgp
->rfapi_cfg
->rfg_export_direct_bgp_l
,
2493 if (!strcmp (rfgn
->name
, rfg
->name
))
2496 vnc_direct_bgp_add_group (bgp
, rfg
);
2502 * Same treatment for zebra export group
2504 for (ALL_LIST_ELEMENTS (bgp
->rfapi_cfg
->rfg_export_zebra_l
,
2508 vnc_zlog_debug_verbose ("%s: ezport zebra: checking if \"%s\" == \"%s\"",
2509 __func__
, rfgn
->name
, rfg
->name
);
2510 if (!strcmp (rfgn
->name
, rfg
->name
))
2513 vnc_zebra_add_group (bgp
, rfg
);
2520 * XXX subsequent calls will need to make sure this item is still
2521 * in the linked list and has the same name
2523 VTY_PUSH_CONTEXT_SUB (BGP_VNC_NVE_GROUP_NODE
, rfg
);
2529 bgp_rfapi_delete_nve_group (
2530 struct vty
*vty
, /* NULL = no output */
2532 struct rfapi_nve_group_cfg
*rfg
)
2534 struct list
*orphaned_nves
= NULL
;
2535 struct listnode
*node
, *nnode
;
2538 * If there are currently-open NVEs that belong to this group,
2539 * zero out their references to this group structure.
2543 struct rfapi_descriptor
*rfd
;
2544 orphaned_nves
= list_new ();
2545 while ((rfd
= listnode_head (rfg
->nves
)))
2548 listnode_delete (rfg
->nves
, rfd
);
2549 listnode_add (orphaned_nves
, rfd
);
2551 list_delete (rfg
->nves
);
2557 if (rfg
->rfapi_import_table
)
2558 rfapiImportTableRefDelByIt (bgp
, rfg
->rfapi_import_table
);
2559 if (rfg
->rt_import_list
)
2560 ecommunity_free (&rfg
->rt_import_list
);
2561 if (rfg
->rt_export_list
)
2562 ecommunity_free (&rfg
->rt_export_list
);
2566 rfg
->vn_node
->info
= NULL
;
2567 route_unlock_node (rfg
->vn_node
); /* frees */
2571 rfg
->un_node
->info
= NULL
;
2572 route_unlock_node (rfg
->un_node
); /* frees */
2575 XFREE (MTYPE_RFAPI_RFP_GROUP_CFG
, rfg
->rfp_cfg
);
2576 listnode_delete (bgp
->rfapi_cfg
->nve_groups_sequential
, rfg
);
2579 XFREE (MTYPE_RFAPI_GROUP_CFG
, rfg
);
2582 * Attempt to reassign the orphaned nves to a new group. If
2583 * a NVE can not be reassigned, its rfd->rfg will remain NULL
2584 * and it will become a zombie until released by rfapi_close().
2588 struct rfapi_descriptor
*rfd
;
2590 for (ALL_LIST_ELEMENTS (orphaned_nves
, node
, nnode
, rfd
))
2593 * 1. rfapi_close() equivalent except:
2594 * a. don't free original descriptor
2595 * b. remember query list
2596 * c. remember advertised route list
2597 * 2. rfapi_open() equivalent except:
2598 * a. reuse original descriptor
2599 * 3. rfapi_register() on remembered advertised route list
2600 * 4. rfapi_query on rememebred query list
2605 rc
= rfapi_reopen (rfd
, bgp
);
2609 list_delete_node (orphaned_nves
, node
);
2611 vty_out (vty
, "WARNING: reassigned NVE vn=");
2612 rfapiPrintRfapiIpAddr (vty
, &rfd
->vn_addr
);
2614 vty_out (vty
, " un=");
2615 rfapiPrintRfapiIpAddr (vty
, &rfd
->un_addr
);
2617 vty_out (vty
, " to new group \"%s\"%s", rfd
->rfg
->name
,
2623 for (ALL_LIST_ELEMENTS_RO (orphaned_nves
, node
, rfd
))
2626 vty_out (vty
, "WARNING: orphaned NVE vn=");
2627 rfapiPrintRfapiIpAddr (vty
, &rfd
->vn_addr
);
2629 vty_out (vty
, " un=");
2630 rfapiPrintRfapiIpAddr (vty
, &rfd
->un_addr
);
2632 vty_out (vty
, "%s", VTY_NEWLINE
);
2634 list_delete (orphaned_nves
);
2639 bgp_rfapi_delete_named_nve_group (
2640 struct vty
*vty
, /* NULL = no output */
2642 const char *rfg_name
, /* NULL = any */
2643 rfapi_group_cfg_type_t type
) /* _MAX = any */
2645 struct rfapi_nve_group_cfg
*rfg
= NULL
;
2646 struct listnode
*node
, *nnode
;
2647 struct rfapi_rfg_name
*rfgn
;
2649 /* Search for name */
2652 rfg
= bgp_rfapi_cfg_match_byname (bgp
, rfg_name
, type
);
2656 vty_out (vty
, "No NVE group named \"%s\"%s", rfg_name
,
2663 * If this group is the redist nve group, unlink it
2665 if (rfg_name
== NULL
|| bgp
->rfapi_cfg
->rfg_redist
== rfg
)
2667 vnc_redistribute_prechange (bgp
);
2668 bgp
->rfapi_cfg
->rfg_redist
= NULL
;
2669 vnc_redistribute_postchange (bgp
);
2674 * remove reference from bgp direct export list
2676 for (ALL_LIST_ELEMENTS_RO (bgp
->rfapi_cfg
->rfg_export_direct_bgp_l
,
2679 if (rfg_name
== NULL
||
2680 (type
== RFAPI_GROUP_CFG_NVE
&& !strcmp (rfgn
->name
, rfg_name
)))
2683 /* remove exported routes from this group */
2684 vnc_direct_bgp_del_group (bgp
, rfg
);
2690 * remove reference from zebra export list
2692 for (ALL_LIST_ELEMENTS_RO (bgp
->rfapi_cfg
->rfg_export_zebra_l
, node
, rfgn
))
2695 if (rfg_name
== NULL
||
2696 (type
== RFAPI_GROUP_CFG_NVE
&& !strcmp (rfgn
->name
, rfg_name
)))
2699 /* remove exported routes from this group */
2700 vnc_zebra_del_group (bgp
, rfg
);
2705 bgp_rfapi_delete_nve_group (vty
, bgp
, rfg
);
2706 else /* must be delete all */
2707 for (ALL_LIST_ELEMENTS
2708 (bgp
->rfapi_cfg
->nve_groups_sequential
, node
, nnode
, rfg
))
2709 bgp_rfapi_delete_nve_group (vty
, bgp
, rfg
);
2713 DEFUN (vnc_no_nve_group
,
2714 vnc_no_nve_group_cmd
,
2715 "no vnc nve-group NAME",
2718 "Configure a NVE group\n"
2721 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2723 return bgp_rfapi_delete_named_nve_group (vty
, bgp
, argv
[3]->arg
, RFAPI_GROUP_CFG_NVE
);
2726 DEFUN (vnc_nve_group_prefix
,
2727 vnc_nve_group_prefix_cmd
,
2728 "prefix <vn|un> <A.B.C.D/M|X:X::X:X/M>",
2729 "Specify prefixes matching NVE VN or UN interfaces\n"
2735 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2736 VTY_DECLVAR_CONTEXT_SUB(rfapi_nve_group_cfg
, rfg
);
2739 struct route_table
*rt
;
2740 struct route_node
*rn
;
2741 int is_un_prefix
= 0;
2743 /* make sure it's still in list */
2744 if (!listnode_lookup (bgp
->rfapi_cfg
->nve_groups_sequential
, rfg
))
2746 /* Not in list anymore */
2747 vty_out (vty
, "Current NVE group no longer exists%s", VTY_NEWLINE
);
2751 if (!str2prefix (argv
[2]->arg
, &p
))
2753 vty_out (vty
, "Malformed prefix \"%s\"%s", argv
[2]->arg
, VTY_NEWLINE
);
2757 afi
= family2afi (p
.family
);
2760 vty_out (vty
, "Unsupported address family%s", VTY_NEWLINE
);
2764 if (argv
[1]->arg
[0] == 'u')
2766 rt
= &(bgp
->rfapi_cfg
->nve_groups_un
[afi
]);
2771 rt
= &(bgp
->rfapi_cfg
->nve_groups_vn
[afi
]);
2774 rn
= route_node_get (rt
, &p
); /* NB locks node */
2778 * There is already a group with this prefix
2780 route_unlock_node (rn
);
2781 if (rn
->info
!= rfg
)
2784 * different group name: fail
2786 vty_out (vty
, "nve group \"%s\" already has \"%s\" prefix %s%s",
2787 ((struct rfapi_nve_group_cfg
*) (rn
->info
))->name
,
2788 argv
[1]->arg
, argv
[2]->arg
, VTY_NEWLINE
);
2794 * same group name: it's already in the correct place
2795 * in the table, so we're done.
2797 * Implies rfg->(vn|un)_prefix is already correct.
2803 if (bgp
->rfapi_cfg
->rfg_redist
== rfg
)
2805 vnc_redistribute_prechange (bgp
);
2808 /* New prefix, new node */
2813 /* detach rfg from previous route table location */
2816 rfg
->un_node
->info
= NULL
;
2817 route_unlock_node (rfg
->un_node
); /* frees */
2819 rfg
->un_node
= rn
; /* back ref */
2826 /* detach rfg from previous route table location */
2829 rfg
->vn_node
->info
= NULL
;
2830 route_unlock_node (rfg
->vn_node
); /* frees */
2832 rfg
->vn_node
= rn
; /* back ref */
2839 if (bgp
->rfapi_cfg
->rfg_redist
== rfg
)
2841 vnc_redistribute_postchange (bgp
);
2847 DEFUN (vnc_nve_group_rt_import
,
2848 vnc_nve_group_rt_import_cmd
,
2849 "rt import RTLIST...",
2850 "Specify route targets\n"
2852 "Space separated route target list (A.B.C.D:MN|EF:OPQR|GHJK:MN)\n")
2854 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2855 VTY_DECLVAR_CONTEXT_SUB(rfapi_nve_group_cfg
, rfg
);
2857 struct listnode
*node
;
2858 struct rfapi_rfg_name
*rfgn
;
2859 int is_export_bgp
= 0;
2860 int is_export_zebra
= 0;
2862 /* make sure it's still in list */
2863 if (!listnode_lookup (bgp
->rfapi_cfg
->nve_groups_sequential
, rfg
))
2865 /* Not in list anymore */
2866 vty_out (vty
, "Current NVE group no longer exists%s", VTY_NEWLINE
);
2870 rc
= set_ecom_list (vty
, argc
- 2, argv
+ 2, &rfg
->rt_import_list
);
2871 if (rc
!= CMD_SUCCESS
)
2874 for (ALL_LIST_ELEMENTS_RO (bgp
->rfapi_cfg
->rfg_export_direct_bgp_l
,
2878 if (rfgn
->rfg
== rfg
)
2886 vnc_direct_bgp_del_group (bgp
, rfg
);
2888 for (ALL_LIST_ELEMENTS_RO (bgp
->rfapi_cfg
->rfg_export_zebra_l
, node
, rfgn
))
2891 if (rfgn
->rfg
== rfg
)
2893 is_export_zebra
= 1;
2898 if (is_export_zebra
)
2899 vnc_zebra_del_group (bgp
, rfg
);
2902 * stop referencing old import table, now reference new one
2904 if (rfg
->rfapi_import_table
)
2905 rfapiImportTableRefDelByIt (bgp
, rfg
->rfapi_import_table
);
2906 rfg
->rfapi_import_table
= rfapiImportTableRefAdd (bgp
, rfg
->rt_import_list
, rfg
);
2909 vnc_direct_bgp_add_group (bgp
, rfg
);
2911 if (is_export_zebra
)
2912 vnc_zebra_add_group (bgp
, rfg
);
2917 DEFUN (vnc_nve_group_rt_export
,
2918 vnc_nve_group_rt_export_cmd
,
2919 "rt export RTLIST...",
2920 "Specify route targets\n"
2922 "Space separated route target list (A.B.C.D:MN|EF:OPQR|GHJK:MN)\n")
2924 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2925 VTY_DECLVAR_CONTEXT_SUB(rfapi_nve_group_cfg
, rfg
);
2928 /* make sure it's still in list */
2929 if (!listnode_lookup (bgp
->rfapi_cfg
->nve_groups_sequential
, rfg
))
2931 /* Not in list anymore */
2932 vty_out (vty
, "Current NVE group no longer exists%s", VTY_NEWLINE
);
2936 if (bgp
->rfapi_cfg
->rfg_redist
== rfg
)
2938 vnc_redistribute_prechange (bgp
);
2941 rc
= set_ecom_list (vty
, argc
- 2, argv
+ 2, &rfg
->rt_export_list
);
2943 if (bgp
->rfapi_cfg
->rfg_redist
== rfg
)
2945 vnc_redistribute_postchange (bgp
);
2951 DEFUN (vnc_nve_group_rt_both
,
2952 vnc_nve_group_rt_both_cmd
,
2953 "rt both RTLIST...",
2954 "Specify route targets\n"
2955 "Export+import filters\n"
2956 "Space separated route target list (A.B.C.D:MN|EF:OPQR|GHJK:MN)\n")
2958 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2959 VTY_DECLVAR_CONTEXT_SUB(rfapi_nve_group_cfg
, rfg
);
2961 int is_export_bgp
= 0;
2962 int is_export_zebra
= 0;
2963 struct listnode
*node
;
2964 struct rfapi_rfg_name
*rfgn
;
2966 /* make sure it's still in list */
2967 if (!listnode_lookup (bgp
->rfapi_cfg
->nve_groups_sequential
, rfg
))
2969 /* Not in list anymore */
2970 vty_out (vty
, "Current NVE group no longer exists%s", VTY_NEWLINE
);
2974 rc
= set_ecom_list (vty
, argc
- 2, argv
+ 2, &rfg
->rt_import_list
);
2975 if (rc
!= CMD_SUCCESS
)
2978 for (ALL_LIST_ELEMENTS_RO (bgp
->rfapi_cfg
->rfg_export_direct_bgp_l
,
2982 if (rfgn
->rfg
== rfg
)
2990 vnc_direct_bgp_del_group (bgp
, rfg
);
2992 for (ALL_LIST_ELEMENTS_RO (bgp
->rfapi_cfg
->rfg_export_zebra_l
, node
, rfgn
))
2995 if (rfgn
->rfg
== rfg
)
2997 is_export_zebra
= 1;
3002 if (is_export_zebra
)
3004 vnc_zlog_debug_verbose ("%s: is_export_zebra", __func__
);
3005 vnc_zebra_del_group (bgp
, rfg
);
3009 * stop referencing old import table, now reference new one
3011 if (rfg
->rfapi_import_table
)
3012 rfapiImportTableRefDelByIt (bgp
, rfg
->rfapi_import_table
);
3013 rfg
->rfapi_import_table
= rfapiImportTableRefAdd (bgp
, rfg
->rt_import_list
, rfg
);
3016 vnc_direct_bgp_add_group (bgp
, rfg
);
3018 if (is_export_zebra
)
3019 vnc_zebra_add_group (bgp
, rfg
);
3021 if (bgp
->rfapi_cfg
->rfg_redist
== rfg
)
3023 vnc_redistribute_prechange (bgp
);
3026 rc
= set_ecom_list (vty
, argc
- 2, argv
+ 2, &rfg
->rt_export_list
);
3028 if (bgp
->rfapi_cfg
->rfg_redist
== rfg
)
3030 vnc_redistribute_postchange (bgp
);
3037 DEFUN (vnc_nve_group_l2rd
,
3038 vnc_nve_group_l2rd_cmd
,
3039 "l2rd <(1-255)|auto-vn>",
3040 "Specify default Local Nve ID value to use in RD for L2 routes\n"
3041 "Fixed value 1-255\n"
3042 "use the low-order octet of the NVE's VN address\n")
3044 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3045 VTY_DECLVAR_CONTEXT_SUB(rfapi_nve_group_cfg
, rfg
);
3047 /* make sure it's still in list */
3048 if (!listnode_lookup (bgp
->rfapi_cfg
->nve_groups_sequential
, rfg
))
3050 /* Not in list anymore */
3051 vty_out (vty
, "Current NVE group no longer exists%s", VTY_NEWLINE
);
3055 if (!strcmp (argv
[1]->arg
, "auto:vn"))
3062 unsigned long value_l
= strtoul (argv
[1]->arg
, &end
, 10);
3063 uint8_t value
= value_l
& 0xff;
3065 if (!argv
[1]->arg
[0] || *end
)
3067 vty_out (vty
, "%% Malformed l2 nve ID \"%s\"%s", argv
[1]->arg
,
3071 if ((value_l
< 1) || (value_l
> 0xff))
3074 "%% Malformed l2 nve id (must be greater than 0 and less than %u%s",
3075 0x100, VTY_NEWLINE
);
3081 rfg
->flags
|= RFAPI_RFG_L2RD
;
3086 DEFUN (vnc_nve_group_no_l2rd
,
3087 vnc_nve_group_no_l2rd_cmd
,
3090 "Specify default Local Nve ID value to use in RD for L2 routes\n")
3092 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3093 VTY_DECLVAR_CONTEXT_SUB(rfapi_nve_group_cfg
, rfg
);
3095 /* make sure it's still in list */
3096 if (!listnode_lookup (bgp
->rfapi_cfg
->nve_groups_sequential
, rfg
))
3098 /* Not in list anymore */
3099 vty_out (vty
, "Current NVE group no longer exists%s", VTY_NEWLINE
);
3104 rfg
->flags
&= ~RFAPI_RFG_L2RD
;
3109 DEFUN (vnc_nve_group_rd
,
3110 vnc_nve_group_rd_cmd
,
3111 "rd ASN:nn_or_IP-address:nn",
3112 "Specify route distinguisher\n"
3113 "Route Distinguisher (<as-number>:<number> | <ip-address>:<number> | auto:vn:<number> )\n")
3115 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3117 struct prefix_rd prd
;
3118 VTY_DECLVAR_CONTEXT_SUB(rfapi_nve_group_cfg
, rfg
);
3120 /* make sure it's still in list */
3121 if (!listnode_lookup (bgp
->rfapi_cfg
->nve_groups_sequential
, rfg
))
3123 /* Not in list anymore */
3124 vty_out (vty
, "Current NVE group no longer exists%s", VTY_NEWLINE
);
3128 if (!strncmp (argv
[1]->arg
, "auto:vn:", 8))
3131 * use AF_UNIX to designate automatically-assigned RD
3132 * auto:vn:nn where nn is a 2-octet quantity
3135 uint32_t value32
= strtoul (argv
[1]->arg
+ 8, &end
, 10);
3136 uint16_t value
= value32
& 0xffff;
3138 if (!argv
[1]->arg
[8] || *end
)
3140 vty_out (vty
, "%% Malformed rd%s", VTY_NEWLINE
);
3143 if (value32
> 0xffff)
3145 vty_out (vty
, "%% Malformed rd (must be less than %u%s",
3146 0x0ffff, VTY_NEWLINE
);
3150 memset (&prd
, 0, sizeof (prd
));
3151 prd
.family
= AF_UNIX
;
3153 prd
.val
[0] = (RD_TYPE_IP
>> 8) & 0x0ff;
3154 prd
.val
[1] = RD_TYPE_IP
& 0x0ff;
3155 prd
.val
[6] = (value
>> 8) & 0x0ff;
3156 prd
.val
[7] = value
& 0x0ff;
3162 ret
= str2prefix_rd (argv
[1]->arg
, &prd
);
3165 vty_out (vty
, "%% Malformed rd%s", VTY_NEWLINE
);
3170 if (bgp
->rfapi_cfg
->rfg_redist
== rfg
)
3172 vnc_redistribute_prechange (bgp
);
3177 if (bgp
->rfapi_cfg
->rfg_redist
== rfg
)
3179 vnc_redistribute_postchange (bgp
);
3184 DEFUN (vnc_nve_group_responselifetime
,
3185 vnc_nve_group_responselifetime_cmd
,
3186 "response-lifetime <LIFETIME|infinite>",
3187 "Specify response lifetime\n"
3188 "Response lifetime in seconds\n" "Infinite response lifetime\n")
3190 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3191 unsigned int rspint
;
3192 VTY_DECLVAR_CONTEXT_SUB(rfapi_nve_group_cfg
, rfg
);
3193 struct rfapi_descriptor
*rfd
;
3194 struct listnode
*hdnode
;
3196 /* make sure it's still in list */
3197 if (!listnode_lookup (bgp
->rfapi_cfg
->nve_groups_sequential
, rfg
))
3199 /* Not in list anymore */
3200 vty_out (vty
, "Current NVE group no longer exists%s", VTY_NEWLINE
);
3204 if (!strcmp (argv
[1]->arg
, "infinite"))
3206 rspint
= RFAPI_INFINITE_LIFETIME
;
3210 VTY_GET_INTEGER ("Response Lifetime", rspint
, argv
[1]->arg
);
3213 rfg
->response_lifetime
= rspint
;
3214 rfg
->flags
|= RFAPI_RFG_RESPONSE_LIFETIME
;
3216 for (ALL_LIST_ELEMENTS_RO (rfg
->nves
, hdnode
, rfd
))
3217 rfd
->response_lifetime
= rspint
;
3222 * Sigh. This command, like exit-address-family, is a hack to deal
3223 * with the lack of rigorous level control in the command handler.
3224 * TBD fix command handler.
3226 DEFUN_NOSH (exit_vnc
,
3229 "Exit VNC configuration mode\n")
3231 if (vty
->node
== BGP_VNC_DEFAULTS_NODE
||
3232 vty
->node
== BGP_VNC_NVE_GROUP_NODE
||
3233 vty
->node
== BGP_VNC_L2_GROUP_NODE
)
3236 vty
->node
= BGP_NODE
;
3241 static struct cmd_node bgp_vnc_defaults_node
= {
3242 BGP_VNC_DEFAULTS_NODE
,
3243 "%s(config-router-vnc-defaults)# ",
3247 static struct cmd_node bgp_vnc_nve_group_node
= {
3248 BGP_VNC_NVE_GROUP_NODE
,
3249 "%s(config-router-vnc-nve-group)# ",
3253 /*-------------------------------------------------------------------------
3255 * Note there are two types of NVEs, one for VPNs one for RFP NVEs
3256 *-----------------------------------------------------------------------*/
3258 DEFUN_NOSH (vnc_vrf_policy
,
3261 "Configure a VRF policy group\n"
3264 struct rfapi_nve_group_cfg
*rfg
;
3265 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3269 vty_out (vty
, "No BGP process is configured%s", VTY_NEWLINE
);
3273 /* Search for name */
3274 rfg
= bgp_rfapi_cfg_match_byname (bgp
, argv
[1]->arg
, RFAPI_GROUP_CFG_VRF
);
3278 rfg
= rfapi_group_new (bgp
, RFAPI_GROUP_CFG_VRF
, argv
[1]->arg
);
3281 /* Error out of memory */
3282 vty_out (vty
, "Can't allocate memory for NVE group%s", VTY_NEWLINE
);
3287 * XXX subsequent calls will need to make sure this item is still
3288 * in the linked list and has the same name
3290 VTY_PUSH_CONTEXT_SUB (BGP_VRF_POLICY_NODE
, rfg
);
3295 DEFUN (vnc_no_vrf_policy
,
3296 vnc_no_vrf_policy_cmd
,
3297 "no vrf-policy NAME",
3299 "Remove a VRF policy group\n"
3302 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3306 vty_out (vty
, "No BGP process is configured%s", VTY_NEWLINE
);
3309 return bgp_rfapi_delete_named_nve_group (vty
, bgp
, argv
[2]->arg
, RFAPI_GROUP_CFG_VRF
);
3312 DEFUN (vnc_vrf_policy_label
,
3313 vnc_vrf_policy_label_cmd
,
3314 "label (0-1048575)",
3315 "Default label value for VRF\n"
3316 "Label Value <0-1048575>\n")
3318 VTY_DECLVAR_CONTEXT_SUB(rfapi_nve_group_cfg
, rfg
);
3321 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3325 vty_out (vty
, "No BGP process is configured%s", VTY_NEWLINE
);
3329 /* make sure it's still in list */
3330 if (!listnode_lookup (bgp
->rfapi_cfg
->nve_groups_sequential
, rfg
))
3332 /* Not in list anymore */
3333 vty_out (vty
, "Current NVE group no longer exists%s", VTY_NEWLINE
);
3337 VTY_GET_INTEGER_RANGE ("Label value", label
, argv
[1]->arg
, 0, MPLS_LABEL_MAX
);
3339 if (bgp
->rfapi_cfg
->rfg_redist
== rfg
)
3341 vnc_redistribute_prechange (bgp
);
3346 if (bgp
->rfapi_cfg
->rfg_redist
== rfg
)
3348 vnc_redistribute_postchange (bgp
);
3353 DEFUN (vnc_vrf_policy_no_label
,
3354 vnc_vrf_policy_no_label_cmd
,
3357 "Remove VRF default label\n")
3359 VTY_DECLVAR_CONTEXT_SUB(rfapi_nve_group_cfg
, rfg
);
3360 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3362 /* make sure it's still in list */
3363 if (!listnode_lookup (bgp
->rfapi_cfg
->nve_groups_sequential
, rfg
))
3365 /* Not in list anymore */
3366 vty_out (vty
, "Current VRF group no longer exists%s", VTY_NEWLINE
);
3370 if (bgp
->rfapi_cfg
->rfg_redist
== rfg
)
3372 vnc_redistribute_prechange (bgp
);
3375 rfg
->label
= MPLS_LABEL_ILLEGAL
;
3377 if (bgp
->rfapi_cfg
->rfg_redist
== rfg
)
3379 vnc_redistribute_postchange (bgp
);
3384 DEFUN (vnc_vrf_policy_nexthop
,
3385 vnc_vrf_policy_nexthop_cmd
,
3386 "nexthop <A.B.C.D|X:X::X:X|self>",
3387 "Specify next hop to use for VRF advertised prefixes\n"
3390 "Use configured router-id (default)")
3392 VTY_DECLVAR_CONTEXT_SUB(rfapi_nve_group_cfg
, rfg
);
3395 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3397 /* make sure it's still in list */
3398 if (!listnode_lookup (bgp
->rfapi_cfg
->nve_groups_sequential
, rfg
))
3400 /* Not in list anymore */
3401 vty_out (vty
, "Current VRF no longer exists%s", VTY_NEWLINE
);
3405 if (bgp
->rfapi_cfg
->rfg_redist
== rfg
)
3407 vnc_redistribute_prechange (bgp
);
3410 if (!str2prefix (argv
[1]->arg
, &p
) && p
.family
)
3412 //vty_out (vty, "Nexthop set to self%s", VTY_NEWLINE);
3413 SET_FLAG (rfg
->flags
, RFAPI_RFG_VPN_NH_SELF
);
3414 memset(&rfg
->vn_prefix
, 0, sizeof(struct prefix
));
3418 UNSET_FLAG (rfg
->flags
, RFAPI_RFG_VPN_NH_SELF
);
3423 /* TBD handle router-id/ nexthop changes when have advertised prefixes */
3425 if (bgp
->rfapi_cfg
->rfg_redist
== rfg
)
3427 vnc_redistribute_postchange (bgp
);
3433 /* The RT code should be refactored/simplified with above... */
3434 DEFUN (vnc_vrf_policy_rt_import
,
3435 vnc_vrf_policy_rt_import_cmd
,
3436 "rt import RTLIST...",
3437 "Specify route targets\n"
3439 "Space separated route target list (A.B.C.D:MN|EF:OPQR|GHJK:MN)\n")
3441 VTY_DECLVAR_CONTEXT_SUB(rfapi_nve_group_cfg
, rfg
);
3442 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3444 struct listnode
*node
;
3445 struct rfapi_rfg_name
*rfgn
;
3446 int is_export_bgp
= 0;
3447 int is_export_zebra
= 0;
3451 vty_out (vty
, "No BGP process is configured%s", VTY_NEWLINE
);
3455 /* make sure it's still in list */
3456 if (!listnode_lookup (bgp
->rfapi_cfg
->nve_groups_sequential
, rfg
))
3458 /* Not in list anymore */
3459 vty_out (vty
, "Current NVE group no longer exists%s", VTY_NEWLINE
);
3463 rc
= set_ecom_list (vty
, argc
-2, argv
+2, &rfg
->rt_import_list
);
3464 if (rc
!= CMD_SUCCESS
)
3467 for (ALL_LIST_ELEMENTS_RO (bgp
->rfapi_cfg
->rfg_export_direct_bgp_l
,
3471 if (rfgn
->rfg
== rfg
)
3479 vnc_direct_bgp_del_group (bgp
, rfg
);
3481 for (ALL_LIST_ELEMENTS_RO (bgp
->rfapi_cfg
->rfg_export_zebra_l
, node
, rfgn
))
3484 if (rfgn
->rfg
== rfg
)
3486 is_export_zebra
= 1;
3491 if (is_export_zebra
)
3492 vnc_zebra_del_group (bgp
, rfg
);
3495 * stop referencing old import table, now reference new one
3497 if (rfg
->rfapi_import_table
)
3498 rfapiImportTableRefDelByIt (bgp
, rfg
->rfapi_import_table
);
3499 rfg
->rfapi_import_table
= rfapiImportTableRefAdd (bgp
, rfg
->rt_import_list
, rfg
);
3502 vnc_direct_bgp_add_group (bgp
, rfg
);
3504 if (is_export_zebra
)
3505 vnc_zebra_add_group (bgp
, rfg
);
3510 DEFUN (vnc_vrf_policy_rt_export
,
3511 vnc_vrf_policy_rt_export_cmd
,
3512 "rt export RTLIST...",
3513 "Specify route targets\n"
3515 "Space separated route target list (A.B.C.D:MN|EF:OPQR|GHJK:MN)\n")
3517 VTY_DECLVAR_CONTEXT_SUB(rfapi_nve_group_cfg
, rfg
);
3518 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3523 vty_out (vty
, "No BGP process is configured%s", VTY_NEWLINE
);
3527 /* make sure it's still in list */
3528 if (!listnode_lookup (bgp
->rfapi_cfg
->nve_groups_sequential
, rfg
))
3530 /* Not in list anymore */
3531 vty_out (vty
, "Current NVE group no longer exists%s", VTY_NEWLINE
);
3535 if (bgp
->rfapi_cfg
->rfg_redist
== rfg
)
3537 vnc_redistribute_prechange (bgp
);
3540 rc
= set_ecom_list (vty
, argc
-2, argv
+2, &rfg
->rt_export_list
);
3542 if (bgp
->rfapi_cfg
->rfg_redist
== rfg
)
3544 vnc_redistribute_postchange (bgp
);
3550 DEFUN (vnc_vrf_policy_rt_both
,
3551 vnc_vrf_policy_rt_both_cmd
,
3552 "rt both RTLIST...",
3553 "Specify route targets\n"
3554 "Export+import filters\n"
3555 "Space separated route target list (A.B.C.D:MN|EF:OPQR|GHJK:MN)\n")
3557 VTY_DECLVAR_CONTEXT_SUB(rfapi_nve_group_cfg
, rfg
);
3558 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3560 int is_export_bgp
= 0;
3561 int is_export_zebra
= 0;
3562 struct listnode
*node
;
3563 struct rfapi_rfg_name
*rfgn
;
3567 vty_out (vty
, "No BGP process is configured%s", VTY_NEWLINE
);
3571 /* make sure it's still in list */
3572 if (!listnode_lookup (bgp
->rfapi_cfg
->nve_groups_sequential
, rfg
))
3574 /* Not in list anymore */
3575 vty_out (vty
, "Current NVE group no longer exists%s", VTY_NEWLINE
);
3579 rc
= set_ecom_list (vty
, argc
-2, argv
+2, &rfg
->rt_import_list
);
3580 if (rc
!= CMD_SUCCESS
)
3583 for (ALL_LIST_ELEMENTS_RO (bgp
->rfapi_cfg
->rfg_export_direct_bgp_l
,
3587 if (rfgn
->rfg
== rfg
)
3595 vnc_direct_bgp_del_group (bgp
, rfg
);
3597 for (ALL_LIST_ELEMENTS_RO (bgp
->rfapi_cfg
->rfg_export_zebra_l
, node
, rfgn
))
3600 if (rfgn
->rfg
== rfg
)
3602 is_export_zebra
= 1;
3607 if (is_export_zebra
)
3609 vnc_zlog_debug_verbose ("%s: is_export_zebra", __func__
);
3610 vnc_zebra_del_group (bgp
, rfg
);
3614 * stop referencing old import table, now reference new one
3616 if (rfg
->rfapi_import_table
)
3617 rfapiImportTableRefDelByIt (bgp
, rfg
->rfapi_import_table
);
3618 rfg
->rfapi_import_table
= rfapiImportTableRefAdd (bgp
, rfg
->rt_import_list
, rfg
);
3621 vnc_direct_bgp_add_group (bgp
, rfg
);
3623 if (is_export_zebra
)
3624 vnc_zebra_add_group (bgp
, rfg
);
3626 if (bgp
->rfapi_cfg
->rfg_redist
== rfg
)
3628 vnc_redistribute_prechange (bgp
);
3631 rc
= set_ecom_list (vty
, argc
-2, argv
+2, &rfg
->rt_export_list
);
3633 if (bgp
->rfapi_cfg
->rfg_redist
== rfg
)
3635 vnc_redistribute_postchange (bgp
);
3642 DEFUN (vnc_vrf_policy_rd
,
3643 vnc_vrf_policy_rd_cmd
,
3644 "rd ASN:nn_or_IP-address:nn",
3645 "Specify default VRF route distinguisher\n"
3646 "Route Distinguisher (<as-number>:<number> | <ip-address>:<number> | auto:nh:<number> )\n")
3649 struct prefix_rd prd
;
3650 VTY_DECLVAR_CONTEXT_SUB(rfapi_nve_group_cfg
, rfg
);
3651 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3655 vty_out (vty
, "No BGP process is configured%s", VTY_NEWLINE
);
3659 /* make sure it's still in list */
3660 if (!listnode_lookup (bgp
->rfapi_cfg
->nve_groups_sequential
, rfg
))
3662 /* Not in list anymore */
3663 vty_out (vty
, "Current NVE group no longer exists%s", VTY_NEWLINE
);
3667 if (!strncmp (argv
[1]->arg
, "auto:nh:", 8))
3670 * use AF_UNIX to designate automatically-assigned RD
3671 * auto:vn:nn where nn is a 2-octet quantity
3674 uint32_t value32
= strtoul (argv
[1]->arg
+ 8, &end
, 10);
3675 uint16_t value
= value32
& 0xffff;
3677 if (!*(argv
[1]->arg
+ 5) || *end
)
3679 vty_out (vty
, "%% Malformed rd%s", VTY_NEWLINE
);
3682 if (value32
> 0xffff)
3684 vty_out (vty
, "%% Malformed rd (must be less than %u%s",
3685 0x0ffff, VTY_NEWLINE
);
3689 memset (&prd
, 0, sizeof (prd
));
3690 prd
.family
= AF_UNIX
;
3692 prd
.val
[0] = (RD_TYPE_IP
>> 8) & 0x0ff;
3693 prd
.val
[1] = RD_TYPE_IP
& 0x0ff;
3694 prd
.val
[6] = (value
>> 8) & 0x0ff;
3695 prd
.val
[7] = value
& 0x0ff;
3701 ret
= str2prefix_rd (argv
[1]->arg
, &prd
);
3704 vty_out (vty
, "%% Malformed rd%s", VTY_NEWLINE
);
3709 if (bgp
->rfapi_cfg
->rfg_redist
== rfg
)
3711 vnc_redistribute_prechange (bgp
);
3716 if (bgp
->rfapi_cfg
->rfg_redist
== rfg
)
3718 vnc_redistribute_postchange (bgp
);
3723 DEFUN_NOSH (exit_vrf_policy
,
3724 exit_vrf_policy_cmd
,
3726 "Exit VRF policy configuration mode\n")
3728 if (vty
->node
== BGP_VRF_POLICY_NODE
)
3730 vty
->node
= BGP_NODE
;
3735 static struct cmd_node bgp_vrf_policy_node
= {
3736 BGP_VRF_POLICY_NODE
,
3737 "%s(config-router-vrf-policy)# ",
3741 /*-------------------------------------------------------------------------
3743 *-----------------------------------------------------------------------*/
3746 DEFUN_NOSH (vnc_l2_group
,
3748 "vnc l2-group NAME",
3749 VNC_CONFIG_STR
"Configure a L2 group\n" "Group name\n")
3751 struct rfapi_l2_group_cfg
*rfg
;
3752 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3756 vty_out (vty
, "No BGP process is configured%s", VTY_NEWLINE
);
3760 /* Search for name */
3761 rfg
= rfapi_l2_group_lookup_byname (bgp
, argv
[1]->arg
);
3765 rfg
= rfapi_l2_group_new ();
3768 /* Error out of memory */
3769 vty_out (vty
, "Can't allocate memory for L2 group%s", VTY_NEWLINE
);
3772 rfg
->name
= strdup (argv
[1]->arg
);
3773 /* add to tail of list */
3774 listnode_add (bgp
->rfapi_cfg
->l2_groups
, rfg
);
3778 * XXX subsequent calls will need to make sure this item is still
3779 * in the linked list and has the same name
3781 VTY_PUSH_CONTEXT_SUB (BGP_VNC_L2_GROUP_NODE
, rfg
);
3786 bgp_rfapi_delete_l2_group (
3787 struct vty
*vty
, /* NULL = no output */
3789 struct rfapi_l2_group_cfg
*rfg
)
3793 if (rfg
->rt_import_list
)
3794 ecommunity_free (&rfg
->rt_import_list
);
3795 if (rfg
->rt_export_list
)
3796 ecommunity_free (&rfg
->rt_export_list
);
3798 list_delete (rfg
->labels
);
3800 XFREE (MTYPE_RFAPI_RFP_GROUP_CFG
, rfg
->rfp_cfg
);
3801 listnode_delete (bgp
->rfapi_cfg
->l2_groups
, rfg
);
3803 rfapi_l2_group_del (rfg
);
3807 bgp_rfapi_delete_named_l2_group (
3808 struct vty
*vty
, /* NULL = no output */
3810 const char *rfg_name
) /* NULL = any */
3812 struct rfapi_l2_group_cfg
*rfg
= NULL
;
3813 struct listnode
*node
, *nnode
;
3815 /* Search for name */
3818 rfg
= rfapi_l2_group_lookup_byname (bgp
, rfg_name
);
3822 vty_out (vty
, "No L2 group named \"%s\"%s", rfg_name
,
3829 bgp_rfapi_delete_l2_group (vty
, bgp
, rfg
);
3830 else /* must be delete all */
3831 for (ALL_LIST_ELEMENTS (bgp
->rfapi_cfg
->l2_groups
, node
, nnode
, rfg
))
3832 bgp_rfapi_delete_l2_group (vty
, bgp
, rfg
);
3836 DEFUN (vnc_no_l2_group
,
3837 vnc_no_l2_group_cmd
,
3838 "no vnc l2-group NAME",
3841 "Configure a L2 group\n"
3844 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3848 vty_out (vty
, "No BGP process is configured%s", VTY_NEWLINE
);
3851 return bgp_rfapi_delete_named_l2_group (vty
, bgp
, argv
[3]->arg
);
3855 DEFUN (vnc_l2_group_lni
,
3856 vnc_l2_group_lni_cmd
,
3857 "logical-network-id <0-4294967295>",
3858 "Specify Logical Network ID associated with group\n"
3861 VTY_DECLVAR_CONTEXT_SUB(rfapi_l2_group_cfg
, rfg
);
3862 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3866 vty_out (vty
, "No BGP process is configured%s", VTY_NEWLINE
);
3870 /* make sure it's still in list */
3871 if (!listnode_lookup (bgp
->rfapi_cfg
->l2_groups
, rfg
))
3873 /* Not in list anymore */
3874 vty_out (vty
, "Current L2 group no longer exists%s", VTY_NEWLINE
);
3878 VTY_GET_INTEGER ("logical-network-id", rfg
->logical_net_id
, argv
[1]->arg
);
3883 DEFUN (vnc_l2_group_labels
,
3884 vnc_l2_group_labels_cmd
,
3885 "labels LABELLIST...",
3886 "Specify label values associated with group\n"
3887 "Space separated list of label values <0-1048575>\n")
3889 VTY_DECLVAR_CONTEXT_SUB(rfapi_l2_group_cfg
, rfg
);
3890 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3895 vty_out (vty
, "No BGP process is configured%s", VTY_NEWLINE
);
3899 /* make sure it's still in list */
3900 if (!listnode_lookup (bgp
->rfapi_cfg
->l2_groups
, rfg
))
3902 /* Not in list anymore */
3903 vty_out (vty
, "Current L2 group no longer exists%s", VTY_NEWLINE
);
3915 for (; argc
; --argc
, ++argv
)
3918 VTY_GET_INTEGER_RANGE ("Label value", label
, argv
[0]->arg
, 0, MPLS_LABEL_MAX
);
3919 if (!listnode_lookup (ll
, (void *) (uintptr_t) label
))
3920 listnode_add (ll
, (void *) (uintptr_t) label
);
3926 DEFUN (vnc_l2_group_no_labels
,
3927 vnc_l2_group_no_labels_cmd
,
3928 "no labels LABELLIST...",
3930 "Remove label values associated with L2 group\n"
3931 "Specify label values associated with L2 group\n"
3932 "Space separated list of label values <0-1048575>\n")
3934 VTY_DECLVAR_CONTEXT_SUB(rfapi_l2_group_cfg
, rfg
);
3935 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3940 vty_out (vty
, "No BGP process is configured%s", VTY_NEWLINE
);
3944 /* make sure it's still in list */
3945 if (!listnode_lookup (bgp
->rfapi_cfg
->l2_groups
, rfg
))
3947 /* Not in list anymore */
3948 vty_out (vty
, "Current L2 group no longer exists%s", VTY_NEWLINE
);
3955 vty_out (vty
, "Label no longer associated with group%s", VTY_NEWLINE
);
3961 for (; argc
; --argc
, ++argv
)
3964 VTY_GET_INTEGER_RANGE ("Label value", label
, argv
[0]->arg
, 0, MPLS_LABEL_MAX
);
3965 listnode_delete (ll
, (void *) (uintptr_t) label
);
3971 DEFUN (vnc_l2_group_rt
,
3972 vnc_l2_group_rt_cmd
,
3973 "rt <both|export|import> ASN:nn_or_IP-address:nn",
3974 "Specify route targets\n"
3975 "Export+import filters\n"
3980 VTY_DECLVAR_CONTEXT_SUB(rfapi_l2_group_cfg
, rfg
);
3981 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3982 int rc
= CMD_SUCCESS
;
3986 switch (argv
[1]->arg
[0])
3989 do_export
= 1; /* fall through */
3997 vty_out (vty
, "Unknown option, %s%s", argv
[1]->arg
, VTY_NEWLINE
);
3998 return CMD_ERR_NO_MATCH
;
4003 vty_out (vty
, "No BGP process is configured%s", VTY_NEWLINE
);
4007 /* make sure it's still in list */
4008 if (!listnode_lookup (bgp
->rfapi_cfg
->l2_groups
, rfg
))
4010 /* Not in list anymore */
4011 vty_out (vty
, "Current L2 group no longer exists%s", VTY_NEWLINE
);
4016 rc
= set_ecom_list (vty
, argc
-2, argv
+2, &rfg
->rt_import_list
);
4017 if (rc
== CMD_SUCCESS
&& do_export
)
4018 rc
= set_ecom_list (vty
, argc
-2, argv
+2, &rfg
->rt_export_list
);
4023 static struct cmd_node bgp_vnc_l2_group_node
= {
4024 BGP_VNC_L2_GROUP_NODE
,
4025 "%s(config-router-vnc-l2-group)# ",
4029 struct rfapi_l2_group_cfg
*
4030 bgp_rfapi_get_group_by_lni_label (
4032 uint32_t logical_net_id
,
4035 struct rfapi_l2_group_cfg
*rfg
;
4036 struct listnode
*node
;
4038 if (bgp
->rfapi_cfg
->l2_groups
== NULL
) /* not the best place for this */
4041 label
= label
& 0xfffff; /* label is 20 bits! */
4043 for (ALL_LIST_ELEMENTS_RO (bgp
->rfapi_cfg
->l2_groups
, node
, rfg
))
4045 if (rfg
->logical_net_id
== logical_net_id
)
4047 struct listnode
*lnode
;
4049 for (ALL_LIST_ELEMENTS_RO (rfg
->labels
, lnode
, data
))
4050 if (((uint32_t) ((uintptr_t) data
)) == label
)
4060 bgp_rfapi_get_labellist_by_lni_label (
4062 uint32_t logical_net_id
,
4065 struct rfapi_l2_group_cfg
*rfg
;
4066 rfg
= bgp_rfapi_get_group_by_lni_label (bgp
, logical_net_id
, label
);
4075 bgp_rfapi_get_ecommunity_by_lni_label (
4078 uint32_t logical_net_id
,
4081 struct rfapi_l2_group_cfg
*rfg
;
4082 rfg
= bgp_rfapi_get_group_by_lni_label (bgp
, logical_net_id
, label
);
4086 return rfg
->rt_import_list
;
4088 return rfg
->rt_export_list
;
4094 bgp_rfapi_cfg_init (void)
4096 /* main bgpd code does not use this hook, but vnc does */
4097 route_map_event_hook (vnc_routemap_event
);
4099 install_node (&bgp_vnc_defaults_node
, NULL
);
4100 install_node (&bgp_vnc_nve_group_node
, NULL
);
4101 install_node (&bgp_vrf_policy_node
, NULL
);
4102 install_node (&bgp_vnc_l2_group_node
, NULL
);
4103 install_default (BGP_VRF_POLICY_NODE
);
4104 install_default (BGP_VNC_DEFAULTS_NODE
);
4105 install_default (BGP_VNC_NVE_GROUP_NODE
);
4106 install_default (BGP_VNC_L2_GROUP_NODE
);
4111 install_element (BGP_NODE
, &vnc_defaults_cmd
);
4112 install_element (BGP_NODE
, &vnc_nve_group_cmd
);
4113 install_element (BGP_NODE
, &vnc_no_nve_group_cmd
);
4114 install_element (BGP_NODE
, &vnc_vrf_policy_cmd
);
4115 install_element (BGP_NODE
, &vnc_no_vrf_policy_cmd
);
4116 install_element (BGP_NODE
, &vnc_l2_group_cmd
);
4117 install_element (BGP_NODE
, &vnc_no_l2_group_cmd
);
4118 install_element (BGP_NODE
, &vnc_advertise_un_method_cmd
);
4119 install_element (BGP_NODE
, &vnc_export_mode_cmd
);
4121 install_element (BGP_VNC_DEFAULTS_NODE
, &vnc_defaults_rt_import_cmd
);
4122 install_element (BGP_VNC_DEFAULTS_NODE
, &vnc_defaults_rt_export_cmd
);
4123 install_element (BGP_VNC_DEFAULTS_NODE
, &vnc_defaults_rt_both_cmd
);
4124 install_element (BGP_VNC_DEFAULTS_NODE
, &vnc_defaults_rd_cmd
);
4125 install_element (BGP_VNC_DEFAULTS_NODE
, &vnc_defaults_l2rd_cmd
);
4126 install_element (BGP_VNC_DEFAULTS_NODE
, &vnc_defaults_no_l2rd_cmd
);
4127 install_element (BGP_VNC_DEFAULTS_NODE
, &vnc_defaults_responselifetime_cmd
);
4128 install_element (BGP_VNC_DEFAULTS_NODE
, &exit_vnc_cmd
);
4130 install_element (BGP_NODE
, &vnc_redistribute_protocol_cmd
);
4131 install_element (BGP_NODE
, &vnc_no_redistribute_protocol_cmd
);
4132 install_element (BGP_NODE
, &vnc_redistribute_nvegroup_cmd
);
4133 install_element (BGP_NODE
, &vnc_redistribute_no_nvegroup_cmd
);
4134 install_element (BGP_NODE
, &vnc_redistribute_lifetime_cmd
);
4135 install_element (BGP_NODE
, &vnc_redistribute_rh_roo_localadmin_cmd
);
4136 install_element (BGP_NODE
, &vnc_redistribute_mode_cmd
);
4137 install_element (BGP_NODE
, &vnc_redistribute_bgp_exterior_cmd
);
4139 install_element (BGP_NODE
, &vnc_redist_bgpdirect_no_prefixlist_cmd
);
4140 install_element (BGP_NODE
, &vnc_redist_bgpdirect_prefixlist_cmd
);
4141 install_element (BGP_NODE
, &vnc_redist_bgpdirect_no_routemap_cmd
);
4142 install_element (BGP_NODE
, &vnc_redist_bgpdirect_routemap_cmd
);
4144 install_element (BGP_VNC_NVE_GROUP_NODE
,
4145 &vnc_nve_group_redist_bgpdirect_no_prefixlist_cmd
);
4146 install_element (BGP_VNC_NVE_GROUP_NODE
,
4147 &vnc_nve_group_redist_bgpdirect_prefixlist_cmd
);
4148 install_element (BGP_VNC_NVE_GROUP_NODE
,
4149 &vnc_nve_group_redist_bgpdirect_no_routemap_cmd
);
4150 install_element (BGP_VNC_NVE_GROUP_NODE
,
4151 &vnc_nve_group_redist_bgpdirect_routemap_cmd
);
4153 install_element (BGP_NODE
, &vnc_export_nvegroup_cmd
);
4154 install_element (BGP_NODE
, &vnc_no_export_nvegroup_cmd
);
4155 install_element (BGP_NODE
, &vnc_nve_export_prefixlist_cmd
);
4156 install_element (BGP_NODE
, &vnc_nve_export_routemap_cmd
);
4157 install_element (BGP_NODE
, &vnc_nve_export_no_prefixlist_cmd
);
4158 install_element (BGP_NODE
, &vnc_nve_export_no_routemap_cmd
);
4160 install_element (BGP_VNC_NVE_GROUP_NODE
, &vnc_nve_group_l2rd_cmd
);
4161 install_element (BGP_VNC_NVE_GROUP_NODE
, &vnc_nve_group_no_l2rd_cmd
);
4162 install_element (BGP_VNC_NVE_GROUP_NODE
, &vnc_nve_group_prefix_cmd
);
4163 install_element (BGP_VNC_NVE_GROUP_NODE
, &vnc_nve_group_rt_import_cmd
);
4164 install_element (BGP_VNC_NVE_GROUP_NODE
, &vnc_nve_group_rt_export_cmd
);
4165 install_element (BGP_VNC_NVE_GROUP_NODE
, &vnc_nve_group_rt_both_cmd
);
4166 install_element (BGP_VNC_NVE_GROUP_NODE
, &vnc_nve_group_rd_cmd
);
4167 install_element (BGP_VNC_NVE_GROUP_NODE
,
4168 &vnc_nve_group_responselifetime_cmd
);
4169 install_element (BGP_VNC_NVE_GROUP_NODE
,
4170 &vnc_nve_group_export_prefixlist_cmd
);
4171 install_element (BGP_VNC_NVE_GROUP_NODE
,
4172 &vnc_nve_group_export_routemap_cmd
);
4173 install_element (BGP_VNC_NVE_GROUP_NODE
,
4174 &vnc_nve_group_export_no_prefixlist_cmd
);
4175 install_element (BGP_VNC_NVE_GROUP_NODE
,
4176 &vnc_nve_group_export_no_routemap_cmd
);
4177 install_element (BGP_VNC_NVE_GROUP_NODE
, &exit_vnc_cmd
);
4179 install_element (BGP_VRF_POLICY_NODE
, &vnc_vrf_policy_label_cmd
);
4180 install_element (BGP_VRF_POLICY_NODE
, &vnc_vrf_policy_no_label_cmd
);
4181 //Reenable to support VRF controller use case and testing
4182 install_element (BGP_VRF_POLICY_NODE
, &vnc_vrf_policy_nexthop_cmd
);
4183 install_element (BGP_VRF_POLICY_NODE
, &vnc_vrf_policy_rt_import_cmd
);
4184 install_element (BGP_VRF_POLICY_NODE
, &vnc_vrf_policy_rt_export_cmd
);
4185 install_element (BGP_VRF_POLICY_NODE
, &vnc_vrf_policy_rt_both_cmd
);
4186 install_element (BGP_VRF_POLICY_NODE
, &vnc_vrf_policy_rd_cmd
);
4187 install_element (BGP_VRF_POLICY_NODE
, &exit_vrf_policy_cmd
);
4189 install_element (BGP_VNC_L2_GROUP_NODE
, &vnc_l2_group_lni_cmd
);
4190 install_element (BGP_VNC_L2_GROUP_NODE
, &vnc_l2_group_labels_cmd
);
4191 install_element (BGP_VNC_L2_GROUP_NODE
, &vnc_l2_group_no_labels_cmd
);
4192 install_element (BGP_VNC_L2_GROUP_NODE
, &vnc_l2_group_rt_cmd
);
4193 install_element (BGP_VNC_L2_GROUP_NODE
, &exit_vnc_cmd
);
4197 bgp_rfapi_cfg_new (struct rfapi_rfp_cfg
*cfg
)
4199 struct rfapi_cfg
*h
;
4203 (struct rfapi_cfg
*) XCALLOC (MTYPE_RFAPI_CFG
, sizeof (struct rfapi_cfg
));
4206 h
->nve_groups_sequential
= list_new ();
4207 assert (h
->nve_groups_sequential
);
4209 for (afi
= AFI_IP
; afi
< AFI_MAX
; afi
++)
4211 /* ugly, to deal with addition of delegates, part of 0.99.24.1 merge */
4212 h
->nve_groups_vn
[afi
].delegate
= route_table_get_default_delegate ();
4213 h
->nve_groups_un
[afi
].delegate
= route_table_get_default_delegate ();
4215 h
->default_response_lifetime
= BGP_VNC_DEFAULT_RESPONSE_LIFETIME_DEFAULT
;
4216 h
->rfg_export_direct_bgp_l
= list_new ();
4217 h
->rfg_export_zebra_l
= list_new ();
4218 h
->resolve_nve_roo_local_admin
=
4219 BGP_VNC_CONFIG_RESOLVE_NVE_ROO_LOCAL_ADMIN_DEFAULT
;
4221 SET_FLAG (h
->flags
, BGP_VNC_CONFIG_FLAGS_DEFAULT
);
4225 h
->rfp_cfg
.download_type
= RFAPI_RFP_DOWNLOAD_PARTIAL
;
4226 h
->rfp_cfg
.ftd_advertisement_interval
=
4227 RFAPI_RFP_CFG_DEFAULT_FTD_ADVERTISEMENT_INTERVAL
;
4228 h
->rfp_cfg
.holddown_factor
= RFAPI_RFP_CFG_DEFAULT_HOLDDOWN_FACTOR
;
4229 h
->rfp_cfg
.use_updated_response
= 0;
4230 h
->rfp_cfg
.use_removes
= 0;
4234 h
->rfp_cfg
.download_type
= cfg
->download_type
;
4235 h
->rfp_cfg
.ftd_advertisement_interval
= cfg
->ftd_advertisement_interval
;
4236 h
->rfp_cfg
.holddown_factor
= cfg
->holddown_factor
;
4237 h
->rfp_cfg
.use_updated_response
= cfg
->use_updated_response
;
4238 h
->rfp_cfg
.use_removes
= cfg
->use_removes
;
4239 if (cfg
->use_updated_response
)
4240 h
->flags
&= ~BGP_VNC_CONFIG_CALLBACK_DISABLE
;
4242 h
->flags
|= BGP_VNC_CONFIG_CALLBACK_DISABLE
;
4243 if (cfg
->use_removes
)
4244 h
->flags
&= ~BGP_VNC_CONFIG_RESPONSE_REMOVAL_DISABLE
;
4246 h
->flags
|= BGP_VNC_CONFIG_RESPONSE_REMOVAL_DISABLE
;
4252 bgp_rfapi_cfg_destroy (struct bgp
*bgp
, struct rfapi_cfg
*h
)
4257 bgp_rfapi_delete_named_nve_group (NULL
, bgp
, NULL
, RFAPI_GROUP_CFG_MAX
);
4258 bgp_rfapi_delete_named_l2_group (NULL
, bgp
, NULL
);
4259 if (h
->l2_groups
!= NULL
)
4260 list_delete (h
->l2_groups
);
4261 list_delete (h
->nve_groups_sequential
);
4262 list_delete (h
->rfg_export_direct_bgp_l
);
4263 list_delete (h
->rfg_export_zebra_l
);
4264 if (h
->default_rt_export_list
)
4265 ecommunity_free (&h
->default_rt_export_list
);
4266 if (h
->default_rt_import_list
)
4267 ecommunity_free (&h
->default_rt_import_list
);
4268 if (h
->default_rfp_cfg
)
4269 XFREE (MTYPE_RFAPI_RFP_GROUP_CFG
, h
->default_rfp_cfg
);
4270 XFREE (MTYPE_RFAPI_CFG
, h
);
4275 bgp_rfapi_cfg_write (struct vty
*vty
, struct bgp
*bgp
)
4277 struct listnode
*node
, *nnode
;
4278 struct rfapi_nve_group_cfg
*rfg
;
4279 struct rfapi_cfg
*hc
= bgp
->rfapi_cfg
;
4280 struct rfapi_rfg_name
*rfgn
;
4285 vty_out (vty
, "!%s", VTY_NEWLINE
);
4286 for (ALL_LIST_ELEMENTS (hc
->nve_groups_sequential
, node
, nnode
, rfg
))
4287 if (rfg
->type
== RFAPI_GROUP_CFG_VRF
)
4290 vty_out (vty
, " vrf-policy %s%s", rfg
->name
, VTY_NEWLINE
);
4291 if (rfg
->label
<= MPLS_LABEL_MAX
)
4293 vty_out (vty
, " label %u%s", rfg
->label
, VTY_NEWLINE
);
4296 if (CHECK_FLAG (rfg
->flags
, RFAPI_RFG_VPN_NH_SELF
))
4298 vty_out (vty
, " nexthop self%s", VTY_NEWLINE
);
4303 if (rfg
->vn_prefix
.family
)
4306 buf
[0] = buf
[BUFSIZ
- 1] = 0;
4307 inet_ntop(rfg
->vn_prefix
.family
, &rfg
->vn_prefix
.u
.prefix
, buf
, sizeof(buf
));
4308 if (!buf
[0] || buf
[BUFSIZ
- 1])
4310 //vty_out (vty, "nexthop self%s", VTY_NEWLINE);
4314 vty_out (vty
, " nexthop %s%s", buf
, VTY_NEWLINE
);
4319 if (rfg
->rd
.prefixlen
)
4322 buf
[0] = buf
[BUFSIZ
- 1] = 0;
4324 if (AF_UNIX
== rfg
->rd
.family
)
4329 value
= ((rfg
->rd
.val
[6] << 8) & 0x0ff00) |
4330 (rfg
->rd
.val
[7] & 0x0ff);
4332 vty_out (vty
, " rd auto:nh:%d%s", value
, VTY_NEWLINE
);
4338 if (!prefix_rd2str (&rfg
->rd
, buf
, BUFSIZ
) ||
4339 !buf
[0] || buf
[BUFSIZ
- 1])
4342 vty_out (vty
, "!Error: Can't convert rd%s", VTY_NEWLINE
);
4346 vty_out (vty
, " rd %s%s", buf
, VTY_NEWLINE
);
4351 if (rfg
->rt_import_list
&& rfg
->rt_export_list
&&
4352 ecommunity_cmp (rfg
->rt_import_list
, rfg
->rt_export_list
))
4354 char *b
= ecommunity_ecom2str (rfg
->rt_import_list
,
4355 ECOMMUNITY_FORMAT_ROUTE_MAP
, ECOMMUNITY_ROUTE_TARGET
);
4356 vty_out (vty
, " rt both %s%s", b
, VTY_NEWLINE
);
4357 XFREE (MTYPE_ECOMMUNITY_STR
, b
);
4361 if (rfg
->rt_import_list
)
4363 char *b
= ecommunity_ecom2str (rfg
->rt_import_list
,
4364 ECOMMUNITY_FORMAT_ROUTE_MAP
, ECOMMUNITY_ROUTE_TARGET
);
4365 vty_out (vty
, " rt import %s%s", b
, VTY_NEWLINE
);
4366 XFREE (MTYPE_ECOMMUNITY_STR
, b
);
4368 if (rfg
->rt_export_list
)
4370 char *b
= ecommunity_ecom2str (rfg
->rt_export_list
,
4371 ECOMMUNITY_FORMAT_ROUTE_MAP
, ECOMMUNITY_ROUTE_TARGET
);
4372 vty_out (vty
, " rt export %s%s", b
, VTY_NEWLINE
);
4373 XFREE (MTYPE_ECOMMUNITY_STR
, b
);
4378 * route filtering: prefix-lists and route-maps
4380 for (afi
= AFI_IP
; afi
< AFI_MAX
; ++afi
)
4383 const char *afistr
= (afi
== AFI_IP
) ? "ipv4" : "ipv6";
4385 if (rfg
->plist_export_bgp_name
[afi
])
4387 vty_out (vty
, " export bgp %s prefix-list %s%s",
4388 afistr
, rfg
->plist_export_bgp_name
[afi
],
4391 if (rfg
->plist_export_zebra_name
[afi
])
4393 vty_out (vty
, " export zebra %s prefix-list %s%s",
4394 afistr
, rfg
->plist_export_zebra_name
[afi
],
4398 * currently we only support redist plists for bgp-direct.
4399 * If we later add plist support for redistributing other
4400 * protocols, we'll need to loop over protocols here
4402 if (rfg
->plist_redist_name
[ZEBRA_ROUTE_BGP_DIRECT
][afi
])
4404 vty_out (vty
, " redistribute bgp-direct %s prefix-list %s%s",
4406 rfg
->plist_redist_name
[ZEBRA_ROUTE_BGP_DIRECT
][afi
],
4409 if (rfg
->plist_redist_name
[ZEBRA_ROUTE_BGP_DIRECT_EXT
][afi
])
4412 " redistribute bgp-direct-to-nve-groups %s prefix-list %s%s",
4414 rfg
->plist_redist_name
[ZEBRA_ROUTE_BGP_DIRECT_EXT
]
4415 [afi
], VTY_NEWLINE
);
4419 if (rfg
->routemap_export_bgp_name
)
4421 vty_out (vty
, " export bgp route-map %s%s",
4422 rfg
->routemap_export_bgp_name
, VTY_NEWLINE
);
4424 if (rfg
->routemap_export_zebra_name
)
4426 vty_out (vty
, " export zebra route-map %s%s",
4427 rfg
->routemap_export_zebra_name
, VTY_NEWLINE
);
4429 if (rfg
->routemap_redist_name
[ZEBRA_ROUTE_BGP_DIRECT
])
4431 vty_out (vty
, " redistribute bgp-direct route-map %s%s",
4432 rfg
->routemap_redist_name
[ZEBRA_ROUTE_BGP_DIRECT
],
4435 if (rfg
->routemap_redist_name
[ZEBRA_ROUTE_BGP_DIRECT_EXT
])
4438 " redistribute bgp-direct-to-nve-groups route-map %s%s",
4439 rfg
->routemap_redist_name
[ZEBRA_ROUTE_BGP_DIRECT_EXT
],
4442 vty_out (vty
, " exit-vrf-policy%s", VTY_NEWLINE
);
4443 vty_out (vty
, "!%s", VTY_NEWLINE
);
4445 if (hc
->flags
& BGP_VNC_CONFIG_ADV_UN_METHOD_ENCAP
)
4447 vty_out (vty
, " vnc advertise-un-method encap-safi%s", VTY_NEWLINE
);
4451 { /* was based on listen ports */
4452 /* for now allow both old and new */
4453 if (bgp
->rfapi
->rfp_methods
.cfg_cb
)
4454 write
+= (bgp
->rfapi
->rfp_methods
.cfg_cb
) (vty
, bgp
->rfapi
->rfp
);
4457 vty_out (vty
, "!%s", VTY_NEWLINE
);
4461 struct rfapi_l2_group_cfg
*rfg
= NULL
;
4462 struct listnode
*gnode
;
4463 for (ALL_LIST_ELEMENTS_RO (hc
->l2_groups
, gnode
, rfg
))
4465 struct listnode
*lnode
;
4468 vty_out (vty
, " vnc l2-group %s%s", rfg
->name
, VTY_NEWLINE
);
4469 if (rfg
->logical_net_id
!= 0)
4470 vty_out (vty
, " logical-network-id %u%s", rfg
->logical_net_id
,
4472 if (rfg
->labels
!= NULL
&& listhead (rfg
->labels
) != NULL
)
4474 vty_out (vty
, " labels ");
4475 for (ALL_LIST_ELEMENTS_RO (rfg
->labels
, lnode
, data
))
4477 vty_out (vty
, "%hu ", (uint16_t) ((uintptr_t) data
));
4479 vty_out (vty
, "%s", VTY_NEWLINE
);
4482 if (rfg
->rt_import_list
&& rfg
->rt_export_list
&&
4483 ecommunity_cmp (rfg
->rt_import_list
, rfg
->rt_export_list
))
4485 char *b
= ecommunity_ecom2str (rfg
->rt_import_list
,
4486 ECOMMUNITY_FORMAT_ROUTE_MAP
, ECOMMUNITY_ROUTE_TARGET
);
4487 vty_out (vty
, " rt both %s%s", b
, VTY_NEWLINE
);
4488 XFREE (MTYPE_ECOMMUNITY_STR
, b
);
4492 if (rfg
->rt_import_list
)
4494 char *b
= ecommunity_ecom2str (rfg
->rt_import_list
,
4495 ECOMMUNITY_FORMAT_ROUTE_MAP
, ECOMMUNITY_ROUTE_TARGET
);
4496 vty_out (vty
, " rt import %s%s", b
, VTY_NEWLINE
);
4497 XFREE (MTYPE_ECOMMUNITY_STR
, b
);
4499 if (rfg
->rt_export_list
)
4501 char *b
= ecommunity_ecom2str (rfg
->rt_export_list
,
4502 ECOMMUNITY_FORMAT_ROUTE_MAP
, ECOMMUNITY_ROUTE_TARGET
);
4503 vty_out (vty
, " rt export %s%s", b
, VTY_NEWLINE
);
4504 XFREE (MTYPE_ECOMMUNITY_STR
, b
);
4507 if (bgp
->rfapi
->rfp_methods
.cfg_group_cb
)
4509 (bgp
->rfapi
->rfp_methods
.cfg_group_cb
) (vty
,
4511 RFAPI_RFP_CFG_GROUP_L2
,
4514 vty_out (vty
, " exit-vnc%s", VTY_NEWLINE
);
4515 vty_out (vty
, "!%s", VTY_NEWLINE
);
4519 if (hc
->default_rd
.family
||
4520 hc
->default_response_lifetime
||
4521 hc
->default_rt_import_list
||
4522 hc
->default_rt_export_list
|| hc
->nve_groups_sequential
->count
)
4527 vty_out (vty
, " vnc defaults%s", VTY_NEWLINE
);
4529 if (hc
->default_rd
.prefixlen
)
4532 buf
[0] = buf
[BUFSIZ
- 1] = 0;
4534 if (AF_UNIX
== hc
->default_rd
.family
)
4538 value
= ((hc
->default_rd
.val
[6] << 8) & 0x0ff00) |
4539 (hc
->default_rd
.val
[7] & 0x0ff);
4541 vty_out (vty
, " rd auto:vn:%d%s", value
, VTY_NEWLINE
);
4547 if (!prefix_rd2str (&hc
->default_rd
, buf
, BUFSIZ
) ||
4548 !buf
[0] || buf
[BUFSIZ
- 1])
4551 vty_out (vty
, "!Error: Can't convert rd%s", VTY_NEWLINE
);
4555 vty_out (vty
, " rd %s%s", buf
, VTY_NEWLINE
);
4559 if (hc
->default_response_lifetime
)
4561 vty_out (vty
, " response-lifetime ");
4562 if (hc
->default_response_lifetime
!= UINT32_MAX
)
4563 vty_out (vty
, "%d", hc
->default_response_lifetime
);
4565 vty_out (vty
, "infinite");
4566 vty_out (vty
, "%s", VTY_NEWLINE
);
4568 if (hc
->default_rt_import_list
&& hc
->default_rt_export_list
&&
4569 ecommunity_cmp (hc
->default_rt_import_list
,
4570 hc
->default_rt_export_list
))
4572 char *b
= ecommunity_ecom2str (hc
->default_rt_import_list
,
4573 ECOMMUNITY_FORMAT_ROUTE_MAP
, ECOMMUNITY_ROUTE_TARGET
);
4574 vty_out (vty
, " rt both %s%s", b
, VTY_NEWLINE
);
4575 XFREE (MTYPE_ECOMMUNITY_STR
, b
);
4579 if (hc
->default_rt_import_list
)
4581 char *b
= ecommunity_ecom2str (hc
->default_rt_import_list
,
4582 ECOMMUNITY_FORMAT_ROUTE_MAP
, ECOMMUNITY_ROUTE_TARGET
);
4583 vty_out (vty
, " rt import %s%s", b
, VTY_NEWLINE
);
4584 XFREE (MTYPE_ECOMMUNITY_STR
, b
);
4586 if (hc
->default_rt_export_list
)
4588 char *b
= ecommunity_ecom2str (hc
->default_rt_export_list
,
4589 ECOMMUNITY_FORMAT_ROUTE_MAP
, ECOMMUNITY_ROUTE_TARGET
);
4590 vty_out (vty
, " rt export %s%s", b
, VTY_NEWLINE
);
4591 XFREE (MTYPE_ECOMMUNITY_STR
, b
);
4594 if (bgp
->rfapi
->rfp_methods
.cfg_group_cb
)
4596 (bgp
->rfapi
->rfp_methods
.cfg_group_cb
) (vty
,
4598 RFAPI_RFP_CFG_GROUP_DEFAULT
,
4600 bgp
->rfapi_cfg
->default_rfp_cfg
);
4601 vty_out (vty
, " exit-vnc%s", VTY_NEWLINE
);
4602 vty_out (vty
, "!%s", VTY_NEWLINE
);
4605 for (ALL_LIST_ELEMENTS (hc
->nve_groups_sequential
, node
, nnode
, rfg
))
4606 if (rfg
->type
== RFAPI_GROUP_CFG_NVE
)
4609 vty_out (vty
, " vnc nve-group %s%s", rfg
->name
, VTY_NEWLINE
);
4611 if (rfg
->vn_prefix
.family
&& rfg
->vn_node
)
4614 buf
[0] = buf
[BUFSIZ
- 1] = 0;
4616 prefix2str (&rfg
->vn_prefix
, buf
, BUFSIZ
);
4617 if (!buf
[0] || buf
[BUFSIZ
- 1])
4619 vty_out (vty
, "!Error: Can't convert prefix%s", VTY_NEWLINE
);
4623 vty_out (vty
, " prefix %s %s%s", "vn", buf
, VTY_NEWLINE
);
4627 if (rfg
->un_prefix
.family
&& rfg
->un_node
)
4630 buf
[0] = buf
[BUFSIZ
- 1] = 0;
4631 prefix2str (&rfg
->un_prefix
, buf
, BUFSIZ
);
4632 if (!buf
[0] || buf
[BUFSIZ
- 1])
4634 vty_out (vty
, "!Error: Can't convert prefix%s", VTY_NEWLINE
);
4638 vty_out (vty
, " prefix %s %s%s", "un", buf
, VTY_NEWLINE
);
4643 if (rfg
->rd
.prefixlen
)
4646 buf
[0] = buf
[BUFSIZ
- 1] = 0;
4648 if (AF_UNIX
== rfg
->rd
.family
)
4653 value
= ((rfg
->rd
.val
[6] << 8) & 0x0ff00) |
4654 (rfg
->rd
.val
[7] & 0x0ff);
4656 vty_out (vty
, " rd auto:vn:%d%s", value
, VTY_NEWLINE
);
4662 if (!prefix_rd2str (&rfg
->rd
, buf
, BUFSIZ
) ||
4663 !buf
[0] || buf
[BUFSIZ
- 1])
4666 vty_out (vty
, "!Error: Can't convert rd%s", VTY_NEWLINE
);
4670 vty_out (vty
, " rd %s%s", buf
, VTY_NEWLINE
);
4674 if (rfg
->flags
& RFAPI_RFG_RESPONSE_LIFETIME
)
4676 vty_out (vty
, " response-lifetime ");
4677 if (rfg
->response_lifetime
!= UINT32_MAX
)
4678 vty_out (vty
, "%d", rfg
->response_lifetime
);
4680 vty_out (vty
, "infinite");
4681 vty_out (vty
, "%s", VTY_NEWLINE
);
4684 if (rfg
->rt_import_list
&& rfg
->rt_export_list
&&
4685 ecommunity_cmp (rfg
->rt_import_list
, rfg
->rt_export_list
))
4687 char *b
= ecommunity_ecom2str (rfg
->rt_import_list
,
4688 ECOMMUNITY_FORMAT_ROUTE_MAP
,
4689 ECOMMUNITY_ROUTE_TARGET
);
4690 vty_out (vty
, " rt both %s%s", b
, VTY_NEWLINE
);
4691 XFREE (MTYPE_ECOMMUNITY_STR
, b
);
4695 if (rfg
->rt_import_list
)
4697 char *b
= ecommunity_ecom2str (rfg
->rt_import_list
,
4698 ECOMMUNITY_FORMAT_ROUTE_MAP
,
4699 ECOMMUNITY_ROUTE_TARGET
);
4700 vty_out (vty
, " rt import %s%s", b
, VTY_NEWLINE
);
4701 XFREE (MTYPE_ECOMMUNITY_STR
, b
);
4703 if (rfg
->rt_export_list
)
4705 char *b
= ecommunity_ecom2str (rfg
->rt_export_list
,
4706 ECOMMUNITY_FORMAT_ROUTE_MAP
, ECOMMUNITY_ROUTE_TARGET
);
4707 vty_out (vty
, " rt export %s%s", b
, VTY_NEWLINE
);
4708 XFREE (MTYPE_ECOMMUNITY_STR
, b
);
4713 * route filtering: prefix-lists and route-maps
4715 for (afi
= AFI_IP
; afi
< AFI_MAX
; ++afi
)
4718 const char *afistr
= (afi
== AFI_IP
) ? "ipv4" : "ipv6";
4720 if (rfg
->plist_export_bgp_name
[afi
])
4722 vty_out (vty
, " export bgp %s prefix-list %s%s",
4723 afistr
, rfg
->plist_export_bgp_name
[afi
],
4726 if (rfg
->plist_export_zebra_name
[afi
])
4728 vty_out (vty
, " export zebra %s prefix-list %s%s",
4729 afistr
, rfg
->plist_export_zebra_name
[afi
],
4733 * currently we only support redist plists for bgp-direct.
4734 * If we later add plist support for redistributing other
4735 * protocols, we'll need to loop over protocols here
4737 if (rfg
->plist_redist_name
[ZEBRA_ROUTE_BGP_DIRECT
][afi
])
4739 vty_out (vty
, " redistribute bgp-direct %s prefix-list %s%s",
4741 rfg
->plist_redist_name
[ZEBRA_ROUTE_BGP_DIRECT
][afi
],
4744 if (rfg
->plist_redist_name
[ZEBRA_ROUTE_BGP_DIRECT_EXT
][afi
])
4747 " redistribute bgp-direct-to-nve-groups %s prefix-list %s%s",
4749 rfg
->plist_redist_name
[ZEBRA_ROUTE_BGP_DIRECT_EXT
]
4750 [afi
], VTY_NEWLINE
);
4754 if (rfg
->routemap_export_bgp_name
)
4756 vty_out (vty
, " export bgp route-map %s%s",
4757 rfg
->routemap_export_bgp_name
, VTY_NEWLINE
);
4759 if (rfg
->routemap_export_zebra_name
)
4761 vty_out (vty
, " export zebra route-map %s%s",
4762 rfg
->routemap_export_zebra_name
, VTY_NEWLINE
);
4764 if (rfg
->routemap_redist_name
[ZEBRA_ROUTE_BGP_DIRECT
])
4766 vty_out (vty
, " redistribute bgp-direct route-map %s%s",
4767 rfg
->routemap_redist_name
[ZEBRA_ROUTE_BGP_DIRECT
],
4770 if (rfg
->routemap_redist_name
[ZEBRA_ROUTE_BGP_DIRECT_EXT
])
4773 " redistribute bgp-direct-to-nve-groups route-map %s%s",
4774 rfg
->routemap_redist_name
[ZEBRA_ROUTE_BGP_DIRECT_EXT
],
4777 if (bgp
->rfapi
->rfp_methods
.cfg_group_cb
)
4779 (bgp
->rfapi
->rfp_methods
.cfg_group_cb
) (vty
,
4781 RFAPI_RFP_CFG_GROUP_NVE
,
4782 rfg
->name
, rfg
->rfp_cfg
);
4783 vty_out (vty
, " exit-vnc%s", VTY_NEWLINE
);
4784 vty_out (vty
, "!%s", VTY_NEWLINE
);
4786 } /* have listen ports */
4789 * route export to other protocols
4791 if (VNC_EXPORT_BGP_GRP_ENABLED (hc
))
4793 vty_out (vty
, " vnc export bgp mode group-nve%s", VTY_NEWLINE
);
4795 else if (VNC_EXPORT_BGP_RH_ENABLED (hc
))
4797 vty_out (vty
, " vnc export bgp mode registering-nve%s", VTY_NEWLINE
);
4799 else if (VNC_EXPORT_BGP_CE_ENABLED (hc
))
4801 vty_out (vty
, " vnc export bgp mode ce%s", VTY_NEWLINE
);
4804 if (VNC_EXPORT_ZEBRA_GRP_ENABLED (hc
))
4806 vty_out (vty
, " vnc export zebra mode group-nve%s", VTY_NEWLINE
);
4808 else if (VNC_EXPORT_ZEBRA_RH_ENABLED (hc
))
4810 vty_out (vty
, " vnc export zebra mode registering-nve%s", VTY_NEWLINE
);
4813 if (hc
->rfg_export_direct_bgp_l
)
4815 for (ALL_LIST_ELEMENTS (hc
->rfg_export_direct_bgp_l
, node
, nnode
, rfgn
))
4818 vty_out (vty
, " vnc export bgp group-nve group %s%s",
4819 rfgn
->name
, VTY_NEWLINE
);
4823 if (hc
->rfg_export_zebra_l
)
4825 for (ALL_LIST_ELEMENTS (hc
->rfg_export_zebra_l
, node
, nnode
, rfgn
))
4828 vty_out (vty
, " vnc export zebra group-nve group %s%s",
4829 rfgn
->name
, VTY_NEWLINE
);
4834 if (hc
->rfg_redist_name
)
4836 vty_out (vty
, " vnc redistribute nve-group %s%s",
4837 hc
->rfg_redist_name
, VTY_NEWLINE
);
4839 if (hc
->redist_lifetime
)
4841 vty_out (vty
, " vnc redistribute lifetime %d%s",
4842 hc
->redist_lifetime
, VTY_NEWLINE
);
4844 if (hc
->resolve_nve_roo_local_admin
!=
4845 BGP_VNC_CONFIG_RESOLVE_NVE_ROO_LOCAL_ADMIN_DEFAULT
)
4848 vty_out (vty
, " vnc redistribute resolve-nve roo-ec-local-admin %d%s",
4849 hc
->resolve_nve_roo_local_admin
, VTY_NEWLINE
);
4852 if (hc
->redist_mode
) /* ! default */
4856 switch (hc
->redist_mode
)
4858 case VNC_REDIST_MODE_PLAIN
:
4861 case VNC_REDIST_MODE_RFG
:
4864 case VNC_REDIST_MODE_RESOLVE_NVE
:
4870 vty_out (vty
, " vnc redistribute mode %s%s", s
, VTY_NEWLINE
);
4875 * route filtering: prefix-lists and route-maps
4877 for (afi
= AFI_IP
; afi
< AFI_MAX
; ++afi
)
4880 const char *afistr
= (afi
== AFI_IP
) ? "ipv4" : "ipv6";
4882 if (hc
->plist_export_bgp_name
[afi
])
4884 vty_out (vty
, " vnc export bgp %s prefix-list %s%s",
4885 afistr
, hc
->plist_export_bgp_name
[afi
], VTY_NEWLINE
);
4887 if (hc
->plist_export_zebra_name
[afi
])
4889 vty_out (vty
, " vnc export zebra %s prefix-list %s%s",
4890 afistr
, hc
->plist_export_zebra_name
[afi
], VTY_NEWLINE
);
4892 if (hc
->plist_redist_name
[ZEBRA_ROUTE_BGP_DIRECT
][afi
])
4894 vty_out (vty
, " vnc redistribute bgp-direct %s prefix-list %s%s",
4895 afistr
, hc
->plist_redist_name
[ZEBRA_ROUTE_BGP_DIRECT
][afi
],
4900 if (hc
->routemap_export_bgp_name
)
4902 vty_out (vty
, " vnc export bgp route-map %s%s",
4903 hc
->routemap_export_bgp_name
, VTY_NEWLINE
);
4905 if (hc
->routemap_export_zebra_name
)
4907 vty_out (vty
, " vnc export zebra route-map %s%s",
4908 hc
->routemap_export_zebra_name
, VTY_NEWLINE
);
4910 if (hc
->routemap_redist_name
[ZEBRA_ROUTE_BGP_DIRECT
])
4912 vty_out (vty
, " vnc redistribute bgp-direct route-map %s%s",
4913 hc
->routemap_redist_name
[ZEBRA_ROUTE_BGP_DIRECT
], VTY_NEWLINE
);
4916 for (afi
= AFI_IP
; afi
< AFI_MAX
; ++afi
)
4918 for (type
= 0; type
< ZEBRA_ROUTE_MAX
; ++type
)
4920 if (hc
->redist
[afi
][type
])
4922 if (type
== ZEBRA_ROUTE_BGP_DIRECT_EXT
&&
4923 hc
->redist_bgp_exterior_view_name
)
4925 vty_out (vty
, " vnc redistribute %s %s view %s%s",
4926 ((afi
== AFI_IP
) ? "ipv4" : "ipv6"),
4927 zebra_route_string (type
),
4928 hc
->redist_bgp_exterior_view_name
, VTY_NEWLINE
);
4932 vty_out (vty
, " vnc redistribute %s %s%s",
4933 ((afi
== AFI_IP
) ? "ipv4" : "ipv6"),
4934 zebra_route_string (type
), VTY_NEWLINE
);
4943 bgp_rfapi_show_summary (struct bgp
*bgp
, struct vty
*vty
)
4945 struct rfapi_cfg
*hc
= bgp
->rfapi_cfg
;
4946 int afi
, type
, redist
= 0;
4951 vty_out (vty
, "%-39s %-19s %s%s", "VNC Advertise method:",
4952 (hc
->flags
& BGP_VNC_CONFIG_ADV_UN_METHOD_ENCAP
4953 ? "Encapsulation SAFI" : "Tunnel Encap attribute"),
4954 ((hc
->flags
& BGP_VNC_CONFIG_ADV_UN_METHOD_ENCAP
) ==
4955 (BGP_VNC_CONFIG_ADV_UN_METHOD_ENCAP
&
4956 BGP_VNC_CONFIG_FLAGS_DEFAULT
) ? "(default)" : ""), VTY_NEWLINE
);
4958 vty_out (vty
, "%-39s ", "Export from VNC:");
4960 * route export to other protocols
4962 if (VNC_EXPORT_BGP_GRP_ENABLED (hc
))
4965 vty_out (vty
, "ToBGP Groups={");
4966 if (hc
->rfg_export_direct_bgp_l
)
4969 struct listnode
*node
, *nnode
;
4970 struct rfapi_rfg_name
*rfgn
;
4971 for (ALL_LIST_ELEMENTS (hc
->rfg_export_direct_bgp_l
,
4977 vty_out (vty
, "%s", rfgn
->name
);
4982 else if (VNC_EXPORT_BGP_RH_ENABLED (hc
))
4985 vty_out (vty
, "ToBGP {Registering NVE}");
4986 /* note filters, route-maps not shown */
4988 else if (VNC_EXPORT_BGP_CE_ENABLED (hc
))
4991 vty_out (vty
, "ToBGP {NVE connected router:%d}",
4992 hc
->resolve_nve_roo_local_admin
);
4993 /* note filters, route-maps not shown */
4996 if (VNC_EXPORT_ZEBRA_GRP_ENABLED (hc
))
4999 vty_out (vty
, "%sToZebra Groups={", (redist
== 1 ? "" : " "));
5000 if (hc
->rfg_export_direct_bgp_l
)
5003 struct listnode
*node
, *nnode
;
5004 struct rfapi_rfg_name
*rfgn
;
5005 for (ALL_LIST_ELEMENTS (hc
->rfg_export_zebra_l
, node
, nnode
, rfgn
))
5009 vty_out (vty
, "%s", rfgn
->name
);
5014 else if (VNC_EXPORT_ZEBRA_RH_ENABLED (hc
))
5017 vty_out (vty
, "%sToZebra {Registering NVE}", (redist
== 1 ? "" : " "));
5018 /* note filters, route-maps not shown */
5020 vty_out (vty
, "%-19s %s%s", (redist
? "" : "Off"),
5021 (redist
? "" : "(default)"), VTY_NEWLINE
);
5023 /* Redistribution */
5025 vty_out (vty
, "%-39s ", "Redistribution into VNC:");
5026 for (afi
= AFI_IP
; afi
< AFI_MAX
; ++afi
)
5028 for (type
= 0; type
< ZEBRA_ROUTE_MAX
; ++type
)
5030 if (hc
->redist
[afi
][type
])
5032 vty_out (vty
, "{%s,%s} ",
5033 ((afi
== AFI_IP
) ? "ipv4" : "ipv6"),
5034 zebra_route_string (type
));
5039 vty_out (vty
, "%-19s %s%s", (redist
? "" : "Off"),
5040 (redist
? "" : "(default)"), VTY_NEWLINE
);
5042 vty_out (vty
, "%-39s %3u%-16s %s%s", "RFP Registration Hold-Down Factor:",
5043 hc
->rfp_cfg
.holddown_factor
, "%",
5044 (hc
->rfp_cfg
.holddown_factor
==
5045 RFAPI_RFP_CFG_DEFAULT_HOLDDOWN_FACTOR
? "(default)" : ""),
5047 vty_out (vty
, "%-39s %-19s %s%s", "RFP Updated responses:",
5048 (hc
->rfp_cfg
.use_updated_response
== 0 ? "Off" : "On"),
5049 (hc
->rfp_cfg
.use_updated_response
== 0 ? "(default)" : ""),
5051 vty_out (vty
, "%-39s %-19s %s%s", "RFP Removal responses:",
5052 (hc
->rfp_cfg
.use_removes
== 0 ? "Off" : "On"),
5053 (hc
->rfp_cfg
.use_removes
== 0 ? "(default)" : ""), VTY_NEWLINE
);
5054 vty_out (vty
, "%-39s %-19s %s%s", "RFP Full table download:",
5055 (hc
->rfp_cfg
.download_type
==
5056 RFAPI_RFP_DOWNLOAD_FULL
? "On" : "Off"),
5057 (hc
->rfp_cfg
.download_type
==
5058 RFAPI_RFP_DOWNLOAD_PARTIAL
? "(default)" : ""), VTY_NEWLINE
);
5059 sprintf (tmp
, "%u seconds", hc
->rfp_cfg
.ftd_advertisement_interval
);
5060 vty_out (vty
, "%-39s %-19s %s%s", " Advertisement Interval:", tmp
,
5061 (hc
->rfp_cfg
.ftd_advertisement_interval
==
5062 RFAPI_RFP_CFG_DEFAULT_FTD_ADVERTISEMENT_INTERVAL
5063 ? "(default)" : ""), VTY_NEWLINE
);
5064 vty_out (vty
, "%-39s %d seconds%s", "Default RFP response lifetime:",
5065 hc
->default_response_lifetime
, VTY_NEWLINE
);
5066 vty_out (vty
, "%s", VTY_NEWLINE
);
5071 bgp_rfapi_get_config (struct bgp
*bgp
)
5073 struct rfapi_cfg
*hc
= NULL
;
5075 bgp
= bgp_get_default ();
5077 hc
= bgp
->rfapi_cfg
;
5081 #endif /* ENABLE_BGP_VNC */