X-Git-Url: https://git.proxmox.com/?a=blobdiff_plain;f=bgpd%2Fbgp_evpn_vty.c;h=603171138e752dafd8aefe1b9867a2d095c7fd47;hb=6d3c2ed4edb863d108239132b3e01daf07024f65;hp=ed67a61f69172d2086235fdf9892e9a4aa5a64a4;hpb=8ba835eb69d897d67a46ede418c81387bd1cc55b;p=mirror_frr.git diff --git a/bgpd/bgp_evpn_vty.c b/bgpd/bgp_evpn_vty.c index ed67a61f6..603171138 100644 --- a/bgpd/bgp_evpn_vty.c +++ b/bgpd/bgp_evpn_vty.c @@ -1,22 +1,22 @@ /* Ethernet-VPN Packet and vty Processing File - Copyright (C) 2017 6WIND - -This file is part of Free Range Routing - -Free Range Routing is free software; you can redistribute it and/or modify it -under the terms of the GNU General Public License as published by the -Free Software Foundation; either version 2, or (at your option) any -later version. - -Free Range Routing is distributed in the hope that it will be useful, but -WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -General Public License for more details. - -You should have received a copy of the GNU General Public License -along with Free Range Routing; see the file COPYING. If not, write to the Free -Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA -02111-1307, USA. */ + * Copyright (C) 2017 6WIND + * + * This file is part of FRRouting + * + * FRRouting is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation; either version 2, or (at your option) any + * later version. + * + * FRRouting is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; see the file COPYING; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ #include #include "command.h" @@ -49,12 +49,6 @@ bgp_show_ethernet_vpn(struct vty *vty, struct prefix_rd *prd, struct bgp_info *ri; int rd_header; int header = 1; - char v4_header[] = - " Network Next Hop Metric LocPrf Weight Path%s"; - char v4_header_tag[] = - " Network Next Hop In tag/Out tag%s"; - char v4_header_overlay[] = - " Network Next Hop EthTag Overlay Index RouterMac%s"; unsigned long output_count = 0; unsigned long total_count = 0; @@ -67,8 +61,7 @@ bgp_show_ethernet_vpn(struct vty *vty, struct prefix_rd *prd, bgp = bgp_get_default(); if (bgp == NULL) { if (!use_json) - vty_out(vty, "No BGP process is configured%s", - VTY_NEWLINE); + vty_out (vty,"No BGP process is configured\n"); return CMD_WARNING; } @@ -142,31 +135,20 @@ bgp_show_ethernet_vpn(struct vty *vty, struct prefix_rd *prd, } else { if (option == SHOW_DISPLAY_TAGS) - vty_out(vty, - v4_header_tag, - VTY_NEWLINE); + vty_out(vty, V4_HEADER_TAG); else if (option == SHOW_DISPLAY_OVERLAY) - vty_out(vty, - v4_header_overlay, - VTY_NEWLINE); + vty_out(vty, V4_HEADER_OVERLAY); else { - vty_out(vty, - "BGP table version is 0, local router ID is %s%s", - inet_ntoa - (bgp-> - router_id), - VTY_NEWLINE); - vty_out(vty, - "Status codes: s suppressed, d damped, h history, * valid, > best, i - internal%s", - VTY_NEWLINE); - vty_out(vty, - "Origin codes: i - IGP, e - EGP, ? - incomplete%s%s", - VTY_NEWLINE, - VTY_NEWLINE); - vty_out(vty, - v4_header, - VTY_NEWLINE); + vty_out (vty, + "BGP table version is 0, local router ID is %s\n", + inet_ntoa(bgp->router_id)); + vty_out (vty, + "Status codes: s suppressed, d damped, h history, * valid, > best, i - internal\n"); + vty_out (vty, + "Origin codes: i - IGP, e - EGP, ? - incomplete%s\n", + VTYNL); + vty_out(vty, V4_HEADER); } } header = 0; @@ -242,8 +224,7 @@ bgp_show_ethernet_vpn(struct vty *vty, struct prefix_rd *prd, ip), rd_ip. val); - vty_out(vty, "%s", - VTY_NEWLINE); + vty_out (vty, "\n\n"); } rd_header = 0; } @@ -272,11 +253,11 @@ bgp_show_ethernet_vpn(struct vty *vty, struct prefix_rd *prd, } } if (output_count == 0) - vty_out(vty, "No prefixes displayed, %ld exist%s", total_count, - VTY_NEWLINE); + vty_out (vty, "No prefixes displayed, %ld exist\n", + total_count); else - vty_out(vty, "%sDisplayed %ld out of %ld total prefixes%s", - VTY_NEWLINE, output_count, total_count, VTY_NEWLINE); + vty_out (vty, "%sDisplayed %ld out of %ld total prefixes\n", + VTYNL, output_count, total_count); return CMD_SUCCESS; } @@ -300,13 +281,15 @@ DEFUN(show_ip_bgp_l2vpn_evpn_rd, "Display information for a route distinguisher\n" "VPN Route Distinguisher\n" JSON_STR) { - int idx_ext_community = 6; + int idx_ext_community = 0; int ret; struct prefix_rd prd; + argv_find (argv, argc, "ASN:nn_or_IP-address:nn", &idx_ext_community); + ret = str2prefix_rd(argv[idx_ext_community]->arg, &prd); if (!ret) { - vty_out(vty, "%% Malformed Route Distinguisher%s", VTY_NEWLINE); + vty_out (vty, "%% Malformed Route Distinguisher\n"); return CMD_WARNING; } return bgp_show_ethernet_vpn(vty, &prd, bgp_show_type_normal, NULL, 0, @@ -339,13 +322,15 @@ DEFUN(show_ip_bgp_l2vpn_evpn_rd_tags, "Display information for a route distinguisher\n" "VPN Route Distinguisher\n" "Display BGP tags for prefixes\n") { - int idx_ext_community = 6; + int idx_ext_community = 0; int ret; struct prefix_rd prd; + argv_find (argv, argc, "ASN:nn_or_IP-address:nn", &idx_ext_community); + ret = str2prefix_rd(argv[idx_ext_community]->arg, &prd); if (!ret) { - vty_out(vty, "%% Malformed Route Distinguisher%s", VTY_NEWLINE); + vty_out (vty, "%% Malformed Route Distinguisher\n"); return CMD_WARNING; } return bgp_show_ethernet_vpn(vty, &prd, bgp_show_type_normal, NULL, 1, @@ -365,12 +350,14 @@ DEFUN(show_ip_bgp_l2vpn_evpn_all_neighbor_routes, "Neighbor to display information about\n" "Display routes learned from neighbor\n" JSON_STR) { - int idx_ipv4 = 6; + int idx_ipv4 = 0; union sockunion su; struct peer *peer; int ret; u_char uj = use_json(argc, argv); + argv_find (argv, argc, "A.B.C.D", &idx_ipv4); + ret = str2sockunion(argv[idx_ipv4]->arg, &su); if (ret < 0) { if (uj) { @@ -378,13 +365,12 @@ DEFUN(show_ip_bgp_l2vpn_evpn_all_neighbor_routes, json_no = json_object_new_object(); json_object_string_add(json_no, "warning", "Malformed address"); - vty_out(vty, "%s%s", - json_object_to_json_string(json_no), - VTY_NEWLINE); + vty_out (vty, "%s\n", + json_object_to_json_string(json_no)); json_object_free(json_no); } else - vty_out(vty, "Malformed address: %s%s", - argv[idx_ipv4]->arg, VTY_NEWLINE); + vty_out (vty, "Malformed address: %s\n", + argv[idx_ipv4]->arg); return CMD_WARNING; } @@ -395,13 +381,12 @@ DEFUN(show_ip_bgp_l2vpn_evpn_all_neighbor_routes, json_no = json_object_new_object(); json_object_string_add(json_no, "warning", "No such neighbor or address family"); - vty_out(vty, "%s%s", - json_object_to_json_string(json_no), - VTY_NEWLINE); + vty_out (vty, "%s\n", + json_object_to_json_string(json_no)); json_object_free(json_no); } else - vty_out(vty, "%% No such neighbor or address family%s", - VTY_NEWLINE); + vty_out (vty, + "%% No such neighbor or address family\n"); return CMD_WARNING; } @@ -423,14 +408,17 @@ DEFUN(show_ip_bgp_l2vpn_evpn_rd_neighbor_routes, "Neighbor to display information about\n" "Display routes learned from neighbor\n" JSON_STR) { - int idx_ext_community = 6; - int idx_ipv4 = 8; + int idx_ext_community = 0; + int idx_ipv4 = 0; int ret; union sockunion su; struct peer *peer; struct prefix_rd prd; u_char uj = use_json(argc, argv); + argv_find (argv, argc, "ASN:nn_or_IP-address:nn", &idx_ext_community); + argv_find (argv, argc, "A.B.C.D", &idx_ipv4); + ret = str2prefix_rd(argv[idx_ext_community]->arg, &prd); if (!ret) { if (uj) { @@ -438,13 +426,11 @@ DEFUN(show_ip_bgp_l2vpn_evpn_rd_neighbor_routes, json_no = json_object_new_object(); json_object_string_add(json_no, "warning", "Malformed Route Distinguisher"); - vty_out(vty, "%s%s", - json_object_to_json_string(json_no), - VTY_NEWLINE); + vty_out (vty, "%s\n", + json_object_to_json_string(json_no)); json_object_free(json_no); } else - vty_out(vty, "%% Malformed Route Distinguisher%s", - VTY_NEWLINE); + vty_out (vty,"%% Malformed Route Distinguisher\n"); return CMD_WARNING; } @@ -455,13 +441,12 @@ DEFUN(show_ip_bgp_l2vpn_evpn_rd_neighbor_routes, json_no = json_object_new_object(); json_object_string_add(json_no, "warning", "Malformed address"); - vty_out(vty, "%s%s", - json_object_to_json_string(json_no), - VTY_NEWLINE); + vty_out (vty, "%s\n", + json_object_to_json_string(json_no)); json_object_free(json_no); } else - vty_out(vty, "Malformed address: %s%s", - argv[idx_ext_community]->arg, VTY_NEWLINE); + vty_out (vty, "Malformed address: %s\n", + argv[idx_ext_community]->arg); return CMD_WARNING; } @@ -472,13 +457,12 @@ DEFUN(show_ip_bgp_l2vpn_evpn_rd_neighbor_routes, json_no = json_object_new_object(); json_object_string_add(json_no, "warning", "No such neighbor or address family"); - vty_out(vty, "%s%s", - json_object_to_json_string(json_no), - VTY_NEWLINE); + vty_out (vty, "%s\n", + json_object_to_json_string(json_no)); json_object_free(json_no); } else - vty_out(vty, "%% No such neighbor or address family%s", - VTY_NEWLINE); + vty_out (vty, + "%% No such neighbor or address family\n"); return CMD_WARNING; } @@ -499,12 +483,14 @@ DEFUN(show_ip_bgp_l2vpn_evpn_all_neighbor_advertised_routes, "Neighbor to display information about\n" "Display the routes advertised to a BGP neighbor\n" JSON_STR) { - int idx_ipv4 = 7; + int idx_ipv4 = 0; int ret; struct peer *peer; union sockunion su; u_char uj = use_json(argc, argv); + argv_find (argv, argc, "A.B.C.D", &idx_ipv4); + ret = str2sockunion(argv[idx_ipv4]->arg, &su); if (ret < 0) { if (uj) { @@ -512,13 +498,12 @@ DEFUN(show_ip_bgp_l2vpn_evpn_all_neighbor_advertised_routes, json_no = json_object_new_object(); json_object_string_add(json_no, "warning", "Malformed address"); - vty_out(vty, "%s%s", - json_object_to_json_string(json_no), - VTY_NEWLINE); + vty_out (vty, "%s\n", + json_object_to_json_string(json_no)); json_object_free(json_no); } else - vty_out(vty, "Malformed address: %s%s", - argv[idx_ipv4]->arg, VTY_NEWLINE); + vty_out (vty, "Malformed address: %s\n", + argv[idx_ipv4]->arg); return CMD_WARNING; } peer = peer_lookup(NULL, &su); @@ -528,13 +513,12 @@ DEFUN(show_ip_bgp_l2vpn_evpn_all_neighbor_advertised_routes, json_no = json_object_new_object(); json_object_string_add(json_no, "warning", "No such neighbor or address family"); - vty_out(vty, "%s%s", - json_object_to_json_string(json_no), - VTY_NEWLINE); + vty_out (vty, "%s\n", + json_object_to_json_string(json_no)); json_object_free(json_no); } else - vty_out(vty, "%% No such neighbor or address family%s", - VTY_NEWLINE); + vty_out (vty, + "%% No such neighbor or address family\n"); return CMD_WARNING; } @@ -555,14 +539,17 @@ DEFUN(show_ip_bgp_l2vpn_evpn_rd_neighbor_advertised_routes, "Neighbor to display information about\n" "Display the routes advertised to a BGP neighbor\n" JSON_STR) { - int idx_ext_community = 6; - int idx_ipv4 = 8; + int idx_ext_community = 0; + int idx_ipv4 = 0; int ret; struct peer *peer; struct prefix_rd prd; union sockunion su; u_char uj = use_json(argc, argv); + argv_find (argv, argc, "ASN:nn_or_IP-address:nn", &idx_ext_community); + argv_find (argv, argc, "A.B.C.D", &idx_ipv4); + ret = str2sockunion(argv[idx_ipv4]->arg, &su); if (ret < 0) { if (uj) { @@ -570,13 +557,12 @@ DEFUN(show_ip_bgp_l2vpn_evpn_rd_neighbor_advertised_routes, json_no = json_object_new_object(); json_object_string_add(json_no, "warning", "Malformed address"); - vty_out(vty, "%s%s", - json_object_to_json_string(json_no), - VTY_NEWLINE); + vty_out (vty, "%s\n", + json_object_to_json_string(json_no)); json_object_free(json_no); } else - vty_out(vty, "Malformed address: %s%s", - argv[idx_ext_community]->arg, VTY_NEWLINE); + vty_out (vty, "Malformed address: %s\n", + argv[idx_ext_community]->arg); return CMD_WARNING; } peer = peer_lookup(NULL, &su); @@ -586,13 +572,12 @@ DEFUN(show_ip_bgp_l2vpn_evpn_rd_neighbor_advertised_routes, json_no = json_object_new_object(); json_object_string_add(json_no, "warning", "No such neighbor or address family"); - vty_out(vty, "%s%s", - json_object_to_json_string(json_no), - VTY_NEWLINE); + vty_out (vty, "%s\n", + json_object_to_json_string(json_no)); json_object_free(json_no); } else - vty_out(vty, "%% No such neighbor or address family%s", - VTY_NEWLINE); + vty_out (vty, + "%% No such neighbor or address family\n"); return CMD_WARNING; } @@ -603,13 +588,11 @@ DEFUN(show_ip_bgp_l2vpn_evpn_rd_neighbor_advertised_routes, json_no = json_object_new_object(); json_object_string_add(json_no, "warning", "Malformed Route Distinguisher"); - vty_out(vty, "%s%s", - json_object_to_json_string(json_no), - VTY_NEWLINE); + vty_out (vty, "%s\n", + json_object_to_json_string(json_no)); json_object_free(json_no); } else - vty_out(vty, "%% Malformed Route Distinguisher%s", - VTY_NEWLINE); + vty_out (vty,"%% Malformed Route Distinguisher\n"); return CMD_WARNING; } @@ -644,13 +627,15 @@ DEFUN(show_ip_bgp_evpn_rd_overlay, "VPN Route Distinguisher\n" "Display BGP Overlay Information for prefixes\n") { - int idx_ext_community = 6; + int idx_ext_community = 0; int ret; struct prefix_rd prd; + argv_find (argv, argc, "ASN:nn_or_IP-address:nn", &idx_ext_community); + ret = str2prefix_rd(argv[idx_ext_community]->arg, &prd); if (!ret) { - vty_out(vty, "%% Malformed Route Distinguisher%s", VTY_NEWLINE); + vty_out (vty, "%% Malformed Route Distinguisher\n"); return CMD_WARNING; } return bgp_show_ethernet_vpn(vty, &prd, bgp_show_type_normal, NULL, @@ -677,7 +662,9 @@ DEFUN(evpnrt5_network, "Gateway IP ( A.B.C.D )\n" "Gateway IPv6 ( X:X::X:X )\n" "Router Mac Ext Comm\n" - "Router Mac address Value ( aa:bb:cc:dd:ee:ff format)\n") + "Router Mac address Value ( aa:bb:cc:dd:ee:ff format)\n" + "Route-map to modify the attributes\n" + "Name of the route map\n") { int idx_ipv4_prefixlen = 1; int idx_ext_community = 3; @@ -687,7 +674,7 @@ DEFUN(evpnrt5_network, int idx_ethtag = 5; int idx_routermac = 13; int idx_rmap = 15; - return bgp_static_set_safi(SAFI_EVPN, vty, + return bgp_static_set_safi(AFI_L2VPN, SAFI_EVPN, vty, argv[idx_ipv4_prefixlen]->arg, argv[idx_ext_community]->arg, argv[idx_word]->arg, @@ -721,7 +708,7 @@ DEFUN(no_evpnrt5_network, int idx_ethtag = 6; int idx_esi = 10; int idx_gwip = 12; - return bgp_static_unset_safi(SAFI_EVPN, vty, + return bgp_static_unset_safi(AFI_L2VPN, SAFI_EVPN, vty, argv[idx_ipv4_prefixlen]->arg, argv[idx_ext_community]->arg, argv[idx_label]->arg, EVPN_IP_PREFIX,