Commit graph

768 commits

Author SHA1 Message Date
Carmine Scarpitta c5dfb9f5e5
Merge pull request #18628 from raja-rajasekar/rajasekarr/fix_frr_reload_srv6
tools: fix reload script for SRv6 locators and formats
2025-04-11 17:07:05 +02:00
Rajasekar Raja ce06d35fa9 tools: fix reload script for SRv6 locators and formats
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>
2025-04-10 07:55:57 -07:00
Martin Winter 9acadf8d3f
tools: Add pathspace option to generate_support_bundle
Adding a `-N` pathspace option to the generate_support_bundle.py
to support FRR running in a non-default namespace with a prefix
on the config/socket options.
The same pathspace will be prepended to the output log files (if
specified)

Signed-off-by: Martin Winter <mwinter@opensourcerouting.org>
2025-04-10 16:47:27 +02:00
Mark Stapp edb330686d tools,pceplib,ospfclient: clean up variable-shadow warnings
Clean up -Wshadow warnings in these components

Signed-off-by: Mark Stapp <mjs@cisco.com>
2025-04-08 14:41:27 -04:00
Martin Winter 29e8cf3a22
tools: Add option to frr-reload to specify alternate logfile
Adding option --logfile to specify a different logfile instead of
the default /var/log/frr/frr-reload.log

Signed-off-by: Martin Winter <mwinter@opensourcerouting.org>
2025-03-10 23:23:04 +01:00
Carmine Scarpitta a515de1c46 tools: Fix frr-reload.py error related to static-sids
```
[...]
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>
2025-03-02 00:02:57 +01:00
Donatas Abraitis b6ae929c1d
Merge pull request #16796 from gtataranni/feat/logfmt
tools: add logfmt option for frr-reload.py
2025-02-17 23:02:27 +02:00
Giovanni Tataranni 44a6e0dfed tools: add logfmt option for frr-reload.py
Add the option of printing logs in logfmt format.

Additional machine readable information can be printed via the `extra`
argument.
Example:
```python
log.debug("exit context"), extra={"line": line, "ctx_keys": ctx_keys})

