]> git.proxmox.com Git - mirror_frr.git/commitdiff
bgpd: implement bgpPeerTable accross VRFs
authorVincent Bernat <vincent@bernat.ch>
Thu, 6 Aug 2020 15:23:06 +0000 (17:23 +0200)
committerVincent Bernat <vincent@bernat.ch>
Thu, 6 Aug 2020 16:04:44 +0000 (18:04 +0200)
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>
bgpd/bgp_snmp.c

index 719ff1452b03a47b396ef3c2c078284c1e140709..303f4ca56e2ca964e90bf1f68886960288bde31d 100644 (file)
@@ -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;
+                       }
                }
        }