From f920dd6dc967f0d5c984387628b572d16431f38a Mon Sep 17 00:00:00 2001 From: Tuetuopay Date: Fri, 22 Mar 2019 13:37:06 +0100 Subject: [PATCH] bgpd, zebra: Redo checks to advertise_all_vni This replaces manual checks of the flag with a wrapper macro to convey the meaning "is evpn enabled on this vrf?" Signed-off-by: Tuetuopay Sponsored-by: Scaleway --- bgpd/bgp_evpn.h | 3 ++- bgpd/bgp_evpn_vty.c | 24 ++++++++++++------------ bgpd/bgp_zebra.c | 5 ++--- zebra/zebra_vxlan.c | 4 ++-- zebra/zebra_vxlan.h | 2 +- 5 files changed, 19 insertions(+), 19 deletions(-) diff --git a/bgpd/bgp_evpn.h b/bgpd/bgp_evpn.h index bcc524d5aa..7f88c1ebf0 100644 --- a/bgpd/bgp_evpn.h +++ b/bgpd/bgp_evpn.h @@ -27,12 +27,13 @@ #define EVPN_ROUTE_STRLEN 200 /* Must be >> MAC + IPv6 strings. */ #define EVPN_AUTORT_VXLAN 0x10000000 +#define EVPN_ENABLED(bgp) (bgp)->advertise_all_vni static inline int is_evpn_enabled(void) { struct bgp *bgp = NULL; bgp = bgp_get_evpn(); - return bgp ? bgp->advertise_all_vni : 0; + return bgp ? EVPN_ENABLED(bgp) : 0; } static inline void vni2label(vni_t vni, mpls_label_t *label) diff --git a/bgpd/bgp_evpn_vty.c b/bgpd/bgp_evpn_vty.c index 08f487e497..f020483ebb 100644 --- a/bgpd/bgp_evpn_vty.c +++ b/bgpd/bgp_evpn_vty.c @@ -2917,7 +2917,7 @@ DEFUN (bgp_evpn_advertise_default_gw, if (!bgp) return CMD_WARNING; - if (!bgp->advertise_all_vni) { + if (!EVPN_ENABLED(bgp)) { vty_out(vty, "This command is only supported under the EVPN VRF\n"); return CMD_WARNING; @@ -2939,7 +2939,7 @@ DEFUN (no_bgp_evpn_advertise_default_gw, if (!bgp) return CMD_WARNING; - if (!bgp->advertise_all_vni) { + if (!EVPN_ENABLED(bgp)) { vty_out(vty, "This command is only supported under the EVPN VRF\n"); return CMD_WARNING; @@ -3066,7 +3066,7 @@ DEFPY (dup_addr_detection, if (!bgp_vrf) return CMD_WARNING; - if (!bgp_vrf->advertise_all_vni) { + if (!EVPN_ENABLED(bgp_vrf)) { vty_out(vty, "This command is only supported under the EVPN VRF\n"); return CMD_WARNING; @@ -3098,7 +3098,7 @@ DEFPY (dup_addr_detection_auto_recovery, if (!bgp_vrf) return CMD_WARNING; - if (!bgp_vrf->advertise_all_vni) { + if (!EVPN_ENABLED(bgp_vrf)) { vty_out(vty, "This command is only supported under the EVPN VRF\n"); return CMD_WARNING; @@ -3133,7 +3133,7 @@ DEFPY (no_dup_addr_detection, if (!bgp_vrf) return CMD_WARNING; - if (!bgp_vrf->advertise_all_vni) { + if (!EVPN_ENABLED(bgp_vrf)) { vty_out(vty, "This command is only supported under the EVPN VRF\n"); return CMD_WARNING; @@ -3205,7 +3205,7 @@ DEFPY(bgp_evpn_advertise_svi_ip, if (!bgp) return CMD_WARNING; - if (!bgp->advertise_all_vni) { + if (!EVPN_ENABLED(bgp)) { vty_out(vty, "This command is only supported under EVPN VRF\n"); return CMD_WARNING; @@ -4522,7 +4522,7 @@ DEFUN (bgp_evpn_vni_rd, if (!bgp) return CMD_WARNING; - if (!bgp->advertise_all_vni) { + if (!EVPN_ENABLED(bgp)) { vty_out(vty, "This command is only supported under EVPN VRF\n"); return CMD_WARNING; @@ -4558,7 +4558,7 @@ DEFUN (no_bgp_evpn_vni_rd, if (!bgp) return CMD_WARNING; - if (!bgp->advertise_all_vni) { + if (!EVPN_ENABLED(bgp)) { vty_out(vty, "This command is only supported under EVPN VRF\n"); return CMD_WARNING; @@ -4598,7 +4598,7 @@ DEFUN (no_bgp_evpn_vni_rd_without_val, if (!bgp) return CMD_WARNING; - if (!bgp->advertise_all_vni) { + if (!EVPN_ENABLED(bgp)) { vty_out(vty, "This command is only supported under EVPN VRF\n"); return CMD_WARNING; @@ -4927,7 +4927,7 @@ DEFUN (bgp_evpn_vni_rt, if (!bgp) return CMD_WARNING; - if (!bgp->advertise_all_vni) { + if (!EVPN_ENABLED(bgp)) { vty_out(vty, "This command is only supported under EVPN VRF\n"); return CMD_WARNING; @@ -4995,7 +4995,7 @@ DEFUN (no_bgp_evpn_vni_rt, if (!bgp) return CMD_WARNING; - if (!bgp->advertise_all_vni) { + if (!EVPN_ENABLED(bgp)) { vty_out(vty, "This command is only supported under EVPN VRF\n"); return CMD_WARNING; @@ -5094,7 +5094,7 @@ DEFUN (no_bgp_evpn_vni_rt_without_val, if (!bgp) return CMD_WARNING; - if (!bgp->advertise_all_vni) { + if (!EVPN_ENABLED(bgp)) { vty_out(vty, "This command is only supported under EVPN VRF\n"); return CMD_WARNING; diff --git a/bgpd/bgp_zebra.c b/bgpd/bgp_zebra.c index 398735d7a4..0c77f63335 100644 --- a/bgpd/bgp_zebra.c +++ b/bgpd/bgp_zebra.c @@ -1632,8 +1632,7 @@ int bgp_redistribute_set(struct bgp *bgp, afi_t afi, int type, return CMD_WARNING; #if ENABLE_BGP_VNC - if (bgp->advertise_all_vni - && type == ZEBRA_ROUTE_VNC_DIRECT) { + if (EVPN_ENABLED(bgp) && type == ZEBRA_ROUTE_VNC_DIRECT) { vnc_export_bgp_enable( bgp, afi); /* only enables if mode bits cfg'd */ } @@ -1794,7 +1793,7 @@ int bgp_redistribute_unset(struct bgp *bgp, afi_t afi, int type, * status. red lookup fails if there is no zebra connection. */ #if ENABLE_BGP_VNC - if (bgp->advertise_all_vni && type == ZEBRA_ROUTE_VNC_DIRECT) { + if (EVPN_ENABLED(bgp) && type == ZEBRA_ROUTE_VNC_DIRECT) { vnc_export_bgp_disable(bgp, afi); } #endif diff --git a/zebra/zebra_vxlan.c b/zebra/zebra_vxlan.c index 0ceaed8d24..2934a2ecd5 100644 --- a/zebra/zebra_vxlan.c +++ b/zebra/zebra_vxlan.c @@ -9048,7 +9048,7 @@ void zebra_vxlan_advertise_all_vni(ZAPI_HANDLER_ARGS) /* Mismatch between EVPN VRF and current VRF (should be prevented by * bgpd's cli) */ - if (is_evpn_enabled() && !zvrf->advertise_all_vni) + if (is_evpn_enabled() && !EVPN_ENABLED(zvrf)) return; s = msg; @@ -9066,7 +9066,7 @@ void zebra_vxlan_advertise_all_vni(ZAPI_HANDLER_ARGS) return; zvrf->advertise_all_vni = advertise; - if (zvrf->advertise_all_vni) { + if (EVPN_ENABLED(zvrf)) { zvrf_default->evpn_vrf_id = zvrf_id(zvrf); /* Note BUM handling */ diff --git a/zebra/zebra_vxlan.h b/zebra/zebra_vxlan.h index 6ca33ae159..46165cf4da 100644 --- a/zebra/zebra_vxlan.h +++ b/zebra/zebra_vxlan.h @@ -41,7 +41,7 @@ static inline int is_evpn_enabled(void) { struct zebra_vrf *zvrf = NULL; zvrf = zebra_vrf_get_evpn(); - return zvrf ? zvrf->advertise_all_vni : 0; + return zvrf ? EVPN_ENABLED(zvrf) : 0; } static inline int -- 2.39.5