log.error(f"Failed to execute command {' '.join(cmd)}", extra={"cmd": cmd})
```

Signed-off-by: Giovanni Tataranni <g.tataranni@gmail.com>
2025-02-17 17:33:28 +01:00
Donald Sharp 9101bff6d2 tools: watchfrr should ignore frr_global_options
watchfrr is currently being started with $frr_global_options
This is problematic as that it has a entirely different cli
than the rest of the daemons and we have no plans to make
this equivalent.

Fixes: #18107

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2025-02-13 11:41:27 -05:00
Donald Sharp 2bda884dfd tools: Add some more support bundle commands
Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2025-02-05 09:08:11 -05:00
Nobuhiro MIKI 594e917656 tools: Fix frr-reload for ebgp-multihop TTL reconfiguration.
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 767aaa3a80 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-29 04:43:17 +00:00
Donatas Abraitis 5f231287a3
Merge pull request #16723 from jklaiber/fix-reload-interface-deletion
tools: fix reload interface deletion
2025-01-21 16:28:28 +02:00
Christian Hopps 2e0387c97b tools: fix regression in gen_northbound_callback tool
When support for new style `get()` was added inadvertently stopped
generating other callbacks and prototypes. Fix this.

Signed-off-by: Christian Hopps <chopps@labn.net>
2025-01-20 06:01:59 +00:00
Julian Klaiber f1a1703a0a tools: Allow deleting of interfaces
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-16 07:04:15 +01:00
Chirag Shah 3ef97f0e2f tools: fix frr-reload for nbr deletion of no form cmds
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-13 11:53:18 -08:00
Giovanni Tataranni a09e949e48 tools: use f-string in frr-reload.py
Adopt f-string for printing log message, so that appropriate formatting can be
applied.

Signed-off-by: Giovanni Tataranni <g.tataranni@gmail.com>
2025-01-13 11:08:51 +01:00
Donald Sharp cc07a4a200
Merge pull request #17772 from LabNConsulting/chopps/fix-oper-walk
improve error handling of operational state walk callback
2025-01-07 13:52:37 -05:00
Christian Hopps 153c06043b tools: add new-style get operation callback support
Signed-off-by: Christian Hopps <chopps@labn.net>
2025-01-07 05:33:32 -05:00
Christian Hopps bdfb6a3db7 tools: we specifically added %Lu to our sprintfrr so allow it
Signed-off-by: Christian Hopps <chopps@labn.net>
2025-01-07 01:34:13 -05:00
Jonathan Voss 975ee8ed6e tools: Add missing rpki keyword to vrf in frr-reload
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>
2025-01-03 03:31:57 +00:00
Donatas Abraitis 38c3419f3d
Merge pull request #17719 from jvoss/srv6_format
tools: Add missing formats keyword to segment-routing in frr-reload
2024-12-31 15:33:21 +02:00
Jonathan Voss 5b8b821f2f tools: Add missing formats keyword to segment-routing in frr-reload
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-12-24 17:27:23 +00:00
Christian Hopps a1fb051590 tools: add support for multiple YANG paths
Signed-off-by: Christian Hopps <chopps@labn.net>
2024-12-15 21:51:13 -05:00
Donald Sharp f032106fdf tools: Add rip support bundle commands
Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2024-12-13 10:56:17 -05:00
Chirag Shah 814a89f6e5 tools: fix style check babletrace file
python3 -m black tools/frr_babeltrace.py

Signed-off-by: Chirag Shah <chirag@nvidia.com>
2024-11-25 09:00:03 -08:00
Chirag Shah 91119dab9b tools: add helper function to print family
Ticket: #4127810
Testing:
2024-11-20T01:52:10.073 frr_zebra:netlink_neigh_update_msg_encode
{'mac': '00:00:00:00:00:00', 'ip': '27.0.0.4', 'nhg': 0, 'flags': 2,
'state': 192, 'family': 'bridge', 'type': 0, 'op': 23}

Signed-off-by: Chirag Shah <chirag@nvidia.com>
2024-11-25 09:00:03 -08:00
Carmine Scarpitta c8e83c3bfd tools: Add missing keyword encapsulation in frr-reload
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-24 10:08:47 +01:00
Carmine Scarpitta 458e8a8516 tools: Add missing keyword node-msd in frr-reload
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-23 08:56:05 +01:00
Carmine Scarpitta b4babae93b tools: Add missing keyword segment-routing srv6 in frr-reload
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-11-23 08:55:55 +01:00
Corey Siltala ef650aca27 tools: Add pim show commands to support bundle
Add more data gathering for pim and pim6 support bundles

Signed-off-by: Corey Siltala <csiltala@atcorp.com>
2024-11-21 17:37:39 -06:00
Donald Sharp dca9915059 tools: Add pim msdp show commands to support bundle
The support bundle was not gathering any msdp data
for pim at all.  Let's add a bit to allow us to
have more data here when a suppport bundle is generated

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2024-11-21 09:16:14 -05:00
Donald Sharp 274156f4d3 tools: Add zebra label show commands to support bundle
There were no zebra show commands related to mpls labels
being generated for support bundles.  Let's rectify that
situation.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2024-11-21 09:15:22 -05:00
Donald Sharp 910b384094 tools: Add isis command generation to support bundle
When a support bundle is created no isis commands were
issued to attempt to gather data about what is going
on in isis.  Let's rectify that

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2024-11-21 09:14:19 -05:00
Donald Sharp b1fbcb6d13 tools: Add bmp command to support bundle generation
Add a bit of bmp data gathering for bgp support bundle generation

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2024-11-21 09:13:24 -05:00
David Lamparter cf4fc9c484 tools: remove strncpy() use
`checkpatch` has sufficiently annoyed me to fix this.

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2024-10-22 14:53:52 +02:00
David Lamparter 070ce19d0c tools/gcc-plugins: don't crash on array parameters
Need to have arrays as a stop condition in this type normalization
function, like pointers and function pointers.  Actual arrays as
argument types are extremely rare to see because C has this
array-decay-to-pointer thing, but it can happen.

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2024-10-15 13:35:24 +02:00
Donatas Abraitis f57a56bca0 tools: Add missing mgmtd into logrotate/rsyslogd
Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2024-10-10 13:01:05 +03:00
Christian Hopps e8648a0c72 lib: add flag to have libyang load internal ietf-yang-library module
Mgmtd makes use of libyang's internal ietf-yang-library module to add
support for said module to FRR management. Previously, mgmtd was loading
this module explicitly; however, that required that libyang's
`ietf-yang-library.yang` module definition file be co-located with FRR's
yang files so that it (and ietf-datastore.yang) would be found when
searched for by libyang using FRRs search path. This isn't always the
case depending on how the user compiles and installs libyang so mgmtd
was failing to run in some cases.

Instead of doing it the above way we simply tell libyang to load it's
internal version of ietf-yang-library when we initialize the libyang
context.

This required adding a boolean to a couple of the init functions which
is why so many files are touched (although all the changes are minimal).

Signed-off-by: Christian Hopps <chopps@labn.net>
2024-10-07 03:32:44 +00:00
anlan_cs e3a846754d tools: fix some special commands for reloading pim
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-10-05 22:00:01 +08:00
anlan_cs 1276eaaa90 tools: fix missing check interfaces for reloading pim
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-29 10:51:39 +08:00
Donatas Abraitis 3dbef7a119
Merge pull request #16733 from gtataranni/fix/regex-string
tools: fix invalid escape on regex string
2024-09-04 08:13:19 +03:00
Giovanni Tataranni fe9e148aaa tools: fix invalid escape on regex string
fix usage of regex string without proper escaping

Signed-off-by: Giovanni Tataranni <g.tataranni@gmail.com>
2024-09-03 19:14:45 +02:00
Jafar Al-Gharaibeh b3dc3680bc tools, ospfclient: add a config option to skip installing python scripts
The new config option --disable-python-runtime allows make install to proceed
without installing any of the python scripts. When installing from deb/rpm
packages those are bundled as frr-pythontools, which is independent from the
frr binaries and can already be skipped. I.e, this PR gives the option to skip
those scripts when building/installing from sources too.

Signed-off-by: Jafar Al-Gharaibeh <jafar@atcorp.com>
2024-08-22 13:46:30 -05:00
Donatas Abraitis 850076b3a1 tools: Fix python string escape warnings for frr-reload.py
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: 8916953b53 ("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-08-08 08:46:39 +03:00
David Lamparter 67a76894b7 tools/checkpatch: recognize + as unary operator
Allow using "+1" when meaningful (i.e. cmd_graph_merge wants -1 or +1)

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2024-07-31 08:08:53 -04:00
Donatas Abraitis 01b7bd3b13 tools: Apply black formatting for the recent frr-reload.py changes
Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2024-07-20 03:30:08 +03:00
Donatas Abraitis d022a4099c tools: Do not append an empty list (pim_vrfs) to the config lines
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: 98d47f43fb ("tools: Fix frr-reload to support legacy pim configuration from file")

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2024-07-20 03:29:21 +03:00
Nathan Bahr 98d47f43fb tools: Fix frr-reload to support legacy pim configuration from file
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-07-16 13:41:18 -05:00
David Lamparter f9d4d1626d tools/checkpatch: accept pim_* typedefs
pimd uses "v4/v6 dispatch" typedefs.  Don't complain about those in
checkpatch.

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2024-06-21 11:32:42 +02:00
David Lamparter da3677e719 tools/gcc-plugins: warn for suseconds_t format
The plugin was already catching attempts to print `time_t` without
casting it first (there is no valid printf specifier without a cast),
but `__suseconds64_t` needs the same treatment.  (Probably
`__suseconds_t` too, if it exists, which I'm not sure it does - but that
doesn't matter, the plugin ignores non-existing types.)

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2024-05-02 22:26:53 +02:00