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_mplsvpn.h"
34 #include "bgpd/bgp_route.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 *-----------------------------------------------------------------------*/
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
,
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
,
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
,
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 static struct rfapi_nve_group_cfg
*
565 rfapi_group_lookup_byname (struct bgp
*bgp
, const char *name
)
567 struct rfapi_nve_group_cfg
*rfg
;
568 struct listnode
*node
, *nnode
;
570 for (ALL_LIST_ELEMENTS
571 (bgp
->rfapi_cfg
->nve_groups_sequential
, node
, nnode
, rfg
))
573 if (!strcmp (rfg
->name
, name
))
579 static struct rfapi_nve_group_cfg
*
582 struct rfapi_nve_group_cfg
*rfg
;
584 rfg
= XCALLOC (MTYPE_RFAPI_GROUP_CFG
, sizeof (struct rfapi_nve_group_cfg
));
585 QOBJ_REG (rfg
, rfapi_nve_group_cfg
);
590 static struct rfapi_l2_group_cfg
*
591 rfapi_l2_group_lookup_byname (struct bgp
*bgp
, const char *name
)
593 struct rfapi_l2_group_cfg
*rfg
;
594 struct listnode
*node
, *nnode
;
596 if (bgp
->rfapi_cfg
->l2_groups
== NULL
) /* not the best place for this */
597 bgp
->rfapi_cfg
->l2_groups
= list_new ();
599 for (ALL_LIST_ELEMENTS (bgp
->rfapi_cfg
->l2_groups
, node
, nnode
, rfg
))
601 if (!strcmp (rfg
->name
, name
))
607 static struct rfapi_l2_group_cfg
*
608 rfapi_l2_group_new ()
610 struct rfapi_l2_group_cfg
*rfg
;
612 rfg
= XCALLOC (MTYPE_RFAPI_L2_CFG
, sizeof (struct rfapi_l2_group_cfg
));
613 QOBJ_REG (rfg
, rfapi_l2_group_cfg
);
619 rfapi_l2_group_del (struct rfapi_l2_group_cfg
*rfg
)
622 XFREE (MTYPE_RFAPI_L2_CFG
, rfg
);
626 rfapi_str2route_type (
635 if (!strcmp (l3str
, "ipv4"))
641 if (!strcmp (l3str
, "ipv6"))
647 if (!strcmp (pstr
, "connected"))
648 *type
= ZEBRA_ROUTE_CONNECT
;
649 if (!strcmp (pstr
, "kernel"))
650 *type
= ZEBRA_ROUTE_KERNEL
;
651 if (!strcmp (pstr
, "static"))
652 *type
= ZEBRA_ROUTE_STATIC
;
653 if (!strcmp (pstr
, "bgp"))
654 *type
= ZEBRA_ROUTE_BGP
;
655 if (!strcmp (pstr
, "bgp-direct"))
656 *type
= ZEBRA_ROUTE_BGP_DIRECT
;
657 if (!strcmp (pstr
, "bgp-direct-to-nve-groups"))
658 *type
= ZEBRA_ROUTE_BGP_DIRECT_EXT
;
660 if (!strcmp (pstr
, "rip"))
663 *type
= ZEBRA_ROUTE_RIP
;
665 *type
= ZEBRA_ROUTE_RIPNG
;
668 if (!strcmp (pstr
, "ripng"))
672 *type
= ZEBRA_ROUTE_RIPNG
;
675 if (!strcmp (pstr
, "ospf"))
678 *type
= ZEBRA_ROUTE_OSPF
;
680 *type
= ZEBRA_ROUTE_OSPF6
;
683 if (!strcmp (pstr
, "ospf6"))
687 *type
= ZEBRA_ROUTE_OSPF6
;
693 /*-------------------------------------------------------------------------
695 *-----------------------------------------------------------------------*/
697 #define VNC_REDIST_ENABLE(bgp, afi, type) do { \
699 case ZEBRA_ROUTE_BGP_DIRECT: \
700 vnc_import_bgp_redist_enable((bgp), (afi)); \
702 case ZEBRA_ROUTE_BGP_DIRECT_EXT: \
703 vnc_import_bgp_exterior_redist_enable((bgp), (afi));\
706 vnc_redistribute_set((bgp), (afi), (type)); \
711 #define VNC_REDIST_DISABLE(bgp, afi, type) do { \
713 case ZEBRA_ROUTE_BGP_DIRECT: \
714 vnc_import_bgp_redist_disable((bgp), (afi)); \
716 case ZEBRA_ROUTE_BGP_DIRECT_EXT: \
717 vnc_import_bgp_exterior_redist_disable((bgp), (afi));\
720 vnc_redistribute_unset((bgp), (afi), (type)); \
725 static uint8_t redist_was_enabled
[AFI_MAX
][ZEBRA_ROUTE_MAX
];
728 vnc_redistribute_prechange (struct bgp
*bgp
)
733 vnc_zlog_debug_verbose ("%s: entry", __func__
);
734 memset (redist_was_enabled
, 0, sizeof (redist_was_enabled
));
737 * Look to see if we have any redistribution enabled. If so, flush
738 * the corresponding routes and turn off redistribution temporarily.
739 * We need to do it because the RD's used for the redistributed
740 * routes depend on the nve group.
742 for (afi
= AFI_IP
; afi
< AFI_MAX
; ++afi
)
744 for (type
= 0; type
< ZEBRA_ROUTE_MAX
; ++type
)
746 if (bgp
->rfapi_cfg
->redist
[afi
][type
])
748 redist_was_enabled
[afi
][type
] = 1;
749 VNC_REDIST_DISABLE (bgp
, afi
, type
);
753 vnc_zlog_debug_verbose ("%s: return", __func__
);
757 vnc_redistribute_postchange (struct bgp
*bgp
)
762 vnc_zlog_debug_verbose ("%s: entry", __func__
);
764 * If we turned off redistribution above, turn it back on. Doing so
765 * will tell zebra to resend the routes to us
767 for (afi
= AFI_IP
; afi
< AFI_MAX
; ++afi
)
769 for (type
= 0; type
< ZEBRA_ROUTE_MAX
; ++type
)
771 if (redist_was_enabled
[afi
][type
])
773 VNC_REDIST_ENABLE (bgp
, afi
, type
);
777 vnc_zlog_debug_verbose ("%s: return", __func__
);
780 DEFUN (vnc_redistribute_rh_roo_localadmin
,
781 vnc_redistribute_rh_roo_localadmin_cmd
,
782 "vnc redistribute resolve-nve roo-ec-local-admin <0-65535>",
784 "Redistribute routes into VNC\n"
786 "Route Origin Extended Community Local Admin Field\n" "Field value\n")
788 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
794 vty_out (vty
, "RFAPI not configured%s", VTY_NEWLINE
);
798 localadmin
= strtoul (argv
[4]->arg
, &endptr
, 0);
799 if (!argv
[4]->arg
[0] || *endptr
)
801 vty_out (vty
, "%% Malformed value%s", VTY_NEWLINE
);
805 if (localadmin
> 0xffff)
807 vty_out (vty
, "%% Value out of range (0-%d)%s", 0xffff, VTY_NEWLINE
);
811 if (bgp
->rfapi_cfg
->resolve_nve_roo_local_admin
== localadmin
)
814 if ((bgp
->rfapi_cfg
->flags
& BGP_VNC_CONFIG_EXPORT_BGP_MODE_BITS
) ==
815 BGP_VNC_CONFIG_EXPORT_BGP_MODE_CE
)
818 vnc_export_bgp_prechange (bgp
);
820 vnc_redistribute_prechange (bgp
);
822 bgp
->rfapi_cfg
->resolve_nve_roo_local_admin
= localadmin
;
824 if ((bgp
->rfapi_cfg
->flags
& BGP_VNC_CONFIG_EXPORT_BGP_MODE_BITS
) ==
825 BGP_VNC_CONFIG_EXPORT_BGP_MODE_CE
)
828 vnc_export_bgp_postchange (bgp
);
830 vnc_redistribute_postchange (bgp
);
836 DEFUN (vnc_redistribute_mode
,
837 vnc_redistribute_mode_cmd
,
838 "vnc redistribute mode (nve-group|plain|resolve-nve)",
840 "Redistribute routes into VNC\n"
841 "Redistribution mode\n"
842 "Based on redistribute nve-group\n"
843 "Unmodified\n" "Resolve each nexthop to connected NVEs\n")
845 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
846 vnc_redist_mode_t newmode
;
850 vty_out (vty
, "RFAPI not configured%s", VTY_NEWLINE
);
855 switch (argv
[3]->arg
[0])
858 newmode
= VNC_REDIST_MODE_RFG
;
862 newmode
= VNC_REDIST_MODE_PLAIN
;
866 newmode
= VNC_REDIST_MODE_RESOLVE_NVE
;
870 vty_out (vty
, "unknown redistribute mode%s", VTY_NEWLINE
);
874 if (newmode
!= bgp
->rfapi_cfg
->redist_mode
)
876 vnc_redistribute_prechange (bgp
);
877 bgp
->rfapi_cfg
->redist_mode
= newmode
;
878 vnc_redistribute_postchange (bgp
);
884 DEFUN (vnc_redistribute_protocol
,
885 vnc_redistribute_protocol_cmd
,
886 "vnc redistribute (ipv4|ipv6) (bgp|bgp-direct|bgp-direct-to-nve-groups|connected|kernel|ospf|rip|static)",
888 "Redistribute routes into VNC\n"
892 "From BGP without Zebra\n"
893 "From BGP without Zebra, only to configured NVE groups\n"
894 "Connected interfaces\n"
895 "From kernel routes\n"
896 "From Open Shortest Path First (OSPF)\n"
897 "From Routing Information Protocol (RIP)\n" "From Static routes\n")
899 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
900 int type
= ZEBRA_ROUTE_MAX
; /* init to bogus value */
905 vty_out (vty
, "RFAPI not configured%s", VTY_NEWLINE
);
909 if (rfapi_str2route_type (argv
[2]->arg
, argv
[3]->arg
, &afi
, &type
))
911 vty_out (vty
, "%% Invalid route type%s", VTY_NEWLINE
);
915 if (type
== ZEBRA_ROUTE_BGP_DIRECT_EXT
)
917 if (bgp
->rfapi_cfg
->redist_bgp_exterior_view_name
)
919 VNC_REDIST_DISABLE (bgp
, afi
, type
); /* disabled view implicitly */
920 free (bgp
->rfapi_cfg
->redist_bgp_exterior_view_name
);
921 bgp
->rfapi_cfg
->redist_bgp_exterior_view_name
= NULL
;
923 bgp
->rfapi_cfg
->redist_bgp_exterior_view
= bgp
;
926 VNC_REDIST_ENABLE (bgp
, afi
, type
);
931 DEFUN (vnc_no_redistribute_protocol
,
932 vnc_no_redistribute_protocol_cmd
,
933 "no vnc redistribute (ipv4|ipv6) (bgp|bgp-direct|bgp-direct-to-nve-groups|connected|kernel|ospf|rip|static)",
936 "Redistribute from other protocol\n"
940 "From BGP without Zebra\n"
941 "From BGP without Zebra, only to configured NVE groups\n"
942 "Connected interfaces\n"
943 "From kernel routes\n"
944 "From Open Shortest Path First (OSPF)\n"
945 "From Routing Information Protocol (RIP)\n" "From Static routes\n")
947 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
953 vty_out (vty
, "RFAPI not configured%s", VTY_NEWLINE
);
957 if (rfapi_str2route_type (argv
[3]->arg
, argv
[4]->arg
, &afi
, &type
))
959 vty_out (vty
, "%% Invalid route type%s", VTY_NEWLINE
);
963 VNC_REDIST_DISABLE (bgp
, afi
, type
);
965 if (type
== ZEBRA_ROUTE_BGP_DIRECT_EXT
)
967 if (bgp
->rfapi_cfg
->redist_bgp_exterior_view_name
)
969 free (bgp
->rfapi_cfg
->redist_bgp_exterior_view_name
);
970 bgp
->rfapi_cfg
->redist_bgp_exterior_view_name
= NULL
;
972 bgp
->rfapi_cfg
->redist_bgp_exterior_view
= NULL
;
978 DEFUN (vnc_redistribute_bgp_exterior
,
979 vnc_redistribute_bgp_exterior_cmd
,
980 "vnc redistribute (ipv4|ipv6) bgp-direct-to-nve-groups view NAME",
982 "Redistribute routes into VNC\n"
985 "From BGP without Zebra, only to configured NVE groups\n"
986 "From BGP view\n" "BGP view name\n")
988 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
994 vty_out (vty
, "RFAPI not configured%s", VTY_NEWLINE
);
998 if (rfapi_str2route_type (argv
[2]->arg
, "bgp-direct-to-nve-groups", &afi
, &type
))
1000 vty_out (vty
, "%% Invalid route type%s", VTY_NEWLINE
);
1004 if (bgp
->rfapi_cfg
->redist_bgp_exterior_view_name
)
1005 free (bgp
->rfapi_cfg
->redist_bgp_exterior_view_name
);
1006 bgp
->rfapi_cfg
->redist_bgp_exterior_view_name
= strdup (argv
[5]->arg
);
1007 /* could be NULL if name is not defined yet */
1008 bgp
->rfapi_cfg
->redist_bgp_exterior_view
= bgp_lookup_by_name (argv
[5]->arg
);
1010 VNC_REDIST_ENABLE (bgp
, afi
, type
);
1015 DEFUN (vnc_redistribute_nvegroup
,
1016 vnc_redistribute_nvegroup_cmd
,
1017 "vnc redistribute nve-group NAME",
1019 "Assign a NVE group to routes redistributed from another routing protocol\n"
1020 "NVE group\n" "Group name\n")
1022 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1024 if (!bgp
->rfapi_cfg
)
1026 vty_out (vty
, "rfapi not configured%s", VTY_NEWLINE
);
1030 vnc_redistribute_prechange (bgp
);
1033 * OK if nve group doesn't exist yet; we'll set the pointer
1034 * when the group is defined later
1036 bgp
->rfapi_cfg
->rfg_redist
= rfapi_group_lookup_byname (bgp
, argv
[3]->arg
);
1037 if (bgp
->rfapi_cfg
->rfg_redist_name
)
1038 free (bgp
->rfapi_cfg
->rfg_redist_name
);
1039 bgp
->rfapi_cfg
->rfg_redist_name
= strdup (argv
[3]->arg
);
1041 vnc_redistribute_postchange (bgp
);
1046 DEFUN (vnc_redistribute_no_nvegroup
,
1047 vnc_redistribute_no_nvegroup_cmd
,
1048 "no vnc redistribute nve-group",
1051 "Redistribute from other protocol\n"
1052 "Assign a NVE group to routes redistributed from another routing protocol\n")
1054 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1056 if (!bgp
->rfapi_cfg
)
1058 vty_out (vty
, "rfapi not configured%s", VTY_NEWLINE
);
1062 vnc_redistribute_prechange (bgp
);
1064 bgp
->rfapi_cfg
->rfg_redist
= NULL
;
1065 if (bgp
->rfapi_cfg
->rfg_redist_name
)
1066 free (bgp
->rfapi_cfg
->rfg_redist_name
);
1067 bgp
->rfapi_cfg
->rfg_redist_name
= NULL
;
1069 vnc_redistribute_postchange (bgp
);
1075 DEFUN (vnc_redistribute_lifetime
,
1076 vnc_redistribute_lifetime_cmd
,
1077 "vnc redistribute lifetime (LIFETIME|infinite)",
1079 "Assign a lifetime to routes redistributed from another routing protocol\n"
1080 "lifetime value (32 bit)\n")
1082 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1084 if (!bgp
->rfapi_cfg
)
1086 vty_out (vty
, "rfapi not configured%s", VTY_NEWLINE
);
1090 vnc_redistribute_prechange (bgp
);
1092 if (!strcmp (argv
[3]->arg
, "infinite"))
1094 bgp
->rfapi_cfg
->redist_lifetime
= RFAPI_INFINITE_LIFETIME
;
1098 VTY_GET_INTEGER ("Response Lifetime", bgp
->rfapi_cfg
->redist_lifetime
,
1102 vnc_redistribute_postchange (bgp
);
1107 /*-- redist policy, non-nvegroup start --*/
1109 DEFUN (vnc_redist_bgpdirect_no_prefixlist
,
1110 vnc_redist_bgpdirect_no_prefixlist_cmd
,
1111 "no vnc redistribute (bgp-direct|bgp-direct-to-nve-groups) (ipv4|ipv6) prefix-list",
1114 "Redistribute from other protocol\n"
1115 "Redistribute from BGP directly\n"
1116 "Redistribute from BGP without Zebra, only to configured NVE groups\n"
1118 "IPv6 routes\n" "Prefix-list for filtering redistributed routes\n")
1120 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1122 struct rfapi_cfg
*hc
;
1123 uint8_t route_type
= 0;
1125 if (!(hc
= bgp
->rfapi_cfg
))
1127 vty_out (vty
, "rfapi not configured%s", VTY_NEWLINE
);
1131 if (!strcmp (argv
[3]->arg
, "bgp-direct"))
1133 route_type
= ZEBRA_ROUTE_BGP_DIRECT
;
1137 route_type
= ZEBRA_ROUTE_BGP_DIRECT_EXT
;
1140 if (!strcmp (argv
[4]->arg
, "ipv4"))
1149 vnc_redistribute_prechange (bgp
);
1151 if (hc
->plist_redist_name
[route_type
][afi
])
1152 free (hc
->plist_redist_name
[route_type
][afi
]);
1153 hc
->plist_redist_name
[route_type
][afi
] = NULL
;
1154 hc
->plist_redist
[route_type
][afi
] = NULL
;
1156 vnc_redistribute_postchange (bgp
);
1161 DEFUN (vnc_redist_bgpdirect_prefixlist
,
1162 vnc_redist_bgpdirect_prefixlist_cmd
,
1163 "vnc redistribute (bgp-direct|bgp-direct-to-nve-groups) (ipv4|ipv6) prefix-list NAME",
1165 "Redistribute from other protocol\n"
1166 "Redistribute from BGP directly\n"
1167 "Redistribute from BGP without Zebra, only to configured NVE groups\n"
1170 "Prefix-list for filtering redistributed routes\n"
1171 "prefix list name\n")
1173 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1174 struct rfapi_cfg
*hc
;
1176 uint8_t route_type
= 0;
1178 if (!(hc
= bgp
->rfapi_cfg
))
1180 vty_out (vty
, "rfapi not configured%s", VTY_NEWLINE
);
1184 if (!strcmp (argv
[2]->arg
, "bgp-direct"))
1186 route_type
= ZEBRA_ROUTE_BGP_DIRECT
;
1190 route_type
= ZEBRA_ROUTE_BGP_DIRECT_EXT
;
1193 if (!strcmp (argv
[3]->arg
, "ipv4"))
1202 vnc_redistribute_prechange (bgp
);
1204 if (hc
->plist_redist_name
[route_type
][afi
])
1205 free (hc
->plist_redist_name
[route_type
][afi
]);
1206 hc
->plist_redist_name
[route_type
][afi
] = strdup (argv
[5]->arg
);
1207 hc
->plist_redist
[route_type
][afi
] = prefix_list_lookup (afi
, argv
[5]->arg
);
1209 vnc_redistribute_postchange (bgp
);
1214 DEFUN (vnc_redist_bgpdirect_no_routemap
,
1215 vnc_redist_bgpdirect_no_routemap_cmd
,
1216 "no vnc redistribute (bgp-direct|bgp-direct-to-nve-groups) route-map",
1219 "Redistribute from other protocols\n"
1220 "Redistribute from BGP directly\n"
1221 "Redistribute from BGP without Zebra, only to configured NVE groups\n"
1222 "Route-map for filtering redistributed routes\n")
1224 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1225 struct rfapi_cfg
*hc
;
1226 uint8_t route_type
= 0;
1228 if (!(hc
= bgp
->rfapi_cfg
))
1230 vty_out (vty
, "rfapi not configured%s", VTY_NEWLINE
);
1234 if (!strcmp (argv
[3]->arg
, "bgp-direct"))
1236 route_type
= ZEBRA_ROUTE_BGP_DIRECT
;
1240 route_type
= ZEBRA_ROUTE_BGP_DIRECT_EXT
;
1243 vnc_redistribute_prechange (bgp
);
1245 if (hc
->routemap_redist_name
[route_type
])
1246 free (hc
->routemap_redist_name
[route_type
]);
1247 hc
->routemap_redist_name
[route_type
] = NULL
;
1248 hc
->routemap_redist
[route_type
] = NULL
;
1250 vnc_redistribute_postchange (bgp
);
1255 DEFUN (vnc_redist_bgpdirect_routemap
,
1256 vnc_redist_bgpdirect_routemap_cmd
,
1257 "vnc redistribute (bgp-direct|bgp-direct-to-nve-groups) route-map NAME",
1259 "Redistribute from other protocols\n"
1260 "Redistribute from BGP directly\n"
1261 "Redistribute from BGP without Zebra, only to configured NVE groups\n"
1262 "Route-map for filtering exported routes\n" "route map name\n")
1264 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1265 struct rfapi_cfg
*hc
;
1266 uint8_t route_type
= 0;
1268 if (!(hc
= bgp
->rfapi_cfg
))
1270 vty_out (vty
, "rfapi not configured%s", VTY_NEWLINE
);
1274 if (!strcmp (argv
[2]->arg
, "bgp-direct"))
1276 route_type
= ZEBRA_ROUTE_BGP_DIRECT
;
1280 route_type
= ZEBRA_ROUTE_BGP_DIRECT_EXT
;
1283 vnc_redistribute_prechange (bgp
);
1285 if (hc
->routemap_redist_name
[route_type
])
1286 free (hc
->routemap_redist_name
[route_type
]);
1287 hc
->routemap_redist_name
[route_type
] = strdup (argv
[4]->arg
);
1288 hc
->routemap_redist
[route_type
] = route_map_lookup_by_name (argv
[4]->arg
);
1290 vnc_redistribute_postchange (bgp
);
1295 /*-- redist policy, non-nvegroup end --*/
1297 /*-- redist policy, nvegroup start --*/
1299 DEFUN (vnc_nve_group_redist_bgpdirect_no_prefixlist
,
1300 vnc_nve_group_redist_bgpdirect_no_prefixlist_cmd
,
1301 "no redistribute bgp-direct (ipv4|ipv6) prefix-list",
1303 "Redistribute from other protocol\n"
1304 "Redistribute from BGP directly\n"
1305 "Disable redistribute filter\n"
1307 "IPv6 routes\n" "Prefix-list for filtering redistributed routes\n")
1309 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1310 VTY_DECLVAR_CONTEXT_SUB(rfapi_nve_group_cfg
, rfg
)
1313 if (!bgp
->rfapi_cfg
)
1315 vty_out (vty
, "rfapi not configured%s", VTY_NEWLINE
);
1319 /* make sure it's still in list */
1320 if (!listnode_lookup (bgp
->rfapi_cfg
->nve_groups_sequential
, rfg
))
1322 /* Not in list anymore */
1323 vty_out (vty
, "Current NVE group no longer exists%s", VTY_NEWLINE
);
1327 if (!strcmp (argv
[3]->arg
, "ipv4"))
1336 vnc_redistribute_prechange (bgp
);
1338 if (rfg
->plist_redist_name
[ZEBRA_ROUTE_BGP_DIRECT
][afi
])
1339 free (rfg
->plist_redist_name
[ZEBRA_ROUTE_BGP_DIRECT
][afi
]);
1340 rfg
->plist_redist_name
[ZEBRA_ROUTE_BGP_DIRECT
][afi
] = NULL
;
1341 rfg
->plist_redist
[ZEBRA_ROUTE_BGP_DIRECT
][afi
] = NULL
;
1343 vnc_redistribute_postchange (bgp
);
1348 DEFUN (vnc_nve_group_redist_bgpdirect_prefixlist
,
1349 vnc_nve_group_redist_bgpdirect_prefixlist_cmd
,
1350 "redistribute bgp-direct (ipv4|ipv6) prefix-list NAME",
1351 "Redistribute from other protocol\n"
1352 "Redistribute from BGP directly\n"
1355 "Prefix-list for filtering redistributed routes\n"
1356 "prefix list name\n")
1358 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1359 VTY_DECLVAR_CONTEXT_SUB(rfapi_nve_group_cfg
, rfg
);
1362 if (!bgp
->rfapi_cfg
)
1364 vty_out (vty
, "rfapi not configured%s", VTY_NEWLINE
);
1368 /* make sure it's still in list */
1369 if (!listnode_lookup (bgp
->rfapi_cfg
->nve_groups_sequential
, rfg
))
1371 /* Not in list anymore */
1372 vty_out (vty
, "Current NVE group no longer exists%s", VTY_NEWLINE
);
1376 if (!strcmp (argv
[2]->arg
, "ipv4"))
1385 vnc_redistribute_prechange (bgp
);
1387 if (rfg
->plist_redist_name
[ZEBRA_ROUTE_BGP_DIRECT
][afi
])
1388 free (rfg
->plist_redist_name
[ZEBRA_ROUTE_BGP_DIRECT
][afi
]);
1389 rfg
->plist_redist_name
[ZEBRA_ROUTE_BGP_DIRECT
][afi
] = strdup (argv
[4]->arg
);
1390 rfg
->plist_redist
[ZEBRA_ROUTE_BGP_DIRECT
][afi
] =
1391 prefix_list_lookup (afi
, argv
[4]->arg
);
1393 vnc_redistribute_postchange (bgp
);
1398 DEFUN (vnc_nve_group_redist_bgpdirect_no_routemap
,
1399 vnc_nve_group_redist_bgpdirect_no_routemap_cmd
,
1400 "no redistribute bgp-direct route-map",
1402 "Redistribute from other protocols\n"
1403 "Redistribute from BGP directly\n"
1404 "Disable redistribute filter\n"
1405 "Route-map for filtering redistributed routes\n")
1407 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1408 VTY_DECLVAR_CONTEXT_SUB(rfapi_nve_group_cfg
, rfg
);
1410 if (!bgp
->rfapi_cfg
)
1412 vty_out (vty
, "rfapi not configured%s", VTY_NEWLINE
);
1416 /* make sure it's still in list */
1417 if (!listnode_lookup (bgp
->rfapi_cfg
->nve_groups_sequential
, rfg
))
1419 /* Not in list anymore */
1420 vty_out (vty
, "Current NVE group no longer exists%s", VTY_NEWLINE
);
1424 vnc_redistribute_prechange (bgp
);
1426 if (rfg
->routemap_redist_name
[ZEBRA_ROUTE_BGP_DIRECT
])
1427 free (rfg
->routemap_redist_name
[ZEBRA_ROUTE_BGP_DIRECT
]);
1428 rfg
->routemap_redist_name
[ZEBRA_ROUTE_BGP_DIRECT
] = NULL
;
1429 rfg
->routemap_redist
[ZEBRA_ROUTE_BGP_DIRECT
] = NULL
;
1431 vnc_redistribute_postchange (bgp
);
1436 DEFUN (vnc_nve_group_redist_bgpdirect_routemap
,
1437 vnc_nve_group_redist_bgpdirect_routemap_cmd
,
1438 "redistribute bgp-direct route-map NAME",
1439 "Redistribute from other protocols\n"
1440 "Redistribute from BGP directly\n"
1441 "Route-map for filtering exported routes\n" "route map name\n")
1443 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1444 VTY_DECLVAR_CONTEXT_SUB(rfapi_nve_group_cfg
, rfg
);
1446 if (!bgp
->rfapi_cfg
)
1448 vty_out (vty
, "rfapi not configured%s", VTY_NEWLINE
);
1452 /* make sure it's still in list */
1453 if (!listnode_lookup (bgp
->rfapi_cfg
->nve_groups_sequential
, rfg
))
1455 /* Not in list anymore */
1456 vty_out (vty
, "Current NVE group no longer exists%s", VTY_NEWLINE
);
1460 vnc_redistribute_prechange (bgp
);
1462 if (rfg
->routemap_redist_name
[ZEBRA_ROUTE_BGP_DIRECT
])
1463 free (rfg
->routemap_redist_name
[ZEBRA_ROUTE_BGP_DIRECT
]);
1464 rfg
->routemap_redist_name
[ZEBRA_ROUTE_BGP_DIRECT
] = strdup (argv
[3]->arg
);
1465 rfg
->routemap_redist
[ZEBRA_ROUTE_BGP_DIRECT
] =
1466 route_map_lookup_by_name (argv
[3]->arg
);
1468 vnc_redistribute_postchange (bgp
);
1473 /*-- redist policy, nvegroup end --*/
1475 /*-------------------------------------------------------------------------
1477 *-----------------------------------------------------------------------*/
1479 DEFUN (vnc_export_mode
,
1480 vnc_export_mode_cmd
,
1481 "vnc export (bgp|zebra) mode (group-nve|ce|none|registering-nve)",
1483 "Export to other protocols\n"
1485 "Export to Zebra (experimental)\n"
1486 "Select export mode\n"
1487 "Export routes with nve-group next-hops\n"
1488 "Export routes with NVE connected router next-hops\n"
1489 "Disable export\n" "Export routes with registering NVE as next-hop\n")
1491 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1492 uint32_t oldmode
= 0;
1493 uint32_t newmode
= 0;
1495 if (!bgp
->rfapi_cfg
)
1497 vty_out (vty
, "VNC not configured%s", VTY_NEWLINE
);
1501 if (argv
[2]->arg
[0] == 'b')
1503 oldmode
= bgp
->rfapi_cfg
->flags
& BGP_VNC_CONFIG_EXPORT_BGP_MODE_BITS
;
1504 switch (argv
[4]->arg
[0])
1507 newmode
= BGP_VNC_CONFIG_EXPORT_BGP_MODE_GRP
;
1510 newmode
= BGP_VNC_CONFIG_EXPORT_BGP_MODE_CE
;
1516 newmode
= BGP_VNC_CONFIG_EXPORT_BGP_MODE_RH
;
1519 vty_out (vty
, "Invalid mode specified%s", VTY_NEWLINE
);
1523 if (newmode
== oldmode
)
1525 vty_out (vty
, "Mode unchanged%s", VTY_NEWLINE
);
1529 vnc_export_bgp_prechange (bgp
);
1531 bgp
->rfapi_cfg
->flags
&= ~BGP_VNC_CONFIG_EXPORT_BGP_MODE_BITS
;
1532 bgp
->rfapi_cfg
->flags
|= newmode
;
1534 vnc_export_bgp_postchange (bgp
);
1541 * export to zebra with RH mode is not yet implemented
1543 vty_out (vty
, "Changing modes for zebra export not implemented yet%s",
1547 oldmode
= bgp
->rfapi_cfg
->flags
& BGP_VNC_CONFIG_EXPORT_ZEBRA_MODE_BITS
;
1548 bgp
->rfapi_cfg
->flags
&= ~BGP_VNC_CONFIG_EXPORT_ZEBRA_MODE_BITS
;
1549 switch (argv
[4]->arg
[0])
1552 if (oldmode
== BGP_VNC_CONFIG_EXPORT_ZEBRA_MODE_RH
)
1556 bgp
->rfapi_cfg
->flags
|= BGP_VNC_CONFIG_EXPORT_ZEBRA_MODE_GRP
;
1557 if (oldmode
!= BGP_VNC_CONFIG_EXPORT_ZEBRA_MODE_GRP
)
1563 if (oldmode
== BGP_VNC_CONFIG_EXPORT_ZEBRA_MODE_RH
)
1567 if (oldmode
== BGP_VNC_CONFIG_EXPORT_ZEBRA_MODE_GRP
)
1573 if (oldmode
== BGP_VNC_CONFIG_EXPORT_ZEBRA_MODE_GRP
)
1577 bgp
->rfapi_cfg
->flags
|= BGP_VNC_CONFIG_EXPORT_ZEBRA_MODE_RH
;
1578 if (oldmode
!= BGP_VNC_CONFIG_EXPORT_ZEBRA_MODE_RH
)
1584 vty_out (vty
, "Invalid mode%s", VTY_NEWLINE
);
1592 static struct rfapi_rfg_name
*
1595 return XCALLOC (MTYPE_RFAPI_RFG_NAME
, sizeof (struct rfapi_rfg_name
));
1599 rfgn_free (struct rfapi_rfg_name
*rfgn
)
1601 XFREE (MTYPE_RFAPI_RFG_NAME
, rfgn
);
1604 DEFUN (vnc_export_nvegroup
,
1605 vnc_export_nvegroup_cmd
,
1606 "vnc export (bgp|zebra) group-nve group NAME",
1608 "Export to other protocols\n"
1610 "Export to Zebra (experimental)\n"
1611 "NVE group, used in 'group-nve' export mode\n"
1612 "NVE group\n" "Group name\n")
1614 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1615 struct rfapi_nve_group_cfg
*rfg_new
;
1617 if (!bgp
->rfapi_cfg
)
1619 vty_out (vty
, "rfapi not configured%s", VTY_NEWLINE
);
1623 rfg_new
= rfapi_group_lookup_byname (bgp
, argv
[5]->arg
);
1625 if (argv
[2]->arg
[0] == 'b')
1628 struct listnode
*node
;
1629 struct rfapi_rfg_name
*rfgn
;
1632 * Set group for export to BGP Direct
1635 /* see if group is already included in export list */
1636 for (ALL_LIST_ELEMENTS_RO (bgp
->rfapi_cfg
->rfg_export_direct_bgp_l
,
1640 if (!strcmp (rfgn
->name
, argv
[5]->arg
))
1642 /* already in the list: we're done */
1648 rfgn
->name
= strdup (argv
[5]->arg
);
1649 rfgn
->rfg
= rfg_new
; /* OK if not set yet */
1651 listnode_add (bgp
->rfapi_cfg
->rfg_export_direct_bgp_l
, rfgn
);
1653 vnc_zlog_debug_verbose ("%s: testing rfg_new", __func__
);
1656 vnc_zlog_debug_verbose ("%s: testing bgp grp mode enabled", __func__
);
1657 if (VNC_EXPORT_BGP_GRP_ENABLED (bgp
->rfapi_cfg
))
1658 vnc_zlog_debug_verbose ("%s: calling vnc_direct_bgp_add_group", __func__
);
1659 vnc_direct_bgp_add_group (bgp
, rfg_new
);
1666 struct listnode
*node
;
1667 struct rfapi_rfg_name
*rfgn
;
1670 * Set group for export to Zebra
1673 /* see if group is already included in export list */
1674 for (ALL_LIST_ELEMENTS_RO (bgp
->rfapi_cfg
->rfg_export_zebra_l
,
1678 if (!strcmp (rfgn
->name
, argv
[5]->arg
))
1680 /* already in the list: we're done */
1686 rfgn
->name
= strdup (argv
[5]->arg
);
1687 rfgn
->rfg
= rfg_new
; /* OK if not set yet */
1689 listnode_add (bgp
->rfapi_cfg
->rfg_export_zebra_l
, rfgn
);
1693 if (VNC_EXPORT_ZEBRA_GRP_ENABLED (bgp
->rfapi_cfg
))
1694 vnc_zebra_add_group (bgp
, rfg_new
);
1702 * This command applies to routes exported from VNC to BGP directly
1703 * without going though zebra
1705 DEFUN (vnc_no_export_nvegroup
,
1706 vnc_no_export_nvegroup_cmd
,
1707 "vnc export (bgp|zebra) group-nve no group NAME",
1709 "Export to other protocols\n"
1711 "Export to Zebra (experimental)\n"
1712 "NVE group, used in 'group-nve' export mode\n"
1713 "Disable export of VNC routes\n" "NVE group\n" "Group name\n")
1715 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1716 struct listnode
*node
, *nnode
;
1717 struct rfapi_rfg_name
*rfgn
;
1719 if (!bgp
->rfapi_cfg
)
1721 vty_out (vty
, "rfapi not configured%s", VTY_NEWLINE
);
1725 if (argv
[2]->arg
[0] == 'b')
1727 for (ALL_LIST_ELEMENTS (bgp
->rfapi_cfg
->rfg_export_direct_bgp_l
,
1731 if (rfgn
->name
&& !strcmp (rfgn
->name
, argv
[6]->arg
))
1733 vnc_zlog_debug_verbose ("%s: matched \"%s\"", __func__
, rfgn
->name
);
1735 vnc_direct_bgp_del_group (bgp
, rfgn
->rfg
);
1737 list_delete_node (bgp
->rfapi_cfg
->rfg_export_direct_bgp_l
,
1746 for (ALL_LIST_ELEMENTS (bgp
->rfapi_cfg
->rfg_export_zebra_l
,
1750 vnc_zlog_debug_verbose ("does rfg \"%s\" match?", rfgn
->name
);
1751 if (rfgn
->name
&& !strcmp (rfgn
->name
, argv
[6]->arg
))
1754 vnc_zebra_del_group (bgp
, rfgn
->rfg
);
1756 list_delete_node (bgp
->rfapi_cfg
->rfg_export_zebra_l
, node
);
1765 DEFUN (vnc_nve_group_export_no_prefixlist
,
1766 vnc_nve_group_export_no_prefixlist_cmd
,
1767 "no export (bgp|zebra) (ipv4|ipv6) prefix-list [NAME]",
1769 "Export to other protocols\n"
1771 "Export to Zebra (experimental)\n"
1774 "Prefix-list for filtering exported routes\n" "prefix list name\n")
1776 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1777 VTY_DECLVAR_CONTEXT_SUB(rfapi_nve_group_cfg
, rfg
);
1780 if (!bgp
->rfapi_cfg
)
1782 vty_out (vty
, "rfapi not configured%s", VTY_NEWLINE
);
1786 /* make sure it's still in list */
1787 if (!listnode_lookup (bgp
->rfapi_cfg
->nve_groups_sequential
, rfg
))
1789 /* Not in list anymore */
1790 vty_out (vty
, "Current NVE group no longer exists%s", VTY_NEWLINE
);
1794 if (!strcmp (argv
[3]->arg
, "ipv4"))
1803 if (argv
[2]->arg
[0] == 'b')
1806 && !strcmp (argv
[5]->arg
, rfg
->plist_export_bgp_name
[afi
]))
1810 if (rfg
->plist_export_bgp_name
[afi
])
1811 free (rfg
->plist_export_bgp_name
[afi
]);
1812 rfg
->plist_export_bgp_name
[afi
] = NULL
;
1813 rfg
->plist_export_bgp
[afi
] = NULL
;
1815 vnc_direct_bgp_reexport_group_afi (bgp
, rfg
, afi
);
1821 && !strcmp (argv
[5]->arg
, rfg
->plist_export_zebra_name
[afi
]))
1824 if (rfg
->plist_export_zebra_name
[afi
])
1825 free (rfg
->plist_export_zebra_name
[afi
]);
1826 rfg
->plist_export_zebra_name
[afi
] = NULL
;
1827 rfg
->plist_export_zebra
[afi
] = NULL
;
1829 vnc_zebra_reexport_group_afi (bgp
, rfg
, afi
);
1835 DEFUN (vnc_nve_group_export_prefixlist
,
1836 vnc_nve_group_export_prefixlist_cmd
,
1837 "export (bgp|zebra) (ipv4|ipv6) prefix-list NAME",
1838 "Export to other protocols\n"
1840 "Export to Zebra (experimental)\n"
1843 "Prefix-list for filtering exported routes\n" "prefix list name\n")
1845 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1846 VTY_DECLVAR_CONTEXT_SUB(rfapi_nve_group_cfg
, rfg
);
1849 if (!bgp
->rfapi_cfg
)
1851 vty_out (vty
, "rfapi not configured%s", VTY_NEWLINE
);
1855 /* make sure it's still in list */
1856 if (!listnode_lookup (bgp
->rfapi_cfg
->nve_groups_sequential
, rfg
))
1858 /* Not in list anymore */
1859 vty_out (vty
, "Current NVE group no longer exists%s", VTY_NEWLINE
);
1863 if (!strcmp (argv
[2]->arg
, "ipv4"))
1872 if (argv
[1]->arg
[0] == 'b')
1874 if (rfg
->plist_export_bgp_name
[afi
])
1875 free (rfg
->plist_export_bgp_name
[afi
]);
1876 rfg
->plist_export_bgp_name
[afi
] = strdup (argv
[4]->arg
);
1877 rfg
->plist_export_bgp
[afi
] = prefix_list_lookup (afi
, argv
[4]->arg
);
1879 vnc_direct_bgp_reexport_group_afi (bgp
, rfg
, afi
);
1884 if (rfg
->plist_export_zebra_name
[afi
])
1885 free (rfg
->plist_export_zebra_name
[afi
]);
1886 rfg
->plist_export_zebra_name
[afi
] = strdup (argv
[4]->arg
);
1887 rfg
->plist_export_zebra
[afi
] = prefix_list_lookup (afi
, argv
[4]->arg
);
1889 vnc_zebra_reexport_group_afi (bgp
, rfg
, afi
);
1894 DEFUN (vnc_nve_group_export_no_routemap
,
1895 vnc_nve_group_export_no_routemap_cmd
,
1896 "no export (bgp|zebra) route-map [NAME]",
1898 "Export to other protocols\n"
1900 "Export to Zebra (experimental)\n"
1901 "Route-map for filtering exported routes\n" "route map name\n")
1903 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1904 VTY_DECLVAR_CONTEXT_SUB(rfapi_nve_group_cfg
, rfg
);
1906 if (!bgp
->rfapi_cfg
)
1908 vty_out (vty
, "rfapi not configured%s", VTY_NEWLINE
);
1912 /* make sure it's still in list */
1913 if (!listnode_lookup (bgp
->rfapi_cfg
->nve_groups_sequential
, rfg
))
1915 /* Not in list anymore */
1916 vty_out (vty
, "Current NVE group no longer exists%s", VTY_NEWLINE
);
1920 if (argv
[2]->arg
[0] == 'b')
1923 && !strcmp (argv
[4]->arg
, rfg
->routemap_export_bgp_name
))
1927 if (rfg
->routemap_export_bgp_name
)
1928 free (rfg
->routemap_export_bgp_name
);
1929 rfg
->routemap_export_bgp_name
= NULL
;
1930 rfg
->routemap_export_bgp
= NULL
;
1932 vnc_direct_bgp_reexport_group_afi (bgp
, rfg
, AFI_IP
);
1933 vnc_direct_bgp_reexport_group_afi (bgp
, rfg
, AFI_IP6
);
1939 && !strcmp (argv
[4]->arg
, rfg
->routemap_export_zebra_name
))
1942 if (rfg
->routemap_export_zebra_name
)
1943 free (rfg
->routemap_export_zebra_name
);
1944 rfg
->routemap_export_zebra_name
= NULL
;
1945 rfg
->routemap_export_zebra
= NULL
;
1947 vnc_zebra_reexport_group_afi (bgp
, rfg
, AFI_IP
);
1948 vnc_zebra_reexport_group_afi (bgp
, rfg
, AFI_IP6
);
1954 DEFUN (vnc_nve_group_export_routemap
,
1955 vnc_nve_group_export_routemap_cmd
,
1956 "export (bgp|zebra) route-map NAME",
1957 "Export to other protocols\n"
1959 "Export to Zebra (experimental)\n"
1960 "Route-map for filtering exported routes\n" "route map name\n")
1962 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1963 VTY_DECLVAR_CONTEXT_SUB(rfapi_nve_group_cfg
, rfg
);
1965 if (!bgp
->rfapi_cfg
)
1967 vty_out (vty
, "rfapi not configured%s", VTY_NEWLINE
);
1971 /* make sure it's still in list */
1972 if (!listnode_lookup (bgp
->rfapi_cfg
->nve_groups_sequential
, rfg
))
1974 /* Not in list anymore */
1975 vty_out (vty
, "Current NVE group no longer exists%s", VTY_NEWLINE
);
1979 if (argv
[1]->arg
[0] == 'b')
1981 if (rfg
->routemap_export_bgp_name
)
1982 free (rfg
->routemap_export_bgp_name
);
1983 rfg
->routemap_export_bgp_name
= strdup (argv
[3]->arg
);
1984 rfg
->routemap_export_bgp
= route_map_lookup_by_name (argv
[3]->arg
);
1985 vnc_direct_bgp_reexport_group_afi (bgp
, rfg
, AFI_IP
);
1986 vnc_direct_bgp_reexport_group_afi (bgp
, rfg
, AFI_IP6
);
1990 if (rfg
->routemap_export_zebra_name
)
1991 free (rfg
->routemap_export_zebra_name
);
1992 rfg
->routemap_export_zebra_name
= strdup (argv
[3]->arg
);
1993 rfg
->routemap_export_zebra
= route_map_lookup_by_name (argv
[3]->arg
);
1994 vnc_zebra_reexport_group_afi (bgp
, rfg
, AFI_IP
);
1995 vnc_zebra_reexport_group_afi (bgp
, rfg
, AFI_IP6
);
2000 DEFUN (vnc_nve_export_no_prefixlist
,
2001 vnc_nve_export_no_prefixlist_cmd
,
2002 "no vnc export (bgp|zebra) (ipv4|ipv6) prefix-list [NAME]",
2005 "Export to other protocols\n"
2007 "Export to Zebra (experimental)\n"
2010 "Prefix-list for filtering exported routes\n" "Prefix list name\n")
2012 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2013 struct rfapi_cfg
*hc
;
2016 if (!(hc
= bgp
->rfapi_cfg
))
2018 vty_out (vty
, "rfapi not configured%s", VTY_NEWLINE
);
2022 if (!strcmp (argv
[4]->arg
, "ipv4"))
2031 if (argv
[3]->arg
[0] == 'b')
2034 && !strcmp (argv
[6]->arg
, hc
->plist_export_bgp_name
[afi
]))
2038 if (hc
->plist_export_bgp_name
[afi
])
2039 free (hc
->plist_export_bgp_name
[afi
]);
2040 hc
->plist_export_bgp_name
[afi
] = NULL
;
2041 hc
->plist_export_bgp
[afi
] = NULL
;
2042 vnc_direct_bgp_reexport (bgp
, afi
);
2048 && !strcmp (argv
[6]->arg
, hc
->plist_export_zebra_name
[afi
]))
2052 if (hc
->plist_export_zebra_name
[afi
])
2053 free (hc
->plist_export_zebra_name
[afi
]);
2054 hc
->plist_export_zebra_name
[afi
] = NULL
;
2055 hc
->plist_export_zebra
[afi
] = NULL
;
2056 /* TBD vnc_zebra_rh_reexport(bgp, afi); */
2062 DEFUN (vnc_nve_export_prefixlist
,
2063 vnc_nve_export_prefixlist_cmd
,
2064 "vnc export (bgp|zebra) (ipv4|ipv6) prefix-list NAME",
2066 "Export to other protocols\n"
2068 "Export to Zebra (experimental)\n"
2069 "Filters, used in 'registering-nve' export mode\n"
2072 "Prefix-list for filtering exported routes\n" "Prefix list name\n")
2074 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2075 struct rfapi_cfg
*hc
;
2078 if (!(hc
= bgp
->rfapi_cfg
))
2080 vty_out (vty
, "rfapi not configured%s", VTY_NEWLINE
);
2084 if (!strcmp (argv
[3]->arg
, "ipv4"))
2093 if (argv
[2]->arg
[0] == 'b')
2095 if (hc
->plist_export_bgp_name
[afi
])
2096 free (hc
->plist_export_bgp_name
[afi
]);
2097 hc
->plist_export_bgp_name
[afi
] = strdup (argv
[5]->arg
);
2098 hc
->plist_export_bgp
[afi
] = prefix_list_lookup (afi
, argv
[5]->arg
);
2099 vnc_direct_bgp_reexport (bgp
, afi
);
2103 if (hc
->plist_export_zebra_name
[afi
])
2104 free (hc
->plist_export_zebra_name
[afi
]);
2105 hc
->plist_export_zebra_name
[afi
] = strdup (argv
[5]->arg
);
2106 hc
->plist_export_zebra
[afi
] = prefix_list_lookup (afi
, argv
[5]->arg
);
2107 /* TBD vnc_zebra_rh_reexport(bgp, afi); */
2112 DEFUN (vnc_nve_export_no_routemap
,
2113 vnc_nve_export_no_routemap_cmd
,
2114 "no vnc export (bgp|zebra) route-map [NAME]",
2117 "Export to other protocols\n"
2119 "Export to Zebra (experimental)\n"
2120 "Route-map for filtering exported routes\n" "Route map name\n")
2122 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2123 struct rfapi_cfg
*hc
;
2125 if (!(hc
= bgp
->rfapi_cfg
))
2127 vty_out (vty
, "rfapi not configured%s", VTY_NEWLINE
);
2131 if (argv
[3]->arg
[0] == 'b')
2134 && !strcmp (argv
[5]->arg
, hc
->routemap_export_bgp_name
))
2138 if (hc
->routemap_export_bgp_name
)
2139 free (hc
->routemap_export_bgp_name
);
2140 hc
->routemap_export_bgp_name
= NULL
;
2141 hc
->routemap_export_bgp
= NULL
;
2142 vnc_direct_bgp_reexport (bgp
, AFI_IP
);
2143 vnc_direct_bgp_reexport (bgp
, AFI_IP6
);
2149 && !strcmp (argv
[5]->arg
, hc
->routemap_export_zebra_name
))
2153 if (hc
->routemap_export_zebra_name
)
2154 free (hc
->routemap_export_zebra_name
);
2155 hc
->routemap_export_zebra_name
= NULL
;
2156 hc
->routemap_export_zebra
= NULL
;
2157 /* TBD vnc_zebra_rh_reexport(bgp, AFI_IP); */
2158 /* TBD vnc_zebra_rh_reexport(bgp, AFI_IP6); */
2164 DEFUN (vnc_nve_export_routemap
,
2165 vnc_nve_export_routemap_cmd
,
2166 "vnc export (bgp|zebra) route-map NAME",
2168 "Export to other protocols\n"
2170 "Export to Zebra (experimental)\n"
2171 "Filters, used in 'registering-nve' export mode\n"
2172 "Route-map for filtering exported routes\n" "Route map name\n")
2174 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2175 struct rfapi_cfg
*hc
;
2177 if (!(hc
= bgp
->rfapi_cfg
))
2179 vty_out (vty
, "rfapi not configured%s", VTY_NEWLINE
);
2183 if (argv
[2]->arg
[0] == 'b')
2185 if (hc
->routemap_export_bgp_name
)
2186 free (hc
->routemap_export_bgp_name
);
2187 hc
->routemap_export_bgp_name
= strdup (argv
[4]->arg
);
2188 hc
->routemap_export_bgp
= route_map_lookup_by_name (argv
[4]->arg
);
2189 vnc_direct_bgp_reexport (bgp
, AFI_IP
);
2190 vnc_direct_bgp_reexport (bgp
, AFI_IP6
);
2194 if (hc
->routemap_export_zebra_name
)
2195 free (hc
->routemap_export_zebra_name
);
2196 hc
->routemap_export_zebra_name
= strdup (argv
[4]->arg
);
2197 hc
->routemap_export_zebra
= route_map_lookup_by_name (argv
[4]->arg
);
2198 /* TBD vnc_zebra_rh_reexport(bgp, AFI_IP); */
2199 /* TBD vnc_zebra_rh_reexport(bgp, AFI_IP6); */
2206 * respond to changes in the global prefix list configuration
2209 vnc_prefix_list_update (struct bgp
*bgp
)
2213 struct rfapi_nve_group_cfg
*rfg
;
2214 struct rfapi_cfg
*hc
;
2219 vnc_zlog_debug_verbose ("%s: No BGP process is configured", __func__
);
2223 if (!(hc
= bgp
->rfapi_cfg
))
2225 vnc_zlog_debug_verbose ("%s: rfapi not configured", __func__
);
2229 for (afi
= AFI_IP
; afi
< AFI_MAX
; afi
++)
2232 * Loop over nve groups
2234 for (ALL_LIST_ELEMENTS_RO (bgp
->rfapi_cfg
->nve_groups_sequential
,
2238 if (rfg
->plist_export_bgp_name
[afi
])
2240 rfg
->plist_export_bgp
[afi
] =
2241 prefix_list_lookup (afi
, rfg
->plist_export_bgp_name
[afi
]);
2243 if (rfg
->plist_export_zebra_name
[afi
])
2245 rfg
->plist_export_zebra
[afi
] =
2246 prefix_list_lookup (afi
, rfg
->plist_export_zebra_name
[afi
]);
2248 for (i
= 0; i
< ZEBRA_ROUTE_MAX
; ++i
)
2250 if (rfg
->plist_redist_name
[i
][afi
])
2252 rfg
->plist_redist
[i
][afi
] =
2253 prefix_list_lookup (afi
, rfg
->plist_redist_name
[i
][afi
]);
2257 vnc_direct_bgp_reexport_group_afi (bgp
, rfg
, afi
);
2258 /* TBD vnc_zebra_reexport_group_afi(bgp, rfg, afi); */
2264 if (hc
->plist_export_bgp_name
[afi
])
2266 hc
->plist_export_bgp
[afi
] =
2267 prefix_list_lookup (afi
, hc
->plist_export_bgp_name
[afi
]);
2269 if (hc
->plist_export_zebra_name
[afi
])
2271 hc
->plist_export_zebra
[afi
] =
2272 prefix_list_lookup (afi
, hc
->plist_export_zebra_name
[afi
]);
2275 for (i
= 0; i
< ZEBRA_ROUTE_MAX
; ++i
)
2277 if (hc
->plist_redist_name
[i
][afi
])
2279 hc
->plist_redist
[i
][afi
] =
2280 prefix_list_lookup (afi
, hc
->plist_redist_name
[i
][afi
]);
2286 vnc_direct_bgp_reexport (bgp
, AFI_IP
);
2287 vnc_direct_bgp_reexport (bgp
, AFI_IP6
);
2289 /* TBD vnc_zebra_rh_reexport(bgp, AFI_IP); */
2290 /* TBD vnc_zebra_rh_reexport(bgp, AFI_IP6); */
2292 vnc_redistribute_prechange (bgp
);
2293 vnc_redistribute_postchange (bgp
);
2297 * respond to changes in the global route map configuration
2300 vnc_routemap_update (struct bgp
*bgp
, const char *unused
)
2303 struct rfapi_nve_group_cfg
*rfg
;
2304 struct rfapi_cfg
*hc
;
2307 vnc_zlog_debug_verbose ("%s(arg=%s)", __func__
, unused
);
2311 vnc_zlog_debug_verbose ("%s: No BGP process is configured", __func__
);
2315 if (!(hc
= bgp
->rfapi_cfg
))
2317 vnc_zlog_debug_verbose ("%s: rfapi not configured", __func__
);
2322 * Loop over nve groups
2324 for (ALL_LIST_ELEMENTS_RO (bgp
->rfapi_cfg
->nve_groups_sequential
, n
, rfg
))
2327 if (rfg
->routemap_export_bgp_name
)
2329 rfg
->routemap_export_bgp
=
2330 route_map_lookup_by_name (rfg
->routemap_export_bgp_name
);
2332 if (rfg
->routemap_export_zebra_name
)
2334 rfg
->routemap_export_bgp
=
2335 route_map_lookup_by_name (rfg
->routemap_export_zebra_name
);
2337 for (i
= 0; i
< ZEBRA_ROUTE_MAX
; ++i
)
2339 if (rfg
->routemap_redist_name
[i
])
2341 rfg
->routemap_redist
[i
] =
2342 route_map_lookup_by_name (rfg
->routemap_redist_name
[i
]);
2346 vnc_direct_bgp_reexport_group_afi (bgp
, rfg
, AFI_IP
);
2347 vnc_direct_bgp_reexport_group_afi (bgp
, rfg
, AFI_IP6
);
2348 /* TBD vnc_zebra_reexport_group_afi(bgp, rfg, afi); */
2354 if (hc
->routemap_export_bgp_name
)
2356 hc
->routemap_export_bgp
=
2357 route_map_lookup_by_name (hc
->routemap_export_bgp_name
);
2359 if (hc
->routemap_export_zebra_name
)
2361 hc
->routemap_export_bgp
=
2362 route_map_lookup_by_name (hc
->routemap_export_zebra_name
);
2364 for (i
= 0; i
< ZEBRA_ROUTE_MAX
; ++i
)
2366 if (hc
->routemap_redist_name
[i
])
2368 hc
->routemap_redist
[i
] =
2369 route_map_lookup_by_name (hc
->routemap_redist_name
[i
]);
2373 vnc_direct_bgp_reexport (bgp
, AFI_IP
);
2374 vnc_direct_bgp_reexport (bgp
, AFI_IP6
);
2376 /* TBD vnc_zebra_rh_reexport(bgp, AFI_IP); */
2377 /* TBD vnc_zebra_rh_reexport(bgp, AFI_IP6); */
2379 vnc_redistribute_prechange (bgp
);
2380 vnc_redistribute_postchange (bgp
);
2382 vnc_zlog_debug_verbose ("%s done", __func__
);
2386 vnc_routemap_event (route_map_event_t type
, /* ignored */
2387 const char *rmap_name
) /* ignored */
2389 struct listnode
*mnode
, *mnnode
;
2392 vnc_zlog_debug_verbose ("%s(event type=%d)", __func__
, type
);
2393 if (bm
->bgp
== NULL
) /* may be called during cleanup */
2396 for (ALL_LIST_ELEMENTS (bm
->bgp
, mnode
, mnnode
, bgp
))
2397 vnc_routemap_update (bgp
, rmap_name
);
2399 vnc_zlog_debug_verbose ("%s: done", __func__
);
2402 /*-------------------------------------------------------------------------
2404 *-----------------------------------------------------------------------*/
2407 DEFUN (vnc_nve_group
,
2409 "vnc nve-group NAME",
2410 VNC_CONFIG_STR
"Configure a NVE group\n" "Group name\n")
2412 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2413 struct rfapi_nve_group_cfg
*rfg
;
2414 struct listnode
*node
, *nnode
;
2415 struct rfapi_rfg_name
*rfgn
;
2417 /* Search for name */
2418 rfg
= rfapi_group_lookup_byname (bgp
, argv
[2]->arg
);
2422 rfg
= rfapi_group_new ();
2425 /* Error out of memory */
2426 vty_out (vty
, "Can't allocate memory for NVE group%s", VTY_NEWLINE
);
2429 rfg
->name
= strdup (argv
[2]->arg
);
2430 /* add to tail of list */
2431 listnode_add (bgp
->rfapi_cfg
->nve_groups_sequential
, rfg
);
2433 /* Copy defaults from struct rfapi_cfg */
2434 rfg
->rd
= bgp
->rfapi_cfg
->default_rd
;
2435 if (bgp
->rfapi_cfg
->flags
& BGP_VNC_CONFIG_L2RD
)
2437 rfg
->l2rd
= bgp
->rfapi_cfg
->default_l2rd
;
2438 rfg
->flags
|= RFAPI_RFG_L2RD
;
2440 rfg
->rd
= bgp
->rfapi_cfg
->default_rd
;
2441 rfg
->response_lifetime
= bgp
->rfapi_cfg
->default_response_lifetime
;
2443 if (bgp
->rfapi_cfg
->default_rt_export_list
)
2445 rfg
->rt_export_list
=
2446 ecommunity_dup (bgp
->rfapi_cfg
->default_rt_export_list
);
2449 if (bgp
->rfapi_cfg
->default_rt_import_list
)
2451 rfg
->rt_import_list
=
2452 ecommunity_dup (bgp
->rfapi_cfg
->default_rt_import_list
);
2453 rfg
->rfapi_import_table
=
2454 rfapiImportTableRefAdd (bgp
, rfg
->rt_import_list
);
2458 * If a redist nve group was named but the group was not defined,
2459 * make the linkage now
2461 if (!bgp
->rfapi_cfg
->rfg_redist
)
2463 if (bgp
->rfapi_cfg
->rfg_redist_name
&&
2464 !strcmp (bgp
->rfapi_cfg
->rfg_redist_name
, rfg
->name
))
2467 vnc_redistribute_prechange (bgp
);
2468 bgp
->rfapi_cfg
->rfg_redist
= rfg
;
2469 vnc_redistribute_postchange (bgp
);
2475 * Same treatment for bgp-direct export group
2477 for (ALL_LIST_ELEMENTS (bgp
->rfapi_cfg
->rfg_export_direct_bgp_l
,
2481 if (!strcmp (rfgn
->name
, rfg
->name
))
2484 vnc_direct_bgp_add_group (bgp
, rfg
);
2490 * Same treatment for zebra export group
2492 for (ALL_LIST_ELEMENTS (bgp
->rfapi_cfg
->rfg_export_zebra_l
,
2496 vnc_zlog_debug_verbose ("%s: ezport zebra: checking if \"%s\" == \"%s\"",
2497 __func__
, rfgn
->name
, rfg
->name
);
2498 if (!strcmp (rfgn
->name
, rfg
->name
))
2501 vnc_zebra_add_group (bgp
, rfg
);
2508 * XXX subsequent calls will need to make sure this item is still
2509 * in the linked list and has the same name
2511 VTY_PUSH_CONTEXT_SUB (BGP_VNC_NVE_GROUP_NODE
, rfg
);
2517 bgp_rfapi_delete_nve_group (
2518 struct vty
*vty
, /* NULL = no output */
2520 struct rfapi_nve_group_cfg
*rfg
)
2522 struct list
*orphaned_nves
= NULL
;
2523 struct listnode
*node
, *nnode
;
2526 * If there are currently-open NVEs that belong to this group,
2527 * zero out their references to this group structure.
2531 struct rfapi_descriptor
*rfd
;
2532 orphaned_nves
= list_new ();
2533 while ((rfd
= listnode_head (rfg
->nves
)))
2536 listnode_delete (rfg
->nves
, rfd
);
2537 listnode_add (orphaned_nves
, rfd
);
2539 list_delete (rfg
->nves
);
2545 if (rfg
->rfapi_import_table
)
2546 rfapiImportTableRefDelByIt (bgp
, rfg
->rfapi_import_table
);
2547 if (rfg
->rt_import_list
)
2548 ecommunity_free (&rfg
->rt_import_list
);
2549 if (rfg
->rt_export_list
)
2550 ecommunity_free (&rfg
->rt_export_list
);
2554 rfg
->vn_node
->info
= NULL
;
2555 route_unlock_node (rfg
->vn_node
); /* frees */
2559 rfg
->un_node
->info
= NULL
;
2560 route_unlock_node (rfg
->un_node
); /* frees */
2563 XFREE (MTYPE_RFAPI_RFP_GROUP_CFG
, rfg
->rfp_cfg
);
2564 listnode_delete (bgp
->rfapi_cfg
->nve_groups_sequential
, rfg
);
2567 XFREE (MTYPE_RFAPI_GROUP_CFG
, rfg
);
2570 * Attempt to reassign the orphaned nves to a new group. If
2571 * a NVE can not be reassigned, its rfd->rfg will remain NULL
2572 * and it will become a zombie until released by rfapi_close().
2576 struct rfapi_descriptor
*rfd
;
2578 for (ALL_LIST_ELEMENTS (orphaned_nves
, node
, nnode
, rfd
))
2581 * 1. rfapi_close() equivalent except:
2582 * a. don't free original descriptor
2583 * b. remember query list
2584 * c. remember advertised route list
2585 * 2. rfapi_open() equivalent except:
2586 * a. reuse original descriptor
2587 * 3. rfapi_register() on remembered advertised route list
2588 * 4. rfapi_query on rememebred query list
2593 rc
= rfapi_reopen (rfd
, bgp
);
2597 list_delete_node (orphaned_nves
, node
);
2599 vty_out (vty
, "WARNING: reassigned NVE vn=");
2600 rfapiPrintRfapiIpAddr (vty
, &rfd
->vn_addr
);
2602 vty_out (vty
, " un=");
2603 rfapiPrintRfapiIpAddr (vty
, &rfd
->un_addr
);
2605 vty_out (vty
, " to new group \"%s\"%s", rfd
->rfg
->name
,
2611 for (ALL_LIST_ELEMENTS_RO (orphaned_nves
, node
, rfd
))
2614 vty_out (vty
, "WARNING: orphaned NVE vn=");
2615 rfapiPrintRfapiIpAddr (vty
, &rfd
->vn_addr
);
2617 vty_out (vty
, " un=");
2618 rfapiPrintRfapiIpAddr (vty
, &rfd
->un_addr
);
2620 vty_out (vty
, "%s", VTY_NEWLINE
);
2622 list_delete (orphaned_nves
);
2627 bgp_rfapi_delete_named_nve_group (
2628 struct vty
*vty
, /* NULL = no output */
2630 const char *rfg_name
) /* NULL = any */
2632 struct rfapi_nve_group_cfg
*rfg
= NULL
;
2633 struct listnode
*node
, *nnode
;
2634 struct rfapi_rfg_name
*rfgn
;
2636 /* Search for name */
2639 rfg
= rfapi_group_lookup_byname (bgp
, rfg_name
);
2643 vty_out (vty
, "No NVE group named \"%s\"%s", rfg_name
,
2650 * If this group is the redist nve group, unlink it
2652 if (rfg_name
== NULL
|| bgp
->rfapi_cfg
->rfg_redist
== rfg
)
2654 vnc_redistribute_prechange (bgp
);
2655 bgp
->rfapi_cfg
->rfg_redist
= NULL
;
2656 vnc_redistribute_postchange (bgp
);
2661 * remove reference from bgp direct export list
2663 for (ALL_LIST_ELEMENTS_RO (bgp
->rfapi_cfg
->rfg_export_direct_bgp_l
,
2666 if (rfg_name
== NULL
|| !strcmp (rfgn
->name
, rfg_name
))
2669 /* remove exported routes from this group */
2670 vnc_direct_bgp_del_group (bgp
, rfg
);
2676 * remove reference from zebra export list
2678 for (ALL_LIST_ELEMENTS_RO (bgp
->rfapi_cfg
->rfg_export_zebra_l
, node
, rfgn
))
2681 if (rfg_name
== NULL
|| !strcmp (rfgn
->name
, rfg_name
))
2684 /* remove exported routes from this group */
2685 vnc_zebra_del_group (bgp
, rfg
);
2690 bgp_rfapi_delete_nve_group (vty
, bgp
, rfg
);
2691 else /* must be delete all */
2692 for (ALL_LIST_ELEMENTS
2693 (bgp
->rfapi_cfg
->nve_groups_sequential
, node
, nnode
, rfg
))
2694 bgp_rfapi_delete_nve_group (vty
, bgp
, rfg
);
2698 DEFUN (vnc_no_nve_group
,
2699 vnc_no_nve_group_cmd
,
2700 "no vnc nve-group NAME",
2703 "Configure a NVE group\n"
2706 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2708 return bgp_rfapi_delete_named_nve_group (vty
, bgp
, argv
[3]->arg
);
2711 DEFUN (vnc_nve_group_prefix
,
2712 vnc_nve_group_prefix_cmd
,
2713 "prefix (vn|un) (A.B.C.D/M|X:X::X:X/M)",
2714 "Specify prefixes matching NVE VN or UN interfaces\n"
2720 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2721 VTY_DECLVAR_CONTEXT_SUB(rfapi_nve_group_cfg
, rfg
);
2724 struct route_table
*rt
;
2725 struct route_node
*rn
;
2726 int is_un_prefix
= 0;
2728 /* make sure it's still in list */
2729 if (!listnode_lookup (bgp
->rfapi_cfg
->nve_groups_sequential
, rfg
))
2731 /* Not in list anymore */
2732 vty_out (vty
, "Current NVE group no longer exists%s", VTY_NEWLINE
);
2736 if (!str2prefix (argv
[2]->arg
, &p
))
2738 vty_out (vty
, "Malformed prefix \"%s\"%s", argv
[2]->arg
, VTY_NEWLINE
);
2742 afi
= family2afi (p
.family
);
2745 vty_out (vty
, "Unsupported address family%s", VTY_NEWLINE
);
2749 if (argv
[1]->arg
[0] == 'u')
2751 rt
= &(bgp
->rfapi_cfg
->nve_groups_un
[afi
]);
2756 rt
= &(bgp
->rfapi_cfg
->nve_groups_vn
[afi
]);
2759 rn
= route_node_get (rt
, &p
); /* NB locks node */
2763 * There is already a group with this prefix
2765 route_unlock_node (rn
);
2766 if (rn
->info
!= rfg
)
2769 * different group name: fail
2771 vty_out (vty
, "nve group \"%s\" already has \"%s\" prefix %s%s",
2772 ((struct rfapi_nve_group_cfg
*) (rn
->info
))->name
,
2773 argv
[1]->arg
, argv
[2]->arg
, VTY_NEWLINE
);
2779 * same group name: it's already in the correct place
2780 * in the table, so we're done.
2782 * Implies rfg->(vn|un)_prefix is already correct.
2788 if (bgp
->rfapi_cfg
->rfg_redist
== rfg
)
2790 vnc_redistribute_prechange (bgp
);
2793 /* New prefix, new node */
2798 /* detach rfg from previous route table location */
2801 rfg
->un_node
->info
= NULL
;
2802 route_unlock_node (rfg
->un_node
); /* frees */
2804 rfg
->un_node
= rn
; /* back ref */
2811 /* detach rfg from previous route table location */
2814 rfg
->vn_node
->info
= NULL
;
2815 route_unlock_node (rfg
->vn_node
); /* frees */
2817 rfg
->vn_node
= rn
; /* back ref */
2824 if (bgp
->rfapi_cfg
->rfg_redist
== rfg
)
2826 vnc_redistribute_postchange (bgp
);
2832 DEFUN (vnc_nve_group_rt_import
,
2833 vnc_nve_group_rt_import_cmd
,
2834 "rt import .RTLIST",
2835 "Specify route targets\n"
2837 "Space separated route target list (A.B.C.D:MN|EF:OPQR|GHJK:MN)\n")
2839 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2840 VTY_DECLVAR_CONTEXT_SUB(rfapi_nve_group_cfg
, rfg
);
2842 struct listnode
*node
;
2843 struct rfapi_rfg_name
*rfgn
;
2844 int is_export_bgp
= 0;
2845 int is_export_zebra
= 0;
2847 /* make sure it's still in list */
2848 if (!listnode_lookup (bgp
->rfapi_cfg
->nve_groups_sequential
, rfg
))
2850 /* Not in list anymore */
2851 vty_out (vty
, "Current NVE group no longer exists%s", VTY_NEWLINE
);
2855 rc
= set_ecom_list (vty
, argc
- 2, argv
+ 2, &rfg
->rt_import_list
);
2856 if (rc
!= CMD_SUCCESS
)
2859 for (ALL_LIST_ELEMENTS_RO (bgp
->rfapi_cfg
->rfg_export_direct_bgp_l
,
2863 if (rfgn
->rfg
== rfg
)
2871 vnc_direct_bgp_del_group (bgp
, rfg
);
2873 for (ALL_LIST_ELEMENTS_RO (bgp
->rfapi_cfg
->rfg_export_zebra_l
, node
, rfgn
))
2876 if (rfgn
->rfg
== rfg
)
2878 is_export_zebra
= 1;
2883 if (is_export_zebra
)
2884 vnc_zebra_del_group (bgp
, rfg
);
2887 * stop referencing old import table, now reference new one
2889 if (rfg
->rfapi_import_table
)
2890 rfapiImportTableRefDelByIt (bgp
, rfg
->rfapi_import_table
);
2891 rfg
->rfapi_import_table
= rfapiImportTableRefAdd (bgp
, rfg
->rt_import_list
);
2894 vnc_direct_bgp_add_group (bgp
, rfg
);
2896 if (is_export_zebra
)
2897 vnc_zebra_add_group (bgp
, rfg
);
2902 DEFUN (vnc_nve_group_rt_export
,
2903 vnc_nve_group_rt_export_cmd
,
2904 "rt export .RTLIST",
2905 "Specify route targets\n"
2907 "Space separated route target list (A.B.C.D:MN|EF:OPQR|GHJK:MN)\n")
2909 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2910 VTY_DECLVAR_CONTEXT_SUB(rfapi_nve_group_cfg
, rfg
);
2913 /* make sure it's still in list */
2914 if (!listnode_lookup (bgp
->rfapi_cfg
->nve_groups_sequential
, rfg
))
2916 /* Not in list anymore */
2917 vty_out (vty
, "Current NVE group no longer exists%s", VTY_NEWLINE
);
2921 if (bgp
->rfapi_cfg
->rfg_redist
== rfg
)
2923 vnc_redistribute_prechange (bgp
);
2926 rc
= set_ecom_list (vty
, argc
- 2, argv
+ 2, &rfg
->rt_export_list
);
2928 if (bgp
->rfapi_cfg
->rfg_redist
== rfg
)
2930 vnc_redistribute_postchange (bgp
);
2936 DEFUN (vnc_nve_group_rt_both
,
2937 vnc_nve_group_rt_both_cmd
,
2939 "Specify route targets\n"
2940 "Export+import filters\n"
2941 "Space separated route target list (A.B.C.D:MN|EF:OPQR|GHJK:MN)\n")
2943 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2944 VTY_DECLVAR_CONTEXT_SUB(rfapi_nve_group_cfg
, rfg
);
2946 int is_export_bgp
= 0;
2947 int is_export_zebra
= 0;
2948 struct listnode
*node
;
2949 struct rfapi_rfg_name
*rfgn
;
2951 /* make sure it's still in list */
2952 if (!listnode_lookup (bgp
->rfapi_cfg
->nve_groups_sequential
, rfg
))
2954 /* Not in list anymore */
2955 vty_out (vty
, "Current NVE group no longer exists%s", VTY_NEWLINE
);
2959 rc
= set_ecom_list (vty
, argc
- 2, argv
+ 2, &rfg
->rt_import_list
);
2960 if (rc
!= CMD_SUCCESS
)
2963 for (ALL_LIST_ELEMENTS_RO (bgp
->rfapi_cfg
->rfg_export_direct_bgp_l
,
2967 if (rfgn
->rfg
== rfg
)
2975 vnc_direct_bgp_del_group (bgp
, rfg
);
2977 for (ALL_LIST_ELEMENTS_RO (bgp
->rfapi_cfg
->rfg_export_zebra_l
, node
, rfgn
))
2980 if (rfgn
->rfg
== rfg
)
2982 is_export_zebra
= 1;
2987 if (is_export_zebra
)
2989 vnc_zlog_debug_verbose ("%s: is_export_zebra", __func__
);
2990 vnc_zebra_del_group (bgp
, rfg
);
2994 * stop referencing old import table, now reference new one
2996 if (rfg
->rfapi_import_table
)
2997 rfapiImportTableRefDelByIt (bgp
, rfg
->rfapi_import_table
);
2998 rfg
->rfapi_import_table
= rfapiImportTableRefAdd (bgp
, rfg
->rt_import_list
);
3001 vnc_direct_bgp_add_group (bgp
, rfg
);
3003 if (is_export_zebra
)
3004 vnc_zebra_add_group (bgp
, rfg
);
3006 if (bgp
->rfapi_cfg
->rfg_redist
== rfg
)
3008 vnc_redistribute_prechange (bgp
);
3011 rc
= set_ecom_list (vty
, argc
- 2, argv
+ 2, &rfg
->rt_export_list
);
3013 if (bgp
->rfapi_cfg
->rfg_redist
== rfg
)
3015 vnc_redistribute_postchange (bgp
);
3022 DEFUN (vnc_nve_group_l2rd
,
3023 vnc_nve_group_l2rd_cmd
,
3024 "l2rd (ID|auto:vn)",
3025 "Specify default Local Nve ID value to use in RD for L2 routes\n"
3026 "Fixed value 1-255\n"
3027 "use the low-order octet of the NVE's VN address\n")
3029 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3030 VTY_DECLVAR_CONTEXT_SUB(rfapi_nve_group_cfg
, rfg
);
3032 /* make sure it's still in list */
3033 if (!listnode_lookup (bgp
->rfapi_cfg
->nve_groups_sequential
, rfg
))
3035 /* Not in list anymore */
3036 vty_out (vty
, "Current NVE group no longer exists%s", VTY_NEWLINE
);
3040 if (!strcmp (argv
[1]->arg
, "auto:vn"))
3047 unsigned long value_l
= strtoul (argv
[1]->arg
, &end
, 10);
3048 uint8_t value
= value_l
& 0xff;
3050 if (!argv
[1]->arg
[0] || *end
)
3052 vty_out (vty
, "%% Malformed l2 nve ID \"%s\"%s", argv
[1]->arg
,
3056 if ((value_l
< 1) || (value_l
> 0xff))
3059 "%% Malformed l2 nve id (must be greater than 0 and less than %u%s",
3060 0x100, VTY_NEWLINE
);
3066 rfg
->flags
|= RFAPI_RFG_L2RD
;
3071 DEFUN (vnc_nve_group_no_l2rd
,
3072 vnc_nve_group_no_l2rd_cmd
,
3075 "Specify default Local Nve ID value to use in RD for L2 routes\n")
3077 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3078 VTY_DECLVAR_CONTEXT_SUB(rfapi_nve_group_cfg
, rfg
);
3080 /* make sure it's still in list */
3081 if (!listnode_lookup (bgp
->rfapi_cfg
->nve_groups_sequential
, rfg
))
3083 /* Not in list anymore */
3084 vty_out (vty
, "Current NVE group no longer exists%s", VTY_NEWLINE
);
3089 rfg
->flags
&= ~RFAPI_RFG_L2RD
;
3094 DEFUN (vnc_nve_group_rd
,
3095 vnc_nve_group_rd_cmd
,
3096 "rd ASN:nn_or_IP-address:nn",
3097 "Specify route distinguisher\n"
3098 "Route Distinguisher (<as-number>:<number> | <ip-address>:<number> | auto:vn:<number> )\n")
3100 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3102 struct prefix_rd prd
;
3103 VTY_DECLVAR_CONTEXT_SUB(rfapi_nve_group_cfg
, rfg
);
3105 /* make sure it's still in list */
3106 if (!listnode_lookup (bgp
->rfapi_cfg
->nve_groups_sequential
, rfg
))
3108 /* Not in list anymore */
3109 vty_out (vty
, "Current NVE group no longer exists%s", VTY_NEWLINE
);
3113 if (!strncmp (argv
[1]->arg
, "auto:vn:", 8))
3116 * use AF_UNIX to designate automatically-assigned RD
3117 * auto:vn:nn where nn is a 2-octet quantity
3120 uint32_t value32
= strtoul (argv
[1]->arg
+ 8, &end
, 10);
3121 uint16_t value
= value32
& 0xffff;
3123 if (!argv
[1]->arg
[8] || *end
)
3125 vty_out (vty
, "%% Malformed rd%s", VTY_NEWLINE
);
3128 if (value32
> 0xffff)
3130 vty_out (vty
, "%% Malformed rd (must be less than %u%s",
3131 0x0ffff, VTY_NEWLINE
);
3135 memset (&prd
, 0, sizeof (prd
));
3136 prd
.family
= AF_UNIX
;
3138 prd
.val
[0] = (RD_TYPE_IP
>> 8) & 0x0ff;
3139 prd
.val
[1] = RD_TYPE_IP
& 0x0ff;
3140 prd
.val
[6] = (value
>> 8) & 0x0ff;
3141 prd
.val
[7] = value
& 0x0ff;
3147 ret
= str2prefix_rd (argv
[1]->arg
, &prd
);
3150 vty_out (vty
, "%% Malformed rd%s", VTY_NEWLINE
);
3155 if (bgp
->rfapi_cfg
->rfg_redist
== rfg
)
3157 vnc_redistribute_prechange (bgp
);
3162 if (bgp
->rfapi_cfg
->rfg_redist
== rfg
)
3164 vnc_redistribute_postchange (bgp
);
3169 DEFUN (vnc_nve_group_responselifetime
,
3170 vnc_nve_group_responselifetime_cmd
,
3171 "response-lifetime (LIFETIME|infinite)",
3172 "Specify response lifetime\n"
3173 "Response lifetime in seconds\n" "Infinite response lifetime\n")
3175 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3176 unsigned int rspint
;
3177 VTY_DECLVAR_CONTEXT_SUB(rfapi_nve_group_cfg
, rfg
);
3178 struct rfapi_descriptor
*rfd
;
3179 struct listnode
*hdnode
;
3181 /* make sure it's still in list */
3182 if (!listnode_lookup (bgp
->rfapi_cfg
->nve_groups_sequential
, rfg
))
3184 /* Not in list anymore */
3185 vty_out (vty
, "Current NVE group no longer exists%s", VTY_NEWLINE
);
3189 if (!strcmp (argv
[1]->arg
, "infinite"))
3191 rspint
= RFAPI_INFINITE_LIFETIME
;
3195 VTY_GET_INTEGER ("Response Lifetime", rspint
, argv
[1]->arg
);
3198 rfg
->response_lifetime
= rspint
;
3199 rfg
->flags
|= RFAPI_RFG_RESPONSE_LIFETIME
;
3201 for (ALL_LIST_ELEMENTS_RO (rfg
->nves
, hdnode
, rfd
))
3202 rfd
->response_lifetime
= rspint
;
3207 * Sigh. This command, like exit-address-family, is a hack to deal
3208 * with the lack of rigorous level control in the command handler.
3209 * TBD fix command handler.
3214 "Exit VNC configuration mode\n")
3216 if (vty
->node
== BGP_VNC_DEFAULTS_NODE
||
3217 vty
->node
== BGP_VNC_NVE_GROUP_NODE
||
3218 vty
->node
== BGP_VNC_L2_GROUP_NODE
)
3221 vty
->node
= BGP_NODE
;
3226 static struct cmd_node bgp_vnc_defaults_node
= {
3227 BGP_VNC_DEFAULTS_NODE
,
3228 "%s(config-router-vnc-defaults)# ",
3232 static struct cmd_node bgp_vnc_nve_group_node
= {
3233 BGP_VNC_NVE_GROUP_NODE
,
3234 "%s(config-router-vnc-nve-group)# ",
3238 /*-------------------------------------------------------------------------
3240 *-----------------------------------------------------------------------*/
3243 DEFUN (vnc_l2_group
,
3245 "vnc l2-group NAME",
3246 VNC_CONFIG_STR
"Configure a L2 group\n" "Group name\n")
3248 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3249 struct rfapi_l2_group_cfg
*rfg
;
3251 /* Search for name */
3252 rfg
= rfapi_l2_group_lookup_byname (bgp
, argv
[2]->arg
);
3256 rfg
= rfapi_l2_group_new ();
3259 /* Error out of memory */
3260 vty_out (vty
, "Can't allocate memory for L2 group%s", VTY_NEWLINE
);
3263 rfg
->name
= strdup (argv
[2]->arg
);
3264 /* add to tail of list */
3265 listnode_add (bgp
->rfapi_cfg
->l2_groups
, rfg
);
3269 * XXX subsequent calls will need to make sure this item is still
3270 * in the linked list and has the same name
3272 VTY_PUSH_CONTEXT_SUB (BGP_VNC_L2_GROUP_NODE
, rfg
);
3277 bgp_rfapi_delete_l2_group (
3278 struct vty
*vty
, /* NULL = no output */
3280 struct rfapi_l2_group_cfg
*rfg
)
3284 if (rfg
->rt_import_list
)
3285 ecommunity_free (&rfg
->rt_import_list
);
3286 if (rfg
->rt_export_list
)
3287 ecommunity_free (&rfg
->rt_export_list
);
3289 list_delete (rfg
->labels
);
3291 XFREE (MTYPE_RFAPI_RFP_GROUP_CFG
, rfg
->rfp_cfg
);
3292 listnode_delete (bgp
->rfapi_cfg
->l2_groups
, rfg
);
3294 rfapi_l2_group_del (rfg
);
3298 bgp_rfapi_delete_named_l2_group (
3299 struct vty
*vty
, /* NULL = no output */
3301 const char *rfg_name
) /* NULL = any */
3303 struct rfapi_l2_group_cfg
*rfg
= NULL
;
3304 struct listnode
*node
, *nnode
;
3306 /* Search for name */
3309 rfg
= rfapi_l2_group_lookup_byname (bgp
, rfg_name
);
3313 vty_out (vty
, "No L2 group named \"%s\"%s", rfg_name
,
3320 bgp_rfapi_delete_l2_group (vty
, bgp
, rfg
);
3321 else /* must be delete all */
3322 for (ALL_LIST_ELEMENTS (bgp
->rfapi_cfg
->l2_groups
, node
, nnode
, rfg
))
3323 bgp_rfapi_delete_l2_group (vty
, bgp
, rfg
);
3327 DEFUN (vnc_no_l2_group
,
3328 vnc_no_l2_group_cmd
,
3329 "no vnc l2-group NAME",
3332 "Configure a L2 group\n"
3335 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3337 return bgp_rfapi_delete_named_l2_group (vty
, bgp
, argv
[3]->arg
);
3341 DEFUN (vnc_l2_group_lni
,
3342 vnc_l2_group_lni_cmd
,
3343 "logical-network-id <0-4294967295>",
3344 "Specify Logical Network ID associated with group\n"
3347 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3348 VTY_DECLVAR_CONTEXT_SUB(rfapi_l2_group_cfg
, rfg
);
3350 /* make sure it's still in list */
3351 if (!listnode_lookup (bgp
->rfapi_cfg
->l2_groups
, rfg
))
3353 /* Not in list anymore */
3354 vty_out (vty
, "Current L2 group no longer exists%s", VTY_NEWLINE
);
3358 VTY_GET_INTEGER ("logical-network-id", rfg
->logical_net_id
, argv
[1]->arg
);
3363 DEFUN (vnc_l2_group_labels
,
3364 vnc_l2_group_labels_cmd
,
3365 "labels .LABELLIST",
3366 "Specify label values associated with group\n"
3367 "Space separated list of label values <0-1048575>\n")
3369 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3370 VTY_DECLVAR_CONTEXT_SUB(rfapi_l2_group_cfg
, rfg
);
3373 /* make sure it's still in list */
3374 if (!listnode_lookup (bgp
->rfapi_cfg
->l2_groups
, rfg
))
3376 /* Not in list anymore */
3377 vty_out (vty
, "Current L2 group no longer exists%s", VTY_NEWLINE
);
3390 for (; argc
; --argc
, ++argv
)
3393 VTY_GET_INTEGER_RANGE ("Label value", label
, argv
[0]->arg
, 0, 1048575);
3394 if (!listnode_lookup (ll
, (void *) (uintptr_t) label
))
3395 listnode_add (ll
, (void *) (uintptr_t) label
);
3401 DEFUN (vnc_l2_group_no_labels
,
3402 vnc_l2_group_no_labels_cmd
,
3403 "no labels .LABELLIST",
3405 "Remove label values associated with L2 group\n"
3406 "Specify label values associated with L2 group\n"
3407 "Space separated list of label values <0-1048575>\n")
3409 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3410 VTY_DECLVAR_CONTEXT_SUB(rfapi_l2_group_cfg
, rfg
);
3413 /* make sure it's still in list */
3414 if (!listnode_lookup (bgp
->rfapi_cfg
->l2_groups
, rfg
))
3416 /* Not in list anymore */
3417 vty_out (vty
, "Current L2 group no longer exists%s", VTY_NEWLINE
);
3424 vty_out (vty
, "Label no longer associated with group%s", VTY_NEWLINE
);
3430 for (; argc
; --argc
, ++argv
)
3433 VTY_GET_INTEGER_RANGE ("Label value", label
, argv
[0]->arg
, 0, 1048575);
3434 listnode_delete (ll
, (void *) (uintptr_t) label
);
3440 DEFUN (vnc_l2_group_rt
,
3441 vnc_l2_group_rt_cmd
,
3442 "rt (both|export|import) ASN:nn_or_IP-address:nn",
3443 "Specify route targets\n"
3444 "Export+import filters\n"
3449 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3450 VTY_DECLVAR_CONTEXT_SUB(rfapi_l2_group_cfg
, rfg
);
3451 int rc
= CMD_SUCCESS
;
3455 switch (argv
[1]->arg
[0])
3458 do_export
= 1; /* fall through */
3466 vty_out (vty
, "Unknown option, %s%s", argv
[1]->arg
, VTY_NEWLINE
);
3467 return CMD_ERR_NO_MATCH
;
3470 return CMD_ERR_INCOMPLETE
;
3474 vty_out (vty
, "No BGP process is configured%s", VTY_NEWLINE
);
3478 /* make sure it's still in list */
3479 if (!listnode_lookup (bgp
->rfapi_cfg
->l2_groups
, rfg
))
3481 /* Not in list anymore */
3482 vty_out (vty
, "Current L2 group no longer exists%s", VTY_NEWLINE
);
3487 rc
= set_ecom_list (vty
, argc
- 2, argv
+ 2, &rfg
->rt_import_list
);
3488 if (rc
== CMD_SUCCESS
&& do_export
)
3489 rc
= set_ecom_list (vty
, argc
- 2, argv
+ 2, &rfg
->rt_export_list
);
3494 static struct cmd_node bgp_vnc_l2_group_node
= {
3495 BGP_VNC_L2_GROUP_NODE
,
3496 "%s(config-router-vnc-l2-group)# ",
3500 static struct rfapi_l2_group_cfg
*
3501 bgp_rfapi_get_group_by_lni_label (
3503 uint32_t logical_net_id
,
3506 struct rfapi_l2_group_cfg
*rfg
;
3507 struct listnode
*node
;
3509 if (bgp
->rfapi_cfg
->l2_groups
== NULL
) /* not the best place for this */
3512 label
= label
& 0xfffff; /* label is 20 bits! */
3514 for (ALL_LIST_ELEMENTS_RO (bgp
->rfapi_cfg
->l2_groups
, node
, rfg
))
3516 if (rfg
->logical_net_id
== logical_net_id
)
3518 struct listnode
*lnode
;
3520 for (ALL_LIST_ELEMENTS_RO (rfg
->labels
, lnode
, data
))
3521 if (((uint32_t) ((uintptr_t) data
)) == label
)
3531 bgp_rfapi_get_labellist_by_lni_label (
3533 uint32_t logical_net_id
,
3536 struct rfapi_l2_group_cfg
*rfg
;
3537 rfg
= bgp_rfapi_get_group_by_lni_label (bgp
, logical_net_id
, label
);
3546 bgp_rfapi_get_ecommunity_by_lni_label (
3549 uint32_t logical_net_id
,
3552 struct rfapi_l2_group_cfg
*rfg
;
3553 rfg
= bgp_rfapi_get_group_by_lni_label (bgp
, logical_net_id
, label
);
3557 return rfg
->rt_import_list
;
3559 return rfg
->rt_export_list
;
3565 bgp_rfapi_cfg_init (void)
3567 /* main bgpd code does not use this hook, but vnc does */
3568 route_map_event_hook (vnc_routemap_event
);
3570 install_node (&bgp_vnc_defaults_node
, NULL
);
3571 install_node (&bgp_vnc_nve_group_node
, NULL
);
3572 install_node (&bgp_vnc_l2_group_node
, NULL
);
3573 install_default (BGP_VNC_DEFAULTS_NODE
);
3574 install_default (BGP_VNC_NVE_GROUP_NODE
);
3575 install_default (BGP_VNC_L2_GROUP_NODE
);
3580 install_element (BGP_NODE
, &vnc_defaults_cmd
);
3581 install_element (BGP_NODE
, &vnc_nve_group_cmd
);
3582 install_element (BGP_NODE
, &vnc_no_nve_group_cmd
);
3583 install_element (BGP_NODE
, &vnc_l2_group_cmd
);
3584 install_element (BGP_NODE
, &vnc_no_l2_group_cmd
);
3585 install_element (BGP_NODE
, &vnc_advertise_un_method_cmd
);
3586 install_element (BGP_NODE
, &vnc_export_mode_cmd
);
3588 install_element (BGP_VNC_DEFAULTS_NODE
, &vnc_defaults_rt_import_cmd
);
3589 install_element (BGP_VNC_DEFAULTS_NODE
, &vnc_defaults_rt_export_cmd
);
3590 install_element (BGP_VNC_DEFAULTS_NODE
, &vnc_defaults_rt_both_cmd
);
3591 install_element (BGP_VNC_DEFAULTS_NODE
, &vnc_defaults_rd_cmd
);
3592 install_element (BGP_VNC_DEFAULTS_NODE
, &vnc_defaults_l2rd_cmd
);
3593 install_element (BGP_VNC_DEFAULTS_NODE
, &vnc_defaults_no_l2rd_cmd
);
3594 install_element (BGP_VNC_DEFAULTS_NODE
, &vnc_defaults_responselifetime_cmd
);
3595 install_element (BGP_VNC_DEFAULTS_NODE
, &exit_vnc_cmd
);
3597 install_element (BGP_NODE
, &vnc_redistribute_protocol_cmd
);
3598 install_element (BGP_NODE
, &vnc_no_redistribute_protocol_cmd
);
3599 install_element (BGP_NODE
, &vnc_redistribute_nvegroup_cmd
);
3600 install_element (BGP_NODE
, &vnc_redistribute_no_nvegroup_cmd
);
3601 install_element (BGP_NODE
, &vnc_redistribute_lifetime_cmd
);
3602 install_element (BGP_NODE
, &vnc_redistribute_rh_roo_localadmin_cmd
);
3603 install_element (BGP_NODE
, &vnc_redistribute_mode_cmd
);
3604 install_element (BGP_NODE
, &vnc_redistribute_bgp_exterior_cmd
);
3606 install_element (BGP_NODE
, &vnc_redist_bgpdirect_no_prefixlist_cmd
);
3607 install_element (BGP_NODE
, &vnc_redist_bgpdirect_prefixlist_cmd
);
3608 install_element (BGP_NODE
, &vnc_redist_bgpdirect_no_routemap_cmd
);
3609 install_element (BGP_NODE
, &vnc_redist_bgpdirect_routemap_cmd
);
3611 install_element (BGP_VNC_NVE_GROUP_NODE
,
3612 &vnc_nve_group_redist_bgpdirect_no_prefixlist_cmd
);
3613 install_element (BGP_VNC_NVE_GROUP_NODE
,
3614 &vnc_nve_group_redist_bgpdirect_prefixlist_cmd
);
3615 install_element (BGP_VNC_NVE_GROUP_NODE
,
3616 &vnc_nve_group_redist_bgpdirect_no_routemap_cmd
);
3617 install_element (BGP_VNC_NVE_GROUP_NODE
,
3618 &vnc_nve_group_redist_bgpdirect_routemap_cmd
);
3620 install_element (BGP_NODE
, &vnc_export_nvegroup_cmd
);
3621 install_element (BGP_NODE
, &vnc_no_export_nvegroup_cmd
);
3622 install_element (BGP_NODE
, &vnc_nve_export_prefixlist_cmd
);
3623 install_element (BGP_NODE
, &vnc_nve_export_routemap_cmd
);
3624 install_element (BGP_NODE
, &vnc_nve_export_no_prefixlist_cmd
);
3625 install_element (BGP_NODE
, &vnc_nve_export_no_routemap_cmd
);
3627 install_element (BGP_VNC_NVE_GROUP_NODE
, &vnc_nve_group_l2rd_cmd
);
3628 install_element (BGP_VNC_NVE_GROUP_NODE
, &vnc_nve_group_no_l2rd_cmd
);
3629 install_element (BGP_VNC_NVE_GROUP_NODE
, &vnc_nve_group_prefix_cmd
);
3630 install_element (BGP_VNC_NVE_GROUP_NODE
, &vnc_nve_group_rt_import_cmd
);
3631 install_element (BGP_VNC_NVE_GROUP_NODE
, &vnc_nve_group_rt_export_cmd
);
3632 install_element (BGP_VNC_NVE_GROUP_NODE
, &vnc_nve_group_rt_both_cmd
);
3633 install_element (BGP_VNC_NVE_GROUP_NODE
, &vnc_nve_group_rd_cmd
);
3634 install_element (BGP_VNC_NVE_GROUP_NODE
,
3635 &vnc_nve_group_responselifetime_cmd
);
3636 install_element (BGP_VNC_NVE_GROUP_NODE
,
3637 &vnc_nve_group_export_prefixlist_cmd
);
3638 install_element (BGP_VNC_NVE_GROUP_NODE
,
3639 &vnc_nve_group_export_routemap_cmd
);
3640 install_element (BGP_VNC_NVE_GROUP_NODE
,
3641 &vnc_nve_group_export_no_prefixlist_cmd
);
3642 install_element (BGP_VNC_NVE_GROUP_NODE
,
3643 &vnc_nve_group_export_no_routemap_cmd
);
3644 install_element (BGP_VNC_NVE_GROUP_NODE
, &exit_vnc_cmd
);
3646 install_element (BGP_VNC_L2_GROUP_NODE
, &vnc_l2_group_lni_cmd
);
3647 install_element (BGP_VNC_L2_GROUP_NODE
, &vnc_l2_group_labels_cmd
);
3648 install_element (BGP_VNC_L2_GROUP_NODE
, &vnc_l2_group_no_labels_cmd
);
3649 install_element (BGP_VNC_L2_GROUP_NODE
, &vnc_l2_group_rt_cmd
);
3650 install_element (BGP_VNC_L2_GROUP_NODE
, &exit_vnc_cmd
);
3654 bgp_rfapi_cfg_new (struct rfapi_rfp_cfg
*cfg
)
3656 struct rfapi_cfg
*h
;
3660 (struct rfapi_cfg
*) XCALLOC (MTYPE_RFAPI_CFG
, sizeof (struct rfapi_cfg
));
3663 h
->nve_groups_sequential
= list_new ();
3664 assert (h
->nve_groups_sequential
);
3666 for (afi
= AFI_IP
; afi
< AFI_MAX
; afi
++)
3668 /* ugly, to deal with addition of delegates, part of 0.99.24.1 merge */
3669 h
->nve_groups_vn
[afi
].delegate
= route_table_get_default_delegate ();
3670 h
->nve_groups_un
[afi
].delegate
= route_table_get_default_delegate ();
3672 h
->default_response_lifetime
= BGP_VNC_DEFAULT_RESPONSE_LIFETIME_DEFAULT
;
3673 h
->rfg_export_direct_bgp_l
= list_new ();
3674 h
->rfg_export_zebra_l
= list_new ();
3675 h
->resolve_nve_roo_local_admin
=
3676 BGP_VNC_CONFIG_RESOLVE_NVE_ROO_LOCAL_ADMIN_DEFAULT
;
3678 SET_FLAG (h
->flags
, BGP_VNC_CONFIG_FLAGS_DEFAULT
);
3682 h
->rfp_cfg
.download_type
= RFAPI_RFP_DOWNLOAD_PARTIAL
;
3683 h
->rfp_cfg
.ftd_advertisement_interval
=
3684 RFAPI_RFP_CFG_DEFAULT_FTD_ADVERTISEMENT_INTERVAL
;
3685 h
->rfp_cfg
.holddown_factor
= RFAPI_RFP_CFG_DEFAULT_HOLDDOWN_FACTOR
;
3686 h
->rfp_cfg
.use_updated_response
= 0;
3687 h
->rfp_cfg
.use_removes
= 0;
3691 h
->rfp_cfg
.download_type
= cfg
->download_type
;
3692 h
->rfp_cfg
.ftd_advertisement_interval
= cfg
->ftd_advertisement_interval
;
3693 h
->rfp_cfg
.holddown_factor
= cfg
->holddown_factor
;
3694 h
->rfp_cfg
.use_updated_response
= cfg
->use_updated_response
;
3695 h
->rfp_cfg
.use_removes
= cfg
->use_removes
;
3696 if (cfg
->use_updated_response
)
3697 h
->flags
&= ~BGP_VNC_CONFIG_CALLBACK_DISABLE
;
3699 h
->flags
|= BGP_VNC_CONFIG_CALLBACK_DISABLE
;
3700 if (cfg
->use_removes
)
3701 h
->flags
&= ~BGP_VNC_CONFIG_RESPONSE_REMOVAL_DISABLE
;
3703 h
->flags
|= BGP_VNC_CONFIG_RESPONSE_REMOVAL_DISABLE
;
3709 bgp_rfapi_cfg_destroy (struct bgp
*bgp
, struct rfapi_cfg
*h
)
3714 bgp_rfapi_delete_named_nve_group (NULL
, bgp
, NULL
);
3715 bgp_rfapi_delete_named_l2_group (NULL
, bgp
, NULL
);
3716 if (h
->l2_groups
!= NULL
)
3717 list_delete (h
->l2_groups
);
3718 list_delete (h
->nve_groups_sequential
);
3719 list_delete (h
->rfg_export_direct_bgp_l
);
3720 list_delete (h
->rfg_export_zebra_l
);
3721 if (h
->default_rt_export_list
)
3722 ecommunity_free (&h
->default_rt_export_list
);
3723 if (h
->default_rt_import_list
)
3724 ecommunity_free (&h
->default_rt_import_list
);
3725 if (h
->default_rfp_cfg
)
3726 XFREE (MTYPE_RFAPI_RFP_GROUP_CFG
, h
->default_rfp_cfg
);
3727 XFREE (MTYPE_RFAPI_CFG
, h
);
3732 bgp_rfapi_cfg_write (struct vty
*vty
, struct bgp
*bgp
)
3734 struct listnode
*node
, *nnode
;
3735 struct rfapi_nve_group_cfg
*rfg
;
3736 struct rfapi_cfg
*hc
= bgp
->rfapi_cfg
;
3737 struct rfapi_rfg_name
*rfgn
;
3742 if (hc
->flags
& BGP_VNC_CONFIG_ADV_UN_METHOD_ENCAP
)
3744 vty_out (vty
, " vnc advertise-un-method encap-safi%s", VTY_NEWLINE
);
3748 { /* was based on listen ports */
3749 /* for now allow both old and new */
3750 if (bgp
->rfapi
->rfp_methods
.cfg_cb
)
3751 write
+= (bgp
->rfapi
->rfp_methods
.cfg_cb
) (vty
, bgp
->rfapi
->rfp
);
3754 vty_out (vty
, "!%s", VTY_NEWLINE
);
3758 struct rfapi_l2_group_cfg
*rfg
= NULL
;
3759 struct listnode
*gnode
;
3760 for (ALL_LIST_ELEMENTS_RO (hc
->l2_groups
, gnode
, rfg
))
3762 struct listnode
*lnode
;
3765 vty_out (vty
, " vnc l2-group %s%s", rfg
->name
, VTY_NEWLINE
);
3766 if (rfg
->logical_net_id
!= 0)
3767 vty_out (vty
, " logical-network-id %u%s", rfg
->logical_net_id
,
3769 if (rfg
->labels
!= NULL
&& listhead (rfg
->labels
) != NULL
)
3771 vty_out (vty
, " labels ");
3772 for (ALL_LIST_ELEMENTS_RO (rfg
->labels
, lnode
, data
))
3774 vty_out (vty
, "%hu ", (uint16_t) ((uintptr_t) data
));
3776 vty_out (vty
, "%s", VTY_NEWLINE
);
3779 if (rfg
->rt_import_list
&& rfg
->rt_export_list
&&
3780 ecommunity_cmp (rfg
->rt_import_list
, rfg
->rt_export_list
))
3782 char *b
= ecommunity_ecom2str (rfg
->rt_import_list
,
3783 ECOMMUNITY_FORMAT_ROUTE_MAP
);
3784 vty_out (vty
, " rt both %s%s", b
, VTY_NEWLINE
);
3785 XFREE (MTYPE_ECOMMUNITY_STR
, b
);
3789 if (rfg
->rt_import_list
)
3791 char *b
= ecommunity_ecom2str (rfg
->rt_import_list
,
3792 ECOMMUNITY_FORMAT_ROUTE_MAP
);
3793 vty_out (vty
, " rt import %s%s", b
, VTY_NEWLINE
);
3794 XFREE (MTYPE_ECOMMUNITY_STR
, b
);
3796 if (rfg
->rt_export_list
)
3798 char *b
= ecommunity_ecom2str (rfg
->rt_export_list
,
3799 ECOMMUNITY_FORMAT_ROUTE_MAP
);
3800 vty_out (vty
, " rt export %s%s", b
, VTY_NEWLINE
);
3801 XFREE (MTYPE_ECOMMUNITY_STR
, b
);
3804 if (bgp
->rfapi
->rfp_methods
.cfg_group_cb
)
3806 (bgp
->rfapi
->rfp_methods
.cfg_group_cb
) (vty
,
3808 RFAPI_RFP_CFG_GROUP_L2
,
3811 vty_out (vty
, " exit-vnc%s", VTY_NEWLINE
);
3812 vty_out (vty
, "!%s", VTY_NEWLINE
);
3816 if (hc
->default_rd
.family
||
3817 hc
->default_response_lifetime
||
3818 hc
->default_rt_import_list
||
3819 hc
->default_rt_export_list
|| hc
->nve_groups_sequential
->count
)
3824 vty_out (vty
, " vnc defaults%s", VTY_NEWLINE
);
3826 if (hc
->default_rd
.prefixlen
)
3829 buf
[0] = buf
[BUFSIZ
- 1] = 0;
3831 if (AF_UNIX
== hc
->default_rd
.family
)
3835 value
= ((hc
->default_rd
.val
[6] << 8) & 0x0ff00) |
3836 (hc
->default_rd
.val
[7] & 0x0ff);
3838 vty_out (vty
, " rd auto:vn:%d%s", value
, VTY_NEWLINE
);
3844 if (!prefix_rd2str (&hc
->default_rd
, buf
, BUFSIZ
) ||
3845 !buf
[0] || buf
[BUFSIZ
- 1])
3848 vty_out (vty
, "!Error: Can't convert rd%s", VTY_NEWLINE
);
3852 vty_out (vty
, " rd %s%s", buf
, VTY_NEWLINE
);
3856 if (hc
->default_response_lifetime
)
3858 vty_out (vty
, " response-lifetime ");
3859 if (hc
->default_response_lifetime
!= UINT32_MAX
)
3860 vty_out (vty
, "%d", hc
->default_response_lifetime
);
3862 vty_out (vty
, "infinite");
3863 vty_out (vty
, "%s", VTY_NEWLINE
);
3865 if (hc
->default_rt_import_list
&& hc
->default_rt_export_list
&&
3866 ecommunity_cmp (hc
->default_rt_import_list
,
3867 hc
->default_rt_export_list
))
3869 char *b
= ecommunity_ecom2str (hc
->default_rt_import_list
,
3870 ECOMMUNITY_FORMAT_ROUTE_MAP
);
3871 vty_out (vty
, " rt both %s%s", b
, VTY_NEWLINE
);
3872 XFREE (MTYPE_ECOMMUNITY_STR
, b
);
3876 if (hc
->default_rt_import_list
)
3878 char *b
= ecommunity_ecom2str (hc
->default_rt_import_list
,
3879 ECOMMUNITY_FORMAT_ROUTE_MAP
);
3880 vty_out (vty
, " rt import %s%s", b
, VTY_NEWLINE
);
3881 XFREE (MTYPE_ECOMMUNITY_STR
, b
);
3883 if (hc
->default_rt_export_list
)
3885 char *b
= ecommunity_ecom2str (hc
->default_rt_export_list
,
3886 ECOMMUNITY_FORMAT_ROUTE_MAP
);
3887 vty_out (vty
, " rt export %s%s", b
, VTY_NEWLINE
);
3888 XFREE (MTYPE_ECOMMUNITY_STR
, b
);
3891 if (bgp
->rfapi
->rfp_methods
.cfg_group_cb
)
3893 (bgp
->rfapi
->rfp_methods
.cfg_group_cb
) (vty
,
3895 RFAPI_RFP_CFG_GROUP_DEFAULT
,
3897 bgp
->rfapi_cfg
->default_rfp_cfg
);
3898 vty_out (vty
, " exit-vnc%s", VTY_NEWLINE
);
3899 vty_out (vty
, "!%s", VTY_NEWLINE
);
3902 for (ALL_LIST_ELEMENTS (hc
->nve_groups_sequential
, node
, nnode
, rfg
))
3905 vty_out (vty
, " vnc nve-group %s%s", rfg
->name
, VTY_NEWLINE
);
3907 if (rfg
->vn_prefix
.family
&& rfg
->vn_node
)
3910 buf
[0] = buf
[BUFSIZ
- 1] = 0;
3912 prefix2str (&rfg
->vn_prefix
, buf
, BUFSIZ
);
3913 if (!buf
[0] || buf
[BUFSIZ
- 1])
3915 vty_out (vty
, "!Error: Can't convert prefix%s", VTY_NEWLINE
);
3919 vty_out (vty
, " prefix %s %s%s", "vn", buf
, VTY_NEWLINE
);
3923 if (rfg
->un_prefix
.family
&& rfg
->un_node
)
3926 buf
[0] = buf
[BUFSIZ
- 1] = 0;
3927 prefix2str (&rfg
->un_prefix
, buf
, BUFSIZ
);
3928 if (!buf
[0] || buf
[BUFSIZ
- 1])
3930 vty_out (vty
, "!Error: Can't convert prefix%s", VTY_NEWLINE
);
3934 vty_out (vty
, " prefix %s %s%s", "un", buf
, VTY_NEWLINE
);
3939 if (rfg
->rd
.prefixlen
)
3942 buf
[0] = buf
[BUFSIZ
- 1] = 0;
3944 if (AF_UNIX
== rfg
->rd
.family
)
3949 value
= ((rfg
->rd
.val
[6] << 8) & 0x0ff00) |
3950 (rfg
->rd
.val
[7] & 0x0ff);
3952 vty_out (vty
, " rd auto:vn:%d%s", value
, VTY_NEWLINE
);
3958 if (!prefix_rd2str (&rfg
->rd
, buf
, BUFSIZ
) ||
3959 !buf
[0] || buf
[BUFSIZ
- 1])
3962 vty_out (vty
, "!Error: Can't convert rd%s", VTY_NEWLINE
);
3966 vty_out (vty
, " rd %s%s", buf
, VTY_NEWLINE
);
3970 if (rfg
->flags
& RFAPI_RFG_RESPONSE_LIFETIME
)
3972 vty_out (vty
, " response-lifetime ");
3973 if (rfg
->response_lifetime
!= UINT32_MAX
)
3974 vty_out (vty
, "%d", rfg
->response_lifetime
);
3976 vty_out (vty
, "infinite");
3977 vty_out (vty
, "%s", VTY_NEWLINE
);
3980 if (rfg
->rt_import_list
&& rfg
->rt_export_list
&&
3981 ecommunity_cmp (rfg
->rt_import_list
, rfg
->rt_export_list
))
3983 char *b
= ecommunity_ecom2str (rfg
->rt_import_list
,
3984 ECOMMUNITY_FORMAT_ROUTE_MAP
);
3985 vty_out (vty
, " rt both %s%s", b
, VTY_NEWLINE
);
3986 XFREE (MTYPE_ECOMMUNITY_STR
, b
);
3990 if (rfg
->rt_import_list
)
3992 char *b
= ecommunity_ecom2str (rfg
->rt_import_list
,
3993 ECOMMUNITY_FORMAT_ROUTE_MAP
);
3994 vty_out (vty
, " rt import %s%s", b
, VTY_NEWLINE
);
3995 XFREE (MTYPE_ECOMMUNITY_STR
, b
);
3997 if (rfg
->rt_export_list
)
3999 char *b
= ecommunity_ecom2str (rfg
->rt_export_list
,
4000 ECOMMUNITY_FORMAT_ROUTE_MAP
);
4001 vty_out (vty
, " rt export %s%s", b
, VTY_NEWLINE
);
4002 XFREE (MTYPE_ECOMMUNITY_STR
, b
);
4007 * route filtering: prefix-lists and route-maps
4009 for (afi
= AFI_IP
; afi
< AFI_MAX
; ++afi
)
4012 const char *afistr
= (afi
== AFI_IP
) ? "ipv4" : "ipv6";
4014 if (rfg
->plist_export_bgp_name
[afi
])
4016 vty_out (vty
, " export bgp %s prefix-list %s%s",
4017 afistr
, rfg
->plist_export_bgp_name
[afi
],
4020 if (rfg
->plist_export_zebra_name
[afi
])
4022 vty_out (vty
, " export zebra %s prefix-list %s%s",
4023 afistr
, rfg
->plist_export_zebra_name
[afi
],
4027 * currently we only support redist plists for bgp-direct.
4028 * If we later add plist support for redistributing other
4029 * protocols, we'll need to loop over protocols here
4031 if (rfg
->plist_redist_name
[ZEBRA_ROUTE_BGP_DIRECT
][afi
])
4033 vty_out (vty
, " redistribute bgp-direct %s prefix-list %s%s",
4035 rfg
->plist_redist_name
[ZEBRA_ROUTE_BGP_DIRECT
][afi
],
4038 if (rfg
->plist_redist_name
[ZEBRA_ROUTE_BGP_DIRECT_EXT
][afi
])
4041 " redistribute bgp-direct-to-nve-groups %s prefix-list %s%s",
4043 rfg
->plist_redist_name
[ZEBRA_ROUTE_BGP_DIRECT_EXT
]
4044 [afi
], VTY_NEWLINE
);
4048 if (rfg
->routemap_export_bgp_name
)
4050 vty_out (vty
, " export bgp route-map %s%s",
4051 rfg
->routemap_export_bgp_name
, VTY_NEWLINE
);
4053 if (rfg
->routemap_export_zebra_name
)
4055 vty_out (vty
, " export zebra route-map %s%s",
4056 rfg
->routemap_export_zebra_name
, VTY_NEWLINE
);
4058 if (rfg
->routemap_redist_name
[ZEBRA_ROUTE_BGP_DIRECT
])
4060 vty_out (vty
, " redistribute bgp-direct route-map %s%s",
4061 rfg
->routemap_redist_name
[ZEBRA_ROUTE_BGP_DIRECT
],
4064 if (rfg
->routemap_redist_name
[ZEBRA_ROUTE_BGP_DIRECT_EXT
])
4067 " redistribute bgp-direct-to-nve-groups route-map %s%s",
4068 rfg
->routemap_redist_name
[ZEBRA_ROUTE_BGP_DIRECT_EXT
],
4071 if (bgp
->rfapi
->rfp_methods
.cfg_group_cb
)
4073 (bgp
->rfapi
->rfp_methods
.cfg_group_cb
) (vty
,
4075 RFAPI_RFP_CFG_GROUP_NVE
,
4076 rfg
->name
, rfg
->rfp_cfg
);
4077 vty_out (vty
, " exit-vnc%s", VTY_NEWLINE
);
4078 vty_out (vty
, "!%s", VTY_NEWLINE
);
4080 } /* have listen ports */
4083 * route export to other protocols
4085 if (VNC_EXPORT_BGP_GRP_ENABLED (hc
))
4087 vty_out (vty
, " vnc export bgp mode group-nve%s", VTY_NEWLINE
);
4089 else if (VNC_EXPORT_BGP_RH_ENABLED (hc
))
4091 vty_out (vty
, " vnc export bgp mode registering-nve%s", VTY_NEWLINE
);
4093 else if (VNC_EXPORT_BGP_CE_ENABLED (hc
))
4095 vty_out (vty
, " vnc export bgp mode ce%s", VTY_NEWLINE
);
4098 if (VNC_EXPORT_ZEBRA_GRP_ENABLED (hc
))
4100 vty_out (vty
, " vnc export zebra mode group-nve%s", VTY_NEWLINE
);
4102 else if (VNC_EXPORT_ZEBRA_RH_ENABLED (hc
))
4104 vty_out (vty
, " vnc export zebra mode registering-nve%s", VTY_NEWLINE
);
4107 if (hc
->rfg_export_direct_bgp_l
)
4109 for (ALL_LIST_ELEMENTS (hc
->rfg_export_direct_bgp_l
, node
, nnode
, rfgn
))
4112 vty_out (vty
, " vnc export bgp group-nve group %s%s",
4113 rfgn
->name
, VTY_NEWLINE
);
4117 if (hc
->rfg_export_zebra_l
)
4119 for (ALL_LIST_ELEMENTS (hc
->rfg_export_zebra_l
, node
, nnode
, rfgn
))
4122 vty_out (vty
, " vnc export zebra group-nve group %s%s",
4123 rfgn
->name
, VTY_NEWLINE
);
4128 if (hc
->rfg_redist_name
)
4130 vty_out (vty
, " vnc redistribute nve-group %s%s",
4131 hc
->rfg_redist_name
, VTY_NEWLINE
);
4133 if (hc
->redist_lifetime
)
4135 vty_out (vty
, " vnc redistribute lifetime %d%s",
4136 hc
->redist_lifetime
, VTY_NEWLINE
);
4138 if (hc
->resolve_nve_roo_local_admin
!=
4139 BGP_VNC_CONFIG_RESOLVE_NVE_ROO_LOCAL_ADMIN_DEFAULT
)
4142 vty_out (vty
, " vnc redistribute resolve-nve roo-ec-local-admin %d%s",
4143 hc
->resolve_nve_roo_local_admin
, VTY_NEWLINE
);
4146 if (hc
->redist_mode
) /* ! default */
4150 switch (hc
->redist_mode
)
4152 case VNC_REDIST_MODE_PLAIN
:
4155 case VNC_REDIST_MODE_RFG
:
4158 case VNC_REDIST_MODE_RESOLVE_NVE
:
4164 vty_out (vty
, " vnc redistribute mode %s%s", s
, VTY_NEWLINE
);
4169 * route filtering: prefix-lists and route-maps
4171 for (afi
= AFI_IP
; afi
< AFI_MAX
; ++afi
)
4174 const char *afistr
= (afi
== AFI_IP
) ? "ipv4" : "ipv6";
4176 if (hc
->plist_export_bgp_name
[afi
])
4178 vty_out (vty
, " vnc export bgp %s prefix-list %s%s",
4179 afistr
, hc
->plist_export_bgp_name
[afi
], VTY_NEWLINE
);
4181 if (hc
->plist_export_zebra_name
[afi
])
4183 vty_out (vty
, " vnc export zebra %s prefix-list %s%s",
4184 afistr
, hc
->plist_export_zebra_name
[afi
], VTY_NEWLINE
);
4186 if (hc
->plist_redist_name
[ZEBRA_ROUTE_BGP_DIRECT
][afi
])
4188 vty_out (vty
, " vnc redistribute bgp-direct %s prefix-list %s%s",
4189 afistr
, hc
->plist_redist_name
[ZEBRA_ROUTE_BGP_DIRECT
][afi
],
4194 if (hc
->routemap_export_bgp_name
)
4196 vty_out (vty
, " vnc export bgp route-map %s%s",
4197 hc
->routemap_export_bgp_name
, VTY_NEWLINE
);
4199 if (hc
->routemap_export_zebra_name
)
4201 vty_out (vty
, " vnc export zebra route-map %s%s",
4202 hc
->routemap_export_zebra_name
, VTY_NEWLINE
);
4204 if (hc
->routemap_redist_name
[ZEBRA_ROUTE_BGP_DIRECT
])
4206 vty_out (vty
, " vnc redistribute bgp-direct route-map %s%s",
4207 hc
->routemap_redist_name
[ZEBRA_ROUTE_BGP_DIRECT
], VTY_NEWLINE
);
4210 for (afi
= AFI_IP
; afi
< AFI_MAX
; ++afi
)
4212 for (type
= 0; type
< ZEBRA_ROUTE_MAX
; ++type
)
4214 if (hc
->redist
[afi
][type
])
4216 if (type
== ZEBRA_ROUTE_BGP_DIRECT_EXT
&&
4217 hc
->redist_bgp_exterior_view_name
)
4219 vty_out (vty
, " vnc redistribute %s %s view %s%s",
4220 ((afi
== AFI_IP
) ? "ipv4" : "ipv6"),
4221 zebra_route_string (type
),
4222 hc
->redist_bgp_exterior_view_name
, VTY_NEWLINE
);
4226 vty_out (vty
, " vnc redistribute %s %s%s",
4227 ((afi
== AFI_IP
) ? "ipv4" : "ipv6"),
4228 zebra_route_string (type
), VTY_NEWLINE
);
4237 bgp_rfapi_show_summary (struct bgp
*bgp
, struct vty
*vty
)
4239 struct rfapi_cfg
*hc
= bgp
->rfapi_cfg
;
4240 int afi
, type
, redist
= 0;
4245 vty_out (vty
, "%-39s %-19s %s%s", "VNC Advertise method:",
4246 (hc
->flags
& BGP_VNC_CONFIG_ADV_UN_METHOD_ENCAP
4247 ? "Encapsulation SAFI" : "Tunnel Encap attribute"),
4248 ((hc
->flags
& BGP_VNC_CONFIG_ADV_UN_METHOD_ENCAP
) ==
4249 (BGP_VNC_CONFIG_ADV_UN_METHOD_ENCAP
&
4250 BGP_VNC_CONFIG_FLAGS_DEFAULT
) ? "(default)" : ""), VTY_NEWLINE
);
4252 vty_out (vty
, "%-39s ", "Export from VNC:");
4254 * route export to other protocols
4256 if (VNC_EXPORT_BGP_GRP_ENABLED (hc
))
4259 vty_out (vty
, "ToBGP Groups={");
4260 if (hc
->rfg_export_direct_bgp_l
)
4263 struct listnode
*node
, *nnode
;
4264 struct rfapi_rfg_name
*rfgn
;
4265 for (ALL_LIST_ELEMENTS (hc
->rfg_export_direct_bgp_l
,
4271 vty_out (vty
, "%s", rfgn
->name
);
4276 else if (VNC_EXPORT_BGP_RH_ENABLED (hc
))
4279 vty_out (vty
, "ToBGP {Registering NVE}");
4280 /* note filters, route-maps not shown */
4282 else if (VNC_EXPORT_BGP_CE_ENABLED (hc
))
4285 vty_out (vty
, "ToBGP {NVE connected router:%d}",
4286 hc
->resolve_nve_roo_local_admin
);
4287 /* note filters, route-maps not shown */
4290 if (VNC_EXPORT_ZEBRA_GRP_ENABLED (hc
))
4293 vty_out (vty
, "%sToZebra Groups={", (redist
== 1 ? "" : " "));
4294 if (hc
->rfg_export_direct_bgp_l
)
4297 struct listnode
*node
, *nnode
;
4298 struct rfapi_rfg_name
*rfgn
;
4299 for (ALL_LIST_ELEMENTS (hc
->rfg_export_zebra_l
, node
, nnode
, rfgn
))
4303 vty_out (vty
, "%s", rfgn
->name
);
4308 else if (VNC_EXPORT_ZEBRA_RH_ENABLED (hc
))
4311 vty_out (vty
, "%sToZebra {Registering NVE}", (redist
== 1 ? "" : " "));
4312 /* note filters, route-maps not shown */
4314 vty_out (vty
, "%-19s %s%s", (redist
? "" : "Off"),
4315 (redist
? "" : "(default)"), VTY_NEWLINE
);
4317 /* Redistribution */
4319 vty_out (vty
, "%-39s ", "Redistribution into VNC:");
4320 for (afi
= AFI_IP
; afi
< AFI_MAX
; ++afi
)
4322 for (type
= 0; type
< ZEBRA_ROUTE_MAX
; ++type
)
4324 if (hc
->redist
[afi
][type
])
4326 vty_out (vty
, "{%s,%s} ",
4327 ((afi
== AFI_IP
) ? "ipv4" : "ipv6"),
4328 zebra_route_string (type
));
4333 vty_out (vty
, "%-19s %s%s", (redist
? "" : "Off"),
4334 (redist
? "" : "(default)"), VTY_NEWLINE
);
4336 vty_out (vty
, "%-39s %3u%-16s %s%s", "RFP Registration Hold-Down Factor:",
4337 hc
->rfp_cfg
.holddown_factor
, "%",
4338 (hc
->rfp_cfg
.holddown_factor
==
4339 RFAPI_RFP_CFG_DEFAULT_HOLDDOWN_FACTOR
? "(default)" : ""),
4341 vty_out (vty
, "%-39s %-19s %s%s", "RFP Updated responses:",
4342 (hc
->rfp_cfg
.use_updated_response
== 0 ? "Off" : "On"),
4343 (hc
->rfp_cfg
.use_updated_response
== 0 ? "(default)" : ""),
4345 vty_out (vty
, "%-39s %-19s %s%s", "RFP Removal responses:",
4346 (hc
->rfp_cfg
.use_removes
== 0 ? "Off" : "On"),
4347 (hc
->rfp_cfg
.use_removes
== 0 ? "(default)" : ""), VTY_NEWLINE
);
4348 vty_out (vty
, "%-39s %-19s %s%s", "RFP Full table download:",
4349 (hc
->rfp_cfg
.download_type
==
4350 RFAPI_RFP_DOWNLOAD_FULL
? "On" : "Off"),
4351 (hc
->rfp_cfg
.download_type
==
4352 RFAPI_RFP_DOWNLOAD_PARTIAL
? "(default)" : ""), VTY_NEWLINE
);
4353 sprintf (tmp
, "%u seconds", hc
->rfp_cfg
.ftd_advertisement_interval
);
4354 vty_out (vty
, "%-39s %-19s %s%s", " Advertisement Interval:", tmp
,
4355 (hc
->rfp_cfg
.ftd_advertisement_interval
==
4356 RFAPI_RFP_CFG_DEFAULT_FTD_ADVERTISEMENT_INTERVAL
4357 ? "(default)" : ""), VTY_NEWLINE
);
4358 vty_out (vty
, "%-39s %d seconds%s", "Default RFP response lifetime:",
4359 hc
->default_response_lifetime
, VTY_NEWLINE
);
4360 vty_out (vty
, "%s", VTY_NEWLINE
);
4365 bgp_rfapi_get_config (struct bgp
*bgp
)
4367 struct rfapi_cfg
*hc
= NULL
;
4369 bgp
= bgp_get_default ();
4371 hc
= bgp
->rfapi_cfg
;
4375 #endif /* ENABLE_BGP_VNC */