Commit Graph

610 Commits

Author SHA1 Message Date
Donald Sharp
c27892b24d
Merge pull request #11064 from opensourcerouting/fix/allow_only_euid_0_running_frrinit
tools: Allow running frrinit.sh only for EUID=0
2022-04-21 19:49:47 -04:00
Donatas Abraitis
0f65c5602c tools: Allow running frrinit.sh only for EUID=0
watchfrr and staticd do not require <1024 ports to be running, thus they can
start, but others fail.

We should allow only users with EUID=0 (sudo or root) running frrinit.sh.

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2022-04-20 18:39:15 +03:00
Donatas Abraitis
1a8dd6f99b tools: Improve usage example for frrinit.sh
```
root@spine1-debian-11:~/frr# /usr/lib/frr/frrinit.sh
Usage:
    /usr/lib/frr/frrinit.sh <start|stop|restart|force-reload|reload|status> [namespace]
    /usr/lib/frr/frrinit.sh stop namespace1
```

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2022-04-20 18:08:51 +03:00
Donald Sharp
83bbdb5e14
Merge pull request #11052 from opensourcerouting/fix/log_dir_permissions
packaging: A couple of fixes for /var/log/frr
2022-04-20 07:45:08 -04:00
Donald Sharp
27a1680926
Merge pull request #11050 from opensourcerouting/fix/pathd_missing
packaging: Add pathd to logrotate
2022-04-19 14:57:46 -04:00
Donatas Abraitis
03ea2db724 packaging: Add pathd to logrotate
Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2022-04-19 19:13:19 +03:00
Donatas Abraitis
9bf7cb0b74 packaging: Set default permissions for /var/log/frr to 0755
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-04-19 16:54:10 +03:00
Donatas Abraitis
9c2f5943aa tools: Print usage for frrinit.sh when running without arguments
```
root@spine1-debian-11:~/frr# /usr/lib/frr/frrinit.sh
Usage:
    /usr/lib/frr/frrinit.sh (start|stop|restart|force-reload|reload|status)
```

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2022-04-19 14:21:21 +03:00
Donald Sharp
1686b1d486 tools: Modify all_stop to actually try to stop all daemons
If a user enters:
/usr/lib/frr/frrinit.sh start
<modifies daemons file to remove a daemon from being used>
then calls:
/usr/lib/frr/frrinit.sh stop

The daemon(s) that are removed from the file are not stopped.

Apparently in shell scripting naming the variables the same
as the callee does not work as one would think.  Just renaming
the variable to something else solved the problem.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2022-03-30 07:44:31 -04:00
Donatas Abraitis
3989029bc0 tools: Replace strings to tr for frrinit.sh
dc3bae68a2 added strings command, which is wrong.

It requires additional package to be installed on the system (binutils).

Let's just get use `tr`.

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2022-03-24 15:26:26 +02:00
Donatas Abraitis
25d7130380
Merge pull request #8967 from anlancs/fix-startup-error-info
tools: suppress unuseful warnings during restarting frr
2022-03-21 09:52:52 +02:00
Donald Sharp
7baebfb715
Merge pull request #10447 from ton31337/fix/json_with_whitespaces
*: Fix JSON keys with whitespaces and PascalCase
2022-03-13 18:19:33 -04:00
Donald Sharp
115335d3e3 tools: Add show thread timers to support bundle generation
Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2022-02-28 06:39:07 -05:00
Igor Ryzhov
57692f125e tools: fix frr-reload context keywords
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-02-10 02:51:49 +03:00
Donald Sharp
6d30246ef1
Merge pull request #10445 from ton31337/fix/frr-reload_stop_disabled_daemons
tools: Stop disabled daemons when doing reload
2022-02-08 14:15:05 -05:00
Jafar Al-Gharaibeh
89569a7684
Merge pull request #10471 from ton31337/fix/release_candidate_procedure
doc: Add a commands snippet to workflow about what to do in RC1 phase
2022-02-06 15:06:16 -06:00
Donatas Abraitis
5568f9d12b doc: Add a commands snippet to workflow about what to do in the 1st phase
What we should do when creating stabilization branch from the master.

Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
2022-02-05 10:07:32 +02:00
Donatas Abraitis
1988854011 tools: Skip decorating commits with references (branch name, remote)
I think we don't care about this in release notes.

