summaryrefslogtreecommitdiff
path: root/tools/frr-reload.py
AgeCommit message (Collapse)Author
2021-12-31tools: cleanup route convertion from null0/Null0 to blackholeanlan_cs
Signed-off-by: anlan_cs <anlan_cs@tom.com>
2021-12-07Merge pull request #10187 from chiragshah6/freloadRuss White
tools: exit when reload fails to parse config file
2021-12-06tools: exit when reload fails to parse config fileChirag Shah
frr-reload triggers restart of service in case it fails to parse new config file and conjunction with running config contains 'router bgp' (default bgp instnace). When frr-reload fails to parse new config file, it fails to build newconfig context (empty object). Instead of bailing out it compares against the running config context. If the running config contains default bgp instance it thinks new config is removing default bgp instance so it triggers frr restart. Fix is to to bail out reload script when it fails to parse config file. Ticket:#2861989 Reviewed By: MR-83 Testing Done: router bgp 102 vrf RED bgp router-id 2.2.2.2 neighbor underlay peer-group neighbor underlay remote-as <---- Partial config Before fix: 2021-12-02 02:43:16,987 ERROR: vtysh failed to process new configuration: vtysh (mark file) exited with status 4: b'line 79: % Command incomplete: neighbor underlay remote-as\n\n' 2021-12-02 02:43:17,145 INFO: Loading Config object from vtysh show running 2021-12-02 02:43:17,362 INFO: "frr version 7.5+cl5.0.0u0" cannot be removed 2021-12-02 02:43:17,362 INFO: "frr defaults datacenter" cannot be removed 2021-12-02 02:43:17,362 INFO: "service integrated-vtysh-config" cannot be removed 2021-12-02 02:43:17,363 INFO: "line vty" cannot be removed 2021-12-02 02:43:17,522 INFO: EVPN is enabled and default instance del needed 2021-12-02 02:43:17,522 INFO: Restarting FRR <---- Restart frr After fix: Just throw Error and abort the script. root@TORS1:mgmt:/home/cumulus# /usr/lib/frr/frr-reload.py --debug --reload --stdout /etc/frr/frr.conf 2021-12-02 04:00:56,519 INFO: Called via "Namespace(bindir='/usr/bin', confdir='/etc/frr', daemon='', debug=True, filename='/etc/frr/$ rr.conf', input=None, overwrite=False, pathspace=None, reload=True, rundir='/var/run/frr', stdout=True, test=False, vty_socket=None)" 2021-12-02 04:00:56,520 INFO: Loading Config object from file /etc/frr/frr.conf 2021-12-02 04:00:56,679 ERROR: vtysh failed to process new configuration: vtysh (mark file) exited with status 4: b'line 79: % Command incomplete: neighbor underlay remote-as\n\n' root@TORS1:mgmt:/home/cumulus# Signed-off-by: Chirag Shah <chirag@nvidia.com>
2021-12-05frr-reload: fix bgp nbr remote-asChirag Shah
Remove neighbor <> remote-as <> config line, if the neighbor is part of the peer-group and peer-group contains remote-as config. Neighbors which are part of the peer-group cannot override remote-as. Fix: Frr-reload needs to remote 'neighbor <> remote-as <>' from lines_to_add if its already part of peer-group and peer-group has remote-as config. Testing Done: Before: Config snippet: neighbor PEERS peer-group neighbor PEERS remote-as external neighbor PEERS timers 3 9 neighbor 10.2.1.1 remote-as external neighbor 10.2.1.1 peer-group PEERS neighbor 10.2.1.1 timers 3 9 neighbor 10.2.1.2 remote-as external neighbor 10.2.1.2 peer-group PEERS Frr-reload failure: line 179: Failure to communicate[13] to bgpd, line: neighbor 10.2.1.1 remote-as external % Peer-group member cannot override remote-as of peer-group line 179: Failure to communicate[13] to bgpd, line: neighbor 10.2.1.2 remote-as external % Peer-group member cannot override remote-as of peer-group After: frr-reload apply the config successfully. Signed-off-by: Chirag Shah <chirag@nvidia.com>
2021-11-17tools, vtysh: Remove final vestige of `address-family evpn`Donald Sharp
This was deprecated over a year ago now. Let's finally remove it from the system. Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2021-11-12tools: simplify excessively complex conditionalQuentin Young
Signed-off-by: Quentin Young <qlyoung@nvidia.com>
2021-11-12tools: string literals -> commentsQuentin Young
Convert all floating string literals being used as comments, to comments Signed-off-by: Quentin Young <qlyoung@nvidia.com>
2021-10-09tools: fix wrong get_contexts() of Config class.anlan_cs
Calling get_contexts() can't display as expected, it wrongly displays: <__main__.Context object at 0x7fdee1d5ad50> So make it display correct data by add __str__ in Context class. Signed-off-by: anlan_cs <anlan_cs@tom.com>
2021-09-04tests: cleanup: rerun changed files through blackChristian Hopps
Signed-off-by: Christian Hopps <chopps@labn.net>
2021-09-04tests: cleanup - remove unused importsChristian Hopps
Signed-off-by: Christian Hopps <chopps@labn.net>
2021-09-04tools: move frr-reload.py to python3 explicitlyChristian Hopps
We already, reasonably, require python3 elsewhere. Do so here, and reap some benefit. Signed-off-by: Christian Hopps <chopps@labn.net>
2021-08-23tools: significantly simplify frr-reload context processingIgor Ryzhov
Currently, in frr-reload we: - store a list of single-line context keywords which needs to be frequently updated, - have a separate "if" clause for every node and subnode we have in FRR. Instead, we can store the tree of all known FRR nodes. This tree needs to be updated whenever we add a new node, which is not frequent. And, most importantly, it allows us to write node-agnostic code and save more than 250 LOC. Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2021-08-08Merge pull request #8870 from anlancs/master-fix-reload-serviceDonald Sharp
tools: add "vni" to oneline list
2021-07-15tools: improve frr-reload.py delta file creationChristian Hopps
- Remove incorrect requirement for `service integrated-vtysh-config` when producing a delta. - Add `--test-reset` option which suppresses non-parseable lines from the produced delta - Use new features in common_config.py Signed-off-by: Christian Hopps <chopps@labn.net>
2021-06-30tools: add "vni" to oneline listanlancs
Add "vni" into oneline list. Additionally, keep them in order in oneline list. Signed-off-by: anlancs <anlan_cs@tom.com>
2021-06-23tools: limit bgp route-maps to direct changes onlyDonald Sharp
When using frr-reload.py to modify a bgp neighbors route-map the code was doing this: a) deleting the previous route-map: `no neighbor XX route-map YY (in|out)` b) Adding the new route-map back in `neighbor XX route-may ZZ (in|out)` Now imagine that we have an outgoing route-map that we are changing and the reload is large because of a large number of lines in frr.conf Item (a) will happen. BGP will immediately start sending all local routes. At some point in time in the future (b) will be applied. This of course causes a withdraw but for a short amount of time we are leaking unintended routes. This is bad for several reasons not 1) route churn upstream, 2) we might influence traffic to go the wrong way. 3) if upstream has a maximum-prefix command the routes being sent might trip its circuitry and shutdown the peer entirely not even allowing you to get to (b). Ticket: #2589685 Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2021-06-22Merge pull request #8867 from wesleycoakley/pbr-table-range-single-lineMark Stapp
tools: make frr-reload recognize `pbr table range` lines as single-line contexts
2021-06-18tools: add mac access-list context to frr-reload.pyDon Slice
Problem reported that frr-reload.py didn't handle the mac access-list command correctly, causing reloads to fail. This fix adds the support for the command as a single line context. Signed-off-by: Don Slice <dslice@nvidia.com>
2021-06-16tools: reload recognizes `pbr table range` as single-line ctxWesley Coakley
The line `pbr table range ...` does not start a new context so treat it like a single-line context Signed-off-by: Wesley Coakley <w@wesleycoakley.com>
2021-05-24tools: fix peer-group deletion in frr-reloadChirag Shah
All of peers and respective configs are wiped out when pee-group is removed. In an attempt to remove peer-group and its associated peers configs via frr-reload fails if the peer-group is removed first. To pass the peer-group config removal via frr-reload following steps are taken: Find the bgp context to which peer-group belongs. Find the peer-group associated peer(s) and store them in a list. Remove the peers config lines from the pending list. Move the peer-group deletion line to end of the pending list so any remaining peer-group associated config can be removed successfully. The above steps take 3 iterations over the pending list and scales linearly. Ticket:2656351 Reviewed By:CCR-11575 Testing Done: Broken: config: router bgp 5544 neighbor PG1 peer-group neighbor PG1 remote-as external neighbor swp10 interface peer-group PG1 neighbor swp10 timers 3 9 failed frr-reload log: 2021-05-17 22:02:42,608 INFO: Executed "router bgp 5544 no neighbor PG1 peer-group" 2021-05-17 22:02:42,708 INFO: Failed to execute router bgp 5544 no neighbor PG1 remote-as external 2021-05-17 22:02:42,808 INFO: Failed to execute router bgp 5544 no neighbor PG1 remote-as 2021-05-17 22:02:42,906 INFO: Failed to execute router bgp 5544 no neighbor PG1 2021-05-17 22:02:43,007 INFO: Failed to execute router bgp 5544 no neighbor 2021-05-17 22:02:43,106 INFO: Failed to execute router bgp 5544 no 2021-05-17 22:02:43,106 ERROR: "router bgp 5544 -- no" we failed to remove this command 2021-05-17 22:02:43,107 ERROR: % Create the peer-group or interface first With fix: 2021-05-17 22:05:27,687 INFO: Executed "router bgp 5544 no neighbor PG1 remote-as external" 2021-05-17 22:05:27,791 INFO: Executed "router bgp 5544 no neighbor PG1 peer-group" Signed-off-by: Chirag Shah <chirag@nvidia.com>
2021-05-06tools: stop frr-reload squashing le 32 / le 128Wesley Coakley
frr-reload no longer consolidates ip prefix-list "le 32" or "le 128" rules when a "ge" is present, more accurately representing existing user config and reflecting also what is accepted in CLI. Signed-off-by: Wesley Coakley <wcoakley@nvidia.com>
2021-04-21tools: Cleanup frr-reload.py by running black on itDonald Sharp
Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2021-04-21tools: Fix warning when running frr-reload.pyDonald Sharp
When I run frr-reload.py I am seeing this error: Apr 21 06:23:51 eva frrinit.sh[3776992]: /usr/lib/frr/frr-reload.py:1094: SyntaxWarning: "is not" with a literal. Did you mean "!="? Apr 21 06:23:51 eva frrinit.sh[3776992]: if line is not "exit-vrf": fix Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2021-04-01tools: do in-place SRGB/SRLB changesEmanuele Di Pascale
avoid issuing a [no] command if we are then issuing the affirmative one. This avoids spurious requests for the default label ranges, which might fail if something else is using those labels. Signed-off-by: Emanuele Di Pascale <emanuele@voltanet.io>
2021-03-31tools: frr-reload fixes for deleting vrf static routesDon Slice
Problems reported that in certain cases, frr-reload.py would delete vrf static routes inadvertantly due to two different reasons. First, vrf statics with null0 or Null0 nexthops would fail the match since rendered as blackholes. This was already fixed for non-vrf statics so added for vrf-based. Second, frr-reload would fail to match due to different formats for adding the command. If entered in the old way "ip route x.x.x.x/x y.y.y.y vrf NAME" and rendered in the new sway "vrf NAME\nip route x.x.x.x/x y.y.y.y" it would fail to match do an inadvertant delete. Ticket: 2570270 Signed-off-by: Don Slice <dslice@nvidia.com>
2021-03-31tools: frr-reload.py changes to make black happyDon Slice
Since black is finding issues before applying my change, committing those changes separately Signed-off-by: Don Slice <dslice@nvidia.com>
2021-03-08tools: frr-reload capture vtysh msg upon failureChirag Shah
Log vtysh message for a failed command. Ticket:2556706 Reviewed By: Testing Done: frr reload fails to delete default bgp instance in presence of bgp vrf instance(s), it captures vtysh message and logs in frr-reload.log logs backend 2021-03-05 05:16:45,623 INFO: Failed to execute no router bgp 5544 2021-03-05 05:16:45,735 INFO: Failed to execute no router bgp 2021-03-05 05:16:45,846 INFO: Failed to execute no router 2021-03-05 05:16:45,846 ERROR: "no router" we failed to remove this command 2021-03-05 05:16:45,847 ERROR: % Cannot delete default BGP instance. Dependent VRF instances exist Signed-off-by: Chirag Shah <chirag@nvidia.com>
2021-03-08tools: Mark reload failure when no form cli failsChirag Shah
if no form of the cli fails to execute, mark frr-reload as failure so return code can be nonzero. The similar approach is done for non no-form (add case) of the cli. Ticket:CM-33345 Reviewed By:CCR-11287 Testing Done: Signed-off-by: Chirag Shah <chirag@nvidia.com>
2021-02-04frr-reload: rpki context exiting uses exit and not endRunar Borge
Issue: The rpki subcontext uses exit instead of end to exit. This makes issues with frr-reload in the way that frr-reload never exits rpki context until it reaches the next end statement. this also happens when parsing the configuration from vtysh. Fixes: #7887 Signed-off-by: Runar Borge <runar@borge.nu>
2021-01-20tools: fix frr-reload BFD profile supportRafael Zalamena
Fix the handling of multiple BFD profiles by adding the appropriated code to push/pop contexts inside BFD configuration node. Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
2021-01-13tools: ignore missing seq nums in prefix and access lists in frr-reload.pyDon Slice
If frr.conf contains a prefix-list or access-list without a seq number, frr-reload needs to be aware that it should not delete/add if the running config contains a seq number. Ticket: CM-32623 Signed-off-by: Don Slice <dslice@nvidia.com>
2021-01-13tools: apply black formatting changes to frr-reload.pyDon Slice
Since new workflow instructions state to run black against python change and it found formatting changes required that were not part of my change set, committing those changes separately. Signed-off-by: Don Slice <dslice@nvidia.com>
2021-01-09tools: fix pce-config removalEmanuele Di Pascale
make sure that the order in which the pcep-related commands are removed by frr-reload.py is the correct one, i.e., pce followed by pce-config followed by pcc. Signed-off-by: Emanuele Di Pascale <emanuele@voltanet.io>
2021-01-09pathd, tools: fix peer preference configEmanuele Di Pascale
on one hand, the default value for a peer preference was always being displayed, and on the other there was some code in frr-reload.py which was attempting to add a default value to match this behavior, and which was incorrectly overriding a specified preference. Fix this by removing this code and making pathd behave like other daemons in this respect, i.e. not displaying the default value. Signed-off-by: Emanuele Di Pascale <emanuele@voltanet.io>
2021-01-09tools: add bfdd to frr-reload.py daemons listEmanuele Di Pascale
Signed-off-by: Emanuele Di Pascale <emanuele@voltanet.io>
2020-12-22Merge pull request #7472 from opensourcerouting/fpm-fixesMark Stapp
fpm: frr-reload, IPv6 and an improvement
2020-12-18pathd: Add optional support for PCEP to pathdSebastien Merle
This new dynamic module makes pathd behave as a PCC for dynamic candidate path using the external library pcpelib https://github.com/volta-networks/pceplib . The candidate paths defined as dynamic will trigger computation requests to the configured PCE, and the PCE response will be used to update the policy. It supports multiple PCE. The one with smaller precedence will be elected as the master PCE, and only if the connection repeatedly fails, the PCC will switch to another PCE. Example of configuration: segment-routing traffic-eng pcep pce-config CONF source-address ip 10.10.10.10 sr-draft07 ! pce PCE1 config CONF address ip 1.1.1.1 ! pce PCE2 config CONF address ip 2.2.2.2 ! pcc peer PCE1 precedence 10 peer PCE2 precedence 20 ! ! ! ! Co-authored-by: Brady Johnson <brady@voltanet.io> Co-authored-by: Emanuele Di Pascale <emanuele@voltanet.io> Co-authored-by: GalaxyGorilla <sascha@netdef.org> Co-authored-by: Javier Garcia <javier.garcia@voltanet.io> Co-authored-by: Renato Westphal <renato@opensourcerouting.org> Co-authored-by: Sebastien Merle <sebastien@netdef.org> Signed-off-by: Sebastien Merle <sebastien@netdef.org>
2020-12-18pathd: New SR-TE policy management daemonSebastien Merle
This new daemon manages Segment-Routing Traffic-Engineering (SR-TE) Policies and installs them into zebra. It provides the usual yang support and vtysh commands to define or change SR-TE Policies. In a nutshell SR-TE Policies provide the possibility to steer traffic through a (possibly dynamic) list of Segment Routing segments to the endpoint of the policy. This list of segments is part of a Candidate Path which again belongs to the SR-TE Policy. SR-TE Policies are uniquely identified by their color and endpoint. The color can be used to e.g. match BGP communities on incoming traffic. There can be multiple Candidate Paths for a single policy, the active Candidate Path is chosen according to certain conditions of which the most important is its preference. Candidate Paths can be explicit (fixed list of segments) or dynamic (list of segment comes from e.g. PCEP, see below). Configuration example: segment-routing traffic-eng segment-list SL index 10 mpls label 1111 index 20 mpls label 2222 ! policy color 4 endpoint 10.10.10.4 name POL4 binding-sid 104 candidate-path preference 100 name exp explicit segment-list SL candidate-path preference 200 name dyn dynamic ! ! ! There is an important connection between dynamic Candidate Paths and the overall topic of Path Computation. Later on for pathd a dynamic module will be introduced that is capable of communicating via the PCEP protocol with a PCE (Path Computation Element) which again is capable of calculating paths according to its local TED (Traffic Engineering Database). This dynamic module will be able to inject the mentioned dynamic Candidate Paths into pathd based on calculated paths from a PCE. https://tools.ietf.org/html/draft-ietf-spring-segment-routing-policy-06 Co-authored-by: Sebastien Merle <sebastien@netdef.org> Co-authored-by: Renato Westphal <renato@opensourcerouting.org> Co-authored-by: GalaxyGorilla <sascha@netdef.org> Co-authored-by: Emanuele Di Pascale <emanuele@voltanet.io> Signed-off-by: Sebastien Merle <sebastien@netdef.org>
2020-12-07Merge pull request #7582 from AnuradhaKaruppiah/frr-reload-cleanupRuss White
frr reload fixes for mac and ip normalization
2020-12-03tools: make frr-reload handle fpm commandsRafael Zalamena
Instruct `frr-reload.py` to not use `fpm` commands as configuration node. Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
2020-11-21frr-reload: ignore-case in the es-id and es-sys-mac config comparisonsAnuradha Karuppiah
MAC address can be configured as lower/upper hex characters but is always rendered as lower case in "show run". Avoid incorrect "change detection" by ignoring case. Ticket: CM-32235 Signed-off-by: Anuradha Karuppiah <anuradhak@nvidia.com>
2020-11-21frr-reload: fixup ipv6 address normalizationAnuradha Karuppiah
The condition to normalize ipv6 addresses was accidentally broken via - [ e238920df07be0b61e483f0a58e0b99ab3d2e0ea tools: Fix reload with 'ipv6 address...' in interface ] The condition was supposed to be skipped only if "ipv6 add" was present in the line. Signed-off-by: Anuradha Karuppiah <anuradhak@cumulusnetworks.com>
2020-11-18tools: fix frr-reload l2vpn deleteEmanuele Di Pascale
when deleting a whole l2vpn context in ldpd which also had pseudowires in it, we were first deleting the l2vpn with a 'no l2vpn XXX' command, and then adding it again by running 'l2vpn XXX\n no member pseudowire YYY' which obviously was not needed. As a result the l2vpn would be reinstated. Signed-off-by: Emanuele Di Pascale <emanuele@voltanet.io>
2020-10-07*: reformat python fileswhitespace
We are now using black. Signed-off-by: Quentin Young <qlyoung@nvidia.com>
2020-09-17tools: fix vtysh failure error handlingQuentin Young
Based on the current code, I think the intent was to gracefully handle vtysh failures and print a useful error message. Barriers in the way of that: - Despite reading the results of subprocess.communicate(), there won't be anything there, because we aren't passing subprocess.PIPE as stdin and stderr when calling subprocess.Popen() - Despite catching subprocess.TimeoutExpired, if we were to actually hit this case frr-reload.py would just crash because it's calling .communicate() on an unbound process variable, probably a copy-paste error - Aside from that, building a kwargs dict to pass to a function that contains something if something else is not None and nothing if it is, is pointless when we could just pass the thing itself Net result is that if vtysh fails to read an frr.conf due to syntax errors, instead of crashing with a traceback, we actually handle the error condition, log the problem and vtysh's output, and exit. Actually we were printing the failed line just by chance because stderr wasn't captured from the subprocess and I guess showed up as part of systemd's error capturing or something, but the traceback did a good job of obscuring that with useless noise. Old: frrinit.sh[32183]: * Started watchfrr frrinit.sh[32183]: line 20: % Unknown command: eee frrinit.sh[32183]: Traceback (most recent call last): frrinit.sh[32183]: File "/usr/lib/frr/frr-reload.py", line 1316, in <module> frrinit.sh[32183]: newconf.load_from_file(args.filename) frrinit.sh[32183]: File "/usr/lib/frr/frr-reload.py", line 231, in load_from_file frrinit.sh[32183]: file_output = self.vtysh.mark_file(filename) frrinit.sh[32183]: File "/usr/lib/frr/frr-reload.py", line 146, in mark_file frrinit.sh[32183]: % (child.returncode, stderr)) frrinit.sh[32183]: __main__.VtyshException: vtysh (mark file) exited with status 2: frrinit.sh[32183]: None New: frrinit.sh[30090]: * Started watchfrr frrinit.sh[30090]: vtysh failed to process new configuration: vtysh (mark file) exited with status 2: frrinit.sh[30090]: line 20: % Unknown command: eee Signed-off-by: Quentin Young <qlyoung@nvidia.com>
2020-08-24lib, tools: fix reloading of key sub-context in key chainsAlexander Chernavin
When you add a key chain in the RIP configuration file and reload the configurations via the frr-reload.py script, the script will fail and the key chain will not appear in the running configuration. The reason is that frr-reload.py doesn't recognize key as a sub-context. Before this change, keys were generated this way: key chain test key 2 key-string 123 key 3 key-string 456 With this change, keys will be generated this way: key chain test key 2 key-string 123 exit key 3 key-string 456 exit This will allow frr-reload.py to see the key sub-context and correctly reload them. Signed-off-by: Alexander Chernavin <achernavin@netgate.com>
2020-08-20Merge pull request #6738 from deastoe/frr-reload-log-levelRafael Zalamena
tools: frr-reload: more detailed log level control
2020-07-22Merge pull request #6343 from opensourcerouting/watchfrr-n-20200505Quentin Young
watchfrr: add `-N` and `--netns` options
2020-07-22tools/frr-reload.py: support -N pathspaceDavid Lamparter
Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2020-07-17tools: fix more frr-reload vrf static errorsDon Slice
Reported that in certain config changes, a static intended for the default table would be duplicated into a vrf context. Determined that we still weren't keeping or adding the exit-vrf command when necessary to keep the contexts straight. Added logic to look for the failing circumstances and add or remove the delete of the exit-vrf command as needed. Signed-off-by: Don Slice <dslice@nvidia.com>