FRRouting / frr

The FRRouting Protocol Suite
https://frrouting.org/
Other
3.35k stars 1.26k forks source link

bgpd:configure 1000 route-maps take a long time #12764

Open guoguojia2021 opened 1 year ago

guoguojia2021 commented 1 year ago

Describe the bug When I test "route-map xxx permit xx". If configure 1000 route-maps and 1000 match local-perference xx, it will take 22m 37s. while, If I configure 1000 route-maps and 1000 match ipv6 address prefix-len xx, it only takes 44s.

route-map(1000) match(1000) spend time
route-map xxx permit x match local-perference xx 22m37s
route-map xxx permit x match ipv6 address prefix-len x 44s

Versions

Additional context route-map xxx permit x and match local-preference x

root@guoguo:~/Documents/frrlab# date
Wed 08 Feb 2023 05:33:34 AM UTC
root@guoguo:~/Documents/frrlab# sudo docker exec -it clab-frr01-router2 vtysh
Hello, this is FRRouting (version 8.4.1_git).
Copyright 1996-2005 Kunihiro Ishiguro, et al.

router2# config
router2(config)# route-map TEST_MAP_VRF1 permit 6501 
router2(config-route-map)# match local-preference 1
router2(config-route-map)# route-map TEST_MAP_VRF2 permit 6502 
router2(config-route-map)# match local-preference 2
router2(config-route-map)# route-map TEST_MAP_VRF3 permit 6503 
router2(config-route-map)# match local-preference 3
Trouter2(config-route-map)# route-map TEST_MAP_VRF4 permit 6504 
router2(config-route-map)# match local-preference 4
router2(config-route-map)# route-map TEST_MAP_VRF5 permit 6505 
router2(config-route-map)# match local-preference 5
router2(config-route-map)# route-map TEST_MAP_VRF6 permit 6506 
router2(config-route-map)# match local-preference 6
router2(config-route-map)# route-map TEST_MAP_VRF7 permit 6507 
router2(config-route-map)# match local-preference 7
router2(config-route-map)# route-map TEST_MAP_VRF8 permit 6508 
router2(config-route-map)# match local-preference 8
router2(config-route-map)# route-map TEST_MAP_VRF9 permit 6509 
router2(config-route-map)# match local-preference 9
router2(config-route-map)# route-map TEST_MAP_VRF10 permit 6510 
router2(config-route-map)# match local-preference 10
router2(config-route-map)# route-map TEST_MAP_VRF11 permit 6511 
router2(config-route-map)# match local-preference 11
router2(config-route-map)# route-map TEST_MAP_VRF12 permit 6512 
router2(config-route-map)# match local-preference 12
.
.
.
router2(config-route-map)# route-map TEST_MAP_VRF992 permit 7492 
router2(config-route-map)# match local-preference 224
router2(config-route-map)# route-map TEST_MAP_VRF993 permit 7493 
router2(config-route-map)# match local-preference 225
router2(config-route-map)# route-map TEST_MAP_VRF994 permit 7494 
router2(config-route-map)# match local-preference 226
router2(config-route-map)# route-map TEST_MAP_VRF995 permit 7495 
router2(config-route-map)# match local-preference 227
router2(config-route-map)# route-map TEST_MAP_VRF996 permit 7496 
router2(config-route-map)# match local-preference 228
router2(config-route-map)# route-map TEST_MAP_VRF997 permit 7497 
router2(config-route-map)# match local-preference 229
router2(config-route-map)# route-map TEST_MAP_VRF998 permit 7498 
router2(config-route-map)# match local-preference 230
router2(config-route-map)# route-map TEST_MAP_VRF999 permit 7499 
router2(config-route-map)# match local-preference 231
router2(config-route-map)# route-map TEST_MAP_VRF1000 permit 7500 
router2(config-route-map)# match local-preference 232
router2(config-route-map)# end
router2# exit
root@guoguo:~/Documents/frrlab# date
Wed 08 Feb 2023 05:56:11 AM UTC
root@guoguo:~/Documents/frrlab# 

route-map xxx permit x and match ipv6 address prefix-len x

root@guoguo:~/Documents/frrlab# 
root@guoguo:~/Documents/frrlab# date
Wed 08 Feb 2023 06:00:33 AM UTC
root@guoguo:~/Documents/frrlab# sudo docker exec -it clab-frr01-router2 vtysh
Hello, this is FRRouting (version 8.4.1_git).
Copyright 1996-2005 Kunihiro Ishiguro, et al.

