From: Donald Sharp Date: Fri, 18 Dec 2020 19:22:09 +0000 (-0500) Subject: lib: Fix dependency of match types in route-map code X-Git-Tag: frr-7.5.1~19^2 X-Git-Url: https://git.puffer.fish/?a=commitdiff_plain;h=46bb9f489dafb5e94b7e6f16854dfd9cdea52b6b;p=matthieu%2Ffrr.git lib: Fix dependency of match types in route-map code Route-maps contain a hash of hash's that contain the container type name ( say community or access list or whatever ) and then it has a hash of route-maps that this maps too Suppose you have this: ! frr version 7.3.1 frr defaults traditional hostname eva log stdout ! debug route-map ! router bgp 239 neighbor 192.168.161.2 remote-as external ! address-family ipv4 unicast neighbor 192.168.161.2 route-map foo in exit-address-family ! bgp community-list standard 7000:40002 permit 7000:40002 bgp community-list standard 7000:40002 permit 7000:40003 ! route-map foo deny 20 match community 7000:40002 ! route-map foo permit 10 ! line vty ! end You have a community hash which has an 7000:40002 entry This entry has a hash of routemaps that are referencing it. In this above example it would have `foo` as the single entry. Given the above config if you do this: eva# conf eva(config)# route-map foo deny 20 eva(config-route-map)# match community 7000:4003 eva(config-route-map)# We would expect the `7000:40002` community hash to no longer have a reference to the `foo` routemap. Instead we see the code doing this: 2020/12/18 13:47:12 BGP: bgpd 7.3.1 starting: vty@2605, bgp@:179 2020/12/18 13:47:47 BGP: Add route-map foo 2020/12/18 13:47:47 BGP: Route-map foo add sequence 10, type: permit 2020/12/18 13:47:57 BGP: Route-map foo add sequence 20, type: deny 2020/12/18 13:48:05 BGP: Adding dependency for filter 7000:40002 in route-map foo 2020/12/18 13:48:05 BGP: route_map_print_dependency: Dependency for 7000:40002: foo 2020/12/18 13:48:41 BGP: bgp_update_receive: rcvd End-of-RIB for IPv4 Unicast from 192.168.161.2 in vrf default 2020/12/18 13:49:19 BGP: Deleting dependency for filter 7000:4003 in route-map foo 2020/12/18 13:49:19 BGP: Adding dependency for filter 7000:4003 in route-map foo 2020/12/18 13:49:19 BGP: route_map_print_dependency: Dependency for 7000:4003: foo Note how the code attempts to remove the dependency for `7000:4003` instead of the dependency for `7000:40002`. Then we create a new hash for `7000:4003` and then install the routemap name in it. This is wrong. We should remove the `7000:40002` dependency and then install a dependency for `7000:4003`. Fix the code to do the right thing. Signed-off-by: Donald Sharp --- diff --git a/lib/routemap.c b/lib/routemap.c index fb70860024..a90443ae1b 100644 --- a/lib/routemap.c +++ b/lib/routemap.c @@ -1347,7 +1347,7 @@ enum rmap_compile_rets route_map_add_match(struct route_map_index *index, get_route_map_delete_event(type); route_map_upd8_dependency( delete_rmap_event_type, - rule_key, + rule->rule_str, index->map->name); }