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 along
17 * with this program; see the file COPYING; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
20 #include "lib/zebra.h"
22 #include "lib/command.h"
23 #include "lib/prefix.h"
24 #include "lib/memory.h"
25 #include "lib/linklist.h"
26 #include "lib/table.h"
27 #include "lib/plist.h"
28 #include "lib/routemap.h"
30 #include "bgpd/bgpd.h"
31 #include "bgpd/bgp_attr.h"
32 #include "bgpd/bgp_route.h"
33 #include "bgpd/bgp_mplsvpn.h"
35 #include "bgpd/bgp_ecommunity.h"
36 #include "bgpd/rfapi/rfapi.h"
37 #include "bgpd/rfapi/bgp_rfapi_cfg.h"
38 #include "bgpd/rfapi/rfapi_backend.h"
39 #include "bgpd/rfapi/rfapi_import.h"
40 #include "bgpd/rfapi/rfapi_private.h"
41 #include "bgpd/rfapi/rfapi_monitor.h"
42 #include "bgpd/rfapi/vnc_zebra.h"
43 #include "bgpd/rfapi/vnc_export_bgp.h"
44 #include "bgpd/rfapi/vnc_export_bgp_p.h"
45 #include "bgpd/rfapi/rfapi_vty.h"
46 #include "bgpd/rfapi/vnc_import_bgp.h"
47 #include "bgpd/rfapi/vnc_debug.h"
51 #undef BGP_VNC_DEBUG_MATCH_GROUP
54 DEFINE_MGROUP(RFAPI
, "rfapi")
55 DEFINE_MTYPE(RFAPI
, RFAPI_CFG
, "NVE Configuration")
56 DEFINE_MTYPE(RFAPI
, RFAPI_GROUP_CFG
, "NVE Group Configuration")
57 DEFINE_MTYPE(RFAPI
, RFAPI_L2_CFG
, "RFAPI L2 Group Configuration")
58 DEFINE_MTYPE(RFAPI
, RFAPI_RFP_GROUP_CFG
, "RFAPI RFP Group Configuration")
59 DEFINE_MTYPE(RFAPI
, RFAPI
, "RFAPI Generic")
60 DEFINE_MTYPE(RFAPI
, RFAPI_DESC
, "RFAPI Descriptor")
61 DEFINE_MTYPE(RFAPI
, RFAPI_IMPORTTABLE
, "RFAPI Import Table")
62 DEFINE_MTYPE(RFAPI
, RFAPI_MONITOR
, "RFAPI Monitor VPN")
63 DEFINE_MTYPE(RFAPI
, RFAPI_MONITOR_ENCAP
, "RFAPI Monitor Encap")
64 DEFINE_MTYPE(RFAPI
, RFAPI_NEXTHOP
, "RFAPI Next Hop")
65 DEFINE_MTYPE(RFAPI
, RFAPI_VN_OPTION
, "RFAPI VN Option")
66 DEFINE_MTYPE(RFAPI
, RFAPI_UN_OPTION
, "RFAPI UN Option")
67 DEFINE_MTYPE(RFAPI
, RFAPI_WITHDRAW
, "RFAPI Withdraw")
68 DEFINE_MTYPE(RFAPI
, RFAPI_RFG_NAME
, "RFAPI RFGName")
69 DEFINE_MTYPE(RFAPI
, RFAPI_ADB
, "RFAPI Advertisement Data")
70 DEFINE_MTYPE(RFAPI
, RFAPI_ETI
, "RFAPI Export Table Info")
71 DEFINE_MTYPE(RFAPI
, RFAPI_NVE_ADDR
, "RFAPI NVE Address")
72 DEFINE_MTYPE(RFAPI
, RFAPI_PREFIX_BAG
, "RFAPI Prefix Bag")
73 DEFINE_MTYPE(RFAPI
, RFAPI_IT_EXTRA
, "RFAPI IT Extra")
74 DEFINE_MTYPE(RFAPI
, RFAPI_INFO
, "RFAPI Info")
75 DEFINE_MTYPE(RFAPI
, RFAPI_ADDR
, "RFAPI Addr")
76 DEFINE_MTYPE(RFAPI
, RFAPI_UPDATED_RESPONSE_QUEUE
, "RFAPI Updated Rsp Queue")
77 DEFINE_MTYPE(RFAPI
, RFAPI_RECENT_DELETE
, "RFAPI Recently Deleted Route")
78 DEFINE_MTYPE(RFAPI
, RFAPI_L2ADDR_OPT
, "RFAPI L2 Address Option")
79 DEFINE_MTYPE(RFAPI
, RFAPI_AP
, "RFAPI Advertised Prefix")
80 DEFINE_MTYPE(RFAPI
, RFAPI_MONITOR_ETH
, "RFAPI Monitor Ethernet")
82 DEFINE_QOBJ_TYPE(rfapi_nve_group_cfg
)
83 DEFINE_QOBJ_TYPE(rfapi_l2_group_cfg
)
84 /***********************************************************************
86 ***********************************************************************/
90 * compaitibility to old quagga_time call
91 * time_t value in terms of stabilised absolute time.
92 * replacement for POSIX time()
95 rfapi_time (time_t *t
)
97 time_t clock
= bgp_clock();
104 nve_group_to_nve_list (
105 struct rfapi_nve_group_cfg
*rfg
,
107 uint8_t family
) /* AF_INET, AF_INET6 */
109 struct listnode
*hln
;
110 struct rfapi_descriptor
*rfd
;
113 * loop over nves in this grp, add to list
115 for (ALL_LIST_ELEMENTS_RO (rfg
->nves
, hln
, rfd
))
117 if (rfd
->vn_addr
.addr_family
== family
)
121 listnode_add (*nves
, rfd
);
127 struct rfapi_nve_group_cfg
*
128 bgp_rfapi_cfg_match_group (
129 struct rfapi_cfg
*hc
,
133 struct rfapi_nve_group_cfg
*rfg_vn
= NULL
;
134 struct rfapi_nve_group_cfg
*rfg_un
= NULL
;
136 struct route_table
*rt_vn
;
137 struct route_table
*rt_un
;
138 struct route_node
*rn_vn
;
139 struct route_node
*rn_un
;
141 struct rfapi_nve_group_cfg
*rfg
;
142 struct listnode
*node
, *nnode
;
147 rt_vn
= &(hc
->nve_groups_vn
[AFI_IP
]);
150 rt_vn
= &(hc
->nve_groups_vn
[AFI_IP6
]);
159 rt_un
= &(hc
->nve_groups_un
[AFI_IP
]);
162 rt_un
= &(hc
->nve_groups_un
[AFI_IP6
]);
168 rn_vn
= route_node_match (rt_vn
, vn
); /* NB locks node */
171 rfg_vn
= rn_vn
->info
;
172 route_unlock_node (rn_vn
);
175 rn_un
= route_node_match (rt_un
, un
); /* NB locks node */
178 rfg_un
= rn_un
->info
;
179 route_unlock_node (rn_un
);
182 #if BGP_VNC_DEBUG_MATCH_GROUP
186 prefix2str (vn
, buf
, BUFSIZ
);
187 vnc_zlog_debug_verbose ("%s: vn prefix: %s", __func__
, buf
);
189 prefix2str (un
, buf
, BUFSIZ
);
190 vnc_zlog_debug_verbose ("%s: un prefix: %s", __func__
, buf
);
192 vnc_zlog_debug_verbose ("%s: rn_vn=%p, rn_un=%p, rfg_vn=%p, rfg_un=%p",
193 __func__
, rn_vn
, rn_un
, rfg_vn
, rfg_un
);
198 if (rfg_un
== rfg_vn
) /* same group */
200 if (!rfg_un
) /* un doesn't match, return vn-matched grp */
202 if (!rfg_vn
) /* vn doesn't match, return un-matched grp */
206 * Two different nve groups match: the group configured earlier wins.
207 * For now, just walk the sequential list and pick the first one.
208 * If this approach is too slow, then store serial numbers in the
209 * nve group structures as they are defined and just compare
212 for (ALL_LIST_ELEMENTS (hc
->nve_groups_sequential
, node
, nnode
, rfg
))
214 if ((rfg
== rfg_un
) || (rfg
== rfg_vn
))
219 vnc_zlog_debug_verbose ("%s: shouldn't happen, returning NULL when un and vn match",
221 return NULL
; /* shouldn't happen */
224 /*------------------------------------------
225 * rfapi_get_rfp_start_val
227 * Returns value passed to rfapi on rfp_start
230 * void * bgp structure
234 *------------------------------------------*/
236 rfapi_get_rfp_start_val (void *bgpv
)
238 struct bgp
*bgp
= bgpv
;
239 if (bgp
== NULL
|| bgp
->rfapi
== NULL
)
241 return bgp
->rfapi
->rfp
;
244 /*------------------------------------------
245 * bgp_rfapi_is_vnc_configured
247 * Returns if VNC (BGP VPN messaging /VPN & encap SAFIs) are configured
250 * bgp NULL (=use default instance)
254 * return value: If VNC is configured for the bgpd instance
256 * ENXIO VNC not configured
257 --------------------------------------------*/
259 bgp_rfapi_is_vnc_configured (struct bgp
*bgp
)
262 bgp
= bgp_get_default ();
264 if (bgp
&& bgp
->rfapi_cfg
)
267 struct peer_group
*group
;
268 struct listnode
*node
, *nnode
;
269 /* if have configured VPN neighbors, assume running VNC */
270 for (ALL_LIST_ELEMENTS (bgp
->group
, node
, nnode
, group
))
272 if (group
->conf
->afc
[AFI_IP
][SAFI_MPLS_VPN
] ||
273 group
->conf
->afc
[AFI_IP6
][SAFI_MPLS_VPN
])
276 for (ALL_LIST_ELEMENTS (bgp
->peer
, node
, nnode
, peer
))
278 if (peer
->afc
[AFI_IP
][SAFI_MPLS_VPN
] ||
279 peer
->afc
[AFI_IP6
][SAFI_MPLS_VPN
])
286 /***********************************************************************
287 * VNC Configuration/CLI
288 ***********************************************************************/
291 DEFUN (vnc_advertise_un_method
,
292 vnc_advertise_un_method_cmd
,
293 "vnc advertise-un-method encap-attr",
295 "Method of advertising UN addresses\n"
296 "Via Tunnel Encap attribute (in VPN SAFI)\n")
298 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
302 vty_out (vty
, "VNC not configured%s", VTY_NEWLINE
);
307 if (!strncmp (argv
[2]->arg
, "encap-safi", 7))
309 bgp
->rfapi_cfg
->flags
|= BGP_VNC_CONFIG_ADV_UN_METHOD_ENCAP
;
313 bgp
->rfapi_cfg
->flags
&= ~BGP_VNC_CONFIG_ADV_UN_METHOD_ENCAP
;
319 /*-------------------------------------------------------------------------
321 *-----------------------------------------------------------------------*/
324 DEFUN_NOSH (vnc_defaults
,
326 "vnc defaults", VNC_CONFIG_STR
"Configure default NVE group\n")
328 vty
->node
= BGP_VNC_DEFAULTS_NODE
;
336 struct cmd_token
**argv
,
337 struct ecommunity
**list
)
339 struct ecommunity
*ecom
= NULL
;
340 struct ecommunity
*ecomadd
;
342 for (; argc
; --argc
, ++argv
)
345 ecomadd
= ecommunity_str2com (argv
[0]->arg
, ECOMMUNITY_ROUTE_TARGET
, 0);
348 vty_out (vty
, "Malformed community-list value%s", VTY_NEWLINE
);
350 ecommunity_free (&ecom
);
356 ecommunity_merge (ecom
, ecomadd
);
357 ecommunity_free (&ecomadd
);
367 ecommunity_free (&*list
);
374 DEFUN (vnc_defaults_rt_import
,
375 vnc_defaults_rt_import_cmd
,
376 "rt import RTLIST...",
377 "Specify default route targets\n"
379 "Space separated route target list (A.B.C.D:MN|EF:OPQR|GHJK:MN)\n")
381 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
382 return set_ecom_list (vty
, argc
- 2, argv
+ 2,
383 &bgp
->rfapi_cfg
->default_rt_import_list
);
386 DEFUN (vnc_defaults_rt_export
,
387 vnc_defaults_rt_export_cmd
,
388 "rt export RTLIST...",
389 "Configure default route targets\n"
391 "Space separated route target list (A.B.C.D:MN|EF:OPQR|GHJK:MN)\n")
393 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
394 return set_ecom_list (vty
, argc
- 2, argv
+ 2,
395 &bgp
->rfapi_cfg
->default_rt_export_list
);
398 DEFUN (vnc_defaults_rt_both
,
399 vnc_defaults_rt_both_cmd
,
401 "Configure default route targets\n"
402 "Export+import filters\n"
403 "Space separated route target list (A.B.C.D:MN|EF:OPQR|GHJK:MN)\n")
405 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
408 rc
= set_ecom_list (vty
, argc
- 2, argv
+ 2,
409 &bgp
->rfapi_cfg
->default_rt_import_list
);
410 if (rc
!= CMD_SUCCESS
)
412 return set_ecom_list (vty
, argc
- 2, argv
+ 2,
413 &bgp
->rfapi_cfg
->default_rt_export_list
);
416 DEFUN (vnc_defaults_rd
,
418 "rd ASN:nn_or_IP-address:nn",
419 "Specify default route distinguisher\n"
420 "Route Distinguisher (<as-number>:<number> | <ip-address>:<number> | auto:vn:<number> )\n")
422 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
424 struct prefix_rd prd
;
426 if (!strncmp (argv
[1]->arg
, "auto:vn:", 8))
429 * use AF_UNIX to designate automatically-assigned RD
430 * auto:vn:nn where nn is a 2-octet quantity
433 uint32_t value32
= strtoul (argv
[1]->arg
+ 8, &end
, 10);
434 uint16_t value
= value32
& 0xffff;
436 if (!argv
[1]->arg
[8] || *end
)
438 vty_out (vty
, "%% Malformed rd%s", VTY_NEWLINE
);
441 if (value32
> 0xffff)
443 vty_out (vty
, "%% Malformed rd (must be less than %u%s",
444 0x0ffff, VTY_NEWLINE
);
448 memset (&prd
, 0, sizeof (prd
));
449 prd
.family
= AF_UNIX
;
451 prd
.val
[0] = (RD_TYPE_IP
>> 8) & 0x0ff;
452 prd
.val
[1] = RD_TYPE_IP
& 0x0ff;
453 prd
.val
[6] = (value
>> 8) & 0x0ff;
454 prd
.val
[7] = value
& 0x0ff;
460 ret
= str2prefix_rd (argv
[1]->arg
, &prd
);
463 vty_out (vty
, "%% Malformed rd%s", VTY_NEWLINE
);
468 bgp
->rfapi_cfg
->default_rd
= prd
;
472 DEFUN (vnc_defaults_l2rd
,
473 vnc_defaults_l2rd_cmd
,
474 "l2rd <(1-255)|auto-vn>",
475 "Specify default Local Nve ID value to use in RD for L2 routes\n"
476 "Fixed value 1-255\n"
477 "use the low-order octet of the NVE's VN address\n")
479 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
482 if (strmatch(argv
[1]->text
, "auto-vn"))
489 unsigned long value_l
= strtoul (argv
[1]->arg
, &end
, 10);
491 value
= value_l
& 0xff;
492 if (!argv
[1]->arg
[0] || *end
)
494 vty_out (vty
, "%% Malformed l2 nve ID \"%s\"%s", argv
[1]->arg
,
498 if ((value_l
< 1) || (value_l
> 0xff))
501 "%% Malformed l2 nve id (must be greater than 0 and less than %u%s",
506 bgp
->rfapi_cfg
->flags
|= BGP_VNC_CONFIG_L2RD
;
507 bgp
->rfapi_cfg
->default_l2rd
= value
;
512 DEFUN (vnc_defaults_no_l2rd
,
513 vnc_defaults_no_l2rd_cmd
,
516 "Specify default Local Nve ID value to use in RD for L2 routes\n")
518 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
520 bgp
->rfapi_cfg
->default_l2rd
= 0;
521 bgp
->rfapi_cfg
->flags
&= ~BGP_VNC_CONFIG_L2RD
;
526 DEFUN (vnc_defaults_responselifetime
,
527 vnc_defaults_responselifetime_cmd
,
528 "response-lifetime <LIFETIME|infinite>",
529 "Specify default response lifetime\n"
530 "Response lifetime in seconds\n" "Infinite response lifetime\n")
532 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
534 struct rfapi
*h
= NULL
;
535 struct listnode
*hdnode
;
536 struct rfapi_descriptor
*rfd
;
542 if (strmatch(argv
[1]->text
, "infinite"))
544 rspint
= RFAPI_INFINITE_LIFETIME
;
548 VTY_GET_INTEGER ("Response Lifetime", rspint
, argv
[1]->arg
);
549 if (rspint
> INT32_MAX
)
550 rspint
= INT32_MAX
; /* is really an int, not an unsigned int */
553 bgp
->rfapi_cfg
->default_response_lifetime
= rspint
;
555 for (ALL_LIST_ELEMENTS_RO (&h
->descriptors
, hdnode
, rfd
))
556 if (rfd
->rfg
&& !(rfd
->rfg
->flags
& RFAPI_RFG_RESPONSE_LIFETIME
))
557 rfd
->response_lifetime
= rfd
->rfg
->response_lifetime
= rspint
;
562 struct rfapi_nve_group_cfg
*
563 bgp_rfapi_cfg_match_byname (struct bgp
*bgp
, const char *name
,
564 rfapi_group_cfg_type_t type
) /* _MAX = any */
566 struct rfapi_nve_group_cfg
*rfg
;
567 struct listnode
*node
, *nnode
;
569 for (ALL_LIST_ELEMENTS
570 (bgp
->rfapi_cfg
->nve_groups_sequential
, node
, nnode
, rfg
))
572 if ((type
== RFAPI_GROUP_CFG_MAX
|| type
== rfg
->type
) &&
573 !strcmp (rfg
->name
, name
))
579 static struct rfapi_nve_group_cfg
*
580 rfapi_group_new (struct bgp
*bgp
,
581 rfapi_group_cfg_type_t type
,
584 struct rfapi_nve_group_cfg
*rfg
;
586 rfg
= XCALLOC (MTYPE_RFAPI_GROUP_CFG
, sizeof (struct rfapi_nve_group_cfg
));
590 rfg
->name
= strdup (name
);
591 /* add to tail of list */
592 listnode_add (bgp
->rfapi_cfg
->nve_groups_sequential
, rfg
);
594 rfg
->label
= MPLS_LABEL_ILLEGAL
;
595 QOBJ_REG (rfg
, rfapi_nve_group_cfg
);
600 static struct rfapi_l2_group_cfg
*
601 rfapi_l2_group_lookup_byname (struct bgp
*bgp
, const char *name
)
603 struct rfapi_l2_group_cfg
*rfg
;
604 struct listnode
*node
, *nnode
;
606 if (bgp
->rfapi_cfg
->l2_groups
== NULL
) /* not the best place for this */
607 bgp
->rfapi_cfg
->l2_groups
= list_new ();
609 for (ALL_LIST_ELEMENTS (bgp
->rfapi_cfg
->l2_groups
, node
, nnode
, rfg
))
611 if (!strcmp (rfg
->name
, name
))
617 static struct rfapi_l2_group_cfg
*
618 rfapi_l2_group_new ()
620 struct rfapi_l2_group_cfg
*rfg
;
622 rfg
= XCALLOC (MTYPE_RFAPI_L2_CFG
, sizeof (struct rfapi_l2_group_cfg
));
623 QOBJ_REG (rfg
, rfapi_l2_group_cfg
);
629 rfapi_l2_group_del (struct rfapi_l2_group_cfg
*rfg
)
632 XFREE (MTYPE_RFAPI_L2_CFG
, rfg
);
636 rfapi_str2route_type (
645 if (!strcmp (l3str
, "ipv4"))
651 if (!strcmp (l3str
, "ipv6"))
657 if (!strcmp (pstr
, "connected"))
658 *type
= ZEBRA_ROUTE_CONNECT
;
659 if (!strcmp (pstr
, "kernel"))
660 *type
= ZEBRA_ROUTE_KERNEL
;
661 if (!strcmp (pstr
, "static"))
662 *type
= ZEBRA_ROUTE_STATIC
;
663 if (!strcmp (pstr
, "bgp"))
664 *type
= ZEBRA_ROUTE_BGP
;
665 if (!strcmp (pstr
, "bgp-direct"))
666 *type
= ZEBRA_ROUTE_BGP_DIRECT
;
667 if (!strcmp (pstr
, "bgp-direct-to-nve-groups"))
668 *type
= ZEBRA_ROUTE_BGP_DIRECT_EXT
;
670 if (!strcmp (pstr
, "rip"))
673 *type
= ZEBRA_ROUTE_RIP
;
675 *type
= ZEBRA_ROUTE_RIPNG
;
678 if (!strcmp (pstr
, "ripng"))
682 *type
= ZEBRA_ROUTE_RIPNG
;
685 if (!strcmp (pstr
, "ospf"))
688 *type
= ZEBRA_ROUTE_OSPF
;
690 *type
= ZEBRA_ROUTE_OSPF6
;
693 if (!strcmp (pstr
, "ospf6"))
697 *type
= ZEBRA_ROUTE_OSPF6
;
703 /*-------------------------------------------------------------------------
705 *-----------------------------------------------------------------------*/
707 #define VNC_REDIST_ENABLE(bgp, afi, type) do { \
709 case ZEBRA_ROUTE_BGP_DIRECT: \
710 vnc_import_bgp_redist_enable((bgp), (afi)); \
712 case ZEBRA_ROUTE_BGP_DIRECT_EXT: \
713 vnc_import_bgp_exterior_redist_enable((bgp), (afi));\
716 vnc_redistribute_set((bgp), (afi), (type)); \
721 #define VNC_REDIST_DISABLE(bgp, afi, type) do { \
723 case ZEBRA_ROUTE_BGP_DIRECT: \
724 vnc_import_bgp_redist_disable((bgp), (afi)); \
726 case ZEBRA_ROUTE_BGP_DIRECT_EXT: \
727 vnc_import_bgp_exterior_redist_disable((bgp), (afi));\
730 vnc_redistribute_unset((bgp), (afi), (type)); \
735 static uint8_t redist_was_enabled
[AFI_MAX
][ZEBRA_ROUTE_MAX
];
738 vnc_redistribute_prechange (struct bgp
*bgp
)
743 vnc_zlog_debug_verbose ("%s: entry", __func__
);
744 memset (redist_was_enabled
, 0, sizeof (redist_was_enabled
));
747 * Look to see if we have any redistribution enabled. If so, flush
748 * the corresponding routes and turn off redistribution temporarily.
749 * We need to do it because the RD's used for the redistributed
750 * routes depend on the nve group.
752 for (afi
= AFI_IP
; afi
< AFI_MAX
; ++afi
)
754 for (type
= 0; type
< ZEBRA_ROUTE_MAX
; ++type
)
756 if (bgp
->rfapi_cfg
->redist
[afi
][type
])
758 redist_was_enabled
[afi
][type
] = 1;
759 VNC_REDIST_DISABLE (bgp
, afi
, type
);
763 vnc_zlog_debug_verbose ("%s: return", __func__
);
767 vnc_redistribute_postchange (struct bgp
*bgp
)
772 vnc_zlog_debug_verbose ("%s: entry", __func__
);
774 * If we turned off redistribution above, turn it back on. Doing so
775 * will tell zebra to resend the routes to us
777 for (afi
= AFI_IP
; afi
< AFI_MAX
; ++afi
)
779 for (type
= 0; type
< ZEBRA_ROUTE_MAX
; ++type
)
781 if (redist_was_enabled
[afi
][type
])
783 VNC_REDIST_ENABLE (bgp
, afi
, type
);
787 vnc_zlog_debug_verbose ("%s: return", __func__
);
790 DEFUN (vnc_redistribute_rh_roo_localadmin
,
791 vnc_redistribute_rh_roo_localadmin_cmd
,
792 "vnc redistribute resolve-nve roo-ec-local-admin (0-65535)",
794 "Redistribute routes into VNC\n"
796 "Route Origin Extended Community Local Admin Field\n" "Field value\n")
798 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
804 vty_out (vty
, "RFAPI not configured%s", VTY_NEWLINE
);
808 localadmin
= strtoul (argv
[4]->arg
, &endptr
, 0);
809 if (!argv
[4]->arg
[0] || *endptr
)
811 vty_out (vty
, "%% Malformed value%s", VTY_NEWLINE
);
815 if (localadmin
> 0xffff)
817 vty_out (vty
, "%% Value out of range (0-%d)%s", 0xffff, VTY_NEWLINE
);
821 if (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_prechange (bgp
);
830 vnc_redistribute_prechange (bgp
);
832 bgp
->rfapi_cfg
->resolve_nve_roo_local_admin
= localadmin
;
834 if ((bgp
->rfapi_cfg
->flags
& BGP_VNC_CONFIG_EXPORT_BGP_MODE_BITS
) ==
835 BGP_VNC_CONFIG_EXPORT_BGP_MODE_CE
)
838 vnc_export_bgp_postchange (bgp
);
840 vnc_redistribute_postchange (bgp
);
846 DEFUN (vnc_redistribute_mode
,
847 vnc_redistribute_mode_cmd
,
848 "vnc redistribute mode <nve-group|plain|resolve-nve>",
850 "Redistribute routes into VNC\n"
851 "Redistribution mode\n"
852 "Based on redistribute nve-group\n"
853 "Unmodified\n" "Resolve each nexthop to connected NVEs\n")
855 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
856 vnc_redist_mode_t newmode
;
860 vty_out (vty
, "RFAPI not configured%s", VTY_NEWLINE
);
865 switch (argv
[3]->arg
[0])
868 newmode
= VNC_REDIST_MODE_RFG
;
872 newmode
= VNC_REDIST_MODE_PLAIN
;
876 newmode
= VNC_REDIST_MODE_RESOLVE_NVE
;
880 vty_out (vty
, "unknown redistribute mode%s", VTY_NEWLINE
);
884 if (newmode
!= bgp
->rfapi_cfg
->redist_mode
)
886 vnc_redistribute_prechange (bgp
);
887 bgp
->rfapi_cfg
->redist_mode
= newmode
;
888 vnc_redistribute_postchange (bgp
);
894 DEFUN (vnc_redistribute_protocol
,
895 vnc_redistribute_protocol_cmd
,
896 "vnc redistribute <ipv4|ipv6> <bgp|bgp-direct|bgp-direct-to-nve-groups|connected|kernel|ospf|rip|static>",
898 "Redistribute routes into VNC\n"
902 "From BGP without Zebra\n"
903 "From BGP without Zebra, only to configured NVE groups\n"
904 "Connected interfaces\n"
905 "From kernel routes\n"
906 "From Open Shortest Path First (OSPF)\n"
907 "From Routing Information Protocol (RIP)\n" "From Static routes\n")
909 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
910 int type
= ZEBRA_ROUTE_MAX
; /* init to bogus value */
915 vty_out (vty
, "RFAPI not configured%s", VTY_NEWLINE
);
919 if (rfapi_str2route_type (argv
[2]->arg
, argv
[3]->arg
, &afi
, &type
))
921 vty_out (vty
, "%% Invalid route type%s", VTY_NEWLINE
);
925 if (type
== ZEBRA_ROUTE_BGP_DIRECT_EXT
)
927 if (bgp
->rfapi_cfg
->redist_bgp_exterior_view_name
)
929 VNC_REDIST_DISABLE (bgp
, afi
, type
); /* disabled view implicitly */
930 free (bgp
->rfapi_cfg
->redist_bgp_exterior_view_name
);
931 bgp
->rfapi_cfg
->redist_bgp_exterior_view_name
= NULL
;
933 bgp
->rfapi_cfg
->redist_bgp_exterior_view
= bgp
;
936 VNC_REDIST_ENABLE (bgp
, afi
, type
);
941 DEFUN (vnc_no_redistribute_protocol
,
942 vnc_no_redistribute_protocol_cmd
,
943 "no vnc redistribute <ipv4|ipv6> <bgp|bgp-direct|bgp-direct-to-nve-groups|connected|kernel|ospf|rip|static>",
946 "Redistribute from other protocol\n"
950 "From BGP without Zebra\n"
951 "From BGP without Zebra, only to configured NVE groups\n"
952 "Connected interfaces\n"
953 "From kernel routes\n"
954 "From Open Shortest Path First (OSPF)\n"
955 "From Routing Information Protocol (RIP)\n" "From Static routes\n")
957 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
963 vty_out (vty
, "RFAPI not configured%s", VTY_NEWLINE
);
967 if (rfapi_str2route_type (argv
[3]->arg
, argv
[4]->arg
, &afi
, &type
))
969 vty_out (vty
, "%% Invalid route type%s", VTY_NEWLINE
);
973 VNC_REDIST_DISABLE (bgp
, afi
, type
);
975 if (type
== ZEBRA_ROUTE_BGP_DIRECT_EXT
)
977 if (bgp
->rfapi_cfg
->redist_bgp_exterior_view_name
)
979 free (bgp
->rfapi_cfg
->redist_bgp_exterior_view_name
);
980 bgp
->rfapi_cfg
->redist_bgp_exterior_view_name
= NULL
;
982 bgp
->rfapi_cfg
->redist_bgp_exterior_view
= NULL
;
988 DEFUN (vnc_redistribute_bgp_exterior
,
989 vnc_redistribute_bgp_exterior_cmd
,
990 "vnc redistribute <ipv4|ipv6> bgp-direct-to-nve-groups view NAME",
992 "Redistribute routes into VNC\n"
995 "From BGP without Zebra, only to configured NVE groups\n"
996 "From BGP view\n" "BGP view name\n")
998 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1002 if (!bgp
->rfapi_cfg
)
1004 vty_out (vty
, "RFAPI not configured%s", VTY_NEWLINE
);
1008 if (rfapi_str2route_type (argv
[2]->arg
, "bgp-direct-to-nve-groups", &afi
, &type
))
1010 vty_out (vty
, "%% Invalid route type%s", VTY_NEWLINE
);
1014 if (bgp
->rfapi_cfg
->redist_bgp_exterior_view_name
)
1015 free (bgp
->rfapi_cfg
->redist_bgp_exterior_view_name
);
1016 bgp
->rfapi_cfg
->redist_bgp_exterior_view_name
= strdup (argv
[5]->arg
);
1017 /* could be NULL if name is not defined yet */
1018 bgp
->rfapi_cfg
->redist_bgp_exterior_view
= bgp_lookup_by_name (argv
[5]->arg
);
1020 VNC_REDIST_ENABLE (bgp
, afi
, type
);
1025 DEFUN (vnc_redistribute_nvegroup
,
1026 vnc_redistribute_nvegroup_cmd
,
1027 "vnc redistribute nve-group NAME",
1029 "Assign a NVE group to routes redistributed from another routing protocol\n"
1030 "NVE group\n" "Group name\n")
1032 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1034 if (!bgp
->rfapi_cfg
)
1036 vty_out (vty
, "rfapi not configured%s", VTY_NEWLINE
);
1040 vnc_redistribute_prechange (bgp
);
1043 * OK if nve group doesn't exist yet; we'll set the pointer
1044 * when the group is defined later
1046 bgp
->rfapi_cfg
->rfg_redist
= bgp_rfapi_cfg_match_byname (bgp
, argv
[3]->arg
,
1047 RFAPI_GROUP_CFG_NVE
);
1048 if (bgp
->rfapi_cfg
->rfg_redist_name
)
1049 free (bgp
->rfapi_cfg
->rfg_redist_name
);
1050 bgp
->rfapi_cfg
->rfg_redist_name
= strdup (argv
[3]->arg
);
1052 vnc_redistribute_postchange (bgp
);
1057 DEFUN (vnc_redistribute_no_nvegroup
,
1058 vnc_redistribute_no_nvegroup_cmd
,
1059 "no vnc redistribute nve-group",
1062 "Redistribute from other protocol\n"
1063 "Assign a NVE group to routes redistributed from another routing protocol\n")
1065 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1067 if (!bgp
->rfapi_cfg
)
1069 vty_out (vty
, "rfapi not configured%s", VTY_NEWLINE
);
1073 vnc_redistribute_prechange (bgp
);
1075 bgp
->rfapi_cfg
->rfg_redist
= NULL
;
1076 if (bgp
->rfapi_cfg
->rfg_redist_name
)
1077 free (bgp
->rfapi_cfg
->rfg_redist_name
);
1078 bgp
->rfapi_cfg
->rfg_redist_name
= NULL
;
1080 vnc_redistribute_postchange (bgp
);
1086 DEFUN (vnc_redistribute_lifetime
,
1087 vnc_redistribute_lifetime_cmd
,
1088 "vnc redistribute lifetime <LIFETIME|infinite>",
1091 "Assign a lifetime to routes redistributed from another routing protocol\n"
1092 "lifetime value (32 bit)\n"
1093 "Allow lifetime to never expire\n")
1095 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1097 if (!bgp
->rfapi_cfg
)
1099 vty_out (vty
, "rfapi not configured%s", VTY_NEWLINE
);
1103 vnc_redistribute_prechange (bgp
);
1105 if (strmatch(argv
[3]->text
, "infinite"))
1107 bgp
->rfapi_cfg
->redist_lifetime
= RFAPI_INFINITE_LIFETIME
;
1111 VTY_GET_INTEGER ("Response Lifetime", bgp
->rfapi_cfg
->redist_lifetime
,
1115 vnc_redistribute_postchange (bgp
);
1120 /*-- redist policy, non-nvegroup start --*/
1122 DEFUN (vnc_redist_bgpdirect_no_prefixlist
,
1123 vnc_redist_bgpdirect_no_prefixlist_cmd
,
1124 "no vnc redistribute <bgp-direct|bgp-direct-to-nve-groups> <ipv4|ipv6> prefix-list",
1127 "Redistribute from other protocol\n"
1128 "Redistribute from BGP directly\n"
1129 "Redistribute from BGP without Zebra, only to configured NVE groups\n"
1131 "IPv6 routes\n" "Prefix-list for filtering redistributed routes\n")
1133 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1135 struct rfapi_cfg
*hc
;
1136 uint8_t route_type
= 0;
1138 if (!(hc
= bgp
->rfapi_cfg
))
1140 vty_out (vty
, "rfapi not configured%s", VTY_NEWLINE
);
1144 if (strmatch(argv
[3]->text
, "bgp-direct"))
1146 route_type
= ZEBRA_ROUTE_BGP_DIRECT
;
1150 route_type
= ZEBRA_ROUTE_BGP_DIRECT_EXT
;
1153 if (strmatch(argv
[4]->text
, "ipv4"))
1162 vnc_redistribute_prechange (bgp
);
1164 if (hc
->plist_redist_name
[route_type
][afi
])
1165 free (hc
->plist_redist_name
[route_type
][afi
]);
1166 hc
->plist_redist_name
[route_type
][afi
] = NULL
;
1167 hc
->plist_redist
[route_type
][afi
] = NULL
;
1169 vnc_redistribute_postchange (bgp
);
1174 DEFUN (vnc_redist_bgpdirect_prefixlist
,
1175 vnc_redist_bgpdirect_prefixlist_cmd
,
1176 "vnc redistribute <bgp-direct|bgp-direct-to-nve-groups> <ipv4|ipv6> prefix-list NAME",
1178 "Redistribute from other protocol\n"
1179 "Redistribute from BGP directly\n"
1180 "Redistribute from BGP without Zebra, only to configured NVE groups\n"
1183 "Prefix-list for filtering redistributed routes\n"
1184 "prefix list name\n")
1186 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1187 struct rfapi_cfg
*hc
;
1189 uint8_t route_type
= 0;
1191 if (!(hc
= bgp
->rfapi_cfg
))
1193 vty_out (vty
, "rfapi not configured%s", VTY_NEWLINE
);
1197 if (strmatch(argv
[2]->text
, "bgp-direct"))
1199 route_type
= ZEBRA_ROUTE_BGP_DIRECT
;
1203 route_type
= ZEBRA_ROUTE_BGP_DIRECT_EXT
;
1206 if (strmatch(argv
[3]->text
, "ipv4"))
1215 vnc_redistribute_prechange (bgp
);
1217 if (hc
->plist_redist_name
[route_type
][afi
])
1218 free (hc
->plist_redist_name
[route_type
][afi
]);
1219 hc
->plist_redist_name
[route_type
][afi
] = strdup (argv
[5]->arg
);
1220 hc
->plist_redist
[route_type
][afi
] = prefix_list_lookup (afi
, argv
[5]->arg
);
1222 vnc_redistribute_postchange (bgp
);
1227 DEFUN (vnc_redist_bgpdirect_no_routemap
,
1228 vnc_redist_bgpdirect_no_routemap_cmd
,
1229 "no vnc redistribute <bgp-direct|bgp-direct-to-nve-groups> route-map",
1232 "Redistribute from other protocols\n"
1233 "Redistribute from BGP directly\n"
1234 "Redistribute from BGP without Zebra, only to configured NVE groups\n"
1235 "Route-map for filtering redistributed routes\n")
1237 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1238 struct rfapi_cfg
*hc
;
1239 uint8_t route_type
= 0;
1241 if (!(hc
= bgp
->rfapi_cfg
))
1243 vty_out (vty
, "rfapi not configured%s", VTY_NEWLINE
);
1247 if (strmatch(argv
[3]->text
, "bgp-direct"))
1249 route_type
= ZEBRA_ROUTE_BGP_DIRECT
;
1253 route_type
= ZEBRA_ROUTE_BGP_DIRECT_EXT
;
1256 vnc_redistribute_prechange (bgp
);
1258 if (hc
->routemap_redist_name
[route_type
])
1259 free (hc
->routemap_redist_name
[route_type
]);
1260 hc
->routemap_redist_name
[route_type
] = NULL
;
1261 hc
->routemap_redist
[route_type
] = NULL
;
1263 vnc_redistribute_postchange (bgp
);
1268 DEFUN (vnc_redist_bgpdirect_routemap
,
1269 vnc_redist_bgpdirect_routemap_cmd
,
1270 "vnc redistribute <bgp-direct|bgp-direct-to-nve-groups> route-map NAME",
1272 "Redistribute from other protocols\n"
1273 "Redistribute from BGP directly\n"
1274 "Redistribute from BGP without Zebra, only to configured NVE groups\n"
1275 "Route-map for filtering exported routes\n" "route map name\n")
1277 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1278 struct rfapi_cfg
*hc
;
1279 uint8_t route_type
= 0;
1281 if (!(hc
= bgp
->rfapi_cfg
))
1283 vty_out (vty
, "rfapi not configured%s", VTY_NEWLINE
);
1287 if (strmatch(argv
[2]->text
, "bgp-direct"))
1289 route_type
= ZEBRA_ROUTE_BGP_DIRECT
;
1293 route_type
= ZEBRA_ROUTE_BGP_DIRECT_EXT
;
1296 vnc_redistribute_prechange (bgp
);
1298 if (hc
->routemap_redist_name
[route_type
])
1299 free (hc
->routemap_redist_name
[route_type
]);
1300 hc
->routemap_redist_name
[route_type
] = strdup (argv
[4]->arg
);
1301 hc
->routemap_redist
[route_type
] = route_map_lookup_by_name (argv
[4]->arg
);
1303 vnc_redistribute_postchange (bgp
);
1308 /*-- redist policy, non-nvegroup end --*/
1310 /*-- redist policy, nvegroup start --*/
1312 DEFUN (vnc_nve_group_redist_bgpdirect_no_prefixlist
,
1313 vnc_nve_group_redist_bgpdirect_no_prefixlist_cmd
,
1314 "no redistribute bgp-direct <ipv4|ipv6> prefix-list",
1316 "Redistribute from other protocol\n"
1317 "Redistribute from BGP directly\n"
1318 "Disable redistribute filter\n"
1320 "IPv6 routes\n" "Prefix-list for filtering redistributed routes\n")
1322 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1323 VTY_DECLVAR_CONTEXT_SUB(rfapi_nve_group_cfg
, rfg
)
1326 if (!bgp
->rfapi_cfg
)
1328 vty_out (vty
, "rfapi not configured%s", VTY_NEWLINE
);
1332 /* make sure it's still in list */
1333 if (!listnode_lookup (bgp
->rfapi_cfg
->nve_groups_sequential
, rfg
))
1335 /* Not in list anymore */
1336 vty_out (vty
, "Current NVE group no longer exists%s", VTY_NEWLINE
);
1340 if (strmatch(argv
[3]->text
, "ipv4"))
1349 vnc_redistribute_prechange (bgp
);
1351 if (rfg
->plist_redist_name
[ZEBRA_ROUTE_BGP_DIRECT
][afi
])
1352 free (rfg
->plist_redist_name
[ZEBRA_ROUTE_BGP_DIRECT
][afi
]);
1353 rfg
->plist_redist_name
[ZEBRA_ROUTE_BGP_DIRECT
][afi
] = NULL
;
1354 rfg
->plist_redist
[ZEBRA_ROUTE_BGP_DIRECT
][afi
] = NULL
;
1356 vnc_redistribute_postchange (bgp
);
1361 DEFUN (vnc_nve_group_redist_bgpdirect_prefixlist
,
1362 vnc_nve_group_redist_bgpdirect_prefixlist_cmd
,
1363 "redistribute bgp-direct <ipv4|ipv6> prefix-list NAME",
1364 "Redistribute from other protocol\n"
1365 "Redistribute from BGP directly\n"
1368 "Prefix-list for filtering redistributed routes\n"
1369 "prefix list name\n")
1371 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1372 VTY_DECLVAR_CONTEXT_SUB(rfapi_nve_group_cfg
, rfg
);
1375 if (!bgp
->rfapi_cfg
)
1377 vty_out (vty
, "rfapi not configured%s", VTY_NEWLINE
);
1381 /* make sure it's still in list */
1382 if (!listnode_lookup (bgp
->rfapi_cfg
->nve_groups_sequential
, rfg
))
1384 /* Not in list anymore */
1385 vty_out (vty
, "Current NVE group no longer exists%s", VTY_NEWLINE
);
1389 if (strmatch(argv
[2]->text
, "ipv4"))
1398 vnc_redistribute_prechange (bgp
);
1400 if (rfg
->plist_redist_name
[ZEBRA_ROUTE_BGP_DIRECT
][afi
])
1401 free (rfg
->plist_redist_name
[ZEBRA_ROUTE_BGP_DIRECT
][afi
]);
1402 rfg
->plist_redist_name
[ZEBRA_ROUTE_BGP_DIRECT
][afi
] = strdup (argv
[4]->arg
);
1403 rfg
->plist_redist
[ZEBRA_ROUTE_BGP_DIRECT
][afi
] =
1404 prefix_list_lookup (afi
, argv
[4]->arg
);
1406 vnc_redistribute_postchange (bgp
);
1411 DEFUN (vnc_nve_group_redist_bgpdirect_no_routemap
,
1412 vnc_nve_group_redist_bgpdirect_no_routemap_cmd
,
1413 "no redistribute bgp-direct route-map",
1415 "Redistribute from other protocols\n"
1416 "Redistribute from BGP directly\n"
1417 "Disable redistribute filter\n"
1418 "Route-map for filtering redistributed routes\n")
1420 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1421 VTY_DECLVAR_CONTEXT_SUB(rfapi_nve_group_cfg
, rfg
);
1423 if (!bgp
->rfapi_cfg
)
1425 vty_out (vty
, "rfapi not configured%s", VTY_NEWLINE
);
1429 /* make sure it's still in list */
1430 if (!listnode_lookup (bgp
->rfapi_cfg
->nve_groups_sequential
, rfg
))
1432 /* Not in list anymore */
1433 vty_out (vty
, "Current NVE group no longer exists%s", VTY_NEWLINE
);
1437 vnc_redistribute_prechange (bgp
);
1439 if (rfg
->routemap_redist_name
[ZEBRA_ROUTE_BGP_DIRECT
])
1440 free (rfg
->routemap_redist_name
[ZEBRA_ROUTE_BGP_DIRECT
]);
1441 rfg
->routemap_redist_name
[ZEBRA_ROUTE_BGP_DIRECT
] = NULL
;
1442 rfg
->routemap_redist
[ZEBRA_ROUTE_BGP_DIRECT
] = NULL
;
1444 vnc_redistribute_postchange (bgp
);
1449 DEFUN (vnc_nve_group_redist_bgpdirect_routemap
,
1450 vnc_nve_group_redist_bgpdirect_routemap_cmd
,
1451 "redistribute bgp-direct route-map NAME",
1452 "Redistribute from other protocols\n"
1453 "Redistribute from BGP directly\n"
1454 "Route-map for filtering exported routes\n" "route map name\n")
1456 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1457 VTY_DECLVAR_CONTEXT_SUB(rfapi_nve_group_cfg
, rfg
);
1459 if (!bgp
->rfapi_cfg
)
1461 vty_out (vty
, "rfapi not configured%s", VTY_NEWLINE
);
1465 /* make sure it's still in list */
1466 if (!listnode_lookup (bgp
->rfapi_cfg
->nve_groups_sequential
, rfg
))
1468 /* Not in list anymore */
1469 vty_out (vty
, "Current NVE group no longer exists%s", VTY_NEWLINE
);
1473 vnc_redistribute_prechange (bgp
);
1475 if (rfg
->routemap_redist_name
[ZEBRA_ROUTE_BGP_DIRECT
])
1476 free (rfg
->routemap_redist_name
[ZEBRA_ROUTE_BGP_DIRECT
]);
1477 rfg
->routemap_redist_name
[ZEBRA_ROUTE_BGP_DIRECT
] = strdup (argv
[3]->arg
);
1478 rfg
->routemap_redist
[ZEBRA_ROUTE_BGP_DIRECT
] =
1479 route_map_lookup_by_name (argv
[3]->arg
);
1481 vnc_redistribute_postchange (bgp
);
1486 /*-- redist policy, nvegroup end --*/
1488 /*-------------------------------------------------------------------------
1490 *-----------------------------------------------------------------------*/
1492 DEFUN (vnc_export_mode
,
1493 vnc_export_mode_cmd
,
1494 "vnc export <bgp|zebra> mode <group-nve|ce|none|registering-nve>",
1496 "Export to other protocols\n"
1498 "Export to Zebra (experimental)\n"
1499 "Select export mode\n"
1500 "Export routes with nve-group next-hops\n"
1501 "Export routes with NVE connected router next-hops\n"
1502 "Disable export\n" "Export routes with registering NVE as next-hop\n")
1504 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1505 uint32_t oldmode
= 0;
1506 uint32_t newmode
= 0;
1508 if (!bgp
->rfapi_cfg
)
1510 vty_out (vty
, "VNC not configured%s", VTY_NEWLINE
);
1514 if (argv
[2]->arg
[0] == 'b')
1516 oldmode
= bgp
->rfapi_cfg
->flags
& BGP_VNC_CONFIG_EXPORT_BGP_MODE_BITS
;
1517 switch (argv
[4]->arg
[0])
1520 newmode
= BGP_VNC_CONFIG_EXPORT_BGP_MODE_GRP
;
1523 newmode
= BGP_VNC_CONFIG_EXPORT_BGP_MODE_CE
;
1529 newmode
= BGP_VNC_CONFIG_EXPORT_BGP_MODE_RH
;
1532 vty_out (vty
, "Invalid mode specified%s", VTY_NEWLINE
);
1536 if (newmode
== oldmode
)
1538 vty_out (vty
, "Mode unchanged%s", VTY_NEWLINE
);
1542 vnc_export_bgp_prechange (bgp
);
1544 bgp
->rfapi_cfg
->flags
&= ~BGP_VNC_CONFIG_EXPORT_BGP_MODE_BITS
;
1545 bgp
->rfapi_cfg
->flags
|= newmode
;
1547 vnc_export_bgp_postchange (bgp
);
1554 * export to zebra with RH mode is not yet implemented
1556 vty_out (vty
, "Changing modes for zebra export not implemented yet%s",
1560 oldmode
= bgp
->rfapi_cfg
->flags
& BGP_VNC_CONFIG_EXPORT_ZEBRA_MODE_BITS
;
1561 bgp
->rfapi_cfg
->flags
&= ~BGP_VNC_CONFIG_EXPORT_ZEBRA_MODE_BITS
;
1562 switch (argv
[4]->arg
[0])
1565 if (oldmode
== BGP_VNC_CONFIG_EXPORT_ZEBRA_MODE_RH
)
1569 bgp
->rfapi_cfg
->flags
|= BGP_VNC_CONFIG_EXPORT_ZEBRA_MODE_GRP
;
1570 if (oldmode
!= BGP_VNC_CONFIG_EXPORT_ZEBRA_MODE_GRP
)
1576 if (oldmode
== BGP_VNC_CONFIG_EXPORT_ZEBRA_MODE_RH
)
1580 if (oldmode
== BGP_VNC_CONFIG_EXPORT_ZEBRA_MODE_GRP
)
1586 if (oldmode
== BGP_VNC_CONFIG_EXPORT_ZEBRA_MODE_GRP
)
1590 bgp
->rfapi_cfg
->flags
|= BGP_VNC_CONFIG_EXPORT_ZEBRA_MODE_RH
;
1591 if (oldmode
!= BGP_VNC_CONFIG_EXPORT_ZEBRA_MODE_RH
)
1597 vty_out (vty
, "Invalid mode%s", VTY_NEWLINE
);
1605 static struct rfapi_rfg_name
*
1608 return XCALLOC (MTYPE_RFAPI_RFG_NAME
, sizeof (struct rfapi_rfg_name
));
1612 rfgn_free (struct rfapi_rfg_name
*rfgn
)
1614 XFREE (MTYPE_RFAPI_RFG_NAME
, rfgn
);
1617 DEFUN (vnc_export_nvegroup
,
1618 vnc_export_nvegroup_cmd
,
1619 "vnc export <bgp|zebra> group-nve group NAME",
1621 "Export to other protocols\n"
1623 "Export to Zebra (experimental)\n"
1624 "NVE group, used in 'group-nve' export mode\n"
1625 "NVE group\n" "Group name\n")
1627 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1628 struct rfapi_nve_group_cfg
*rfg_new
;
1630 if (!bgp
->rfapi_cfg
)
1632 vty_out (vty
, "rfapi not configured%s", VTY_NEWLINE
);
1636 rfg_new
= bgp_rfapi_cfg_match_byname (bgp
, argv
[5]->arg
, RFAPI_GROUP_CFG_NVE
);
1638 if (argv
[2]->arg
[0] == 'b')
1641 struct listnode
*node
;
1642 struct rfapi_rfg_name
*rfgn
;
1645 * Set group for export to BGP Direct
1648 /* see if group is already included in export list */
1649 for (ALL_LIST_ELEMENTS_RO (bgp
->rfapi_cfg
->rfg_export_direct_bgp_l
,
1653 if (!strcmp (rfgn
->name
, argv
[5]->arg
))
1655 /* already in the list: we're done */
1661 rfgn
->name
= strdup (argv
[5]->arg
);
1662 rfgn
->rfg
= rfg_new
; /* OK if not set yet */
1664 listnode_add (bgp
->rfapi_cfg
->rfg_export_direct_bgp_l
, rfgn
);
1666 vnc_zlog_debug_verbose ("%s: testing rfg_new", __func__
);
1669 vnc_zlog_debug_verbose ("%s: testing bgp grp mode enabled", __func__
);
1670 if (VNC_EXPORT_BGP_GRP_ENABLED (bgp
->rfapi_cfg
))
1671 vnc_zlog_debug_verbose ("%s: calling vnc_direct_bgp_add_group", __func__
);
1672 vnc_direct_bgp_add_group (bgp
, rfg_new
);
1679 struct listnode
*node
;
1680 struct rfapi_rfg_name
*rfgn
;
1683 * Set group for export to Zebra
1686 /* see if group is already included in export list */
1687 for (ALL_LIST_ELEMENTS_RO (bgp
->rfapi_cfg
->rfg_export_zebra_l
,
1691 if (!strcmp (rfgn
->name
, argv
[5]->arg
))
1693 /* already in the list: we're done */
1699 rfgn
->name
= strdup (argv
[5]->arg
);
1700 rfgn
->rfg
= rfg_new
; /* OK if not set yet */
1702 listnode_add (bgp
->rfapi_cfg
->rfg_export_zebra_l
, rfgn
);
1706 if (VNC_EXPORT_ZEBRA_GRP_ENABLED (bgp
->rfapi_cfg
))
1707 vnc_zebra_add_group (bgp
, rfg_new
);
1715 * This command applies to routes exported from VNC to BGP directly
1716 * without going though zebra
1718 DEFUN (vnc_no_export_nvegroup
,
1719 vnc_no_export_nvegroup_cmd
,
1720 "vnc export <bgp|zebra> group-nve no group NAME",
1722 "Export to other protocols\n"
1724 "Export to Zebra (experimental)\n"
1725 "NVE group, used in 'group-nve' export mode\n"
1726 "Disable export of VNC routes\n" "NVE group\n" "Group name\n")
1728 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1729 struct listnode
*node
, *nnode
;
1730 struct rfapi_rfg_name
*rfgn
;
1732 if (!bgp
->rfapi_cfg
)
1734 vty_out (vty
, "rfapi not configured%s", VTY_NEWLINE
);
1738 if (argv
[2]->arg
[0] == 'b')
1740 for (ALL_LIST_ELEMENTS (bgp
->rfapi_cfg
->rfg_export_direct_bgp_l
,
1744 if (rfgn
->name
&& !strcmp (rfgn
->name
, argv
[6]->arg
))
1746 vnc_zlog_debug_verbose ("%s: matched \"%s\"", __func__
, rfgn
->name
);
1748 vnc_direct_bgp_del_group (bgp
, rfgn
->rfg
);
1750 list_delete_node (bgp
->rfapi_cfg
->rfg_export_direct_bgp_l
,
1759 for (ALL_LIST_ELEMENTS (bgp
->rfapi_cfg
->rfg_export_zebra_l
,
1763 vnc_zlog_debug_verbose ("does rfg \"%s\" match?", rfgn
->name
);
1764 if (rfgn
->name
&& !strcmp (rfgn
->name
, argv
[6]->arg
))
1767 vnc_zebra_del_group (bgp
, rfgn
->rfg
);
1769 list_delete_node (bgp
->rfapi_cfg
->rfg_export_zebra_l
, node
);
1778 DEFUN (vnc_nve_group_export_no_prefixlist
,
1779 vnc_nve_group_export_no_prefixlist_cmd
,
1780 "no export <bgp|zebra> <ipv4|ipv6> prefix-list [NAME]",
1782 "Export to other protocols\n"
1784 "Export to Zebra (experimental)\n"
1787 "Prefix-list for filtering exported routes\n" "prefix list name\n")
1789 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1790 VTY_DECLVAR_CONTEXT_SUB(rfapi_nve_group_cfg
, rfg
);
1793 if (!bgp
->rfapi_cfg
)
1795 vty_out (vty
, "rfapi not configured%s", VTY_NEWLINE
);
1799 /* make sure it's still in list */
1800 if (!listnode_lookup (bgp
->rfapi_cfg
->nve_groups_sequential
, rfg
))
1802 /* Not in list anymore */
1803 vty_out (vty
, "Current NVE group no longer exists%s", VTY_NEWLINE
);
1807 if (strmatch(argv
[3]->text
, "ipv4"))
1816 if (argv
[2]->arg
[0] == 'b')
1819 && strmatch(argv
[5]->text
, rfg
->plist_export_bgp_name
[afi
]))
1823 if (rfg
->plist_export_bgp_name
[afi
])
1824 free (rfg
->plist_export_bgp_name
[afi
]);
1825 rfg
->plist_export_bgp_name
[afi
] = NULL
;
1826 rfg
->plist_export_bgp
[afi
] = NULL
;
1828 vnc_direct_bgp_reexport_group_afi (bgp
, rfg
, afi
);
1834 && strmatch(argv
[5]->text
, rfg
->plist_export_zebra_name
[afi
]))
1837 if (rfg
->plist_export_zebra_name
[afi
])
1838 free (rfg
->plist_export_zebra_name
[afi
]);
1839 rfg
->plist_export_zebra_name
[afi
] = NULL
;
1840 rfg
->plist_export_zebra
[afi
] = NULL
;
1842 vnc_zebra_reexport_group_afi (bgp
, rfg
, afi
);
1848 DEFUN (vnc_nve_group_export_prefixlist
,
1849 vnc_nve_group_export_prefixlist_cmd
,
1850 "export <bgp|zebra> <ipv4|ipv6> prefix-list NAME",
1851 "Export to other protocols\n"
1853 "Export to Zebra (experimental)\n"
1856 "Prefix-list for filtering exported routes\n" "prefix list name\n")
1858 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1859 VTY_DECLVAR_CONTEXT_SUB(rfapi_nve_group_cfg
, rfg
);
1862 if (!bgp
->rfapi_cfg
)
1864 vty_out (vty
, "rfapi not configured%s", VTY_NEWLINE
);
1868 /* make sure it's still in list */
1869 if (!listnode_lookup (bgp
->rfapi_cfg
->nve_groups_sequential
, rfg
))
1871 /* Not in list anymore */
1872 vty_out (vty
, "Current NVE group no longer exists%s", VTY_NEWLINE
);
1876 if (strmatch(argv
[2]->text
, "ipv4"))
1885 if (argv
[1]->arg
[0] == 'b')
1887 if (rfg
->plist_export_bgp_name
[afi
])
1888 free (rfg
->plist_export_bgp_name
[afi
]);
1889 rfg
->plist_export_bgp_name
[afi
] = strdup (argv
[4]->arg
);
1890 rfg
->plist_export_bgp
[afi
] = prefix_list_lookup (afi
, argv
[4]->arg
);
1892 vnc_direct_bgp_reexport_group_afi (bgp
, rfg
, afi
);
1897 if (rfg
->plist_export_zebra_name
[afi
])
1898 free (rfg
->plist_export_zebra_name
[afi
]);
1899 rfg
->plist_export_zebra_name
[afi
] = strdup (argv
[4]->arg
);
1900 rfg
->plist_export_zebra
[afi
] = prefix_list_lookup (afi
, argv
[4]->arg
);
1902 vnc_zebra_reexport_group_afi (bgp
, rfg
, afi
);
1907 DEFUN (vnc_nve_group_export_no_routemap
,
1908 vnc_nve_group_export_no_routemap_cmd
,
1909 "no export <bgp|zebra> route-map [NAME]",
1911 "Export to other protocols\n"
1913 "Export to Zebra (experimental)\n"
1914 "Route-map for filtering exported routes\n" "route map name\n")
1916 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1917 VTY_DECLVAR_CONTEXT_SUB(rfapi_nve_group_cfg
, rfg
);
1919 if (!bgp
->rfapi_cfg
)
1921 vty_out (vty
, "rfapi not configured%s", VTY_NEWLINE
);
1925 /* make sure it's still in list */
1926 if (!listnode_lookup (bgp
->rfapi_cfg
->nve_groups_sequential
, rfg
))
1928 /* Not in list anymore */
1929 vty_out (vty
, "Current NVE group no longer exists%s", VTY_NEWLINE
);
1933 if (argv
[2]->arg
[0] == 'b')
1936 && strmatch(argv
[4]->text
, rfg
->routemap_export_bgp_name
))
1940 if (rfg
->routemap_export_bgp_name
)
1941 free (rfg
->routemap_export_bgp_name
);
1942 rfg
->routemap_export_bgp_name
= NULL
;
1943 rfg
->routemap_export_bgp
= NULL
;
1945 vnc_direct_bgp_reexport_group_afi (bgp
, rfg
, AFI_IP
);
1946 vnc_direct_bgp_reexport_group_afi (bgp
, rfg
, AFI_IP6
);
1952 && strmatch(argv
[4]->text
, rfg
->routemap_export_zebra_name
))
1955 if (rfg
->routemap_export_zebra_name
)
1956 free (rfg
->routemap_export_zebra_name
);
1957 rfg
->routemap_export_zebra_name
= NULL
;
1958 rfg
->routemap_export_zebra
= NULL
;
1960 vnc_zebra_reexport_group_afi (bgp
, rfg
, AFI_IP
);
1961 vnc_zebra_reexport_group_afi (bgp
, rfg
, AFI_IP6
);
1967 DEFUN (vnc_nve_group_export_routemap
,
1968 vnc_nve_group_export_routemap_cmd
,
1969 "export <bgp|zebra> route-map NAME",
1970 "Export to other protocols\n"
1972 "Export to Zebra (experimental)\n"
1973 "Route-map for filtering exported routes\n" "route map name\n")
1975 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1976 VTY_DECLVAR_CONTEXT_SUB(rfapi_nve_group_cfg
, rfg
);
1978 if (!bgp
->rfapi_cfg
)
1980 vty_out (vty
, "rfapi not configured%s", VTY_NEWLINE
);
1984 /* make sure it's still in list */
1985 if (!listnode_lookup (bgp
->rfapi_cfg
->nve_groups_sequential
, rfg
))
1987 /* Not in list anymore */
1988 vty_out (vty
, "Current NVE group no longer exists%s", VTY_NEWLINE
);
1992 if (argv
[1]->arg
[0] == 'b')
1994 if (rfg
->routemap_export_bgp_name
)
1995 free (rfg
->routemap_export_bgp_name
);
1996 rfg
->routemap_export_bgp_name
= strdup (argv
[3]->arg
);
1997 rfg
->routemap_export_bgp
= route_map_lookup_by_name (argv
[3]->arg
);
1998 vnc_direct_bgp_reexport_group_afi (bgp
, rfg
, AFI_IP
);
1999 vnc_direct_bgp_reexport_group_afi (bgp
, rfg
, AFI_IP6
);
2003 if (rfg
->routemap_export_zebra_name
)
2004 free (rfg
->routemap_export_zebra_name
);
2005 rfg
->routemap_export_zebra_name
= strdup (argv
[3]->arg
);
2006 rfg
->routemap_export_zebra
= route_map_lookup_by_name (argv
[3]->arg
);
2007 vnc_zebra_reexport_group_afi (bgp
, rfg
, AFI_IP
);
2008 vnc_zebra_reexport_group_afi (bgp
, rfg
, AFI_IP6
);
2013 DEFUN (vnc_nve_export_no_prefixlist
,
2014 vnc_nve_export_no_prefixlist_cmd
,
2015 "no vnc export <bgp|zebra> <ipv4|ipv6> prefix-list [NAME]",
2018 "Export to other protocols\n"
2020 "Export to Zebra (experimental)\n"
2023 "Prefix-list for filtering exported routes\n" "Prefix list name\n")
2025 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2026 struct rfapi_cfg
*hc
;
2029 if (!(hc
= bgp
->rfapi_cfg
))
2031 vty_out (vty
, "rfapi not configured%s", VTY_NEWLINE
);
2035 if (strmatch(argv
[4]->text
, "ipv4"))
2044 if (argv
[3]->arg
[0] == 'b')
2047 && hc
->plist_export_bgp_name
[afi
]
2048 && strmatch(argv
[6]->text
, hc
->plist_export_bgp_name
[afi
]))
2052 free (hc
->plist_export_bgp_name
[afi
]);
2053 hc
->plist_export_bgp_name
[afi
] = NULL
;
2054 hc
->plist_export_bgp
[afi
] = NULL
;
2055 vnc_direct_bgp_reexport (bgp
, afi
);
2061 && hc
->plist_export_zebra_name
[afi
]
2062 && strmatch(argv
[6]->text
, hc
->plist_export_zebra_name
[afi
]))
2066 free (hc
->plist_export_zebra_name
[afi
]);
2067 hc
->plist_export_zebra_name
[afi
] = NULL
;
2068 hc
->plist_export_zebra
[afi
] = NULL
;
2069 /* TBD vnc_zebra_rh_reexport(bgp, afi); */
2075 DEFUN (vnc_nve_export_prefixlist
,
2076 vnc_nve_export_prefixlist_cmd
,
2077 "vnc export <bgp|zebra> <ipv4|ipv6> prefix-list NAME",
2079 "Export to other protocols\n"
2081 "Export to Zebra (experimental)\n"
2082 "Filters, used in 'registering-nve' export mode\n"
2085 "Prefix-list for filtering exported routes\n" "Prefix list name\n")
2087 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2088 struct rfapi_cfg
*hc
;
2091 if (!(hc
= bgp
->rfapi_cfg
))
2093 vty_out (vty
, "rfapi not configured%s", VTY_NEWLINE
);
2097 if (strmatch(argv
[3]->text
, "ipv4"))
2106 if (argv
[2]->arg
[0] == 'b')
2108 if (hc
->plist_export_bgp_name
[afi
])
2109 free (hc
->plist_export_bgp_name
[afi
]);
2110 hc
->plist_export_bgp_name
[afi
] = strdup (argv
[5]->arg
);
2111 hc
->plist_export_bgp
[afi
] = prefix_list_lookup (afi
, argv
[5]->arg
);
2112 vnc_direct_bgp_reexport (bgp
, afi
);
2116 if (hc
->plist_export_zebra_name
[afi
])
2117 free (hc
->plist_export_zebra_name
[afi
]);
2118 hc
->plist_export_zebra_name
[afi
] = strdup (argv
[5]->arg
);
2119 hc
->plist_export_zebra
[afi
] = prefix_list_lookup (afi
, argv
[5]->arg
);
2120 /* TBD vnc_zebra_rh_reexport(bgp, afi); */
2125 DEFUN (vnc_nve_export_no_routemap
,
2126 vnc_nve_export_no_routemap_cmd
,
2127 "no vnc export <bgp|zebra> route-map [NAME]",
2130 "Export to other protocols\n"
2132 "Export to Zebra (experimental)\n"
2133 "Route-map for filtering exported routes\n" "Route map name\n")
2135 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2136 struct rfapi_cfg
*hc
;
2138 if (!(hc
= bgp
->rfapi_cfg
))
2140 vty_out (vty
, "rfapi not configured%s", VTY_NEWLINE
);
2144 if (argv
[3]->arg
[0] == 'b')
2147 && hc
->routemap_export_bgp_name
2148 && strmatch(argv
[5]->text
, hc
->routemap_export_bgp_name
))
2152 free (hc
->routemap_export_bgp_name
);
2153 hc
->routemap_export_bgp_name
= NULL
;
2154 hc
->routemap_export_bgp
= NULL
;
2155 vnc_direct_bgp_reexport (bgp
, AFI_IP
);
2156 vnc_direct_bgp_reexport (bgp
, AFI_IP6
);
2162 && hc
->routemap_export_zebra_name
2163 && strmatch(argv
[5]->text
, hc
->routemap_export_zebra_name
))
2167 free (hc
->routemap_export_zebra_name
);
2168 hc
->routemap_export_zebra_name
= NULL
;
2169 hc
->routemap_export_zebra
= NULL
;
2170 /* TBD vnc_zebra_rh_reexport(bgp, AFI_IP); */
2171 /* TBD vnc_zebra_rh_reexport(bgp, AFI_IP6); */
2177 DEFUN (vnc_nve_export_routemap
,
2178 vnc_nve_export_routemap_cmd
,
2179 "vnc export <bgp|zebra> route-map NAME",
2181 "Export to other protocols\n"
2183 "Export to Zebra (experimental)\n"
2184 "Filters, used in 'registering-nve' export mode\n"
2185 "Route-map for filtering exported routes\n" "Route map name\n")
2187 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2188 struct rfapi_cfg
*hc
;
2190 if (!(hc
= bgp
->rfapi_cfg
))
2192 vty_out (vty
, "rfapi not configured%s", VTY_NEWLINE
);
2196 if (argv
[2]->arg
[0] == 'b')
2198 if (hc
->routemap_export_bgp_name
)
2199 free (hc
->routemap_export_bgp_name
);
2200 hc
->routemap_export_bgp_name
= strdup (argv
[4]->arg
);
2201 hc
->routemap_export_bgp
= route_map_lookup_by_name (argv
[4]->arg
);
2202 vnc_direct_bgp_reexport (bgp
, AFI_IP
);
2203 vnc_direct_bgp_reexport (bgp
, AFI_IP6
);
2207 if (hc
->routemap_export_zebra_name
)
2208 free (hc
->routemap_export_zebra_name
);
2209 hc
->routemap_export_zebra_name
= strdup (argv
[4]->arg
);
2210 hc
->routemap_export_zebra
= route_map_lookup_by_name (argv
[4]->arg
);
2211 /* TBD vnc_zebra_rh_reexport(bgp, AFI_IP); */
2212 /* TBD vnc_zebra_rh_reexport(bgp, AFI_IP6); */
2219 * respond to changes in the global prefix list configuration
2222 vnc_prefix_list_update (struct bgp
*bgp
)
2226 struct rfapi_nve_group_cfg
*rfg
;
2227 struct rfapi_cfg
*hc
;
2232 vnc_zlog_debug_verbose ("%s: No BGP process is configured", __func__
);
2236 if (!(hc
= bgp
->rfapi_cfg
))
2238 vnc_zlog_debug_verbose ("%s: rfapi not configured", __func__
);
2242 for (afi
= AFI_IP
; afi
< AFI_MAX
; afi
++)
2245 * Loop over nve groups
2247 for (ALL_LIST_ELEMENTS_RO (bgp
->rfapi_cfg
->nve_groups_sequential
,
2251 if (rfg
->plist_export_bgp_name
[afi
])
2253 rfg
->plist_export_bgp
[afi
] =
2254 prefix_list_lookup (afi
, rfg
->plist_export_bgp_name
[afi
]);
2256 if (rfg
->plist_export_zebra_name
[afi
])
2258 rfg
->plist_export_zebra
[afi
] =
2259 prefix_list_lookup (afi
, rfg
->plist_export_zebra_name
[afi
]);
2261 for (i
= 0; i
< ZEBRA_ROUTE_MAX
; ++i
)
2263 if (rfg
->plist_redist_name
[i
][afi
])
2265 rfg
->plist_redist
[i
][afi
] =
2266 prefix_list_lookup (afi
, rfg
->plist_redist_name
[i
][afi
]);
2270 vnc_direct_bgp_reexport_group_afi (bgp
, rfg
, afi
);
2271 /* TBD vnc_zebra_reexport_group_afi(bgp, rfg, afi); */
2277 if (hc
->plist_export_bgp_name
[afi
])
2279 hc
->plist_export_bgp
[afi
] =
2280 prefix_list_lookup (afi
, hc
->plist_export_bgp_name
[afi
]);
2282 if (hc
->plist_export_zebra_name
[afi
])
2284 hc
->plist_export_zebra
[afi
] =
2285 prefix_list_lookup (afi
, hc
->plist_export_zebra_name
[afi
]);
2288 for (i
= 0; i
< ZEBRA_ROUTE_MAX
; ++i
)
2290 if (hc
->plist_redist_name
[i
][afi
])
2292 hc
->plist_redist
[i
][afi
] =
2293 prefix_list_lookup (afi
, hc
->plist_redist_name
[i
][afi
]);
2299 vnc_direct_bgp_reexport (bgp
, AFI_IP
);
2300 vnc_direct_bgp_reexport (bgp
, AFI_IP6
);
2302 /* TBD vnc_zebra_rh_reexport(bgp, AFI_IP); */
2303 /* TBD vnc_zebra_rh_reexport(bgp, AFI_IP6); */
2305 vnc_redistribute_prechange (bgp
);
2306 vnc_redistribute_postchange (bgp
);
2310 * respond to changes in the global route map configuration
2313 vnc_routemap_update (struct bgp
*bgp
, const char *unused
)
2316 struct rfapi_nve_group_cfg
*rfg
;
2317 struct rfapi_cfg
*hc
;
2320 vnc_zlog_debug_verbose ("%s(arg=%s)", __func__
, unused
);
2324 vnc_zlog_debug_verbose ("%s: No BGP process is configured", __func__
);
2328 if (!(hc
= bgp
->rfapi_cfg
))
2330 vnc_zlog_debug_verbose ("%s: rfapi not configured", __func__
);
2335 * Loop over nve groups
2337 for (ALL_LIST_ELEMENTS_RO (bgp
->rfapi_cfg
->nve_groups_sequential
, n
, rfg
))
2340 if (rfg
->routemap_export_bgp_name
)
2342 rfg
->routemap_export_bgp
=
2343 route_map_lookup_by_name (rfg
->routemap_export_bgp_name
);
2345 if (rfg
->routemap_export_zebra_name
)
2347 rfg
->routemap_export_bgp
=
2348 route_map_lookup_by_name (rfg
->routemap_export_zebra_name
);
2350 for (i
= 0; i
< ZEBRA_ROUTE_MAX
; ++i
)
2352 if (rfg
->routemap_redist_name
[i
])
2354 rfg
->routemap_redist
[i
] =
2355 route_map_lookup_by_name (rfg
->routemap_redist_name
[i
]);
2359 vnc_direct_bgp_reexport_group_afi (bgp
, rfg
, AFI_IP
);
2360 vnc_direct_bgp_reexport_group_afi (bgp
, rfg
, AFI_IP6
);
2361 /* TBD vnc_zebra_reexport_group_afi(bgp, rfg, afi); */
2367 if (hc
->routemap_export_bgp_name
)
2369 hc
->routemap_export_bgp
=
2370 route_map_lookup_by_name (hc
->routemap_export_bgp_name
);
2372 if (hc
->routemap_export_zebra_name
)
2374 hc
->routemap_export_bgp
=
2375 route_map_lookup_by_name (hc
->routemap_export_zebra_name
);
2377 for (i
= 0; i
< ZEBRA_ROUTE_MAX
; ++i
)
2379 if (hc
->routemap_redist_name
[i
])
2381 hc
->routemap_redist
[i
] =
2382 route_map_lookup_by_name (hc
->routemap_redist_name
[i
]);
2386 vnc_direct_bgp_reexport (bgp
, AFI_IP
);
2387 vnc_direct_bgp_reexport (bgp
, AFI_IP6
);
2389 /* TBD vnc_zebra_rh_reexport(bgp, AFI_IP); */
2390 /* TBD vnc_zebra_rh_reexport(bgp, AFI_IP6); */
2392 vnc_redistribute_prechange (bgp
);
2393 vnc_redistribute_postchange (bgp
);
2395 vnc_zlog_debug_verbose ("%s done", __func__
);
2399 vnc_routemap_event (route_map_event_t type
, /* ignored */
2400 const char *rmap_name
) /* ignored */
2402 struct listnode
*mnode
, *mnnode
;
2405 vnc_zlog_debug_verbose ("%s(event type=%d)", __func__
, type
);
2406 if (bm
->bgp
== NULL
) /* may be called during cleanup */
2409 for (ALL_LIST_ELEMENTS (bm
->bgp
, mnode
, mnnode
, bgp
))
2410 vnc_routemap_update (bgp
, rmap_name
);
2412 vnc_zlog_debug_verbose ("%s: done", __func__
);
2415 /*-------------------------------------------------------------------------
2417 *-----------------------------------------------------------------------*/
2420 DEFUN_NOSH (vnc_nve_group
,
2422 "vnc nve-group NAME",
2423 VNC_CONFIG_STR
"Configure a NVE group\n" "Group name\n")
2425 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2426 struct rfapi_nve_group_cfg
*rfg
;
2427 struct listnode
*node
, *nnode
;
2428 struct rfapi_rfg_name
*rfgn
;
2430 /* Search for name */
2431 rfg
= bgp_rfapi_cfg_match_byname (bgp
, argv
[2]->arg
, RFAPI_GROUP_CFG_NVE
);
2435 rfg
= rfapi_group_new (bgp
, RFAPI_GROUP_CFG_NVE
, argv
[2]->arg
);
2438 /* Error out of memory */
2439 vty_out (vty
, "Can't allocate memory for NVE group%s", VTY_NEWLINE
);
2443 /* Copy defaults from struct rfapi_cfg */
2444 rfg
->rd
= bgp
->rfapi_cfg
->default_rd
;
2445 if (bgp
->rfapi_cfg
->flags
& BGP_VNC_CONFIG_L2RD
)
2447 rfg
->l2rd
= bgp
->rfapi_cfg
->default_l2rd
;
2448 rfg
->flags
|= RFAPI_RFG_L2RD
;
2450 rfg
->rd
= bgp
->rfapi_cfg
->default_rd
;
2451 rfg
->response_lifetime
= bgp
->rfapi_cfg
->default_response_lifetime
;
2453 if (bgp
->rfapi_cfg
->default_rt_export_list
)
2455 rfg
->rt_export_list
=
2456 ecommunity_dup (bgp
->rfapi_cfg
->default_rt_export_list
);
2459 if (bgp
->rfapi_cfg
->default_rt_import_list
)
2461 rfg
->rt_import_list
=
2462 ecommunity_dup (bgp
->rfapi_cfg
->default_rt_import_list
);
2463 rfg
->rfapi_import_table
=
2464 rfapiImportTableRefAdd (bgp
, rfg
->rt_import_list
, rfg
);
2468 * If a redist nve group was named but the group was not defined,
2469 * make the linkage now
2471 if (!bgp
->rfapi_cfg
->rfg_redist
)
2473 if (bgp
->rfapi_cfg
->rfg_redist_name
&&
2474 !strcmp (bgp
->rfapi_cfg
->rfg_redist_name
, rfg
->name
))
2477 vnc_redistribute_prechange (bgp
);
2478 bgp
->rfapi_cfg
->rfg_redist
= rfg
;
2479 vnc_redistribute_postchange (bgp
);
2485 * Same treatment for bgp-direct export group
2487 for (ALL_LIST_ELEMENTS (bgp
->rfapi_cfg
->rfg_export_direct_bgp_l
,
2491 if (!strcmp (rfgn
->name
, rfg
->name
))
2494 vnc_direct_bgp_add_group (bgp
, rfg
);
2500 * Same treatment for zebra export group
2502 for (ALL_LIST_ELEMENTS (bgp
->rfapi_cfg
->rfg_export_zebra_l
,
2506 vnc_zlog_debug_verbose ("%s: ezport zebra: checking if \"%s\" == \"%s\"",
2507 __func__
, rfgn
->name
, rfg
->name
);
2508 if (!strcmp (rfgn
->name
, rfg
->name
))
2511 vnc_zebra_add_group (bgp
, rfg
);
2518 * XXX subsequent calls will need to make sure this item is still
2519 * in the linked list and has the same name
2521 VTY_PUSH_CONTEXT_SUB (BGP_VNC_NVE_GROUP_NODE
, rfg
);
2527 bgp_rfapi_delete_nve_group (
2528 struct vty
*vty
, /* NULL = no output */
2530 struct rfapi_nve_group_cfg
*rfg
)
2532 struct list
*orphaned_nves
= NULL
;
2533 struct listnode
*node
, *nnode
;
2536 * If there are currently-open NVEs that belong to this group,
2537 * zero out their references to this group structure.
2541 struct rfapi_descriptor
*rfd
;
2542 orphaned_nves
= list_new ();
2543 while ((rfd
= listnode_head (rfg
->nves
)))
2546 listnode_delete (rfg
->nves
, rfd
);
2547 listnode_add (orphaned_nves
, rfd
);
2549 list_delete (rfg
->nves
);
2555 if (rfg
->rfapi_import_table
)
2556 rfapiImportTableRefDelByIt (bgp
, rfg
->rfapi_import_table
);
2557 if (rfg
->rt_import_list
)
2558 ecommunity_free (&rfg
->rt_import_list
);
2559 if (rfg
->rt_export_list
)
2560 ecommunity_free (&rfg
->rt_export_list
);
2564 rfg
->vn_node
->info
= NULL
;
2565 route_unlock_node (rfg
->vn_node
); /* frees */
2569 rfg
->un_node
->info
= NULL
;
2570 route_unlock_node (rfg
->un_node
); /* frees */
2573 XFREE (MTYPE_RFAPI_RFP_GROUP_CFG
, rfg
->rfp_cfg
);
2574 listnode_delete (bgp
->rfapi_cfg
->nve_groups_sequential
, rfg
);
2577 XFREE (MTYPE_RFAPI_GROUP_CFG
, rfg
);
2580 * Attempt to reassign the orphaned nves to a new group. If
2581 * a NVE can not be reassigned, its rfd->rfg will remain NULL
2582 * and it will become a zombie until released by rfapi_close().
2586 struct rfapi_descriptor
*rfd
;
2588 for (ALL_LIST_ELEMENTS (orphaned_nves
, node
, nnode
, rfd
))
2591 * 1. rfapi_close() equivalent except:
2592 * a. don't free original descriptor
2593 * b. remember query list
2594 * c. remember advertised route list
2595 * 2. rfapi_open() equivalent except:
2596 * a. reuse original descriptor
2597 * 3. rfapi_register() on remembered advertised route list
2598 * 4. rfapi_query on rememebred query list
2603 rc
= rfapi_reopen (rfd
, bgp
);
2607 list_delete_node (orphaned_nves
, node
);
2609 vty_out (vty
, "WARNING: reassigned NVE vn=");
2610 rfapiPrintRfapiIpAddr (vty
, &rfd
->vn_addr
);
2612 vty_out (vty
, " un=");
2613 rfapiPrintRfapiIpAddr (vty
, &rfd
->un_addr
);
2615 vty_out (vty
, " to new group \"%s\"%s", rfd
->rfg
->name
,
2621 for (ALL_LIST_ELEMENTS_RO (orphaned_nves
, node
, rfd
))
2624 vty_out (vty
, "WARNING: orphaned NVE vn=");
2625 rfapiPrintRfapiIpAddr (vty
, &rfd
->vn_addr
);
2627 vty_out (vty
, " un=");
2628 rfapiPrintRfapiIpAddr (vty
, &rfd
->un_addr
);
2630 vty_out (vty
, "%s", VTY_NEWLINE
);
2632 list_delete (orphaned_nves
);
2637 bgp_rfapi_delete_named_nve_group (
2638 struct vty
*vty
, /* NULL = no output */
2640 const char *rfg_name
, /* NULL = any */
2641 rfapi_group_cfg_type_t type
) /* _MAX = any */
2643 struct rfapi_nve_group_cfg
*rfg
= NULL
;
2644 struct listnode
*node
, *nnode
;
2645 struct rfapi_rfg_name
*rfgn
;
2647 /* Search for name */
2650 rfg
= bgp_rfapi_cfg_match_byname (bgp
, rfg_name
, type
);
2654 vty_out (vty
, "No NVE group named \"%s\"%s", rfg_name
,
2661 * If this group is the redist nve group, unlink it
2663 if (rfg_name
== NULL
|| bgp
->rfapi_cfg
->rfg_redist
== rfg
)
2665 vnc_redistribute_prechange (bgp
);
2666 bgp
->rfapi_cfg
->rfg_redist
= NULL
;
2667 vnc_redistribute_postchange (bgp
);
2672 * remove reference from bgp direct export list
2674 for (ALL_LIST_ELEMENTS_RO (bgp
->rfapi_cfg
->rfg_export_direct_bgp_l
,
2677 if (rfg_name
== NULL
||
2678 (type
== RFAPI_GROUP_CFG_NVE
&& !strcmp (rfgn
->name
, rfg_name
)))
2681 /* remove exported routes from this group */
2682 vnc_direct_bgp_del_group (bgp
, rfg
);
2688 * remove reference from zebra export list
2690 for (ALL_LIST_ELEMENTS_RO (bgp
->rfapi_cfg
->rfg_export_zebra_l
, node
, rfgn
))
2693 if (rfg_name
== NULL
||
2694 (type
== RFAPI_GROUP_CFG_NVE
&& !strcmp (rfgn
->name
, rfg_name
)))
2697 /* remove exported routes from this group */
2698 vnc_zebra_del_group (bgp
, rfg
);
2703 bgp_rfapi_delete_nve_group (vty
, bgp
, rfg
);
2704 else /* must be delete all */
2705 for (ALL_LIST_ELEMENTS
2706 (bgp
->rfapi_cfg
->nve_groups_sequential
, node
, nnode
, rfg
))
2707 bgp_rfapi_delete_nve_group (vty
, bgp
, rfg
);
2711 DEFUN (vnc_no_nve_group
,
2712 vnc_no_nve_group_cmd
,
2713 "no vnc nve-group NAME",
2716 "Configure a NVE group\n"
2719 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2721 return bgp_rfapi_delete_named_nve_group (vty
, bgp
, argv
[3]->arg
, RFAPI_GROUP_CFG_NVE
);
2724 DEFUN (vnc_nve_group_prefix
,
2725 vnc_nve_group_prefix_cmd
,
2726 "prefix <vn|un> <A.B.C.D/M|X:X::X:X/M>",
2727 "Specify prefixes matching NVE VN or UN interfaces\n"
2733 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2734 VTY_DECLVAR_CONTEXT_SUB(rfapi_nve_group_cfg
, rfg
);
2737 struct route_table
*rt
;
2738 struct route_node
*rn
;
2739 int is_un_prefix
= 0;
2741 /* make sure it's still in list */
2742 if (!listnode_lookup (bgp
->rfapi_cfg
->nve_groups_sequential
, rfg
))
2744 /* Not in list anymore */
2745 vty_out (vty
, "Current NVE group no longer exists%s", VTY_NEWLINE
);
2749 if (!str2prefix (argv
[2]->arg
, &p
))
2751 vty_out (vty
, "Malformed prefix \"%s\"%s", argv
[2]->arg
, VTY_NEWLINE
);
2755 afi
= family2afi (p
.family
);
2758 vty_out (vty
, "Unsupported address family%s", VTY_NEWLINE
);
2762 if (argv
[1]->arg
[0] == 'u')
2764 rt
= &(bgp
->rfapi_cfg
->nve_groups_un
[afi
]);
2769 rt
= &(bgp
->rfapi_cfg
->nve_groups_vn
[afi
]);
2772 rn
= route_node_get (rt
, &p
); /* NB locks node */
2776 * There is already a group with this prefix
2778 route_unlock_node (rn
);
2779 if (rn
->info
!= rfg
)
2782 * different group name: fail
2784 vty_out (vty
, "nve group \"%s\" already has \"%s\" prefix %s%s",
2785 ((struct rfapi_nve_group_cfg
*) (rn
->info
))->name
,
2786 argv
[1]->arg
, argv
[2]->arg
, VTY_NEWLINE
);
2792 * same group name: it's already in the correct place
2793 * in the table, so we're done.
2795 * Implies rfg->(vn|un)_prefix is already correct.
2801 if (bgp
->rfapi_cfg
->rfg_redist
== rfg
)
2803 vnc_redistribute_prechange (bgp
);
2806 /* New prefix, new node */
2811 /* detach rfg from previous route table location */
2814 rfg
->un_node
->info
= NULL
;
2815 route_unlock_node (rfg
->un_node
); /* frees */
2817 rfg
->un_node
= rn
; /* back ref */
2824 /* detach rfg from previous route table location */
2827 rfg
->vn_node
->info
= NULL
;
2828 route_unlock_node (rfg
->vn_node
); /* frees */
2830 rfg
->vn_node
= rn
; /* back ref */
2837 if (bgp
->rfapi_cfg
->rfg_redist
== rfg
)
2839 vnc_redistribute_postchange (bgp
);
2845 DEFUN (vnc_nve_group_rt_import
,
2846 vnc_nve_group_rt_import_cmd
,
2847 "rt import RTLIST...",
2848 "Specify route targets\n"
2850 "Space separated route target list (A.B.C.D:MN|EF:OPQR|GHJK:MN)\n")
2852 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2853 VTY_DECLVAR_CONTEXT_SUB(rfapi_nve_group_cfg
, rfg
);
2855 struct listnode
*node
;
2856 struct rfapi_rfg_name
*rfgn
;
2857 int is_export_bgp
= 0;
2858 int is_export_zebra
= 0;
2860 /* make sure it's still in list */
2861 if (!listnode_lookup (bgp
->rfapi_cfg
->nve_groups_sequential
, rfg
))
2863 /* Not in list anymore */
2864 vty_out (vty
, "Current NVE group no longer exists%s", VTY_NEWLINE
);
2868 rc
= set_ecom_list (vty
, argc
- 2, argv
+ 2, &rfg
->rt_import_list
);
2869 if (rc
!= CMD_SUCCESS
)
2872 for (ALL_LIST_ELEMENTS_RO (bgp
->rfapi_cfg
->rfg_export_direct_bgp_l
,
2876 if (rfgn
->rfg
== rfg
)
2884 vnc_direct_bgp_del_group (bgp
, rfg
);
2886 for (ALL_LIST_ELEMENTS_RO (bgp
->rfapi_cfg
->rfg_export_zebra_l
, node
, rfgn
))
2889 if (rfgn
->rfg
== rfg
)
2891 is_export_zebra
= 1;
2896 if (is_export_zebra
)
2897 vnc_zebra_del_group (bgp
, rfg
);
2900 * stop referencing old import table, now reference new one
2902 if (rfg
->rfapi_import_table
)
2903 rfapiImportTableRefDelByIt (bgp
, rfg
->rfapi_import_table
);
2904 rfg
->rfapi_import_table
= rfapiImportTableRefAdd (bgp
, rfg
->rt_import_list
, rfg
);
2907 vnc_direct_bgp_add_group (bgp
, rfg
);
2909 if (is_export_zebra
)
2910 vnc_zebra_add_group (bgp
, rfg
);
2915 DEFUN (vnc_nve_group_rt_export
,
2916 vnc_nve_group_rt_export_cmd
,
2917 "rt export RTLIST...",
2918 "Specify route targets\n"
2920 "Space separated route target list (A.B.C.D:MN|EF:OPQR|GHJK:MN)\n")
2922 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2923 VTY_DECLVAR_CONTEXT_SUB(rfapi_nve_group_cfg
, rfg
);
2926 /* make sure it's still in list */
2927 if (!listnode_lookup (bgp
->rfapi_cfg
->nve_groups_sequential
, rfg
))
2929 /* Not in list anymore */
2930 vty_out (vty
, "Current NVE group no longer exists%s", VTY_NEWLINE
);
2934 if (bgp
->rfapi_cfg
->rfg_redist
== rfg
)
2936 vnc_redistribute_prechange (bgp
);
2939 rc
= set_ecom_list (vty
, argc
- 2, argv
+ 2, &rfg
->rt_export_list
);
2941 if (bgp
->rfapi_cfg
->rfg_redist
== rfg
)
2943 vnc_redistribute_postchange (bgp
);
2949 DEFUN (vnc_nve_group_rt_both
,
2950 vnc_nve_group_rt_both_cmd
,
2951 "rt both RTLIST...",
2952 "Specify route targets\n"
2953 "Export+import filters\n"
2954 "Space separated route target list (A.B.C.D:MN|EF:OPQR|GHJK:MN)\n")
2956 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2957 VTY_DECLVAR_CONTEXT_SUB(rfapi_nve_group_cfg
, rfg
);
2959 int is_export_bgp
= 0;
2960 int is_export_zebra
= 0;
2961 struct listnode
*node
;
2962 struct rfapi_rfg_name
*rfgn
;
2964 /* make sure it's still in list */
2965 if (!listnode_lookup (bgp
->rfapi_cfg
->nve_groups_sequential
, rfg
))
2967 /* Not in list anymore */
2968 vty_out (vty
, "Current NVE group no longer exists%s", VTY_NEWLINE
);
2972 rc
= set_ecom_list (vty
, argc
- 2, argv
+ 2, &rfg
->rt_import_list
);
2973 if (rc
!= CMD_SUCCESS
)
2976 for (ALL_LIST_ELEMENTS_RO (bgp
->rfapi_cfg
->rfg_export_direct_bgp_l
,
2980 if (rfgn
->rfg
== rfg
)
2988 vnc_direct_bgp_del_group (bgp
, rfg
);
2990 for (ALL_LIST_ELEMENTS_RO (bgp
->rfapi_cfg
->rfg_export_zebra_l
, node
, rfgn
))
2993 if (rfgn
->rfg
== rfg
)
2995 is_export_zebra
= 1;
3000 if (is_export_zebra
)
3002 vnc_zlog_debug_verbose ("%s: is_export_zebra", __func__
);
3003 vnc_zebra_del_group (bgp
, rfg
);
3007 * stop referencing old import table, now reference new one
3009 if (rfg
->rfapi_import_table
)
3010 rfapiImportTableRefDelByIt (bgp
, rfg
->rfapi_import_table
);
3011 rfg
->rfapi_import_table
= rfapiImportTableRefAdd (bgp
, rfg
->rt_import_list
, rfg
);
3014 vnc_direct_bgp_add_group (bgp
, rfg
);
3016 if (is_export_zebra
)
3017 vnc_zebra_add_group (bgp
, rfg
);
3019 if (bgp
->rfapi_cfg
->rfg_redist
== rfg
)
3021 vnc_redistribute_prechange (bgp
);
3024 rc
= set_ecom_list (vty
, argc
- 2, argv
+ 2, &rfg
->rt_export_list
);
3026 if (bgp
->rfapi_cfg
->rfg_redist
== rfg
)
3028 vnc_redistribute_postchange (bgp
);
3035 DEFUN (vnc_nve_group_l2rd
,
3036 vnc_nve_group_l2rd_cmd
,
3037 "l2rd <(1-255)|auto-vn>",
3038 "Specify default Local Nve ID value to use in RD for L2 routes\n"
3039 "Fixed value 1-255\n"
3040 "use the low-order octet of the NVE's VN address\n")
3042 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3043 VTY_DECLVAR_CONTEXT_SUB(rfapi_nve_group_cfg
, rfg
);
3045 /* make sure it's still in list */
3046 if (!listnode_lookup (bgp
->rfapi_cfg
->nve_groups_sequential
, rfg
))
3048 /* Not in list anymore */
3049 vty_out (vty
, "Current NVE group no longer exists%s", VTY_NEWLINE
);
3053 if (strmatch(argv
[1]->text
, "auto:vn"))
3060 unsigned long value_l
= strtoul (argv
[1]->arg
, &end
, 10);
3061 uint8_t value
= value_l
& 0xff;
3063 if (!argv
[1]->arg
[0] || *end
)
3065 vty_out (vty
, "%% Malformed l2 nve ID \"%s\"%s", argv
[1]->arg
,
3069 if ((value_l
< 1) || (value_l
> 0xff))
3072 "%% Malformed l2 nve id (must be greater than 0 and less than %u%s",
3073 0x100, VTY_NEWLINE
);
3079 rfg
->flags
|= RFAPI_RFG_L2RD
;
3084 DEFUN (vnc_nve_group_no_l2rd
,
3085 vnc_nve_group_no_l2rd_cmd
,
3088 "Specify default Local Nve ID value to use in RD for L2 routes\n")
3090 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3091 VTY_DECLVAR_CONTEXT_SUB(rfapi_nve_group_cfg
, rfg
);
3093 /* make sure it's still in list */
3094 if (!listnode_lookup (bgp
->rfapi_cfg
->nve_groups_sequential
, rfg
))
3096 /* Not in list anymore */
3097 vty_out (vty
, "Current NVE group no longer exists%s", VTY_NEWLINE
);
3102 rfg
->flags
&= ~RFAPI_RFG_L2RD
;
3107 DEFUN (vnc_nve_group_rd
,
3108 vnc_nve_group_rd_cmd
,
3109 "rd ASN:nn_or_IP-address:nn",
3110 "Specify route distinguisher\n"
3111 "Route Distinguisher (<as-number>:<number> | <ip-address>:<number> | auto:vn:<number> )\n")
3113 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3115 struct prefix_rd prd
;
3116 VTY_DECLVAR_CONTEXT_SUB(rfapi_nve_group_cfg
, rfg
);
3118 /* make sure it's still in list */
3119 if (!listnode_lookup (bgp
->rfapi_cfg
->nve_groups_sequential
, rfg
))
3121 /* Not in list anymore */
3122 vty_out (vty
, "Current NVE group no longer exists%s", VTY_NEWLINE
);
3126 if (!strncmp (argv
[1]->arg
, "auto:vn:", 8))
3129 * use AF_UNIX to designate automatically-assigned RD
3130 * auto:vn:nn where nn is a 2-octet quantity
3133 uint32_t value32
= strtoul (argv
[1]->arg
+ 8, &end
, 10);
3134 uint16_t value
= value32
& 0xffff;
3136 if (!argv
[1]->arg
[8] || *end
)
3138 vty_out (vty
, "%% Malformed rd%s", VTY_NEWLINE
);
3141 if (value32
> 0xffff)
3143 vty_out (vty
, "%% Malformed rd (must be less than %u%s",
3144 0x0ffff, VTY_NEWLINE
);
3148 memset (&prd
, 0, sizeof (prd
));
3149 prd
.family
= AF_UNIX
;
3151 prd
.val
[0] = (RD_TYPE_IP
>> 8) & 0x0ff;
3152 prd
.val
[1] = RD_TYPE_IP
& 0x0ff;
3153 prd
.val
[6] = (value
>> 8) & 0x0ff;
3154 prd
.val
[7] = value
& 0x0ff;
3160 ret
= str2prefix_rd (argv
[1]->arg
, &prd
);
3163 vty_out (vty
, "%% Malformed rd%s", VTY_NEWLINE
);
3168 if (bgp
->rfapi_cfg
->rfg_redist
== rfg
)
3170 vnc_redistribute_prechange (bgp
);
3175 if (bgp
->rfapi_cfg
->rfg_redist
== rfg
)
3177 vnc_redistribute_postchange (bgp
);
3182 DEFUN (vnc_nve_group_responselifetime
,
3183 vnc_nve_group_responselifetime_cmd
,
3184 "response-lifetime <LIFETIME|infinite>",
3185 "Specify response lifetime\n"
3186 "Response lifetime in seconds\n" "Infinite response lifetime\n")
3188 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3189 unsigned int rspint
;
3190 VTY_DECLVAR_CONTEXT_SUB(rfapi_nve_group_cfg
, rfg
);
3191 struct rfapi_descriptor
*rfd
;
3192 struct listnode
*hdnode
;
3194 /* make sure it's still in list */
3195 if (!listnode_lookup (bgp
->rfapi_cfg
->nve_groups_sequential
, rfg
))
3197 /* Not in list anymore */
3198 vty_out (vty
, "Current NVE group no longer exists%s", VTY_NEWLINE
);
3202 if (strmatch(argv
[1]->text
, "infinite"))
3204 rspint
= RFAPI_INFINITE_LIFETIME
;
3208 VTY_GET_INTEGER ("Response Lifetime", rspint
, argv
[1]->arg
);
3211 rfg
->response_lifetime
= rspint
;
3212 rfg
->flags
|= RFAPI_RFG_RESPONSE_LIFETIME
;
3214 for (ALL_LIST_ELEMENTS_RO (rfg
->nves
, hdnode
, rfd
))
3215 rfd
->response_lifetime
= rspint
;
3220 * Sigh. This command, like exit-address-family, is a hack to deal
3221 * with the lack of rigorous level control in the command handler.
3222 * TBD fix command handler.
3224 DEFUN_NOSH (exit_vnc
,
3227 "Exit VNC configuration mode\n")
3229 if (vty
->node
== BGP_VNC_DEFAULTS_NODE
||
3230 vty
->node
== BGP_VNC_NVE_GROUP_NODE
||
3231 vty
->node
== BGP_VNC_L2_GROUP_NODE
)
3234 vty
->node
= BGP_NODE
;
3239 static struct cmd_node bgp_vnc_defaults_node
= {
3240 BGP_VNC_DEFAULTS_NODE
,
3241 "%s(config-router-vnc-defaults)# ",
3245 static struct cmd_node bgp_vnc_nve_group_node
= {
3246 BGP_VNC_NVE_GROUP_NODE
,
3247 "%s(config-router-vnc-nve-group)# ",
3251 /*-------------------------------------------------------------------------
3253 * Note there are two types of NVEs, one for VPNs one for RFP NVEs
3254 *-----------------------------------------------------------------------*/
3256 DEFUN_NOSH (vnc_vrf_policy
,
3259 "Configure a VRF policy group\n"
3262 struct rfapi_nve_group_cfg
*rfg
;
3263 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3267 vty_out (vty
, "No BGP process is configured%s", VTY_NEWLINE
);
3271 /* Search for name */
3272 rfg
= bgp_rfapi_cfg_match_byname (bgp
, argv
[1]->arg
, RFAPI_GROUP_CFG_VRF
);
3276 rfg
= rfapi_group_new (bgp
, RFAPI_GROUP_CFG_VRF
, argv
[1]->arg
);
3279 /* Error out of memory */
3280 vty_out (vty
, "Can't allocate memory for NVE group%s", VTY_NEWLINE
);
3285 * XXX subsequent calls will need to make sure this item is still
3286 * in the linked list and has the same name
3288 VTY_PUSH_CONTEXT_SUB (BGP_VRF_POLICY_NODE
, rfg
);
3293 DEFUN (vnc_no_vrf_policy
,
3294 vnc_no_vrf_policy_cmd
,
3295 "no vrf-policy NAME",
3297 "Remove a VRF policy group\n"
3300 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3304 vty_out (vty
, "No BGP process is configured%s", VTY_NEWLINE
);
3307 return bgp_rfapi_delete_named_nve_group (vty
, bgp
, argv
[2]->arg
, RFAPI_GROUP_CFG_VRF
);
3310 DEFUN (vnc_vrf_policy_label
,
3311 vnc_vrf_policy_label_cmd
,
3312 "label (0-1048575)",
3313 "Default label value for VRF\n"
3314 "Label Value <0-1048575>\n")
3316 VTY_DECLVAR_CONTEXT_SUB(rfapi_nve_group_cfg
, rfg
);
3319 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3323 vty_out (vty
, "No BGP process is configured%s", VTY_NEWLINE
);
3327 /* make sure it's still in list */
3328 if (!listnode_lookup (bgp
->rfapi_cfg
->nve_groups_sequential
, rfg
))
3330 /* Not in list anymore */
3331 vty_out (vty
, "Current NVE group no longer exists%s", VTY_NEWLINE
);
3335 VTY_GET_INTEGER_RANGE ("Label value", label
, argv
[1]->arg
, 0, MPLS_LABEL_MAX
);
3337 if (bgp
->rfapi_cfg
->rfg_redist
== rfg
)
3339 vnc_redistribute_prechange (bgp
);
3344 if (bgp
->rfapi_cfg
->rfg_redist
== rfg
)
3346 vnc_redistribute_postchange (bgp
);
3351 DEFUN (vnc_vrf_policy_no_label
,
3352 vnc_vrf_policy_no_label_cmd
,
3355 "Remove VRF default label\n")
3357 VTY_DECLVAR_CONTEXT_SUB(rfapi_nve_group_cfg
, rfg
);
3358 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3360 /* make sure it's still in list */
3361 if (!listnode_lookup (bgp
->rfapi_cfg
->nve_groups_sequential
, rfg
))
3363 /* Not in list anymore */
3364 vty_out (vty
, "Current VRF group no longer exists%s", VTY_NEWLINE
);
3368 if (bgp
->rfapi_cfg
->rfg_redist
== rfg
)
3370 vnc_redistribute_prechange (bgp
);
3373 rfg
->label
= MPLS_LABEL_ILLEGAL
;
3375 if (bgp
->rfapi_cfg
->rfg_redist
== rfg
)
3377 vnc_redistribute_postchange (bgp
);
3382 DEFUN (vnc_vrf_policy_nexthop
,
3383 vnc_vrf_policy_nexthop_cmd
,
3384 "nexthop <A.B.C.D|X:X::X:X|self>",
3385 "Specify next hop to use for VRF advertised prefixes\n"
3388 "Use configured router-id (default)\n")
3390 VTY_DECLVAR_CONTEXT_SUB(rfapi_nve_group_cfg
, rfg
);
3393 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3395 /* make sure it's still in list */
3396 if (!listnode_lookup (bgp
->rfapi_cfg
->nve_groups_sequential
, rfg
))
3398 /* Not in list anymore */
3399 vty_out (vty
, "Current VRF no longer exists%s", VTY_NEWLINE
);
3403 if (bgp
->rfapi_cfg
->rfg_redist
== rfg
)
3405 vnc_redistribute_prechange (bgp
);
3408 if (!str2prefix (argv
[1]->arg
, &p
) && p
.family
)
3410 //vty_out (vty, "Nexthop set to self%s", VTY_NEWLINE);
3411 SET_FLAG (rfg
->flags
, RFAPI_RFG_VPN_NH_SELF
);
3412 memset(&rfg
->vn_prefix
, 0, sizeof(struct prefix
));
3416 UNSET_FLAG (rfg
->flags
, RFAPI_RFG_VPN_NH_SELF
);
3421 /* TBD handle router-id/ nexthop changes when have advertised prefixes */
3423 if (bgp
->rfapi_cfg
->rfg_redist
== rfg
)
3425 vnc_redistribute_postchange (bgp
);
3431 /* The RT code should be refactored/simplified with above... */
3432 DEFUN (vnc_vrf_policy_rt_import
,
3433 vnc_vrf_policy_rt_import_cmd
,
3434 "rt import RTLIST...",
3435 "Specify route targets\n"
3437 "Space separated route target list (A.B.C.D:MN|EF:OPQR|GHJK:MN)\n")
3439 VTY_DECLVAR_CONTEXT_SUB(rfapi_nve_group_cfg
, rfg
);
3440 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3442 struct listnode
*node
;
3443 struct rfapi_rfg_name
*rfgn
;
3444 int is_export_bgp
= 0;
3445 int is_export_zebra
= 0;
3449 vty_out (vty
, "No BGP process is configured%s", VTY_NEWLINE
);
3453 /* make sure it's still in list */
3454 if (!listnode_lookup (bgp
->rfapi_cfg
->nve_groups_sequential
, rfg
))
3456 /* Not in list anymore */
3457 vty_out (vty
, "Current NVE group no longer exists%s", VTY_NEWLINE
);
3461 rc
= set_ecom_list (vty
, argc
-2, argv
+2, &rfg
->rt_import_list
);
3462 if (rc
!= CMD_SUCCESS
)
3465 for (ALL_LIST_ELEMENTS_RO (bgp
->rfapi_cfg
->rfg_export_direct_bgp_l
,
3469 if (rfgn
->rfg
== rfg
)
3477 vnc_direct_bgp_del_group (bgp
, rfg
);
3479 for (ALL_LIST_ELEMENTS_RO (bgp
->rfapi_cfg
->rfg_export_zebra_l
, node
, rfgn
))
3482 if (rfgn
->rfg
== rfg
)
3484 is_export_zebra
= 1;
3489 if (is_export_zebra
)
3490 vnc_zebra_del_group (bgp
, rfg
);
3493 * stop referencing old import table, now reference new one
3495 if (rfg
->rfapi_import_table
)
3496 rfapiImportTableRefDelByIt (bgp
, rfg
->rfapi_import_table
);
3497 rfg
->rfapi_import_table
= rfapiImportTableRefAdd (bgp
, rfg
->rt_import_list
, rfg
);
3500 vnc_direct_bgp_add_group (bgp
, rfg
);
3502 if (is_export_zebra
)
3503 vnc_zebra_add_group (bgp
, rfg
);
3508 DEFUN (vnc_vrf_policy_rt_export
,
3509 vnc_vrf_policy_rt_export_cmd
,
3510 "rt export RTLIST...",
3511 "Specify route targets\n"
3513 "Space separated route target list (A.B.C.D:MN|EF:OPQR|GHJK:MN)\n")
3515 VTY_DECLVAR_CONTEXT_SUB(rfapi_nve_group_cfg
, rfg
);
3516 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3521 vty_out (vty
, "No BGP process is configured%s", VTY_NEWLINE
);
3525 /* make sure it's still in list */
3526 if (!listnode_lookup (bgp
->rfapi_cfg
->nve_groups_sequential
, rfg
))
3528 /* Not in list anymore */
3529 vty_out (vty
, "Current NVE group no longer exists%s", VTY_NEWLINE
);
3533 if (bgp
->rfapi_cfg
->rfg_redist
== rfg
)
3535 vnc_redistribute_prechange (bgp
);
3538 rc
= set_ecom_list (vty
, argc
-2, argv
+2, &rfg
->rt_export_list
);
3540 if (bgp
->rfapi_cfg
->rfg_redist
== rfg
)
3542 vnc_redistribute_postchange (bgp
);
3548 DEFUN (vnc_vrf_policy_rt_both
,
3549 vnc_vrf_policy_rt_both_cmd
,
3550 "rt both RTLIST...",
3551 "Specify route targets\n"
3552 "Export+import filters\n"
3553 "Space separated route target list (A.B.C.D:MN|EF:OPQR|GHJK:MN)\n")
3555 VTY_DECLVAR_CONTEXT_SUB(rfapi_nve_group_cfg
, rfg
);
3556 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3558 int is_export_bgp
= 0;
3559 int is_export_zebra
= 0;
3560 struct listnode
*node
;
3561 struct rfapi_rfg_name
*rfgn
;
3565 vty_out (vty
, "No BGP process is configured%s", VTY_NEWLINE
);
3569 /* make sure it's still in list */
3570 if (!listnode_lookup (bgp
->rfapi_cfg
->nve_groups_sequential
, rfg
))
3572 /* Not in list anymore */
3573 vty_out (vty
, "Current NVE group no longer exists%s", VTY_NEWLINE
);
3577 rc
= set_ecom_list (vty
, argc
-2, argv
+2, &rfg
->rt_import_list
);
3578 if (rc
!= CMD_SUCCESS
)
3581 for (ALL_LIST_ELEMENTS_RO (bgp
->rfapi_cfg
->rfg_export_direct_bgp_l
,
3585 if (rfgn
->rfg
== rfg
)
3593 vnc_direct_bgp_del_group (bgp
, rfg
);
3595 for (ALL_LIST_ELEMENTS_RO (bgp
->rfapi_cfg
->rfg_export_zebra_l
, node
, rfgn
))
3598 if (rfgn
->rfg
== rfg
)
3600 is_export_zebra
= 1;
3605 if (is_export_zebra
)
3607 vnc_zlog_debug_verbose ("%s: is_export_zebra", __func__
);
3608 vnc_zebra_del_group (bgp
, rfg
);
3612 * stop referencing old import table, now reference new one
3614 if (rfg
->rfapi_import_table
)
3615 rfapiImportTableRefDelByIt (bgp
, rfg
->rfapi_import_table
);
3616 rfg
->rfapi_import_table
= rfapiImportTableRefAdd (bgp
, rfg
->rt_import_list
, rfg
);
3619 vnc_direct_bgp_add_group (bgp
, rfg
);
3621 if (is_export_zebra
)
3622 vnc_zebra_add_group (bgp
, rfg
);
3624 if (bgp
->rfapi_cfg
->rfg_redist
== rfg
)
3626 vnc_redistribute_prechange (bgp
);
3629 rc
= set_ecom_list (vty
, argc
-2, argv
+2, &rfg
->rt_export_list
);
3631 if (bgp
->rfapi_cfg
->rfg_redist
== rfg
)
3633 vnc_redistribute_postchange (bgp
);
3640 DEFUN (vnc_vrf_policy_rd
,
3641 vnc_vrf_policy_rd_cmd
,
3642 "rd ASN:nn_or_IP-address:nn",
3643 "Specify default VRF route distinguisher\n"
3644 "Route Distinguisher (<as-number>:<number> | <ip-address>:<number> | auto:nh:<number> )\n")
3647 struct prefix_rd prd
;
3648 VTY_DECLVAR_CONTEXT_SUB(rfapi_nve_group_cfg
, rfg
);
3649 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3653 vty_out (vty
, "No BGP process is configured%s", VTY_NEWLINE
);
3657 /* make sure it's still in list */
3658 if (!listnode_lookup (bgp
->rfapi_cfg
->nve_groups_sequential
, rfg
))
3660 /* Not in list anymore */
3661 vty_out (vty
, "Current NVE group no longer exists%s", VTY_NEWLINE
);
3665 if (!strncmp (argv
[1]->arg
, "auto:nh:", 8))
3668 * use AF_UNIX to designate automatically-assigned RD
3669 * auto:vn:nn where nn is a 2-octet quantity
3672 uint32_t value32
= strtoul (argv
[1]->arg
+ 8, &end
, 10);
3673 uint16_t value
= value32
& 0xffff;
3675 if (!*(argv
[1]->arg
+ 5) || *end
)
3677 vty_out (vty
, "%% Malformed rd%s", VTY_NEWLINE
);
3680 if (value32
> 0xffff)
3682 vty_out (vty
, "%% Malformed rd (must be less than %u%s",
3683 0x0ffff, VTY_NEWLINE
);
3687 memset (&prd
, 0, sizeof (prd
));
3688 prd
.family
= AF_UNIX
;
3690 prd
.val
[0] = (RD_TYPE_IP
>> 8) & 0x0ff;
3691 prd
.val
[1] = RD_TYPE_IP
& 0x0ff;
3692 prd
.val
[6] = (value
>> 8) & 0x0ff;
3693 prd
.val
[7] = value
& 0x0ff;
3699 ret
= str2prefix_rd (argv
[1]->arg
, &prd
);
3702 vty_out (vty
, "%% Malformed rd%s", VTY_NEWLINE
);
3707 if (bgp
->rfapi_cfg
->rfg_redist
== rfg
)
3709 vnc_redistribute_prechange (bgp
);
3714 if (bgp
->rfapi_cfg
->rfg_redist
== rfg
)
3716 vnc_redistribute_postchange (bgp
);
3721 DEFUN_NOSH (exit_vrf_policy
,
3722 exit_vrf_policy_cmd
,
3724 "Exit VRF policy configuration mode\n")
3726 if (vty
->node
== BGP_VRF_POLICY_NODE
)
3728 vty
->node
= BGP_NODE
;
3733 static struct cmd_node bgp_vrf_policy_node
= {
3734 BGP_VRF_POLICY_NODE
,
3735 "%s(config-router-vrf-policy)# ",
3739 /*-------------------------------------------------------------------------
3741 *-----------------------------------------------------------------------*/
3744 DEFUN_NOSH (vnc_l2_group
,
3746 "vnc l2-group NAME",
3747 VNC_CONFIG_STR
"Configure a L2 group\n" "Group name\n")
3749 struct rfapi_l2_group_cfg
*rfg
;
3750 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3754 vty_out (vty
, "No BGP process is configured%s", VTY_NEWLINE
);
3758 /* Search for name */
3759 rfg
= rfapi_l2_group_lookup_byname (bgp
, argv
[1]->arg
);
3763 rfg
= rfapi_l2_group_new ();
3766 /* Error out of memory */
3767 vty_out (vty
, "Can't allocate memory for L2 group%s", VTY_NEWLINE
);
3770 rfg
->name
= strdup (argv
[1]->arg
);
3771 /* add to tail of list */
3772 listnode_add (bgp
->rfapi_cfg
->l2_groups
, rfg
);
3776 * XXX subsequent calls will need to make sure this item is still
3777 * in the linked list and has the same name
3779 VTY_PUSH_CONTEXT_SUB (BGP_VNC_L2_GROUP_NODE
, rfg
);
3784 bgp_rfapi_delete_l2_group (
3785 struct vty
*vty
, /* NULL = no output */
3787 struct rfapi_l2_group_cfg
*rfg
)
3791 if (rfg
->rt_import_list
)
3792 ecommunity_free (&rfg
->rt_import_list
);
3793 if (rfg
->rt_export_list
)
3794 ecommunity_free (&rfg
->rt_export_list
);
3796 list_delete (rfg
->labels
);
3798 XFREE (MTYPE_RFAPI_RFP_GROUP_CFG
, rfg
->rfp_cfg
);
3799 listnode_delete (bgp
->rfapi_cfg
->l2_groups
, rfg
);
3801 rfapi_l2_group_del (rfg
);
3805 bgp_rfapi_delete_named_l2_group (
3806 struct vty
*vty
, /* NULL = no output */
3808 const char *rfg_name
) /* NULL = any */
3810 struct rfapi_l2_group_cfg
*rfg
= NULL
;
3811 struct listnode
*node
, *nnode
;
3813 /* Search for name */
3816 rfg
= rfapi_l2_group_lookup_byname (bgp
, rfg_name
);
3820 vty_out (vty
, "No L2 group named \"%s\"%s", rfg_name
,
3827 bgp_rfapi_delete_l2_group (vty
, bgp
, rfg
);
3828 else /* must be delete all */
3829 for (ALL_LIST_ELEMENTS (bgp
->rfapi_cfg
->l2_groups
, node
, nnode
, rfg
))
3830 bgp_rfapi_delete_l2_group (vty
, bgp
, rfg
);
3834 DEFUN (vnc_no_l2_group
,
3835 vnc_no_l2_group_cmd
,
3836 "no vnc l2-group NAME",
3839 "Configure a L2 group\n"
3842 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3846 vty_out (vty
, "No BGP process is configured%s", VTY_NEWLINE
);
3849 return bgp_rfapi_delete_named_l2_group (vty
, bgp
, argv
[3]->arg
);
3853 DEFUN (vnc_l2_group_lni
,
3854 vnc_l2_group_lni_cmd
,
3855 "logical-network-id <0-4294967295>",
3856 "Specify Logical Network ID associated with group\n"
3859 VTY_DECLVAR_CONTEXT_SUB(rfapi_l2_group_cfg
, rfg
);
3860 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3864 vty_out (vty
, "No BGP process is configured%s", VTY_NEWLINE
);
3868 /* make sure it's still in list */
3869 if (!listnode_lookup (bgp
->rfapi_cfg
->l2_groups
, rfg
))
3871 /* Not in list anymore */
3872 vty_out (vty
, "Current L2 group no longer exists%s", VTY_NEWLINE
);
3876 VTY_GET_INTEGER ("logical-network-id", rfg
->logical_net_id
, argv
[1]->arg
);
3881 DEFUN (vnc_l2_group_labels
,
3882 vnc_l2_group_labels_cmd
,
3883 "labels LABELLIST...",
3884 "Specify label values associated with group\n"
3885 "Space separated list of label values <0-1048575>\n")
3887 VTY_DECLVAR_CONTEXT_SUB(rfapi_l2_group_cfg
, rfg
);
3888 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3893 vty_out (vty
, "No BGP process is configured%s", VTY_NEWLINE
);
3897 /* make sure it's still in list */
3898 if (!listnode_lookup (bgp
->rfapi_cfg
->l2_groups
, rfg
))
3900 /* Not in list anymore */
3901 vty_out (vty
, "Current L2 group no longer exists%s", VTY_NEWLINE
);
3913 for (; argc
; --argc
, ++argv
)
3916 VTY_GET_INTEGER_RANGE ("Label value", label
, argv
[0]->arg
, 0, MPLS_LABEL_MAX
);
3917 if (!listnode_lookup (ll
, (void *) (uintptr_t) label
))
3918 listnode_add (ll
, (void *) (uintptr_t) label
);
3924 DEFUN (vnc_l2_group_no_labels
,
3925 vnc_l2_group_no_labels_cmd
,
3926 "no labels LABELLIST...",
3928 "Remove label values associated with L2 group\n"
3929 "Specify label values associated with L2 group\n"
3930 "Space separated list of label values <0-1048575>\n")
3932 VTY_DECLVAR_CONTEXT_SUB(rfapi_l2_group_cfg
, rfg
);
3933 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3938 vty_out (vty
, "No BGP process is configured%s", VTY_NEWLINE
);
3942 /* make sure it's still in list */
3943 if (!listnode_lookup (bgp
->rfapi_cfg
->l2_groups
, rfg
))
3945 /* Not in list anymore */
3946 vty_out (vty
, "Current L2 group no longer exists%s", VTY_NEWLINE
);
3953 vty_out (vty
, "Label no longer associated with group%s", VTY_NEWLINE
);
3959 for (; argc
; --argc
, ++argv
)
3962 VTY_GET_INTEGER_RANGE ("Label value", label
, argv
[0]->arg
, 0, MPLS_LABEL_MAX
);
3963 listnode_delete (ll
, (void *) (uintptr_t) label
);
3969 DEFUN (vnc_l2_group_rt
,
3970 vnc_l2_group_rt_cmd
,
3971 "rt <both|export|import> ASN:nn_or_IP-address:nn",
3972 "Specify route targets\n"
3973 "Export+import filters\n"
3978 VTY_DECLVAR_CONTEXT_SUB(rfapi_l2_group_cfg
, rfg
);
3979 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3980 int rc
= CMD_SUCCESS
;
3984 switch (argv
[1]->arg
[0])
3987 do_export
= 1; /* fall through */
3995 vty_out (vty
, "Unknown option, %s%s", argv
[1]->arg
, VTY_NEWLINE
);
3996 return CMD_ERR_NO_MATCH
;
4001 vty_out (vty
, "No BGP process is configured%s", VTY_NEWLINE
);
4005 /* make sure it's still in list */
4006 if (!listnode_lookup (bgp
->rfapi_cfg
->l2_groups
, rfg
))
4008 /* Not in list anymore */
4009 vty_out (vty
, "Current L2 group no longer exists%s", VTY_NEWLINE
);
4014 rc
= set_ecom_list (vty
, argc
-2, argv
+2, &rfg
->rt_import_list
);
4015 if (rc
== CMD_SUCCESS
&& do_export
)
4016 rc
= set_ecom_list (vty
, argc
-2, argv
+2, &rfg
->rt_export_list
);
4021 static struct cmd_node bgp_vnc_l2_group_node
= {
4022 BGP_VNC_L2_GROUP_NODE
,
4023 "%s(config-router-vnc-l2-group)# ",
4027 struct rfapi_l2_group_cfg
*
4028 bgp_rfapi_get_group_by_lni_label (
4030 uint32_t logical_net_id
,
4033 struct rfapi_l2_group_cfg
*rfg
;
4034 struct listnode
*node
;
4036 if (bgp
->rfapi_cfg
->l2_groups
== NULL
) /* not the best place for this */
4039 label
= label
& 0xfffff; /* label is 20 bits! */
4041 for (ALL_LIST_ELEMENTS_RO (bgp
->rfapi_cfg
->l2_groups
, node
, rfg
))
4043 if (rfg
->logical_net_id
== logical_net_id
)
4045 struct listnode
*lnode
;
4047 for (ALL_LIST_ELEMENTS_RO (rfg
->labels
, lnode
, data
))
4048 if (((uint32_t) ((uintptr_t) data
)) == label
)
4058 bgp_rfapi_get_labellist_by_lni_label (
4060 uint32_t logical_net_id
,
4063 struct rfapi_l2_group_cfg
*rfg
;
4064 rfg
= bgp_rfapi_get_group_by_lni_label (bgp
, logical_net_id
, label
);
4073 bgp_rfapi_get_ecommunity_by_lni_label (
4076 uint32_t logical_net_id
,
4079 struct rfapi_l2_group_cfg
*rfg
;
4080 rfg
= bgp_rfapi_get_group_by_lni_label (bgp
, logical_net_id
, label
);
4084 return rfg
->rt_import_list
;
4086 return rfg
->rt_export_list
;
4092 bgp_rfapi_cfg_init (void)
4094 /* main bgpd code does not use this hook, but vnc does */
4095 route_map_event_hook (vnc_routemap_event
);
4097 install_node (&bgp_vnc_defaults_node
, NULL
);
4098 install_node (&bgp_vnc_nve_group_node
, NULL
);
4099 install_node (&bgp_vrf_policy_node
, NULL
);
4100 install_node (&bgp_vnc_l2_group_node
, NULL
);
4101 install_default (BGP_VRF_POLICY_NODE
);
4102 install_default (BGP_VNC_DEFAULTS_NODE
);
4103 install_default (BGP_VNC_NVE_GROUP_NODE
);
4104 install_default (BGP_VNC_L2_GROUP_NODE
);
4109 install_element (BGP_NODE
, &vnc_defaults_cmd
);
4110 install_element (BGP_NODE
, &vnc_nve_group_cmd
);
4111 install_element (BGP_NODE
, &vnc_no_nve_group_cmd
);
4112 install_element (BGP_NODE
, &vnc_vrf_policy_cmd
);
4113 install_element (BGP_NODE
, &vnc_no_vrf_policy_cmd
);
4114 install_element (BGP_NODE
, &vnc_l2_group_cmd
);
4115 install_element (BGP_NODE
, &vnc_no_l2_group_cmd
);
4116 install_element (BGP_NODE
, &vnc_advertise_un_method_cmd
);
4117 install_element (BGP_NODE
, &vnc_export_mode_cmd
);
4119 install_element (BGP_VNC_DEFAULTS_NODE
, &vnc_defaults_rt_import_cmd
);
4120 install_element (BGP_VNC_DEFAULTS_NODE
, &vnc_defaults_rt_export_cmd
);
4121 install_element (BGP_VNC_DEFAULTS_NODE
, &vnc_defaults_rt_both_cmd
);
4122 install_element (BGP_VNC_DEFAULTS_NODE
, &vnc_defaults_rd_cmd
);
4123 install_element (BGP_VNC_DEFAULTS_NODE
, &vnc_defaults_l2rd_cmd
);
4124 install_element (BGP_VNC_DEFAULTS_NODE
, &vnc_defaults_no_l2rd_cmd
);
4125 install_element (BGP_VNC_DEFAULTS_NODE
, &vnc_defaults_responselifetime_cmd
);
4126 install_element (BGP_VNC_DEFAULTS_NODE
, &exit_vnc_cmd
);
4128 install_element (BGP_NODE
, &vnc_redistribute_protocol_cmd
);
4129 install_element (BGP_NODE
, &vnc_no_redistribute_protocol_cmd
);
4130 install_element (BGP_NODE
, &vnc_redistribute_nvegroup_cmd
);
4131 install_element (BGP_NODE
, &vnc_redistribute_no_nvegroup_cmd
);
4132 install_element (BGP_NODE
, &vnc_redistribute_lifetime_cmd
);
4133 install_element (BGP_NODE
, &vnc_redistribute_rh_roo_localadmin_cmd
);
4134 install_element (BGP_NODE
, &vnc_redistribute_mode_cmd
);
4135 install_element (BGP_NODE
, &vnc_redistribute_bgp_exterior_cmd
);
4137 install_element (BGP_NODE
, &vnc_redist_bgpdirect_no_prefixlist_cmd
);
4138 install_element (BGP_NODE
, &vnc_redist_bgpdirect_prefixlist_cmd
);
4139 install_element (BGP_NODE
, &vnc_redist_bgpdirect_no_routemap_cmd
);
4140 install_element (BGP_NODE
, &vnc_redist_bgpdirect_routemap_cmd
);
4142 install_element (BGP_VNC_NVE_GROUP_NODE
,
4143 &vnc_nve_group_redist_bgpdirect_no_prefixlist_cmd
);
4144 install_element (BGP_VNC_NVE_GROUP_NODE
,
4145 &vnc_nve_group_redist_bgpdirect_prefixlist_cmd
);
4146 install_element (BGP_VNC_NVE_GROUP_NODE
,
4147 &vnc_nve_group_redist_bgpdirect_no_routemap_cmd
);
4148 install_element (BGP_VNC_NVE_GROUP_NODE
,
4149 &vnc_nve_group_redist_bgpdirect_routemap_cmd
);
4151 install_element (BGP_NODE
, &vnc_export_nvegroup_cmd
);
4152 install_element (BGP_NODE
, &vnc_no_export_nvegroup_cmd
);
4153 install_element (BGP_NODE
, &vnc_nve_export_prefixlist_cmd
);
4154 install_element (BGP_NODE
, &vnc_nve_export_routemap_cmd
);
4155 install_element (BGP_NODE
, &vnc_nve_export_no_prefixlist_cmd
);
4156 install_element (BGP_NODE
, &vnc_nve_export_no_routemap_cmd
);
4158 install_element (BGP_VNC_NVE_GROUP_NODE
, &vnc_nve_group_l2rd_cmd
);
4159 install_element (BGP_VNC_NVE_GROUP_NODE
, &vnc_nve_group_no_l2rd_cmd
);
4160 install_element (BGP_VNC_NVE_GROUP_NODE
, &vnc_nve_group_prefix_cmd
);
4161 install_element (BGP_VNC_NVE_GROUP_NODE
, &vnc_nve_group_rt_import_cmd
);
4162 install_element (BGP_VNC_NVE_GROUP_NODE
, &vnc_nve_group_rt_export_cmd
);
4163 install_element (BGP_VNC_NVE_GROUP_NODE
, &vnc_nve_group_rt_both_cmd
);
4164 install_element (BGP_VNC_NVE_GROUP_NODE
, &vnc_nve_group_rd_cmd
);
4165 install_element (BGP_VNC_NVE_GROUP_NODE
,
4166 &vnc_nve_group_responselifetime_cmd
);
4167 install_element (BGP_VNC_NVE_GROUP_NODE
,
4168 &vnc_nve_group_export_prefixlist_cmd
);
4169 install_element (BGP_VNC_NVE_GROUP_NODE
,
4170 &vnc_nve_group_export_routemap_cmd
);
4171 install_element (BGP_VNC_NVE_GROUP_NODE
,
4172 &vnc_nve_group_export_no_prefixlist_cmd
);
4173 install_element (BGP_VNC_NVE_GROUP_NODE
,
4174 &vnc_nve_group_export_no_routemap_cmd
);
4175 install_element (BGP_VNC_NVE_GROUP_NODE
, &exit_vnc_cmd
);
4177 install_element (BGP_VRF_POLICY_NODE
, &vnc_vrf_policy_label_cmd
);
4178 install_element (BGP_VRF_POLICY_NODE
, &vnc_vrf_policy_no_label_cmd
);
4179 //Reenable to support VRF controller use case and testing
4180 install_element (BGP_VRF_POLICY_NODE
, &vnc_vrf_policy_nexthop_cmd
);
4181 install_element (BGP_VRF_POLICY_NODE
, &vnc_vrf_policy_rt_import_cmd
);
4182 install_element (BGP_VRF_POLICY_NODE
, &vnc_vrf_policy_rt_export_cmd
);
4183 install_element (BGP_VRF_POLICY_NODE
, &vnc_vrf_policy_rt_both_cmd
);
4184 install_element (BGP_VRF_POLICY_NODE
, &vnc_vrf_policy_rd_cmd
);
4185 install_element (BGP_VRF_POLICY_NODE
, &exit_vrf_policy_cmd
);
4187 install_element (BGP_VNC_L2_GROUP_NODE
, &vnc_l2_group_lni_cmd
);
4188 install_element (BGP_VNC_L2_GROUP_NODE
, &vnc_l2_group_labels_cmd
);
4189 install_element (BGP_VNC_L2_GROUP_NODE
, &vnc_l2_group_no_labels_cmd
);
4190 install_element (BGP_VNC_L2_GROUP_NODE
, &vnc_l2_group_rt_cmd
);
4191 install_element (BGP_VNC_L2_GROUP_NODE
, &exit_vnc_cmd
);
4195 bgp_rfapi_cfg_new (struct rfapi_rfp_cfg
*cfg
)
4197 struct rfapi_cfg
*h
;
4201 (struct rfapi_cfg
*) XCALLOC (MTYPE_RFAPI_CFG
, sizeof (struct rfapi_cfg
));
4204 h
->nve_groups_sequential
= list_new ();
4205 assert (h
->nve_groups_sequential
);
4207 for (afi
= AFI_IP
; afi
< AFI_MAX
; afi
++)
4209 /* ugly, to deal with addition of delegates, part of 0.99.24.1 merge */
4210 h
->nve_groups_vn
[afi
].delegate
= route_table_get_default_delegate ();
4211 h
->nve_groups_un
[afi
].delegate
= route_table_get_default_delegate ();
4213 h
->default_response_lifetime
= BGP_VNC_DEFAULT_RESPONSE_LIFETIME_DEFAULT
;
4214 h
->rfg_export_direct_bgp_l
= list_new ();
4215 h
->rfg_export_zebra_l
= list_new ();
4216 h
->resolve_nve_roo_local_admin
=
4217 BGP_VNC_CONFIG_RESOLVE_NVE_ROO_LOCAL_ADMIN_DEFAULT
;
4219 SET_FLAG (h
->flags
, BGP_VNC_CONFIG_FLAGS_DEFAULT
);
4223 h
->rfp_cfg
.download_type
= RFAPI_RFP_DOWNLOAD_PARTIAL
;
4224 h
->rfp_cfg
.ftd_advertisement_interval
=
4225 RFAPI_RFP_CFG_DEFAULT_FTD_ADVERTISEMENT_INTERVAL
;
4226 h
->rfp_cfg
.holddown_factor
= RFAPI_RFP_CFG_DEFAULT_HOLDDOWN_FACTOR
;
4227 h
->rfp_cfg
.use_updated_response
= 0;
4228 h
->rfp_cfg
.use_removes
= 0;
4232 h
->rfp_cfg
.download_type
= cfg
->download_type
;
4233 h
->rfp_cfg
.ftd_advertisement_interval
= cfg
->ftd_advertisement_interval
;
4234 h
->rfp_cfg
.holddown_factor
= cfg
->holddown_factor
;
4235 h
->rfp_cfg
.use_updated_response
= cfg
->use_updated_response
;
4236 h
->rfp_cfg
.use_removes
= cfg
->use_removes
;
4237 if (cfg
->use_updated_response
)
4238 h
->flags
&= ~BGP_VNC_CONFIG_CALLBACK_DISABLE
;
4240 h
->flags
|= BGP_VNC_CONFIG_CALLBACK_DISABLE
;
4241 if (cfg
->use_removes
)
4242 h
->flags
&= ~BGP_VNC_CONFIG_RESPONSE_REMOVAL_DISABLE
;
4244 h
->flags
|= BGP_VNC_CONFIG_RESPONSE_REMOVAL_DISABLE
;
4250 bgp_rfapi_cfg_destroy (struct bgp
*bgp
, struct rfapi_cfg
*h
)
4255 bgp_rfapi_delete_named_nve_group (NULL
, bgp
, NULL
, RFAPI_GROUP_CFG_MAX
);
4256 bgp_rfapi_delete_named_l2_group (NULL
, bgp
, NULL
);
4257 if (h
->l2_groups
!= NULL
)
4258 list_delete (h
->l2_groups
);
4259 list_delete (h
->nve_groups_sequential
);
4260 list_delete (h
->rfg_export_direct_bgp_l
);
4261 list_delete (h
->rfg_export_zebra_l
);
4262 if (h
->default_rt_export_list
)
4263 ecommunity_free (&h
->default_rt_export_list
);
4264 if (h
->default_rt_import_list
)
4265 ecommunity_free (&h
->default_rt_import_list
);
4266 if (h
->default_rfp_cfg
)
4267 XFREE (MTYPE_RFAPI_RFP_GROUP_CFG
, h
->default_rfp_cfg
);
4268 XFREE (MTYPE_RFAPI_CFG
, h
);
4273 bgp_rfapi_cfg_write (struct vty
*vty
, struct bgp
*bgp
)
4275 struct listnode
*node
, *nnode
;
4276 struct rfapi_nve_group_cfg
*rfg
;
4277 struct rfapi_cfg
*hc
= bgp
->rfapi_cfg
;
4278 struct rfapi_rfg_name
*rfgn
;
4282 if (bgp
->rfapi
== NULL
|| hc
== NULL
)
4285 vty_out (vty
, "!%s", VTY_NEWLINE
);
4286 for (ALL_LIST_ELEMENTS (hc
->nve_groups_sequential
, node
, nnode
, rfg
))
4287 if (rfg
->type
== RFAPI_GROUP_CFG_VRF
)
4290 vty_out (vty
, " vrf-policy %s%s", rfg
->name
, VTY_NEWLINE
);
4291 if (rfg
->label
<= MPLS_LABEL_MAX
)
4293 vty_out (vty
, " label %u%s", rfg
->label
, VTY_NEWLINE
);
4296 if (CHECK_FLAG (rfg
->flags
, RFAPI_RFG_VPN_NH_SELF
))
4298 vty_out (vty
, " nexthop self%s", VTY_NEWLINE
);
4303 if (rfg
->vn_prefix
.family
)
4306 buf
[0] = buf
[BUFSIZ
- 1] = 0;
4307 inet_ntop(rfg
->vn_prefix
.family
, &rfg
->vn_prefix
.u
.prefix
, buf
, sizeof(buf
));
4308 if (!buf
[0] || buf
[BUFSIZ
- 1])
4310 //vty_out (vty, "nexthop self%s", VTY_NEWLINE);
4314 vty_out (vty
, " nexthop %s%s", buf
, VTY_NEWLINE
);
4319 if (rfg
->rd
.prefixlen
)
4322 buf
[0] = buf
[BUFSIZ
- 1] = 0;
4324 if (AF_UNIX
== rfg
->rd
.family
)
4329 value
= ((rfg
->rd
.val
[6] << 8) & 0x0ff00) |
4330 (rfg
->rd
.val
[7] & 0x0ff);
4332 vty_out (vty
, " rd auto:nh:%d%s", value
, VTY_NEWLINE
);
4338 if (!prefix_rd2str (&rfg
->rd
, buf
, BUFSIZ
) ||
4339 !buf
[0] || buf
[BUFSIZ
- 1])
4342 vty_out (vty
, "!Error: Can't convert rd%s", VTY_NEWLINE
);
4346 vty_out (vty
, " rd %s%s", buf
, VTY_NEWLINE
);
4351 if (rfg
->rt_import_list
&& rfg
->rt_export_list
&&
4352 ecommunity_cmp (rfg
->rt_import_list
, rfg
->rt_export_list
))
4354 char *b
= ecommunity_ecom2str (rfg
->rt_import_list
,
4355 ECOMMUNITY_FORMAT_ROUTE_MAP
, ECOMMUNITY_ROUTE_TARGET
);
4356 vty_out (vty
, " rt both %s%s", b
, VTY_NEWLINE
);
4357 XFREE (MTYPE_ECOMMUNITY_STR
, b
);
4361 if (rfg
->rt_import_list
)
4363 char *b
= ecommunity_ecom2str (rfg
->rt_import_list
,
4364 ECOMMUNITY_FORMAT_ROUTE_MAP
, ECOMMUNITY_ROUTE_TARGET
);
4365 vty_out (vty
, " rt import %s%s", b
, VTY_NEWLINE
);
4366 XFREE (MTYPE_ECOMMUNITY_STR
, b
);
4368 if (rfg
->rt_export_list
)
4370 char *b
= ecommunity_ecom2str (rfg
->rt_export_list
,
4371 ECOMMUNITY_FORMAT_ROUTE_MAP
, ECOMMUNITY_ROUTE_TARGET
);
4372 vty_out (vty
, " rt export %s%s", b
, VTY_NEWLINE
);
4373 XFREE (MTYPE_ECOMMUNITY_STR
, b
);
4378 * route filtering: prefix-lists and route-maps
4380 for (afi
= AFI_IP
; afi
< AFI_MAX
; ++afi
)
4383 const char *afistr
= (afi
== AFI_IP
) ? "ipv4" : "ipv6";
4385 if (rfg
->plist_export_bgp_name
[afi
])
4387 vty_out (vty
, " export bgp %s prefix-list %s%s",
4388 afistr
, rfg
->plist_export_bgp_name
[afi
],
4391 if (rfg
->plist_export_zebra_name
[afi
])
4393 vty_out (vty
, " export zebra %s prefix-list %s%s",
4394 afistr
, rfg
->plist_export_zebra_name
[afi
],
4398 * currently we only support redist plists for bgp-direct.
4399 * If we later add plist support for redistributing other
4400 * protocols, we'll need to loop over protocols here
4402 if (rfg
->plist_redist_name
[ZEBRA_ROUTE_BGP_DIRECT
][afi
])
4404 vty_out (vty
, " redistribute bgp-direct %s prefix-list %s%s",
4406 rfg
->plist_redist_name
[ZEBRA_ROUTE_BGP_DIRECT
][afi
],
4409 if (rfg
->plist_redist_name
[ZEBRA_ROUTE_BGP_DIRECT_EXT
][afi
])
4412 " redistribute bgp-direct-to-nve-groups %s prefix-list %s%s",
4414 rfg
->plist_redist_name
[ZEBRA_ROUTE_BGP_DIRECT_EXT
]
4415 [afi
], VTY_NEWLINE
);
4419 if (rfg
->routemap_export_bgp_name
)
4421 vty_out (vty
, " export bgp route-map %s%s",
4422 rfg
->routemap_export_bgp_name
, VTY_NEWLINE
);
4424 if (rfg
->routemap_export_zebra_name
)
4426 vty_out (vty
, " export zebra route-map %s%s",
4427 rfg
->routemap_export_zebra_name
, VTY_NEWLINE
);
4429 if (rfg
->routemap_redist_name
[ZEBRA_ROUTE_BGP_DIRECT
])
4431 vty_out (vty
, " redistribute bgp-direct route-map %s%s",
4432 rfg
->routemap_redist_name
[ZEBRA_ROUTE_BGP_DIRECT
],
4435 if (rfg
->routemap_redist_name
[ZEBRA_ROUTE_BGP_DIRECT_EXT
])
4438 " redistribute bgp-direct-to-nve-groups route-map %s%s",
4439 rfg
->routemap_redist_name
[ZEBRA_ROUTE_BGP_DIRECT_EXT
],
4442 vty_out (vty
, " exit-vrf-policy%s", VTY_NEWLINE
);
4443 vty_out (vty
, "!%s", VTY_NEWLINE
);
4445 if (hc
->flags
& BGP_VNC_CONFIG_ADV_UN_METHOD_ENCAP
)
4447 vty_out (vty
, " vnc advertise-un-method encap-safi%s", VTY_NEWLINE
);
4451 { /* was based on listen ports */
4452 /* for now allow both old and new */
4453 if (bgp
->rfapi
->rfp_methods
.cfg_cb
)
4454 write
+= (bgp
->rfapi
->rfp_methods
.cfg_cb
) (vty
, bgp
->rfapi
->rfp
);
4457 vty_out (vty
, "!%s", VTY_NEWLINE
);
4461 struct rfapi_l2_group_cfg
*rfg
= NULL
;
4462 struct listnode
*gnode
;
4463 for (ALL_LIST_ELEMENTS_RO (hc
->l2_groups
, gnode
, rfg
))
4465 struct listnode
*lnode
;
4468 vty_out (vty
, " vnc l2-group %s%s", rfg
->name
, VTY_NEWLINE
);
4469 if (rfg
->logical_net_id
!= 0)
4470 vty_out (vty
, " logical-network-id %u%s", rfg
->logical_net_id
,
4472 if (rfg
->labels
!= NULL
&& listhead (rfg
->labels
) != NULL
)
4474 vty_out (vty
, " labels ");
4475 for (ALL_LIST_ELEMENTS_RO (rfg
->labels
, lnode
, data
))
4477 vty_out (vty
, "%hu ", (uint16_t) ((uintptr_t) data
));
4479 vty_out (vty
, "%s", VTY_NEWLINE
);
4482 if (rfg
->rt_import_list
&& rfg
->rt_export_list
&&
4483 ecommunity_cmp (rfg
->rt_import_list
, rfg
->rt_export_list
))
4485 char *b
= ecommunity_ecom2str (rfg
->rt_import_list
,
4486 ECOMMUNITY_FORMAT_ROUTE_MAP
, ECOMMUNITY_ROUTE_TARGET
);
4487 vty_out (vty
, " rt both %s%s", b
, VTY_NEWLINE
);
4488 XFREE (MTYPE_ECOMMUNITY_STR
, b
);
4492 if (rfg
->rt_import_list
)
4494 char *b
= ecommunity_ecom2str (rfg
->rt_import_list
,
4495 ECOMMUNITY_FORMAT_ROUTE_MAP
, ECOMMUNITY_ROUTE_TARGET
);
4496 vty_out (vty
, " rt import %s%s", b
, VTY_NEWLINE
);
4497 XFREE (MTYPE_ECOMMUNITY_STR
, b
);
4499 if (rfg
->rt_export_list
)
4501 char *b
= ecommunity_ecom2str (rfg
->rt_export_list
,
4502 ECOMMUNITY_FORMAT_ROUTE_MAP
, ECOMMUNITY_ROUTE_TARGET
);
4503 vty_out (vty
, " rt export %s%s", b
, VTY_NEWLINE
);
4504 XFREE (MTYPE_ECOMMUNITY_STR
, b
);
4507 if (bgp
->rfapi
->rfp_methods
.cfg_group_cb
)
4509 (bgp
->rfapi
->rfp_methods
.cfg_group_cb
) (vty
,
4511 RFAPI_RFP_CFG_GROUP_L2
,
4514 vty_out (vty
, " exit-vnc%s", VTY_NEWLINE
);
4515 vty_out (vty
, "!%s", VTY_NEWLINE
);
4519 if (hc
->default_rd
.family
||
4520 hc
->default_response_lifetime
||
4521 hc
->default_rt_import_list
||
4522 hc
->default_rt_export_list
|| hc
->nve_groups_sequential
->count
)
4527 vty_out (vty
, " vnc defaults%s", VTY_NEWLINE
);
4529 if (hc
->default_rd
.prefixlen
)
4532 buf
[0] = buf
[BUFSIZ
- 1] = 0;
4534 if (AF_UNIX
== hc
->default_rd
.family
)
4538 value
= ((hc
->default_rd
.val
[6] << 8) & 0x0ff00) |
4539 (hc
->default_rd
.val
[7] & 0x0ff);
4541 vty_out (vty
, " rd auto:vn:%d%s", value
, VTY_NEWLINE
);
4547 if (!prefix_rd2str (&hc
->default_rd
, buf
, BUFSIZ
) ||
4548 !buf
[0] || buf
[BUFSIZ
- 1])
4551 vty_out (vty
, "!Error: Can't convert rd%s", VTY_NEWLINE
);
4555 vty_out (vty
, " rd %s%s", buf
, VTY_NEWLINE
);
4559 if (hc
->default_response_lifetime
)
4561 vty_out (vty
, " response-lifetime ");
4562 if (hc
->default_response_lifetime
!= UINT32_MAX
)
4563 vty_out (vty
, "%d", hc
->default_response_lifetime
);
4565 vty_out (vty
, "infinite");
4566 vty_out (vty
, "%s", VTY_NEWLINE
);
4568 if (hc
->default_rt_import_list
&& hc
->default_rt_export_list
&&
4569 ecommunity_cmp (hc
->default_rt_import_list
,
4570 hc
->default_rt_export_list
))
4572 char *b
= ecommunity_ecom2str (hc
->default_rt_import_list
,
4573 ECOMMUNITY_FORMAT_ROUTE_MAP
, ECOMMUNITY_ROUTE_TARGET
);
4574 vty_out (vty
, " rt both %s%s", b
, VTY_NEWLINE
);
4575 XFREE (MTYPE_ECOMMUNITY_STR
, b
);
4579 if (hc
->default_rt_import_list
)
4581 char *b
= ecommunity_ecom2str (hc
->default_rt_import_list
,
4582 ECOMMUNITY_FORMAT_ROUTE_MAP
, ECOMMUNITY_ROUTE_TARGET
);
4583 vty_out (vty
, " rt import %s%s", b
, VTY_NEWLINE
);
4584 XFREE (MTYPE_ECOMMUNITY_STR
, b
);
4586 if (hc
->default_rt_export_list
)
4588 char *b
= ecommunity_ecom2str (hc
->default_rt_export_list
,
4589 ECOMMUNITY_FORMAT_ROUTE_MAP
, ECOMMUNITY_ROUTE_TARGET
);
4590 vty_out (vty
, " rt export %s%s", b
, VTY_NEWLINE
);
4591 XFREE (MTYPE_ECOMMUNITY_STR
, b
);
4594 if (bgp
->rfapi
->rfp_methods
.cfg_group_cb
)
4596 (bgp
->rfapi
->rfp_methods
.cfg_group_cb
) (vty
,
4598 RFAPI_RFP_CFG_GROUP_DEFAULT
,
4600 bgp
->rfapi_cfg
->default_rfp_cfg
);
4601 vty_out (vty
, " exit-vnc%s", VTY_NEWLINE
);
4602 vty_out (vty
, "!%s", VTY_NEWLINE
);
4605 for (ALL_LIST_ELEMENTS (hc
->nve_groups_sequential
, node
, nnode
, rfg
))
4606 if (rfg
->type
== RFAPI_GROUP_CFG_NVE
)
4609 vty_out (vty
, " vnc nve-group %s%s", rfg
->name
, VTY_NEWLINE
);
4611 if (rfg
->vn_prefix
.family
&& rfg
->vn_node
)
4614 buf
[0] = buf
[BUFSIZ
- 1] = 0;
4616 prefix2str (&rfg
->vn_prefix
, buf
, BUFSIZ
);
4617 if (!buf
[0] || buf
[BUFSIZ
- 1])
4619 vty_out (vty
, "!Error: Can't convert prefix%s", VTY_NEWLINE
);
4623 vty_out (vty
, " prefix %s %s%s", "vn", buf
, VTY_NEWLINE
);
4627 if (rfg
->un_prefix
.family
&& rfg
->un_node
)
4630 buf
[0] = buf
[BUFSIZ
- 1] = 0;
4631 prefix2str (&rfg
->un_prefix
, buf
, BUFSIZ
);
4632 if (!buf
[0] || buf
[BUFSIZ
- 1])
4634 vty_out (vty
, "!Error: Can't convert prefix%s", VTY_NEWLINE
);
4638 vty_out (vty
, " prefix %s %s%s", "un", buf
, VTY_NEWLINE
);
4643 if (rfg
->rd
.prefixlen
)
4646 buf
[0] = buf
[BUFSIZ
- 1] = 0;
4648 if (AF_UNIX
== rfg
->rd
.family
)
4653 value
= ((rfg
->rd
.val
[6] << 8) & 0x0ff00) |
4654 (rfg
->rd
.val
[7] & 0x0ff);
4656 vty_out (vty
, " rd auto:vn:%d%s", value
, VTY_NEWLINE
);
4662 if (!prefix_rd2str (&rfg
->rd
, buf
, BUFSIZ
) ||
4663 !buf
[0] || buf
[BUFSIZ
- 1])
4666 vty_out (vty
, "!Error: Can't convert rd%s", VTY_NEWLINE
);
4670 vty_out (vty
, " rd %s%s", buf
, VTY_NEWLINE
);
4674 if (rfg
->flags
& RFAPI_RFG_RESPONSE_LIFETIME
)
4676 vty_out (vty
, " response-lifetime ");
4677 if (rfg
->response_lifetime
!= UINT32_MAX
)
4678 vty_out (vty
, "%d", rfg
->response_lifetime
);
4680 vty_out (vty
, "infinite");
4681 vty_out (vty
, "%s", VTY_NEWLINE
);
4684 if (rfg
->rt_import_list
&& rfg
->rt_export_list
&&
4685 ecommunity_cmp (rfg
->rt_import_list
, rfg
->rt_export_list
))
4687 char *b
= ecommunity_ecom2str (rfg
->rt_import_list
,
4688 ECOMMUNITY_FORMAT_ROUTE_MAP
,
4689 ECOMMUNITY_ROUTE_TARGET
);
4690 vty_out (vty
, " rt both %s%s", b
, VTY_NEWLINE
);
4691 XFREE (MTYPE_ECOMMUNITY_STR
, b
);
4695 if (rfg
->rt_import_list
)
4697 char *b
= ecommunity_ecom2str (rfg
->rt_import_list
,
4698 ECOMMUNITY_FORMAT_ROUTE_MAP
,
4699 ECOMMUNITY_ROUTE_TARGET
);
4700 vty_out (vty
, " rt import %s%s", b
, VTY_NEWLINE
);
4701 XFREE (MTYPE_ECOMMUNITY_STR
, b
);
4703 if (rfg
->rt_export_list
)
4705 char *b
= ecommunity_ecom2str (rfg
->rt_export_list
,
4706 ECOMMUNITY_FORMAT_ROUTE_MAP
, ECOMMUNITY_ROUTE_TARGET
);
4707 vty_out (vty
, " rt export %s%s", b
, VTY_NEWLINE
);
4708 XFREE (MTYPE_ECOMMUNITY_STR
, b
);
4713 * route filtering: prefix-lists and route-maps
4715 for (afi
= AFI_IP
; afi
< AFI_MAX
; ++afi
)
4718 const char *afistr
= (afi
== AFI_IP
) ? "ipv4" : "ipv6";
4720 if (rfg
->plist_export_bgp_name
[afi
])
4722 vty_out (vty
, " export bgp %s prefix-list %s%s",
4723 afistr
, rfg
->plist_export_bgp_name
[afi
],
4726 if (rfg
->plist_export_zebra_name
[afi
])
4728 vty_out (vty
, " export zebra %s prefix-list %s%s",
4729 afistr
, rfg
->plist_export_zebra_name
[afi
],
4733 * currently we only support redist plists for bgp-direct.
4734 * If we later add plist support for redistributing other
4735 * protocols, we'll need to loop over protocols here
4737 if (rfg
->plist_redist_name
[ZEBRA_ROUTE_BGP_DIRECT
][afi
])
4739 vty_out (vty
, " redistribute bgp-direct %s prefix-list %s%s",
4741 rfg
->plist_redist_name
[ZEBRA_ROUTE_BGP_DIRECT
][afi
],
4744 if (rfg
->plist_redist_name
[ZEBRA_ROUTE_BGP_DIRECT_EXT
][afi
])
4747 " redistribute bgp-direct-to-nve-groups %s prefix-list %s%s",
4749 rfg
->plist_redist_name
[ZEBRA_ROUTE_BGP_DIRECT_EXT
]
4750 [afi
], VTY_NEWLINE
);
4754 if (rfg
->routemap_export_bgp_name
)
4756 vty_out (vty
, " export bgp route-map %s%s",
4757 rfg
->routemap_export_bgp_name
, VTY_NEWLINE
);
4759 if (rfg
->routemap_export_zebra_name
)
4761 vty_out (vty
, " export zebra route-map %s%s",
4762 rfg
->routemap_export_zebra_name
, VTY_NEWLINE
);
4764 if (rfg
->routemap_redist_name
[ZEBRA_ROUTE_BGP_DIRECT
])
4766 vty_out (vty
, " redistribute bgp-direct route-map %s%s",
4767 rfg
->routemap_redist_name
[ZEBRA_ROUTE_BGP_DIRECT
],
4770 if (rfg
->routemap_redist_name
[ZEBRA_ROUTE_BGP_DIRECT_EXT
])
4773 " redistribute bgp-direct-to-nve-groups route-map %s%s",
4774 rfg
->routemap_redist_name
[ZEBRA_ROUTE_BGP_DIRECT_EXT
],
4777 if (bgp
->rfapi
->rfp_methods
.cfg_group_cb
)
4779 (bgp
->rfapi
->rfp_methods
.cfg_group_cb
) (vty
,
4781 RFAPI_RFP_CFG_GROUP_NVE
,
4782 rfg
->name
, rfg
->rfp_cfg
);
4783 vty_out (vty
, " exit-vnc%s", VTY_NEWLINE
);
4784 vty_out (vty
, "!%s", VTY_NEWLINE
);
4786 } /* have listen ports */
4789 * route export to other protocols
4791 if (VNC_EXPORT_BGP_GRP_ENABLED (hc
))
4793 vty_out (vty
, " vnc export bgp mode group-nve%s", VTY_NEWLINE
);
4795 else if (VNC_EXPORT_BGP_RH_ENABLED (hc
))
4797 vty_out (vty
, " vnc export bgp mode registering-nve%s", VTY_NEWLINE
);
4799 else if (VNC_EXPORT_BGP_CE_ENABLED (hc
))
4801 vty_out (vty
, " vnc export bgp mode ce%s", VTY_NEWLINE
);
4804 if (VNC_EXPORT_ZEBRA_GRP_ENABLED (hc
))
4806 vty_out (vty
, " vnc export zebra mode group-nve%s", VTY_NEWLINE
);
4808 else if (VNC_EXPORT_ZEBRA_RH_ENABLED (hc
))
4810 vty_out (vty
, " vnc export zebra mode registering-nve%s", VTY_NEWLINE
);
4813 if (hc
->rfg_export_direct_bgp_l
)
4815 for (ALL_LIST_ELEMENTS (hc
->rfg_export_direct_bgp_l
, node
, nnode
, rfgn
))
4818 vty_out (vty
, " vnc export bgp group-nve group %s%s",
4819 rfgn
->name
, VTY_NEWLINE
);
4823 if (hc
->rfg_export_zebra_l
)
4825 for (ALL_LIST_ELEMENTS (hc
->rfg_export_zebra_l
, node
, nnode
, rfgn
))
4828 vty_out (vty
, " vnc export zebra group-nve group %s%s",
4829 rfgn
->name
, VTY_NEWLINE
);
4834 if (hc
->rfg_redist_name
)
4836 vty_out (vty
, " vnc redistribute nve-group %s%s",
4837 hc
->rfg_redist_name
, VTY_NEWLINE
);
4839 if (hc
->redist_lifetime
)
4841 vty_out (vty
, " vnc redistribute lifetime %d%s",
4842 hc
->redist_lifetime
, VTY_NEWLINE
);
4844 if (hc
->resolve_nve_roo_local_admin
!=
4845 BGP_VNC_CONFIG_RESOLVE_NVE_ROO_LOCAL_ADMIN_DEFAULT
)
4848 vty_out (vty
, " vnc redistribute resolve-nve roo-ec-local-admin %d%s",
4849 hc
->resolve_nve_roo_local_admin
, VTY_NEWLINE
);
4852 if (hc
->redist_mode
) /* ! default */
4856 switch (hc
->redist_mode
)
4858 case VNC_REDIST_MODE_PLAIN
:
4861 case VNC_REDIST_MODE_RFG
:
4864 case VNC_REDIST_MODE_RESOLVE_NVE
:
4870 vty_out (vty
, " vnc redistribute mode %s%s", s
, VTY_NEWLINE
);
4875 * route filtering: prefix-lists and route-maps
4877 for (afi
= AFI_IP
; afi
< AFI_MAX
; ++afi
)
4880 const char *afistr
= (afi
== AFI_IP
) ? "ipv4" : "ipv6";
4882 if (hc
->plist_export_bgp_name
[afi
])
4884 vty_out (vty
, " vnc export bgp %s prefix-list %s%s",
4885 afistr
, hc
->plist_export_bgp_name
[afi
], VTY_NEWLINE
);
4887 if (hc
->plist_export_zebra_name
[afi
])
4889 vty_out (vty
, " vnc export zebra %s prefix-list %s%s",
4890 afistr
, hc
->plist_export_zebra_name
[afi
], VTY_NEWLINE
);
4892 if (hc
->plist_redist_name
[ZEBRA_ROUTE_BGP_DIRECT
][afi
])
4894 vty_out (vty
, " vnc redistribute bgp-direct %s prefix-list %s%s",
4895 afistr
, hc
->plist_redist_name
[ZEBRA_ROUTE_BGP_DIRECT
][afi
],
4900 if (hc
->routemap_export_bgp_name
)
4902 vty_out (vty
, " vnc export bgp route-map %s%s",
4903 hc
->routemap_export_bgp_name
, VTY_NEWLINE
);
4905 if (hc
->routemap_export_zebra_name
)
4907 vty_out (vty
, " vnc export zebra route-map %s%s",
4908 hc
->routemap_export_zebra_name
, VTY_NEWLINE
);
4910 if (hc
->routemap_redist_name
[ZEBRA_ROUTE_BGP_DIRECT
])
4912 vty_out (vty
, " vnc redistribute bgp-direct route-map %s%s",
4913 hc
->routemap_redist_name
[ZEBRA_ROUTE_BGP_DIRECT
], VTY_NEWLINE
);
4916 for (afi
= AFI_IP
; afi
< AFI_MAX
; ++afi
)
4918 for (type
= 0; type
< ZEBRA_ROUTE_MAX
; ++type
)
4920 if (hc
->redist
[afi
][type
])
4922 if (type
== ZEBRA_ROUTE_BGP_DIRECT_EXT
&&
4923 hc
->redist_bgp_exterior_view_name
)
4925 vty_out (vty
, " vnc redistribute %s %s view %s%s",
4926 ((afi
== AFI_IP
) ? "ipv4" : "ipv6"),
4927 zebra_route_string (type
),
4928 hc
->redist_bgp_exterior_view_name
, VTY_NEWLINE
);
4932 vty_out (vty
, " vnc redistribute %s %s%s",
4933 ((afi
== AFI_IP
) ? "ipv4" : "ipv6"),
4934 zebra_route_string (type
), VTY_NEWLINE
);
4943 bgp_rfapi_show_summary (struct bgp
*bgp
, struct vty
*vty
)
4945 struct rfapi_cfg
*hc
= bgp
->rfapi_cfg
;
4946 int afi
, type
, redist
= 0;
4951 vty_out (vty
, "%-39s %-19s %s%s", "VNC Advertise method:",
4952 (hc
->flags
& BGP_VNC_CONFIG_ADV_UN_METHOD_ENCAP
4953 ? "Encapsulation SAFI" : "Tunnel Encap attribute"),
4954 ((hc
->flags
& BGP_VNC_CONFIG_ADV_UN_METHOD_ENCAP
) ==
4955 (BGP_VNC_CONFIG_ADV_UN_METHOD_ENCAP
&
4956 BGP_VNC_CONFIG_FLAGS_DEFAULT
) ? "(default)" : ""), VTY_NEWLINE
);
4958 vty_out (vty
, "%-39s ", "Export from VNC:");
4960 * route export to other protocols
4962 if (VNC_EXPORT_BGP_GRP_ENABLED (hc
))
4965 vty_out (vty
, "ToBGP Groups={");
4966 if (hc
->rfg_export_direct_bgp_l
)
4969 struct listnode
*node
, *nnode
;
4970 struct rfapi_rfg_name
*rfgn
;
4971 for (ALL_LIST_ELEMENTS (hc
->rfg_export_direct_bgp_l
,
4977 vty_out (vty
, "%s", rfgn
->name
);
4982 else if (VNC_EXPORT_BGP_RH_ENABLED (hc
))
4985 vty_out (vty
, "ToBGP {Registering NVE}");
4986 /* note filters, route-maps not shown */
4988 else if (VNC_EXPORT_BGP_CE_ENABLED (hc
))
4991 vty_out (vty
, "ToBGP {NVE connected router:%d}",
4992 hc
->resolve_nve_roo_local_admin
);
4993 /* note filters, route-maps not shown */
4996 if (VNC_EXPORT_ZEBRA_GRP_ENABLED (hc
))
4999 vty_out (vty
, "%sToZebra Groups={", (redist
== 1 ? "" : " "));
5000 if (hc
->rfg_export_direct_bgp_l
)
5003 struct listnode
*node
, *nnode
;
5004 struct rfapi_rfg_name
*rfgn
;
5005 for (ALL_LIST_ELEMENTS (hc
->rfg_export_zebra_l
, node
, nnode
, rfgn
))
5009 vty_out (vty
, "%s", rfgn
->name
);
5014 else if (VNC_EXPORT_ZEBRA_RH_ENABLED (hc
))
5017 vty_out (vty
, "%sToZebra {Registering NVE}", (redist
== 1 ? "" : " "));
5018 /* note filters, route-maps not shown */
5020 vty_out (vty
, "%-19s %s%s", (redist
? "" : "Off"),
5021 (redist
? "" : "(default)"), VTY_NEWLINE
);
5023 /* Redistribution */
5025 vty_out (vty
, "%-39s ", "Redistribution into VNC:");
5026 for (afi
= AFI_IP
; afi
< AFI_MAX
; ++afi
)
5028 for (type
= 0; type
< ZEBRA_ROUTE_MAX
; ++type
)
5030 if (hc
->redist
[afi
][type
])
5032 vty_out (vty
, "{%s,%s} ",
5033 ((afi
== AFI_IP
) ? "ipv4" : "ipv6"),
5034 zebra_route_string (type
));
5039 vty_out (vty
, "%-19s %s%s", (redist
? "" : "Off"),
5040 (redist
? "" : "(default)"), VTY_NEWLINE
);
5042 vty_out (vty
, "%-39s %3u%-16s %s%s", "RFP Registration Hold-Down Factor:",
5043 hc
->rfp_cfg
.holddown_factor
, "%",
5044 (hc
->rfp_cfg
.holddown_factor
==
5045 RFAPI_RFP_CFG_DEFAULT_HOLDDOWN_FACTOR
? "(default)" : ""),
5047 vty_out (vty
, "%-39s %-19s %s%s", "RFP Updated responses:",
5048 (hc
->rfp_cfg
.use_updated_response
== 0 ? "Off" : "On"),
5049 (hc
->rfp_cfg
.use_updated_response
== 0 ? "(default)" : ""),
5051 vty_out (vty
, "%-39s %-19s %s%s", "RFP Removal responses:",
5052 (hc
->rfp_cfg
.use_removes
== 0 ? "Off" : "On"),
5053 (hc
->rfp_cfg
.use_removes
== 0 ? "(default)" : ""), VTY_NEWLINE
);
5054 vty_out (vty
, "%-39s %-19s %s%s", "RFP Full table download:",
5055 (hc
->rfp_cfg
.download_type
==
5056 RFAPI_RFP_DOWNLOAD_FULL
? "On" : "Off"),
5057 (hc
->rfp_cfg
.download_type
==
5058 RFAPI_RFP_DOWNLOAD_PARTIAL
? "(default)" : ""), VTY_NEWLINE
);
5059 sprintf (tmp
, "%u seconds", hc
->rfp_cfg
.ftd_advertisement_interval
);
5060 vty_out (vty
, "%-39s %-19s %s%s", " Advertisement Interval:", tmp
,
5061 (hc
->rfp_cfg
.ftd_advertisement_interval
==
5062 RFAPI_RFP_CFG_DEFAULT_FTD_ADVERTISEMENT_INTERVAL
5063 ? "(default)" : ""), VTY_NEWLINE
);
5064 vty_out (vty
, "%-39s %d seconds%s", "Default RFP response lifetime:",
5065 hc
->default_response_lifetime
, VTY_NEWLINE
);
5066 vty_out (vty
, "%s", VTY_NEWLINE
);
5071 bgp_rfapi_get_config (struct bgp
*bgp
)
5073 struct rfapi_cfg
*hc
= NULL
;
5075 bgp
= bgp_get_default ();
5077 hc
= bgp
->rfapi_cfg
;
5081 #endif /* ENABLE_BGP_VNC */