router2# config
router2(config)# route-map TEST_MAP_VRF1 permit 6501 
router2(config-route-map)# match ipv6 address prefix-len 1
router2(config-route-map)# route-map TEST_MAP_VRF2 permit 6502 
router2(config-route-map)# match ipv6 address prefix-len 2
router2(config-route-map)# route-map TEST_MAP_VRF3 permit 6503 
router2(config-route-map)# match ipv6 address prefix-len 3
router2(config-route-map)# route-map TEST_MAP_VRF4 permit 6504 
router2(config-route-map)# match ipv6 address prefix-len 4
router2(config-route-map)# route-map TEST_MAP_VRF5 permit 6505 
router2(config-route-map)# match ipv6 address prefix-len 5
router2(config-route-map)# route-map TEST_MAP_VRF6 permit 6506 
router2(config-route-map)# match ipv6 address prefix-len 6
router2(config-route-map)# route-map TEST_MAP_VRF7 permit 6507 
router2(config-route-map)# match ipv6 address prefix-len 7
router2(config-route-map)# route-map TEST_MAP_VRF8 permit 6508 
router2(config-route-map)# match ipv6 address prefix-len 8
router2(config-route-map)# route-map TEST_MAP_VRF9 permit 6509 
.
.
.
router2(config-route-map)# route-map TEST_MAP_VRF988 permit 7488 
router2(config-route-map)# match ipv6 address prefix-len 92
router2(config-route-map)# route-map TEST_MAP_VRF989 permit 7489 
router2(config-route-map)# match ipv6 address prefix-len 93
router2(config-route-map)# route-map TEST_MAP_VRF990 permit 7490 
router2(config-route-map)# match ipv6 address prefix-len 94
router2(config-route-map)# route-map TEST_MAP_VRF991 permit 7491 
router2(config-route-map)# match ipv6 address prefix-len 95
router2(config-route-map)# route-map TEST_MAP_VRF992 permit 7492 
router2(config-route-map)# match ipv6 address prefix-len 96
router2(config-route-map)# route-map TEST_MAP_VRF993 permit 7493 
router2(config-route-map)# match ipv6 address prefix-len 97
router2(config-route-map)# route-map TEST_MAP_VRF994 permit 7494 
router2(config-route-map)# match ipv6 address prefix-len 98
router2(config-route-map)# route-map TEST_MAP_VRF995 permit 7495 
router2(config-route-map)# match ipv6 address prefix-len 99
router2(config-route-map)# route-map TEST_MAP_VRF996 permit 7496 
router2(config-route-map)# match ipv6 address prefix-len 100
router2(config-route-map)# route-map TEST_MAP_VRF997 permit 7497 
router2(config-route-map)# match ipv6 address prefix-len 101
router2(config-route-map)# route-map TEST_MAP_VRF998 permit 7498 
router2(config-route-map)# match ipv6 address prefix-len 102
router2(config-route-map)# route-map TEST_MAP_VRF999 permit 7499 
router2(config-route-map)# match ipv6 address prefix-len 103
router2(config-route-map)# route-map TEST_MAP_VRF1000 permit 7500 
router2(config-route-map)# match ipv6 address prefix-len 104
router2(config-route-map)# end
router2# exit
root@guoguo:~/Documents/frrlab# date
Wed 08 Feb 2023 06:01:17 AM UTC
root@guoguo:~/Documents/frrlab# 

Compare the difference between match local-preference x and match ipv6 address prefix-len x, The yang node definition(when condition) is different.

match local-preference x

  augment "/frr-route-map:lib/frr-route-map:route-map/frr-route-map:entry/frr-route-map:match-condition/frr-route-map:rmap-match-condition/frr-route-map:match-condition" {
    case local-preference {
      when "derived-from-or-self(/frr-route-map:lib/frr-route-map:route-map/frr-route-map:entry/frr-route-map:match-condition/frr-route-map:condition, 'frr-bgp-route-map:match-local-preference')";
      leaf local-preference {
        type uint32 {
          range "0..4294967295";
        }
      }
    }

 match ipv6 address prefix-len x

  augment "/frr-route-map:lib/frr-route-map:route-map/frr-route-map:entry/frr-route-map:match-condition/frr-route-map:rmap-match-condition/frr-route-map:match-condition" {
    case ipv4-prefix-length {
      when "derived-from-or-self(../frr-route-map:condition, 'frr-zebra-route-map:ipv4-prefix-length') or "
         + "derived-from-or-self(../frr-route-map:condition, 'frr-zebra-route-map:ipv4-next-hop-prefix-length')";
      leaf ipv4-prefix-length {
        type uint8 {
          range "0..32";
        }
      }
    }

    case ipv6-prefix-length {
      when "derived-from-or-self(../frr-route-map:condition, 'frr-zebra-route-map:ipv6-prefix-length')";
      leaf ipv6-prefix-length {
        type uint8 {
          range "0..128";
        }
      }
    }

If I change /frr-route-map:lib/frr-route-map:route-map/frr-route-map:entry/frr-route-map:match-condition/frr-route-map:condition as ../frr-route-map:condition, It will very quickly.

Question

  1. What's the difference between /frr-route-map:lib/frr-route-map:route-map/frr-route-map:entry/frr-route-map:match-condition/frr-route-map:condition and ../frr-route-map:condition.
  2. Can I replace it or other way to fix the bug.
donaldsharp commented 1 year ago

@choppsv1 -> Can you take a look here and help this person out?

donaldsharp commented 1 year ago

@guoguojia2021 can you share with me your config file?

Darwin4053 commented 3 months ago

I am observing a significant performance difference when configuring route-maps in FRRouting.

Configuring 1000 route-maps with match local-preference xx takes approximately 59 seconds. Configuring 1000 route-maps with match ipv6 address prefix-len xx takes around 4 minutes and 41 seconds.