cf0516f4d83069a022cb2491113ed816b123730b
[openwrt-10.03/.git] / package / quagga / not-patches / patches-old / 140-bgpd-routes_from_established_peers.patch
1 From 234e5c8d5a35339fb319affb952581bf5abb48a7 Mon Sep 17 00:00:00 2001
2 From: Dinesh G Dutt <ddutt@cumulusnetworks.com>
3 Date: Sun, 1 Feb 2015 00:56:12 -0800
4 Subject: [PATCH] bgpd: Only use routes from Established peers for best path
5  selection
6
7 Ensure that routes from a peer are not considered for best path
8 comparison if the peer is not in an Established state. There can
9 be a window between a peer being deleted and the background
10 thread that actually clears the routes (marks them as "removed")
11 runs during which best path may run. If this path selection
12 compared two prefixes all the way down to peer IP addresses and
13 one of these two peers had just been deleted, that peer would
14 not have its sockunion structures, especially su_remote, resulting
15 in a BGPD exception.
16
17 Signed-off-by: Vivek Venkatraman <vivek@cumulusnetworks.com>
18 ---
19  bgpd/bgp_route.c | 14 ++++++++++++++
20  1 file changed, 14 insertions(+)
21
22 diff --git a/bgpd/bgp_route.c b/bgpd/bgp_route.c
23 index 648dc9c..02c926f 100644
24 --- a/bgpd/bgp_route.c
25 +++ b/bgpd/bgp_route.c
26 @@ -1345,6 +1345,9 @@ bgp_best_selection (struct bgp *bgp, struct bgp_node *rn,
27           continue;
28         if (BGP_INFO_HOLDDOWN (ri1))
29           continue;
30 +        if (ri1->peer && ri1->peer != bgp->peer_self)
31 +          if (ri1->peer->status != Established)
32 +            continue;
33  
34         new_select = ri1;
35         if (do_mpath)
36 @@ -1357,6 +1360,11 @@ bgp_best_selection (struct bgp *bgp, struct bgp_node *rn,
37                 continue;
38               if (BGP_INFO_HOLDDOWN (ri2))
39                 continue;
40 +              if (ri2->peer &&
41 +                  ri2->peer != bgp->peer_self &&
42 +                  !CHECK_FLAG (ri2->peer->sflags, PEER_STATUS_NSF_WAIT))
43 +                if (ri2->peer->status != Established)
44 +                  continue;
45  
46               if (aspath_cmp_left (ri1->attr->aspath, ri2->attr->aspath)
47                   || aspath_cmp_left_confed (ri1->attr->aspath,
48 @@ -1408,6 +1416,12 @@ bgp_best_selection (struct bgp *bgp, struct bgp_node *rn,
49            continue;
50          }
51  
52 +      if (ri->peer &&
53 +          ri->peer != bgp->peer_self &&
54 +          !CHECK_FLAG (ri->peer->sflags, PEER_STATUS_NSF_WAIT))
55 +        if (ri->peer->status != Established)
56 +          continue;
57 +
58        if (bgp_flag_check (bgp, BGP_FLAG_DETERMINISTIC_MED)
59            && (! CHECK_FLAG (ri->flags, BGP_INFO_DMED_SELECTED)))
60         {
61 -- 
62 2.7.0
63