Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Not correct reason description in bgp bestpath #16914

Open
ak503 opened this issue Sep 25, 2024 · 3 comments
Open

Not correct reason description in bgp bestpath #16914

ak503 opened this issue Sep 25, 2024 · 3 comments
Labels

Comments

@ak503
Copy link
Contributor

ak503 commented Sep 25, 2024

example topo:

|----------------------     R3          -------- 192.168.199.0/24
|    192.16.3.0/24       RID 1.1.1.3          
|                        AS 65003
|                        MED 150
|
|
|    192.16.2.0/24
R1 --------------------    R2          -------- 192.168.199.0/24
AS 65001                 RID 1.1.1.2
|                        AS 65024
|                        MED 200
|
|
|----------------------     R4          -------- 192.168.199.0/24
    192.16.4.0/24        RID 1.1.1.4
                         AS 65024
                         MED 100

R1:

debug bgp bestpath 192.168.199.0/24

router bgp 65001
 no bgp ebgp-requires-policy
 neighbor 192.168.2.2 remote-as 65024
 neighbor 192.168.3.3 remote-as 65003
 neighbor 192.168.4.4 remote-as 65024
exit

R2:

ip prefix-list ned_pref_out seq 10 permit 192.168.199.0/24

router bgp 65024
 bgp router-id 1.1.1.2
 no bgp ebgp-requires-policy
 neighbor 192.168.2.1 remote-as 65001
 !
 address-family ipv4 unicast
  network 192.168.199.0/24
  neighbor 192.168.2.1 route-map med_rp_out out
 exit-address-family
exit
!
route-map med_rp_out permit 10
 match ip address prefix-list ned_pref_out
 set metric 200
exit

R3:

ip prefix-list med_pref_out seq 10 permit 192.168.199.0/24
!
router bgp 65003
 bgp router-id 1.1.1.3
 no bgp ebgp-requires-policy
 neighbor 192.168.3.1 remote-as 65001
 !
 address-family ipv4 unicast
  network 192.168.199.0/24
  neighbor 192.168.3.1 route-map med_rp_out out
 exit-address-family
exit
!
route-map med_rp_out permit 10
 match ip address prefix-list med_pref_out
 set metric 150
exit

R4:

ip prefix-list med_pref_out seq 10 permit 192.168.199.0/24
!
router bgp 65024
 bgp router-id 1.1.1.4
 no bgp ebgp-requires-policy
 neighbor 192.168.4.1 remote-as 65001
 !
 address-family ipv4 unicast
  network 192.168.199.0/24
  neighbor 192.168.4.1 route-map med_rp_out out
 exit-address-family
exit
!
route-map med_rp_out permit 10
 match ip address prefix-list med_pref_out
 set metric 100
exit

Run R2, then R3, then R4

  1. Run R2
    R1 info:
bgp_process_main_one: p=192.168.199.0/24(VRF default) afi=IPv4, safi=unicast start
192.168.199.0/24(VRF default): After path selection, newbest is path 192.168.2.2 oldbest was NONE
192.168.199.0/24(VRF default): path 192.168.2.2 is the bestpath, add to the multipath list
192.168.199.0/24(VRF default): starting mpath update, newbest 192.168.2.2 num candidates 1 old-mpath-count 0 old-cum-bw 0
192.168.199.0/24(VRF default): comparing candidate 192.168.2.2 with existing mpath NONE
192.168.199.0/24(VRF default): New mpath count (incl newbest) 1 mpath-change NO all_paths_lb 0 cum_bw 0
bgp_process_main_one: p=192.168.199.0/24(VRF default) afi=IPv4, safi=unicast, old_select=0x0, new_select=0x1721190
bgp_process_main_one: 192.168.199.0/24 setting SELECTED flag

