summaryrefslogtreecommitdiffstats
path: root/bgpd/bgp_snmp.c
diff options
context:
space:
mode:
authorVincent Bernat <vincent@bernat.ch>2020-08-06 17:23:06 +0200
committerVincent Bernat <vincent@bernat.ch>2020-08-06 18:04:44 +0200
commit55443115621c4e1b7b2478bdf5d1d19178b6cf06 (patch)
tree0c1f835bc50e4cb7a0c0489c0065ff8acff7e1ee /bgpd/bgp_snmp.c
parentMerge pull request #6778 from mjstapp/fix_topo_route_scale (diff)
downloadfrr-55443115621c4e1b7b2478bdf5d1d19178b6cf06.tar.xz
frr-55443115621c4e1b7b2478bdf5d1d19178b6cf06.zip
bgpd: implement bgpPeerTable accross VRFs
Currently, bgpPeerTable only looks the default BGP instance. Most vendors return all the available peers in this table. This commit exposes all BGP instances. The other tables are unchanged as it doesn't make sense to expose routes from random VRFs into a single table. Vendors are using SNMP contexts for that but we don't have support for it. Therefore, do nothing. Fix #6077 Signed-off-by: Vincent Bernat <vincent@bernat.ch>
Diffstat (limited to 'bgpd/bgp_snmp.c')
-rw-r--r--bgpd/bgp_snmp.c46
1 files changed, 22 insertions, 24 deletions
diff --git a/bgpd/bgp_snmp.c b/bgpd/bgp_snmp.c
index 719ff1452..303f4ca56 100644
--- a/bgpd/bgp_snmp.c
+++ b/bgpd/bgp_snmp.c
@@ -356,17 +356,16 @@ static struct peer *peer_lookup_addr_ipv4(struct in_addr *src)
struct bgp *bgp;
struct peer *peer;
struct listnode *node;
+ struct listnode *bgpnode;
- bgp = bgp_get_default();
- if (!bgp)
- return NULL;
+ for (ALL_LIST_ELEMENTS_RO(bm->bgp, bgpnode, bgp)) {
+ for (ALL_LIST_ELEMENTS_RO(bgp->peer, node, peer)) {
+ if (sockunion_family(&peer->su) != AF_INET)
+ continue;
- for (ALL_LIST_ELEMENTS_RO(bgp->peer, node, peer)) {
- if (sockunion_family(&peer->su) != AF_INET)
- continue;
-
- if (sockunion2ip(&peer->su) == src->s_addr)
- return peer;
+ if (sockunion2ip(&peer->su) == src->s_addr)
+ return peer;
+ }
}
return NULL;
@@ -378,21 +377,20 @@ static struct peer *bgp_peer_lookup_next(struct in_addr *src)
struct peer *peer;
struct peer *next_peer = NULL;
struct listnode *node;
-
- bgp = bgp_get_default();
- if (!bgp)
- return NULL;
-
- for (ALL_LIST_ELEMENTS_RO(bgp->peer, node, peer)) {
- if (sockunion_family(&peer->su) != AF_INET)
- continue;
- if (ntohl(sockunion2ip(&peer->su)) <= ntohl(src->s_addr))
- continue;
-
- if (!next_peer
- || ntohl(sockunion2ip(&next_peer->su))
- > ntohl(sockunion2ip(&peer->su))) {
- next_peer = peer;
+ struct listnode *bgpnode;
+
+ for (ALL_LIST_ELEMENTS_RO(bm->bgp, bgpnode, bgp)) {
+ for (ALL_LIST_ELEMENTS_RO(bgp->peer, node, peer)) {
+ if (sockunion_family(&peer->su) != AF_INET)
+ continue;
+ if (ntohl(sockunion2ip(&peer->su)) <= ntohl(src->s_addr))
+ continue;
+
+ if (!next_peer
+ || ntohl(sockunion2ip(&next_peer->su))
+ > ntohl(sockunion2ip(&peer->su))) {
+ next_peer = peer;
+ }
}
}