Mailing List Archive

[PATCH 33/57] bgpd: enhance network command for evpn route type 5
A new vty command available under evpn address family. This command
takes following format:

(af-evpn)# network A.B.C.D/M rd ASN:nn_or_IP-address:nn ethtag WORD
label WORD esi WORD gwip A.B.C.D routermac WORD

Among new parameters, ethtag stands for the ethernet tag indentifier.
ESI stands for the ethernet segment identifier, and must be entered in
following format: 00:11:22:33:44:55:66:77:88:99.
gwip stands for the gateway IP address contained in RT5 message.
RouterMAc is the gateway mac address sent as extended community
attribute.
The no form of above command is also available.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
---
bgpd/bgp_encap.c | 4 +-
bgpd/bgp_evpn.c | 48 +++++++++++++++++++++++
bgpd/bgp_mplsvpn.c | 6 +--
bgpd/bgp_route.c | 113 +++++++++++++++++++++++++++++++++++++++++++++++++----
bgpd/bgp_route.h | 6 ++-
5 files changed, 162 insertions(+), 15 deletions(-)

diff --git a/bgpd/bgp_encap.c b/bgpd/bgp_encap.c
index 48817e05da88..3fe0d8c9f817 100644
--- a/bgpd/bgp_encap.c
+++ b/bgpd/bgp_encap.c
@@ -211,7 +211,7 @@ DEFUN (encap_network,
"BGP tag\n"
"tag value\n")
{
- return bgp_static_set_safi (SAFI_ENCAP, vty, argv[0], argv[1], argv[2], NULL);
+ return bgp_static_set_safi (SAFI_ENCAP, vty, argv[0], argv[1], argv[2], NULL, NULL, NULL, NULL, NULL);
}

/* For testing purpose, static route of ENCAP. */
@@ -226,7 +226,7 @@ DEFUN (no_encap_network,
"BGP tag\n"
"tag value\n")
{
- return bgp_static_unset_safi (SAFI_ENCAP, vty, argv[0], argv[1], argv[2]);
+ return bgp_static_unset_safi (SAFI_ENCAP, vty, argv[0], argv[1], argv[2], NULL, NULL, NULL);
}

static int
diff --git a/bgpd/bgp_evpn.c b/bgpd/bgp_evpn.c
index b8945daeffc2..7828caa02fea 100644
--- a/bgpd/bgp_evpn.c
+++ b/bgpd/bgp_evpn.c
@@ -673,6 +673,52 @@ DEFUN (show_bgp_l2vpn_evpn_rd_neighbor_advertised_routes,
return show_adj_route_evpn (vty, peer, &prd);
}

