From: Mitesh Kanjariya Date: Tue, 27 Feb 2018 10:00:10 +0000 (-0800) Subject: Merge branch 'master' into evpn-bugs X-Git-Tag: frr-5.0-dev~200^2 X-Git-Url: https://git.puffer.fish/?a=commitdiff_plain;h=83ea2eb026c7054fdfd4ead9255b8a58c97001b7;p=matthieu%2Ffrr.git Merge branch 'master' into evpn-bugs --- 83ea2eb026c7054fdfd4ead9255b8a58c97001b7 diff --cc bgpd/bgp_evpn_private.h index 54e9b014cf,1dbc1f25f0..5d59ed5ae6 --- a/bgpd/bgp_evpn_private.h +++ b/bgpd/bgp_evpn_private.h @@@ -61,9 -61,9 +61,11 @@@ struct bgpevpn #define VNI_FLAG_RD_CFGD 0x4 /* RD is user configured. */ #define VNI_FLAG_IMPRT_CFGD 0x8 /* Import RT is user configured */ #define VNI_FLAG_EXPRT_CFGD 0x10 /* Export RT is user configured */ + #define VNI_FLAG_USE_TWO_LABELS 0x20 /* Attach both L2-VNI and L3-VNI if + needed for this VPN */ + struct bgp *bgp_vrf; /* back pointer to the vrf instance */ + /* Flag to indicate if we are advertising the g/w mac ip for this VNI*/ u_int8_t advertise_gw_macip; @@@ -163,31 -178,33 +165,37 @@@ static inline struct list *bgpevpn_get_ static inline void bgpevpn_unlink_from_l3vni(struct bgpevpn *vpn) { - struct bgp *bgp_vrf = NULL; - - bgp_vrf = bgp_lookup_by_vrf_id(vpn->tenant_vrf_id); - if (!bgp_vrf) + /* bail if vpn is not associated to bgp_vrf */ + if (!vpn->bgp_vrf) return; -- ++ + UNSET_FLAG(vpn->flags, VNI_FLAG_USE_TWO_LABELS); - - if (bgp_vrf->l2vnis) - listnode_delete(bgp_vrf->l2vnis, vpn); + listnode_delete(vpn->bgp_vrf->l2vnis, vpn); - ++ + /* remove the backpointer to the vrf instance */ + vpn->bgp_vrf = NULL; } static inline void bgpevpn_link_to_l3vni(struct bgpevpn *vpn) { struct bgp *bgp_vrf = NULL; + /* bail if vpn is already associated to vrf */ + if (vpn->bgp_vrf) + return; + bgp_vrf = bgp_lookup_by_vrf_id(vpn->tenant_vrf_id); - if (!bgp_vrf || !bgp_vrf->l2vnis) + if (!bgp_vrf) return; + /* associate the vpn to the bgp_vrf instance */ + vpn->bgp_vrf = bgp_vrf; + listnode_add_sort(bgp_vrf->l2vnis, vpn); ++ + /* check if we are advertising two labels for this vpn */ + if (!CHECK_FLAG(bgp_vrf->vrf_flags, + BGP_VRF_L3VNI_PREFIX_ROUTES_ONLY)) + SET_FLAG(vpn->flags, VNI_FLAG_USE_TWO_LABELS); - - if (bgp_vrf->l2vnis) - listnode_add_sort(bgp_vrf->l2vnis, vpn); } static inline int is_vni_configured(struct bgpevpn *vpn)