bgpd: move l2vpn evpn related flags in struct bgp to af_flags

We have af_flags in struct bgp to hold address family related flags,
l2vpn evpn flags to indicate advertise ipvX unicast should be moved there.

Signed-off-by: Mitesh Kanjariya <mitesh@cumulusnetworks.com>
This commit is contained in:
Mitesh Kanjariya 2018-02-20 00:46:22 -08:00 committed by mitesh
parent fdf19f06f2
commit 154faa5007
3 changed files with 33 additions and 24 deletions

View File

@ -62,11 +62,13 @@ static inline int advertise_type5_routes(struct bgp *bgp_vrf,
return 0; return 0;
if (afi == AFI_IP && if (afi == AFI_IP &&
CHECK_FLAG(bgp_vrf->vrf_flags, BGP_VRF_ADVERTISE_IPV4_IN_EVPN)) CHECK_FLAG(bgp_vrf->af_flags[AFI_L2VPN][SAFI_EVPN],
BGP_L2VPN_EVPN_ADVERTISE_IPV4_UNICAST))
return 1; return 1;
if (afi == AFI_IP6 && if (afi == AFI_IP6 &&
CHECK_FLAG(bgp_vrf->vrf_flags, BGP_VRF_ADVERTISE_IPV6_IN_EVPN)) CHECK_FLAG(bgp_vrf->af_flags[AFI_L2VPN][SAFI_EVPN],
BGP_L2VPN_EVPN_ADVERTISE_IPV6_UNICAST))
return 1; return 1;
return 0; return 0;

View File

@ -2761,21 +2761,23 @@ DEFUN (bgp_evpn_advertise_type5,
/* if we are already advertising ipv4 prefix as type-5 /* if we are already advertising ipv4 prefix as type-5
* nothing to do * nothing to do
*/ */
if (!rmap_changed && CHECK_FLAG(bgp_vrf->vrf_flags, if (!rmap_changed &&
BGP_VRF_ADVERTISE_IPV4_IN_EVPN)) CHECK_FLAG(bgp_vrf->af_flags[AFI_L2VPN][SAFI_EVPN],
BGP_L2VPN_EVPN_ADVERTISE_IPV4_UNICAST))
return CMD_WARNING; return CMD_WARNING;
SET_FLAG(bgp_vrf->vrf_flags, SET_FLAG(bgp_vrf->af_flags[AFI_L2VPN][SAFI_EVPN],
BGP_VRF_ADVERTISE_IPV4_IN_EVPN); BGP_L2VPN_EVPN_ADVERTISE_IPV4_UNICAST);
} else { } else {
/* if we are already advertising ipv6 prefix as type-5 /* if we are already advertising ipv6 prefix as type-5
* nothing to do * nothing to do
*/ */
if (!rmap_changed && CHECK_FLAG(bgp_vrf->vrf_flags, if (!rmap_changed &&
BGP_VRF_ADVERTISE_IPV6_IN_EVPN)) CHECK_FLAG(bgp_vrf->af_flags[AFI_L2VPN][SAFI_EVPN],
BGP_L2VPN_EVPN_ADVERTISE_IPV6_UNICAST))
return CMD_WARNING; return CMD_WARNING;
SET_FLAG(bgp_vrf->vrf_flags, SET_FLAG(bgp_vrf->af_flags[AFI_L2VPN][SAFI_EVPN],
BGP_VRF_ADVERTISE_IPV6_IN_EVPN); BGP_L2VPN_EVPN_ADVERTISE_IPV6_UNICAST);
} }
if (rmap_changed) { if (rmap_changed) {
@ -2836,22 +2838,22 @@ DEFUN (no_bgp_evpn_advertise_type5,
/* if we are not advertising ipv4 prefix as type-5 /* if we are not advertising ipv4 prefix as type-5
* nothing to do * nothing to do
*/ */
if (CHECK_FLAG(bgp_vrf->vrf_flags, if (CHECK_FLAG(bgp_vrf->af_flags[AFI_L2VPN][SAFI_EVPN],
BGP_VRF_ADVERTISE_IPV4_IN_EVPN)) { BGP_L2VPN_EVPN_ADVERTISE_IPV4_UNICAST)) {
bgp_evpn_withdraw_type5_routes(bgp_vrf, afi, safi); bgp_evpn_withdraw_type5_routes(bgp_vrf, afi, safi);
UNSET_FLAG(bgp_vrf->vrf_flags, UNSET_FLAG(bgp_vrf->af_flags[AFI_L2VPN][SAFI_EVPN],
BGP_VRF_ADVERTISE_IPV4_IN_EVPN); BGP_L2VPN_EVPN_ADVERTISE_IPV4_UNICAST);
} }
} else { } else {
/* if we are not advertising ipv6 prefix as type-5 /* if we are not advertising ipv6 prefix as type-5
* nothing to do * nothing to do
*/ */
if (CHECK_FLAG(bgp_vrf->vrf_flags, if (CHECK_FLAG(bgp_vrf->af_flags[AFI_L2VPN][SAFI_EVPN],
BGP_VRF_ADVERTISE_IPV6_IN_EVPN)) { BGP_L2VPN_EVPN_ADVERTISE_IPV6_UNICAST)) {
bgp_evpn_withdraw_type5_routes(bgp_vrf, afi, safi); bgp_evpn_withdraw_type5_routes(bgp_vrf, afi, safi);
UNSET_FLAG(bgp_vrf->vrf_flags, UNSET_FLAG(bgp_vrf->vrf_flags,
BGP_VRF_ADVERTISE_IPV6_IN_EVPN); BGP_L2VPN_EVPN_ADVERTISE_IPV6_UNICAST);
} }
} }
@ -4373,10 +4375,12 @@ void bgp_config_write_evpn_info(struct vty *vty, struct bgp *bgp, afi_t afi,
if (bgp->advertise_gw_macip) if (bgp->advertise_gw_macip)
vty_out(vty, " advertise-default-gw\n"); vty_out(vty, " advertise-default-gw\n");
if (CHECK_FLAG(bgp->vrf_flags, BGP_VRF_ADVERTISE_IPV4_IN_EVPN)) if (CHECK_FLAG(bgp->af_flags[AFI_L2VPN][SAFI_EVPN],
BGP_L2VPN_EVPN_ADVERTISE_IPV4_UNICAST))
vty_out(vty, " advertise ipv4 unicast\n"); vty_out(vty, " advertise ipv4 unicast\n");
if (CHECK_FLAG(bgp->vrf_flags, BGP_VRF_ADVERTISE_IPV6_IN_EVPN)) if (CHECK_FLAG(bgp->af_flags[AFI_L2VPN][SAFI_EVPN],
BGP_L2VPN_EVPN_ADVERTISE_IPV6_UNICAST))
vty_out(vty, " advertise ipv6 unicast\n"); vty_out(vty, " advertise ipv6 unicast\n");
} }