bgpd,pimd,isisd,nhrpd: Convert to vty_json() (origin/fix/vty_json)
ospf6d: Fix memory leak for `show ipv6 ospf6 zebra json` (origin/fix/zebra_ospf6d_json_leak)

Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
2022-02-04 23:24:03 +02:00
Donatas Abraitis
bcd464bb34 tools: Check against capital first in JSON keys
Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
2022-02-03 10:48:06 +02:00
Donatas Abraitis
1ab60f2978 tools: Catch JSON keys with whitespaces
Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
2022-02-03 10:47:32 +02:00
Donatas Abraitis
1c862c2d9e tools: Handle new lines for json_object_to_json_string_ext()
Just to handle %s and %s\n.

Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
2022-01-31 15:34:24 +02:00
Donatas Abraitis
dc3bae68a2 tools: Stop disabled daemons when doing reload
After:
```
root@exit1-debian-11:~# grep ripngd= /etc/frr/daemons
ripngd=no
root@exit1-debian-11:~# pgrep -f ripngd -c
0
root@exit1-debian-11:~# sed -i 's/ripngd=no/ripngd=yes/' /etc/frr/daemons
root@exit1-debian-11:~# /usr/lib/frr/frrinit.sh reload
Stopped watchfrr.
Started watchfrr.
root@exit1-debian-11:~# pgrep -f ripngd -c
2
root@exit1-debian-11:~# grep ripngd= /etc/frr/daemons
ripngd=yes
root@exit1-debian-11:~# sed -i 's/ripngd=yes/ripngd=no/' /etc/frr/daemons
root@exit1-debian-11:~# /usr/lib/frr/frrinit.sh reload
Stopped watchfrr.
Started watchfrr.
Stopped ripngd.
root@exit1-debian-11:~# pgrep -f ripngd -c
0
```

Before:
```
root@exit1-debian-11:~# grep ripngd= /etc/frr/daemons
ripngd=no
root@exit1-debian-11:~# pgrep -f ripngd -c
0
root@exit1-debian-11:~# sed -i 's/ripngd=no/ripngd=yes/' /etc/frr/daemons
root@exit1-debian-11:~# /usr/lib/frr/frrinit.sh reload
Stopped watchfrr.
Started watchfrr.
root@exit1-debian-11:~# pgrep -f ripngd -c
2
root@exit1-debian-11:~# grep ripngd= /etc/frr/daemons
ripngd=yes
root@exit1-debian-11:~# sed -i 's/ripngd=yes/ripngd=no/' /etc/frr/daemons
root@exit1-debian-11:~# /usr/lib/frr/frrinit.sh reload
Stopped watchfrr.
Started watchfrr.
Stopped ripngd.
root@exit1-debian-11:~# pgrep -f ripngd -c
1 <<<<<< ripngd is running, while watchfrr skips it
```

Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
2022-01-31 08:48:44 +02:00
anlan_cs
19a99d89f0 tools: suppress unuseful warnings during restarting frr
Problem:
During restarting frr.service, it throws annoying warnings:
Cannot stop bgpd(and others): pid file not found.

Root Cause:
During restarting process, systemd uses "stop", and watchfrr
uses "restart".
Yes, watchfrr using "restart" is to avoid systemd failing to stop.
But it should be quiet.

Fix:
During restarting service, suppress these warnings from watchfrr.

Signed-off-by: anlan_cs <vic.lan@pica8.com>
2022-01-21 21:23:22 -05:00
David Lamparter
176b254cb9 tools: disable printf ext checks in checkpatch
checkpatch.pl has a hardcoded list of printf extensions supported... by
the Linux kernel.  This happens to have covered the ones we have in FRR
so far, but `%pPA` isn't on the list and others may not be either.

Since we have the frr-format GCC plugin (and CI runs that on Debian 11)
we don't really need these checks in checkpatch.pl.

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2022-01-14 09:18:25 +01:00
Igor Ryzhov
398f41c8bb
Merge pull request #10030 from anlancs/cleanup-reload-null0
tools: cleanup convertion of "Null0"
2022-01-09 17:17:00 +03:00
Jafar Al-Gharaibeh
ca47cd1fb1
Merge pull request #9517 from anlancs/reload-add-str
tools: fix wrong get_contexts() of Config class.
2022-01-09 00:07:53 -06:00
Donald Sharp
bcbc98b0b9
Merge pull request #10242 from anlancs/fix-service-time
build: add "--with-service-timeout" in configure.ac
2022-01-08 07:15:37 -05:00
Donald Sharp
667cfdc824 tools: Run formatter over generate_support_bundle.py
The generate_support_bundle.py script needs some
reformating to meet our standards

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2022-01-06 08:18:30 -05:00
anlan_cs
fc539216ce build: add "--with-service-timeout" in configure.ac
On lower CPU with lots of static routes, it will cost more than 2
minutes.

2 minutes is the default timeout value, we can adjust it by configure:
./configure --with-service-timeout=<digit>

Signed-off-by: anlan_cs <anlan_cs@tom.com>
2022-01-06 07:42:36 -05:00
anlan_cs
9dee14bdb8 tools: cleanup route convertion from null0/Null0 to blackhole
Signed-off-by: anlan_cs <anlan_cs@tom.com>
2021-12-31 00:59:22 -05:00
Jonas Gorski
b321edc51b tools: fix backing up previous logs in generate_support_bundle.py
subprocess.check_call needs to be called with shell=True, else it will
interpret the string as a single path to execute instead of a command
with arguments:

Fixes the following error:

$ /usr/lib/frr/generate_support_bundle.py
Making backup of /var/log/frr/bgp_support_bundle.log
Traceback (most recent call last):
  File "/usr/lib/frr/generate_support_bundle.py", line 89, in <module>
    main()
  File "/usr/lib/frr/generate_support_bundle.py", line 80, in main
    stdout=open_with_backup(ofn),
  File "/usr/lib/frr/generate_support_bundle.py", line 32, in open_with_backup
    subprocess.check_call("mv {0} {0}.prev".format(path))
  File "/usr/lib/python3.8/subprocess.py", line 359, in check_call
    retcode = call(*popenargs, **kwargs)
  File "/usr/lib/python3.8/subprocess.py", line 340, in call
    with Popen(*popenargs, **kwargs) as p:
  File "/usr/lib/python3.8/subprocess.py", line 858, in __init__
    self._execute_child(args, executable, preexec_fn, close_fds,
  File "/usr/lib/python3.8/subprocess.py", line 1704, in _execute_child
    raise child_exception_type(errno_num, err_msg, err_filename)
FileNotFoundError: [Errno 2] No such file or directory: 'mv /var/log/frr/bgp_support_bundle.log /var/log/frr/bgp_support_bundle.log.prev'

Fixes: 5417cc2de ("tests: collect support bundle data in parallel, fix bugs")
Signed-off-by: Jonas Gorski <jonas.gorski@bisdn.de>
2021-12-15 10:41:49 +01:00
Quentin Young
d64d20fcd4
Merge pull request #9937 from Jafaral/rel-script 2021-12-13 12:26:22 -05:00
Russ White
46507be0fe
Merge pull request #10187 from chiragshah6/freload
tools: exit when reload fails to parse config file
2021-12-07 11:40:36 -05:00
Chirag Shah
3a442b25ec tools: exit when reload fails to parse config file
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-06 14:20:57 -08:00
Jafar Al-Gharaibeh
339bd66fde tools: add a script to generate draft release changelog
This utility script helps in generated formatted and consistent
change log including:
       1- group logs per daemon
       2- standarize daemon names (lowercase, end with d)
       3- capitalize all log lines
       4- no merge commits

caveat: comments are assumed to be in the form

   daemon-name : message

Sample Output:

```
sharpd
    Follow the practice on cli design for json output
    Install route supports nexthop-seg6 (step3)
    Install_routes_helper support zapi_route flags (step1)

snapcraft
    Add missing dependency
    Add pathd to frr snap daemons
    Change base to ubuntu 18.04 and libyang 2.0.7

staticd
    Convert typedef to enum
    Fix distance processing
    Fix late initialization of blackhole type
    Output config using nb callbacks instead of operational data
```

Signed-off-by: Jafar Al-Gharaibeh <jafar@atcorp.com>
2021-12-06 13:44:57 -06:00
Chirag Shah
2134a5fe51 frr-reload: fix bgp nbr remote-as
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-12-05 21:28:11 -08:00
Igor Ryzhov
cb3fa0a612
Merge pull request #10124 from ton31337/feature/vty_json 2021-11-29 02:11:29 +03:00
Donatas Abraitis
f615ecb96d tools: Convert vty_out to vty_json for JSON
Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
2021-11-25 17:49:25 +02:00
Donatas Abraitis
15116b0069 tools: Replace prefix2str for JSON to %pFX
Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
2021-11-25 17:26:26 +02:00
Donatas Abraitis
8b3c84254d tools: Add coccinelle script to replace inet_ntop inside JSON
Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
2021-11-18 11:32:46 +02:00
Donald Sharp
8e653596c4 tools, vtysh: Remove final vestige of address-family evpn
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-17 07:49:56 -05:00
Donald Sharp
23ee09601b tools: Add another valgrind suppression for libyang
More memory leaks from libyang that we can just ignore

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2021-11-15 15:06:58 -05:00
Quentin Young
6e09a5bfea tools: simplify excessively complex conditional
Signed-off-by: Quentin Young <qlyoung@nvidia.com>
2021-11-12 13:37:09 -05:00
Quentin Young
d2863e4a6b tools: string literals -> comments
Convert all floating string literals being used as comments, to comments

Signed-off-by: Quentin Young <qlyoung@nvidia.com>
2021-11-12 13:18:52 -05:00
David Lamparter
7c1803d0a0 tools: remove Linux kernel bits from checkpatch
These aren't appropriate for use in FRR.  Among other things, this
enables running checkpatch by calling it in a git working tree with
`tools/checkpatch.pl -g origin/master..`

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2021-10-19 14:58:51 +02:00
David Lamparter
4d619e25ab tools: add iterators to checkpatch
For the purpose of allowing the space in `frr_each (`, copy the list of
iterators from .clang-format and wire it up appropriately.

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2021-10-19 14:58:51 +02:00
Anuradha Karuppiah
32dcd36d29 tools: upstream linter is recommending double quotes
Replaced single quotes with double quotes for strings in
the frr_babeltrace.py utility.

Signed-off-by: Anuradha Karuppiah <anuradhak@nvidia.com>
2021-10-15 10:37:45 -07:00
Anuradha Karuppiah
b9c3be8be2 tools: add frr_babeltrace.py to /usr/lib/frr
Make the script available as a part of the FRR package install for
ease of use.

Signed-off-by: Anuradha Karuppiah <anuradhak@nvidia.com>
2021-10-15 10:37:02 -07:00
Anuradha Karuppiah
a383bfc7c9 bgpd: lttng tracepoint for local events received from zebra
TPs -
=====
root@ibm-2410a1-01:mgmt:~# lttng list --userspace |grep frr_bgp:evpn.*recv
      frr_bgp:evpn_local_l3vni_del_zrecv (loglevel: TRACE_INFO (6)) (type: tracepoint)
      frr_bgp:evpn_local_l3vni_add_zrecv (loglevel: TRACE_INFO (6)) (type: tracepoint)
      frr_bgp:evpn_local_macip_del_zrecv (loglevel: TRACE_INFO (6)) (type: tracepoint)
      frr_bgp:evpn_local_macip_add_zrecv (loglevel: TRACE_INFO (6)) (type: tracepoint)
      frr_bgp:evpn_local_vni_del_zrecv (loglevel: TRACE_INFO (6)) (type: tracepoint)
      frr_bgp:evpn_local_vni_add_zrecv (loglevel: TRACE_INFO (6)) (type: tracepoint)
      frr_bgp:evpn_mh_local_es_evi_del_zrecv (loglevel: TRACE_INFO (6)) (type: tracepoint)
      frr_bgp:evpn_mh_local_es_evi_add_zrecv (loglevel: TRACE_INFO (6)) (type: tracepoint)
      frr_bgp:evpn_mh_local_es_del_zrecv (loglevel: TRACE_INFO (6)) (type: tracepoint)
      frr_bgp:evpn_mh_local_es_add_zrecv (loglevel: TRACE_INFO (6)) (type: tracepoint)
root@ibm-2410a1-01:mgmt:~#

Sample output -
===============
1. ES
frr_bgp:evpn_mh_local_es_add_zrecv {'esi': '03:44:38:39:ff:ff:01:00:00:01', 'vtep': '27.0.0.15', 'active': 0, 'bypass': 0, 'df_pref': 50000}
frr_bgp:evpn_mh_local_es_del_zrecv {'esi': '03:44:38:39:ff:ff:01:00:00:01'}

2. ES-EVI
frr_bgp:evpn_mh_local_es_evi_add_zrecv {'esi': '03:44:38:39:ff:ff:01:00:00:01', 'vni': 1004}
frr_bgp:evpn_mh_local_es_evi_del_zrecv {'esi': '03:44:38:39:ff:ff:01:00:00:01', 'vni': 1001}

3. L2-VNI
frr_bgp:evpn_local_vni_add_zrecv {'vni': 1004, 'vtep': '27.0.0.15', 'mc_grp': '239.1.1.104', 'vrf': 97}

4. L3-VNI
frr_bgp:evpn_local_l3vni_add_zrecv {'vni': 4001, 'vrf': 87, 'svi_rmac': '24:8a:07:cc:aa:5f', 'vrr_rmac': '24:8a:07:cc:aa:5f', 'vtep': '27.0.0.15', 'filter': 0, 'svi_ifindex': 95, 'anycast_mac': 'n'
frr_bgp:evpn_local_l3vni_del_zrecv {'vni': 4003, 'vrf': 107}

5. MAC-IP
frr_bgp:evpn_local_macip_add_zrecv {'vni': 1003, 'mac': '00:02:00:00:00:04', 'ip': 'fe80::202:ff:fe00:4', 'flags': 4, 'seq': 0, 'esi': '03:44:38:39:ff:ff:01:00:00:02'}
frr_bgp:evpn_local_macip_del_zrecv {'vni': 1000, 'mac': '00:02:00:00:00:04', 'ip': '2001:fee1::4', 'state': 1}

Signed-off-by: Anuradha Karuppiah <anuradhak@nvidia.com>
2021-10-15 10:37:02 -07:00
anlan_cs
1bdffcf01c tools: fix wrong get_contexts() of Config class.
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-10-09 04:15:55 -04:00