From 530db8dc0398fabe8a88a2c614e14a1f3ccc1ba4 Mon Sep 17 00:00:00 2001 From: Tuetuopay Date: Wed, 6 Mar 2019 19:15:10 +0100 Subject: [PATCH] bgpd, zebra: Scope EVPN commands to EVPN VRF If the EVPN VRF is not the default one (i.e. with advertise-all-vni), this allows showing its information with `show bgp l2evpn evpn ...` commands. They do not require adding `vrf VRFNAME` since we only support a single EVPN VRF. The same is true for zebra-specific commands (e.g. `show evpn ...`). Configuration commands are not restricted to the default VRF but to the EVPN one, that is to the one bearing `advertise-all-vni`. Signed-off-by: Tuetuopay Sponsored-by: Scaleway --- bgpd/bgp_evpn_vty.c | 82 ++++++++++++++++++++++----------------------- zebra/zebra_vty.c | 38 ++++++++++----------- zebra/zebra_vxlan.c | 8 ++--- 3 files changed, 64 insertions(+), 64 deletions(-) diff --git a/bgpd/bgp_evpn_vty.c b/bgpd/bgp_evpn_vty.c index 9ac1af046a..7f74ad48f2 100644 --- a/bgpd/bgp_evpn_vty.c +++ b/bgpd/bgp_evpn_vty.c @@ -1006,7 +1006,7 @@ static int bgp_show_ethernet_vpn(struct vty *vty, struct prefix_rd *prd, json_object *json_scode = NULL; json_object *json_ocode = NULL; - bgp = bgp_get_default(); + bgp = bgp_get_evpn(); if (bgp == NULL) { if (!use_json) vty_out(vty, "No BGP process is configured\n"); @@ -2917,9 +2917,9 @@ DEFUN (bgp_evpn_advertise_default_gw, if (!bgp) return CMD_WARNING; - if (bgp->vrf_id != VRF_DEFAULT) { + if (!bgp->advertise_all_vni) { vty_out(vty, - "This command is only supported under Default VRF\n"); + "This command is only supported under the EVPN VRF\n"); return CMD_WARNING; } @@ -2939,9 +2939,9 @@ DEFUN (no_bgp_evpn_advertise_default_gw, if (!bgp) return CMD_WARNING; - if (bgp->vrf_id != VRF_DEFAULT) { + if (!bgp->advertise_all_vni) { vty_out(vty, - "This command is only supported under Default VRF\n"); + "This command is only supported under the EVPN VRF\n"); return CMD_WARNING; } @@ -3066,9 +3066,9 @@ DEFPY (dup_addr_detection, if (!bgp_vrf) return CMD_WARNING; - if (bgp_vrf->vrf_id != VRF_DEFAULT) { + if (!bgp_vrf->advertise_all_vni) { vty_out(vty, - "This command is only supported under Default VRF\n"); + "This command is only supported under the EVPN VRF\n"); return CMD_WARNING; } @@ -3098,9 +3098,9 @@ DEFPY (dup_addr_detection_auto_recovery, if (!bgp_vrf) return CMD_WARNING; - if (bgp_vrf->vrf_id != VRF_DEFAULT) { + if (!bgp_vrf->advertise_all_vni) { vty_out(vty, - "This command is only supported under Default VRF\n"); + "This command is only supported under the EVPN VRF\n"); return CMD_WARNING; } @@ -3133,9 +3133,9 @@ DEFPY (no_dup_addr_detection, if (!bgp_vrf) return CMD_WARNING; - if (bgp_vrf->vrf_id != VRF_DEFAULT) { + if (!bgp_vrf->advertise_all_vni) { vty_out(vty, - "This command is only supported under Default VRF\n"); + "This command is only supported under the EVPN VRF\n"); return CMD_WARNING; } @@ -3205,9 +3205,9 @@ DEFPY(bgp_evpn_advertise_svi_ip, if (!bgp) return CMD_WARNING; - if (bgp->vrf_id != VRF_DEFAULT) { + if (!bgp->advertise_all_vni) { vty_out(vty, - "This command is only supported under Default VRF\n"); + "This command is only supported under EVPN VRF\n"); return CMD_WARNING; } @@ -3464,7 +3464,7 @@ DEFUN(show_bgp_l2vpn_evpn_vni, uj = use_json(argc, argv); - bgp_def = bgp_get_default(); + bgp_def = bgp_get_evpn(); if (!bgp_def) return CMD_WARNING; @@ -3559,7 +3559,7 @@ DEFUN(show_bgp_l2vpn_evpn_es, memset(&esi, 0, sizeof(esi)); uj = use_json(argc, argv); - bgp = bgp_get_default(); + bgp = bgp_get_evpn(); if (!bgp) return CMD_WARNING; @@ -3642,7 +3642,7 @@ DEFUN(show_bgp_l2vpn_evpn_route, uj = use_json(argc, argv); - bgp = bgp_get_default(); + bgp = bgp_get_evpn(); if (!bgp) return CMD_WARNING; @@ -3703,7 +3703,7 @@ DEFUN(show_bgp_l2vpn_evpn_route_rd, bool uj = false; json_object *json = NULL; - bgp = bgp_get_default(); + bgp = bgp_get_evpn(); if (!bgp) return CMD_WARNING; @@ -3779,7 +3779,7 @@ DEFUN(show_bgp_l2vpn_evpn_route_rd_macip, memset(&mac, 0, sizeof(struct ethaddr)); memset(&ip, 0, sizeof(struct ipaddr)); - bgp = bgp_get_default(); + bgp = bgp_get_evpn(); if (!bgp) return CMD_WARNING; @@ -3843,7 +3843,7 @@ DEFUN(show_bgp_l2vpn_evpn_route_esi, json_object *json = NULL; memset(&esi, 0, sizeof(esi)); - bgp = bgp_get_default(); + bgp = bgp_get_evpn(); if (!bgp) return CMD_WARNING; @@ -3896,7 +3896,7 @@ DEFUN(show_bgp_l2vpn_evpn_route_vni, show_bgp_l2vpn_evpn_route_vni_cmd, bool uj = false; json_object *json = NULL; - bgp = bgp_get_default(); + bgp = bgp_get_evpn(); if (!bgp) return CMD_WARNING; @@ -3968,7 +3968,7 @@ DEFUN(show_bgp_l2vpn_evpn_route_vni_macip, bool uj = false; json_object *json = NULL; - bgp = bgp_get_default(); + bgp = bgp_get_evpn(); if (!bgp) return CMD_WARNING; @@ -4036,7 +4036,7 @@ DEFUN(show_bgp_l2vpn_evpn_route_vni_multicast, bool uj = false; json_object *json = NULL; - bgp = bgp_get_default(); + bgp = bgp_get_evpn(); if (!bgp) return CMD_WARNING; @@ -4092,7 +4092,7 @@ DEFUN(show_bgp_l2vpn_evpn_route_vni_all, bool uj = false; json_object *json = NULL; - bgp = bgp_get_default(); + bgp = bgp_get_evpn(); if (!bgp) return CMD_WARNING; @@ -4141,7 +4141,7 @@ DEFUN(show_bgp_l2vpn_evpn_vrf_import_rt, struct bgp *bgp_def = NULL; json_object *json = NULL; - bgp_def = bgp_get_default(); + bgp_def = bgp_get_evpn(); if (!bgp_def) return CMD_WARNING; @@ -4177,7 +4177,7 @@ DEFUN(show_bgp_l2vpn_evpn_import_rt, bool uj = false; json_object *json = NULL; - bgp = bgp_get_default(); + bgp = bgp_get_evpn(); if (!bgp) return CMD_WARNING; @@ -4208,9 +4208,9 @@ DEFUN(test_adv_evpn_type4_route, struct bgp *bgp; struct ipaddr vtep_ip; - bgp = bgp_get_default(); + bgp = bgp_get_evpn(); if (!bgp) { - vty_out(vty, "%%Default BGP instance not yet created\n"); + vty_out(vty, "%%EVPN BGP instance not yet created\n"); return CMD_WARNING; } @@ -4242,9 +4242,9 @@ DEFUN(test_withdraw_evpn_type4_route, struct bgp *bgp; struct ipaddr vtep_ip; - bgp = bgp_get_default(); + bgp = bgp_get_evpn(); if (!bgp) { - vty_out(vty, "%%Default BGP instance not yet created\n"); + vty_out(vty, "%%EVPN BGP instance not yet created\n"); return CMD_WARNING; } @@ -4522,9 +4522,9 @@ DEFUN (bgp_evpn_vni_rd, if (!bgp) return CMD_WARNING; - if (bgp->vrf_id != VRF_DEFAULT) { + if (!bgp->advertise_all_vni) { vty_out(vty, - "This command is only supported under Default VRF\n"); + "This command is only supported under EVPN VRF\n"); return CMD_WARNING; } @@ -4558,9 +4558,9 @@ DEFUN (no_bgp_evpn_vni_rd, if (!bgp) return CMD_WARNING; - if (bgp->vrf_id != VRF_DEFAULT) { + if (!bgp->advertise_all_vni) { vty_out(vty, - "This command is only supported under Default VRF\n"); + "This command is only supported under EVPN VRF\n"); return CMD_WARNING; } @@ -4598,9 +4598,9 @@ DEFUN (no_bgp_evpn_vni_rd_without_val, if (!bgp) return CMD_WARNING; - if (bgp->vrf_id != VRF_DEFAULT) { + if (!bgp->advertise_all_vni) { vty_out(vty, - "This command is only supported under Default VRF\n"); + "This command is only supported under EVPN VRF\n"); return CMD_WARNING; } @@ -4927,9 +4927,9 @@ DEFUN (bgp_evpn_vni_rt, if (!bgp) return CMD_WARNING; - if (bgp->vrf_id != VRF_DEFAULT) { + if (!bgp->advertise_all_vni) { vty_out(vty, - "This command is only supported under Default VRF\n"); + "This command is only supported under EVPN VRF\n"); return CMD_WARNING; } @@ -4995,9 +4995,9 @@ DEFUN (no_bgp_evpn_vni_rt, if (!bgp) return CMD_WARNING; - if (bgp->vrf_id != VRF_DEFAULT) { + if (!bgp->advertise_all_vni) { vty_out(vty, - "This command is only supported under Default VRF\n"); + "This command is only supported under EVPN VRF\n"); return CMD_WARNING; } @@ -5094,9 +5094,9 @@ DEFUN (no_bgp_evpn_vni_rt_without_val, if (!bgp) return CMD_WARNING; - if (bgp->vrf_id != VRF_DEFAULT) { + if (!bgp->advertise_all_vni) { vty_out(vty, - "This command is only supported under Default VRF\n"); + "This command is only supported under EVPN VRF\n"); return CMD_WARNING; } diff --git a/zebra/zebra_vty.c b/zebra/zebra_vty.c index 537820f7ea..b88a05afa4 100644 --- a/zebra/zebra_vty.c +++ b/zebra/zebra_vty.c @@ -1797,7 +1797,7 @@ DEFUN (show_evpn_vni, struct zebra_vrf *zvrf; bool uj = use_json(argc, argv); - zvrf = vrf_info_lookup(VRF_DEFAULT); + zvrf = zebra_vrf_get_evpn(); zebra_vxlan_print_vnis(vty, zvrf, uj); return CMD_SUCCESS; } @@ -1813,7 +1813,7 @@ DEFUN (show_evpn_vni_detail, show_evpn_vni_detail_cmd, struct zebra_vrf *zvrf; bool uj = use_json(argc, argv); - zvrf = vrf_info_lookup(VRF_DEFAULT); + zvrf = zebra_vrf_get_evpn(); zebra_vxlan_print_vnis_detail(vty, zvrf, uj); return CMD_SUCCESS; } @@ -1832,7 +1832,7 @@ DEFUN (show_evpn_vni_vni, bool uj = use_json(argc, argv); vni = strtoul(argv[3]->arg, NULL, 10); - zvrf = vrf_info_lookup(VRF_DEFAULT); + zvrf = zebra_vrf_get_evpn(); zebra_vxlan_print_vni(vty, zvrf, vni, uj); return CMD_SUCCESS; } @@ -1976,7 +1976,7 @@ DEFUN (show_evpn_mac_vni, bool uj = use_json(argc, argv); vni = strtoul(argv[4]->arg, NULL, 10); - zvrf = vrf_info_lookup(VRF_DEFAULT); + zvrf = zebra_vrf_get_evpn(); zebra_vxlan_print_macs_vni(vty, zvrf, vni, uj); return CMD_SUCCESS; } @@ -1994,7 +1994,7 @@ DEFUN (show_evpn_mac_vni_all, struct zebra_vrf *zvrf; bool uj = use_json(argc, argv); - zvrf = vrf_info_lookup(VRF_DEFAULT); + zvrf = zebra_vrf_get_evpn(); zebra_vxlan_print_macs_all_vni(vty, zvrf, false, uj); return CMD_SUCCESS; } @@ -2012,7 +2012,7 @@ DEFUN (show_evpn_mac_vni_all_detail, show_evpn_mac_vni_all_detail_cmd, struct zebra_vrf *zvrf; bool uj = use_json(argc, argv); - zvrf = vrf_info_lookup(VRF_DEFAULT); + zvrf = zebra_vrf_get_evpn(); zebra_vxlan_print_macs_all_vni_detail(vty, zvrf, false, uj); return CMD_SUCCESS; } @@ -2038,7 +2038,7 @@ DEFUN (show_evpn_mac_vni_all_vtep, vty_out(vty, "%% Malformed VTEP IP address\n"); return CMD_WARNING; } - zvrf = vrf_info_lookup(VRF_DEFAULT); + zvrf = zebra_vrf_get_evpn(); zebra_vxlan_print_macs_all_vni_vtep(vty, zvrf, vtep_ip, uj); return CMD_SUCCESS; @@ -2068,7 +2068,7 @@ DEFUN (show_evpn_mac_vni_mac, vty_out(vty, "%% Malformed MAC address"); return CMD_WARNING; } - zvrf = vrf_info_lookup(VRF_DEFAULT); + zvrf = zebra_vrf_get_evpn(); zebra_vxlan_print_specific_mac_vni(vty, zvrf, vni, &mac, uj); return CMD_SUCCESS; } @@ -2097,7 +2097,7 @@ DEFUN (show_evpn_mac_vni_vtep, return CMD_WARNING; } - zvrf = vrf_info_lookup(VRF_DEFAULT); + zvrf = zebra_vrf_get_evpn(); zebra_vxlan_print_macs_vni_vtep(vty, zvrf, vni, vtep_ip, uj); return CMD_SUCCESS; } @@ -2116,7 +2116,7 @@ DEFPY (show_evpn_mac_vni_all_dad, struct zebra_vrf *zvrf; bool uj = use_json(argc, argv); - zvrf = vrf_info_lookup(VRF_DEFAULT); + zvrf = zebra_vrf_get_evpn(); zebra_vxlan_print_macs_all_vni(vty, zvrf, true, uj); return CMD_SUCCESS; } @@ -2138,7 +2138,7 @@ DEFPY (show_evpn_mac_vni_dad, bool uj = use_json(argc, argv); vni = strtoul(argv[4]->arg, NULL, 10); - zvrf = vrf_info_lookup(VRF_DEFAULT); + zvrf = zebra_vrf_get_evpn(); zebra_vxlan_print_macs_vni_dad(vty, zvrf, vni, uj); @@ -2161,7 +2161,7 @@ DEFPY (show_evpn_neigh_vni_dad, bool uj = use_json(argc, argv); vni = strtoul(argv[4]->arg, NULL, 10); - zvrf = vrf_info_lookup(VRF_DEFAULT); + zvrf = zebra_vrf_get_evpn(); zebra_vxlan_print_neigh_vni_dad(vty, zvrf, vni, uj); return CMD_SUCCESS; } @@ -2180,7 +2180,7 @@ DEFPY (show_evpn_neigh_vni_all_dad, struct zebra_vrf *zvrf; bool uj = use_json(argc, argv); - zvrf = vrf_info_lookup(VRF_DEFAULT); + zvrf = zebra_vrf_get_evpn(); zebra_vxlan_print_neigh_all_vni(vty, zvrf, true, uj); return CMD_SUCCESS; } @@ -2201,7 +2201,7 @@ DEFUN (show_evpn_neigh_vni, bool uj = use_json(argc, argv); vni = strtoul(argv[4]->arg, NULL, 10); - zvrf = vrf_info_lookup(VRF_DEFAULT); + zvrf = zebra_vrf_get_evpn(); zebra_vxlan_print_neigh_vni(vty, zvrf, vni, uj); return CMD_SUCCESS; } @@ -2219,7 +2219,7 @@ DEFUN (show_evpn_neigh_vni_all, struct zebra_vrf *zvrf; bool uj = use_json(argc, argv); - zvrf = vrf_info_lookup(VRF_DEFAULT); + zvrf = zebra_vrf_get_evpn(); zebra_vxlan_print_neigh_all_vni(vty, zvrf, false, uj); return CMD_SUCCESS; } @@ -2236,7 +2236,7 @@ DEFUN (show_evpn_neigh_vni_all_detail, show_evpn_neigh_vni_all_detail_cmd, struct zebra_vrf *zvrf; bool uj = use_json(argc, argv); - zvrf = vrf_info_lookup(VRF_DEFAULT); + zvrf = zebra_vrf_get_evpn(); zebra_vxlan_print_neigh_all_vni_detail(vty, zvrf, false, uj); return CMD_SUCCESS; } @@ -2264,7 +2264,7 @@ DEFUN (show_evpn_neigh_vni_neigh, vty_out(vty, "%% Malformed Neighbor address\n"); return CMD_WARNING; } - zvrf = vrf_info_lookup(VRF_DEFAULT); + zvrf = zebra_vrf_get_evpn(); zebra_vxlan_print_specific_neigh_vni(vty, zvrf, vni, &ip, uj); return CMD_SUCCESS; } @@ -2293,7 +2293,7 @@ DEFUN (show_evpn_neigh_vni_vtep, return CMD_WARNING; } - zvrf = vrf_info_lookup(VRF_DEFAULT); + zvrf = zebra_vrf_get_evpn(); zebra_vxlan_print_neigh_vni_vtep(vty, zvrf, vni, vtep_ip, uj); return CMD_SUCCESS; } @@ -2358,7 +2358,7 @@ DEFPY (clear_evpn_dup_addr, struct ethaddr mac_addr; int ret = CMD_SUCCESS; - zvrf = vrf_info_lookup(VRF_DEFAULT); + zvrf = zebra_vrf_get_evpn(); if (vni_val) { vni = strtoul(vni_val, NULL, 10); diff --git a/zebra/zebra_vxlan.c b/zebra/zebra_vxlan.c index fe7391f740..4debf5f2dc 100644 --- a/zebra/zebra_vxlan.c +++ b/zebra/zebra_vxlan.c @@ -3801,7 +3801,7 @@ static zebra_vni_t *zvni_lookup(vni_t vni) zebra_vni_t tmp_vni; zebra_vni_t *zvni = NULL; - zvrf = vrf_info_lookup(VRF_DEFAULT); + zvrf = zebra_vrf_get_evpn(); assert(zvrf); memset(&tmp_vni, 0, sizeof(zebra_vni_t)); tmp_vni.vni = vni; @@ -3819,7 +3819,7 @@ static zebra_vni_t *zvni_add(vni_t vni) zebra_vni_t tmp_zvni; zebra_vni_t *zvni = NULL; - zvrf = vrf_info_lookup(VRF_DEFAULT); + zvrf = zebra_vrf_get_evpn(); assert(zvrf); memset(&tmp_zvni, 0, sizeof(zebra_vni_t)); tmp_zvni.vni = vni; @@ -3845,7 +3845,7 @@ static int zvni_del(zebra_vni_t *zvni) struct zebra_vrf *zvrf; zebra_vni_t *tmp_zvni; - zvrf = vrf_info_lookup(VRF_DEFAULT); + zvrf = zebra_vrf_get_evpn(); assert(zvrf); zvni->vxlan_if = NULL; @@ -6924,7 +6924,7 @@ void zebra_vxlan_print_evpn(struct vty *vty, bool uj) if (!is_evpn_enabled()) return; - zvrf = vrf_info_lookup(VRF_DEFAULT); + zvrf = zebra_vrf_get_evpn(); if (!zvrf) return; -- 2.39.5