summaryrefslogtreecommitdiffstats
path: root/bgpd/bgpd.h
diff options
context:
space:
mode:
authorvivek <vivek@cumulusnetworks.com>2016-02-20 03:43:30 +0100
committervivek <vivek@cumulusnetworks.com>2016-02-20 03:43:30 +0100
commitd1be1f083d2c73d8a6ce67ea9f729d22b75eafa6 (patch)
tree64606dc0b9722d55a8fd6b2158e9fa5911c19cf3 /bgpd/bgpd.h
parentZebra: Cleanup and update RA debugs (diff)
downloadfrr-d1be1f083d2c73d8a6ce67ea9f729d22b75eafa6.tar.xz
frr-d1be1f083d2c73d8a6ce67ea9f729d22b75eafa6.zip
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 <vivek@cumulusnetworks.com> Reviewed-by: Donald Sharp <sharpd@cumulusnetworks.com> Ticket: CM-9122 Reviewed By: CCR-4102 Testing Done: Manual
Diffstat (limited to 'bgpd/bgpd.h')
-rw-r--r--bgpd/bgpd.h35
1 files changed, 35 insertions, 0 deletions
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 */