Merge pull request #6872 from vincentbernat/fix/bgp4mib-vrf

bgpd: implement bgpPeerTable accross VRFs
This commit is contained in:
Donatas Abraitis 2020-08-07 18:04:47 +03:00 committed by GitHub
commit 940bb755fc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -356,17 +356,16 @@ static struct peer *peer_lookup_addr_ipv4(struct in_addr *src)
struct bgp *bgp; struct bgp *bgp;
struct peer *peer; struct peer *peer;
struct listnode *node; struct listnode *node;
struct listnode *bgpnode;
bgp = bgp_get_default(); for (ALL_LIST_ELEMENTS_RO(bm->bgp, bgpnode, bgp)) {
if (!bgp) for (ALL_LIST_ELEMENTS_RO(bgp->peer, node, peer)) {
return NULL; if (sockunion_family(&peer->su) != AF_INET)
continue;
for (ALL_LIST_ELEMENTS_RO(bgp->peer, node, peer)) { if (sockunion2ip(&peer->su) == src->s_addr)
if (sockunion_family(&peer->su) != AF_INET) return peer;
continue; }
if (sockunion2ip(&peer->su) == src->s_addr)
return peer;
} }
return NULL; return NULL;
@ -378,21 +377,20 @@ static struct peer *bgp_peer_lookup_next(struct in_addr *src)
struct peer *peer; struct peer *peer;
struct peer *next_peer = NULL; struct peer *next_peer = NULL;
struct listnode *node; struct listnode *node;
struct listnode *bgpnode;
bgp = bgp_get_default(); for (ALL_LIST_ELEMENTS_RO(bm->bgp, bgpnode, bgp)) {
if (!bgp) for (ALL_LIST_ELEMENTS_RO(bgp->peer, node, peer)) {
return NULL; if (sockunion_family(&peer->su) != AF_INET)
continue;
if (ntohl(sockunion2ip(&peer->su)) <= ntohl(src->s_addr))
continue;
for (ALL_LIST_ELEMENTS_RO(bgp->peer, node, peer)) { if (!next_peer
if (sockunion_family(&peer->su) != AF_INET) || ntohl(sockunion2ip(&next_peer->su))
continue; > ntohl(sockunion2ip(&peer->su))) {
if (ntohl(sockunion2ip(&peer->su)) <= ntohl(src->s_addr)) next_peer = peer;
continue; }
if (!next_peer
|| ntohl(sockunion2ip(&next_peer->su))
> ntohl(sockunion2ip(&peer->su))) {
next_peer = peer;
} }
} }