+/* For testing purpose, static route of MPLS-VPN. */
+DEFUN (evpnrt5_network,
+ evpnrt5_network_cmd,
+ "network A.B.C.D/M rd ASN:nn_or_IP-address:nn ethtag WORD label WORD esi WORD gwip A.B.C.D routermac WORD",
+ "Specify a network to announce via BGP\n"
+ "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
+ "Specify Route Distinguisher\n"
+ "VPN Route Distinguisher\n"
+ "Ethernet Tag\n"
+ "Ethernet Tag Value\n"
+ "BGP label\n"
+ "label value\n"
+ "Ethernet Segment Identifier\n"
+ "ESI value ( 00:11:22:33:44:55:66:77:88:99 format) \n"
+ "Gateway IP\n"
+ "Gateway IP ( A.B.C.D )\n"
+ "Router Mac Ext Comm\n"
+ "Router Mac address Value ( aa:bb:cc:dd:ee:ff format)\n")
+{
+ return bgp_static_set_safi (SAFI_INTERNAL_EVPN, vty, argv[0], argv[1], argv[3], NULL,
+ argv[4], argv[5], argv[2], argv[6]);
+}
+
+/* For testing purpose, static route of MPLS-VPN. */
+DEFUN (no_evpnrt5_network,
+ no_evpnrt5_network_cmd,
+ "no network A.B.C.D/M rd ASN:nn_or_IP-address:nn ethtag WORD label WORD esi WORD gwip A.B.C.D",
+ NO_STR
+ "Specify a network to announce via BGP\n"
+ "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
+ "Specify Route Distinguisher\n"
+ "VPN Route Distinguisher\n"
+ "Ethernet Tag\n"
+ "Ethernet Tag Value\n"
+ "BGP label\n"
+ "label value\n"
+ "Ethernet Segment Identifier\n"
+ "ESI value ( 00:11:22:33:44:55:66:77:88:99 format) \n"
+ "Gateway IP\n"
+ "Gateway IP ( A.B.C.D )\n")
+{
+ return bgp_static_unset_safi (SAFI_INTERNAL_EVPN, vty, argv[0], argv[1], argv[3],
+ argv[4], argv[5], argv[2]);
+}
+
+
void
bgp_ethernetvpn_init (void)
{
@@ -688,4 +734,6 @@ bgp_ethernetvpn_init (void)
install_element (VIEW_NODE, &show_bgp_l2vpn_evpn_rd_neighbor_routes_cmd);
install_element (VIEW_NODE, &show_bgp_l2vpn_evpn_all_neighbor_advertised_routes_cmd);
install_element (VIEW_NODE, &show_bgp_l2vpn_evpn_rd_neighbor_advertised_routes_cmd);
+ install_element (BGP_EVPN_NODE, &no_evpnrt5_network_cmd);
+ install_element (BGP_EVPN_NODE, &evpnrt5_network_cmd);
}
diff --git a/bgpd/bgp_mplsvpn.c b/bgpd/bgp_mplsvpn.c
index 09a20a1c18b7..2385bfade3b9 100644
--- a/bgpd/bgp_mplsvpn.c
+++ b/bgpd/bgp_mplsvpn.c
@@ -407,7 +407,7 @@ DEFUN (vpnv4_network,
"BGP tag\n"
"tag value\n")
{
- return bgp_static_set_safi (SAFI_MPLS_VPN, vty, argv[0], argv[1], argv[2], NULL);
+ return bgp_static_set_safi (SAFI_MPLS_VPN, vty, argv[0], argv[1], argv[2], NULL, NULL, NULL, NULL, NULL);
}

