diff options
Diffstat (limited to 'bgpd/bgp_zebra.c')
| -rw-r--r-- | bgpd/bgp_zebra.c | 88 |
1 files changed, 52 insertions, 36 deletions
diff --git a/bgpd/bgp_zebra.c b/bgpd/bgp_zebra.c index f42c16c1c1..3b762a362b 100644 --- a/bgpd/bgp_zebra.c +++ b/bgpd/bgp_zebra.c @@ -287,6 +287,7 @@ static int bgp_interface_down(int command, struct zclient *zclient, struct nbr_connected *nc; struct listnode *node, *nnode; struct bgp *bgp; + struct peer *peer; bgp = bgp_lookup_by_vrf_id(vrf_id); if (!bgp) @@ -307,11 +308,7 @@ static int bgp_interface_down(int command, struct zclient *zclient, bgp_nbr_connected_delete(bgp, nc, 1); /* Fast external-failover */ - { - struct peer *peer; - - if (CHECK_FLAG(bgp->flags, BGP_FLAG_NO_FAST_EXT_FAILOVER)) - return 0; + if (!CHECK_FLAG(bgp->flags, BGP_FLAG_NO_FAST_EXT_FAILOVER)) { for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { #if defined(HAVE_CUMULUS) @@ -474,6 +471,7 @@ static int bgp_interface_vrf_update(int command, struct zclient *zclient, struct nbr_connected *nc; struct listnode *node, *nnode; struct bgp *bgp; + struct peer *peer; ifp = zebra_interface_vrf_update_read(zclient->ibuf, vrf_id, &new_vrf_id); @@ -495,12 +493,7 @@ static int bgp_interface_vrf_update(int command, struct zclient *zclient, bgp_nbr_connected_delete(bgp, nc, 1); /* Fast external-failover */ - { - struct peer *peer; - - if (CHECK_FLAG(bgp->flags, BGP_FLAG_NO_FAST_EXT_FAILOVER)) - return 0; - + if (!CHECK_FLAG(bgp->flags, BGP_FLAG_NO_FAST_EXT_FAILOVER)) { for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { if ((peer->ttl != 1) && (peer->gtsm_hops != 1)) continue; @@ -777,8 +770,9 @@ static int if_get_ipv4_address(struct interface *ifp, struct in_addr *addr) return 0; } -int bgp_nexthop_set(union sockunion *local, union sockunion *remote, - struct bgp_nexthop *nexthop, struct peer *peer) + +bool bgp_zebra_nexthop_set(union sockunion *local, union sockunion *remote, + struct bgp_nexthop *nexthop, struct peer *peer) { int ret = 0; struct interface *ifp = NULL; @@ -786,9 +780,9 @@ int bgp_nexthop_set(union sockunion *local, union sockunion *remote, memset(nexthop, 0, sizeof(struct bgp_nexthop)); if (!local) - return -1; + return false; if (!remote) - return -1; + return false; if (local->sa.sa_family == AF_INET) { nexthop->v4 = local->sin.sin_addr; @@ -815,8 +809,24 @@ int bgp_nexthop_set(union sockunion *local, union sockunion *remote, peer->bgp->vrf_id); } - if (!ifp) - return -1; + if (!ifp) { + /* + * BGP views do not currently get proper data + * from zebra( when attached ) to be able to + * properly resolve nexthops, so give this + * instance type a pass. + */ + if (peer->bgp->inst_type == BGP_INSTANCE_TYPE_VIEW) + return true; + /* + * If we have no interface data but we have established + * some connection w/ zebra than something has gone + * terribly terribly wrong here, so say this failed + * If we do not any zebra connection then not + * having a ifp pointer is ok. + */ + return zclient_num_connects ? false : true; + } nexthop->ifp = ifp; @@ -912,7 +922,7 @@ int bgp_nexthop_set(union sockunion *local, union sockunion *remote, /* If we have identified the local interface, there is no error for now. */ - return 0; + return true; } static struct in6_addr *bgp_info_to_ipv6_nexthop(struct bgp_info *info, @@ -1078,8 +1088,8 @@ int bgp_zebra_get_table_range(uint32_t chunk_size, return -1; ret = tm_get_table_chunk(zclient, chunk_size, start, end); if (ret < 0) { - flog_err(BGP_ERR_TABLE_CHUNK, - "BGP: Error getting table chunk %u", chunk_size); + flog_err(EC_BGP_TABLE_CHUNK, + "BGP: Error getting table chunk %u", chunk_size); return -1; } zlog_info("BGP: Table Manager returns range from chunk %u is [%u %u]", @@ -2380,7 +2390,8 @@ static int bgp_zebra_process_local_macip(int command, struct zclient *zclient, int ipa_len; char buf[ETHER_ADDR_STRLEN]; char buf1[INET6_ADDRSTRLEN]; - uint8_t flags; + uint8_t flags = 0; + uint32_t seqnum = 0; memset(&ip, 0, sizeof(ip)); s = zclient->ibuf; @@ -2389,10 +2400,10 @@ static int bgp_zebra_process_local_macip(int command, struct zclient *zclient, ipa_len = stream_getl(s); if (ipa_len != 0 && ipa_len != IPV4_MAX_BYTELEN && ipa_len != IPV6_MAX_BYTELEN) { - flog_err(BGP_ERR_MACIP_LEN, - "%u:Recv MACIP %s with invalid IP addr length %d", - vrf_id, (command == ZEBRA_MACIP_ADD) ? "Add" : "Del", - ipa_len); + flog_err(EC_BGP_MACIP_LEN, + "%u:Recv MACIP %s with invalid IP addr length %d", + vrf_id, (command == ZEBRA_MACIP_ADD) ? "Add" : "Del", + ipa_len); return -1; } @@ -2401,20 +2412,24 @@ static int bgp_zebra_process_local_macip(int command, struct zclient *zclient, (ipa_len == IPV4_MAX_BYTELEN) ? IPADDR_V4 : IPADDR_V6; stream_get(&ip.ip.addr, s, ipa_len); } - flags = stream_getc(s); + if (command == ZEBRA_MACIP_ADD) { + flags = stream_getc(s); + seqnum = stream_getl(s); + } bgp = bgp_lookup_by_vrf_id(vrf_id); if (!bgp) return 0; if (BGP_DEBUG(zebra, ZEBRA)) - zlog_debug("%u:Recv MACIP %s flags 0x%x MAC %s IP %s VNI %u", + zlog_debug("%u:Recv MACIP %s flags 0x%x MAC %s IP %s VNI %u seq %u", vrf_id, (command == ZEBRA_MACIP_ADD) ? "Add" : "Del", flags, prefix_mac2str(&mac, buf, sizeof(buf)), - ipaddr2str(&ip, buf1, sizeof(buf1)), vni); + ipaddr2str(&ip, buf1, sizeof(buf1)), vni, seqnum); if (command == ZEBRA_MACIP_ADD) - return bgp_evpn_local_macip_add(bgp, vni, &mac, &ip, flags); + return bgp_evpn_local_macip_add(bgp, vni, &mac, &ip, + flags, seqnum); else return bgp_evpn_local_macip_del(bgp, vni, &mac, &ip); } @@ -2482,13 +2497,13 @@ static void bgp_zebra_process_label_chunk( STREAM_GETL(s, last); if (zclient->redist_default != proto) { - flog_err(BGP_ERR_LM_ERROR, "Got LM msg with wrong proto %u", - proto); + flog_err(EC_BGP_LM_ERROR, "Got LM msg with wrong proto %u", + proto); return; } if (zclient->instance != instance) { - flog_err(BGP_ERR_LM_ERROR, "Got LM msg with wrong instance %u", - proto); + flog_err(EC_BGP_LM_ERROR, "Got LM msg with wrong instance %u", + proto); return; } @@ -2496,8 +2511,8 @@ static void bgp_zebra_process_label_chunk( first < MPLS_LABEL_UNRESERVED_MIN || last > MPLS_LABEL_UNRESERVED_MAX) { - flog_err(BGP_ERR_LM_ERROR, "%s: Invalid Label chunk: %u - %u", - __func__, first, last); + flog_err(EC_BGP_LM_ERROR, "%s: Invalid Label chunk: %u - %u", + __func__, first, last); return; } if (BGP_DEBUG(zebra, ZEBRA)) { @@ -2513,7 +2528,7 @@ stream_failure: /* for STREAM_GETX */ extern struct zebra_privs_t bgpd_privs; -void bgp_zebra_init(struct thread_master *master) +void bgp_zebra_init(struct thread_master *master, unsigned short instance) { zclient_num_connects = 0; @@ -2552,6 +2567,7 @@ void bgp_zebra_init(struct thread_master *master) zclient->ipset_notify_owner = ipset_notify_owner; zclient->ipset_entry_notify_owner = ipset_entry_notify_owner; zclient->iptable_notify_owner = iptable_notify_owner; + zclient->instance = instance; } void bgp_zebra_destroy(void) |