# do show bgp ipv4 192.168.199.0/24
BGP routing table entry for 192.168.199.0/24, version 6
Paths: (1 available, best #1, table default)
  Advertised to non peer-group peers:
  192.168.2.2
  65024
    192.168.2.2 from 192.168.2.2 (1.1.1.2)
      Origin IGP, metric 200, valid, external, best (First path received)
      Last update: Wed Sep 25 13:12:45 2024
  1. Run R3
    R1 info:
bgp_process_main_one: p=192.168.199.0/24(VRF default) afi=IPv4, safi=unicast start
192.168.199.0/24(VRF default): Comparing path 192.168.3.3 flags Valid Counted Unsorted  with path 192.168.2.2 flags Selected Valid Counted 
192.168.199.0/24: path 192.168.3.3 loses to path 192.168.2.2 due to oldest external
192.168.199.0/24(VRF default): After path selection, newbest is path 192.168.2.2 oldbest was 192.168.2.2
192.168.199.0/24(VRF default): path 192.168.2.2 is the bestpath, add to the multipath list
192.168.199.0/24(VRF default): Comparing path 192.168.3.3 flags Valid Counted  with path 192.168.2.2 flags Selected Valid Counted 

192.168.199.0/24: path 192.168.3.3 loses to path 192.168.2.2 due to oldest external <---------- OK

192.168.199.0/24(VRF default): starting mpath update, newbest 192.168.2.2 num candidates 1 old-mpath-count 0 old-cum-bw 0
192.168.199.0/24(VRF default): comparing candidate 192.168.2.2 with existing mpath NONE
192.168.199.0/24(VRF default): New mpath count (incl newbest) 1 mpath-change NO all_paths_lb 0 cum_bw 0
bgp_process_main_one: p=192.168.199.0/24(VRF default) afi=IPv4, safi=unicast, old_select=0x1721190, new_select=0x1721190

# do show bgp ipv4 192.168.199.0/24
BGP routing table entry for 192.168.199.0/24, version 6
Paths: (1 available, best #1, table default)
  Advertised to non peer-group peers:
  192.168.2.2 192.168.3.3
  65024
    192.168.2.2 from 192.168.2.2 (1.1.1.2)
      Origin IGP, metric 200, valid, external, best (Older Path)       <---------- OK
      Last update: Wed Sep 25 13:12:45 2024
  65003
    192.168.3.3 from 192.168.3.3 (1.1.1.3)
      Origin IGP, metric 150, valid, external
      Last update: Wed Sep 25 13:15:32 2024
  1. Run R4
    R1 info:
bgp_process_main_one: p=192.168.199.0/24(VRF default) afi=IPv4, safi=unicast start
192.168.199.0/24(VRF default): Comparing path 192.168.4.4 flags Valid Counted Unsorted  with path 192.168.2.2 flags Selected Valid Counted 
192.168.199.0/24: path 192.168.4.4 wins over path 192.168.2.2 due to MED 100 < 200
192.168.199.0/24(VRF default): After path selection, newbest is path 192.168.4.4 oldbest was 192.168.2.2
192.168.199.0/24(VRF default): path 192.168.4.4 is the bestpath, add to the multipath list
192.168.199.0/24(VRF default): Comparing path 192.168.2.2 flags Selected Valid Counted  with path 192.168.4.4 flags Valid Counted 

192.168.199.0/24: path 192.168.2.2 loses to path 192.168.4.4 due to MED 200 > 100      <------- OK: 192.168.4.4 is best

192.168.199.0/24(VRF default): Comparing path 192.168.3.3 flags Valid Counted  with path 192.168.4.4 flags Valid Counted 

192.168.199.0/24: path 192.168.3.3 wins over path 192.168.4.4 due to Router-ID comparison <-------- rewrite dest->reason 

192.168.199.0/24(VRF default): starting mpath update, newbest 192.168.4.4 num candidates 1 old-mpath-count 0 old-cum-bw 0
192.168.199.0/24(VRF default): comparing candidate 192.168.4.4 with existing mpath NONE
192.168.199.0/24(VRF default): New mpath count (incl newbest) 1 mpath-change NO all_paths_lb 0 cum_bw 0
bgp_process_main_one: p=192.168.199.0/24(VRF default) afi=IPv4, safi=unicast, old_select=0x1721190, new_select=0x17360a0
bgp_process_main_one: 192.168.199.0/24 setting SELECTED flag

# do show bgp ipv4 192.168.199.0/24
BGP routing table entry for 192.168.199.0/24, version 7
Paths: (3 available, best #1, table default)
  Advertised to non peer-group peers:
  192.168.2.2 192.168.3.3 192.168.4.4
  65024
    192.168.4.4 from 192.168.4.4 (1.1.1.4)
      Origin IGP, metric 100, valid, external, best (Router ID) <-- 192.168.4.4 is best via MED, but have dest->reason=router-id
      Last update: Wed Sep 25 13:17:51 2024
  65024
    192.168.2.2 from 192.168.2.2 (1.1.1.2)
      Origin IGP, metric 200, valid, external
      Last update: Wed Sep 25 13:12:45 2024
  65003
    192.168.3.3 from 192.168.3.3 (1.1.1.3)
      Origin IGP, metric 150, valid, external
      Last update: Wed Sep 25 13:15:32 2024

192.168.4.4 is best via MED, but have dest->reason=router-id

@ak503
Copy link
Contributor Author

ak503 commented Sep 25, 2024

here bgp_path_info_cmp use for find paths_eq, but also update reason ?

frr/bgpd/bgp_route.c

Lines 3245 to 3257 in 2203dc4

if (pi->peer && pi->peer != bgp->peer_self
&& !CHECK_FLAG(pi->peer->sflags,
PEER_STATUS_NSF_WAIT))
if (!peer_established(pi->peer->connection))
continue;
bgp_path_info_cmp(bgp, pi, new_select, &paths_eq,
mpath_cfg, debug, pfx_buf, afi, safi,
&dest->reason);
if (paths_eq) {
if (debug)
zlog_debug(

@ton31337 ton31337 added the bgp label Sep 25, 2024
@ton31337 ton31337 assigned ton31337 and unassigned ton31337 Sep 25, 2024
@ton31337
Copy link
Member

@SergeKrier said he will start working on this issue.

@donaldsharp
Copy link
Member

Seems like this is a really great excuse for some new topotests.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants