From d1be1f083d2c73d8a6ce67ea9f729d22b75eafa6 Mon Sep 17 00:00:00 2001 From: vivek Date: Fri, 19 Feb 2016 18:43:30 -0800 Subject: BGP: Link BGP instance to corresponding VRF Link BGP instance (Default or VRF) to the corresponding VRF structure and modify lookup to use this. The logic is very similar to what is implemented in zebra - the 'struct zebra_vrf' there is essentially 'struct bgp' in BGP. Signed-off-by: Vivek Venkatraman Reviewed-by: Donald Sharp Ticket: CM-9122 Reviewed By: CCR-4102 Testing Done: Manual --- bgpd/bgpd.h | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) (limited to 'bgpd/bgpd.h') diff --git a/bgpd/bgpd.h b/bgpd/bgpd.h index ce318b338..8c6addacb 100644 --- a/bgpd/bgpd.h +++ b/bgpd/bgpd.h @@ -1438,4 +1438,39 @@ peer_cap_enhe (struct peer *peer) return (CHECK_FLAG(peer->af_cap[AFI_IP][SAFI_UNICAST], PEER_CAP_ENHE_AF_NEGO)); } +/* Lookup VRF for BGP instance based on its type. */ +static inline struct vrf * +bgp_vrf_lookup_by_instance_type (struct bgp *bgp) +{ + struct vrf *vrf; + + if (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) + vrf = vrf_lookup (VRF_DEFAULT); + else if (bgp->inst_type == BGP_INSTANCE_TYPE_VRF) + vrf = vrf_lookup_by_name (bgp->name); + else + vrf = NULL; + + return vrf; +} + +/* Link BGP instance to VRF. */ +static inline void +bgp_vrf_link (struct bgp *bgp, struct vrf *vrf) +{ + bgp->vrf_id = vrf->vrf_id; + bgp_lock (bgp); + vrf->info = (void *)bgp; + +} + +/* Unlink BGP instance from VRF. */ +static inline void +bgp_vrf_unlink (struct bgp *bgp, struct vrf *vrf) +{ + vrf->info = NULL; + bgp_unlock (bgp); + bgp->vrf_id = VRF_DEFAULT; +} + #endif /* _QUAGGA_BGPD_H */ -- cgit v1.2.3