summaryrefslogtreecommitdiff
path: root/tools
AgeCommit message (Collapse)Author
2020-10-23tools: add cocci patch for thread cancel api changesMark Stapp
Add Quentin's cocci patch to align code with the changes to the event cancel api. Also added a README to explain what this collection of cocci patches is for. Signed-off-by: Quentin Young <qlyoung@nvidia.com> Signed-off-by: Mark Stapp <mjs@voltanet.io>
2020-10-13tools: use function chownfrrEmanuele Bovisio
chownfrr applies correct owner and group Signed-off-by: Emanuele Bovisio <emanuele.bovisio@eolo.it>
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-08-12Merge pull request #6909 from donaldsharp/weird_dump_commandsSri Mohana Singamsetty
tools: Remove zebra commands that have never existed
2020-08-12tools: Remove zebra commands that have never existedDonald Sharp
The support bundle feature(tm) asks for some data from zebra in the form of a command that has never existed in FRR. Looks like some cruft snuck in remove. Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2020-08-11tools: nb generate callback script to use attrChirag Shah
northbound genrate callback script to use attr->event in case passed in generated callbacks.. Signed-off-by: Chirag Shah <chirag@cumulusnetworks.com>
2020-07-29Merge pull request #6732 from opensourcerouting/printfrr-prepQuentin Young
*: preparations for printfrr coccinelle run
2020-07-23tools: do not silently ignore errors when loading config during startupTore Anderson
Drop the `-n` (`--noerror`) flag from the `vtysh -b` invocation called by the init script responsible for starting FRR. This ensures that errors in the configuration file is propagated to the administrator, and prevents a node from entering a production network while running an essentially undefined configuration (a behaviour that I can personally attest to has the potential to cause disastrous network outages - documented in more detail in Cumulus Networks CS#12791). Silently ignoring errors also leads to the rather odd behaviour that starting FRR will ostensibly succeed, while reloading it immediately after - without changing the configuration - will fail. This is due to the fact that the `-n` flag is not used while reloading. The use of the `-n` flag appears to have been introduced without any explanation in commit 858aa29c6862ed2390baee53b6fc9f54e65246e2 by @donaldsharp. Looking at the commit message, I suspect that it was not an intentional change. It seems more likely to me that it was just meant to be used during testing and development, but ended up being committed to master by accident. Ticket:CM-28003 Signed-off-by: Tore Anderson <tore@fud.no>
2020-07-22Merge pull request #6343 from opensourcerouting/watchfrr-n-20200505Quentin Young
watchfrr: add `-N` and `--netns` options
2020-07-22tools: add frr@.serviceDavid Lamparter
... for starting an FRR instance. Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2020-07-22tools/frr-reload.py: support -N pathspaceDavid Lamparter
Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2020-07-22watchfrr: add (network) namespace supportDavid Lamparter
This adds -N and --netns options to watchfrr, allowing it to start daemons with -N and switching network namespaces respectively. 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>
2020-07-17tools/gcc-frr-format: update READMEDavid Lamparter
Signed-off-by: David Lamparter <equinox@diac24.net>
2020-07-17tools/gcc-frr-format: update debian bitsDavid Lamparter
Signed-off-by: David Lamparter <equinox@diac24.net>
2020-07-17tools/gcc-frr-format: improve testDavid Lamparter
Signed-off-by: David Lamparter <equinox@diac24.net>
2020-07-17tools/gcc-frr-format: update for gcc 10David Lamparter
Signed-off-by: David Lamparter <equinox@diac24.net>
2020-07-15tools: frr-reload: log exclusively through loggerDuncan Eastoe
In several instances a call to log.error() is preceded by a print() for the same message. To prevent duplicate messages these print() calls are removed. To maintain (very) similar behaviour we add a StreamHandler to the logger, when doing logging to a file (ie. --reload without --stdout), which additionally sends error and above logs to STDOUT without any metadata (exactly as they did before, with print()). There is one subtle change - the log from Vtysh.is_config_available() is now preceded with the "vtysh 'configure' returned" text, whereas previously only the output from vtysh was sent to STDOUT. Furthermore any error logs which weren't previously explicitly logged to STDOUT will now be. Signed-off-by: Duncan Eastoe <duncan.eastoe@att.com>
2020-07-14tools: frr-reload: more detailed log level controlDuncan Eastoe
Add a "--log-level" option to frr-reload to set the maximum message level to be logged. When the option is not used, the level is set to info as before. The existing --debug option is synonymous with --log-level=debug and these options are therefore mutually exclusive. Signed-off-by: Duncan Eastoe <duncan.eastoe@att.com>
2020-07-14tools: improve cocci.hDavid Lamparter
Add a few more macros so coccinelle can parse code correctly. Signed-off-by: David Lamparter <equinox@diac24.net>
2020-07-14*: un-split strings across linesDavid Lamparter
Remove mid-string line breaks, cf. workflow doc: .. [#tool_style_conflicts] For example, lines over 80 characters are allowed for text strings to make it possible to search the code for them: please see `Linux kernel style (breaking long lines and strings) <https://www.kernel.org/doc/html/v4.10/process/coding-style.html#breaking-long-lines-and-strings>`_ and `Issue #1794 <https://github.com/FRRouting/frr/issues/1794>`_. Scripted commit, idempotent to running: ``` python3 tools/stringmangle.py --unwrap `git ls-files | egrep '\.[ch]$'` ``` Signed-off-by: David Lamparter <equinox@diac24.net>
2020-07-14tools: add source code string manglerDavid Lamparter
Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2020-07-09tools: create sub-context for bfd peersPaul Manley
add lines starting with 'peer' to the list of sub-contexts that are handled by frr-reload.py. https://github.com/FRRouting/frr/issues/6511#issuecomment-655163833 Signed-off-by: Paul Manley <paul.manley@wholefoods.com>
2020-07-02tools: Catch argv_find() cases when testing only the indexDonatas Abraitis
Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
2020-06-24tools: Fix reload with 'ipv6 address...' in interfaceDonald Sharp
When you have this configuration: int foo ipv6 address fd01:0:0:1::1/64 And issue a reload statement, FRR-reload is reducing the code to a `no ipv6 address fd01:0:0:1::/64` and then issuing a: `ipv6 address fd01:0:0:1::/64` The end result is of course that the foo interface now has two v6 addresses on it. The brilliance of this is of course if you happen to have two systems that are connected over an interface, and you issue a reload command. They both get fd01:0:0:1::/64 as an ipv6 address and DAD detection kicks in and stomps on your stuff. Put a special hey don't munch the v6 address line in a reload situation. Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2020-06-18Merge pull request #6614 from qlyoung/fix-evpnmh-reloadJafar Al-Gharaibeh
tools: 'evpn mh' is a new one-line context
2020-06-18tools: 'evpn mh' is a new one-line contextQuentin Young
frr-reload.py needs to know about config-level commands, otherwise it assumes they are contexts Ticket: CM-30128 Ticket: CM-30077 Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2020-06-15tools: fix frr-reload.py daemon optionEmanuele Di Pascale
the refactored frr-reload.py is adding 'no-header' to the 'show running' command of vtysh, but if a daemon is specified the no-header option should only be added after the daemon name. Signed-off-by: Emanuele Di Pascale <emanuele@voltanet.io>
2020-05-26tools/frr-reload: --vty_socket argDavid Lamparter
After the cleanup, adding this doesn't require updating a zillion locations in the code anymore, just one :) Partially derived from 6a00e91d99f7f98d857c2056d0dcfeba48966581 Originally-by: Emanuele Di Pascale <emanuele@voltanet.io> Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2020-05-26tools/frr-reload: cleanup passDavid Lamparter
- throw vtysh into a wrapper class - ignore "username" commands - use mark output on stdout - some other random cleanups Signed-off-by: David Lamparter <equinox@diac24.net>
2020-05-18Merge pull request #6406 from donaldsharp/ospf_multi_instance_start_fixDonatas Abraitis
tools: Only load instances or daemon
2020-05-14tools: Only load instances or daemonDonald Sharp
Original start/stop of FRR prior to David's rewrite in PR 3507, when configuring multi-instance would only start multi-instance (-1 -2 -3 -4...) or just the daemon, not both. If you happened to start a ospfd instance of 1 then both the default and instance 1 would react to cli. Do not allow this, put it back to original behavior Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2020-05-13Merge pull request #6387 from donaldsharp/reloadDonatas Abraitis
tools: revert frr-reload.py remove stderr redirects"
2020-05-12tools: revert frr-reload.py remove stderr redirects"Donald Sharp
This reverts commit 3fa139a65be70e5a81b5f078530094f09a247416. This is being reverted because this commit completely breaks the invocation of frr-reload. Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2020-05-11build: use configfile mode in init scriptDavid Lamparter
This only applies for split-config; the init script would create an empty config file with default permissions. Reported-by: Robert Scheck <robert@fedoraproject.org> Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2020-05-08Merge pull request #6348 from dslicenc/frr-reload-bfdDonatas Abraitis
tools: fix frr traceback on bgp neighbor bfd deletion
2020-05-05tools: fix frr traceback on bgp neighbor bfd deletionDon Slice
Problem reported that with certain configs, when the user deleted a "neighbor x.x.x.x bfd 4 100 100" statement from frr.conf and then reloaded, a traceback was seen and the deletion did not succeed. Found that in some scenarios it was possible to have something in lines_to_add that was in a different context and when the re.search was attempted, it found an empy line and was unhappy. This fix avoids trying to search in the wrong context. Ticket: CM-29145 Signed-off-by: Don Slice <dslice@cumulusnetworks.com>
2020-05-05build: add LLVM bitcode targetsDavid Lamparter
Just an easy way to produce LLVM .bc (bitcode) files. Not used during normal builds. Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2020-05-05tools: frr-llvm-cgDavid Lamparter
This dumps call graph data from LLVM bitcode files into a JSON file. Specifically for FRR, it understands thread_add_*(), hook_*() and install_element() so it can provide extra information in these cases. As a general feature, it tries to track down function pointers as far as easily feasible. Signed-off-by: David Lamparter <equinox@diac24.net>
2020-04-27tools: fix frr-reload AF issue with ldpdEmanuele Di Pascale
when removing a whole address-family block from ldpd config we were erroneously trying to also remove each of the interface sub-sub-contexts that belonged to it; this would effectively re-enable the AF we just removed. Work around this by ignoring these sub-sub-contexts if we detect that we are already removing the parent block. Signed-off-by: Emanuele Di Pascale <emanuele@voltanet.io>
2020-04-27tools/symalyzer: fix copypastaDavid Lamparter
Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2020-04-27python: move MakeVars class into separate moduleDavid Lamparter
... so I can reuse it. Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2020-04-24Merge pull request #6279 from opensourcerouting/nb-cb-argsDonald Sharp
*: change the signature of the northbound callbacks to be more flexible
2020-04-23*: change the signature of the northbound callbacks to be more flexibleRenato Westphal
Having a fixed set of parameters for each northbound callback isn't a good idea since it makes it difficult to add new parameters whenever that becomes necessary, as several hundreds or thousands of existing callbacks need to be updated accordingly. To remediate this issue, this commit changes the signature of all northbound callbacks to have a single parameter: a pointer to a 'nb_cb_x_args' structure (where x is different for each type of callback). These structures encapsulate all real parameters (both input and output) the callbacks need to have access to. And adding a new parameter to a given callback is as simple as adding a new field to the corresponding 'nb_cb_x_args' structure, without needing to update any instance of that callback in any daemon. This commit includes a .cocci semantic patch that can be used to update old code to the new format automatically. Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2020-04-20bgpd, isis, tools: style fixenQuentin Young
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2020-04-20*: use appropriate buffer sizes, specifiersQuentin Young
- Fix 1 byte overflow when showing GR info in bgpd - Use PATH_MAX for path buffers - Use unsigned specifiers for uint16_t's in zebra pbr Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2020-04-20*: sprintf -> snprintfQuentin Young
Replace sprintf with snprintf where straightforward to do so. - sprintf's into local scope buffers of known size are replaced with the equivalent snprintf call - snprintf's into local scope buffers of known size that use the buffer size expression now use sizeof(buffer) - sprintf(buf + strlen(buf), ...) replaced with snprintf() into temp buffer followed by strlcat Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>