DEFUN (vpnv4_network_route_map,
@@ -422,7 +422,7 @@ DEFUN (vpnv4_network_route_map,
"route map\n"
"route map name\n")
{
- return bgp_static_set_safi (SAFI_MPLS_VPN, vty, argv[0], argv[1], argv[2], argv[3]);
+ return bgp_static_set_safi (SAFI_MPLS_VPN, vty, argv[0], argv[1], argv[2], argv[3], NULL, NULL, NULL, NULL);
}

/* For testing purpose, static route of MPLS-VPN. */
@@ -437,7 +437,7 @@ DEFUN (no_vpnv4_network,
"BGP tag\n"
"tag value\n")
{
- return bgp_static_unset_safi (SAFI_MPLS_VPN, vty, argv[0], argv[1], argv[2]);
+ return bgp_static_unset_safi (SAFI_MPLS_VPN, vty, argv[0], argv[1], argv[2], NULL, NULL, NULL);
}

static int
diff --git a/bgpd/bgp_route.c b/bgpd/bgp_route.c
index c6225c9e35eb..d9cbc45ef292 100644
--- a/bgpd/bgp_route.c
+++ b/bgpd/bgp_route.c
@@ -5046,7 +5046,8 @@ bgp_static_delete (struct bgp *bgp)
int
bgp_static_set_safi (safi_t safi, struct vty *vty, const char *ip_str,
const char *rd_str, const char *tag_str,
- const char *rmap_str)
+ const char *rmap_str, const char *esi, const char *gwip,
+ const char *ethtag, const char *routermac)
{
int ret;
struct prefix p;
@@ -5059,6 +5060,12 @@ bgp_static_set_safi (safi_t safi, struct vty *vty, const char *ip_str,
struct bgp_vrf *vrf;
uint32_t labels[BGP_MAX_LABELS];
size_t nlabels;
+ afi_t afi;
+
+ if(safi == SAFI_INTERNAL_EVPN)
+ afi = AFI_INTERNAL_L2VPN;
+ else
+ afi = AFI_IP;

bgp = vty->index;

@@ -5082,11 +5089,28 @@ bgp_static_set_safi (safi_t safi, struct vty *vty, const char *ip_str,
vty_out (vty, "%% Malformed tag%s", VTY_NEWLINE);
return CMD_WARNING;
}
-
- prn = bgp_node_get (bgp->route[AFI_IP][safi],
+ if (safi == SAFI_INTERNAL_EVPN)
+ {
+ if( esi && str2esi (esi, NULL) == 0)
+ {
+ vty_out (vty, "%% Malformed ESI%s", VTY_NEWLINE);
+ return CMD_WARNING;
+ }
+ if( routermac && str2mac (routermac, NULL) == 0)
+ {
+ vty_out (vty, "%% Malformed Router MAC%s", VTY_NEWLINE);
+ return CMD_WARNING;
+ }
+ if(!ethtag)
+ {
+ vty_out (vty, "%% Eth Tag Compulsory%s", VTY_NEWLINE);
+ return CMD_WARNING;
+ }
+ }
+ prn = bgp_node_get (bgp->route[afi][safi],
(struct prefix *)&prd);
if (prn->info == NULL)
- prn->info = bgp_table_init (AFI_IP, safi);
+ prn->info = bgp_table_init (afi, safi);
else
bgp_unlock_node (prn);
table = prn->info;
@@ -5122,10 +5146,27 @@ bgp_static_set_safi (safi_t safi, struct vty *vty, const char *ip_str,
bgp_static->rmap.name = strdup (rmap_str);
bgp_static->rmap.map = route_map_lookup_by_name (rmap_str);
}
+
+ if (safi == SAFI_INTERNAL_EVPN)
+ {
+ if(esi)
+ {
+ bgp_static->eth_s_id = XCALLOC (MTYPE_ATTR, sizeof(struct eth_segment_id));
+ str2esi (esi, bgp_static->eth_s_id);
+ }
+ if( routermac)
+ {
+ bgp_static->router_mac = XCALLOC (MTYPE_ATTR, MAC_LEN+1);
+ str2mac (routermac, bgp_static->router_mac);
+ }
+ bgp_static->eth_t_id = atol(ethtag);
+ if (gwip)
+ inet_aton (gwip, &bgp_static->igpnexthop);
+ }
rn->info = bgp_static;

bgp_static->valid = 1;
- bgp_static_update_safi (bgp, &p, bgp_static, AFI_IP, safi);
+ bgp_static_update_safi (bgp, &p, bgp_static, afi, safi);
}

return CMD_SUCCESS;
@@ -5134,7 +5175,8 @@ bgp_static_set_safi (safi_t safi, struct vty *vty, const char *ip_str,
/* Configure static BGP network. */
int
bgp_static_unset_safi(safi_t safi, struct vty *vty, const char *ip_str,
- const char *rd_str, const char *tag_str)
+ const char *rd_str, const char *tag_str,
+ const char *esi, const char *gwip, const char *ethtag)
{
int ret;
struct bgp *bgp;
@@ -5183,7 +5225,10 @@ bgp_static_unset_safi(safi_t safi, struct vty *vty, const char *ip_str,

if (rn)
{
- bgp_static_withdraw_safi (bgp, &p, AFI_IP, safi, &prd, labels, nlabels);
+ if(safi == SAFI_INTERNAL_EVPN)
+ bgp_static_withdraw_safi (bgp, &p, AFI_INTERNAL_L2VPN, safi, &prd, labels, nlabels);
+ else
+ bgp_static_withdraw_safi (bgp, &p, AFI_IP, safi, &prd, labels, nlabels);

bgp_static = rn->info;
bgp_static_free (bgp_static);
@@ -17218,6 +17263,55 @@ bgp_config_write_network_vpnv4 (struct vty *vty, struct bgp *bgp,
return 0;
}

+static int
+bgp_config_write_network_evpn (struct vty *vty, struct bgp *bgp,
+ afi_t afi, safi_t safi, int *write)
+{
+ struct bgp_node *prn;
+ struct bgp_node *rn;
+ struct bgp_table *table;
+ struct prefix *p;
+ struct prefix_rd *prd;
+ struct bgp_static *bgp_static;
+ char buf[SU_ADDRSTRLEN];
+ char buf2[SU_ADDRSTRLEN];
+ char rdbuf[RD_ADDRSTRLEN];
+ char lblbuf[BUFSIZ];
+
+ /* Network configuration. */
+ for (prn = bgp_table_top (bgp->route[afi][safi]); prn; prn = bgp_route_next (prn))
+ if ((table = prn->info) != NULL)
+ for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn))
+ if ((bgp_static = rn->info) != NULL)
+ {
+ char *macrouter = NULL;
+ char *esi = NULL;
+
+ if(bgp_static->router_mac)
+ macrouter = mac2str(bgp_static->router_mac);
+ if(bgp_static->eth_s_id)
+ esi = esi2str(bgp_static->eth_s_id);
+ p = &rn->p;
+ prd = (struct prefix_rd *) &prn->p;
+
+ /* "address-family" display. */
+ bgp_config_write_family_header (vty, afi, safi, write);
+
+ /* "network" configuration display. */
+ prefix_rd2str (prd, rdbuf, RD_ADDRSTRLEN);
+ labels2str (lblbuf, sizeof(lblbuf),
+ bgp_static->labels, bgp_static->nlabels);
+ inet_ntop (AF_INET, &bgp_static->igpnexthop, buf2, SU_ADDRSTRLEN);
+
+ vty_out (vty, " network %s/%d rd %s ethtag %u tag %s esi %s gwip %s routermac %s",
+ inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN),
+ p->prefixlen,
+ rdbuf, bgp_static->eth_t_id, lblbuf, esi, buf2 , macrouter);
+ vty_out (vty, "%s", VTY_NEWLINE);
+ }
+ return 0;
+}
+
/* Configuration of static route announcement and aggregate
information. */
int
@@ -17229,10 +17323,13 @@ bgp_config_write_network (struct vty *vty, struct bgp *bgp,
struct bgp_static *bgp_static;
struct bgp_aggregate *bgp_aggregate;
char buf[SU_ADDRSTRLEN];
-
+
if (afi == AFI_IP && ((safi == SAFI_MPLS_VPN) || (safi == SAFI_ENCAP)))
return bgp_config_write_network_vpnv4 (vty, bgp, afi, safi, write);

+ if (afi == AFI_INTERNAL_L2VPN && safi == SAFI_INTERNAL_EVPN)
+ return bgp_config_write_network_evpn (vty, bgp, afi, safi, write);
+
/* Network configuration. */
for (rn = bgp_table_top (bgp->route[afi][safi]); rn; rn = bgp_route_next (rn))
if ((bgp_static = rn->info) != NULL)
diff --git a/bgpd/bgp_route.h b/bgpd/bgp_route.h
index 908a91f99182..c266d8c30f5b 100644
--- a/bgpd/bgp_route.h
+++ b/bgpd/bgp_route.h
@@ -252,10 +252,12 @@ extern void bgp_static_update (struct bgp *, struct prefix *, struct bgp_static
extern void bgp_static_withdraw (struct bgp *, struct prefix *, afi_t, safi_t);

extern int bgp_static_set_safi (safi_t safi, struct vty *vty, const char *,
- const char *, const char *, const char *);
+ const char *, const char *, const char *,
+ const char *, const char *, const char *, const char *);

extern int bgp_static_unset_safi (safi_t safi, struct vty *, const char *,
- const char *, const char *);
+ const char *, const char *,
+ const char *, const char *, const char *);

/* this is primarily for MPLS-VPN */
extern int bgp_update (struct peer *, struct prefix *, struct attr *,
--
2.1.4


_______________________________________________
Quagga-dev mailing list
Quagga-dev@lists.quagga.net
https://lists.quagga.net/mailman/listinfo/quagga-dev