summaryrefslogtreecommitdiff
path: root/bgpd/rfapi/rfapi_import.c
diff options
context:
space:
mode:
Diffstat (limited to 'bgpd/rfapi/rfapi_import.c')
-rw-r--r--bgpd/rfapi/rfapi_import.c40
1 files changed, 8 insertions, 32 deletions
diff --git a/bgpd/rfapi/rfapi_import.c b/bgpd/rfapi/rfapi_import.c
index 568f8d68e8..ad0900c2b8 100644
--- a/bgpd/rfapi/rfapi_import.c
+++ b/bgpd/rfapi/rfapi_import.c
@@ -375,41 +375,14 @@ int rfapiGetVncLifetime(struct attr *attr, uint32_t *lifetime)
}
/*
- * Extract the tunnel type from the extended community
- */
-int rfapiGetTunnelType(struct attr *attr, bgp_encap_types *type)
-{
- *type = BGP_ENCAP_TYPE_MPLS; /* default to MPLS */
- if (attr && attr->ecommunity) {
- struct ecommunity *ecom = attr->ecommunity;
- int i;
-
- for (i = 0; i < (ecom->size * ECOMMUNITY_SIZE);
- i += ECOMMUNITY_SIZE) {
- uint8_t *ep;
-
- ep = ecom->val + i;
- if (ep[0] == ECOMMUNITY_ENCODE_OPAQUE
- && ep[1] == ECOMMUNITY_OPAQUE_SUBTYPE_ENCAP) {
- *type = (ep[6] << 8) + ep[7];
- return 0;
- }
- }
- }
-
- return ENOENT;
-}
-
-
-/*
* Look for UN address in Encap attribute
*/
int rfapiGetVncTunnelUnAddr(struct attr *attr, struct prefix *p)
{
struct bgp_attr_encap_subtlv *pEncap;
- bgp_encap_types tun_type;
+ bgp_encap_types tun_type = BGP_ENCAP_TYPE_MPLS;/*Default tunnel type*/
- rfapiGetTunnelType(attr, &tun_type);
+ bgp_attr_extcom_tunnel_type(attr, &tun_type);
if (tun_type == BGP_ENCAP_TYPE_MPLS) {
if (!p)
return 0;
@@ -1350,7 +1323,7 @@ rfapiRouteInfo2NextHopEntry(struct rfapi_ip_prefix *rprefix,
}
if (bpi->attr) {
- bgp_encap_types tun_type;
+ bgp_encap_types tun_type = BGP_ENCAP_TYPE_MPLS; /*Default*/
new->prefix.cost = rfapiRfpCost(bpi->attr);
struct bgp_attr_encap_subtlv *pEncap;
@@ -1390,7 +1363,7 @@ rfapiRouteInfo2NextHopEntry(struct rfapi_ip_prefix *rprefix,
}
}
- rfapiGetTunnelType(bpi->attr, &tun_type);
+ bgp_attr_extcom_tunnel_type(bpi->attr, &tun_type);
if (tun_type == BGP_ENCAP_TYPE_MPLS) {
struct prefix p;
/* MPLS carries UN address in next hop */
@@ -2011,11 +1984,14 @@ static void rfapiBgpInfoAttachSorted(struct agg_node *rn,
for (prev = NULL, next = rn->info; next;
prev = next, next = next->next) {
+ enum bgp_path_selection_reason reason;
+
if (!bgp
|| (!CHECK_FLAG(info_new->flags, BGP_PATH_REMOVED)
&& CHECK_FLAG(next->flags, BGP_PATH_REMOVED))
|| bgp_path_info_cmp_compatible(bgp, info_new, next,
- pfx_buf, afi, safi)
+ pfx_buf, afi, safi,
+ &reason)
== -1) { /* -1 if 1st is better */
break;
}