diff options
Diffstat (limited to 'bgpd/bgp_zebra.c')
| -rw-r--r-- | bgpd/bgp_zebra.c | 128 |
1 files changed, 12 insertions, 116 deletions
diff --git a/bgpd/bgp_zebra.c b/bgpd/bgp_zebra.c index f6e7b444c6..95e80ba1bb 100644 --- a/bgpd/bgp_zebra.c +++ b/bgpd/bgp_zebra.c @@ -67,13 +67,10 @@ #include "bgpd/bgp_trace.h" #include "bgpd/bgp_community.h" #include "bgpd/bgp_lcommunity.h" -#include "bgpd/bgp_orr.h" /* All information about zebra. */ struct zclient *zclient = NULL; -static int bgp_opaque_msg_handler(ZAPI_CALLBACK_ARGS); - /* hook to indicate vrf status change for SNMP */ DEFINE_HOOK(bgp_vrf_status_changed, (struct bgp *bgp, struct interface *ifp), (bgp, ifp)); @@ -234,7 +231,6 @@ static int bgp_ifp_up(struct interface *ifp) struct connected *c; struct nbr_connected *nc; struct listnode *node, *nnode; - struct bgp *bgp_default = bgp_get_default(); struct bgp *bgp; bgp = ifp->vrf->info; @@ -257,14 +253,6 @@ static int bgp_ifp_up(struct interface *ifp) hook_call(bgp_vrf_status_changed, bgp, ifp); bgp_nht_ifp_up(ifp); - if (bgp_default && if_is_loopback(ifp)) { - vpn_leak_zebra_vrf_label_update(bgp, AFI_IP); - vpn_leak_zebra_vrf_label_update(bgp, AFI_IP6); - vpn_leak_zebra_vrf_sid_update(bgp, AFI_IP); - vpn_leak_zebra_vrf_sid_update(bgp, AFI_IP6); - vpn_leak_postchange_all(); - } - return 0; } @@ -273,7 +261,6 @@ static int bgp_ifp_down(struct interface *ifp) struct connected *c; struct nbr_connected *nc; struct listnode *node, *nnode; - struct bgp *bgp_default = bgp_get_default(); struct bgp *bgp; struct peer *peer; @@ -313,14 +300,6 @@ static int bgp_ifp_down(struct interface *ifp) hook_call(bgp_vrf_status_changed, bgp, ifp); bgp_nht_ifp_down(ifp); - if (bgp_default && if_is_loopback(ifp)) { - vpn_leak_zebra_vrf_label_update(bgp, AFI_IP); - vpn_leak_zebra_vrf_label_update(bgp, AFI_IP6); - vpn_leak_zebra_vrf_sid_update(bgp, AFI_IP); - vpn_leak_zebra_vrf_sid_update(bgp, AFI_IP6); - vpn_leak_postchange_all(); - } - return 0; } @@ -408,16 +387,10 @@ static int bgp_interface_address_add(ZAPI_CALLBACK_ARGS) static int bgp_interface_address_delete(ZAPI_CALLBACK_ARGS) { struct listnode *node, *nnode; - struct bgp_path_info *pi; - struct bgp_table *table; - struct bgp_dest *dest; struct connected *ifc; struct peer *peer; - struct bgp *bgp, *from_bgp, *bgp_default; - struct listnode *next; + struct bgp *bgp; struct prefix *addr; - afi_t afi; - safi_t safi; bgp = bgp_lookup_by_vrf_id(vrf_id); @@ -445,6 +418,9 @@ static int bgp_interface_address_delete(ZAPI_CALLBACK_ARGS) * we do not want the peering to bounce. */ for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { + afi_t afi; + safi_t safi; + if (addr->family == AF_INET) continue; @@ -460,44 +436,6 @@ static int bgp_interface_address_delete(ZAPI_CALLBACK_ARGS) } } - bgp_default = bgp_get_default(); - afi = family2afi(addr->family); - safi = SAFI_UNICAST; - - /* When the last IPv4 address was deleted, Linux removes all routes - * using the interface so that bgpd needs to re-send them. - */ - if (bgp_default && afi == AFI_IP) { - for (ALL_LIST_ELEMENTS_RO(bm->bgp, next, from_bgp)) { - table = from_bgp->rib[afi][safi]; - if (!table) - continue; - - for (dest = bgp_table_top(table); dest; - dest = bgp_route_next(dest)) { - for (pi = bgp_dest_get_bgp_path_info(dest); pi; - pi = pi->next) { - if (pi->type == ZEBRA_ROUTE_BGP && - pi->attr && - pi->attr->nh_ifindex == - ifc->ifp->ifindex) { - SET_FLAG(pi->attr->nh_flag, - BGP_ATTR_NH_REFRESH); - } - } - } - - if (from_bgp->inst_type != BGP_INSTANCE_TYPE_VRF) - continue; - - vpn_leak_postchange(BGP_VPN_POLICY_DIR_TOVPN, afi, - bgp_default, from_bgp); - - vpn_leak_postchange(BGP_VPN_POLICY_DIR_FROMVPN, afi, - bgp_default, from_bgp); - } - } - connected_free(&ifc); return 0; @@ -1066,8 +1004,7 @@ bgp_path_info_to_ipv6_nexthop(struct bgp_path_info *path, ifindex_t *ifindex) || path->attr->mp_nexthop_len == BGP_ATTR_NHLEN_VPNV6_GLOBAL_AND_LL) { /* Check if route-map is set to prefer global over link-local */ - if (CHECK_FLAG(path->attr->nh_flag, - BGP_ATTR_NH_MP_PREFER_GLOBAL)) { + if (path->attr->mp_nexthop_prefer_global) { nexthop = &path->attr->mp_nexthop_global; if (IN6_IS_ADDR_LINKLOCAL(nexthop)) *ifindex = path->attr->nh_ifindex; @@ -1367,7 +1304,6 @@ void bgp_zebra_announce(struct bgp_dest *dest, const struct prefix *p, uint8_t distance; struct peer *peer; struct bgp_path_info *mpinfo; - struct bgp_path_info *bpi_ultimate; struct bgp *bgp_orig; uint32_t metric; struct attr local_attr; @@ -1416,9 +1352,13 @@ void bgp_zebra_announce(struct bgp_dest *dest, const struct prefix *p, peer = info->peer; - if (info->type == ZEBRA_ROUTE_BGP) { - bpi_ultimate = bgp_get_imported_bpi_ultimate(info); - peer = bpi_ultimate->peer; + if (info->type == ZEBRA_ROUTE_BGP + && info->sub_type == BGP_ROUTE_IMPORTED) { + + /* Obtain peer from parent */ + if (info->extra && info->extra->parent) + peer = ((struct bgp_path_info *)(info->extra->parent)) + ->peer; } tag = info->attr->tag; @@ -3250,7 +3190,6 @@ extern struct zebra_privs_t bgpd_privs; static int bgp_ifp_create(struct interface *ifp) { - struct bgp *bgp_default = bgp_get_default(); struct bgp *bgp; if (BGP_DEBUG(zebra, ZEBRA)) @@ -3265,17 +3204,6 @@ static int bgp_ifp_create(struct interface *ifp) bgp_update_interface_nbrs(bgp, ifp, ifp); hook_call(bgp_vrf_status_changed, bgp, ifp); - - if (bgp_default && - (if_is_loopback_exact(ifp) || - (if_is_vrf(ifp) && ifp->vrf->vrf_id != VRF_DEFAULT))) { - vpn_leak_zebra_vrf_label_update(bgp, AFI_IP); - vpn_leak_zebra_vrf_label_update(bgp, AFI_IP6); - vpn_leak_zebra_vrf_sid_update(bgp, AFI_IP); - vpn_leak_zebra_vrf_sid_update(bgp, AFI_IP6); - vpn_leak_postchange_all(); - } - return 0; } @@ -3486,7 +3414,6 @@ static zclient_handler *const bgp_handlers[] = { [ZEBRA_SRV6_LOCATOR_DELETE] = bgp_zebra_process_srv6_locator_delete, [ZEBRA_SRV6_MANAGER_GET_LOCATOR_CHUNK] = bgp_zebra_process_srv6_locator_chunk, - [ZEBRA_OPAQUE_MESSAGE] = bgp_opaque_msg_handler, }; static int bgp_if_new_hook(struct interface *ifp) @@ -3939,34 +3866,3 @@ int bgp_zebra_srv6_manager_release_locator_chunk(const char *name) { return srv6_manager_release_locator_chunk(zclient, name); } - -/* - * ORR messages between processes - */ -static int bgp_opaque_msg_handler(ZAPI_CALLBACK_ARGS) -{ - struct stream *s; - struct zapi_opaque_msg info; - struct orr_igp_metric_info table; - int ret = 0; - - s = zclient->ibuf; - - if (zclient_opaque_decode(s, &info) != 0) { - bgp_orr_debug("%s: opaque decode failed", __func__); - return -1; - } - - switch (info.type) { - case ORR_IGP_METRIC_UPDATE: - STREAM_GET(&table, s, sizeof(table)); - ret = bgg_orr_message_process(BGP_ORR_IMSG_IGP_METRIC_UPDATE, - (void *)&table); - break; - default: - break; - } - -stream_failure: - return ret; -} |
