summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSteve Hill <quagga@cheesy.sackheads.org>2009-07-28 17:54:35 +0100
committerPaul Jakma <paul@quagga.net>2009-07-28 18:06:39 +0100
commitfc4dc59d08589a887ac33a70d946eb7905541f5f (patch)
treeb142a18a28ebf915757aafe6bf5a139ec0f112bb
parent3117b5c47df044f8b2197fff60641075394fdce5 (diff)
bgpd: Allow inbound connections to non-default view
* bgpd.c: (peer_lookup) Search through all BGP instances for matches, not just the default instance, if no specific instance is given. (peer_lookup_with_open) same.
-rw-r--r--bgpd/bgpd.c29
1 files changed, 22 insertions, 7 deletions
diff --git a/bgpd/bgpd.c b/bgpd/bgpd.c
index ef8fbe97..366ee432 100644
--- a/bgpd/bgpd.c
+++ b/bgpd/bgpd.c
@@ -2144,18 +2144,29 @@ peer_lookup (struct bgp *bgp, union sockunion *su)
struct peer *peer;
struct listnode *node, *nnode;
- if (! bgp)
- bgp = bgp_get_default ();
-
- if (! bgp)
- return NULL;
+ if (bgp != NULL)
+ {
+ for (ALL_LIST_ELEMENTS (bgp->peer, node, nnode, peer))
+ {
+ if (sockunion_same (&peer->su, su)
+ && ! CHECK_FLAG (peer->sflags, PEER_STATUS_ACCEPT_PEER))
+ return peer;
+ }
+ }
+ else if (bm->bgp != NULL)
+ {
+ struct listnode *bgpnode, *nbgpnode;
+ for(ALL_LIST_ELEMENTS(bm->bgp, bgpnode, nbgpnode, bgp))
+ {
for (ALL_LIST_ELEMENTS (bgp->peer, node, nnode, peer))
{
if (sockunion_same (&peer->su, su)
&& ! CHECK_FLAG (peer->sflags, PEER_STATUS_ACCEPT_PEER))
return peer;
}
+ }
+ }
return NULL;
}
@@ -2165,12 +2176,14 @@ peer_lookup_with_open (union sockunion *su, as_t remote_as,
{
struct peer *peer;
struct listnode *node, *nnode;
+ struct listnode *bgpnode, *nbgpnode;
struct bgp *bgp;
- bgp = bgp_get_default ();
- if (! bgp)
+ if (! bm->bgp)
return NULL;
+ for(ALL_LIST_ELEMENTS(bm->bgp, bgpnode, nbgpnode, bgp))
+ {
for (ALL_LIST_ELEMENTS (bgp->peer, node, nnode, peer))
{
if (sockunion_same (&peer->su, su)
@@ -2183,6 +2196,7 @@ peer_lookup_with_open (union sockunion *su, as_t remote_as,
*as = 1;
}
}
+
for (ALL_LIST_ELEMENTS (bgp->peer, node, nnode, peer))
{
if (sockunion_same (&peer->su, su)
@@ -2195,6 +2209,7 @@ peer_lookup_with_open (union sockunion *su, as_t remote_as,
*as = 1;
}
}
+ }
return NULL;
}