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-safi|encap-attr>",
295 "Method of advertising UN addresses\n"
296 "Via Encapsulation SAFI\n"
297 "Via Tunnel Encap attribute (in VPN SAFI)\n")
299 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
303 vty_out (vty
, "VNC not configured%s", VTY_NEWLINE
);
308 if (!strncmp (argv
[2]->arg
, "encap-safi", 7))
310 bgp
->rfapi_cfg
->flags
|= BGP_VNC_CONFIG_ADV_UN_METHOD_ENCAP
;
314 bgp
->rfapi_cfg
->flags
&= ~BGP_VNC_CONFIG_ADV_UN_METHOD_ENCAP
;
320 /*-------------------------------------------------------------------------
322 *-----------------------------------------------------------------------*/
325 DEFUN_NOSH (vnc_defaults
,
327 "vnc defaults", VNC_CONFIG_STR
"Configure default NVE group\n")
329 vty
->node
= BGP_VNC_DEFAULTS_NODE
;
337 struct cmd_token
**argv
,
338 struct ecommunity
**list
)
340 struct ecommunity
*ecom
= NULL
;
341 struct ecommunity
*ecomadd
;
343 for (; argc
; --argc
, ++argv
)
346 ecomadd
= ecommunity_str2com (argv
[0]->arg
, ECOMMUNITY_ROUTE_TARGET
, 0);
349 vty_out (vty
, "Malformed community-list value%s", VTY_NEWLINE
);
351 ecommunity_free (&ecom
);
357 ecommunity_merge (ecom
, ecomadd
);
358 ecommunity_free (&ecomadd
);
368 ecommunity_free (&*list
);
375 DEFUN (vnc_defaults_rt_import
,
376 vnc_defaults_rt_import_cmd
,
377 "rt import RTLIST...",
378 "Specify default route targets\n"
380 "Space separated route target list (A.B.C.D:MN|EF:OPQR|GHJK:MN)\n")
382 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
383 return set_ecom_list (vty
, argc
- 2, argv
+ 2,
384 &bgp
->rfapi_cfg
->default_rt_import_list
);
387 DEFUN (vnc_defaults_rt_export
,
388 vnc_defaults_rt_export_cmd
,
389 "rt export RTLIST...",
390 "Configure default route targets\n"
392 "Space separated route target list (A.B.C.D:MN|EF:OPQR|GHJK:MN)\n")
394 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
395 return set_ecom_list (vty
, argc
- 2, argv
+ 2,
396 &bgp
->rfapi_cfg
->default_rt_export_list
);
399 DEFUN (vnc_defaults_rt_both
,
400 vnc_defaults_rt_both_cmd
,
402 "Configure default route targets\n"
403 "Export+import filters\n"
404 "Space separated route target list (A.B.C.D:MN|EF:OPQR|GHJK:MN)\n")
406 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
409 rc
= set_ecom_list (vty
, argc
- 2, argv
+ 2,
410 &bgp
->rfapi_cfg
->default_rt_import_list
);
411 if (rc
!= CMD_SUCCESS
)
413 return set_ecom_list (vty
, argc
- 2, argv
+ 2,
414 &bgp
->rfapi_cfg
->default_rt_export_list
);
417 DEFUN (vnc_defaults_rd
,
419 "rd ASN:nn_or_IP-address:nn",
420 "Specify default route distinguisher\n"
421 "Route Distinguisher (<as-number>:<number> | <ip-address>:<number> | auto:vn:<number> )\n")
423 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
425 struct prefix_rd prd
;
427 if (!strncmp (argv
[1]->arg
, "auto:vn:", 8))
430 * use AF_UNIX to designate automatically-assigned RD
431 * auto:vn:nn where nn is a 2-octet quantity
434 uint32_t value32
= strtoul (argv
[1]->arg
+ 8, &end
, 10);
435 uint16_t value
= value32
& 0xffff;
437 if (!argv
[1]->arg
[8] || *end
)
439 vty_out (vty
, "%% Malformed rd%s", VTY_NEWLINE
);
442 if (value32
> 0xffff)
444 vty_out (vty
, "%% Malformed rd (must be less than %u%s",
445 0x0ffff, VTY_NEWLINE
);
449 memset (&prd
, 0, sizeof (prd
));
450 prd
.family
= AF_UNIX
;
452 prd
.val
[0] = (RD_TYPE_IP
>> 8) & 0x0ff;
453 prd
.val
[1] = RD_TYPE_IP
& 0x0ff;
454 prd
.val
[6] = (value
>> 8) & 0x0ff;
455 prd
.val
[7] = value
& 0x0ff;
461 ret
= str2prefix_rd (argv
[1]->arg
, &prd
);
464 vty_out (vty
, "%% Malformed rd%s", VTY_NEWLINE
);
469 bgp
->rfapi_cfg
->default_rd
= prd
;
473 DEFUN (vnc_defaults_l2rd
,
474 vnc_defaults_l2rd_cmd
,
475 "l2rd <(1-255)|auto-vn>",
476 "Specify default Local Nve ID value to use in RD for L2 routes\n"
477 "Fixed value 1-255\n"
478 "use the low-order octet of the NVE's VN address\n")
480 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
483 if (!strcmp (argv
[1]->arg
, "auto-vn"))
490 unsigned long value_l
= strtoul (argv
[1]->arg
, &end
, 10);
492 value
= value_l
& 0xff;
493 if (!argv
[1]->arg
[0] || *end
)
495 vty_out (vty
, "%% Malformed l2 nve ID \"%s\"%s", argv
[1]->arg
,
499 if ((value_l
< 1) || (value_l
> 0xff))
502 "%% Malformed l2 nve id (must be greater than 0 and less than %u%s",
507 bgp
->rfapi_cfg
->flags
|= BGP_VNC_CONFIG_L2RD
;
508 bgp
->rfapi_cfg
->default_l2rd
= value
;
513 DEFUN (vnc_defaults_no_l2rd
,
514 vnc_defaults_no_l2rd_cmd
,
517 "Specify default Local Nve ID value to use in RD for L2 routes\n")
519 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
521 bgp
->rfapi_cfg
->default_l2rd
= 0;
522 bgp
->rfapi_cfg
->flags
&= ~BGP_VNC_CONFIG_L2RD
;
527 DEFUN (vnc_defaults_responselifetime
,
528 vnc_defaults_responselifetime_cmd
,
529 "response-lifetime <LIFETIME|infinite>",
530 "Specify default response lifetime\n"
531 "Response lifetime in seconds\n" "Infinite response lifetime\n")
533 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
535 struct rfapi
*h
= NULL
;
536 struct listnode
*hdnode
;
537 struct rfapi_descriptor
*rfd
;
543 if (!strcmp (argv
[1]->arg
, "infinite"))
545 rspint
= RFAPI_INFINITE_LIFETIME
;
549 VTY_GET_INTEGER ("Response Lifetime", rspint
, argv
[1]->arg
);
550 if (rspint
> INT32_MAX
)
551 rspint
= INT32_MAX
; /* is really an int, not an unsigned int */
554 bgp
->rfapi_cfg
->default_response_lifetime
= rspint
;
556 for (ALL_LIST_ELEMENTS_RO (&h
->descriptors
, hdnode
, rfd
))
557 if (rfd
->rfg
&& !(rfd
->rfg
->flags
& RFAPI_RFG_RESPONSE_LIFETIME
))
558 rfd
->response_lifetime
= rfd
->rfg
->response_lifetime
= rspint
;
563 struct rfapi_nve_group_cfg
*
564 bgp_rfapi_cfg_match_byname (struct bgp
*bgp
, const char *name
,
565 rfapi_group_cfg_type_t type
) /* _MAX = any */
567 struct rfapi_nve_group_cfg
*rfg
;
568 struct listnode
*node
, *nnode
;
570 for (ALL_LIST_ELEMENTS
571 (bgp
->rfapi_cfg
->nve_groups_sequential
, node
, nnode
, rfg
))
573 if ((type
== RFAPI_GROUP_CFG_MAX
|| type
== rfg
->type
) &&
574 !strcmp (rfg
->name
, name
))
580 static struct rfapi_nve_group_cfg
*
581 rfapi_group_new (struct bgp
*bgp
,
582 rfapi_group_cfg_type_t type
,
585 struct rfapi_nve_group_cfg
*rfg
;
587 rfg
= XCALLOC (MTYPE_RFAPI_GROUP_CFG
, sizeof (struct rfapi_nve_group_cfg
));
591 rfg
->name
= strdup (name
);
592 /* add to tail of list */
593 listnode_add (bgp
->rfapi_cfg
->nve_groups_sequential
, rfg
);
595 rfg
->label
= MPLS_LABEL_ILLEGAL
;
596 QOBJ_REG (rfg
, rfapi_nve_group_cfg
);
601 static struct rfapi_l2_group_cfg
*
602 rfapi_l2_group_lookup_byname (struct bgp
*bgp
, const char *name
)
604 struct rfapi_l2_group_cfg
*rfg
;
605 struct listnode
*node
, *nnode
;
607 if (bgp
->rfapi_cfg
->l2_groups
== NULL
) /* not the best place for this */
608 bgp
->rfapi_cfg
->l2_groups
= list_new ();
610 for (ALL_LIST_ELEMENTS (bgp
->rfapi_cfg
->l2_groups
, node
, nnode
, rfg
))
612 if (!strcmp (rfg
->name
, name
))
618 static struct rfapi_l2_group_cfg
*
619 rfapi_l2_group_new ()
621 struct rfapi_l2_group_cfg
*rfg
;
623 rfg
= XCALLOC (MTYPE_RFAPI_L2_CFG
, sizeof (struct rfapi_l2_group_cfg
));
624 QOBJ_REG (rfg
, rfapi_l2_group_cfg
);
630 rfapi_l2_group_del (struct rfapi_l2_group_cfg
*rfg
)
633 XFREE (MTYPE_RFAPI_L2_CFG
, rfg
);
637 rfapi_str2route_type (
646 if (!strcmp (l3str
, "ipv4"))
652 if (!strcmp (l3str
, "ipv6"))
658 if (!strcmp (pstr
, "connected"))
659 *type
= ZEBRA_ROUTE_CONNECT
;
660 if (!strcmp (pstr
, "kernel"))
661 *type
= ZEBRA_ROUTE_KERNEL
;
662 if (!strcmp (pstr
, "static"))
663 *type
= ZEBRA_ROUTE_STATIC
;
664 if (!strcmp (pstr
, "bgp"))
665 *type
= ZEBRA_ROUTE_BGP
;
666 if (!strcmp (pstr
, "bgp-direct"))
667 *type
= ZEBRA_ROUTE_BGP_DIRECT
;
668 if (!strcmp (pstr
, "bgp-direct-to-nve-groups"))
669 *type
= ZEBRA_ROUTE_BGP_DIRECT_EXT
;
671 if (!strcmp (pstr
, "rip"))
674 *type
= ZEBRA_ROUTE_RIP
;
676 *type
= ZEBRA_ROUTE_RIPNG
;
679 if (!strcmp (pstr
, "ripng"))
683 *type
= ZEBRA_ROUTE_RIPNG
;
686 if (!strcmp (pstr
, "ospf"))
689 *type
= ZEBRA_ROUTE_OSPF
;
691 *type
= ZEBRA_ROUTE_OSPF6
;
694 if (!strcmp (pstr
, "ospf6"))
698 *type
= ZEBRA_ROUTE_OSPF6
;
704 /*-------------------------------------------------------------------------
706 *-----------------------------------------------------------------------*/
708 #define VNC_REDIST_ENABLE(bgp, afi, type) do { \
710 case ZEBRA_ROUTE_BGP_DIRECT: \
711 vnc_import_bgp_redist_enable((bgp), (afi)); \
713 case ZEBRA_ROUTE_BGP_DIRECT_EXT: \
714 vnc_import_bgp_exterior_redist_enable((bgp), (afi));\
717 vnc_redistribute_set((bgp), (afi), (type)); \
722 #define VNC_REDIST_DISABLE(bgp, afi, type) do { \
724 case ZEBRA_ROUTE_BGP_DIRECT: \
725 vnc_import_bgp_redist_disable((bgp), (afi)); \
727 case ZEBRA_ROUTE_BGP_DIRECT_EXT: \
728 vnc_import_bgp_exterior_redist_disable((bgp), (afi));\
731 vnc_redistribute_unset((bgp), (afi), (type)); \
736 static uint8_t redist_was_enabled
[AFI_MAX
][ZEBRA_ROUTE_MAX
];
739 vnc_redistribute_prechange (struct bgp
*bgp
)
744 vnc_zlog_debug_verbose ("%s: entry", __func__
);
745 memset (redist_was_enabled
, 0, sizeof (redist_was_enabled
));
748 * Look to see if we have any redistribution enabled. If so, flush
749 * the corresponding routes and turn off redistribution temporarily.
750 * We need to do it because the RD's used for the redistributed
751 * routes depend on the nve group.
753 for (afi
= AFI_IP
; afi
< AFI_MAX
; ++afi
)
755 for (type
= 0; type
< ZEBRA_ROUTE_MAX
; ++type
)
757 if (bgp
->rfapi_cfg
->redist
[afi
][type
])
759 redist_was_enabled
[afi
][type
] = 1;
760 VNC_REDIST_DISABLE (bgp
, afi
, type
);
764 vnc_zlog_debug_verbose ("%s: return", __func__
);
768 vnc_redistribute_postchange (struct bgp
*bgp
)
773 vnc_zlog_debug_verbose ("%s: entry", __func__
);
775 * If we turned off redistribution above, turn it back on. Doing so
776 * will tell zebra to resend the routes to us
778 for (afi
= AFI_IP
; afi
< AFI_MAX
; ++afi
)
780 for (type
= 0; type
< ZEBRA_ROUTE_MAX
; ++type
)
782 if (redist_was_enabled
[afi
][type
])
784 VNC_REDIST_ENABLE (bgp
, afi
, type
);
788 vnc_zlog_debug_verbose ("%s: return", __func__
);
791 DEFUN (vnc_redistribute_rh_roo_localadmin
,
792 vnc_redistribute_rh_roo_localadmin_cmd
,
793 "vnc redistribute resolve-nve roo-ec-local-admin (0-65535)",
795 "Redistribute routes into VNC\n"
797 "Route Origin Extended Community Local Admin Field\n" "Field value\n")
799 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
805 vty_out (vty
, "RFAPI not configured%s", VTY_NEWLINE
);
809 localadmin
= strtoul (argv
[4]->arg
, &endptr
, 0);
810 if (!argv
[4]->arg
[0] || *endptr
)
812 vty_out (vty
, "%% Malformed value%s", VTY_NEWLINE
);
816 if (localadmin
> 0xffff)
818 vty_out (vty
, "%% Value out of range (0-%d)%s", 0xffff, VTY_NEWLINE
);
822 if (bgp
->rfapi_cfg
->resolve_nve_roo_local_admin
== localadmin
)
825 if ((bgp
->rfapi_cfg
->flags
& BGP_VNC_CONFIG_EXPORT_BGP_MODE_BITS
) ==
826 BGP_VNC_CONFIG_EXPORT_BGP_MODE_CE
)
829 vnc_export_bgp_prechange (bgp
);
831 vnc_redistribute_prechange (bgp
);
833 bgp
->rfapi_cfg
->resolve_nve_roo_local_admin
= localadmin
;
835 if ((bgp
->rfapi_cfg
->flags
& BGP_VNC_CONFIG_EXPORT_BGP_MODE_BITS
) ==
836 BGP_VNC_CONFIG_EXPORT_BGP_MODE_CE
)
839 vnc_export_bgp_postchange (bgp
);
841 vnc_redistribute_postchange (bgp
);
847 DEFUN (vnc_redistribute_mode
,
848 vnc_redistribute_mode_cmd
,
849 "vnc redistribute mode <nve-group|plain|resolve-nve>",
851 "Redistribute routes into VNC\n"
852 "Redistribution mode\n"
853 "Based on redistribute nve-group\n"
854 "Unmodified\n" "Resolve each nexthop to connected NVEs\n")
856 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
857 vnc_redist_mode_t newmode
;
861 vty_out (vty
, "RFAPI not configured%s", VTY_NEWLINE
);
866 switch (argv
[3]->arg
[0])
869 newmode
= VNC_REDIST_MODE_RFG
;
873 newmode
= VNC_REDIST_MODE_PLAIN
;
877 newmode
= VNC_REDIST_MODE_RESOLVE_NVE
;
881 vty_out (vty
, "unknown redistribute mode%s", VTY_NEWLINE
);
885 if (newmode
!= bgp
->rfapi_cfg
->redist_mode
)
887 vnc_redistribute_prechange (bgp
);
888 bgp
->rfapi_cfg
->redist_mode
= newmode
;
889 vnc_redistribute_postchange (bgp
);
895 DEFUN (vnc_redistribute_protocol
,
896 vnc_redistribute_protocol_cmd
,
897 "vnc redistribute <ipv4|ipv6> <bgp|bgp-direct|bgp-direct-to-nve-groups|connected|kernel|ospf|rip|static>",
899 "Redistribute routes into VNC\n"
903 "From BGP without Zebra\n"
904 "From BGP without Zebra, only to configured NVE groups\n"
905 "Connected interfaces\n"
906 "From kernel routes\n"
907 "From Open Shortest Path First (OSPF)\n"
908 "From Routing Information Protocol (RIP)\n" "From Static routes\n")
910 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
911 int type
= ZEBRA_ROUTE_MAX
; /* init to bogus value */
916 vty_out (vty
, "RFAPI not configured%s", VTY_NEWLINE
);
920 if (rfapi_str2route_type (argv
[2]->arg
, argv
[3]->arg
, &afi
, &type
))
922 vty_out (vty
, "%% Invalid route type%s", VTY_NEWLINE
);
926 if (type
== ZEBRA_ROUTE_BGP_DIRECT_EXT
)
928 if (bgp
->rfapi_cfg
->redist_bgp_exterior_view_name
)
930 VNC_REDIST_DISABLE (bgp
, afi
, type
); /* disabled view implicitly */
931 free (bgp
->rfapi_cfg
->redist_bgp_exterior_view_name
);
932 bgp
->rfapi_cfg
->redist_bgp_exterior_view_name
= NULL
;
934 bgp
->rfapi_cfg
->redist_bgp_exterior_view
= bgp
;
937 VNC_REDIST_ENABLE (bgp
, afi
, type
);
942 DEFUN (vnc_no_redistribute_protocol
,
943 vnc_no_redistribute_protocol_cmd
,
944 "no vnc redistribute <ipv4|ipv6> <bgp|bgp-direct|bgp-direct-to-nve-groups|connected|kernel|ospf|rip|static>",
947 "Redistribute from other protocol\n"
951 "From BGP without Zebra\n"
952 "From BGP without Zebra, only to configured NVE groups\n"
953 "Connected interfaces\n"
954 "From kernel routes\n"
955 "From Open Shortest Path First (OSPF)\n"
956 "From Routing Information Protocol (RIP)\n" "From Static routes\n")
958 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
964 vty_out (vty
, "RFAPI not configured%s", VTY_NEWLINE
);
968 if (rfapi_str2route_type (argv
[3]->arg
, argv
[4]->arg
, &afi
, &type
))
970 vty_out (vty
, "%% Invalid route type%s", VTY_NEWLINE
);
974 VNC_REDIST_DISABLE (bgp
, afi
, type
);
976 if (type
== ZEBRA_ROUTE_BGP_DIRECT_EXT
)
978 if (bgp
->rfapi_cfg
->redist_bgp_exterior_view_name
)
980 free (bgp
->rfapi_cfg
->redist_bgp_exterior_view_name
);
981 bgp
->rfapi_cfg
->redist_bgp_exterior_view_name
= NULL
;
983 bgp
->rfapi_cfg
->redist_bgp_exterior_view
= NULL
;
989 DEFUN (vnc_redistribute_bgp_exterior
,
990 vnc_redistribute_bgp_exterior_cmd
,
991 "vnc redistribute <ipv4|ipv6> bgp-direct-to-nve-groups view NAME",
993 "Redistribute routes into VNC\n"
996 "From BGP without Zebra, only to configured NVE groups\n"
997 "From BGP view\n" "BGP view name\n")
999 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1003 if (!bgp
->rfapi_cfg
)
1005 vty_out (vty
, "RFAPI not configured%s", VTY_NEWLINE
);
1009 if (rfapi_str2route_type (argv
[2]->arg
, "bgp-direct-to-nve-groups", &afi
, &type
))
1011 vty_out (vty
, "%% Invalid route type%s", VTY_NEWLINE
);
1015 if (bgp
->rfapi_cfg
->redist_bgp_exterior_view_name
)
1016 free (bgp
->rfapi_cfg
->redist_bgp_exterior_view_name
);
1017 bgp
->rfapi_cfg
->redist_bgp_exterior_view_name
= strdup (argv
[5]->arg
);
1018 /* could be NULL if name is not defined yet */
1019 bgp
->rfapi_cfg
->redist_bgp_exterior_view
= bgp_lookup_by_name (argv
[5]->arg
);
1021 VNC_REDIST_ENABLE (bgp
, afi
, type
);
1026 DEFUN (vnc_redistribute_nvegroup
,
1027 vnc_redistribute_nvegroup_cmd
,
1028 "vnc redistribute nve-group NAME",
1030 "Assign a NVE group to routes redistributed from another routing protocol\n"
1031 "NVE group\n" "Group name\n")
1033 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1035 if (!bgp
->rfapi_cfg
)
1037 vty_out (vty
, "rfapi not configured%s", VTY_NEWLINE
);
1041 vnc_redistribute_prechange (bgp
);
1044 * OK if nve group doesn't exist yet; we'll set the pointer
1045 * when the group is defined later
1047 bgp
->rfapi_cfg
->rfg_redist
= bgp_rfapi_cfg_match_byname (bgp
, argv
[3]->arg
,
1048 RFAPI_GROUP_CFG_NVE
);
1049 if (bgp
->rfapi_cfg
->rfg_redist_name
)
1050 free (bgp
->rfapi_cfg
->rfg_redist_name
);
1051 bgp
->rfapi_cfg
->rfg_redist_name
= strdup (argv
[3]->arg
);
1053 vnc_redistribute_postchange (bgp
);
1058 DEFUN (vnc_redistribute_no_nvegroup
,
1059 vnc_redistribute_no_nvegroup_cmd
,
1060 "no vnc redistribute nve-group",
1063 "Redistribute from other protocol\n"
1064 "Assign a NVE group to routes redistributed from another routing protocol\n")
1066 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1068 if (!bgp
->rfapi_cfg
)
1070 vty_out (vty
, "rfapi not configured%s", VTY_NEWLINE
);
1074 vnc_redistribute_prechange (bgp
);
1076 bgp
->rfapi_cfg
->rfg_redist
= NULL
;
1077 if (bgp
->rfapi_cfg
->rfg_redist_name
)
1078 free (bgp
->rfapi_cfg
->rfg_redist_name
);
1079 bgp
->rfapi_cfg
->rfg_redist_name
= NULL
;
1081 vnc_redistribute_postchange (bgp
);
1087 DEFUN (vnc_redistribute_lifetime
,
1088 vnc_redistribute_lifetime_cmd
,
1089 "vnc redistribute lifetime <LIFETIME|infinite>",
1092 "Assign a lifetime to routes redistributed from another routing protocol\n"
1093 "lifetime value (32 bit)\n"
1094 "Allow lifetime to never expire\n")
1096 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1098 if (!bgp
->rfapi_cfg
)
1100 vty_out (vty
, "rfapi not configured%s", VTY_NEWLINE
);
1104 vnc_redistribute_prechange (bgp
);
1106 if (!strcmp (argv
[3]->arg
, "infinite"))
1108 bgp
->rfapi_cfg
->redist_lifetime
= RFAPI_INFINITE_LIFETIME
;
1112 VTY_GET_INTEGER ("Response Lifetime", bgp
->rfapi_cfg
->redist_lifetime
,
1116 vnc_redistribute_postchange (bgp
);
1121 /*-- redist policy, non-nvegroup start --*/
1123 DEFUN (vnc_redist_bgpdirect_no_prefixlist
,
1124 vnc_redist_bgpdirect_no_prefixlist_cmd
,
1125 "no vnc redistribute <bgp-direct|bgp-direct-to-nve-groups> <ipv4|ipv6> prefix-list",
1128 "Redistribute from other protocol\n"
1129 "Redistribute from BGP directly\n"
1130 "Redistribute from BGP without Zebra, only to configured NVE groups\n"
1132 "IPv6 routes\n" "Prefix-list for filtering redistributed routes\n")
1134 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1136 struct rfapi_cfg
*hc
;
1137 uint8_t route_type
= 0;
1139 if (!(hc
= bgp
->rfapi_cfg
))
1141 vty_out (vty
, "rfapi not configured%s", VTY_NEWLINE
);
1145 if (!strcmp (argv
[3]->arg
, "bgp-direct"))
1147 route_type
= ZEBRA_ROUTE_BGP_DIRECT
;
1151 route_type
= ZEBRA_ROUTE_BGP_DIRECT_EXT
;
1154 if (!strcmp (argv
[4]->arg
, "ipv4"))
1163 vnc_redistribute_prechange (bgp
);
1165 if (hc
->plist_redist_name
[route_type
][afi
])
1166 free (hc
->plist_redist_name
[route_type
][afi
]);
1167 hc
->plist_redist_name
[route_type
][afi
] = NULL
;
1168 hc
->plist_redist
[route_type
][afi
] = NULL
;
1170 vnc_redistribute_postchange (bgp
);
1175 DEFUN (vnc_redist_bgpdirect_prefixlist
,
1176 vnc_redist_bgpdirect_prefixlist_cmd
,
1177 "vnc redistribute <bgp-direct|bgp-direct-to-nve-groups> <ipv4|ipv6> prefix-list NAME",
1179 "Redistribute from other protocol\n"
1180 "Redistribute from BGP directly\n"
1181 "Redistribute from BGP without Zebra, only to configured NVE groups\n"
1184 "Prefix-list for filtering redistributed routes\n"
1185 "prefix list name\n")
1187 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1188 struct rfapi_cfg
*hc
;
1190 uint8_t route_type
= 0;
1192 if (!(hc
= bgp
->rfapi_cfg
))
1194 vty_out (vty
, "rfapi not configured%s", VTY_NEWLINE
);
1198 if (!strcmp (argv
[2]->arg
, "bgp-direct"))
1200 route_type
= ZEBRA_ROUTE_BGP_DIRECT
;
1204 route_type
= ZEBRA_ROUTE_BGP_DIRECT_EXT
;
1207 if (!strcmp (argv
[3]->arg
, "ipv4"))
1216 vnc_redistribute_prechange (bgp
);
1218 if (hc
->plist_redist_name
[route_type
][afi
])
1219 free (hc
->plist_redist_name
[route_type
][afi
]);
1220 hc
->plist_redist_name
[route_type
][afi
] = strdup (argv
[5]->arg
);
1221 hc
->plist_redist
[route_type
][afi
] = prefix_list_lookup (afi
, argv
[5]->arg
);
1223 vnc_redistribute_postchange (bgp
);
1228 DEFUN (vnc_redist_bgpdirect_no_routemap
,
1229 vnc_redist_bgpdirect_no_routemap_cmd
,
1230 "no vnc redistribute <bgp-direct|bgp-direct-to-nve-groups> route-map",
1233 "Redistribute from other protocols\n"
1234 "Redistribute from BGP directly\n"
1235 "Redistribute from BGP without Zebra, only to configured NVE groups\n"
1236 "Route-map for filtering redistributed routes\n")
1238 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1239 struct rfapi_cfg
*hc
;
1240 uint8_t route_type
= 0;
1242 if (!(hc
= bgp
->rfapi_cfg
))
1244 vty_out (vty
, "rfapi not configured%s", VTY_NEWLINE
);
1248 if (!strcmp (argv
[3]->arg
, "bgp-direct"))
1250 route_type
= ZEBRA_ROUTE_BGP_DIRECT
;
1254 route_type
= ZEBRA_ROUTE_BGP_DIRECT_EXT
;
1257 vnc_redistribute_prechange (bgp
);
1259 if (hc
->routemap_redist_name
[route_type
])
1260 free (hc
->routemap_redist_name
[route_type
]);
1261 hc
->routemap_redist_name
[route_type
] = NULL
;
1262 hc
->routemap_redist
[route_type
] = NULL
;
1264 vnc_redistribute_postchange (bgp
);
1269 DEFUN (vnc_redist_bgpdirect_routemap
,
1270 vnc_redist_bgpdirect_routemap_cmd
,
1271 "vnc redistribute <bgp-direct|bgp-direct-to-nve-groups> route-map NAME",
1273 "Redistribute from other protocols\n"
1274 "Redistribute from BGP directly\n"
1275 "Redistribute from BGP without Zebra, only to configured NVE groups\n"
1276 "Route-map for filtering exported routes\n" "route map name\n")
1278 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1279 struct rfapi_cfg
*hc
;
1280 uint8_t route_type
= 0;
1282 if (!(hc
= bgp
->rfapi_cfg
))
1284 vty_out (vty
, "rfapi not configured%s", VTY_NEWLINE
);
1288 if (!strcmp (argv
[2]->arg
, "bgp-direct"))
1290 route_type
= ZEBRA_ROUTE_BGP_DIRECT
;
1294 route_type
= ZEBRA_ROUTE_BGP_DIRECT_EXT
;
1297 vnc_redistribute_prechange (bgp
);
1299 if (hc
->routemap_redist_name
[route_type
])
1300 free (hc
->routemap_redist_name
[route_type
]);
1301 hc
->routemap_redist_name
[route_type
] = strdup (argv
[4]->arg
);
1302 hc
->routemap_redist
[route_type
] = route_map_lookup_by_name (argv
[4]->arg
);
1304 vnc_redistribute_postchange (bgp
);
1309 /*-- redist policy, non-nvegroup end --*/
1311 /*-- redist policy, nvegroup start --*/
1313 DEFUN (vnc_nve_group_redist_bgpdirect_no_prefixlist
,
1314 vnc_nve_group_redist_bgpdirect_no_prefixlist_cmd
,
1315 "no redistribute bgp-direct <ipv4|ipv6> prefix-list",
1317 "Redistribute from other protocol\n"
1318 "Redistribute from BGP directly\n"
1319 "Disable redistribute filter\n"
1321 "IPv6 routes\n" "Prefix-list for filtering redistributed routes\n")
1323 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1324 VTY_DECLVAR_CONTEXT_SUB(rfapi_nve_group_cfg
, rfg
)
1327 if (!bgp
->rfapi_cfg
)
1329 vty_out (vty
, "rfapi not configured%s", VTY_NEWLINE
);
1333 /* make sure it's still in list */
1334 if (!listnode_lookup (bgp
->rfapi_cfg
->nve_groups_sequential
, rfg
))
1336 /* Not in list anymore */
1337 vty_out (vty
, "Current NVE group no longer exists%s", VTY_NEWLINE
);
1341 if (!strcmp (argv
[3]->arg
, "ipv4"))
1350 vnc_redistribute_prechange (bgp
);
1352 if (rfg
->plist_redist_name
[ZEBRA_ROUTE_BGP_DIRECT
][afi
])
1353 free (rfg
->plist_redist_name
[ZEBRA_ROUTE_BGP_DIRECT
][afi
]);
1354 rfg
->plist_redist_name
[ZEBRA_ROUTE_BGP_DIRECT
][afi
] = NULL
;
1355 rfg
->plist_redist
[ZEBRA_ROUTE_BGP_DIRECT
][afi
] = NULL
;
1357 vnc_redistribute_postchange (bgp
);
1362 DEFUN (vnc_nve_group_redist_bgpdirect_prefixlist
,
1363 vnc_nve_group_redist_bgpdirect_prefixlist_cmd
,
1364 "redistribute bgp-direct <ipv4|ipv6> prefix-list NAME",
1365 "Redistribute from other protocol\n"
1366 "Redistribute from BGP directly\n"
1369 "Prefix-list for filtering redistributed routes\n"
1370 "prefix list name\n")
1372 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1373 VTY_DECLVAR_CONTEXT_SUB(rfapi_nve_group_cfg
, rfg
);
1376 if (!bgp
->rfapi_cfg
)
1378 vty_out (vty
, "rfapi not configured%s", VTY_NEWLINE
);
1382 /* make sure it's still in list */
1383 if (!listnode_lookup (bgp
->rfapi_cfg
->nve_groups_sequential
, rfg
))
1385 /* Not in list anymore */
1386 vty_out (vty
, "Current NVE group no longer exists%s", VTY_NEWLINE
);
1390 if (!strcmp (argv
[2]->arg
, "ipv4"))
1399 vnc_redistribute_prechange (bgp
);
1401 if (rfg
->plist_redist_name
[ZEBRA_ROUTE_BGP_DIRECT
][afi
])
1402 free (rfg
->plist_redist_name
[ZEBRA_ROUTE_BGP_DIRECT
][afi
]);
1403 rfg
->plist_redist_name
[ZEBRA_ROUTE_BGP_DIRECT
][afi
] = strdup (argv
[4]->arg
);
1404 rfg
->plist_redist
[ZEBRA_ROUTE_BGP_DIRECT
][afi
] =
1405 prefix_list_lookup (afi
, argv
[4]->arg
);
1407 vnc_redistribute_postchange (bgp
);
1412 DEFUN (vnc_nve_group_redist_bgpdirect_no_routemap
,
1413 vnc_nve_group_redist_bgpdirect_no_routemap_cmd
,
1414 "no redistribute bgp-direct route-map",
1416 "Redistribute from other protocols\n"
1417 "Redistribute from BGP directly\n"
1418 "Disable redistribute filter\n"
1419 "Route-map for filtering redistributed routes\n")
1421 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1422 VTY_DECLVAR_CONTEXT_SUB(rfapi_nve_group_cfg
, rfg
);
1424 if (!bgp
->rfapi_cfg
)
1426 vty_out (vty
, "rfapi not configured%s", VTY_NEWLINE
);
1430 /* make sure it's still in list */
1431 if (!listnode_lookup (bgp
->rfapi_cfg
->nve_groups_sequential
, rfg
))
1433 /* Not in list anymore */
1434 vty_out (vty
, "Current NVE group no longer exists%s", VTY_NEWLINE
);
1438 vnc_redistribute_prechange (bgp
);
1440 if (rfg
->routemap_redist_name
[ZEBRA_ROUTE_BGP_DIRECT
])
1441 free (rfg
->routemap_redist_name
[ZEBRA_ROUTE_BGP_DIRECT
]);
1442 rfg
->routemap_redist_name
[ZEBRA_ROUTE_BGP_DIRECT
] = NULL
;
1443 rfg
->routemap_redist
[ZEBRA_ROUTE_BGP_DIRECT
] = NULL
;
1445 vnc_redistribute_postchange (bgp
);
1450 DEFUN (vnc_nve_group_redist_bgpdirect_routemap
,
1451 vnc_nve_group_redist_bgpdirect_routemap_cmd
,
1452 "redistribute bgp-direct route-map NAME",
1453 "Redistribute from other protocols\n"
1454 "Redistribute from BGP directly\n"
1455 "Route-map for filtering exported routes\n" "route map name\n")
1457 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1458 VTY_DECLVAR_CONTEXT_SUB(rfapi_nve_group_cfg
, rfg
);
1460 if (!bgp
->rfapi_cfg
)
1462 vty_out (vty
, "rfapi not configured%s", VTY_NEWLINE
);
1466 /* make sure it's still in list */
1467 if (!listnode_lookup (bgp
->rfapi_cfg
->nve_groups_sequential
, rfg
))
1469 /* Not in list anymore */
1470 vty_out (vty
, "Current NVE group no longer exists%s", VTY_NEWLINE
);
1474 vnc_redistribute_prechange (bgp
);
1476 if (rfg
->routemap_redist_name
[ZEBRA_ROUTE_BGP_DIRECT
])
1477 free (rfg
->routemap_redist_name
[ZEBRA_ROUTE_BGP_DIRECT
]);
1478 rfg
->routemap_redist_name
[ZEBRA_ROUTE_BGP_DIRECT
] = strdup (argv
[3]->arg
);
1479 rfg
->routemap_redist
[ZEBRA_ROUTE_BGP_DIRECT
] =
1480 route_map_lookup_by_name (argv
[3]->arg
);
1482 vnc_redistribute_postchange (bgp
);
1487 /*-- redist policy, nvegroup end --*/
1489 /*-------------------------------------------------------------------------
1491 *-----------------------------------------------------------------------*/
1493 DEFUN (vnc_export_mode
,
1494 vnc_export_mode_cmd
,
1495 "vnc export <bgp|zebra> mode <group-nve|ce|none|registering-nve>",
1497 "Export to other protocols\n"
1499 "Export to Zebra (experimental)\n"
1500 "Select export mode\n"
1501 "Export routes with nve-group next-hops\n"
1502 "Export routes with NVE connected router next-hops\n"
1503 "Disable export\n" "Export routes with registering NVE as next-hop\n")
1505 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1506 uint32_t oldmode
= 0;
1507 uint32_t newmode
= 0;
1509 if (!bgp
->rfapi_cfg
)
1511 vty_out (vty
, "VNC not configured%s", VTY_NEWLINE
);
1515 if (argv
[2]->arg
[0] == 'b')
1517 oldmode
= bgp
->rfapi_cfg
->flags
& BGP_VNC_CONFIG_EXPORT_BGP_MODE_BITS
;
1518 switch (argv
[4]->arg
[0])
1521 newmode
= BGP_VNC_CONFIG_EXPORT_BGP_MODE_GRP
;
1524 newmode
= BGP_VNC_CONFIG_EXPORT_BGP_MODE_CE
;
1530 newmode
= BGP_VNC_CONFIG_EXPORT_BGP_MODE_RH
;
1533 vty_out (vty
, "Invalid mode specified%s", VTY_NEWLINE
);
1537 if (newmode
== oldmode
)
1539 vty_out (vty
, "Mode unchanged%s", VTY_NEWLINE
);
1543 vnc_export_bgp_prechange (bgp
);
1545 bgp
->rfapi_cfg
->flags
&= ~BGP_VNC_CONFIG_EXPORT_BGP_MODE_BITS
;
1546 bgp
->rfapi_cfg
->flags
|= newmode
;
1548 vnc_export_bgp_postchange (bgp
);
1555 * export to zebra with RH mode is not yet implemented
1557 vty_out (vty
, "Changing modes for zebra export not implemented yet%s",
1561 oldmode
= bgp
->rfapi_cfg
->flags
& BGP_VNC_CONFIG_EXPORT_ZEBRA_MODE_BITS
;
1562 bgp
->rfapi_cfg
->flags
&= ~BGP_VNC_CONFIG_EXPORT_ZEBRA_MODE_BITS
;
1563 switch (argv
[4]->arg
[0])
1566 if (oldmode
== BGP_VNC_CONFIG_EXPORT_ZEBRA_MODE_RH
)
1570 bgp
->rfapi_cfg
->flags
|= BGP_VNC_CONFIG_EXPORT_ZEBRA_MODE_GRP
;
1571 if (oldmode
!= BGP_VNC_CONFIG_EXPORT_ZEBRA_MODE_GRP
)
1577 if (oldmode
== BGP_VNC_CONFIG_EXPORT_ZEBRA_MODE_RH
)
1581 if (oldmode
== BGP_VNC_CONFIG_EXPORT_ZEBRA_MODE_GRP
)
1587 if (oldmode
== BGP_VNC_CONFIG_EXPORT_ZEBRA_MODE_GRP
)
1591 bgp
->rfapi_cfg
->flags
|= BGP_VNC_CONFIG_EXPORT_ZEBRA_MODE_RH
;
1592 if (oldmode
!= BGP_VNC_CONFIG_EXPORT_ZEBRA_MODE_RH
)
1598 vty_out (vty
, "Invalid mode%s", VTY_NEWLINE
);
1606 static struct rfapi_rfg_name
*
1609 return XCALLOC (MTYPE_RFAPI_RFG_NAME
, sizeof (struct rfapi_rfg_name
));
1613 rfgn_free (struct rfapi_rfg_name
*rfgn
)
1615 XFREE (MTYPE_RFAPI_RFG_NAME
, rfgn
);
1618 DEFUN (vnc_export_nvegroup
,
1619 vnc_export_nvegroup_cmd
,
1620 "vnc export <bgp|zebra> group-nve group NAME",
1622 "Export to other protocols\n"
1624 "Export to Zebra (experimental)\n"
1625 "NVE group, used in 'group-nve' export mode\n"
1626 "NVE group\n" "Group name\n")
1628 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1629 struct rfapi_nve_group_cfg
*rfg_new
;
1631 if (!bgp
->rfapi_cfg
)
1633 vty_out (vty
, "rfapi not configured%s", VTY_NEWLINE
);
1637 rfg_new
= bgp_rfapi_cfg_match_byname (bgp
, argv
[5]->arg
, RFAPI_GROUP_CFG_NVE
);
1639 if (argv
[2]->arg
[0] == 'b')
1642 struct listnode
*node
;
1643 struct rfapi_rfg_name
*rfgn
;
1646 * Set group for export to BGP Direct
1649 /* see if group is already included in export list */
1650 for (ALL_LIST_ELEMENTS_RO (bgp
->rfapi_cfg
->rfg_export_direct_bgp_l
,
1654 if (!strcmp (rfgn
->name
, argv
[5]->arg
))
1656 /* already in the list: we're done */
1662 rfgn
->name
= strdup (argv
[5]->arg
);
1663 rfgn
->rfg
= rfg_new
; /* OK if not set yet */
1665 listnode_add (bgp
->rfapi_cfg
->rfg_export_direct_bgp_l
, rfgn
);
1667 vnc_zlog_debug_verbose ("%s: testing rfg_new", __func__
);
1670 vnc_zlog_debug_verbose ("%s: testing bgp grp mode enabled", __func__
);
1671 if (VNC_EXPORT_BGP_GRP_ENABLED (bgp
->rfapi_cfg
))
1672 vnc_zlog_debug_verbose ("%s: calling vnc_direct_bgp_add_group", __func__
);
1673 vnc_direct_bgp_add_group (bgp
, rfg_new
);
1680 struct listnode
*node
;
1681 struct rfapi_rfg_name
*rfgn
;
1684 * Set group for export to Zebra
1687 /* see if group is already included in export list */
1688 for (ALL_LIST_ELEMENTS_RO (bgp
->rfapi_cfg
->rfg_export_zebra_l
,
1692 if (!strcmp (rfgn
->name
, argv
[5]->arg
))
1694 /* already in the list: we're done */
1700 rfgn
->name
= strdup (argv
[5]->arg
);
1701 rfgn
->rfg
= rfg_new
; /* OK if not set yet */
1703 listnode_add (bgp
->rfapi_cfg
->rfg_export_zebra_l
, rfgn
);
1707 if (VNC_EXPORT_ZEBRA_GRP_ENABLED (bgp
->rfapi_cfg
))
1708 vnc_zebra_add_group (bgp
, rfg_new
);
1716 * This command applies to routes exported from VNC to BGP directly
1717 * without going though zebra
1719 DEFUN (vnc_no_export_nvegroup
,
1720 vnc_no_export_nvegroup_cmd
,
1721 "vnc export <bgp|zebra> group-nve no group NAME",
1723 "Export to other protocols\n"
1725 "Export to Zebra (experimental)\n"
1726 "NVE group, used in 'group-nve' export mode\n"
1727 "Disable export of VNC routes\n" "NVE group\n" "Group name\n")
1729 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1730 struct listnode
*node
, *nnode
;
1731 struct rfapi_rfg_name
*rfgn
;
1733 if (!bgp
->rfapi_cfg
)
1735 vty_out (vty
, "rfapi not configured%s", VTY_NEWLINE
);
1739 if (argv
[2]->arg
[0] == 'b')
1741 for (ALL_LIST_ELEMENTS (bgp
->rfapi_cfg
->rfg_export_direct_bgp_l
,
1745 if (rfgn
->name
&& !strcmp (rfgn
->name
, argv
[6]->arg
))
1747 vnc_zlog_debug_verbose ("%s: matched \"%s\"", __func__
, rfgn
->name
);
1749 vnc_direct_bgp_del_group (bgp
, rfgn
->rfg
);
1751 list_delete_node (bgp
->rfapi_cfg
->rfg_export_direct_bgp_l
,
1760 for (ALL_LIST_ELEMENTS (bgp
->rfapi_cfg
->rfg_export_zebra_l
,
1764 vnc_zlog_debug_verbose ("does rfg \"%s\" match?", rfgn
->name
);
1765 if (rfgn
->name
&& !strcmp (rfgn
->name
, argv
[6]->arg
))
1768 vnc_zebra_del_group (bgp
, rfgn
->rfg
);
1770 list_delete_node (bgp
->rfapi_cfg
->rfg_export_zebra_l
, node
);
1779 DEFUN (vnc_nve_group_export_no_prefixlist
,
1780 vnc_nve_group_export_no_prefixlist_cmd
,
1781 "no export <bgp|zebra> <ipv4|ipv6> prefix-list [NAME]",
1783 "Export to other protocols\n"
1785 "Export to Zebra (experimental)\n"
1788 "Prefix-list for filtering exported routes\n" "prefix list name\n")
1790 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1791 VTY_DECLVAR_CONTEXT_SUB(rfapi_nve_group_cfg
, rfg
);
1794 if (!bgp
->rfapi_cfg
)
1796 vty_out (vty
, "rfapi not configured%s", VTY_NEWLINE
);
1800 /* make sure it's still in list */
1801 if (!listnode_lookup (bgp
->rfapi_cfg
->nve_groups_sequential
, rfg
))
1803 /* Not in list anymore */
1804 vty_out (vty
, "Current NVE group no longer exists%s", VTY_NEWLINE
);
1808 if (!strcmp (argv
[3]->arg
, "ipv4"))
1817 if (argv
[2]->arg
[0] == 'b')
1820 && !strcmp (argv
[5]->arg
, rfg
->plist_export_bgp_name
[afi
]))
1824 if (rfg
->plist_export_bgp_name
[afi
])
1825 free (rfg
->plist_export_bgp_name
[afi
]);
1826 rfg
->plist_export_bgp_name
[afi
] = NULL
;
1827 rfg
->plist_export_bgp
[afi
] = NULL
;
1829 vnc_direct_bgp_reexport_group_afi (bgp
, rfg
, afi
);
1835 && !strcmp (argv
[5]->arg
, rfg
->plist_export_zebra_name
[afi
]))
1838 if (rfg
->plist_export_zebra_name
[afi
])
1839 free (rfg
->plist_export_zebra_name
[afi
]);
1840 rfg
->plist_export_zebra_name
[afi
] = NULL
;
1841 rfg
->plist_export_zebra
[afi
] = NULL
;
1843 vnc_zebra_reexport_group_afi (bgp
, rfg
, afi
);
1849 DEFUN (vnc_nve_group_export_prefixlist
,
1850 vnc_nve_group_export_prefixlist_cmd
,
1851 "export <bgp|zebra> <ipv4|ipv6> prefix-list NAME",
1852 "Export to other protocols\n"
1854 "Export to Zebra (experimental)\n"
1857 "Prefix-list for filtering exported routes\n" "prefix list name\n")
1859 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1860 VTY_DECLVAR_CONTEXT_SUB(rfapi_nve_group_cfg
, rfg
);
1863 if (!bgp
->rfapi_cfg
)
1865 vty_out (vty
, "rfapi not configured%s", VTY_NEWLINE
);
1869 /* make sure it's still in list */
1870 if (!listnode_lookup (bgp
->rfapi_cfg
->nve_groups_sequential
, rfg
))
1872 /* Not in list anymore */
1873 vty_out (vty
, "Current NVE group no longer exists%s", VTY_NEWLINE
);
1877 if (!strcmp (argv
[2]->arg
, "ipv4"))
1886 if (argv
[1]->arg
[0] == 'b')
1888 if (rfg
->plist_export_bgp_name
[afi
])
1889 free (rfg
->plist_export_bgp_name
[afi
]);
1890 rfg
->plist_export_bgp_name
[afi
] = strdup (argv
[4]->arg
);
1891 rfg
->plist_export_bgp
[afi
] = prefix_list_lookup (afi
, argv
[4]->arg
);
1893 vnc_direct_bgp_reexport_group_afi (bgp
, rfg
, afi
);
1898 if (rfg
->plist_export_zebra_name
[afi
])
1899 free (rfg
->plist_export_zebra_name
[afi
]);
1900 rfg
->plist_export_zebra_name
[afi
] = strdup (argv
[4]->arg
);
1901 rfg
->plist_export_zebra
[afi
] = prefix_list_lookup (afi
, argv
[4]->arg
);
1903 vnc_zebra_reexport_group_afi (bgp
, rfg
, afi
);
1908 DEFUN (vnc_nve_group_export_no_routemap
,
1909 vnc_nve_group_export_no_routemap_cmd
,
1910 "no export <bgp|zebra> route-map [NAME]",
1912 "Export to other protocols\n"
1914 "Export to Zebra (experimental)\n"
1915 "Route-map for filtering exported routes\n" "route map name\n")
1917 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1918 VTY_DECLVAR_CONTEXT_SUB(rfapi_nve_group_cfg
, rfg
);
1920 if (!bgp
->rfapi_cfg
)
1922 vty_out (vty
, "rfapi not configured%s", VTY_NEWLINE
);
1926 /* make sure it's still in list */
1927 if (!listnode_lookup (bgp
->rfapi_cfg
->nve_groups_sequential
, rfg
))
1929 /* Not in list anymore */
1930 vty_out (vty
, "Current NVE group no longer exists%s", VTY_NEWLINE
);
1934 if (argv
[2]->arg
[0] == 'b')
1937 && !strcmp (argv
[4]->arg
, rfg
->routemap_export_bgp_name
))
1941 if (rfg
->routemap_export_bgp_name
)
1942 free (rfg
->routemap_export_bgp_name
);
1943 rfg
->routemap_export_bgp_name
= NULL
;
1944 rfg
->routemap_export_bgp
= NULL
;
1946 vnc_direct_bgp_reexport_group_afi (bgp
, rfg
, AFI_IP
);
1947 vnc_direct_bgp_reexport_group_afi (bgp
, rfg
, AFI_IP6
);
1953 && !strcmp (argv
[4]->arg
, rfg
->routemap_export_zebra_name
))
1956 if (rfg
->routemap_export_zebra_name
)
1957 free (rfg
->routemap_export_zebra_name
);
1958 rfg
->routemap_export_zebra_name
= NULL
;
1959 rfg
->routemap_export_zebra
= NULL
;
1961 vnc_zebra_reexport_group_afi (bgp
, rfg
, AFI_IP
);
1962 vnc_zebra_reexport_group_afi (bgp
, rfg
, AFI_IP6
);
1968 DEFUN (vnc_nve_group_export_routemap
,
1969 vnc_nve_group_export_routemap_cmd
,
1970 "export <bgp|zebra> route-map NAME",
1971 "Export to other protocols\n"
1973 "Export to Zebra (experimental)\n"
1974 "Route-map for filtering exported routes\n" "route map name\n")
1976 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1977 VTY_DECLVAR_CONTEXT_SUB(rfapi_nve_group_cfg
, rfg
);
1979 if (!bgp
->rfapi_cfg
)
1981 vty_out (vty
, "rfapi not configured%s", VTY_NEWLINE
);
1985 /* make sure it's still in list */
1986 if (!listnode_lookup (bgp
->rfapi_cfg
->nve_groups_sequential
, rfg
))
1988 /* Not in list anymore */
1989 vty_out (vty
, "Current NVE group no longer exists%s", VTY_NEWLINE
);
1993 if (argv
[1]->arg
[0] == 'b')
1995 if (rfg
->routemap_export_bgp_name
)
1996 free (rfg
->routemap_export_bgp_name
);
1997 rfg
->routemap_export_bgp_name
= strdup (argv
[3]->arg
);
1998 rfg
->routemap_export_bgp
= route_map_lookup_by_name (argv
[3]->arg
);
1999 vnc_direct_bgp_reexport_group_afi (bgp
, rfg
, AFI_IP
);
2000 vnc_direct_bgp_reexport_group_afi (bgp
, rfg
, AFI_IP6
);
2004 if (rfg
->routemap_export_zebra_name
)
2005 free (rfg
->routemap_export_zebra_name
);
2006 rfg
->routemap_export_zebra_name
= strdup (argv
[3]->arg
);
2007 rfg
->routemap_export_zebra
= route_map_lookup_by_name (argv
[3]->arg
);
2008 vnc_zebra_reexport_group_afi (bgp
, rfg
, AFI_IP
);
2009 vnc_zebra_reexport_group_afi (bgp
, rfg
, AFI_IP6
);
2014 DEFUN (vnc_nve_export_no_prefixlist
,
2015 vnc_nve_export_no_prefixlist_cmd
,
2016 "no vnc export <bgp|zebra> <ipv4|ipv6> prefix-list [NAME]",
2019 "Export to other protocols\n"
2021 "Export to Zebra (experimental)\n"
2024 "Prefix-list for filtering exported routes\n" "Prefix list name\n")
2026 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2027 struct rfapi_cfg
*hc
;
2030 if (!(hc
= bgp
->rfapi_cfg
))
2032 vty_out (vty
, "rfapi not configured%s", VTY_NEWLINE
);
2036 if (!strcmp (argv
[4]->arg
, "ipv4"))
2045 if (argv
[3]->arg
[0] == 'b')
2048 && hc
->plist_export_bgp_name
[afi
]
2049 && !strcmp (argv
[6]->arg
, hc
->plist_export_bgp_name
[afi
]))
2053 free (hc
->plist_export_bgp_name
[afi
]);
2054 hc
->plist_export_bgp_name
[afi
] = NULL
;
2055 hc
->plist_export_bgp
[afi
] = NULL
;
2056 vnc_direct_bgp_reexport (bgp
, afi
);
2062 && hc
->plist_export_zebra_name
[afi
]
2063 && !strcmp (argv
[6]->arg
, hc
->plist_export_zebra_name
[afi
]))
2067 free (hc
->plist_export_zebra_name
[afi
]);
2068 hc
->plist_export_zebra_name
[afi
] = NULL
;
2069 hc
->plist_export_zebra
[afi
] = NULL
;
2070 /* TBD vnc_zebra_rh_reexport(bgp, afi); */
2076 DEFUN (vnc_nve_export_prefixlist
,
2077 vnc_nve_export_prefixlist_cmd
,
2078 "vnc export <bgp|zebra> <ipv4|ipv6> prefix-list NAME",
2080 "Export to other protocols\n"
2082 "Export to Zebra (experimental)\n"
2083 "Filters, used in 'registering-nve' export mode\n"
2086 "Prefix-list for filtering exported routes\n" "Prefix list name\n")
2088 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2089 struct rfapi_cfg
*hc
;
2092 if (!(hc
= bgp
->rfapi_cfg
))
2094 vty_out (vty
, "rfapi not configured%s", VTY_NEWLINE
);
2098 if (!strcmp (argv
[3]->arg
, "ipv4"))
2107 if (argv
[2]->arg
[0] == 'b')
2109 if (hc
->plist_export_bgp_name
[afi
])
2110 free (hc
->plist_export_bgp_name
[afi
]);
2111 hc
->plist_export_bgp_name
[afi
] = strdup (argv
[5]->arg
);
2112 hc
->plist_export_bgp
[afi
] = prefix_list_lookup (afi
, argv
[5]->arg
);
2113 vnc_direct_bgp_reexport (bgp
, afi
);
2117 if (hc
->plist_export_zebra_name
[afi
])
2118 free (hc
->plist_export_zebra_name
[afi
]);
2119 hc
->plist_export_zebra_name
[afi
] = strdup (argv
[5]->arg
);
2120 hc
->plist_export_zebra
[afi
] = prefix_list_lookup (afi
, argv
[5]->arg
);
2121 /* TBD vnc_zebra_rh_reexport(bgp, afi); */
2126 DEFUN (vnc_nve_export_no_routemap
,
2127 vnc_nve_export_no_routemap_cmd
,
2128 "no vnc export <bgp|zebra> route-map [NAME]",
2131 "Export to other protocols\n"
2133 "Export to Zebra (experimental)\n"
2134 "Route-map for filtering exported routes\n" "Route map name\n")
2136 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2137 struct rfapi_cfg
*hc
;
2139 if (!(hc
= bgp
->rfapi_cfg
))
2141 vty_out (vty
, "rfapi not configured%s", VTY_NEWLINE
);
2145 if (argv
[3]->arg
[0] == 'b')
2148 && hc
->routemap_export_bgp_name
2149 && !strcmp (argv
[5]->arg
, hc
->routemap_export_bgp_name
))
2153 free (hc
->routemap_export_bgp_name
);
2154 hc
->routemap_export_bgp_name
= NULL
;
2155 hc
->routemap_export_bgp
= NULL
;
2156 vnc_direct_bgp_reexport (bgp
, AFI_IP
);
2157 vnc_direct_bgp_reexport (bgp
, AFI_IP6
);
2163 && hc
->routemap_export_zebra_name
2164 && !strcmp (argv
[5]->arg
, hc
->routemap_export_zebra_name
))
2168 free (hc
->routemap_export_zebra_name
);
2169 hc
->routemap_export_zebra_name
= NULL
;
2170 hc
->routemap_export_zebra
= NULL
;
2171 /* TBD vnc_zebra_rh_reexport(bgp, AFI_IP); */
2172 /* TBD vnc_zebra_rh_reexport(bgp, AFI_IP6); */
2178 DEFUN (vnc_nve_export_routemap
,
2179 vnc_nve_export_routemap_cmd
,
2180 "vnc export <bgp|zebra> route-map NAME",
2182 "Export to other protocols\n"
2184 "Export to Zebra (experimental)\n"
2185 "Filters, used in 'registering-nve' export mode\n"
2186 "Route-map for filtering exported routes\n" "Route map name\n")
2188 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2189 struct rfapi_cfg
*hc
;
2191 if (!(hc
= bgp
->rfapi_cfg
))
2193 vty_out (vty
, "rfapi not configured%s", VTY_NEWLINE
);
2197 if (argv
[2]->arg
[0] == 'b')
2199 if (hc
->routemap_export_bgp_name
)
2200 free (hc
->routemap_export_bgp_name
);
2201 hc
->routemap_export_bgp_name
= strdup (argv
[4]->arg
);
2202 hc
->routemap_export_bgp
= route_map_lookup_by_name (argv
[4]->arg
);
2203 vnc_direct_bgp_reexport (bgp
, AFI_IP
);
2204 vnc_direct_bgp_reexport (bgp
, AFI_IP6
);
2208 if (hc
->routemap_export_zebra_name
)
2209 free (hc
->routemap_export_zebra_name
);
2210 hc
->routemap_export_zebra_name
= strdup (argv
[4]->arg
);
2211 hc
->routemap_export_zebra
= route_map_lookup_by_name (argv
[4]->arg
);
2212 /* TBD vnc_zebra_rh_reexport(bgp, AFI_IP); */
2213 /* TBD vnc_zebra_rh_reexport(bgp, AFI_IP6); */
2220 * respond to changes in the global prefix list configuration
2223 vnc_prefix_list_update (struct bgp
*bgp
)
2227 struct rfapi_nve_group_cfg
*rfg
;
2228 struct rfapi_cfg
*hc
;
2233 vnc_zlog_debug_verbose ("%s: No BGP process is configured", __func__
);
2237 if (!(hc
= bgp
->rfapi_cfg
))
2239 vnc_zlog_debug_verbose ("%s: rfapi not configured", __func__
);
2243 for (afi
= AFI_IP
; afi
< AFI_MAX
; afi
++)
2246 * Loop over nve groups
2248 for (ALL_LIST_ELEMENTS_RO (bgp
->rfapi_cfg
->nve_groups_sequential
,
2252 if (rfg
->plist_export_bgp_name
[afi
])
2254 rfg
->plist_export_bgp
[afi
] =
2255 prefix_list_lookup (afi
, rfg
->plist_export_bgp_name
[afi
]);
2257 if (rfg
->plist_export_zebra_name
[afi
])
2259 rfg
->plist_export_zebra
[afi
] =
2260 prefix_list_lookup (afi
, rfg
->plist_export_zebra_name
[afi
]);
2262 for (i
= 0; i
< ZEBRA_ROUTE_MAX
; ++i
)
2264 if (rfg
->plist_redist_name
[i
][afi
])
2266 rfg
->plist_redist
[i
][afi
] =
2267 prefix_list_lookup (afi
, rfg
->plist_redist_name
[i
][afi
]);
2271 vnc_direct_bgp_reexport_group_afi (bgp
, rfg
, afi
);
2272 /* TBD vnc_zebra_reexport_group_afi(bgp, rfg, afi); */
2278 if (hc
->plist_export_bgp_name
[afi
])
2280 hc
->plist_export_bgp
[afi
] =
2281 prefix_list_lookup (afi
, hc
->plist_export_bgp_name
[afi
]);
2283 if (hc
->plist_export_zebra_name
[afi
])
2285 hc
->plist_export_zebra
[afi
] =
2286 prefix_list_lookup (afi
, hc
->plist_export_zebra_name
[afi
]);
2289 for (i
= 0; i
< ZEBRA_ROUTE_MAX
; ++i
)
2291 if (hc
->plist_redist_name
[i
][afi
])
2293 hc
->plist_redist
[i
][afi
] =
2294 prefix_list_lookup (afi
, hc
->plist_redist_name
[i
][afi
]);
2300 vnc_direct_bgp_reexport (bgp
, AFI_IP
);
2301 vnc_direct_bgp_reexport (bgp
, AFI_IP6
);
2303 /* TBD vnc_zebra_rh_reexport(bgp, AFI_IP); */
2304 /* TBD vnc_zebra_rh_reexport(bgp, AFI_IP6); */
2306 vnc_redistribute_prechange (bgp
);
2307 vnc_redistribute_postchange (bgp
);
2311 * respond to changes in the global route map configuration
2314 vnc_routemap_update (struct bgp
*bgp
, const char *unused
)
2317 struct rfapi_nve_group_cfg
*rfg
;
2318 struct rfapi_cfg
*hc
;
2321 vnc_zlog_debug_verbose ("%s(arg=%s)", __func__
, unused
);
2325 vnc_zlog_debug_verbose ("%s: No BGP process is configured", __func__
);
2329 if (!(hc
= bgp
->rfapi_cfg
))
2331 vnc_zlog_debug_verbose ("%s: rfapi not configured", __func__
);
2336 * Loop over nve groups
2338 for (ALL_LIST_ELEMENTS_RO (bgp
->rfapi_cfg
->nve_groups_sequential
, n
, rfg
))
2341 if (rfg
->routemap_export_bgp_name
)
2343 rfg
->routemap_export_bgp
=
2344 route_map_lookup_by_name (rfg
->routemap_export_bgp_name
);
2346 if (rfg
->routemap_export_zebra_name
)
2348 rfg
->routemap_export_bgp
=
2349 route_map_lookup_by_name (rfg
->routemap_export_zebra_name
);
2351 for (i
= 0; i
< ZEBRA_ROUTE_MAX
; ++i
)
2353 if (rfg
->routemap_redist_name
[i
])
2355 rfg
->routemap_redist
[i
] =
2356 route_map_lookup_by_name (rfg
->routemap_redist_name
[i
]);
2360 vnc_direct_bgp_reexport_group_afi (bgp
, rfg
, AFI_IP
);
2361 vnc_direct_bgp_reexport_group_afi (bgp
, rfg
, AFI_IP6
);
2362 /* TBD vnc_zebra_reexport_group_afi(bgp, rfg, afi); */
2368 if (hc
->routemap_export_bgp_name
)
2370 hc
->routemap_export_bgp
=
2371 route_map_lookup_by_name (hc
->routemap_export_bgp_name
);
2373 if (hc
->routemap_export_zebra_name
)
2375 hc
->routemap_export_bgp
=
2376 route_map_lookup_by_name (hc
->routemap_export_zebra_name
);
2378 for (i
= 0; i
< ZEBRA_ROUTE_MAX
; ++i
)
2380 if (hc
->routemap_redist_name
[i
])
2382 hc
->routemap_redist
[i
] =
2383 route_map_lookup_by_name (hc
->routemap_redist_name
[i
]);
2387 vnc_direct_bgp_reexport (bgp
, AFI_IP
);
2388 vnc_direct_bgp_reexport (bgp
, AFI_IP6
);
2390 /* TBD vnc_zebra_rh_reexport(bgp, AFI_IP); */
2391 /* TBD vnc_zebra_rh_reexport(bgp, AFI_IP6); */
2393 vnc_redistribute_prechange (bgp
);
2394 vnc_redistribute_postchange (bgp
);
2396 vnc_zlog_debug_verbose ("%s done", __func__
);
2400 vnc_routemap_event (route_map_event_t type
, /* ignored */
2401 const char *rmap_name
) /* ignored */
2403 struct listnode
*mnode
, *mnnode
;
2406 vnc_zlog_debug_verbose ("%s(event type=%d)", __func__
, type
);
2407 if (bm
->bgp
== NULL
) /* may be called during cleanup */
2410 for (ALL_LIST_ELEMENTS (bm
->bgp
, mnode
, mnnode
, bgp
))
2411 vnc_routemap_update (bgp
, rmap_name
);
2413 vnc_zlog_debug_verbose ("%s: done", __func__
);
2416 /*-------------------------------------------------------------------------
2418 *-----------------------------------------------------------------------*/
2421 DEFUN_NOSH (vnc_nve_group
,
2423 "vnc nve-group NAME",
2424 VNC_CONFIG_STR
"Configure a NVE group\n" "Group name\n")
2426 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2427 struct rfapi_nve_group_cfg
*rfg
;
2428 struct listnode
*node
, *nnode
;
2429 struct rfapi_rfg_name
*rfgn
;
2431 /* Search for name */
2432 rfg
= bgp_rfapi_cfg_match_byname (bgp
, argv
[2]->arg
, RFAPI_GROUP_CFG_NVE
);
2436 rfg
= rfapi_group_new (bgp
, RFAPI_GROUP_CFG_NVE
, argv
[2]->arg
);
2439 /* Error out of memory */
2440 vty_out (vty
, "Can't allocate memory for NVE group%s", VTY_NEWLINE
);
2444 /* Copy defaults from struct rfapi_cfg */
2445 rfg
->rd
= bgp
->rfapi_cfg
->default_rd
;
2446 if (bgp
->rfapi_cfg
->flags
& BGP_VNC_CONFIG_L2RD
)
2448 rfg
->l2rd
= bgp
->rfapi_cfg
->default_l2rd
;
2449 rfg
->flags
|= RFAPI_RFG_L2RD
;
2451 rfg
->rd
= bgp
->rfapi_cfg
->default_rd
;
2452 rfg
->response_lifetime
= bgp
->rfapi_cfg
->default_response_lifetime
;
2454 if (bgp
->rfapi_cfg
->default_rt_export_list
)
2456 rfg
->rt_export_list
=
2457 ecommunity_dup (bgp
->rfapi_cfg
->default_rt_export_list
);
2460 if (bgp
->rfapi_cfg
->default_rt_import_list
)
2462 rfg
->rt_import_list
=
2463 ecommunity_dup (bgp
->rfapi_cfg
->default_rt_import_list
);
2464 rfg
->rfapi_import_table
=
2465 rfapiImportTableRefAdd (bgp
, rfg
->rt_import_list
, rfg
);
2469 * If a redist nve group was named but the group was not defined,
2470 * make the linkage now
2472 if (!bgp
->rfapi_cfg
->rfg_redist
)
2474 if (bgp
->rfapi_cfg
->rfg_redist_name
&&
2475 !strcmp (bgp
->rfapi_cfg
->rfg_redist_name
, rfg
->name
))
2478 vnc_redistribute_prechange (bgp
);
2479 bgp
->rfapi_cfg
->rfg_redist
= rfg
;
2480 vnc_redistribute_postchange (bgp
);
2486 * Same treatment for bgp-direct export group
2488 for (ALL_LIST_ELEMENTS (bgp
->rfapi_cfg
->rfg_export_direct_bgp_l
,
2492 if (!strcmp (rfgn
->name
, rfg
->name
))
2495 vnc_direct_bgp_add_group (bgp
, rfg
);
2501 * Same treatment for zebra export group
2503 for (ALL_LIST_ELEMENTS (bgp
->rfapi_cfg
->rfg_export_zebra_l
,
2507 vnc_zlog_debug_verbose ("%s: ezport zebra: checking if \"%s\" == \"%s\"",
2508 __func__
, rfgn
->name
, rfg
->name
);
2509 if (!strcmp (rfgn
->name
, rfg
->name
))
2512 vnc_zebra_add_group (bgp
, rfg
);
2519 * XXX subsequent calls will need to make sure this item is still
2520 * in the linked list and has the same name
2522 VTY_PUSH_CONTEXT_SUB (BGP_VNC_NVE_GROUP_NODE
, rfg
);
2528 bgp_rfapi_delete_nve_group (
2529 struct vty
*vty
, /* NULL = no output */
2531 struct rfapi_nve_group_cfg
*rfg
)
2533 struct list
*orphaned_nves
= NULL
;
2534 struct listnode
*node
, *nnode
;
2537 * If there are currently-open NVEs that belong to this group,
2538 * zero out their references to this group structure.
2542 struct rfapi_descriptor
*rfd
;
2543 orphaned_nves
= list_new ();
2544 while ((rfd
= listnode_head (rfg
->nves
)))
2547 listnode_delete (rfg
->nves
, rfd
);
2548 listnode_add (orphaned_nves
, rfd
);
2550 list_delete (rfg
->nves
);
2556 if (rfg
->rfapi_import_table
)
2557 rfapiImportTableRefDelByIt (bgp
, rfg
->rfapi_import_table
);
2558 if (rfg
->rt_import_list
)
2559 ecommunity_free (&rfg
->rt_import_list
);
2560 if (rfg
->rt_export_list
)
2561 ecommunity_free (&rfg
->rt_export_list
);
2565 rfg
->vn_node
->info
= NULL
;
2566 route_unlock_node (rfg
->vn_node
); /* frees */
2570 rfg
->un_node
->info
= NULL
;
2571 route_unlock_node (rfg
->un_node
); /* frees */
2574 XFREE (MTYPE_RFAPI_RFP_GROUP_CFG
, rfg
->rfp_cfg
);
2575 listnode_delete (bgp
->rfapi_cfg
->nve_groups_sequential
, rfg
);
2578 XFREE (MTYPE_RFAPI_GROUP_CFG
, rfg
);
2581 * Attempt to reassign the orphaned nves to a new group. If
2582 * a NVE can not be reassigned, its rfd->rfg will remain NULL
2583 * and it will become a zombie until released by rfapi_close().
2587 struct rfapi_descriptor
*rfd
;
2589 for (ALL_LIST_ELEMENTS (orphaned_nves
, node
, nnode
, rfd
))
2592 * 1. rfapi_close() equivalent except:
2593 * a. don't free original descriptor
2594 * b. remember query list
2595 * c. remember advertised route list
2596 * 2. rfapi_open() equivalent except:
2597 * a. reuse original descriptor
2598 * 3. rfapi_register() on remembered advertised route list
2599 * 4. rfapi_query on rememebred query list
2604 rc
= rfapi_reopen (rfd
, bgp
);
2608 list_delete_node (orphaned_nves
, node
);
2610 vty_out (vty
, "WARNING: reassigned NVE vn=");
2611 rfapiPrintRfapiIpAddr (vty
, &rfd
->vn_addr
);
2613 vty_out (vty
, " un=");
2614 rfapiPrintRfapiIpAddr (vty
, &rfd
->un_addr
);
2616 vty_out (vty
, " to new group \"%s\"%s", rfd
->rfg
->name
,
2622 for (ALL_LIST_ELEMENTS_RO (orphaned_nves
, node
, rfd
))
2625 vty_out (vty
, "WARNING: orphaned NVE vn=");
2626 rfapiPrintRfapiIpAddr (vty
, &rfd
->vn_addr
);
2628 vty_out (vty
, " un=");
2629 rfapiPrintRfapiIpAddr (vty
, &rfd
->un_addr
);
2631 vty_out (vty
, "%s", VTY_NEWLINE
);
2633 list_delete (orphaned_nves
);
2638 bgp_rfapi_delete_named_nve_group (
2639 struct vty
*vty
, /* NULL = no output */
2641 const char *rfg_name
, /* NULL = any */
2642 rfapi_group_cfg_type_t type
) /* _MAX = any */
2644 struct rfapi_nve_group_cfg
*rfg
= NULL
;
2645 struct listnode
*node
, *nnode
;
2646 struct rfapi_rfg_name
*rfgn
;
2648 /* Search for name */
2651 rfg
= bgp_rfapi_cfg_match_byname (bgp
, rfg_name
, type
);
2655 vty_out (vty
, "No NVE group named \"%s\"%s", rfg_name
,
2662 * If this group is the redist nve group, unlink it
2664 if (rfg_name
== NULL
|| bgp
->rfapi_cfg
->rfg_redist
== rfg
)
2666 vnc_redistribute_prechange (bgp
);
2667 bgp
->rfapi_cfg
->rfg_redist
= NULL
;
2668 vnc_redistribute_postchange (bgp
);
2673 * remove reference from bgp direct export list
2675 for (ALL_LIST_ELEMENTS_RO (bgp
->rfapi_cfg
->rfg_export_direct_bgp_l
,
2678 if (rfg_name
== NULL
||
2679 (type
== RFAPI_GROUP_CFG_NVE
&& !strcmp (rfgn
->name
, rfg_name
)))
2682 /* remove exported routes from this group */
2683 vnc_direct_bgp_del_group (bgp
, rfg
);
2689 * remove reference from zebra export list
2691 for (ALL_LIST_ELEMENTS_RO (bgp
->rfapi_cfg
->rfg_export_zebra_l
, node
, rfgn
))
2694 if (rfg_name
== NULL
||
2695 (type
== RFAPI_GROUP_CFG_NVE
&& !strcmp (rfgn
->name
, rfg_name
)))
2698 /* remove exported routes from this group */
2699 vnc_zebra_del_group (bgp
, rfg
);
2704 bgp_rfapi_delete_nve_group (vty
, bgp
, rfg
);
2705 else /* must be delete all */
2706 for (ALL_LIST_ELEMENTS
2707 (bgp
->rfapi_cfg
->nve_groups_sequential
, node
, nnode
, rfg
))
2708 bgp_rfapi_delete_nve_group (vty
, bgp
, rfg
);
2712 DEFUN (vnc_no_nve_group
,
2713 vnc_no_nve_group_cmd
,
2714 "no vnc nve-group NAME",
2717 "Configure a NVE group\n"
2720 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2722 return bgp_rfapi_delete_named_nve_group (vty
, bgp
, argv
[3]->arg
, RFAPI_GROUP_CFG_NVE
);
2725 DEFUN (vnc_nve_group_prefix
,
2726 vnc_nve_group_prefix_cmd
,
2727 "prefix <vn|un> <A.B.C.D/M|X:X::X:X/M>",
2728 "Specify prefixes matching NVE VN or UN interfaces\n"
2734 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2735 VTY_DECLVAR_CONTEXT_SUB(rfapi_nve_group_cfg
, rfg
);
2738 struct route_table
*rt
;
2739 struct route_node
*rn
;
2740 int is_un_prefix
= 0;
2742 /* make sure it's still in list */
2743 if (!listnode_lookup (bgp
->rfapi_cfg
->nve_groups_sequential
, rfg
))
2745 /* Not in list anymore */
2746 vty_out (vty
, "Current NVE group no longer exists%s", VTY_NEWLINE
);
2750 if (!str2prefix (argv
[2]->arg
, &p
))
2752 vty_out (vty
, "Malformed prefix \"%s\"%s", argv
[2]->arg
, VTY_NEWLINE
);
2756 afi
= family2afi (p
.family
);
2759 vty_out (vty
, "Unsupported address family%s", VTY_NEWLINE
);
2763 if (argv
[1]->arg
[0] == 'u')
2765 rt
= &(bgp
->rfapi_cfg
->nve_groups_un
[afi
]);
2770 rt
= &(bgp
->rfapi_cfg
->nve_groups_vn
[afi
]);
2773 rn
= route_node_get (rt
, &p
); /* NB locks node */
2777 * There is already a group with this prefix
2779 route_unlock_node (rn
);
2780 if (rn
->info
!= rfg
)
2783 * different group name: fail
2785 vty_out (vty
, "nve group \"%s\" already has \"%s\" prefix %s%s",
2786 ((struct rfapi_nve_group_cfg
*) (rn
->info
))->name
,
2787 argv
[1]->arg
, argv
[2]->arg
, VTY_NEWLINE
);
2793 * same group name: it's already in the correct place
2794 * in the table, so we're done.
2796 * Implies rfg->(vn|un)_prefix is already correct.
2802 if (bgp
->rfapi_cfg
->rfg_redist
== rfg
)
2804 vnc_redistribute_prechange (bgp
);
2807 /* New prefix, new node */
2812 /* detach rfg from previous route table location */
2815 rfg
->un_node
->info
= NULL
;
2816 route_unlock_node (rfg
->un_node
); /* frees */
2818 rfg
->un_node
= rn
; /* back ref */
2825 /* detach rfg from previous route table location */
2828 rfg
->vn_node
->info
= NULL
;
2829 route_unlock_node (rfg
->vn_node
); /* frees */
2831 rfg
->vn_node
= rn
; /* back ref */
2838 if (bgp
->rfapi_cfg
->rfg_redist
== rfg
)
2840 vnc_redistribute_postchange (bgp
);
2846 DEFUN (vnc_nve_group_rt_import
,
2847 vnc_nve_group_rt_import_cmd
,
2848 "rt import RTLIST...",
2849 "Specify route targets\n"
2851 "Space separated route target list (A.B.C.D:MN|EF:OPQR|GHJK:MN)\n")
2853 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2854 VTY_DECLVAR_CONTEXT_SUB(rfapi_nve_group_cfg
, rfg
);
2856 struct listnode
*node
;
2857 struct rfapi_rfg_name
*rfgn
;
2858 int is_export_bgp
= 0;
2859 int is_export_zebra
= 0;
2861 /* make sure it's still in list */
2862 if (!listnode_lookup (bgp
->rfapi_cfg
->nve_groups_sequential
, rfg
))
2864 /* Not in list anymore */
2865 vty_out (vty
, "Current NVE group no longer exists%s", VTY_NEWLINE
);
2869 rc
= set_ecom_list (vty
, argc
- 2, argv
+ 2, &rfg
->rt_import_list
);
2870 if (rc
!= CMD_SUCCESS
)
2873 for (ALL_LIST_ELEMENTS_RO (bgp
->rfapi_cfg
->rfg_export_direct_bgp_l
,
2877 if (rfgn
->rfg
== rfg
)
2885 vnc_direct_bgp_del_group (bgp
, rfg
);
2887 for (ALL_LIST_ELEMENTS_RO (bgp
->rfapi_cfg
->rfg_export_zebra_l
, node
, rfgn
))
2890 if (rfgn
->rfg
== rfg
)
2892 is_export_zebra
= 1;
2897 if (is_export_zebra
)
2898 vnc_zebra_del_group (bgp
, rfg
);
2901 * stop referencing old import table, now reference new one
2903 if (rfg
->rfapi_import_table
)
2904 rfapiImportTableRefDelByIt (bgp
, rfg
->rfapi_import_table
);
2905 rfg
->rfapi_import_table
= rfapiImportTableRefAdd (bgp
, rfg
->rt_import_list
, rfg
);
2908 vnc_direct_bgp_add_group (bgp
, rfg
);
2910 if (is_export_zebra
)
2911 vnc_zebra_add_group (bgp
, rfg
);
2916 DEFUN (vnc_nve_group_rt_export
,
2917 vnc_nve_group_rt_export_cmd
,
2918 "rt export RTLIST...",
2919 "Specify route targets\n"
2921 "Space separated route target list (A.B.C.D:MN|EF:OPQR|GHJK:MN)\n")
2923 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2924 VTY_DECLVAR_CONTEXT_SUB(rfapi_nve_group_cfg
, rfg
);
2927 /* make sure it's still in list */
2928 if (!listnode_lookup (bgp
->rfapi_cfg
->nve_groups_sequential
, rfg
))
2930 /* Not in list anymore */
2931 vty_out (vty
, "Current NVE group no longer exists%s", VTY_NEWLINE
);
2935 if (bgp
->rfapi_cfg
->rfg_redist
== rfg
)
2937 vnc_redistribute_prechange (bgp
);
2940 rc
= set_ecom_list (vty
, argc
- 2, argv
+ 2, &rfg
->rt_export_list
);
2942 if (bgp
->rfapi_cfg
->rfg_redist
== rfg
)
2944 vnc_redistribute_postchange (bgp
);
2950 DEFUN (vnc_nve_group_rt_both
,
2951 vnc_nve_group_rt_both_cmd
,
2952 "rt both RTLIST...",
2953 "Specify route targets\n"
2954 "Export+import filters\n"
2955 "Space separated route target list (A.B.C.D:MN|EF:OPQR|GHJK:MN)\n")
2957 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2958 VTY_DECLVAR_CONTEXT_SUB(rfapi_nve_group_cfg
, rfg
);
2960 int is_export_bgp
= 0;
2961 int is_export_zebra
= 0;
2962 struct listnode
*node
;
2963 struct rfapi_rfg_name
*rfgn
;
2965 /* make sure it's still in list */
2966 if (!listnode_lookup (bgp
->rfapi_cfg
->nve_groups_sequential
, rfg
))
2968 /* Not in list anymore */
2969 vty_out (vty
, "Current NVE group no longer exists%s", VTY_NEWLINE
);
2973 rc
= set_ecom_list (vty
, argc
- 2, argv
+ 2, &rfg
->rt_import_list
);
2974 if (rc
!= CMD_SUCCESS
)
2977 for (ALL_LIST_ELEMENTS_RO (bgp
->rfapi_cfg
->rfg_export_direct_bgp_l
,
2981 if (rfgn
->rfg
== rfg
)
2989 vnc_direct_bgp_del_group (bgp
, rfg
);
2991 for (ALL_LIST_ELEMENTS_RO (bgp
->rfapi_cfg
->rfg_export_zebra_l
, node
, rfgn
))
2994 if (rfgn
->rfg
== rfg
)
2996 is_export_zebra
= 1;
3001 if (is_export_zebra
)
3003 vnc_zlog_debug_verbose ("%s: is_export_zebra", __func__
);
3004 vnc_zebra_del_group (bgp
, rfg
);
3008 * stop referencing old import table, now reference new one
3010 if (rfg
->rfapi_import_table
)
3011 rfapiImportTableRefDelByIt (bgp
, rfg
->rfapi_import_table
);
3012 rfg
->rfapi_import_table
= rfapiImportTableRefAdd (bgp
, rfg
->rt_import_list
, rfg
);
3015 vnc_direct_bgp_add_group (bgp
, rfg
);
3017 if (is_export_zebra
)
3018 vnc_zebra_add_group (bgp
, rfg
);
3020 if (bgp
->rfapi_cfg
->rfg_redist
== rfg
)
3022 vnc_redistribute_prechange (bgp
);
3025 rc
= set_ecom_list (vty
, argc
- 2, argv
+ 2, &rfg
->rt_export_list
);
3027 if (bgp
->rfapi_cfg
->rfg_redist
== rfg
)
3029 vnc_redistribute_postchange (bgp
);
3036 DEFUN (vnc_nve_group_l2rd
,
3037 vnc_nve_group_l2rd_cmd
,
3038 "l2rd <(1-255)|auto-vn>",
3039 "Specify default Local Nve ID value to use in RD for L2 routes\n"
3040 "Fixed value 1-255\n"
3041 "use the low-order octet of the NVE's VN address\n")
3043 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3044 VTY_DECLVAR_CONTEXT_SUB(rfapi_nve_group_cfg
, rfg
);
3046 /* make sure it's still in list */
3047 if (!listnode_lookup (bgp
->rfapi_cfg
->nve_groups_sequential
, rfg
))
3049 /* Not in list anymore */
3050 vty_out (vty
, "Current NVE group no longer exists%s", VTY_NEWLINE
);
3054 if (!strcmp (argv
[1]->arg
, "auto:vn"))
3061 unsigned long value_l
= strtoul (argv
[1]->arg
, &end
, 10);
3062 uint8_t value
= value_l
& 0xff;
3064 if (!argv
[1]->arg
[0] || *end
)
3066 vty_out (vty
, "%% Malformed l2 nve ID \"%s\"%s", argv
[1]->arg
,
3070 if ((value_l
< 1) || (value_l
> 0xff))
3073 "%% Malformed l2 nve id (must be greater than 0 and less than %u%s",
3074 0x100, VTY_NEWLINE
);
3080 rfg
->flags
|= RFAPI_RFG_L2RD
;
3085 DEFUN (vnc_nve_group_no_l2rd
,
3086 vnc_nve_group_no_l2rd_cmd
,
3089 "Specify default Local Nve ID value to use in RD for L2 routes\n")
3091 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3092 VTY_DECLVAR_CONTEXT_SUB(rfapi_nve_group_cfg
, rfg
);
3094 /* make sure it's still in list */
3095 if (!listnode_lookup (bgp
->rfapi_cfg
->nve_groups_sequential
, rfg
))
3097 /* Not in list anymore */
3098 vty_out (vty
, "Current NVE group no longer exists%s", VTY_NEWLINE
);
3103 rfg
->flags
&= ~RFAPI_RFG_L2RD
;
3108 DEFUN (vnc_nve_group_rd
,
3109 vnc_nve_group_rd_cmd
,
3110 "rd ASN:nn_or_IP-address:nn",
3111 "Specify route distinguisher\n"
3112 "Route Distinguisher (<as-number>:<number> | <ip-address>:<number> | auto:vn:<number> )\n")
3114 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3116 struct prefix_rd prd
;
3117 VTY_DECLVAR_CONTEXT_SUB(rfapi_nve_group_cfg
, rfg
);
3119 /* make sure it's still in list */
3120 if (!listnode_lookup (bgp
->rfapi_cfg
->nve_groups_sequential
, rfg
))
3122 /* Not in list anymore */
3123 vty_out (vty
, "Current NVE group no longer exists%s", VTY_NEWLINE
);
3127 if (!strncmp (argv
[1]->arg
, "auto:vn:", 8))
3130 * use AF_UNIX to designate automatically-assigned RD
3131 * auto:vn:nn where nn is a 2-octet quantity
3134 uint32_t value32
= strtoul (argv
[1]->arg
+ 8, &end
, 10);
3135 uint16_t value
= value32
& 0xffff;
3137 if (!argv
[1]->arg
[8] || *end
)
3139 vty_out (vty
, "%% Malformed rd%s", VTY_NEWLINE
);
3142 if (value32
> 0xffff)
3144 vty_out (vty
, "%% Malformed rd (must be less than %u%s",
3145 0x0ffff, VTY_NEWLINE
);
3149 memset (&prd
, 0, sizeof (prd
));
3150 prd
.family
= AF_UNIX
;
3152 prd
.val
[0] = (RD_TYPE_IP
>> 8) & 0x0ff;
3153 prd
.val
[1] = RD_TYPE_IP
& 0x0ff;
3154 prd
.val
[6] = (value
>> 8) & 0x0ff;
3155 prd
.val
[7] = value
& 0x0ff;
3161 ret
= str2prefix_rd (argv
[1]->arg
, &prd
);
3164 vty_out (vty
, "%% Malformed rd%s", VTY_NEWLINE
);
3169 if (bgp
->rfapi_cfg
->rfg_redist
== rfg
)
3171 vnc_redistribute_prechange (bgp
);
3176 if (bgp
->rfapi_cfg
->rfg_redist
== rfg
)
3178 vnc_redistribute_postchange (bgp
);
3183 DEFUN (vnc_nve_group_responselifetime
,
3184 vnc_nve_group_responselifetime_cmd
,
3185 "response-lifetime <LIFETIME|infinite>",
3186 "Specify response lifetime\n"
3187 "Response lifetime in seconds\n" "Infinite response lifetime\n")
3189 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3190 unsigned int rspint
;
3191 VTY_DECLVAR_CONTEXT_SUB(rfapi_nve_group_cfg
, rfg
);
3192 struct rfapi_descriptor
*rfd
;
3193 struct listnode
*hdnode
;
3195 /* make sure it's still in list */
3196 if (!listnode_lookup (bgp
->rfapi_cfg
->nve_groups_sequential
, rfg
))
3198 /* Not in list anymore */
3199 vty_out (vty
, "Current NVE group no longer exists%s", VTY_NEWLINE
);
3203 if (!strcmp (argv
[1]->arg
, "infinite"))
3205 rspint
= RFAPI_INFINITE_LIFETIME
;
3209 VTY_GET_INTEGER ("Response Lifetime", rspint
, argv
[1]->arg
);
3212 rfg
->response_lifetime
= rspint
;
3213 rfg
->flags
|= RFAPI_RFG_RESPONSE_LIFETIME
;
3215 for (ALL_LIST_ELEMENTS_RO (rfg
->nves
, hdnode
, rfd
))
3216 rfd
->response_lifetime
= rspint
;
3221 * Sigh. This command, like exit-address-family, is a hack to deal
3222 * with the lack of rigorous level control in the command handler.
3223 * TBD fix command handler.
3225 DEFUN_NOSH (exit_vnc
,
3228 "Exit VNC configuration mode\n")
3230 if (vty
->node
== BGP_VNC_DEFAULTS_NODE
||
3231 vty
->node
== BGP_VNC_NVE_GROUP_NODE
||
3232 vty
->node
== BGP_VNC_L2_GROUP_NODE
)
3235 vty
->node
= BGP_NODE
;
3240 static struct cmd_node bgp_vnc_defaults_node
= {
3241 BGP_VNC_DEFAULTS_NODE
,
3242 "%s(config-router-vnc-defaults)# ",
3246 static struct cmd_node bgp_vnc_nve_group_node
= {
3247 BGP_VNC_NVE_GROUP_NODE
,
3248 "%s(config-router-vnc-nve-group)# ",
3252 /*-------------------------------------------------------------------------
3254 * Note there are two types of NVEs, one for VPNs one for RFP NVEs
3255 *-----------------------------------------------------------------------*/
3257 DEFUN_NOSH (vnc_vrf_policy
,
3260 "Configure a VRF policy group\n"
3263 struct rfapi_nve_group_cfg
*rfg
;
3264 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3268 vty_out (vty
, "No BGP process is configured%s", VTY_NEWLINE
);
3272 /* Search for name */
3273 rfg
= bgp_rfapi_cfg_match_byname (bgp
, argv
[1]->arg
, RFAPI_GROUP_CFG_VRF
);
3277 rfg
= rfapi_group_new (bgp
, RFAPI_GROUP_CFG_VRF
, argv
[1]->arg
);
3280 /* Error out of memory */
3281 vty_out (vty
, "Can't allocate memory for NVE group%s", VTY_NEWLINE
);
3286 * XXX subsequent calls will need to make sure this item is still
3287 * in the linked list and has the same name
3289 VTY_PUSH_CONTEXT_SUB (BGP_VRF_POLICY_NODE
, rfg
);
3294 DEFUN (vnc_no_vrf_policy
,
3295 vnc_no_vrf_policy_cmd
,
3296 "no vrf-policy NAME",
3298 "Remove a VRF policy group\n"
3301 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3305 vty_out (vty
, "No BGP process is configured%s", VTY_NEWLINE
);
3308 return bgp_rfapi_delete_named_nve_group (vty
, bgp
, argv
[2]->arg
, RFAPI_GROUP_CFG_VRF
);
3311 DEFUN (vnc_vrf_policy_label
,
3312 vnc_vrf_policy_label_cmd
,
3313 "label (0-1048575)",
3314 "Default label value for VRF\n"
3315 "Label Value <0-1048575>\n")
3317 VTY_DECLVAR_CONTEXT_SUB(rfapi_nve_group_cfg
, rfg
);
3320 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3324 vty_out (vty
, "No BGP process is configured%s", VTY_NEWLINE
);
3328 /* make sure it's still in list */
3329 if (!listnode_lookup (bgp
->rfapi_cfg
->nve_groups_sequential
, rfg
))
3331 /* Not in list anymore */
3332 vty_out (vty
, "Current NVE group no longer exists%s", VTY_NEWLINE
);
3336 VTY_GET_INTEGER_RANGE ("Label value", label
, argv
[1]->arg
, 0, MPLS_LABEL_MAX
);
3338 if (bgp
->rfapi_cfg
->rfg_redist
== rfg
)
3340 vnc_redistribute_prechange (bgp
);
3345 if (bgp
->rfapi_cfg
->rfg_redist
== rfg
)
3347 vnc_redistribute_postchange (bgp
);
3352 DEFUN (vnc_vrf_policy_no_label
,
3353 vnc_vrf_policy_no_label_cmd
,
3356 "Remove VRF default label\n")
3358 VTY_DECLVAR_CONTEXT_SUB(rfapi_nve_group_cfg
, rfg
);
3359 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3361 /* make sure it's still in list */
3362 if (!listnode_lookup (bgp
->rfapi_cfg
->nve_groups_sequential
, rfg
))
3364 /* Not in list anymore */
3365 vty_out (vty
, "Current VRF group no longer exists%s", VTY_NEWLINE
);
3369 if (bgp
->rfapi_cfg
->rfg_redist
== rfg
)
3371 vnc_redistribute_prechange (bgp
);
3374 rfg
->label
= MPLS_LABEL_ILLEGAL
;
3376 if (bgp
->rfapi_cfg
->rfg_redist
== rfg
)
3378 vnc_redistribute_postchange (bgp
);
3383 DEFUN (vnc_vrf_policy_nexthop
,
3384 vnc_vrf_policy_nexthop_cmd
,
3385 "nexthop <A.B.C.D|X:X::X:X|self>",
3386 "Specify next hop to use for VRF advertised prefixes\n"
3389 "Use configured router-id (default)")
3391 VTY_DECLVAR_CONTEXT_SUB(rfapi_nve_group_cfg
, rfg
);
3394 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3396 /* make sure it's still in list */
3397 if (!listnode_lookup (bgp
->rfapi_cfg
->nve_groups_sequential
, rfg
))
3399 /* Not in list anymore */
3400 vty_out (vty
, "Current VRF no longer exists%s", VTY_NEWLINE
);
3404 if (bgp
->rfapi_cfg
->rfg_redist
== rfg
)
3406 vnc_redistribute_prechange (bgp
);
3409 if (!str2prefix (argv
[1]->arg
, &p
) && p
.family
)
3411 //vty_out (vty, "Nexthop set to self%s", VTY_NEWLINE);
3412 SET_FLAG (rfg
->flags
, RFAPI_RFG_VPN_NH_SELF
);
3413 memset(&rfg
->vn_prefix
, 0, sizeof(struct prefix
));
3417 UNSET_FLAG (rfg
->flags
, RFAPI_RFG_VPN_NH_SELF
);
3422 /* TBD handle router-id/ nexthop changes when have advertised prefixes */
3424 if (bgp
->rfapi_cfg
->rfg_redist
== rfg
)
3426 vnc_redistribute_postchange (bgp
);
3432 /* The RT code should be refactored/simplified with above... */
3433 DEFUN (vnc_vrf_policy_rt_import
,
3434 vnc_vrf_policy_rt_import_cmd
,
3435 "rt import RTLIST...",
3436 "Specify route targets\n"
3438 "Space separated route target list (A.B.C.D:MN|EF:OPQR|GHJK:MN)\n")
3440 VTY_DECLVAR_CONTEXT_SUB(rfapi_nve_group_cfg
, rfg
);
3441 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3443 struct listnode
*node
;
3444 struct rfapi_rfg_name
*rfgn
;
3445 int is_export_bgp
= 0;
3446 int is_export_zebra
= 0;
3450 vty_out (vty
, "No BGP process is configured%s", VTY_NEWLINE
);
3454 /* make sure it's still in list */
3455 if (!listnode_lookup (bgp
->rfapi_cfg
->nve_groups_sequential
, rfg
))
3457 /* Not in list anymore */
3458 vty_out (vty
, "Current NVE group no longer exists%s", VTY_NEWLINE
);
3462 rc
= set_ecom_list (vty
, argc
-2, argv
+2, &rfg
->rt_import_list
);
3463 if (rc
!= CMD_SUCCESS
)
3466 for (ALL_LIST_ELEMENTS_RO (bgp
->rfapi_cfg
->rfg_export_direct_bgp_l
,
3470 if (rfgn
->rfg
== rfg
)
3478 vnc_direct_bgp_del_group (bgp
, rfg
);
3480 for (ALL_LIST_ELEMENTS_RO (bgp
->rfapi_cfg
->rfg_export_zebra_l
, node
, rfgn
))
3483 if (rfgn
->rfg
== rfg
)
3485 is_export_zebra
= 1;
3490 if (is_export_zebra
)
3491 vnc_zebra_del_group (bgp
, rfg
);
3494 * stop referencing old import table, now reference new one
3496 if (rfg
->rfapi_import_table
)
3497 rfapiImportTableRefDelByIt (bgp
, rfg
->rfapi_import_table
);
3498 rfg
->rfapi_import_table
= rfapiImportTableRefAdd (bgp
, rfg
->rt_import_list
, rfg
);
3501 vnc_direct_bgp_add_group (bgp
, rfg
);
3503 if (is_export_zebra
)
3504 vnc_zebra_add_group (bgp
, rfg
);
3509 DEFUN (vnc_vrf_policy_rt_export
,
3510 vnc_vrf_policy_rt_export_cmd
,
3511 "rt export RTLIST...",
3512 "Specify route targets\n"
3514 "Space separated route target list (A.B.C.D:MN|EF:OPQR|GHJK:MN)\n")
3516 VTY_DECLVAR_CONTEXT_SUB(rfapi_nve_group_cfg
, rfg
);
3517 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3522 vty_out (vty
, "No BGP process is configured%s", VTY_NEWLINE
);
3526 /* make sure it's still in list */
3527 if (!listnode_lookup (bgp
->rfapi_cfg
->nve_groups_sequential
, rfg
))
3529 /* Not in list anymore */
3530 vty_out (vty
, "Current NVE group no longer exists%s", VTY_NEWLINE
);
3534 if (bgp
->rfapi_cfg
->rfg_redist
== rfg
)
3536 vnc_redistribute_prechange (bgp
);
3539 rc
= set_ecom_list (vty
, argc
-2, argv
+2, &rfg
->rt_export_list
);
3541 if (bgp
->rfapi_cfg
->rfg_redist
== rfg
)
3543 vnc_redistribute_postchange (bgp
);
3549 DEFUN (vnc_vrf_policy_rt_both
,
3550 vnc_vrf_policy_rt_both_cmd
,
3551 "rt both RTLIST...",
3552 "Specify route targets\n"
3553 "Export+import filters\n"
3554 "Space separated route target list (A.B.C.D:MN|EF:OPQR|GHJK:MN)\n")
3556 VTY_DECLVAR_CONTEXT_SUB(rfapi_nve_group_cfg
, rfg
);
3557 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3559 int is_export_bgp
= 0;
3560 int is_export_zebra
= 0;
3561 struct listnode
*node
;
3562 struct rfapi_rfg_name
*rfgn
;
3566 vty_out (vty
, "No BGP process is configured%s", VTY_NEWLINE
);
3570 /* make sure it's still in list */
3571 if (!listnode_lookup (bgp
->rfapi_cfg
->nve_groups_sequential
, rfg
))
3573 /* Not in list anymore */
3574 vty_out (vty
, "Current NVE group no longer exists%s", VTY_NEWLINE
);
3578 rc
= set_ecom_list (vty
, argc
-2, argv
+2, &rfg
->rt_import_list
);
3579 if (rc
!= CMD_SUCCESS
)
3582 for (ALL_LIST_ELEMENTS_RO (bgp
->rfapi_cfg
->rfg_export_direct_bgp_l
,
3586 if (rfgn
->rfg
== rfg
)
3594 vnc_direct_bgp_del_group (bgp
, rfg
);
3596 for (ALL_LIST_ELEMENTS_RO (bgp
->rfapi_cfg
->rfg_export_zebra_l
, node
, rfgn
))
3599 if (rfgn
->rfg
== rfg
)
3601 is_export_zebra
= 1;
3606 if (is_export_zebra
)
3608 vnc_zlog_debug_verbose ("%s: is_export_zebra", __func__
);
3609 vnc_zebra_del_group (bgp
, rfg
);
3613 * stop referencing old import table, now reference new one
3615 if (rfg
->rfapi_import_table
)
3616 rfapiImportTableRefDelByIt (bgp
, rfg
->rfapi_import_table
);
3617 rfg
->rfapi_import_table
= rfapiImportTableRefAdd (bgp
, rfg
->rt_import_list
, rfg
);
3620 vnc_direct_bgp_add_group (bgp
, rfg
);
3622 if (is_export_zebra
)
3623 vnc_zebra_add_group (bgp
, rfg
);
3625 if (bgp
->rfapi_cfg
->rfg_redist
== rfg
)
3627 vnc_redistribute_prechange (bgp
);
3630 rc
= set_ecom_list (vty
, argc
-2, argv
+2, &rfg
->rt_export_list
);
3632 if (bgp
->rfapi_cfg
->rfg_redist
== rfg
)
3634 vnc_redistribute_postchange (bgp
);
3641 DEFUN (vnc_vrf_policy_rd
,
3642 vnc_vrf_policy_rd_cmd
,
3643 "rd ASN:nn_or_IP-address:nn",
3644 "Specify default VRF route distinguisher\n"
3645 "Route Distinguisher (<as-number>:<number> | <ip-address>:<number> | auto:nh:<number> )\n")
3648 struct prefix_rd prd
;
3649 VTY_DECLVAR_CONTEXT_SUB(rfapi_nve_group_cfg
, rfg
);
3650 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3654 vty_out (vty
, "No BGP process is configured%s", VTY_NEWLINE
);
3658 /* make sure it's still in list */
3659 if (!listnode_lookup (bgp
->rfapi_cfg
->nve_groups_sequential
, rfg
))
3661 /* Not in list anymore */
3662 vty_out (vty
, "Current NVE group no longer exists%s", VTY_NEWLINE
);
3666 if (!strncmp (argv
[1]->arg
, "auto:nh:", 8))
3669 * use AF_UNIX to designate automatically-assigned RD
3670 * auto:vn:nn where nn is a 2-octet quantity
3673 uint32_t value32
= strtoul (argv
[1]->arg
+ 8, &end
, 10);
3674 uint16_t value
= value32
& 0xffff;
3676 if (!*(argv
[1]->arg
+ 5) || *end
)
3678 vty_out (vty
, "%% Malformed rd%s", VTY_NEWLINE
);
3681 if (value32
> 0xffff)
3683 vty_out (vty
, "%% Malformed rd (must be less than %u%s",
3684 0x0ffff, VTY_NEWLINE
);
3688 memset (&prd
, 0, sizeof (prd
));
3689 prd
.family
= AF_UNIX
;
3691 prd
.val
[0] = (RD_TYPE_IP
>> 8) & 0x0ff;
3692 prd
.val
[1] = RD_TYPE_IP
& 0x0ff;
3693 prd
.val
[6] = (value
>> 8) & 0x0ff;
3694 prd
.val
[7] = value
& 0x0ff;
3700 ret
= str2prefix_rd (argv
[1]->arg
, &prd
);
3703 vty_out (vty
, "%% Malformed rd%s", VTY_NEWLINE
);
3708 if (bgp
->rfapi_cfg
->rfg_redist
== rfg
)
3710 vnc_redistribute_prechange (bgp
);
3715 if (bgp
->rfapi_cfg
->rfg_redist
== rfg
)
3717 vnc_redistribute_postchange (bgp
);
3722 DEFUN_NOSH (exit_vrf_policy
,
3723 exit_vrf_policy_cmd
,
3725 "Exit VRF policy configuration mode\n")
3727 if (vty
->node
== BGP_VRF_POLICY_NODE
)
3729 vty
->node
= BGP_NODE
;
3734 static struct cmd_node bgp_vrf_policy_node
= {
3735 BGP_VRF_POLICY_NODE
,
3736 "%s(config-router-vrf-policy)# ",
3740 /*-------------------------------------------------------------------------
3742 *-----------------------------------------------------------------------*/
3745 DEFUN_NOSH (vnc_l2_group
,
3747 "vnc l2-group NAME",
3748 VNC_CONFIG_STR
"Configure a L2 group\n" "Group name\n")
3750 struct rfapi_l2_group_cfg
*rfg
;
3751 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3755 vty_out (vty
, "No BGP process is configured%s", VTY_NEWLINE
);
3759 /* Search for name */
3760 rfg
= rfapi_l2_group_lookup_byname (bgp
, argv
[1]->arg
);
3764 rfg
= rfapi_l2_group_new ();
3767 /* Error out of memory */
3768 vty_out (vty
, "Can't allocate memory for L2 group%s", VTY_NEWLINE
);
3771 rfg
->name
= strdup (argv
[1]->arg
);
3772 /* add to tail of list */
3773 listnode_add (bgp
->rfapi_cfg
->l2_groups
, rfg
);
3777 * XXX subsequent calls will need to make sure this item is still
3778 * in the linked list and has the same name
3780 VTY_PUSH_CONTEXT_SUB (BGP_VNC_L2_GROUP_NODE
, rfg
);
3785 bgp_rfapi_delete_l2_group (
3786 struct vty
*vty
, /* NULL = no output */
3788 struct rfapi_l2_group_cfg
*rfg
)
3792 if (rfg
->rt_import_list
)
3793 ecommunity_free (&rfg
->rt_import_list
);
3794 if (rfg
->rt_export_list
)
3795 ecommunity_free (&rfg
->rt_export_list
);
3797 list_delete (rfg
->labels
);
3799 XFREE (MTYPE_RFAPI_RFP_GROUP_CFG
, rfg
->rfp_cfg
);
3800 listnode_delete (bgp
->rfapi_cfg
->l2_groups
, rfg
);
3802 rfapi_l2_group_del (rfg
);
3806 bgp_rfapi_delete_named_l2_group (
3807 struct vty
*vty
, /* NULL = no output */
3809 const char *rfg_name
) /* NULL = any */
3811 struct rfapi_l2_group_cfg
*rfg
= NULL
;
3812 struct listnode
*node
, *nnode
;
3814 /* Search for name */
3817 rfg
= rfapi_l2_group_lookup_byname (bgp
, rfg_name
);
3821 vty_out (vty
, "No L2 group named \"%s\"%s", rfg_name
,
3828 bgp_rfapi_delete_l2_group (vty
, bgp
, rfg
);
3829 else /* must be delete all */
3830 for (ALL_LIST_ELEMENTS (bgp
->rfapi_cfg
->l2_groups
, node
, nnode
, rfg
))
3831 bgp_rfapi_delete_l2_group (vty
, bgp
, rfg
);
3835 DEFUN (vnc_no_l2_group
,
3836 vnc_no_l2_group_cmd
,
3837 "no vnc l2-group NAME",
3840 "Configure a L2 group\n"
3843 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3847 vty_out (vty
, "No BGP process is configured%s", VTY_NEWLINE
);
3850 return bgp_rfapi_delete_named_l2_group (vty
, bgp
, argv
[3]->arg
);
3854 DEFUN (vnc_l2_group_lni
,
3855 vnc_l2_group_lni_cmd
,
3856 "logical-network-id <0-4294967295>",
3857 "Specify Logical Network ID associated with group\n"
3860 VTY_DECLVAR_CONTEXT_SUB(rfapi_l2_group_cfg
, rfg
);
3861 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3865 vty_out (vty
, "No BGP process is configured%s", VTY_NEWLINE
);
3869 /* make sure it's still in list */
3870 if (!listnode_lookup (bgp
->rfapi_cfg
->l2_groups
, rfg
))
3872 /* Not in list anymore */
3873 vty_out (vty
, "Current L2 group no longer exists%s", VTY_NEWLINE
);
3877 VTY_GET_INTEGER ("logical-network-id", rfg
->logical_net_id
, argv
[1]->arg
);
3882 DEFUN (vnc_l2_group_labels
,
3883 vnc_l2_group_labels_cmd
,
3884 "labels LABELLIST...",
3885 "Specify label values associated with group\n"
3886 "Space separated list of label values <0-1048575>\n")
3888 VTY_DECLVAR_CONTEXT_SUB(rfapi_l2_group_cfg
, rfg
);
3889 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3894 vty_out (vty
, "No BGP process is configured%s", VTY_NEWLINE
);
3898 /* make sure it's still in list */
3899 if (!listnode_lookup (bgp
->rfapi_cfg
->l2_groups
, rfg
))
3901 /* Not in list anymore */
3902 vty_out (vty
, "Current L2 group no longer exists%s", VTY_NEWLINE
);
3914 for (; argc
; --argc
, ++argv
)
3917 VTY_GET_INTEGER_RANGE ("Label value", label
, argv
[0]->arg
, 0, MPLS_LABEL_MAX
);
3918 if (!listnode_lookup (ll
, (void *) (uintptr_t) label
))
3919 listnode_add (ll
, (void *) (uintptr_t) label
);
3925 DEFUN (vnc_l2_group_no_labels
,
3926 vnc_l2_group_no_labels_cmd
,
3927 "no labels LABELLIST...",
3929 "Remove label values associated with L2 group\n"
3930 "Specify label values associated with L2 group\n"
3931 "Space separated list of label values <0-1048575>\n")
3933 VTY_DECLVAR_CONTEXT_SUB(rfapi_l2_group_cfg
, rfg
);
3934 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3939 vty_out (vty
, "No BGP process is configured%s", VTY_NEWLINE
);
3943 /* make sure it's still in list */
3944 if (!listnode_lookup (bgp
->rfapi_cfg
->l2_groups
, rfg
))
3946 /* Not in list anymore */
3947 vty_out (vty
, "Current L2 group no longer exists%s", VTY_NEWLINE
);
3954 vty_out (vty
, "Label no longer associated with group%s", VTY_NEWLINE
);
3960 for (; argc
; --argc
, ++argv
)
3963 VTY_GET_INTEGER_RANGE ("Label value", label
, argv
[0]->arg
, 0, MPLS_LABEL_MAX
);
3964 listnode_delete (ll
, (void *) (uintptr_t) label
);
3970 DEFUN (vnc_l2_group_rt
,
3971 vnc_l2_group_rt_cmd
,
3972 "rt <both|export|import> ASN:nn_or_IP-address:nn",
3973 "Specify route targets\n"
3974 "Export+import filters\n"
3979 VTY_DECLVAR_CONTEXT_SUB(rfapi_l2_group_cfg
, rfg
);
3980 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3981 int rc
= CMD_SUCCESS
;
3985 switch (argv
[1]->arg
[0])
3988 do_export
= 1; /* fall through */
3996 vty_out (vty
, "Unknown option, %s%s", argv
[1]->arg
, VTY_NEWLINE
);
3997 return CMD_ERR_NO_MATCH
;
4002 vty_out (vty
, "No BGP process is configured%s", VTY_NEWLINE
);
4006 /* make sure it's still in list */
4007 if (!listnode_lookup (bgp
->rfapi_cfg
->l2_groups
, rfg
))
4009 /* Not in list anymore */
4010 vty_out (vty
, "Current L2 group no longer exists%s", VTY_NEWLINE
);
4015 rc
= set_ecom_list (vty
, argc
-2, argv
+2, &rfg
->rt_import_list
);
4016 if (rc
== CMD_SUCCESS
&& do_export
)
4017 rc
= set_ecom_list (vty
, argc
-2, argv
+2, &rfg
->rt_export_list
);
4022 static struct cmd_node bgp_vnc_l2_group_node
= {
4023 BGP_VNC_L2_GROUP_NODE
,
4024 "%s(config-router-vnc-l2-group)# ",
4028 struct rfapi_l2_group_cfg
*
4029 bgp_rfapi_get_group_by_lni_label (
4031 uint32_t logical_net_id
,
4034 struct rfapi_l2_group_cfg
*rfg
;
4035 struct listnode
*node
;
4037 if (bgp
->rfapi_cfg
->l2_groups
== NULL
) /* not the best place for this */
4040 label
= label
& 0xfffff; /* label is 20 bits! */
4042 for (ALL_LIST_ELEMENTS_RO (bgp
->rfapi_cfg
->l2_groups
, node
, rfg
))
4044 if (rfg
->logical_net_id
== logical_net_id
)
4046 struct listnode
*lnode
;
4048 for (ALL_LIST_ELEMENTS_RO (rfg
->labels
, lnode
, data
))
4049 if (((uint32_t) ((uintptr_t) data
)) == label
)
4059 bgp_rfapi_get_labellist_by_lni_label (
4061 uint32_t logical_net_id
,
4064 struct rfapi_l2_group_cfg
*rfg
;
4065 rfg
= bgp_rfapi_get_group_by_lni_label (bgp
, logical_net_id
, label
);
4074 bgp_rfapi_get_ecommunity_by_lni_label (
4077 uint32_t logical_net_id
,
4080 struct rfapi_l2_group_cfg
*rfg
;
4081 rfg
= bgp_rfapi_get_group_by_lni_label (bgp
, logical_net_id
, label
);
4085 return rfg
->rt_import_list
;
4087 return rfg
->rt_export_list
;
4093 bgp_rfapi_cfg_init (void)
4095 /* main bgpd code does not use this hook, but vnc does */
4096 route_map_event_hook (vnc_routemap_event
);
4098 install_node (&bgp_vnc_defaults_node
, NULL
);
4099 install_node (&bgp_vnc_nve_group_node
, NULL
);
4100 install_node (&bgp_vrf_policy_node
, NULL
);
4101 install_node (&bgp_vnc_l2_group_node
, NULL
);
4102 install_default (BGP_VRF_POLICY_NODE
);
4103 install_default (BGP_VNC_DEFAULTS_NODE
);
4104 install_default (BGP_VNC_NVE_GROUP_NODE
);
4105 install_default (BGP_VNC_L2_GROUP_NODE
);
4110 install_element (BGP_NODE
, &vnc_defaults_cmd
);
4111 install_element (BGP_NODE
, &vnc_nve_group_cmd
);
4112 install_element (BGP_NODE
, &vnc_no_nve_group_cmd
);
4113 install_element (BGP_NODE
, &vnc_vrf_policy_cmd
);
4114 install_element (BGP_NODE
, &vnc_no_vrf_policy_cmd
);
4115 install_element (BGP_NODE
, &vnc_l2_group_cmd
);
4116 install_element (BGP_NODE
, &vnc_no_l2_group_cmd
);
4117 install_element (BGP_NODE
, &vnc_advertise_un_method_cmd
);
4118 install_element (BGP_NODE
, &vnc_export_mode_cmd
);
4120 install_element (BGP_VNC_DEFAULTS_NODE
, &vnc_defaults_rt_import_cmd
);
4121 install_element (BGP_VNC_DEFAULTS_NODE
, &vnc_defaults_rt_export_cmd
);
4122 install_element (BGP_VNC_DEFAULTS_NODE
, &vnc_defaults_rt_both_cmd
);
4123 install_element (BGP_VNC_DEFAULTS_NODE
, &vnc_defaults_rd_cmd
);
4124 install_element (BGP_VNC_DEFAULTS_NODE
, &vnc_defaults_l2rd_cmd
);
4125 install_element (BGP_VNC_DEFAULTS_NODE
, &vnc_defaults_no_l2rd_cmd
);
4126 install_element (BGP_VNC_DEFAULTS_NODE
, &vnc_defaults_responselifetime_cmd
);
4127 install_element (BGP_VNC_DEFAULTS_NODE
, &exit_vnc_cmd
);
4129 install_element (BGP_NODE
, &vnc_redistribute_protocol_cmd
);
4130 install_element (BGP_NODE
, &vnc_no_redistribute_protocol_cmd
);
4131 install_element (BGP_NODE
, &vnc_redistribute_nvegroup_cmd
);
4132 install_element (BGP_NODE
, &vnc_redistribute_no_nvegroup_cmd
);
4133 install_element (BGP_NODE
, &vnc_redistribute_lifetime_cmd
);
4134 install_element (BGP_NODE
, &vnc_redistribute_rh_roo_localadmin_cmd
);
4135 install_element (BGP_NODE
, &vnc_redistribute_mode_cmd
);
4136 install_element (BGP_NODE
, &vnc_redistribute_bgp_exterior_cmd
);
4138 install_element (BGP_NODE
, &vnc_redist_bgpdirect_no_prefixlist_cmd
);
4139 install_element (BGP_NODE
, &vnc_redist_bgpdirect_prefixlist_cmd
);
4140 install_element (BGP_NODE
, &vnc_redist_bgpdirect_no_routemap_cmd
);
4141 install_element (BGP_NODE
, &vnc_redist_bgpdirect_routemap_cmd
);
4143 install_element (BGP_VNC_NVE_GROUP_NODE
,
4144 &vnc_nve_group_redist_bgpdirect_no_prefixlist_cmd
);
4145 install_element (BGP_VNC_NVE_GROUP_NODE
,
4146 &vnc_nve_group_redist_bgpdirect_prefixlist_cmd
);
4147 install_element (BGP_VNC_NVE_GROUP_NODE
,
4148 &vnc_nve_group_redist_bgpdirect_no_routemap_cmd
);
4149 install_element (BGP_VNC_NVE_GROUP_NODE
,
4150 &vnc_nve_group_redist_bgpdirect_routemap_cmd
);
4152 install_element (BGP_NODE
, &vnc_export_nvegroup_cmd
);
4153 install_element (BGP_NODE
, &vnc_no_export_nvegroup_cmd
);
4154 install_element (BGP_NODE
, &vnc_nve_export_prefixlist_cmd
);
4155 install_element (BGP_NODE
, &vnc_nve_export_routemap_cmd
);
4156 install_element (BGP_NODE
, &vnc_nve_export_no_prefixlist_cmd
);
4157 install_element (BGP_NODE
, &vnc_nve_export_no_routemap_cmd
);
4159 install_element (BGP_VNC_NVE_GROUP_NODE
, &vnc_nve_group_l2rd_cmd
);
4160 install_element (BGP_VNC_NVE_GROUP_NODE
, &vnc_nve_group_no_l2rd_cmd
);
4161 install_element (BGP_VNC_NVE_GROUP_NODE
, &vnc_nve_group_prefix_cmd
);
4162 install_element (BGP_VNC_NVE_GROUP_NODE
, &vnc_nve_group_rt_import_cmd
);
4163 install_element (BGP_VNC_NVE_GROUP_NODE
, &vnc_nve_group_rt_export_cmd
);
4164 install_element (BGP_VNC_NVE_GROUP_NODE
, &vnc_nve_group_rt_both_cmd
);
4165 install_element (BGP_VNC_NVE_GROUP_NODE
, &vnc_nve_group_rd_cmd
);
4166 install_element (BGP_VNC_NVE_GROUP_NODE
,
4167 &vnc_nve_group_responselifetime_cmd
);
4168 install_element (BGP_VNC_NVE_GROUP_NODE
,
4169 &vnc_nve_group_export_prefixlist_cmd
);
4170 install_element (BGP_VNC_NVE_GROUP_NODE
,
4171 &vnc_nve_group_export_routemap_cmd
);
4172 install_element (BGP_VNC_NVE_GROUP_NODE
,
4173 &vnc_nve_group_export_no_prefixlist_cmd
);
4174 install_element (BGP_VNC_NVE_GROUP_NODE
,
4175 &vnc_nve_group_export_no_routemap_cmd
);
4176 install_element (BGP_VNC_NVE_GROUP_NODE
, &exit_vnc_cmd
);
4178 install_element (BGP_VRF_POLICY_NODE
, &vnc_vrf_policy_label_cmd
);
4179 install_element (BGP_VRF_POLICY_NODE
, &vnc_vrf_policy_no_label_cmd
);
4180 //Reenable to support VRF controller use case and testing
4181 install_element (BGP_VRF_POLICY_NODE
, &vnc_vrf_policy_nexthop_cmd
);
4182 install_element (BGP_VRF_POLICY_NODE
, &vnc_vrf_policy_rt_import_cmd
);
4183 install_element (BGP_VRF_POLICY_NODE
, &vnc_vrf_policy_rt_export_cmd
);
4184 install_element (BGP_VRF_POLICY_NODE
, &vnc_vrf_policy_rt_both_cmd
);
4185 install_element (BGP_VRF_POLICY_NODE
, &vnc_vrf_policy_rd_cmd
);
4186 install_element (BGP_VRF_POLICY_NODE
, &exit_vrf_policy_cmd
);
4188 install_element (BGP_VNC_L2_GROUP_NODE
, &vnc_l2_group_lni_cmd
);
4189 install_element (BGP_VNC_L2_GROUP_NODE
, &vnc_l2_group_labels_cmd
);
4190 install_element (BGP_VNC_L2_GROUP_NODE
, &vnc_l2_group_no_labels_cmd
);
4191 install_element (BGP_VNC_L2_GROUP_NODE
, &vnc_l2_group_rt_cmd
);
4192 install_element (BGP_VNC_L2_GROUP_NODE
, &exit_vnc_cmd
);
4196 bgp_rfapi_cfg_new (struct rfapi_rfp_cfg
*cfg
)
4198 struct rfapi_cfg
*h
;
4202 (struct rfapi_cfg
*) XCALLOC (MTYPE_RFAPI_CFG
, sizeof (struct rfapi_cfg
));
4205 h
->nve_groups_sequential
= list_new ();
4206 assert (h
->nve_groups_sequential
);
4208 for (afi
= AFI_IP
; afi
< AFI_MAX
; afi
++)
4210 /* ugly, to deal with addition of delegates, part of 0.99.24.1 merge */
4211 h
->nve_groups_vn
[afi
].delegate
= route_table_get_default_delegate ();
4212 h
->nve_groups_un
[afi
].delegate
= route_table_get_default_delegate ();
4214 h
->default_response_lifetime
= BGP_VNC_DEFAULT_RESPONSE_LIFETIME_DEFAULT
;
4215 h
->rfg_export_direct_bgp_l
= list_new ();
4216 h
->rfg_export_zebra_l
= list_new ();
4217 h
->resolve_nve_roo_local_admin
=
4218 BGP_VNC_CONFIG_RESOLVE_NVE_ROO_LOCAL_ADMIN_DEFAULT
;
4220 SET_FLAG (h
->flags
, BGP_VNC_CONFIG_FLAGS_DEFAULT
);
4224 h
->rfp_cfg
.download_type
= RFAPI_RFP_DOWNLOAD_PARTIAL
;
4225 h
->rfp_cfg
.ftd_advertisement_interval
=
4226 RFAPI_RFP_CFG_DEFAULT_FTD_ADVERTISEMENT_INTERVAL
;
4227 h
->rfp_cfg
.holddown_factor
= RFAPI_RFP_CFG_DEFAULT_HOLDDOWN_FACTOR
;
4228 h
->rfp_cfg
.use_updated_response
= 0;
4229 h
->rfp_cfg
.use_removes
= 0;
4233 h
->rfp_cfg
.download_type
= cfg
->download_type
;
4234 h
->rfp_cfg
.ftd_advertisement_interval
= cfg
->ftd_advertisement_interval
;
4235 h
->rfp_cfg
.holddown_factor
= cfg
->holddown_factor
;
4236 h
->rfp_cfg
.use_updated_response
= cfg
->use_updated_response
;
4237 h
->rfp_cfg
.use_removes
= cfg
->use_removes
;
4238 if (cfg
->use_updated_response
)
4239 h
->flags
&= ~BGP_VNC_CONFIG_CALLBACK_DISABLE
;
4241 h
->flags
|= BGP_VNC_CONFIG_CALLBACK_DISABLE
;
4242 if (cfg
->use_removes
)
4243 h
->flags
&= ~BGP_VNC_CONFIG_RESPONSE_REMOVAL_DISABLE
;
4245 h
->flags
|= BGP_VNC_CONFIG_RESPONSE_REMOVAL_DISABLE
;
4251 bgp_rfapi_cfg_destroy (struct bgp
*bgp
, struct rfapi_cfg
*h
)
4256 bgp_rfapi_delete_named_nve_group (NULL
, bgp
, NULL
, RFAPI_GROUP_CFG_MAX
);
4257 bgp_rfapi_delete_named_l2_group (NULL
, bgp
, NULL
);
4258 if (h
->l2_groups
!= NULL
)
4259 list_delete (h
->l2_groups
);
4260 list_delete (h
->nve_groups_sequential
);
4261 list_delete (h
->rfg_export_direct_bgp_l
);
4262 list_delete (h
->rfg_export_zebra_l
);
4263 if (h
->default_rt_export_list
)
4264 ecommunity_free (&h
->default_rt_export_list
);
4265 if (h
->default_rt_import_list
)
4266 ecommunity_free (&h
->default_rt_import_list
);
4267 if (h
->default_rfp_cfg
)
4268 XFREE (MTYPE_RFAPI_RFP_GROUP_CFG
, h
->default_rfp_cfg
);
4269 XFREE (MTYPE_RFAPI_CFG
, h
);
4274 bgp_rfapi_cfg_write (struct vty
*vty
, struct bgp
*bgp
)
4276 struct listnode
*node
, *nnode
;
4277 struct rfapi_nve_group_cfg
*rfg
;
4278 struct rfapi_cfg
*hc
= bgp
->rfapi_cfg
;
4279 struct rfapi_rfg_name
*rfgn
;
4283 if (bgp
->rfapi
== NULL
|| hc
== NULL
)
4286 vty_out (vty
, "!%s", VTY_NEWLINE
);
4287 for (ALL_LIST_ELEMENTS (hc
->nve_groups_sequential
, node
, nnode
, rfg
))
4288 if (rfg
->type
== RFAPI_GROUP_CFG_VRF
)
4291 vty_out (vty
, " vrf-policy %s%s", rfg
->name
, VTY_NEWLINE
);
4292 if (rfg
->label
<= MPLS_LABEL_MAX
)
4294 vty_out (vty
, " label %u%s", rfg
->label
, VTY_NEWLINE
);
4297 if (CHECK_FLAG (rfg
->flags
, RFAPI_RFG_VPN_NH_SELF
))
4299 vty_out (vty
, " nexthop self%s", VTY_NEWLINE
);
4304 if (rfg
->vn_prefix
.family
)
4307 buf
[0] = buf
[BUFSIZ
- 1] = 0;
4308 inet_ntop(rfg
->vn_prefix
.family
, &rfg
->vn_prefix
.u
.prefix
, buf
, sizeof(buf
));
4309 if (!buf
[0] || buf
[BUFSIZ
- 1])
4311 //vty_out (vty, "nexthop self%s", VTY_NEWLINE);
4315 vty_out (vty
, " nexthop %s%s", buf
, VTY_NEWLINE
);
4320 if (rfg
->rd
.prefixlen
)
4323 buf
[0] = buf
[BUFSIZ
- 1] = 0;
4325 if (AF_UNIX
== rfg
->rd
.family
)
4330 value
= ((rfg
->rd
.val
[6] << 8) & 0x0ff00) |
4331 (rfg
->rd
.val
[7] & 0x0ff);
4333 vty_out (vty
, " rd auto:nh:%d%s", value
, VTY_NEWLINE
);
4339 if (!prefix_rd2str (&rfg
->rd
, buf
, BUFSIZ
) ||
4340 !buf
[0] || buf
[BUFSIZ
- 1])
4343 vty_out (vty
, "!Error: Can't convert rd%s", VTY_NEWLINE
);
4347 vty_out (vty
, " rd %s%s", buf
, VTY_NEWLINE
);
4352 if (rfg
->rt_import_list
&& rfg
->rt_export_list
&&
4353 ecommunity_cmp (rfg
->rt_import_list
, rfg
->rt_export_list
))
4355 char *b
= ecommunity_ecom2str (rfg
->rt_import_list
,
4356 ECOMMUNITY_FORMAT_ROUTE_MAP
, ECOMMUNITY_ROUTE_TARGET
);
4357 vty_out (vty
, " rt both %s%s", b
, VTY_NEWLINE
);
4358 XFREE (MTYPE_ECOMMUNITY_STR
, b
);
4362 if (rfg
->rt_import_list
)
4364 char *b
= ecommunity_ecom2str (rfg
->rt_import_list
,
4365 ECOMMUNITY_FORMAT_ROUTE_MAP
, ECOMMUNITY_ROUTE_TARGET
);
4366 vty_out (vty
, " rt import %s%s", b
, VTY_NEWLINE
);
4367 XFREE (MTYPE_ECOMMUNITY_STR
, b
);
4369 if (rfg
->rt_export_list
)
4371 char *b
= ecommunity_ecom2str (rfg
->rt_export_list
,
4372 ECOMMUNITY_FORMAT_ROUTE_MAP
, ECOMMUNITY_ROUTE_TARGET
);
4373 vty_out (vty
, " rt export %s%s", b
, VTY_NEWLINE
);
4374 XFREE (MTYPE_ECOMMUNITY_STR
, b
);
4379 * route filtering: prefix-lists and route-maps
4381 for (afi
= AFI_IP
; afi
< AFI_MAX
; ++afi
)
4384 const char *afistr
= (afi
== AFI_IP
) ? "ipv4" : "ipv6";
4386 if (rfg
->plist_export_bgp_name
[afi
])
4388 vty_out (vty
, " export bgp %s prefix-list %s%s",
4389 afistr
, rfg
->plist_export_bgp_name
[afi
],
4392 if (rfg
->plist_export_zebra_name
[afi
])
4394 vty_out (vty
, " export zebra %s prefix-list %s%s",
4395 afistr
, rfg
->plist_export_zebra_name
[afi
],
4399 * currently we only support redist plists for bgp-direct.
4400 * If we later add plist support for redistributing other
4401 * protocols, we'll need to loop over protocols here
4403 if (rfg
->plist_redist_name
[ZEBRA_ROUTE_BGP_DIRECT
][afi
])
4405 vty_out (vty
, " redistribute bgp-direct %s prefix-list %s%s",
4407 rfg
->plist_redist_name
[ZEBRA_ROUTE_BGP_DIRECT
][afi
],
4410 if (rfg
->plist_redist_name
[ZEBRA_ROUTE_BGP_DIRECT_EXT
][afi
])
4413 " redistribute bgp-direct-to-nve-groups %s prefix-list %s%s",
4415 rfg
->plist_redist_name
[ZEBRA_ROUTE_BGP_DIRECT_EXT
]
4416 [afi
], VTY_NEWLINE
);
4420 if (rfg
->routemap_export_bgp_name
)
4422 vty_out (vty
, " export bgp route-map %s%s",
4423 rfg
->routemap_export_bgp_name
, VTY_NEWLINE
);
4425 if (rfg
->routemap_export_zebra_name
)
4427 vty_out (vty
, " export zebra route-map %s%s",
4428 rfg
->routemap_export_zebra_name
, VTY_NEWLINE
);
4430 if (rfg
->routemap_redist_name
[ZEBRA_ROUTE_BGP_DIRECT
])
4432 vty_out (vty
, " redistribute bgp-direct route-map %s%s",
4433 rfg
->routemap_redist_name
[ZEBRA_ROUTE_BGP_DIRECT
],
4436 if (rfg
->routemap_redist_name
[ZEBRA_ROUTE_BGP_DIRECT_EXT
])
4439 " redistribute bgp-direct-to-nve-groups route-map %s%s",
4440 rfg
->routemap_redist_name
[ZEBRA_ROUTE_BGP_DIRECT_EXT
],
4443 vty_out (vty
, " exit-vrf-policy%s", VTY_NEWLINE
);
4444 vty_out (vty
, "!%s", VTY_NEWLINE
);
4446 if (hc
->flags
& BGP_VNC_CONFIG_ADV_UN_METHOD_ENCAP
)
4448 vty_out (vty
, " vnc advertise-un-method encap-safi%s", VTY_NEWLINE
);
4452 { /* was based on listen ports */
4453 /* for now allow both old and new */
4454 if (bgp
->rfapi
->rfp_methods
.cfg_cb
)
4455 write
+= (bgp
->rfapi
->rfp_methods
.cfg_cb
) (vty
, bgp
->rfapi
->rfp
);
4458 vty_out (vty
, "!%s", VTY_NEWLINE
);
4462 struct rfapi_l2_group_cfg
*rfg
= NULL
;
4463 struct listnode
*gnode
;
4464 for (ALL_LIST_ELEMENTS_RO (hc
->l2_groups
, gnode
, rfg
))
4466 struct listnode
*lnode
;
4469 vty_out (vty
, " vnc l2-group %s%s", rfg
->name
, VTY_NEWLINE
);
4470 if (rfg
->logical_net_id
!= 0)
4471 vty_out (vty
, " logical-network-id %u%s", rfg
->logical_net_id
,
4473 if (rfg
->labels
!= NULL
&& listhead (rfg
->labels
) != NULL
)
4475 vty_out (vty
, " labels ");
4476 for (ALL_LIST_ELEMENTS_RO (rfg
->labels
, lnode
, data
))
4478 vty_out (vty
, "%hu ", (uint16_t) ((uintptr_t) data
));
4480 vty_out (vty
, "%s", VTY_NEWLINE
);
4483 if (rfg
->rt_import_list
&& rfg
->rt_export_list
&&
4484 ecommunity_cmp (rfg
->rt_import_list
, rfg
->rt_export_list
))
4486 char *b
= ecommunity_ecom2str (rfg
->rt_import_list
,
4487 ECOMMUNITY_FORMAT_ROUTE_MAP
, ECOMMUNITY_ROUTE_TARGET
);
4488 vty_out (vty
, " rt both %s%s", b
, VTY_NEWLINE
);
4489 XFREE (MTYPE_ECOMMUNITY_STR
, b
);
4493 if (rfg
->rt_import_list
)
4495 char *b
= ecommunity_ecom2str (rfg
->rt_import_list
,
4496 ECOMMUNITY_FORMAT_ROUTE_MAP
, ECOMMUNITY_ROUTE_TARGET
);
4497 vty_out (vty
, " rt import %s%s", b
, VTY_NEWLINE
);
4498 XFREE (MTYPE_ECOMMUNITY_STR
, b
);
4500 if (rfg
->rt_export_list
)
4502 char *b
= ecommunity_ecom2str (rfg
->rt_export_list
,
4503 ECOMMUNITY_FORMAT_ROUTE_MAP
, ECOMMUNITY_ROUTE_TARGET
);
4504 vty_out (vty
, " rt export %s%s", b
, VTY_NEWLINE
);
4505 XFREE (MTYPE_ECOMMUNITY_STR
, b
);
4508 if (bgp
->rfapi
->rfp_methods
.cfg_group_cb
)
4510 (bgp
->rfapi
->rfp_methods
.cfg_group_cb
) (vty
,
4512 RFAPI_RFP_CFG_GROUP_L2
,
4515 vty_out (vty
, " exit-vnc%s", VTY_NEWLINE
);
4516 vty_out (vty
, "!%s", VTY_NEWLINE
);
4520 if (hc
->default_rd
.family
||
4521 hc
->default_response_lifetime
||
4522 hc
->default_rt_import_list
||
4523 hc
->default_rt_export_list
|| hc
->nve_groups_sequential
->count
)
4528 vty_out (vty
, " vnc defaults%s", VTY_NEWLINE
);
4530 if (hc
->default_rd
.prefixlen
)
4533 buf
[0] = buf
[BUFSIZ
- 1] = 0;
4535 if (AF_UNIX
== hc
->default_rd
.family
)
4539 value
= ((hc
->default_rd
.val
[6] << 8) & 0x0ff00) |
4540 (hc
->default_rd
.val
[7] & 0x0ff);
4542 vty_out (vty
, " rd auto:vn:%d%s", value
, VTY_NEWLINE
);
4548 if (!prefix_rd2str (&hc
->default_rd
, buf
, BUFSIZ
) ||
4549 !buf
[0] || buf
[BUFSIZ
- 1])
4552 vty_out (vty
, "!Error: Can't convert rd%s", VTY_NEWLINE
);
4556 vty_out (vty
, " rd %s%s", buf
, VTY_NEWLINE
);
4560 if (hc
->default_response_lifetime
)
4562 vty_out (vty
, " response-lifetime ");
4563 if (hc
->default_response_lifetime
!= UINT32_MAX
)
4564 vty_out (vty
, "%d", hc
->default_response_lifetime
);
4566 vty_out (vty
, "infinite");
4567 vty_out (vty
, "%s", VTY_NEWLINE
);
4569 if (hc
->default_rt_import_list
&& hc
->default_rt_export_list
&&
4570 ecommunity_cmp (hc
->default_rt_import_list
,
4571 hc
->default_rt_export_list
))
4573 char *b
= ecommunity_ecom2str (hc
->default_rt_import_list
,
4574 ECOMMUNITY_FORMAT_ROUTE_MAP
, ECOMMUNITY_ROUTE_TARGET
);
4575 vty_out (vty
, " rt both %s%s", b
, VTY_NEWLINE
);
4576 XFREE (MTYPE_ECOMMUNITY_STR
, b
);
4580 if (hc
->default_rt_import_list
)
4582 char *b
= ecommunity_ecom2str (hc
->default_rt_import_list
,
4583 ECOMMUNITY_FORMAT_ROUTE_MAP
, ECOMMUNITY_ROUTE_TARGET
);
4584 vty_out (vty
, " rt import %s%s", b
, VTY_NEWLINE
);
4585 XFREE (MTYPE_ECOMMUNITY_STR
, b
);
4587 if (hc
->default_rt_export_list
)
4589 char *b
= ecommunity_ecom2str (hc
->default_rt_export_list
,
4590 ECOMMUNITY_FORMAT_ROUTE_MAP
, ECOMMUNITY_ROUTE_TARGET
);
4591 vty_out (vty
, " rt export %s%s", b
, VTY_NEWLINE
);
4592 XFREE (MTYPE_ECOMMUNITY_STR
, b
);
4595 if (bgp
->rfapi
->rfp_methods
.cfg_group_cb
)
4597 (bgp
->rfapi
->rfp_methods
.cfg_group_cb
) (vty
,
4599 RFAPI_RFP_CFG_GROUP_DEFAULT
,
4601 bgp
->rfapi_cfg
->default_rfp_cfg
);
4602 vty_out (vty
, " exit-vnc%s", VTY_NEWLINE
);
4603 vty_out (vty
, "!%s", VTY_NEWLINE
);
4606 for (ALL_LIST_ELEMENTS (hc
->nve_groups_sequential
, node
, nnode
, rfg
))
4607 if (rfg
->type
== RFAPI_GROUP_CFG_NVE
)
4610 vty_out (vty
, " vnc nve-group %s%s", rfg
->name
, VTY_NEWLINE
);
4612 if (rfg
->vn_prefix
.family
&& rfg
->vn_node
)
4615 buf
[0] = buf
[BUFSIZ
- 1] = 0;
4617 prefix2str (&rfg
->vn_prefix
, buf
, BUFSIZ
);
4618 if (!buf
[0] || buf
[BUFSIZ
- 1])
4620 vty_out (vty
, "!Error: Can't convert prefix%s", VTY_NEWLINE
);
4624 vty_out (vty
, " prefix %s %s%s", "vn", buf
, VTY_NEWLINE
);
4628 if (rfg
->un_prefix
.family
&& rfg
->un_node
)
4631 buf
[0] = buf
[BUFSIZ
- 1] = 0;
4632 prefix2str (&rfg
->un_prefix
, buf
, BUFSIZ
);
4633 if (!buf
[0] || buf
[BUFSIZ
- 1])
4635 vty_out (vty
, "!Error: Can't convert prefix%s", VTY_NEWLINE
);
4639 vty_out (vty
, " prefix %s %s%s", "un", buf
, VTY_NEWLINE
);
4644 if (rfg
->rd
.prefixlen
)
4647 buf
[0] = buf
[BUFSIZ
- 1] = 0;
4649 if (AF_UNIX
== rfg
->rd
.family
)
4654 value
= ((rfg
->rd
.val
[6] << 8) & 0x0ff00) |
4655 (rfg
->rd
.val
[7] & 0x0ff);
4657 vty_out (vty
, " rd auto:vn:%d%s", value
, VTY_NEWLINE
);
4663 if (!prefix_rd2str (&rfg
->rd
, buf
, BUFSIZ
) ||
4664 !buf
[0] || buf
[BUFSIZ
- 1])
4667 vty_out (vty
, "!Error: Can't convert rd%s", VTY_NEWLINE
);
4671 vty_out (vty
, " rd %s%s", buf
, VTY_NEWLINE
);
4675 if (rfg
->flags
& RFAPI_RFG_RESPONSE_LIFETIME
)
4677 vty_out (vty
, " response-lifetime ");
4678 if (rfg
->response_lifetime
!= UINT32_MAX
)
4679 vty_out (vty
, "%d", rfg
->response_lifetime
);
4681 vty_out (vty
, "infinite");
4682 vty_out (vty
, "%s", VTY_NEWLINE
);
4685 if (rfg
->rt_import_list
&& rfg
->rt_export_list
&&
4686 ecommunity_cmp (rfg
->rt_import_list
, rfg
->rt_export_list
))
4688 char *b
= ecommunity_ecom2str (rfg
->rt_import_list
,
4689 ECOMMUNITY_FORMAT_ROUTE_MAP
,
4690 ECOMMUNITY_ROUTE_TARGET
);
4691 vty_out (vty
, " rt both %s%s", b
, VTY_NEWLINE
);
4692 XFREE (MTYPE_ECOMMUNITY_STR
, b
);
4696 if (rfg
->rt_import_list
)
4698 char *b
= ecommunity_ecom2str (rfg
->rt_import_list
,
4699 ECOMMUNITY_FORMAT_ROUTE_MAP
,
4700 ECOMMUNITY_ROUTE_TARGET
);
4701 vty_out (vty
, " rt import %s%s", b
, VTY_NEWLINE
);
4702 XFREE (MTYPE_ECOMMUNITY_STR
, b
);
4704 if (rfg
->rt_export_list
)
4706 char *b
= ecommunity_ecom2str (rfg
->rt_export_list
,
4707 ECOMMUNITY_FORMAT_ROUTE_MAP
, ECOMMUNITY_ROUTE_TARGET
);
4708 vty_out (vty
, " rt export %s%s", b
, VTY_NEWLINE
);
4709 XFREE (MTYPE_ECOMMUNITY_STR
, b
);
4714 * route filtering: prefix-lists and route-maps
4716 for (afi
= AFI_IP
; afi
< AFI_MAX
; ++afi
)
4719 const char *afistr
= (afi
== AFI_IP
) ? "ipv4" : "ipv6";
4721 if (rfg
->plist_export_bgp_name
[afi
])
4723 vty_out (vty
, " export bgp %s prefix-list %s%s",
4724 afistr
, rfg
->plist_export_bgp_name
[afi
],
4727 if (rfg
->plist_export_zebra_name
[afi
])
4729 vty_out (vty
, " export zebra %s prefix-list %s%s",
4730 afistr
, rfg
->plist_export_zebra_name
[afi
],
4734 * currently we only support redist plists for bgp-direct.
4735 * If we later add plist support for redistributing other
4736 * protocols, we'll need to loop over protocols here
4738 if (rfg
->plist_redist_name
[ZEBRA_ROUTE_BGP_DIRECT
][afi
])
4740 vty_out (vty
, " redistribute bgp-direct %s prefix-list %s%s",
4742 rfg
->plist_redist_name
[ZEBRA_ROUTE_BGP_DIRECT
][afi
],
4745 if (rfg
->plist_redist_name
[ZEBRA_ROUTE_BGP_DIRECT_EXT
][afi
])
4748 " redistribute bgp-direct-to-nve-groups %s prefix-list %s%s",
4750 rfg
->plist_redist_name
[ZEBRA_ROUTE_BGP_DIRECT_EXT
]
4751 [afi
], VTY_NEWLINE
);
4755 if (rfg
->routemap_export_bgp_name
)
4757 vty_out (vty
, " export bgp route-map %s%s",
4758 rfg
->routemap_export_bgp_name
, VTY_NEWLINE
);
4760 if (rfg
->routemap_export_zebra_name
)
4762 vty_out (vty
, " export zebra route-map %s%s",
4763 rfg
->routemap_export_zebra_name
, VTY_NEWLINE
);
4765 if (rfg
->routemap_redist_name
[ZEBRA_ROUTE_BGP_DIRECT
])
4767 vty_out (vty
, " redistribute bgp-direct route-map %s%s",
4768 rfg
->routemap_redist_name
[ZEBRA_ROUTE_BGP_DIRECT
],
4771 if (rfg
->routemap_redist_name
[ZEBRA_ROUTE_BGP_DIRECT_EXT
])
4774 " redistribute bgp-direct-to-nve-groups route-map %s%s",
4775 rfg
->routemap_redist_name
[ZEBRA_ROUTE_BGP_DIRECT_EXT
],
4778 if (bgp
->rfapi
->rfp_methods
.cfg_group_cb
)
4780 (bgp
->rfapi
->rfp_methods
.cfg_group_cb
) (vty
,
4782 RFAPI_RFP_CFG_GROUP_NVE
,
4783 rfg
->name
, rfg
->rfp_cfg
);
4784 vty_out (vty
, " exit-vnc%s", VTY_NEWLINE
);
4785 vty_out (vty
, "!%s", VTY_NEWLINE
);
4787 } /* have listen ports */
4790 * route export to other protocols
4792 if (VNC_EXPORT_BGP_GRP_ENABLED (hc
))
4794 vty_out (vty
, " vnc export bgp mode group-nve%s", VTY_NEWLINE
);
4796 else if (VNC_EXPORT_BGP_RH_ENABLED (hc
))
4798 vty_out (vty
, " vnc export bgp mode registering-nve%s", VTY_NEWLINE
);
4800 else if (VNC_EXPORT_BGP_CE_ENABLED (hc
))
4802 vty_out (vty
, " vnc export bgp mode ce%s", VTY_NEWLINE
);
4805 if (VNC_EXPORT_ZEBRA_GRP_ENABLED (hc
))
4807 vty_out (vty
, " vnc export zebra mode group-nve%s", VTY_NEWLINE
);
4809 else if (VNC_EXPORT_ZEBRA_RH_ENABLED (hc
))
4811 vty_out (vty
, " vnc export zebra mode registering-nve%s", VTY_NEWLINE
);
4814 if (hc
->rfg_export_direct_bgp_l
)
4816 for (ALL_LIST_ELEMENTS (hc
->rfg_export_direct_bgp_l
, node
, nnode
, rfgn
))
4819 vty_out (vty
, " vnc export bgp group-nve group %s%s",
4820 rfgn
->name
, VTY_NEWLINE
);
4824 if (hc
->rfg_export_zebra_l
)
4826 for (ALL_LIST_ELEMENTS (hc
->rfg_export_zebra_l
, node
, nnode
, rfgn
))
4829 vty_out (vty
, " vnc export zebra group-nve group %s%s",
4830 rfgn
->name
, VTY_NEWLINE
);
4835 if (hc
->rfg_redist_name
)
4837 vty_out (vty
, " vnc redistribute nve-group %s%s",
4838 hc
->rfg_redist_name
, VTY_NEWLINE
);
4840 if (hc
->redist_lifetime
)
4842 vty_out (vty
, " vnc redistribute lifetime %d%s",
4843 hc
->redist_lifetime
, VTY_NEWLINE
);
4845 if (hc
->resolve_nve_roo_local_admin
!=
4846 BGP_VNC_CONFIG_RESOLVE_NVE_ROO_LOCAL_ADMIN_DEFAULT
)
4849 vty_out (vty
, " vnc redistribute resolve-nve roo-ec-local-admin %d%s",
4850 hc
->resolve_nve_roo_local_admin
, VTY_NEWLINE
);
4853 if (hc
->redist_mode
) /* ! default */
4857 switch (hc
->redist_mode
)
4859 case VNC_REDIST_MODE_PLAIN
:
4862 case VNC_REDIST_MODE_RFG
:
4865 case VNC_REDIST_MODE_RESOLVE_NVE
:
4871 vty_out (vty
, " vnc redistribute mode %s%s", s
, VTY_NEWLINE
);
4876 * route filtering: prefix-lists and route-maps
4878 for (afi
= AFI_IP
; afi
< AFI_MAX
; ++afi
)
4881 const char *afistr
= (afi
== AFI_IP
) ? "ipv4" : "ipv6";
4883 if (hc
->plist_export_bgp_name
[afi
])
4885 vty_out (vty
, " vnc export bgp %s prefix-list %s%s",
4886 afistr
, hc
->plist_export_bgp_name
[afi
], VTY_NEWLINE
);
4888 if (hc
->plist_export_zebra_name
[afi
])
4890 vty_out (vty
, " vnc export zebra %s prefix-list %s%s",
4891 afistr
, hc
->plist_export_zebra_name
[afi
], VTY_NEWLINE
);
4893 if (hc
->plist_redist_name
[ZEBRA_ROUTE_BGP_DIRECT
][afi
])
4895 vty_out (vty
, " vnc redistribute bgp-direct %s prefix-list %s%s",
4896 afistr
, hc
->plist_redist_name
[ZEBRA_ROUTE_BGP_DIRECT
][afi
],
4901 if (hc
->routemap_export_bgp_name
)
4903 vty_out (vty
, " vnc export bgp route-map %s%s",
4904 hc
->routemap_export_bgp_name
, VTY_NEWLINE
);
4906 if (hc
->routemap_export_zebra_name
)
4908 vty_out (vty
, " vnc export zebra route-map %s%s",
4909 hc
->routemap_export_zebra_name
, VTY_NEWLINE
);
4911 if (hc
->routemap_redist_name
[ZEBRA_ROUTE_BGP_DIRECT
])
4913 vty_out (vty
, " vnc redistribute bgp-direct route-map %s%s",
4914 hc
->routemap_redist_name
[ZEBRA_ROUTE_BGP_DIRECT
], VTY_NEWLINE
);
4917 for (afi
= AFI_IP
; afi
< AFI_MAX
; ++afi
)
4919 for (type
= 0; type
< ZEBRA_ROUTE_MAX
; ++type
)
4921 if (hc
->redist
[afi
][type
])
4923 if (type
== ZEBRA_ROUTE_BGP_DIRECT_EXT
&&
4924 hc
->redist_bgp_exterior_view_name
)
4926 vty_out (vty
, " vnc redistribute %s %s view %s%s",
4927 ((afi
== AFI_IP
) ? "ipv4" : "ipv6"),
4928 zebra_route_string (type
),
4929 hc
->redist_bgp_exterior_view_name
, VTY_NEWLINE
);
4933 vty_out (vty
, " vnc redistribute %s %s%s",
4934 ((afi
== AFI_IP
) ? "ipv4" : "ipv6"),
4935 zebra_route_string (type
), VTY_NEWLINE
);
4944 bgp_rfapi_show_summary (struct bgp
*bgp
, struct vty
*vty
)
4946 struct rfapi_cfg
*hc
= bgp
->rfapi_cfg
;
4947 int afi
, type
, redist
= 0;
4952 vty_out (vty
, "%-39s %-19s %s%s", "VNC Advertise method:",
4953 (hc
->flags
& BGP_VNC_CONFIG_ADV_UN_METHOD_ENCAP
4954 ? "Encapsulation SAFI" : "Tunnel Encap attribute"),
4955 ((hc
->flags
& BGP_VNC_CONFIG_ADV_UN_METHOD_ENCAP
) ==
4956 (BGP_VNC_CONFIG_ADV_UN_METHOD_ENCAP
&
4957 BGP_VNC_CONFIG_FLAGS_DEFAULT
) ? "(default)" : ""), VTY_NEWLINE
);
4959 vty_out (vty
, "%-39s ", "Export from VNC:");
4961 * route export to other protocols
4963 if (VNC_EXPORT_BGP_GRP_ENABLED (hc
))
4966 vty_out (vty
, "ToBGP Groups={");
4967 if (hc
->rfg_export_direct_bgp_l
)
4970 struct listnode
*node
, *nnode
;
4971 struct rfapi_rfg_name
*rfgn
;
4972 for (ALL_LIST_ELEMENTS (hc
->rfg_export_direct_bgp_l
,
4978 vty_out (vty
, "%s", rfgn
->name
);
4983 else if (VNC_EXPORT_BGP_RH_ENABLED (hc
))
4986 vty_out (vty
, "ToBGP {Registering NVE}");
4987 /* note filters, route-maps not shown */
4989 else if (VNC_EXPORT_BGP_CE_ENABLED (hc
))
4992 vty_out (vty
, "ToBGP {NVE connected router:%d}",
4993 hc
->resolve_nve_roo_local_admin
);
4994 /* note filters, route-maps not shown */
4997 if (VNC_EXPORT_ZEBRA_GRP_ENABLED (hc
))
5000 vty_out (vty
, "%sToZebra Groups={", (redist
== 1 ? "" : " "));
5001 if (hc
->rfg_export_direct_bgp_l
)
5004 struct listnode
*node
, *nnode
;
5005 struct rfapi_rfg_name
*rfgn
;
5006 for (ALL_LIST_ELEMENTS (hc
->rfg_export_zebra_l
, node
, nnode
, rfgn
))
5010 vty_out (vty
, "%s", rfgn
->name
);
5015 else if (VNC_EXPORT_ZEBRA_RH_ENABLED (hc
))
5018 vty_out (vty
, "%sToZebra {Registering NVE}", (redist
== 1 ? "" : " "));
5019 /* note filters, route-maps not shown */
5021 vty_out (vty
, "%-19s %s%s", (redist
? "" : "Off"),
5022 (redist
? "" : "(default)"), VTY_NEWLINE
);
5024 /* Redistribution */
5026 vty_out (vty
, "%-39s ", "Redistribution into VNC:");
5027 for (afi
= AFI_IP
; afi
< AFI_MAX
; ++afi
)
5029 for (type
= 0; type
< ZEBRA_ROUTE_MAX
; ++type
)
5031 if (hc
->redist
[afi
][type
])
5033 vty_out (vty
, "{%s,%s} ",
5034 ((afi
== AFI_IP
) ? "ipv4" : "ipv6"),
5035 zebra_route_string (type
));
5040 vty_out (vty
, "%-19s %s%s", (redist
? "" : "Off"),
5041 (redist
? "" : "(default)"), VTY_NEWLINE
);
5043 vty_out (vty
, "%-39s %3u%-16s %s%s", "RFP Registration Hold-Down Factor:",
5044 hc
->rfp_cfg
.holddown_factor
, "%",
5045 (hc
->rfp_cfg
.holddown_factor
==
5046 RFAPI_RFP_CFG_DEFAULT_HOLDDOWN_FACTOR
? "(default)" : ""),
5048 vty_out (vty
, "%-39s %-19s %s%s", "RFP Updated responses:",
5049 (hc
->rfp_cfg
.use_updated_response
== 0 ? "Off" : "On"),
5050 (hc
->rfp_cfg
.use_updated_response
== 0 ? "(default)" : ""),
5052 vty_out (vty
, "%-39s %-19s %s%s", "RFP Removal responses:",
5053 (hc
->rfp_cfg
.use_removes
== 0 ? "Off" : "On"),
5054 (hc
->rfp_cfg
.use_removes
== 0 ? "(default)" : ""), VTY_NEWLINE
);
5055 vty_out (vty
, "%-39s %-19s %s%s", "RFP Full table download:",
5056 (hc
->rfp_cfg
.download_type
==
5057 RFAPI_RFP_DOWNLOAD_FULL
? "On" : "Off"),
5058 (hc
->rfp_cfg
.download_type
==
5059 RFAPI_RFP_DOWNLOAD_PARTIAL
? "(default)" : ""), VTY_NEWLINE
);
5060 sprintf (tmp
, "%u seconds", hc
->rfp_cfg
.ftd_advertisement_interval
);
5061 vty_out (vty
, "%-39s %-19s %s%s", " Advertisement Interval:", tmp
,
5062 (hc
->rfp_cfg
.ftd_advertisement_interval
==
5063 RFAPI_RFP_CFG_DEFAULT_FTD_ADVERTISEMENT_INTERVAL
5064 ? "(default)" : ""), VTY_NEWLINE
);
5065 vty_out (vty
, "%-39s %d seconds%s", "Default RFP response lifetime:",
5066 hc
->default_response_lifetime
, VTY_NEWLINE
);
5067 vty_out (vty
, "%s", VTY_NEWLINE
);
5072 bgp_rfapi_get_config (struct bgp
*bgp
)
5074 struct rfapi_cfg
*hc
= NULL
;
5076 bgp
= bgp_get_default ();
5078 hc
= bgp
->rfapi_cfg
;
5082 #endif /* ENABLE_BGP_VNC */