summaryrefslogtreecommitdiffstats
path: root/bgpd
diff options
context:
space:
mode:
authorDonald Sharp <sharpd@cumulusnetworks.com>2015-05-20 03:03:50 +0200
committerDonald Sharp <sharpd@cumulusnetworks.com>2015-05-20 03:03:50 +0200
commit75aead62b763031dae21ceda615fec5a148ae715 (patch)
tree6cd6781b3fb7004c53aa0f7ed736e2908a48a0c9 /bgpd
parentospfd: ospf-start-lsreq-b4-exchange.patch (diff)
downloadfrr-75aead62b763031dae21ceda615fec5a148ae715.tar.xz
frr-75aead62b763031dae21ceda615fec5a148ae715.zip
When internal operations are performed (e.g., best-path selection, next-hop
change processing etc.) that refer to the BGP instance, the correct BGP instance must be referenced and not the default BGP instance. The default BGP instance is the first instance on the instance list. In a scenario where one BGP instance is deleted (through operator action such as a "no router bgp" command) and another instance exists or is created, there may still be events in-flight that need to be processed against the deleted instance. Trying to process these against the default instance is erroneous. The calls to bgp_get_default() must be limited to the user interface (vtysh) context. Signed-off-by: Vivek Venkatraman <vivek@cumulusnetworks.com>
Diffstat (limited to 'bgpd')
-rw-r--r--bgpd/bgp_attr.c2
-rw-r--r--bgpd/bgp_fsm.c4
-rw-r--r--bgpd/bgp_nexthop.h1
-rw-r--r--bgpd/bgp_nht.c7
-rw-r--r--bgpd/bgp_nht.h5
-rw-r--r--bgpd/bgp_route.c12
6 files changed, 17 insertions, 14 deletions
diff --git a/bgpd/bgp_attr.c b/bgpd/bgp_attr.c
index e0c5cc893..9ae46dbb3 100644
--- a/bgpd/bgp_attr.c
+++ b/bgpd/bgp_attr.c
@@ -2249,7 +2249,7 @@ bgp_packet_attribute (struct bgp *bgp, struct peer *peer,
size_t mpattrlen_pos = 0;
if (! bgp)
- bgp = bgp_get_default ();
+ bgp = peer->bgp;
/* Remember current pointer. */
cp = stream_get_endp (s);
diff --git a/bgpd/bgp_fsm.c b/bgpd/bgp_fsm.c
index 5683c1544..19bd59f5b 100644
--- a/bgpd/bgp_fsm.c
+++ b/bgpd/bgp_fsm.c
@@ -1267,8 +1267,8 @@ bgp_start (struct peer *peer)
if ((peer->ttl == 1) || (peer->gtsm_hops == 1))
connected = 1;
- bgp_find_or_add_nexthop(family2afi(peer->su.sa.sa_family), NULL, peer,
- connected);
+ bgp_find_or_add_nexthop(peer->bgp, family2afi(peer->su.sa.sa_family),
+ NULL, peer, connected);
status = bgp_connect (peer);
switch (status)
diff --git a/bgpd/bgp_nexthop.h b/bgpd/bgp_nexthop.h
index 4d582465f..cee967303 100644
--- a/bgpd/bgp_nexthop.h
+++ b/bgpd/bgp_nexthop.h
@@ -52,6 +52,7 @@ struct bgp_nexthop_cache
void *nht_info; /* In BGP, peer session */
LIST_HEAD(path_list, bgp_info) paths;
unsigned int path_count;
+ struct bgp *bgp;
};
extern int bgp_nexthop_lookup (afi_t, struct peer *peer, struct bgp_info *,
diff --git a/bgpd/bgp_nht.c b/bgpd/bgp_nht.c
index df479bf25..c460f0ee6 100644
--- a/bgpd/bgp_nht.c
+++ b/bgpd/bgp_nht.c
@@ -89,8 +89,8 @@ bgp_unlink_nexthop (struct bgp_info *path)
}
int
-bgp_find_or_add_nexthop (afi_t afi, struct bgp_info *ri, struct peer *peer,
- int connected)
+bgp_find_or_add_nexthop (struct bgp *bgp, afi_t afi, struct bgp_info *ri,
+ struct peer *peer, int connected)
{
struct bgp_node *rn;
struct bgp_nexthop_cache *bnc;
@@ -124,6 +124,7 @@ bgp_find_or_add_nexthop (afi_t afi, struct bgp_info *ri, struct peer *peer,
bnc = bnc_new();
rn->info = bnc;
bnc->node = rn;
+ bnc->bgp = bgp;
bgp_lock_node(rn);
if (connected)
SET_FLAG(bnc->flags, BGP_NEXTHOP_CONNECTED);
@@ -432,7 +433,7 @@ evaluate_paths (struct bgp_nexthop_cache *bnc)
{
struct bgp_node *rn;
struct bgp_info *path;
- struct bgp *bgp = bgp_get_default();
+ struct bgp *bgp = bnc->bgp;
int afi;
struct peer *peer = (struct peer *)bnc->nht_info;
diff --git a/bgpd/bgp_nht.h b/bgpd/bgp_nht.h
index 0897d43a0..2c779802b 100644
--- a/bgpd/bgp_nht.h
+++ b/bgpd/bgp_nht.h
@@ -40,13 +40,14 @@ extern int bgp_find_nexthop(struct bgp_info *p, int connected);
* object. If not found, create a new object and register with ZEBRA for
* nexthop notification.
* ARGUMENTS:
+ * bgp - BGP instance
* a - afi: AFI_IP or AF_IP6
* p - path for which the nexthop object is being looked up
* peer - The BGP peer associated with this NHT
* connected - True if NH MUST be a connected route
*/
-extern int bgp_find_or_add_nexthop(afi_t a, struct bgp_info *p,
- struct peer *peer, int connected);
+extern int bgp_find_or_add_nexthop(struct bgp *bgp, afi_t a,
+ struct bgp_info *p, struct peer *peer, int connected);
/**
* bgp_unlink_nexthop() - Unlink the nexthop object from the path structure.
diff --git a/bgpd/bgp_route.c b/bgpd/bgp_route.c
index f37f3179a..7e0c60464 100644
--- a/bgpd/bgp_route.c
+++ b/bgpd/bgp_route.c
@@ -3052,7 +3052,7 @@ bgp_update_main (struct peer *peer, struct prefix *p, u_int32_t addpath_id,
else
connected = 0;
- if (bgp_find_or_add_nexthop (afi, ri, NULL, connected))
+ if (bgp_find_or_add_nexthop (bgp, afi, ri, NULL, connected))
bgp_info_set_flag (rn, ri, BGP_INFO_VALID);
else
{
@@ -3109,7 +3109,7 @@ bgp_update_main (struct peer *peer, struct prefix *p, u_int32_t addpath_id,
else
connected = 0;
- if (bgp_find_or_add_nexthop (afi, new, NULL, connected))
+ if (bgp_find_or_add_nexthop (bgp, afi, new, NULL, connected))
bgp_info_set_flag (rn, new, BGP_INFO_VALID);
else
{
@@ -4158,7 +4158,7 @@ bgp_static_update_rsclient (struct peer *rsclient, struct prefix *p,
/* Nexthop reachability check. */
if (bgp_flag_check (bgp, BGP_FLAG_IMPORT_CHECK))
{
- if (bgp_find_or_add_nexthop (afi, ri, NULL, 0))
+ if (bgp_find_or_add_nexthop (bgp, afi, ri, NULL, 0))
bgp_info_set_flag (rn, ri, BGP_INFO_VALID);
else
{
@@ -4187,7 +4187,7 @@ bgp_static_update_rsclient (struct peer *rsclient, struct prefix *p,
/* Nexthop reachability check. */
if (bgp_flag_check (bgp, BGP_FLAG_IMPORT_CHECK))
{
- if (bgp_find_or_add_nexthop (afi, new, NULL, 0))
+ if (bgp_find_or_add_nexthop (bgp, afi, new, NULL, 0))
bgp_info_set_flag (rn, new, BGP_INFO_VALID);
else
{
@@ -4307,7 +4307,7 @@ bgp_static_update_main (struct bgp *bgp, struct prefix *p,
/* Nexthop reachability check. */
if (bgp_flag_check (bgp, BGP_FLAG_IMPORT_CHECK))
{
- if (bgp_find_or_add_nexthop (afi, ri, NULL, 0))
+ if (bgp_find_or_add_nexthop (bgp, afi, ri, NULL, 0))
bgp_info_set_flag (rn, ri, BGP_INFO_VALID);
else
{
@@ -4337,7 +4337,7 @@ bgp_static_update_main (struct bgp *bgp, struct prefix *p,
/* Nexthop reachability check. */
if (bgp_flag_check (bgp, BGP_FLAG_IMPORT_CHECK))
{
- if (bgp_find_or_add_nexthop (afi, new, NULL, 0))
+ if (bgp_find_or_add_nexthop (bgp, afi, new, NULL, 0))
bgp_info_set_flag (rn, new, BGP_INFO_VALID);
else
{