From: Julien Courtat <julien.cour...@6wind.com> On VRF creation, an additionnal parameter layer type can be provided to distinguish between layer 2 and layer 3 vrf. layer 2 is used by EVPN when dealing with MAC/IP route advertisement. layer 3 is used by any other route L3VPN or EVPN route advertisement.
Signed-off-by: Julien Courtat <julien.cour...@6wind.com> --- bgpd/bgp_vty.c | 20 ++++++++++++++++++-- bgpd/bgpd.c | 13 ++++++++++--- bgpd/bgpd.h | 11 ++++++++++- 3 files changed, 38 insertions(+), 6 deletions(-) diff --git a/bgpd/bgp_vty.c b/bgpd/bgp_vty.c index ea00149ba0a1..a0d37d1a9d69 100644 --- a/bgpd/bgp_vty.c +++ b/bgpd/bgp_vty.c @@ -9947,15 +9947,17 @@ bgp_config_write_redistribute (struct vty *vty, struct bgp *bgp, afi_t afi, DEFUN (bgp_vrf, bgp_vrf_cmd, - "vrf rd WORD", + "vrf rd WORD [LAYER]", "BGP VPN VRF\n" "Route Distinguisher\n" "Route Distinguisher\n" + "Layer type: layer_2 or layer_3\n" ) { struct bgp *bgp = vty->index; struct bgp_vrf *vrf; struct prefix_rd prd; + bgp_layer_type_t ltype = BGP_LAYER_TYPE_3; if (! str2prefix_rd (argv[0], &prd)) { @@ -9963,6 +9965,20 @@ DEFUN (bgp_vrf, return CMD_WARNING; } + if (argc == 2) + { + if (!strncmp(argv[1], "layer_2", 7)) + ltype = BGP_LAYER_TYPE_2; + else + if (!strncmp(argv[1], "layer_3", 7)) + ltype = BGP_LAYER_TYPE_3; + else + { + vty_out (vty, "%% VRF with layer type '%s' not supported%s", argv[1], VTY_NEWLINE); + return CMD_WARNING; + } + } + vrf = bgp_vrf_lookup (bgp, &prd); if (vrf) { @@ -9970,7 +9986,7 @@ DEFUN (bgp_vrf, return CMD_WARNING; } - bgp_vrf_create (bgp, &prd); + bgp_vrf_create (bgp, ltype, &prd); return CMD_SUCCESS; } diff --git a/bgpd/bgpd.c b/bgpd/bgpd.c index 2833b6e8751f..82d077c03876 100644 --- a/bgpd/bgpd.c +++ b/bgpd/bgpd.c @@ -2123,7 +2123,7 @@ bgp_vrf_lookup (struct bgp *bgp, struct prefix_rd *outbound_rd) } struct bgp_vrf * -bgp_vrf_create (struct bgp *bgp, struct prefix_rd *outbound_rd) +bgp_vrf_create (struct bgp *bgp, bgp_layer_type_t ltype, struct prefix_rd *outbound_rd) { struct bgp_vrf *vrf; afi_t afi; @@ -2132,8 +2132,13 @@ bgp_vrf_create (struct bgp *bgp, struct prefix_rd *outbound_rd) return NULL; vrf->bgp = bgp; + vrf->ltype = ltype; vrf->outbound_rd = *outbound_rd; - vrf->max_mpath = bgp->maxpaths[AFI_IP][SAFI_MPLS_VPN].maxpaths_ibgp; + + if (ltype == BGP_LAYER_TYPE_2) + vrf->max_mpath = bgp->maxpaths[AFI_INTERNAL_L2VPN][SAFI_INTERNAL_EVPN].maxpaths_ibgp; + else + vrf->max_mpath = bgp->maxpaths[AFI_IP][SAFI_MPLS_VPN].maxpaths_ibgp; for (afi = AFI_IP; afi < AFI_MAX; afi++) { @@ -5818,7 +5823,9 @@ bgp_config_write (struct vty *vty) for (ALL_LIST_ELEMENTS_RO(bgp->vrfs, node, vrf)) { str_p = prefix_rd2str(&(vrf->outbound_rd), rdstr, RD_ADDRSTRLEN); - vty_out(vty, " vrf rd %s%s", str_p == NULL?"<err>":str_p, VTY_NEWLINE); + vty_out(vty, " vrf rd %s%s%s", str_p == NULL?"<err>":str_p, + vrf->ltype == BGP_LAYER_TYPE_2 ? " layer_2": "", + VTY_NEWLINE); if(vrf->rt_import) { str2_p = ecommunity_ecom2str (vrf->rt_import, diff --git a/bgpd/bgpd.h b/bgpd/bgpd.h index 505c1389a087..15a4aaaf16d8 100644 --- a/bgpd/bgpd.h +++ b/bgpd/bgpd.h @@ -208,10 +208,19 @@ struct bgp_rt_sub struct list *vrfs; }; +typedef enum +{ + BGP_LAYER_TYPE_2 = 1, + BGP_LAYER_TYPE_3 = 2, +} bgp_layer_type_t; + struct bgp_vrf { struct bgp *bgp; + /* TYPE2 for EVPN MAC/IP routes, TYPE3 for others */ + bgp_layer_type_t ltype; + /* RD used for route advertisements */ struct prefix_rd outbound_rd; @@ -1040,7 +1049,7 @@ extern int peer_ttl_security_hops_set (struct peer *, int); extern int peer_ttl_security_hops_unset (struct peer *); extern void bgp_scan_finish (void); -extern struct bgp_vrf *bgp_vrf_create (struct bgp *bgp, struct prefix_rd *outbound_rd); +extern struct bgp_vrf *bgp_vrf_create (struct bgp *bgp, bgp_layer_type_t ltype, struct prefix_rd *outbound_rd); extern struct bgp_vrf *bgp_vrf_lookup (struct bgp *bgp, struct prefix_rd *outbound_rd); extern struct bgp_vrf *bgp_vrf_lookup_per_rn (struct bgp *bgp, int afi, struct bgp_node *vrf_rn); extern void bgp_vrf_delete (struct bgp_vrf *vrf); -- 2.1.4 _______________________________________________ Quagga-dev mailing list Quagga-dev@lists.quagga.net https://lists.quagga.net/mailman/listinfo/quagga-dev