summaryrefslogtreecommitdiff
path: root/bgpd/bgp_zebra.c
diff options
context:
space:
mode:
Diffstat (limited to 'bgpd/bgp_zebra.c')
-rw-r--r--bgpd/bgp_zebra.c140
1 files changed, 66 insertions, 74 deletions
diff --git a/bgpd/bgp_zebra.c b/bgpd/bgp_zebra.c
index db5c877759..627e996937 100644
--- a/bgpd/bgp_zebra.c
+++ b/bgpd/bgp_zebra.c
@@ -67,6 +67,10 @@
/* All information about zebra. */
struct zclient *zclient = NULL;
+/* hook to indicate vrf status change for SNMP */
+DEFINE_HOOK(bgp_vrf_status_changed, (struct bgp *bgp, struct interface *ifp),
+ (bgp, ifp))
+
/* Can we install into zebra? */
static inline bool bgp_install_info_to_zebra(struct bgp *bgp)
{
@@ -212,8 +216,10 @@ static int bgp_ifp_destroy(struct interface *ifp)
if (BGP_DEBUG(zebra, ZEBRA))
zlog_debug("Rx Intf del VRF %u IF %s", ifp->vrf_id, ifp->name);
- if (bgp)
+ if (bgp) {
bgp_update_interface_nbrs(bgp, ifp, NULL);
+ hook_call(bgp_vrf_status_changed, bgp, ifp);
+ }
bgp_mac_del_mac_entry(ifp);
@@ -243,6 +249,7 @@ static int bgp_ifp_up(struct interface *ifp)
for (ALL_LIST_ELEMENTS(ifp->nbr_connected, node, nnode, nc))
bgp_nbr_connected_add(bgp, nc);
+ hook_call(bgp_vrf_status_changed, bgp, ifp);
return 0;
}
@@ -297,6 +304,7 @@ static int bgp_ifp_down(struct interface *ifp)
}
}
+ hook_call(bgp_vrf_status_changed, bgp, ifp);
return 0;
}
@@ -461,6 +469,8 @@ static int bgp_interface_vrf_update(ZAPI_CALLBACK_ARGS)
for (ALL_LIST_ELEMENTS(ifp->nbr_connected, node, nnode, nc))
bgp_nbr_connected_add(bgp, nc);
+
+ hook_call(bgp_vrf_status_changed, bgp, ifp);
return 0;
}
@@ -896,6 +906,7 @@ bgp_path_info_to_ipv6_nexthop(struct bgp_path_info *path, ifindex_t *ifindex)
/* Workaround for Cisco's nexthop bug. */
if (IN6_IS_ADDR_UNSPECIFIED(
&path->attr->mp_nexthop_global)
+ && path->peer->su_remote
&& path->peer->su_remote->sa.sa_family
== AF_INET6) {
nexthop =
@@ -1305,43 +1316,36 @@ void bgp_zebra_announce(struct bgp_dest *dest, const struct prefix *p,
ATTR_FLAG_BIT(BGP_ATTR_SRTE_COLOR)))
api_nh->srte_color = info->attr->srte_color;
- if (nh_family == AF_INET) {
- if (bgp_debug_zebra(&api.prefix)) {
- if (mpinfo->extra) {
- zlog_debug(
- "%s: p=%s, bgp_is_valid_label: %d",
- __func__, buf_prefix,
- bgp_is_valid_label(
- &mpinfo->extra
- ->label[0]));
- } else {
- zlog_debug(
- "%s: p=%s, extra is NULL, no label",
- __func__, buf_prefix);
- }
- }
-
- if (bgp->table_map[afi][safi].name) {
- /* Copy info and attributes, so the route-map
- apply doesn't modify the BGP route info. */
- local_attr = *mpinfo->attr;
- mpinfo_cp->attr = &local_attr;
+ if (bgp_debug_zebra(&api.prefix)) {
+ if (mpinfo->extra) {
+ zlog_debug("%s: p=%s, bgp_is_valid_label: %d",
+ __func__, buf_prefix,
+ bgp_is_valid_label(
+ &mpinfo->extra->label[0]));
+ } else {
+ zlog_debug("%s: p=%s, extra is NULL, no label",
+ __func__, buf_prefix);
}
+ }
- if (bgp->table_map[afi][safi].name) {
- if (!bgp_table_map_apply(
- bgp->table_map[afi][safi].map, p,
- mpinfo_cp))
- continue;
+ if (bgp->table_map[afi][safi].name) {
+ /* Copy info and attributes, so the route-map
+ apply doesn't modify the BGP route info. */
+ local_attr = *mpinfo->attr;
+ mpinfo_cp->attr = &local_attr;
+ if (!bgp_table_map_apply(bgp->table_map[afi][safi].map,
+ p, mpinfo_cp))
+ continue;
- /* metric/tag is only allowed to be
- * overridden on 1st nexthop */
- if (mpinfo == info) {
- metric = mpinfo_cp->attr->med;
- tag = mpinfo_cp->attr->tag;
- }
+ /* metric/tag is only allowed to be
+ * overridden on 1st nexthop */
+ if (mpinfo == info) {
+ metric = mpinfo_cp->attr->med;
+ tag = mpinfo_cp->attr->tag;
}
+ }
+ if (nh_family == AF_INET) {
nh_updated = update_ipv4nh_for_route_install(
nh_othervrf,
nh_othervrf ?
@@ -1352,38 +1356,23 @@ void bgp_zebra_announce(struct bgp_dest *dest, const struct prefix *p,
ifindex_t ifindex = IFINDEX_INTERNAL;
struct in6_addr *nexthop;
- if (bgp->table_map[afi][safi].name) {
- /* Copy info and attributes, so the route-map
- apply doesn't modify the BGP route info. */
- local_attr = *mpinfo->attr;
- mpinfo_cp->attr = &local_attr;
- }
-
- if (bgp->table_map[afi][safi].name) {
- /* Copy info and attributes, so the route-map
- apply doesn't modify the BGP route info. */
- local_attr = *mpinfo->attr;
- mpinfo_cp->attr = &local_attr;
-
- if (!bgp_table_map_apply(
- bgp->table_map[afi][safi].map, p,
- mpinfo_cp))
- continue;
-
- /* metric/tag is only allowed to be
- * overridden on 1st nexthop */
- if (mpinfo == info) {
- metric = mpinfo_cp->attr->med;
- tag = mpinfo_cp->attr->tag;
- }
- }
nexthop = bgp_path_info_to_ipv6_nexthop(mpinfo_cp,
&ifindex);
- nh_updated = update_ipv6nh_for_route_install(
- nh_othervrf, nh_othervrf ?
- info->extra->bgp_orig : bgp,
- nexthop, ifindex,
- mpinfo, info, is_evpn, api_nh);
+
+ if (!nexthop)
+ nh_updated = update_ipv4nh_for_route_install(
+ nh_othervrf,
+ nh_othervrf ? info->extra->bgp_orig
+ : bgp,
+ &mpinfo_cp->attr->nexthop,
+ mpinfo_cp->attr, is_evpn, api_nh);
+ else
+ nh_updated = update_ipv6nh_for_route_install(
+ nh_othervrf,
+ nh_othervrf ? info->extra->bgp_orig
+ : bgp,
+ nexthop, ifindex, mpinfo, info, is_evpn,
+ api_nh);
}
/* Did we get proper nexthop info to update zebra? */
@@ -1499,9 +1488,7 @@ void bgp_zebra_announce(struct bgp_dest *dest, const struct prefix *p,
api_nh->vrf_id, api_nh->weight,
label_buf, eth_buf);
}
- }
- if (bgp_debug_zebra(p)) {
int recursion_flag = 0;
if (CHECK_FLAG(api.flags, ZEBRA_FLAG_ALLOW_RECURSION))
@@ -2409,7 +2396,6 @@ static int bgp_zebra_route_notify_owner(int command, struct zclient *zclient,
struct prefix p;
enum zapi_route_notify_owner note;
uint32_t table_id;
- char buf[PREFIX_STRLEN];
afi_t afi;
safi_t safi;
struct bgp_dest *dest;
@@ -2431,9 +2417,6 @@ static int bgp_zebra_route_notify_owner(int command, struct zclient *zclient,
return -1;
}
- if (BGP_DEBUG(zebra, ZEBRA))
- prefix2str(&p, buf, sizeof(buf));
-
/* Find the bgp route node */
dest = bgp_afi_node_lookup(bgp->rib[afi][safi], afi, safi, &p,
&bgp->vrf_prd);
@@ -2452,7 +2435,7 @@ static int bgp_zebra_route_notify_owner(int command, struct zclient *zclient,
BGP_NODE_FIB_INSTALL_PENDING);
SET_FLAG(dest->flags, BGP_NODE_FIB_INSTALLED);
if (BGP_DEBUG(zebra, ZEBRA))
- zlog_debug("route %s : INSTALLED", buf);
+ zlog_debug("route %pRN : INSTALLED", dest);
/* Find the best route */
for (pi = dest->info; pi; pi = pi->next) {
/* Process aggregate route */
@@ -2468,8 +2451,8 @@ static int bgp_zebra_route_notify_owner(int command, struct zclient *zclient,
dest, new_select);
else {
flog_err(EC_BGP_INVALID_ROUTE,
- "selected route %s not found",
- buf);
+ "selected route %pRN not found",
+ dest);
return -1;
}
}
@@ -2480,16 +2463,24 @@ static int bgp_zebra_route_notify_owner(int command, struct zclient *zclient,
* route add later
*/
UNSET_FLAG(dest->flags, BGP_NODE_FIB_INSTALLED);
+ if (BGP_DEBUG(zebra, ZEBRA))
+ zlog_debug("route %pRN: Removed from Fib", dest);
break;
case ZAPI_ROUTE_FAIL_INSTALL:
+ if (BGP_DEBUG(zebra, ZEBRA))
+ zlog_debug("route: %pRN Failed to Install into Fib",
+ dest);
/* Error will be logged by zebra module */
break;
case ZAPI_ROUTE_BETTER_ADMIN_WON:
+ if (BGP_DEBUG(zebra, ZEBRA))
+ zlog_debug("route: %pRN removed due to better admin won",
+ dest);
/* No action required */
break;
case ZAPI_ROUTE_REMOVE_FAIL:
- zlog_warn("%s: Route %s failure to remove",
- __func__, buf);
+ zlog_warn("%s: Route %pRN failure to remove",
+ __func__, dest);
break;
}
return 0;
@@ -2983,6 +2974,7 @@ static int bgp_ifp_create(struct interface *ifp)
bgp_mac_add_mac_entry(ifp);
bgp_update_interface_nbrs(bgp, ifp, ifp);
+ hook_call(bgp_vrf_status_changed, bgp, ifp);
return 0;
}