View File

@ -320,6 +320,11 @@ struct bgp {
u_int16_t af_flags[AFI_MAX][SAFI_MAX]; u_int16_t af_flags[AFI_MAX][SAFI_MAX];
#define BGP_CONFIG_DAMPENING (1 << 0) #define BGP_CONFIG_DAMPENING (1 << 0)
/* l2vpn evpn flags */
#define BGP_L2VPN_EVPN_ADVERTISE_IPV4_UNICAST (1 << 0)
#define BGP_L2VPN_EVPN_ADVERTISE_IPV6_UNICAST (1 << 1)
/* Route table for next-hop lookup cache. */ /* Route table for next-hop lookup cache. */
struct bgp_table *nexthop_cache_table[AFI_MAX]; struct bgp_table *nexthop_cache_table[AFI_MAX];
@ -431,11 +436,9 @@ struct bgp {
/* vrf flags */ /* vrf flags */
uint32_t vrf_flags; uint32_t vrf_flags;
#define BGP_VRF_AUTO (1 << 0) #define BGP_VRF_AUTO (1 << 0)
#define BGP_VRF_ADVERTISE_IPV4_IN_EVPN (1 << 1) #define BGP_VRF_IMPORT_RT_CFGD (1 << 1)
#define BGP_VRF_ADVERTISE_IPV6_IN_EVPN (1 << 2) #define BGP_VRF_EXPORT_RT_CFGD (1 << 2)
#define BGP_VRF_IMPORT_RT_CFGD (1 << 3) #define BGP_VRF_RD_CFGD (1 << 3)
#define BGP_VRF_EXPORT_RT_CFGD (1 << 4)
#define BGP_VRF_RD_CFGD (1 << 5)
/* unique ID for auto derivation of RD for this vrf */ /* unique ID for auto derivation of RD for this vrf */
uint16_t vrf_rd_id; uint16_t vrf_rd_id;