modernize backfire 10.03 so it can be operational again
[openwrt-10.03/.git] / package / quagga / not-patches / patches-old / 130-bgpd_ignore_stale_entry.patch
1 From bd4b7f1559ab5cb52bbe9dc2db9e50a032ccdbb7 Mon Sep 17 00:00:00 2001
2 From: vivek <vivek@cumulusnetworks.com>
3 Date: Tue, 30 Sep 2014 15:54:45 -0700
4 Subject: [PATCH] bgpd: Ignore stale entry candidates during bestpath
5  selection.
6
7 During best path selection, if one of the candidates is a stale entry, do not
8 perform the neighbor address comparison as that information is invalid for
9 the stale entry. Attempting to perform the comparison results in a bgpd
10 exception.
11
12 Signed-off-by: Vivek Venkataraman <vivek@cumulusnetworks.com>
13 Reviewed-by: Dinesh G Dutt <ddutt@cumulusnetworks.com>
14 ---
15  bgpd/bgp_route.c | 14 +++++++++++++-
16  1 file changed, 13 insertions(+), 1 deletion(-)
17
18 diff --git a/bgpd/bgp_route.c b/bgpd/bgp_route.c
19 index 34ba1ab..648dc9c 100644
20 --- a/bgpd/bgp_route.c
21 +++ b/bgpd/bgp_route.c
22 @@ -524,7 +524,11 @@ bgp_info_cmp (struct bgp *bgp, struct bgp_info *new, struct bgp_info *exist,
23         return 0;
24      }
25  
26 -  /* 11. Rourter-ID comparision. */
27 +  /* 11. Router-ID comparision. */
28 +  /* If one of the paths is "stale", the corresponding peer router-id will
29 +   * be 0 and would always win over the other path. If originator id is
30 +   * used for the comparision, it will decide which path is better.
31 +   */
32    if (newattr->flag & ATTR_FLAG_BIT(BGP_ATTR_ORIGINATOR_ID))
33      new_id.s_addr = newattre->originator_id.s_addr;
34    else
35 @@ -553,6 +557,14 @@ bgp_info_cmp (struct bgp *bgp, struct bgp_info *new, struct bgp_info *exist,
36      return 0;
37  
38    /* 13. Neighbor address comparision. */
39 +  /* Do this only if neither path is "stale" as stale paths do not have
40 +   * valid peer information (as the connection may or may not be up).
41 +   */
42 +  if (CHECK_FLAG (exist->flags, BGP_INFO_STALE))
43 +    return 1;
44 +  if (CHECK_FLAG (new->flags, BGP_INFO_STALE))
45 +    return 0;
46 +
47    ret = sockunion_cmp (new->peer->su_remote, exist->peer->su_remote);
48  
49    if (ret == 1)
50 -- 
51 2.7.0
52