From bb52e5ebdcd450d718bef31917c476c43fb9a082 Mon Sep 17 00:00:00 2001 From: Chirag Shah Date: Thu, 18 Apr 2024 11:44:00 -0700 Subject: [PATCH 1/2] tools: fix pim interface config deletionII When no ip pim is performed subsequent pim related configs under the interface also implicitly deleted. The previous fix was attempting to remove from the same list which was being integrated. First collect the lines to remove in separate list then at the end remove from the original lines_to_del. commit 623af04e1c does not work properly if tries to delete an entry from existing list which is being walked on. Ticket: #3869779 Testing done: frr.conf: no interface config running-config: -------------- interface swp1 ip pim ip pim active-active ip pim allow-rp rp-list sample ip pim bfd ip pim use-source 1.1.1.1 ip multicast boundary oil test exit frr-reload log pointing only no ip pim config is removed under interface: 2024-04-18 18:44:37,202 INFO: "frr defaults datacenter" cannot be removed 2024-04-18 18:44:37,202 INFO: "service integrated-vtysh-config" cannot be removed 2024-04-18 18:44:37,504 INFO: Executed "interface swp1 no ip pim exit" 2024-04-18 18:44:37,505 INFO: /var/run/frr/reload-YHS51E.txt content Signed-off-by: Chirag Shah --- tools/frr-reload.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/tools/frr-reload.py b/tools/frr-reload.py index b6e67fc7d252..0b3057193941 100755 --- a/tools/frr-reload.py +++ b/tools/frr-reload.py @@ -1083,6 +1083,7 @@ def pim_delete_move_lines(lines_to_add, lines_to_del): # Remove all such depdendent options from delete # pending list. pim_disable = False + lines_to_del_to_del = [] for ctx_keys, line in lines_to_del: if ctx_keys[0].startswith("interface") and line and line == "ip pim": @@ -1093,9 +1094,12 @@ def pim_delete_move_lines(lines_to_add, lines_to_del): if ( ctx_keys[0].startswith("interface") and line - and line.startswith("ip pim ") + and (line.startswith("ip pim ") or line.startswith("ip multicast ")) ): - lines_to_del.remove((ctx_keys, line)) + lines_to_del_to_del.append((ctx_keys, line)) + + for ctx_keys, line in lines_to_del_to_del: + lines_to_del.remove((ctx_keys, line)) return (lines_to_add, lines_to_del) From da2093ba3916327367eb2179c1b2ce36be4e5ebc Mon Sep 17 00:00:00 2001 From: Chirag Shah Date: Mon, 22 Apr 2024 19:47:27 -0700 Subject: [PATCH 2/2] tools: fix frr-reload for no ip msdp peer cmd no form of 'ip pm msdp peer <> source <>' does not accept source argument. Stip the 'source <>' part from config line being deleted via frr-reload. Ticket: #3874971 Testing: Config: vrf blue ip msdp peer 1.1.1.1 source 1.1.1.1 frr-reload failure log: 2024-04-23 02:08:32,501 INFO: Failed to execute vrf blue no ip msdp peer 1.1.1.1 source 1.1.1.1 exit 2024-04-23 02:08:32,501 ERROR: "vrf blue -- no ip msdp peer 1.1.1.1 source 1.1.1.1 -- exit" we failed to remove this command 2024-04-23 02:08:32,501 ERROR: % Unknown command: no ip msdp peer 1.1.1.1 source 1.1.1.1 Signed-off-by: Chirag Shah --- tools/frr-reload.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/tools/frr-reload.py b/tools/frr-reload.py index 0b3057193941..84360f632bfa 100755 --- a/tools/frr-reload.py +++ b/tools/frr-reload.py @@ -1085,10 +1085,21 @@ def pim_delete_move_lines(lines_to_add, lines_to_del): pim_disable = False lines_to_del_to_del = [] + index = -1 for ctx_keys, line in lines_to_del: + index = index + 1 if ctx_keys[0].startswith("interface") and line and line == "ip pim": pim_disable = True + # no ip msdp peer <> does not accept source so strip it off. + if line and line.startswith("ip msdp peer "): + pim_msdp_peer = re.search("ip msdp peer (\S+) source (\S+)", line) + if pim_msdp_peer: + source_sub_str = "source %s" % pim_msdp_peer.group(2) + new_line = line.replace(source_sub_str, "").strip() + lines_to_del.remove((ctx_keys, line)) + lines_to_del.insert(index, (ctx_keys, new_line)) + if pim_disable: for ctx_keys, line in lines_to_del: if (