summaryrefslogtreecommitdiff
path: root/bgpd/bgp_mplsvpn.h
diff options
context:
space:
mode:
Diffstat (limited to 'bgpd/bgp_mplsvpn.h')
-rw-r--r--bgpd/bgp_mplsvpn.h31
1 files changed, 31 insertions, 0 deletions
diff --git a/bgpd/bgp_mplsvpn.h b/bgpd/bgp_mplsvpn.h
index 56dd33f9b1..75c0264987 100644
--- a/bgpd/bgp_mplsvpn.h
+++ b/bgpd/bgp_mplsvpn.h
@@ -342,6 +342,37 @@ static inline bool is_pi_family_vpn(struct bgp_path_info *pi)
is_pi_family_matching(pi, AFI_IP6, SAFI_MPLS_VPN));
}
+/*
+ * If you are using SRv6 VPN instead of MPLS, it need to check
+ * the SID allocation. If the sid is not allocated, the rib
+ * will be invalid.
+ * If the SID per VRF is not available, also consider the rib as
+ * invalid.
+ */
+static inline bool is_pi_srv6_valid(struct bgp_path_info *pi, struct bgp *bgp_nexthop, afi_t afi,
+ safi_t safi)
+{
+ if (!pi->attr->srv6_l3vpn && !pi->attr->srv6_vpn)
+ return false;
+
+ /* imported paths from VPN: srv6 enabled and nht reachability
+ * are enough to know if that path is valid
+ */
+ if (safi == SAFI_UNICAST)
+ return true;
+
+ if (bgp_nexthop->vpn_policy[afi].tovpn_sid == NULL && bgp_nexthop->tovpn_sid == NULL)
+ return false;
+
+ if (bgp_nexthop->tovpn_sid_index == 0 &&
+ !CHECK_FLAG(bgp_nexthop->vrf_flags, BGP_VRF_TOVPN_SID_AUTO) &&
+ bgp_nexthop->vpn_policy[afi].tovpn_sid_index == 0 &&
+ !CHECK_FLAG(bgp_nexthop->vpn_policy[afi].flags, BGP_VPN_POLICY_TOVPN_SID_AUTO))
+ return false;
+
+ return true;
+}
+
extern void vpn_policy_routemap_event(const char *rmap_name);
extern vrf_id_t get_first_vrf_for_redirect_with_rt(struct ecommunity *eckey);