summaryrefslogtreecommitdiff
path: root/tools/frr-reload.py
AgeCommit message (Collapse)Author
2025-04-11tools: fix reload script for SRv6 locators and formatsRajasekar Raja
Current code implementation does not have a "no" form of handling for the following commands under segment-routing srv6 - no formats - no locators - no prefix <> under locator XYZ Fix the handling of segment-routing srv6 locators and formats commands - Ignore "no formats" and "no locators" command - replace "no prefix" under locator XYZ as "no locator XYZ" as prefix is a mandatory property of locator Signed-off-by: Rajasekar Raja <rajasekarr@nvidia.com> (cherry picked from commit ce06d35fa983c67d25d93f5c2533610490313699)
2025-03-03tools: Fix `frr-reload.py` error related to `static-sids`Carmine Scarpitta
``` [...] segment-routing srv6 static-sids sid fcbb:bbbb:1::/48 locator MAIN behavior uN sid fcbb:bbbb:1:fe10::/64 locator MAIN behavior uDT4 vrf Vrf10 sid fcbb:bbbb:1:fe20::/64 locator MAIN behavior uDT6 vrf Vrf20 sid fcbb:bbbb:1:fe30::/64 locator MAIN behavior uDT46 vrf Vrf30 sid fcbb:bbbb:1:fe40::/64 locator MAIN behavior uA interface sr0 nexthop 2001::2 [...] ``` When the user has a configuration like the one above and runs the command `frr-reload.py --reload`, the following error occurs: ``` [1129654|mgmtd] sending configuration line 17: % Unknown command[76]: sid fcbb:bbbb:1::/48 locator MAIN behavior uN line 23: % Unknown command[76]: sid fcbb:bbbb:1:fe10::/64 locator MAIN behavior uDT4 vrf Vrf10 line 29: % Unknown command[76]: sid fcbb:bbbb:1:fe20::/64 locator MAIN behavior uDT6 vrf Vrf20 line 35: % Unknown command[76]: sid fcbb:bbbb:1:fe30::/64 locator MAIN behavior uDT46 vrf Vrf30 line 41: % Unknown command[76]: sid fcbb:bbbb:1:fe40::/64 locator MAIN behavior uA interface sr0 nexthop 2001::2 ``` The problem is that in `frr-reload-py` all commands that start a new multi-line context must be included in the `ctx_keyword` dictionary. However, the `static-sids` command is not part of the `ctx_keyword` dictionary. This commit fixes the problem by adding `static-sids` to `ctx_keyword`. Signed-off-by: Carmine Scarpitta <cscarpit@cisco.com> (cherry picked from commit a515de1c46f617ee3608ab55cdef5f2a262d387a)
2025-01-29tools: Fix frr-reload for ebgp-multihop TTL reconfiguration.Nobuhiro MIKI
In ebgp-multihop, there is a difference in reload behavior when TTL is unspecified (meaning default 255) and when 255 is explicitly specified. For example, when reloading with 'neighbor <neighbor> ebgp-multihop 255' in the config, the following difference is created. This commit fixes that. Lines To Delete =============== router bgp 65001 no neighbor 10.0.0.4 ebgp-multihop exit Lines To Add ============ router bgp 65001 neighbor 10.0.0.4 ebgp-multihop 255 exit The commit 767aaa3a8048 is not sufficient and frr-reload needs to be fixed to handle both unspecified and specified cases. Signed-off-by: Nobuhiro MIKI <nob@bobuhiro11.net>
2025-01-16tools: Allow deleting of interfacesJulian Klaiber
The frr-reload script currently deletes configurations line-by-line under an interface context, if the interface was removed. This approach fails when the interface has already been removed from the system. This change enables whole interface removal using a single command (no interface <interface-name>), simplifying the reload process and reducing reload errors. Signed-off-by: Julian Klaiber <jklaiber@open-systems.com>
2025-01-13tools: fix frr-reload for nbr deletion of no form cmdsChirag Shah
When a bgp neighbor removed from associated to peer-group, the neighbor is fully deleted, subsequent deletion of any configuration related to the neighbor leads to failure in frr-reload. Handle any 'no neighbor ...' part of lines_to_del list Testing: Below first line would delete the neighbor swp1.10, the existing code before the change handles to remove config starts with 'neighbor swp1.10 ...' but not 'no neighbor swp1.10 ...'. (Pdb) (lines_to_del) (('router bgp 100',), 'neighbor swp1.10 interface peer-group dpeergrp_2'), (('router bgp 100',), 'neighbor swp1.10 advertisement-interval 1'), (('router bgp 100',), 'neighbor swp1.10 timers 3 9'), (('router bgp 100',), 'neighbor swp1.10 timers connect 1'), (('router bgp 100',), 'no neighbor swp1.10 capability dynamic'), Before fix: (Pdb) (lines_to_del) [(('router bgp 100',), 'neighbor swp1.10 interface peer-group dpeergrp_2'), (('router bgp 100',), 'no neighbor swp1.10 capability dynamic')] frr-reload log: 2025-01-13 05:13:11,172 INFO: Executed "router bgp 100 no neighbor swp1.10 interface peer-group dpeergrp_2 exit" 2025-01-13 05:13:11,227 ERROR: Failed to execute router bgp 100 neighbor swp1.10 capability dynamic exit 2025-01-13 05:13:11,228 ERROR: "router bgp 100 -- neighbor swp1.10 capability dynamic -- exit" we failed to remove this command After fix: (Pdb)(lines_to_del) [(('router bgp 100',), 'neighbor swp1.10 interface peer-group dpeergrp_2')] Signed-off-by: Chirag Shah <chirag@nvidia.com>
2025-01-03tools: Add missing rpki keyword to vrf in frr-reloadJonathan Voss
When reloading the following configuration: ``` vrf red rpki rpki cache tcp 172.65.0.2 8282 preference 1 exit exit-vrf ``` frr-reload.py does not properly enter the `rpki` context within a `vrf`. Because of this, it fails to apply RPKI configurations. Signed-off-by: Jonathan Voss <jvoss@onvox.net>
2024-12-24tools: Add missing formats keyword to segment-routing in frr-reloadJonathan Voss
When reloading the following configuration: ``` segment-routing srv6 formats format usid-f3216 wide-local-id-block explicit start 100 exit ! format uncompressed-f4024 exit ! exit ! exit ! exit ``` frr-reload.py does not properly enter the `formats` context. Because of this, it fails with an unknown command error when applying new or updating format configuration. Signed-off-by: Jonathan Voss <jvoss@onvox.net>
2024-11-24tools: Add missing keyword `encapsulation` in frr-reloadCarmine Scarpitta
Consider the following scenario. You start from the configuration below: ``` ! segment-routing srv6 encapsulation source-address fc00:0:1::1 ! ! ! ``` Then you change the source address: ``` r1# configure r1(config)# segment-routing r1(config-sr)# srv6 r1(config-srv6)# encapsulation r1(config-srv6-encap) source-address 1::1 ``` And finally, reload the configuration `python3 frr-reload.py --reload /etc/frr/frr.conf` frr-reload returns the error below: ``` Failed to execute segment-routing srv6 no source-address 1::1 exit exit "segment-routing -- srv6 -- no source-address 1::1 -- exit -- exit" we failed to remove this command % Unknown command: no source-address 1::1 [79975|mgmtd] sending configuration line 3: % Unknown command[76]: source-address fc00:0:1::1 [79975|mgmtd] Configuration file[/etc/frr/frr.conf] processing failure: 2 ``` The reason is that the keyword `encapsulation` is missing in frr-reload. This patch adds the missing keyword `encapsulation`. Signed-off-by: Carmine Scarpitta <cscarpit@cisco.com>
2024-11-23tools: Add missing keyword `node-msd` in frr-reloadCarmine Scarpitta
Fix the error below: ``` [58564|mgmtd] sending configuration [58565|zebra] sending configuration, line 14: % Unknown command[52]: max-segs-left 3 line 18: % Unknown command[52]: max-end-pop 3 line 22: % Unknown command[52]: max-h-encaps 2 line 26: % Unknown command[52]: max-end-d 5 [58573|isisd] sending configuration [58565|zebra] Configuration file[/etc/frr/frr.conf] processing failure: 2 ``` Signed-off-by: Carmine Scarpitta <cscarpit@cisco.com>
2024-11-23tools: Add missing keyword `segment-routing srv6` in frr-reloadCarmine Scarpitta
Fix the error below: ``` [58564|mgmtd] sending configuration [58565|zebra] sending configuration, line 10: % Unknown command[52]: node-msd [58573|isisd] sending configuration [58565|zebra] Configuration file[/etc/frr/frr.conf] processing failure: 2 ``` Signed-off-by: Carmine Scarpitta <cscarpit@cisco.com>
2024-10-05tools: fix some special commands for reloading pimanlan_cs
The issue is we can't remove all pim configurations including some special configurations (e.g., `no ip pim bsm`) for one interface. For one pim-disable interface, all such pim depdendent options (including `ip pim ` and `no ip pim `) should be completely removed. Also append `no ip multicast` for the same purpose, it is no use at present, but for future use. The running config: ``` interface A ip pim no ip pim bsm exit ``` Reload the new config: ``` interface A exit ``` Before: ``` 2024-10-05 20:52:33,467 INFO: Executed "interface A no ip pim exit" 2024-10-05 20:52:33,482 INFO: Executed "interface A ip pim bsm exit" ``` And the pim configurations in running configuration are not removed after reloading: ``` interface A ip pim <- Wrong exit ``` After: ``` 2024-10-05 20:56:27,489 INFO: Executed "interface A no ip pim exit" ``` And all the pim configuration are removed. Signed-off-by: anlan_cs <anlan_cs@126.com>
2024-09-29tools: fix missing check interfaces for reloading pimanlan_cs
Without checking interfaces, the other interfaces' changes will be wrongly lost. Running config: ``` interface A ip pim ip pim use-source 11.0.0.1 exit ! interface B ip pim ip pim use-source 22.0.0.1 exit ! ``` Reload the new config: ``` interface A exit ! interface B ip pim exit ``` Before: ``` 2024-09-29 10:08:27,686 INFO: Executed "interface A no ip pim exit" ``` After: ``` 2024-09-29 10:05:01,356 INFO: Executed "interface A no ip pim exit" 2024-09-29 10:05:01,376 INFO: Executed "interface B no ip pim use-source 22.0.0.1 exit" ``` Signed-off-by: anlan_cs <anlan_cs@126.com>
2024-09-03tools: fix invalid escape on regex stringGiovanni Tataranni
fix usage of regex string without proper escaping Signed-off-by: Giovanni Tataranni <g.tataranni@gmail.com>
2024-08-08tools: Fix python string escape warnings for frr-reload.pyDonatas Abraitis
When using a regex (or anything that uses `\?` escapes) in python, raw strings (`r"content"`) should be used so python doesn't consume the escapes itself. Otherwise we get either broken behavior and/or `SyntaxWarning: invalid escape sequence '\['` Fixes: 8916953b534f64a7545860ad5b4b36dc2544f33a ("build: fix a few python string escape warnings") Fixes: https://github.com/FRRouting/frr/issues/16522 Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2024-07-20tools: Apply black formatting for the recent frr-reload.py changesDonatas Abraitis
Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2024-07-20tools: Do not append an empty list (pim_vrfs) to the config linesDonatas Abraitis
If pim_vrfs is empty, we append [] into the lines array, and the reload is broken since it expects only strings, but gets an array inside at the end. ``` Traceback (most recent call last): File "/usr/lib/frr/frr-reload.py", line 2227, in <module> log.debug("New Frr Config\n%s", newconf.get_lines()) File "/usr/lib/frr/frr-reload.py", line 436, in get_lines return "\n".join(self.lines) TypeError: sequence item 45: expected str instance, list found ``` Fixes: 98d47f43fbba4e376c8351c724e8c625799805f7 ("tools: Fix frr-reload to support legacy pim configuration from file") Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2024-07-16tools: Fix frr-reload to support legacy pim configuration from fileNathan Bahr
Fix load from file in frr-reload to detect and convert legacy pim configuration so that the tool can continue to be used with legacy configurations. Signed-off-by: Nathan Bahr <nbahr@atcorp.com>
2024-04-25tools: Handle seq num for BGP as-path in frr-reload.pyChirag Shah
If frr.conf has bgp as-path access-list clause without sequence number then upon performing frr-rleoad, the running config clause with sequence number will always be deleted and the new ones without sequence will be re-added. This could lead to blackholing until the config gets reapplied. Testing: frr.conf: bgp as-path access-list important_internet_bgp_as_numbers permit _16509_ Running config: bgp as-path access-list important_internet_bgp_as_numbers seq 5 permit _16509_ ! Before fix Upon frr-reload it deletes and readd line as without seq 2024-04-26 03:16:45,772 INFO: Executed "no bgp as-path access-list important_internet_bgp_as_numbers seq 5 permit _16509_" 'bgp as-path access-list important_internet_bgp_as_numbers permit _16509_\n' After fix: no form is not executed and no delta determine between frr.conf and running-config. Signed-off-by: Chirag Shah <chirag@nvidia.com>
2024-04-23tools: fix frr-reload for no ip msdp peer cmdChirag Shah
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 <chirag@nvidia.com>
2024-04-23tools: fix pim interface config deletionIIChirag Shah
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 <chirag@nvidia.com>
2024-04-10tools: frr-reload strip interface vrf ctx lineChirag Shah
if frr.conf file contains 'interface x vrf <name> config it causes protocol (like ospf) neighbor session flap, as it deletes interface base config line ('interface x') from running config and readds with 'interface x vrf <name>' line from frr.conf. This deletion and readdition of lines leads to neighborship flaps. This issue is by product of (PR-10411 | https://github.com/FRRouting/frr/pull/10411) (commit id: 788a036fdb) where running config for interface config no loger displays associated vrf line. Ticket: #3858146 Testing: frr.conf interface swp1.2 vrf vrf1012 ip ospf network point-to-point running-config: interface swp1.2 ip ospf network point-to-point exit Before fix: frr-reload logs: 2024-04-09 00:28:31,096 INFO: Executed "interface swp1.2 no ip ospf network point-to-point exit" 'interface swp1.2 vrf vrf1012\n ip ospf network point-to-point\nexit\n', After fix: frr-reload strips vrf line, thus no config change between frr.conf and running config. Signed-off-by: Chirag Shah <chirag@nvidia.com>
2024-01-06tools: fix frr-reload for nbr deletionChirag Shah
bgp neighbor config can have multiple lines, if neighbor is deleted via frr-reload, no neighbor remote-as <> wipes out the neighbor, subsequent neighbor associated config deletion would throw generic error. Frr-reload needs to move neighbor remote-as line to end and allow all other config lines to be removed. Ticket:#3588361 #3589216 Testing Done: config: neighbor swp3 interface remote-as external neighbor swp3 bfd 3 300 300 neighbor swp3 password leaf11-spine INFO: Executed "router bgp 65101 no neighbor swp3 interface remote-as external" INFO: Failed to execute router bgp 65101 no neighbor swp3 bfd 3 300 300 INFO: Failed to execute router bgp 65101 no neighbor swp3 bfd 3 300 INFO: Failed to execute router bgp 65101 no neighbor swp3 bfd 3 INFO: Failed to execute router bgp 65101 no neighbor swp3 bfd INFO: Failed to execute router bgp 65101 no neighbor swp3 INFO: Failed to execute router bgp 65101 no neighbor INFO: Failed to execute router bgp 65101 no ERROR: "router bgp 65101 -- no" we failed to remove this command ERROR: % Specify remote-as or peer-group commands first INFO: Failed to execute router bgp 65101 no neighbor swp3 password leaf11-spine INFO: Failed to execute router bgp 65101 no neighbor swp3 password INFO: Failed to execute router bgp 65101 no neighbor swp3 INFO: Failed to execute router bgp 65101 no neighbor INFO: Failed to execute router bgp 65101 no ERROR: "router bgp 65101 -- no" we failed to remove this command ERROR: % Specify remote-as or peer-group commands first After fix: move the neighbor remote-as deletion line to end which allows to remove other neighbor associated lines to be deleted. router bgp 65101 no neighbor swp3 interface remote-as external Signed-off-by: Chirag Shah <chirag@nvidia.com>
2023-12-14tools: Use error log level when failing to execute commands via frr-reload.pyDonatas Abraitis
Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2023-12-12tools: fix frr-reload multiple no description cmdsChirag Shah
Ensure to change description for index 0 from the list. Ticket: #3628756 Testing Done: After fix: start with three interfaces description delete in lines_to_del: (Pdb) lines_to_del [(('interface swp1',), "description swp1 -> sp1's swp1"), (('interface swp2',), "description swp2 -> sp2's swp 1"), (('interface swp3',), "description swp3 -> sp3's swp1")] After first iteration swp1: (Pdb) index 0 (Pdb) lines_to_del [(('interface swp1',), 'description'), (('interface swp2',), "description swp2 -> sp2's swp1"), (('interface swp 1s2',), "description swp3 -> sp3's swp1")] After second iteration swp2: (Pdb) lines_to_del [(('interface swp1',), 'description'), (('interface swp2',), 'description'), (('interface swp3',), "description swp3 -> sp3's swp1")] After third iteration swp3 fix (Pdb) lines_to_del [(('interface swp1',), 'description'), (('interface swp2',), 'description'), (('interface swp3',), 'description' )] Signed-off-by: Chirag Shah <chirag@nvidia.com>
2023-11-28tools: fix frr-reload interface desc cmdChirag Shah
Fix frr-reload script to only render 'no description' rather than 'no description blah' Ticket:#3628756 Testing Done: Before: 2023-11-29 02:38:55,758 INFO: Failed to execute interface hostbond_1 no description hostbond_1_to_host exit 2023-11-29 02:38:55,758 ERROR: "interface hostbond_1 -- no description hostbond_1_to_host -- exit" we failed to remove this command 2023-11-29 02:38:55,758 ERROR: % Unknown command: no description hostbond_1_to_host Signed-off-by: Chirag Shah <chirag@nvidia.com>
2023-11-02tools: Apply black formatting for tools/frr-reload.pyDonatas Abraitis
Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2023-11-01tools: fix frr-reload route-map desc cmdChirag Shah
Fix frr-reload script to only render 'no description' rather than 'no description blah' Ticket:#3650752 Testing: route-map TEST permit 140 description rule for PFIX_IPV6_7 match ipv6 address prefix-list PFIX_IPV6_7 exit ! end torc-11# confi t torc-11(config)# route-map TEST permit 140 torc-11(config-route-map)# no description rule for PFIX_IPV6_7 % Unknown command: no description rule for PFIX_IPV6_7 torc-11(config-route-map)# no description rule % There is no matched command. torc-11(config-route-map)# no description <cr> torc-11(config-route-map)# no description torc-11(config-route-map)# Using frr-reload failure log: 2023-10-31 00:30:31,972 INFO: Failed to execute route-map TEST permit 140 no description rule for PFIX_IPV6_7 exit 2023-10-31 00:30:31,972 ERROR: "route-map TEST permit 140 -- no description rule for PFIX_IPV6_7 -- exit" we failed to remove this command 2023-10-31 00:30:31,972 ERROR: % Unknown command: no description rule for PFIX_IPV6_7 With fix: 2023-11-02 06:10:30,024 INFO: Executed "route-map TEST permit 140 no description exit" Signed-off-by: Chirag Shah <chirag@nvidia.com>
2023-07-27tools: fix key chain reload removalRafael Zalamena
When deleting a key chain with frr-reload track if the whole root node is being removed or not. Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
2023-07-18Merge pull request #10136 from idryzhov/frr-reload-exitMark Stapp
tools: always append "exit" in frr-reload.py
2023-07-09tools: fix ospf area stub summary in frr-reloadChirag Shah
OSPFv2 no area x stub no-summary only resets 'no-summary' config. From frr-reload if the config line 'area x stub no-summary' is removed then it needs to remove completely. Before this change it took two frr-roload to remove the config which is inconsistent behavior. Fix is to frr-reload to add extra line to delete 'no area x stub'. Ticket:#3514775 Testing Done: Running config: router ospf ospf router-id 6.6.6.6 area 0.0.0.1 stub no-summary area 0.0.0.2 stub exit ! router ospf vrf sym_1 area 0.0.1.1 range 24.1.1.0/24 area 0.0.1.2 stub no-summary exit changed frr.conf: router ospf ospf router-id 6.6.6.6 area 0.0.0.2 stub exit ! router ospf vrf sym_1 area 0.0.1.1 range 24.1.1.0/24 exit Lines To Delete =============== router ospf no area 0.0.0.1 stub <<<< newly added router ospf vrf sym_1 no area 0.0.1.2 stub <<<< newly added router ospf no area 0.0.0.1 stub no-summary router ospf vrf sym_1 no area 0.0.1.2 stub no-summary After fix new running-config post reload: i router ospf ospf router-id 6.6.6.6 area 0.0.0.2 stub exit ! router ospf vrf sym_1 area 0.0.1.1 range 24.1.1.0/24 exit Before fix running-config post 1st reload: router ospf ospf router-id 6.6.6.6 area 0.0.0.1 stub area 0.0.0.2 stub exit ! router ospf vrf sym_1 area 0.0.1.1 range 24.1.1.0/24 area 0.0.1.2 stub exit Signed-off-by: Chirag Shah <chirag@nvidia.com>
2023-07-04tools: always append "exit" in frr-reload.pyIgor Ryzhov
When reloading the following config: ``` router ospf6 area 0 range 2001:db8::/32 advertise exit ! interface eth0 ipv6 ospf6 area 0 exit ``` frr-reload.py doesn't execute "exit" commands. Because of that, it tries to execute "interface eth0" inside the "router ospf6" context and fails. To always execute all commands from the correct context, frr-reload.py should properly exit from every entered node. Fixes #10132. Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2023-06-29tools: fix pim interface config deletionChirag Shah
When no ip pim is performed subsequent pim related configs under the interface also implicitly deleted. When doing this via frr-reload requires to remove any explicit no ip pim <blah> lines so delete list. Testing Done: running-config: interface lo ip pim ip pim use-source 6.0.0.1 exit frr.conf: remove two pim config lines. interface lo exit Before fix: 2023-06-29 23:44:26,062 INFO: Failed to execute interface lo no ip pim use-source 6.0.0.1 2023-06-29 23:44:26,142 INFO: Failed to execute interface lo no ip pim use-source 2023-06-29 23:44:26,221 INFO: Executed "interface lo no ip pim" After fix: Only no ip pim executed and rest of the other lines removed from delete list. 2023-06-30 01:07:32,618 INFO: Executed "interface lo no ip pim" Signed-off-by: Chirag Shah <chirag@nvidia.com>
2023-06-05tools: fix list value remove in frr-reloadChirag Shah
There might be a time element(s) from temporary list are removed more than once which leads to valueError in certain python3 version. commit-id 1543f58b5 did not handle valueError properly. This caused regression where prefix-list config leads to delete followed by add. The new fix should just pass the exception as value removal from list_to_add or list_to_del is best effort. This allows prefix-list config has no change then removes the lines from lines_to_del and lines_to_add properly. Ticket:#3490252 Testing: Configure prefix-list in frr.conf and perform multiple frr-reload. After first reload operatoin subsequent ones should not result in delete followed by add of the prefix-list but rather no-op operation. (Pdb) lines_to_add [(('ip prefix-list FOO permit 10.2.1.0/24',), None)] (Pdb) lines_to_del [(('ip prefix-list FOO seq 5 permit 10.2.1.0/24',), None), (('ip prefix-list FOO seq 10 permit 10.2.1.0/24',), None)] (Pdb) lines_to_del_to_del [(('ip prefix-list FOO seq 5 permit 10.2.1.0/24',), None), (('ip prefix-list FOO seq 10 permit 10.2.1.0/24',), None)] (Pdb) lines_to_add_to_del [(('ip prefix-list FOO permit 10.2.1.0/24',), None), (('ip prefix-list FOO permit 10.2.1.0/24',), None)] (Pdb) c > /usr/lib/frr/frr-reload.py(1562)ignore_delete_re_add_lines() -> return (lines_to_add, lines_to_del) (Pdb) lines_to_add [] (Pdb) lines_to_del [] Signed-off-by: Chirag Shah <chirag@nvidia.com>
2023-04-15tools: Make check flag really work for reloadanlan_cs
The check flag of `found_pg_cmd` is already there, but not used. So, make it really work for reload. Signed-off-by: anlan_cs <vic.lan@pica8.com>
2023-04-15tools: fix missing remote-as configuration when reloadanlan_cs
From commit `411d1a2`, `bgp_delete_nbr_remote_as_line()` is added to remove some specific bgp neighbors. But, when reloading the following configuration, it will wrongly remove some good ones: `neighbor 66.66.66.6 remote-as internal`: ``` router bgp 66 bgp router-id 172.16.204.6 neighbor ANLAN peer-group neighbor ANLAN remote-as internal neighbor 66.66.66.6 remote-as internal <- LOST neighbor 66.66.66.60 peer-group ANLAN ``` The reason is that "66.66.66.6" is included in "66.66.66.60" literally, then it is mistakenly thought to be a match. Just fix it with excat match. Signed-off-by: anlan_cs <vic.lan@pica8.com>
2023-03-14tools: frr-reload fix list value not presentChirag Shah
Check for value present in list before removing as in certain python3 ValueError traceback is observed. Traceback (most recent call last): File "/usr/lib/frr/frr-reload.py", line 2278, in <module> (lines_to_add, lines_to_del, restart_frr) = compare_context_objects(newconf, running) File "/usr/lib/frr/frr-reload.py", line 1933, in compare_context_objects lines_to_add, lines_to_del File "/usr/lib/frr/frr-reload.py", line 1549, in ignore_delete_re_add_lines lines_to_del.remove((ctx_keys, line)) ValueError: list.remove(x): x not in list Ticket:#3389979 Issue:3389979 Testing Done: With fix perform frr-relaod on frr.conf config where earlier traceback was seen. Signed-off-by: Donald Sharp <sharpd@nvidia.com> Signed-off-by: Chirag Shah <chirag@nvidia.com>
2023-02-09*: auto-convert to SPDX License IDsDavid Lamparter
Done with a combination of regex'ing and banging my head against a wall. Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2023-01-15tools: Add missing daemonsYuxiang Zhu
Got `ERROR: Daemon babeld is not a valid option for 'show running-config'` when using `frr-reload.py --reload --daemon babeld`. Adds `babeld` and `nhrpd` as valid daemons. Signed-off-by: Yuxiang Zhu <vfreex@gmail.com>
2022-12-22tools: Ignore agentx command for frr-reload.pyDonatas Abraitis
agentx can't be disabled once enabled, so we should ignore it for frr-reload.py. ``` $ /usr/lib/frr/frr-reload.py --reload /etc/frr/bgpd.conf --bindir /usr/local/bin "no agentx" we failed to remove this command SNMP AgentX support cannot be disabled once enabled ``` Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2022-10-11tools: Apply black formatting for frr-reload.pyDonatas Abraitis
Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2022-10-11tools: Handle sequence numbers for BGP community (large/ext) in frr-reload.pyDonatas Abraitis
If we add/modify community/large/ext lists without sequence numbers, and doing frr-reload.py, then rules with sequence numbers (show running-config always adds sequence numbers) will be deleted and new ones will be re-added. This could lead to blackholing for some time. Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2022-08-06tools: Add pim6d to tools so that pim6d will work properlyDonald Sharp
Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2022-05-30tools: add eigrp support on frr-reloadChristian Poessinger
Signed-off-by: Christian Poessinger <christian@poessinger.com>
2022-04-24tools: string literals -> commentsChirag Shah
Convert string literals to comment. Signed-off-by: Chirag Shah <chirag@nvidia.com>
2022-04-23tools: frr-reload fix bgp nbr deleteChirag Shah
When a bgp neighbor removed from associated to peer-group, the neighbor is fully deleted, subsequent deletion of any configuration related to the neighbor leads to failure in frr-reload. Fix: In frr-reload lines to delete check if any neighbor with peer-group removal line is present, if so then remove any further config deletion associated the neighbor needs to removed from the lines to delete. Ticket:#3032234 Reviewed By: Testing Done: BEFORE FIX: ----------- 2022-04-08 20:03:32,734 INFO: Executed "router bgp 4200000005 no neighbor swp5 interface peer-group UNDERLAY" 2022-04-08 20:03:32,892 INFO: Failed to execute router bgp 4200000005 no neighbor swp5 password SSSS 2022-04-08 20:03:33,050 INFO: Failed to execute router bgp 4200000005 no neighbor swp5 password 2022-04-08 20:03:33,218 INFO: Failed to execute router bgp 4200000005 no neighbor swp5 2022-04-08 20:03:33,354 INFO: Failed to execute router bgp 4200000005 no neighbor 2022-04-08 20:03:33,520 INFO: Failed to execute router bgp 4200000005 no 2022-04-08 20:03:33,521 ERROR: "router bgp 4200000005 -- no" we failed to remove this command 2022-04-08 20:03:33,521 ERROR: % Specify remote-as or peer-group commands first 2022-04-08 20:03:33,691 INFO: Failed to execute router bgp 4200000005 no neighbor swp5 advertisement-interval 0 2022-04-08 20:03:33,853 INFO: Failed to execute router bgp 4200000005 no neighbor swp5 advertisement-interval 2022-04-08 20:03:34,015 INFO: Failed to execute router bgp 4200000005 no neighbor swp5 2022-04-08 20:03:34,145 INFO: Failed to execute router bgp 4200000005 no neighbor 2022-04-08 20:03:34,326 INFO: Failed to execute router bgp 4200000005 no 2022-04-08 20:03:34,327 ERROR: "router bgp 4200000005 -- no" we failed to remove this command 2022-04-08 20:03:34,327 ERROR: % Specify remote-as or peer-group commands first AFTER FIX: ---------- delete of numbered neighbor: 2022-04-08 19:52:17,204 INFO: Executed "router bgp 4200000005 no neighbor 1.2.3.4 peer-group UNDERLAY" 2022-04-08 19:52:17,205 INFO: /var/run/frr/reload-GRFX1M.txt content delete of unnumbered neighbor: 2022-04-08 20:00:02,952 INFO: Executed "router bgp 4200000005 no neighbor swp5 interface peer-group UNDERLAY" 2022-04-08 20:00:02,953 INFO: /var/run/frr/reload-722C3P.txt content Signed-off-by: Chirag Shah <chirag@nvidia.com>
2022-04-23tools: fix bgp instances deletion in frr-reloadChirag Shah
BGPd does not allow default instance deletion in presence of bgp vrf instance; frr-reload script fails if delete list contains default instance followed by vrf instance. Fix: frr-reload scans lines_to_delete to look for 'router bgp' and 'router bgp vrf ...' line. If both are present switch the order to delete bgp vrf instance(s) than default instance at the end. Testing Done: Before: INFO: Loading Config object from file /etc/frr/frr.conf INFO: Loading Config object from vtysh show running INFO: Failed to execute no router bgp 40201 <-- Failed to delete INFO: Failed to execute no router bgp INFO: Failed to execute no router ERROR: "no router" we failed to remove this command ERROR: % Cannot delete default BGP instance. Dependent VRF instances exist INFO: Executed "no router bgp 40201 vrf bgp-test" <-- vrf instance deleted INFO: Loading Config object from vtysh show running After: order of deletion switched INFO: Loading Config object from file /etc/frr/frr.conf INFO: Loading Config object from vtysh show running INFO: Executed "no router bgp 40201 vrf bgp-test" INFO: Executed "no router bgp 40201" INFO: Loading Config object from vtysh show running Signed-off-by: Chirag Shah <chirag@nvidia.com>
2022-04-19packaging: Set default permissions for /var/log/frr to 0755Donatas Abraitis
At the moment we set /var/log/frr permissions to 0750 (frr:frr), but the log file is 0640 (root:adm) (unless logrotated) and that doesn't allow adm group to even open the directory. Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2022-02-10tools: fix frr-reload context keywordsIgor Ryzhov
There are singline-line commands inside `router bgp` that start with `vnc ` or `bmp `. Those commands are currently treated as node-entering commands. We need to specify such commands more precisely. Fixes #10548. Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2022-01-09Merge pull request #10030 from anlancs/cleanup-reload-null0Igor Ryzhov
tools: cleanup convertion of "Null0"
2022-01-09Merge pull request #9517 from anlancs/reload-add-strJafar Al-Gharaibeh
tools: fix wrong get_contexts() of Config class.