Commit graph

768 commits

Author SHA1 Message Date
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
Donatas Abraitis c08050d6d1 tools: Catch double pointer of struct thread towards thread_add_*
```
% spatch --sp-file tools/coccinelle/struct_thread_double_pointer.cocci --macro-file tools/cocci.h ./ 2>/dev/null
./lib/northbound_confd.c:429:65-66: Passed double 'struct thread' pointer
./lib/northbound_confd.c:1174:61-62: Passed double 'struct thread' pointer
./lib/northbound_sysrepo.c:543:69-70: Passed double 'struct thread' pointer
```

Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
2021-10-07 16:25:03 +03:00
Russ White 334d9d259f
Merge pull request #9731 from ton31337/fix/thread_null_set
cleanup: struct thread = NULL
2021-10-05 19:27:23 -04:00
Donatas Abraitis 83e66fdfd6 tools: Add coccinelle script to catch thread to NULL assignments
Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
2021-10-04 19:29:06 +03:00
Anuradha Karuppiah 23aa35ade5 bgpd: initial batch of evpn lttng tracepoints
Low overhead bgp-evpn TPs have been added which push data out in a binary
format -
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
root@switch:~# lttng list --userspace |grep "frr_bgp:evpn"
      frr_bgp:evpn_mh_nh_rmac_zsend (loglevel: TRACE_DEBUG_LINE (13)) (type: tracepoint)
      frr_bgp:evpn_mh_nh_zsend (loglevel: TRACE_INFO (6)) (type: tracepoint)
      frr_bgp:evpn_mh_nhg_zsend (loglevel: TRACE_INFO (6)) (type: tracepoint)
      frr_bgp:evpn_mh_vtep_zsend (loglevel: TRACE_INFO (6)) (type: tracepoint)
      frr_bgp:evpn_bum_vtep_zsend (loglevel: TRACE_INFO (6)) (type: tracepoint)
      frr_bgp:evpn_mac_ip_zsend (loglevel: TRACE_INFO (6)) (type: tracepoint)
root@switch:~#
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

In addition to the tracepoints a babeltrace python plugin for pretty
printing (binary data is converted into grepable strings). Sample usage -
frr_babeltrace.py trace_path

Sample tracepoint output -
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
1. frr_bgp: evpn_mac_ip_zsend
frr_bgp:evpn_mac_ip_zsend {'action': 'add', 'vni': 1007, 'mac': '00:02:00:00:00:04', 'ip': 'fe80::202:ff:fe00:4', 'vtep': '27.0.0.15', 'esi': '03:44:38:39:ff:ff:01:00:00:02'}

2. frr_bgp: evpn_mh_vtep_zsend
frr_bgp:evpn_mh_vtep_zsend {'action': 'add', 'esi': '03:44:38:39:ff:ff:01:00:00:02', 'vtep': '27.0.0.16'}

3. frr_bgp: evpn_mh_nhg_zsend
frr_bgp:evpn_mh_nhg_zsend {'action': 'add', 'type': 'v4', 'nhg': 74999998, 'esi': '03:44:38:39:ff:ff:01:00:00:02', 'vrf': 85}

4. frr_bgp: evpn_mh_nh_zsend
frr_bgp:evpn_mh_nh_zsend {'nhg': 74999998, 'vtep': '27.0.0.16', 'svi': 93}

5. frr_bgp: evpn_mh_nh_rmac_zsend
frr_bgp:evpn_mh_nh_rmac_zsend {'action': 'add', 'vrf': 85, 'nh': '::ffff:1b00:12', 'rmac': '00:02:00:00:00:50'}
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

Signed-off-by: Anuradha Karuppiah <anuradhak@nvidia.com>
2021-10-01 09:02:25 -07:00
Donatas Abraitis 94ca37e0a9 tools: Add coccinelle script to catch \n or \r at the end of zlog_*
Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
2021-09-27 15:21:52 +03:00
Donald Sharp cd8aaf076e tools: Add some new suppressions
Bunch of new stuff came in w/ the libyang2 upgrade that needs
to be suppressed.  Make it so.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2021-09-21 07:54:54 -04:00
Quentin Young 32acb4a7ad
Merge pull request #9497 from opensourcerouting/cli-better-no 2021-09-09 12:22:53 -04:00
Christian Hopps a53c08bc13 tests: cleanup: rerun changed files through black
Signed-off-by: Christian Hopps <chopps@labn.net>
2021-09-04 09:04:47 -04:00
Christian Hopps 4953ca977f tests: cleanup - remove unused imports
Signed-off-by: Christian Hopps <chopps@labn.net>
2021-09-04 09:04:47 -04:00
Christian Hopps 77a7a87cdd tools: move frr-reload.py to python3 explicitly
We already, reasonably, require python3 elsewhere. Do so here, and reap some
benefit.

Signed-off-by: Christian Hopps <chopps@labn.net>
2021-09-04 09:04:47 -04:00
David Lamparter b8f9523597
Merge pull request #9340 from stefreak/patch-1
tools: fix frr pathspace folder permissions
2021-09-02 13:24:44 +02:00
David Lamparter 90c8406c20 lib: add ![...] syntax for easy "no" forms
This allows defining a CLI command like this:
  `[no] some setting ![VALUE]`
with VALUE being optional for the "no" form, but required for the
positive form.  It's just a `[...]` where the empty branch can only be
taken for commands starting with `no`.

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2021-08-26 21:03:44 +02:00
Igor Ryzhov fc43980f25 tools: significantly simplify frr-reload context processing
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-23 22:08:20 +03:00
Igor Ryzhov 541af473f9
Merge pull request #9341 from LabNConsulting/chopps/ospf-support-bundle
tools: add ospfd support bundle commands
2021-08-18 14:40:08 +03:00
Donald Sharp 061bf350dd
Merge pull request #9271 from opensourcerouting/workflow-release-sched
workflow: document release scheduling discussed
2021-08-14 09:06:23 -04:00
David Lamparter dc1c0bc2b3 workflow: document release scheduling discussed
As discussed in the weekly meeting today, this is what we're trying to
work with for the time being.

(Date calculator included as a bonus goodie ;)

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2021-08-11 16:37:46 +02:00
Christian Hopps 36cd3e81e8 tools: add ospfd support bundle commands
Signed-off-by: Christian Hopps <chopps@labn.net>
2021-08-10 07:39:18 +00:00
Christian Hopps cb04c8e906
Merge pull request #9219 from mobash-rasool/ospfv2-bug-fixes
tools: Add ospfv2 and ospfv3 commands in support bundle
2021-08-10 03:14:43 -04:00
Steffen Neubauer 0fc6a5f8ed tools: fix frr pathspace folder permissions
The pathspace folder in /var/run needs the x permission for the group too

Otherwise vtysh fails when running it with groups frrvty and frr:

    $ vtysh -N gateway
    % Can't open configuration file /etc/frr/gateway/vtysh.conf due to 'Permission denied'.
    vtysh_connect(/var/run/frr/gateway/zebra.vty): stat = Permission denied

Signed-off-by: Steffen Neubauer <s.neubauer@syseleven.de>
2021-08-09 13:54:58 +02:00
Donald Sharp a66413a53b
Merge pull request #8870 from anlancs/master-fix-reload-service
tools: add "vni" to oneline list
2021-08-08 07:21:10 -04:00
Mobashshera Rasool 54d8e033f3 tools: Add ospfv3 commands in the support bundle
Co-authored-by: Yash Ranjan <ranjyany@vmware.com>
Signed-off-by: Yash Ranjan <ranjyany@vmware.com>
Co-authored-by: Mobashshera Rasool <mrasool@vmware.com>
Signed-off-by: Mobashshera Rasool <mrasool@vmware.com>
2021-07-30 05:14:26 -07:00
Mobashshera Rasool 34e96abf2e tools: Add ospfd commands in support bundle
Signed-off-by: Mobashshera Rasool <mrasool@vmware.com>
2021-07-30 03:52:45 -07:00
Christian Hopps be4a9b0570 tools: improve frr-reload.py delta file creation
- 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-07-15 22:12:01 -04:00
Donatas Abraitis 107df351c6 tools: Add coccinelle script for hash compare functions NULL values
Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
2021-07-13 08:49:38 +03:00
Donald Sharp acb4c44ef8
Merge pull request #8942 from ton31337/fix/cleanups_2
Another round of cleanup
2021-07-06 09:47:41 -04:00
Donald Sharp 432bb280fb
Merge pull request #8939 from LabNConsulting/chopps/sup-bund-fixes
Speedup support bundles, fix bugs, add CLI timestamp
2021-07-06 07:58:19 -04:00
Igor Ryzhov c54e2a8144 tools: Simplify the script to build Debian binary package
Signed-off-by: Ondřej Surý <ondrej@sury.org>
2021-07-03 17:02:37 +02:00
Ondřej Surý dfbc6c046e debian: Add support for Debian bullseye to the packaging script
The Debian bullseye is frozen now, so this adds support to this
Debian release to the packaging script.

Signed-off-by: Ondřej Surý <ondrej@sury.org>
2021-07-03 17:02:37 +02:00
Ondřej Surý 9ea548cf3c debian: Fix the debian packaging script to build on non-default branch
The packaging script would fail to run on non-master branch, fix that
by pulling original branch name.

Signed-off-by: Ondřej Surý <ondrej@sury.org>
2021-07-03 17:02:37 +02:00
Ondřej Surý 223766ead4 debian: Update the tools/build-debian-package.sh to be example build script
Signed-off-by: Ondřej Surý <ondrej@sury.org>
2021-07-03 17:02:37 +02:00
Ondřej Surý aa1e17f5ca debian: Remove now obsolete tarsource.sh script
Signed-off-by: Ondřej Surý <ondrej@sury.org>
2021-07-03 17:02:37 +02:00
Ondřej Surý 06417e9f18 debian: Remove the changelog-auto automation in favor of dch
Signed-off-by: Ondřej Surý <ondrej@sury.org>
2021-07-03 17:02:37 +02:00
Ondřej Surý bcd053ee8d debian: Update tools/build-debian-package.sh to use git-buildpackage
Signed-off-by: Ondřej Surý <ondrej@sury.org>
2021-07-03 17:02:37 +02:00
Ondřej Surý 25785834af debian: Adjust tarsource.sh to use native debian/changelog
Signed-off-by: Ondřej Surý <ondrej@sury.org>
2021-07-03 17:02:37 +02:00
Christian Hopps 5417cc2de3 tests: collect support bundle data in parallel, fix bugs
Speedup (large topo): OLD: ~6 minutes NEW: ~1 second.
  (when paired with common_config.py changes)
- Collect each "proc" support in parallel
- For each "proc" only call vtysh once with all commands

Bug fixes:
- output was broken, a dump of python "repr" format of str.

Signed-off-by: Christian Hopps <chopps@labn.net>
2021-06-30 15:46:10 +00:00
anlancs 470d316e3e tools: add "vni" to oneline list
Add "vni" into oneline list.
Additionally, keep them in order in oneline list.

Signed-off-by: anlancs <anlan_cs@tom.com>
2021-06-30 16:28:37 +08:00
Donatas Abraitis 63f7a3b910 tools: Add coccinelle script for checking against XMALLOC/XCALLOC NULLs
Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
2021-06-29 22:27:50 +03:00
Donald Sharp 6293c2181a tools: limit bgp route-maps to direct changes only
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-23 10:19:00 -04:00
Patrick Ruddy fa855f8fa3
Merge pull request #6695 from adharkar/frr-master-gateway_ip
EVPN route type-5 gateway IP overlay Index
2021-06-23 09:23:54 +01:00
Mark Stapp a78dde0dcd
Merge pull request #8867 from wesleycoakley/pbr-table-range-single-line
tools: make frr-reload recognize `pbr table range` lines as single-line contexts
2021-06-22 09:12:02 -04:00
Don Slice 1443e23148 tools: add mac access-list context to frr-reload.py
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-18 08:09:02 -07:00
Wesley Coakley cbfb52986f
tools: reload recognizes pbr table range as single-line ctx
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-06-16 20:34:30 -04:00
Ameya Dharkar fb651da9e2 tools: Add EVPN show commands to support bundle
Signed-off-by: Ameya Dharkar <adharkar@vmware.com>
2021-06-07 17:59:45 -07:00
Quentin Young c99313762a
Merge pull request #8353 from opensourcerouting/llvm-20210327 2021-06-01 19:08:32 +00:00
Rafael Zalamena 6c1a2a6538
Merge pull request #6317 from rgirada/fix_route_dump
zebrad: Added a command to dump routes in support bundle
2021-05-28 18:12:17 -03:00
Chirag Shah 934c84a02b tools: fix peer-group deletion in frr-reload
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-24 16:06:24 -07:00
Christian Hopps 3bb513c399 lib: adapt to version 2 of libyang
Compile with v2.0.0 tag of `libyang2` branch of:
https://github.com/CESNET/libyang

staticd init load time of 10k routes now 6s vs ly1 time of 150s

Signed-off-by: Christian Hopps <chopps@labn.net>
2021-05-13 16:24:48 -04:00
David Lamparter 0f12ac7f12
Merge pull request #8472 from donaldsharp/more_valgrind_stuff
tools: Add some more data to ignore for valgrind
2021-05-09 19:20:47 +02:00
Igor Ryzhov d0bb3c542c
Merge pull request #8632 from wesleycoakley/le-32-128-fix
lib: ip prefix-list "le" and "ge" bug squish
2021-05-07 12:05:59 +03:00
Wesley Coakley d7e594edd2
tools: stop frr-reload squashing le 32 / le 128
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-05-06 12:31:37 -04:00
rgirada d29fd1b72e zebrad: Added a command to dump routes in support bundle
Description:
Added a new show command("show ip zebra route dump") to dump all routes
with detailed information including nexthops,flags, status ..etc.
This helps for dubugging and added to support_bundle_command.conf.
Defined this command as a hidden command.

Signed-off-by: Rajesh Girada <rgirada@vmware.com>
2021-05-06 02:40:12 -07:00
Donald Sharp 56b99116f2 tools: Add some more data to ignore for valgrind
When running valgrind there are some possible memory leaks.
These memory leaks we have absolutely no control over, mark
them as not worthy of being reported.

Finally move the valgrind suppressions file from bgpd/ to tools/
this is because this suppressions file can be used beyond bgpd

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2021-05-05 10:52:51 -04:00
David Lamparter 64dd77361f lib: rework how we "override" assert()
The previous method, using zassert.h and hoping nothing includes
assert.h (which, on glibc at least, just does "#undef assert" and puts
its own definition in...) was fragile - and actually broke undetected.

Just provide our own assert.h and control overriding by putting it in a
separate directory to add to the include path (or not.)

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2021-05-02 16:27:17 +02:00
Donald Sharp 61dc17d8cb tools: Cleanup frr-reload.py by running black on it
Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2021-04-21 08:59:22 -04:00
Donald Sharp 0ed6a49d90 tools: Fix warning when running frr-reload.py
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-21 08:57:29 -04:00
Quentin Young 6c8bdfd569 tools: add note to users re: frr.conf overwrite
Most software doesn't overwrite its own config files; vtysh's 'wr mem'
may be confusing, so add a note to the config file explaining changes
made may be overwritten.

Signed-off-by: Quentin Young <qlyoung@nvidia.com>
2021-04-09 13:14:30 -04:00
David Lamparter b0b14dfdd1 tools: dump YANG info in frr-llvm-cg
Since all of these function pointers are entry points for YANG actions,
they're useful to have in the call graph.

Signed-off-by: David Lamparter <equinox@diac24.net>
2021-04-07 22:31:54 +02:00
David Lamparter d71449a3f7 tools: grok struct member calls in frr-llvm-cg
Calling a function pointer embedded in a struct is quite common & having
this listed in the call graph is useful.

Signed-off-by: David Lamparter <equinox@diac24.net>
2021-04-07 22:31:25 +02:00
Quentin Young 2a9d6bce5a
Merge pull request #8384 from volta-networks/fix_no_srb_block
tools: do in-place SRGB/SRLB changes
2021-04-06 03:44:25 +00:00
Quentin Young 63f1943136
Merge pull request #8364 from stipmonster/master
Added pathd to the init files
2021-04-04 00:33:19 +00:00
Emanuele Di Pascale 5ad4633333 tools: do in-place SRGB/SRLB changes
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-04-01 10:35:57 +02:00
Don Slice 00302a580c tools: frr-reload fixes for deleting vrf static routes
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-31 09:38:59 -07:00
Don Slice 880dcb06e4 tools: frr-reload.py changes to make black happy
Since black is finding issues before applying my change, committing
those changes separately

Signed-off-by: Don Slice <dslice@nvidia.com>
2021-03-31 09:38:59 -07:00
Erik Kooistra f8ca116ef0 tools: Added pathd to the relevant init files
Currently pathd is missing from the deamon list in frrcommon
with this missing frrinit can't start pathd if it is added to
the deamon file. This commit adds it to the frrcommon deamon list
and updates the example deamon file.

Signed-off-by: Erik Kooistra <me@erikkooistra.nl>
2021-03-29 15:42:35 +02:00
David Lamparter 49fc8264e9 tools: adapt frr-llvm-cg to xref changes
These caused some function names to change, which frr-llvm-cg looks at
in order to improve callgraph accuracy.

Signed-off-by: David Lamparter <equinox@diac24.net>
2021-03-27 20:59:45 +01:00
David Lamparter fa03d806ef build: ignore frr-llvm-cg binary
Signed-off-by: David Lamparter <equinox@diac24.net>
2021-03-27 20:59:39 +01:00
David Lamparter bcf9d7d8aa tools/gcc-plugin: support [un]signed in pragma
Need `unsigned char *` for `%pHX`.

Signed-off-by: David Lamparter <equinox@diac24.net>
2021-03-26 17:51:55 +01:00
David Lamparter 23922bbc08 tools/gcc-plugin: fix format precision/width type
`%*.*pEXT` applied the extension type to the precision and width (*.*)
too.  Oops.

Signed-off-by: David Lamparter <equinox@diac24.net>
2021-03-26 17:51:55 +01:00
Donald Sharp 1a6aa9d098
Merge pull request #8341 from simondeziel/systemd-onfailure
systemd's %n already includes the type suffix (.service)
2021-03-25 15:00:13 -04:00
Donald Sharp 95a2b8f9eb
Merge pull request #8252 from SaiGomathiN/8249
pimd: support bundle commands added
2021-03-25 11:52:12 -04:00
Simon Deziel 489faf5e4a tools: fix systemd OnFailure directive
systemd's %n already includes the type suffix (.service)

Signed-off-by: Simon Deziel <simon@sdeziel.info>
2021-03-25 10:37:23 -04:00
David Lamparter 5493cdf55e tools: run vtysh -b once for all-startup
As noted by Donald:

When FRR is starting all daemons (or restarting them all) FRR is reading
in the configuration 1 time for each daemon specified to run. This is
not a big deal if you have a very small configuration. But with large
configurations FRR is taking long enough that watchfrr is not
establishing connection to all the daemons and starting some over.

Modify the code so that vtysh is only read in at the end of a all
sequence. If we are restarting an individual daemon allow the read in of
the whole config.

Reported-by: Donald Sharp <sharpd@nvidia.com>
Signed-off-by: David Lamparter <equinox@diac24.net>
2021-03-22 20:21:19 +01:00
nsaigomathi 79c889228f tools: Add pimd support bundle commands
PIM Support Bundle commands are added in support_bundle_commands.conf file.
It will help us in debugging PIM test Failures.

Signed-off-by: Sai Gomathi <nsaigomathi@vmware.com>
2021-03-17 06:48:29 -07:00
Donald Sharp 30643d6f31
Merge pull request #8155 from idryzhov/zebra-support-bundle
zebra support bundle fixes and improvements
2021-03-16 13:00:37 -04:00
Donatas Abraitis 293b8b9529
Merge pull request #8214 from chiragshah6/mdev
tools: frr-reload refine error handling
2021-03-16 09:28:03 +02:00
Jafar Al-Gharaibeh fe67f1f929 tools: add explicit licence phrase
Signed-off-by: Jafar Al-Gharaibeh <jafar@atcorp.com>
2021-03-10 11:31:25 -06:00
Joe Maimon f725df0fae tools: example bash script client for the nhrpd event sock
Signed-off-by: Joe Maimon <jmaimon@jmaimon.com>
2021-03-10 11:31:25 -06:00
Chirag Shah 641b032e23 tools: frr-reload capture vtysh msg upon failure
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-08 12:02:08 -08:00
Chirag Shah f26070fc07 tools: Mark reload failure when no form cli fails
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-03-08 11:58:29 -08:00
Igor Ryzhov 6695f13b39 tools: add "show ip/ipv6 route" to zebra support bundle commands
Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2021-02-26 14:26:45 +03:00
Igor Ryzhov a02c4b0ecc tools: fix zebra support bundle commands
CI constantly fails to execute "show zebra fpm stats":
```
Execute: show zebra fpm stats
Traceback (most recent call last):
  File "/usr/lib/frr/generate_support_bundle.py", line 55, in executeCommand
    cmd_output = subprocess.check_output(cmd_exec_str, shell=True)
  File "/usr/lib/python3.6/subprocess.py", line 356, in check_output
    **kwargs).stdout
  File "/usr/lib/python3.6/subprocess.py", line 438, in run
    output=stdout, stderr=stderr)
subprocess.CalledProcessError: Command 'vtysh -c "show zebra fpm stats" ' returned non-zero exit status 1.
```

Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2021-02-26 14:26:17 +03:00
Donatas Abraitis 82451d0cc7
Merge pull request #7942 from donaldsharp/rpki_reload_fix
frr-reload: rpki context exiting uses exit and not end
2021-02-18 09:34:27 +02:00
Mark Stapp 70b99f2fff tests: make generate support bundle python3 only
Make the generate-support-bundle script and interactions more
python3-friendly, and use python3 explicitly.

Signed-off-by: Mark Stapp <mjs@voltanet.io>
2021-02-15 08:13:06 -05:00
Runar Borge 7cfb307943 frr-reload: rpki context exiting uses exit and not end
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-02-04 17:26:12 -05:00
David Lamparter acbf5146a9 tools/checkpatch: downgrade string concat warning
This is the best I can make the asm blocks in lib/xref.h look, so just
mute the warning.  (It shouldn't come in relevant for other code.)

Signed-off-by: David Lamparter <equinox@diac24.net>
2021-02-01 17:33:03 +01:00
Donald Sharp 6df6d7bdf1
Merge pull request #7368 from eololab/add-pidfile-in-frr.service
tools: add PIDFile option in frr.service
2021-01-26 13:29:26 -05:00
Rafael Zalamena c42dfbb505 tools: fix frr-reload BFD profile support
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-20 11:42:59 -03:00
Don Slice 7ac6afbd36 tools: ignore missing seq nums in prefix and access lists in frr-reload.py
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-13 05:04:07 -08:00
Don Slice d82c5d61e6 tools: apply black formatting changes to frr-reload.py
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-13 05:04:07 -08:00
Emanuele Di Pascale 0e11b1e2ba tools: fix pce-config removal
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-09 15:50:17 +01:00
Emanuele Di Pascale 2f1406fc86 pathd, tools: fix peer preference config
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-09 15:50:17 +01:00
Emanuele Di Pascale ee96c52a28 tools: add bfdd to frr-reload.py daemons list
Signed-off-by: Emanuele Di Pascale <emanuele@voltanet.io>
2021-01-09 15:50:17 +01:00
Donald Sharp 39bda68b1e tools: Cleanup some zebra section of the support bundle
a) Add some useful commands
b) Remove `show error all` this just dumps the error codes.  If
we know the version we don't need this.  Additionally this is
rather large.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2021-01-08 20:54:43 -05:00
Donald Sharp 5e67b0f345 tools: Cleanup bgp commands in the support bundle
Add some missing commands ( I am sure that there are more useful ones to )
Cleanup to use the modern non-deprecated syntax in case anyone runs across
this.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2021-01-08 20:54:43 -05:00
Mark Stapp 700ff41ed3
Merge pull request #7472 from opensourcerouting/fpm-fixes
fpm: frr-reload, IPv6 and an improvement
2020-12-22 11:37:58 -05:00
Sebastien Merle efba0985fc pathd: Add optional support for PCEP to pathd
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-18 16:47:52 +01:00
Sebastien Merle 4d7b695d3a pathd: New SR-TE policy management daemon
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-18 16:34:02 +01:00
Russ White bd32345be3
Merge pull request #7582 from AnuradhaKaruppiah/frr-reload-cleanup
frr reload fixes for mac and ip normalization
2020-12-07 16:19:04 -05:00
Rafael Zalamena 2a437850fd tools: make frr-reload handle fpm commands
Instruct `frr-reload.py` to not use `fpm` commands as configuration
node.

Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
2020-12-03 07:30:23 -03:00
Javier Garcia d3a3e6253b tools: Fix run folder permissions
In the case of some linux distros the /var/run dir is mounted
with tmpfs so in every reboot it's removed.
Then the frrcommon.sh will recreate it without 'x' perm
So no pid file cannot be created in /var/run/frr

Signed-off-by: Javier Garcia <rampxxxx@gmail.com>
2020-12-01 12:37:51 +01:00
Anuradha Karuppiah 8a63e80c6c frr-reload: ignore-case in the es-id and es-sys-mac config comparisons
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-21 18:03:06 -08:00
Anuradha Karuppiah ed37777f03 frr-reload: fixup ipv6 address normalization
The condition to normalize ipv6 addresses was accidentally broken via -
[
e238920df0 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-21 18:02:58 -08:00
Quentin Young 439be082d3 Revert "debian: Adjust tarsource.sh to use native debian/changelog"
This reverts commit 4ffb9a4c9d.
2020-11-19 17:12:41 -05:00
Quentin Young 1b8a899da3 Revert "debian: Update tools/build-debian-package.sh to use git-buildpackage"
This reverts commit 63c0c8ed89.
2020-11-19 17:12:40 -05:00
Quentin Young fb0b3592ca Revert "debian: Remove the changelog-auto automation in favor of dch"
This reverts commit cace1d9bf1.
2020-11-19 17:12:40 -05:00
Quentin Young 2013e82a89 Revert "debian: Remove now obsolete tarsource.sh script"
This reverts commit bc304e08ea.
2020-11-19 17:12:38 -05:00
Quentin Young 5aa63f6aa6 Revert "debian: Update the tools/build-debian-package.sh to be example build script"
This reverts commit c950a7f214.
2020-11-19 17:12:27 -05:00
Ondřej Surý c950a7f214 debian: Update the tools/build-debian-package.sh to be example build script
Signed-off-by: Ondřej Surý <ondrej@sury.org>
2020-11-19 21:30:11 +01:00
Ondřej Surý bc304e08ea debian: Remove now obsolete tarsource.sh script 2020-11-19 21:30:08 +01:00
Ondřej Surý cace1d9bf1 debian: Remove the changelog-auto automation in favor of dch
Signed-off-by: Ondřej Surý <ondrej@sury.org>
2020-11-19 21:30:06 +01:00
Ondřej Surý 63c0c8ed89 debian: Update tools/build-debian-package.sh to use git-buildpackage
Signed-off-by: Ondřej Surý <ondrej@sury.org>
2020-11-19 21:30:02 +01:00
Ondřej Surý 4ffb9a4c9d debian: Adjust tarsource.sh to use native debian/changelog
Signed-off-by: Ondřej Surý <ondrej@sury.org>
2020-11-19 21:29:59 +01:00
Emanuele Di Pascale 8239db83b0 tools: fix frr-reload l2vpn delete
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-11-18 11:44:39 +01:00
David Lamparter cd67bcf99a tools/gcc-frr-format: fix ICE in gcc-10
gcc-10 has a more strict internal assert for type checks so the plugin
currently causes an Internal Compiler Error.  Fix.

Signed-off-by: David Lamparter <equinox@diac24.net>
2020-11-03 00:53:29 +01:00
Emanuele Bovisio 566397ba65 tools: add PIDFile option in frr.service
when type is forking, it is recommended to also use the PIDFile= option,
so that systemd can reliably identify the main process of the service.

Signed-off-by: Emanuele Bovisio <emanuele.bovisio@eolo.it>
2020-10-30 16:33:20 +01:00
Donald Sharp 65a58145a1
Merge pull request #7370 from eololab/add-missing-daemon-in-watchfrr-conf-file
tools: add staticd line in daemon config file
2020-10-27 11:29:26 -04:00
Emanuele Bovisio 78d0a253ea tools: add comment on staticd in daemon config file
staticd is always started, so no need to specify it explicitly

Signed-off-by: Emanuele Bovisio <emanuele.bovisio@eolo.it>
2020-10-26 17:50:31 +01:00
Renato Westphal 8d869d378b lib: combine two YANG schema iteration functions into one
Combine yang_snodes_iterate_module() and yang_snodes_iterate_all()
into an unified yang_snodes_iterate() function, where the first
"module" parameter is optional. There's no point in having two
separate YANG schema iteration functions anymore now that they are
too similar.

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2020-10-23 18:18:22 -03:00
Mark Stapp 70c583eb81 tools: add cocci patch for thread cancel api changes
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-23 12:16:52 -04:00
Emanuele Bovisio 371fe435ca tools: use function chownfrr
chownfrr applies correct owner and group

Signed-off-by: Emanuele Bovisio <emanuele.bovisio@eolo.it>
2020-10-13 09:46:42 +02:00
whitespace 701a01920e *: reformat python files
We are now using black.

Signed-off-by: Quentin Young <qlyoung@nvidia.com>
2020-10-07 17:22:26 -04:00
Quentin Young fdaee098f3 tools: fix vtysh failure error handling
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-09-17 15:53:42 -04:00
Alexander Chernavin deb95b373f lib, tools: fix reloading of key sub-context in key chains
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-24 09:54:55 -04:00
Rafael Zalamena e99d81a374
Merge pull request #6738 from deastoe/frr-reload-log-level
tools: frr-reload: more detailed log level control
2020-08-20 13:42:34 +00:00
Sri Mohana Singamsetty e11baa4c72
Merge pull request #6909 from donaldsharp/weird_dump_commands
tools: Remove zebra commands that have never existed
2020-08-12 20:42:34 -07:00
Donald Sharp 9057bd834a tools: Remove zebra commands that have never existed
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-12 20:59:47 -04:00
Chirag Shah 1c7f624509 tools: nb generate callback script to use attr
northbound genrate callback script to use attr->event
in case passed in generated callbacks..

Signed-off-by: Chirag Shah <chirag@cumulusnetworks.com>
2020-08-11 17:08:26 -07:00
Quentin Young 25ee44b522
Merge pull request #6732 from opensourcerouting/printfrr-prep
*: preparations for printfrr coccinelle run
2020-07-29 14:29:34 -04:00
Tore Anderson e220f954de
tools: do not silently ignore errors when loading config during startup
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 858aa29c68 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-23 10:29:27 +02:00
Quentin Young 9d9adc84c7
Merge pull request #6343 from opensourcerouting/watchfrr-n-20200505
watchfrr: add `-N` and `--netns` options
2020-07-22 12:07:14 -04:00
David Lamparter e2986b1b27 tools: add frr@.service
... for starting an FRR instance.

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2020-07-22 12:56:04 +02:00
David Lamparter a0a7dead0b tools/frr-reload.py: support -N pathspace
Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2020-07-22 12:56:04 +02:00
David Lamparter 33606a1547 watchfrr: add (network) namespace support
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-22 12:56:04 +02:00
Don Slice eb9113dfe3 tools: fix more frr-reload vrf static errors
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-17 16:45:54 +00:00
David Lamparter 1a798bcb6b tools/gcc-frr-format: update README
Signed-off-by: David Lamparter <equinox@diac24.net>
2020-07-17 05:56:40 +02:00
David Lamparter 20a236abe3 tools/gcc-frr-format: update debian bits
Signed-off-by: David Lamparter <equinox@diac24.net>
2020-07-17 05:54:54 +02:00
David Lamparter 555cc1001d tools/gcc-frr-format: improve test
Signed-off-by: David Lamparter <equinox@diac24.net>
2020-07-17 05:54:54 +02:00
David Lamparter 05675eb32f tools/gcc-frr-format: update for gcc 10
Signed-off-by: David Lamparter <equinox@diac24.net>
2020-07-17 05:54:54 +02:00
Duncan Eastoe 6eee4767d0 tools: frr-reload: log exclusively through logger
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-15 12:44:20 +01:00
Duncan Eastoe 9c782ad2a4 tools: frr-reload: more detailed log level control
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-14 19:05:17 +01:00
David Lamparter 6894924238 tools: improve cocci.h
Add a few more macros so coccinelle can parse code correctly.

Signed-off-by: David Lamparter <equinox@diac24.net>
2020-07-14 11:27:41 +02:00
David Lamparter 3efd0893d0 *: un-split strings across lines
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-14 10:37:25 +02:00
David Lamparter 93195af63f tools: add source code string mangler
Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2020-07-14 10:37:24 +02:00
Paul Manley 1c23a0aaa1 tools: create sub-context for bfd peers
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-09 11:21:16 -05:00
Donatas Abraitis c54142bb84 tools: Catch argv_find() cases when testing only the index
Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
2020-07-02 11:39:29 +03:00
Donald Sharp e238920df0 tools: Fix reload with 'ipv6 address...' in interface
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-24 14:30:49 -04:00
Jafar Al-Gharaibeh 5f26363bda
Merge pull request #6614 from qlyoung/fix-evpnmh-reload
tools: 'evpn mh' is a new one-line context
2020-06-18 23:41:55 -05:00
Quentin Young a840a40df4 tools: 'evpn mh' is a new one-line context
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-18 17:00:51 -04:00
Emanuele Di Pascale 7e7fedcb40 tools: fix frr-reload.py daemon option
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-06-15 14:58:22 +02:00
David Lamparter fa18c6bbda tools/frr-reload: --vty_socket arg
After the cleanup, adding this doesn't require updating a zillion
locations in the code anymore, just one :)

Partially derived from 6a00e91d99

Originally-by: Emanuele Di Pascale <emanuele@voltanet.io>
Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2020-05-26 19:14:00 +02:00
David Lamparter 663ece2f6d tools/frr-reload: cleanup pass
- 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-26 19:09:32 +02:00
Donatas Abraitis 0591d71e92
Merge pull request #6406 from donaldsharp/ospf_multi_instance_start_fix
tools: Only load instances or daemon
2020-05-18 14:51:17 +03:00
Donald Sharp b82ad4c0d1 tools: Only load instances or daemon
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-14 14:11:03 -04:00
Donatas Abraitis 0ad81e648e
Merge pull request #6387 from donaldsharp/reload
tools: revert frr-reload.py remove stderr redirects"
2020-05-13 09:10:06 +03:00
Donald Sharp b2be8c9286 tools: revert frr-reload.py remove stderr redirects"
This reverts commit 3fa139a65b.

This is being reverted because this commit completely
breaks the invocation of frr-reload.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2020-05-12 13:31:09 -04:00
David Lamparter 5c90637711 build: use configfile mode in init script
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-11 21:50:27 +02:00
Donatas Abraitis 555fc63c75
Merge pull request #6348 from dslicenc/frr-reload-bfd
tools: fix frr traceback on bgp neighbor bfd deletion
2020-05-08 18:56:01 +03:00
Don Slice ca7f04961d tools: fix frr traceback on bgp neighbor bfd deletion
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-05 17:59:59 +00:00
David Lamparter 8fb40377de build: add LLVM bitcode targets
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-05 14:39:12 +02:00
David Lamparter 0045c13067 tools: frr-llvm-cg
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-05-05 14:39:12 +02:00
Emanuele Di Pascale e04ff92ed0 tools: fix frr-reload AF issue with ldpd
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-27 16:38:29 +02:00
David Lamparter ec8f987e91 tools/symalyzer: fix copypasta
Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2020-04-27 09:30:01 +02:00
David Lamparter 879a9dc5cd python: move MakeVars class into separate module
... so I can reuse it.

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2020-04-27 09:30:01 +02:00
Donald Sharp 967ebd2431
Merge pull request #6279 from opensourcerouting/nb-cb-args
*: change the signature of the northbound callbacks to be  more flexible
2020-04-24 08:09:16 -04:00
Renato Westphal 60ee8be107 *: change the signature of the northbound callbacks to be more flexible
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-23 10:14:32 -03:00
Quentin Young 4ced1a2cb3 bgpd, isis, tools: style fixen
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2020-04-20 19:15:35 -04:00
Quentin Young 2b7165e76f *: use appropriate buffer sizes, specifiers
- 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 19:14:33 -04:00
Quentin Young 772270f3b6 *: sprintf -> snprintf
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>
2020-04-20 19:14:33 -04:00
Quentin Young 3f0cc3ffb3 tools: add more macros to cocci.h
Coccinelle needs to know about complicated macros to understand certain
code paths, add some more macros there.

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2020-04-20 19:14:33 -04:00
Donatas Abraitis ff8b039ecf tools: Add coccinelle script to catch typecasts to same type
Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
2020-04-08 17:15:10 +03:00
Donatas Abraitis c4efd0f423 *: Do not cast to the same type
Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
2020-04-08 17:15:06 +03:00
Donatas Abraitis 71abb5c135 tools: Add coccinelle script to catch typecasts to larger sizes
That's valid only for uint*_t

Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
2020-04-07 18:03:57 +03:00
Renato Westphal b90204a8e9 lib, tools: silence harmless warnings in the northbound tools
Our two northbound tools don't have embedded YANG modules like the
other FRR binaries. As such, ly_ctx_set_module_imp_clb() shouldn't be
called when the YANG subsystem it being initialized by a northbound
tool. To make that possible, add a new "embedded_modules" parameter
to the yang_init() function to control whether libyang should look
for embedded modules or not.

With this fix, "gen_northbound_callbacks" and "gen_yang_deviations"
won't emit "YANG model X not embedded, trying external file"
warnings anymore.

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2020-04-03 22:34:55 -03:00
David Lamparter 2537f690c3 tools/gcc-plugins: add small test for frr-format
Just enough to check that it works.

Signed-off-by: David Lamparter <equinox@diac24.net>
2020-03-29 10:45:46 +02:00
David Lamparter 7ff9120698 tools/gcc-plugins: frr-format
This provides the first reasonably-working version of the frr-format GCC
plugin.  I've only tested it with gcc 9.3.0.

Signed-off-by: David Lamparter <equinox@diac24.net>
2020-03-29 10:45:46 +02:00
David Lamparter 37f0e5fecc tools/gcc-plugins: cut c-format.c to size
... remove everything we don't need (or can't use because GCC doesn't
export all of its internal classes & stuff.)

Signed-off-by: David Lamparter <equinox@diac24.net>
2020-03-29 10:45:46 +02:00
David Lamparter 891eac5990 tools/gcc-plugins: import c-format from GCC
(and gcc-common.h from the Linux kernel)

Signed-off-by: David Lamparter <equinox@diac24.net>
2020-03-29 10:45:46 +02:00
Donatas Abraitis 09fdbbe98c tools: Convert type int functions to bool where possible
Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
2020-03-21 14:58:21 +02:00
Donatas Abraitis d1fc0cdf06 tools: Move scripts/coccinelle to tools/coccinelle
Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
2020-03-10 11:41:09 +02:00
Martin Winter 276c4809d8 tools: Update generate_support_bundle.py to support Python 3
Signed-off-by: Martin Winter <mwinter@opensourcerouting.org>
2020-01-25 00:43:20 +01:00
Don Slice 6024e562c9 tools: improve frr-reload delete performance for some commands
Problem seen when deleting many static routes or access-lists due
to frr-reload.py issuing individual vtysh -c commands for every
line. On slow switches, this can take long enough for systemd to
time out the reload process and restart frr.  This fix uses add
logic for static routes, prefix-lists, and access-lists to gang
the changes together.

Signed-off-by: Don Slice <dslice@cumulusnetworks.com>
Ticket: CM-27856
2020-01-16 11:57:56 +00:00
David Lamparter ba7eb55ec6 tools: symalyzer
Signed-off-by: David Lamparter <equinox@diac24.net>
2019-12-14 12:41:19 +01:00
David Lamparter 3fa139a65b tools/frr-reload.py: remove stderr redirects
These make no sense.  stderr=subprocess.STDOUT means that vtysh's stdout
and stderr are combined and returned by check_output.  We don't expect
errors in that, and we certainly don't log them.

Leaving vtysh's stderr as stderr is perfectly fine, it'll be captured
for logging just like stderr output from frr-reload.py.

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2019-12-06 15:13:32 +01:00
David Lamparter 684959068c build: apply DFLT_NAME/profiles in init script
Hopefully at some point we can get rid of the --enable-datacenter switch
and just have the init script do magic.  Should already work for Cumulus
as it is.

NB: the profile name can't be baked into the package.  The whole point
is to make the package profile-agnostic;  in theory at some point the
exact same package files should work on both, say, a Cumulus switch and
a Linux software BGP DFZ router.

Signed-off-by: David Lamparter <equinox@diac24.net>
2019-12-06 15:13:32 +01:00
Quentin Young db6e0503a6 tools: [ [ is not valid test syntax
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2019-12-05 12:57:45 -05:00
Quentin Young 1d92edb209
Merge pull request #5224 from manuhalo/fix_frr_reload_paths
Fixes and extensions to frr_reload.py
2019-11-19 17:12:38 -05:00
Don Slice deb2d4019e tools: resolve issue with bfd timer change fix in frr-reload.py
Found that while the previous fix solved the traceback and created
the correct configuration, it was doing a delete/add process rather
than just an add.  This was due to an incorrectly created search
string. This commit fixes that search string and testing verifies
that the correct thing is now being done.

Ticket: CM-27233
Signed-off-by: Don Slice <dslice@cumulusnetworks.com>
2019-11-19 13:40:23 +00:00
Don Slice c32ab5cfef tools: stop repeating lines to delete for multiple bfd timer changes
Problem reported with tracebacks seen when making multiple bfd timer
changes in frr.conf and applying via frr-reload.py.  Found that when
multiple bfd timer changes are made, the same line can be added for
deletion more than once, causing the traceback when the deletion is
performed.  This fix verifies the correct line is being appended for
deletion.

Ticket: CM-27233
Signed-off-by: Don Slice <dslice@cumulusnetworks.com>
2019-11-13 15:19:36 +00:00
Emanuele Di Pascale 609ac8dd49 tools, vtysh: improved fix for ldpd ifaces
instead of suppressing the 'exit' markers at the end of each
'interface XXX' clause in the mpls ldp configuration, mark
those with a special marker 'exit-ldp-if' and teach the
reload script to correctly recognize the new sub-subcontext

Signed-off-by: Emanuele Di Pascale <emanuele@voltanet.io>
2019-11-12 15:36:15 +01:00
Jafar Al-Gharaibeh e8e4d6ec03 tools: generate .changes file required for deb pkg upload
Signed-off-by: Jafar Al-Gharaibeh <jafar@atcorp.com>
2019-11-01 11:30:26 -05:00
Renato Westphal f5f0a0e302 tools: update the northbound callbacks generator
Add a new '-s' option which controls whether the generated northbound
callbacks are declared with the 'static' specifier or not. If not
(the default), a prototype is generated for each callback before
their declarations.

It's suggested that daemons shouldn't use the '-s' option so that
their northbound callbacks can be implemented in different files
according to their class (config, state, rpc or notification).

libfrr commands, on the other hand, can use the '-s' option when
their associated YANG module is too small and putting all callbacks
in the same file is desirable.

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2019-10-30 10:32:51 -03:00
Emanuele Di Pascale ccef6e47a3 tools, vtysh: fix ldpd + frr-reload.py
frr-reload.py has many special case rules that did not consider ldpd
at all. Specifically:

 1. The bulk of ldp configuration comes in a big 'mpls ldp' context, which was
    previously considered a single-line context as it started with 'mpls'. This
    rule should only apply to labels and lsps.
 2. ldp has a 'router-id' config line that fell into the same rule as the above
    one. It should not be considered a single-line context as more ldp
    configuration can follow.
 3. enabled interfaces should not end their context. A better fix
    would actually require popping a new context for each interface
    in case there is any interface-specific config, but at least this
    fix will address the most common use case.
 4. when declaring pseudowires, any line with 'member pseudowire XXX' should
    be considered a sub-context of the 'l2vpn YYY type ZZZ' context. Without
    this fix, changes in the first psuedowire declared would not correctly
    be processed (e.g. removing a 'control-word exclude' line would not
    be picked up).

Signed-off-by: Emanuele Di Pascale <emanuele@voltanet.io>
2019-10-29 10:32:38 +01:00
Emanuele Di Pascale d9730542a9 tools: frr-reload.py for single daemon
allow frr-reload.py to be invoked with a --daemon option to specify
an individual daemon for which the configuration diff should be
computed. This is useful when integrated config is not used and we
want to apply a patch to a single daemon config file.

No attempt to integrate this with 'service frr reload' has been done.
Making watchfrr work with per-daemon config is outside the scope of
this simple patch.

Signed-off-by: Emanuele Di Pascale <emanuele@voltanet.io>
2019-10-29 10:32:38 +01:00
Emanuele Di Pascale 1a11d9cd1e tools: non hardcoded paths in frr-reload
allow command line parameters to specify different folder for
the vtysh binary,  config file location and temporary file.
Keep the old hardcoded paths as default values for those options
to preserve current functionality.

Signed-off-by: Emanuele Di Pascale <emanuele@voltanet.io>
2019-10-29 10:32:38 +01:00
Sri Mohana Singamsetty 8fc80fbd4c tools: Adding new commands to the list of support bundle commands
Signed-off-by: Sri Mohana Singamsetty <msingamsetty@vmware.com>
2019-09-13 10:05:57 -07:00
Sri Mohana Singamsetty 11c83aa48a tools: Modifications to copy support bundle files
This commit is to copy the support bundle scripts to appropriate directories during installation

Signed-off-by: Sri Mohana Singamsetty <msingamsetty@vmware.com>
2019-09-13 10:05:13 -07:00
David Lamparter 0cf6db21ec *: frr_elevate_privs -> frr_with_privs
Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2019-09-03 17:18:35 +02:00
David Lamparter ba28659f1c tools: extend checkpatch.pl for frr_{with,each}
For frr_each, just fix some existing warnings;  for frr_with_* add a
warning indicating that braces should always be used.

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2019-09-03 17:15:17 +02:00
David Lamparter 00dffa8cde lib: add frr_with_mutex() block-wrapper
frr_with_mutex(...) { ... } locks and automatically unlocks the listed
mutex(es) when the block is exited.  This adds a bit of safety against
forgetting the unlock in error paths & co. and makes the code a slight
bit more readable.

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2019-09-03 17:15:17 +02:00
David Lamparter fefa5e0ff5 *: fix ctype (isalpha & co.) casts
The correct cast for these is (unsigned char), because "char" could be
signed and thus have some negative value.  isalpha & co. expect an int
arg that is positive, i.e. 0-255.  So we need to cast to (unsigned char)
when calling any of these.

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2019-08-06 16:54:52 +02:00
Donald Sharp 64f598fd28
Merge pull request #4754 from opensourcerouting/gen-northbound-improvements
tools: improve gen_northbound_callbacks
2019-07-31 14:28:45 -04:00
Rafael Zalamena c681616f87 tools: generate code that handles all cases
Help developers to start implementing northbound with more complete
callbacks.

Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
2019-07-30 15:39:34 -03:00
Rafael Zalamena 13080468b0 tools: generate northbound code without warnings
Use the alternate struct instantiation that does not generates warning
on old compilers.

Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
2019-07-29 19:28:59 -03:00
Rafael Zalamena 88292d6959 tools: allow YANG model path specification
This allows developer to set a temporary YANG model directory path for
generating northbound for models not yet installed.

Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
2019-07-29 18:59:20 -03:00
Rafael Zalamena 55c8666a92 frr-reload.py: fix reload with different settings
Add `allow-external-route-update` and `domainname` to the one line
context list, otherwise reload will fail when those commands show up in
the running configuration.

Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
2019-07-23 18:20:22 -03:00
David Lamparter b9a0d38d53 tools: add vim snippet
Signed-off-by: David Lamparter <equinox@diac24.net>
2019-06-12 19:35:43 +02:00
David Lamparter 9c251d376a tools: retain sanity when reloading under systemd
Without this, we end up restarting watchfrr with the systemd watchdog
non-functional & tripped a bit later.  Also, if watchfrr is in the
"control" cgroup, systemd 232 will kill it.  (241 apparently doesn't.
Can't find anything about this in systemd's ChangeLog though.)

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2019-06-10 19:21:43 +02:00
Donald Sharp 9ee2f5741d tools: On shutdown no need to flush from tools/frr.in script
Zebra already flushes routes on proper shutdown if you are not
using the -K option.  If you are using the -K option then you
do not want the tools/frr script to flush routes.

If zebra crashes and we restart then load up will either delete
the routes or leave them depending on the -K option.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2019-05-31 21:49:17 -04:00
Donald Sharp 610b53283b doc, tools: Update to code to show example MAX_FDS
Place in the code the ability for end operators to know how
to modify MAX_FDS so that they can run large scale operations.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2019-05-24 08:24:18 -04:00
Quentin Young 1f1896fc6e tools: add vrrpd to frrcommon.sh
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2019-05-17 16:26:26 +00:00
Quentin Young f9d31f6f6c tools: fix vrrp autoconfigure reload
Ticket: CM-24375
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2019-05-17 00:27:08 +00:00
Quentin Young 97b5f22bcd vrrpd: update auto*, init scripts, etc
Add vrrpd to all the usual places daemons need to go

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2019-05-17 00:27:08 +00:00
Quentin Young d8b87afe7c lib: hashing functions should take const arguments
It doesn't make much sense for a hash function to modify its argument,
so const the hash input.

BGP does it in a couple places, those cast away the const. Not great but
not any worse than it was.

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2019-05-14 21:23:08 +00:00
Quentin Young 5307949e8f tools: add lints for unsafe functions
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2019-05-08 15:55:54 +00:00
Don Slice ee951352d1 tools: frr-reload.py stop bouncing peers on bfd timer change
Problem reported that if a bgp neighbor had a bfd timer change
made in frr.conf and systemctl reload frr performed, the neighbor
with the timer changed bounced.  If the change is made in vtysh
by just adding the new timer values, no peer bounce occurs.  This
fix skips the delete part of the delete/add process in frr-reload
so the peers stay up.

Signed-off-by: Don Slice <dslice@cumulusnetworks.com>
2019-04-25 10:54:54 -07:00
Christian Franke a55578f631 tools/frr.in: Only attempt to load daemons.conf if present
Apparently, the default changed to use `/etc/frr/daemons` instead of
`/etc/frr/daemons.conf`. Therefore, we should ignore absence of the
latter file, because its absence is not an actuall error but will
cause a confusing error message like this:

    /etc/init.d/frr: line 507: /etc/frr/daemons.conf: No such file or directory
2019-03-26 10:33:45 +01:00
Donald Sharp 08d4711684
Merge pull request #3989 from opensourcerouting/redhat-new-init
redhat: switch to new init script
2019-03-25 07:45:04 -04:00
David Lamparter b7862d93ae tools/frrcommon.sh: ignore 'declare' failures
The "declare -p watchfrr_options" call is just to support backwards
compatibility.  If it fails, silently ignore that.

Signed-off-by: David Lamparter <equinox@diac24.net>
2019-03-24 15:53:43 +01:00
Donald Sharp 0384e5da0b
Merge pull request #3839 from srimohans/support_bundle
FRR: Python script to generate support bundle for FRR
2019-03-22 04:03:45 -04:00
Ruben Kerkhof 33b397711b tools: fix two typos in daemons file
Signed-off-by: Ruben Kerkhof <ruben@rubenkerkhof.com>
2019-03-21 14:50:53 +01:00
David Lamparter d3b05897ed
Merge pull request #3869 from qlyoung/cocci-fixes
Assorted Coccinelle fixes
2019-03-06 15:54:44 +01:00
Russ White 3f77bcdbe0
Merge pull request #3872 from dslicenc/frr-reload-vrf-context
tools: keep exit-vrf to change context correctly between vrfs
2019-02-27 11:16:38 -05:00
Quentin Young 25af5f0d79 tools: add coccinelle spatches
Add some Coccinelle semantic patches we can use to automatically
refactor code in the future.

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2019-02-26 17:40:40 +00:00
Don Slice 06ad470d7c tools: keep exit-vrf to change context correctly between vrfs
Discovered in testing that if a static route in the default table
was entered immediately after a vrf static block, the static route
intended for the default table was put in the vrf instead.  This
fix retains the "exit-vrf" statement which causes the following
static routes to appear in the default table correctly.

Ticket: CM-23985
Signed-off-by: Don Slice <dslice@cumulusnetwork.com>
2019-02-26 14:23:53 +00:00
Don Slice 348135a5da tools: fix blackhole static changes in frr-reload.py
Problem caused when nclu is used to create "ip route 1.1.1.0/24
blackhole" because frr-reload.py changed the line to Null0 instead
of blackhole.  If nclu tries to delete it using the same line as
entered, the commit fails since it doesn't match.

Ticket: CM-23986
Signed-off-by: Don Slice <dslice@cumulusnetworks.com>
2019-02-26 14:08:27 +00:00
Donald Sharp 5fa3430885
Merge pull request #3836 from opensourcerouting/debian/master-kill-backports
[master] debian packaging
2019-02-23 18:23:21 -05:00
Sri Mohana Singamsetty e60eb780e4 FRR: Python script to generate support bundle for FRR
This has a python script that helps in collecting various CLI show command outputs in an automated way.

This commit has two files.

1.Text Configuration file: support_bundle_commands.conf - This file has list of CLI show commands to be executed. This file will be in tools/etc/frr/ directory. On executing command "sudo install -m 644 tools/etc/frr/ support_bundle_commands.conf /etc/frr/support_bundle_commands.conf", as part of FRR installation, this file will be copied into /etc/frr directory.

2.Python script file: generate_support_bundle.py - This file has the python code that has the below functionality.
  * It reads the support_bundle_commands.conf file. For each process present in the conf file, it creates a support_bundle file. For example, it creates bgp_support_bundle.log file for BGP and zebra_support_bundle.log file for Zebra. These files will be created in /var/log/frr/ directory. This is where regular FRR log files are also stored currently.
  * The script reads the CLI command specified between CLI_START and CLI_END key words for each process. It will execute the commands one by one.
  * For each such command, the script also appends the current time stamp at which the CLI command is executed.
  * In case of successful execution of the CLI command, it will copy the CLI output into the above support bundle file.
  * In case of CLI command failure, it will capture the error thrown and the error is also written into the same file.
  * A small snippet of the output file is as below.

  >>[2019-01-02 13:55:23.318987]show bgp summary

  IPv4 Unicast Summary:
  BGP router identifier 203.0.113.1, local AS number 65000 vrf-id 0
  BGP table version 4
  RIB entries 7, using 1176 bytes of memory
  Peers 1, using 21 KiB of memory
  Peer groups 1, using 64 bytes of memory

  Neighbor        V         AS MsgRcvd MsgSent   TblVer  InQ OutQ  Up/Down State/PfxRcd
  203.0.113.2     4      65001      34      34        0    0    0 00:29:47            2

  Total number of neighbors 1
  >>[2019-01-02 13:55:23.619953]show ip bgp

  BGP table version is 4, local router ID is 203.0.113.1, vrf id 0
  Status codes:  s suppressed, d damped, h history, * valid, > best, = multipath,
                 i internal, r RIB-failure, S Stale, R Removed

Signed-off-by: Sri Mohana Singamsetty <msingamsetty@vmware.com>
2019-02-20 11:56:22 -08:00
David Lamparter 195f215cfc tools: fix new init script wrt. multi-instance
TBH when I looked at watchfrr I didn't see any MI support and hence
assumed this just didn't work to begin with.  However, it actually does
(transparently to watchfrr, by just using "ospfd-1" as daemon name.)

So, fix this up and make it work again.

(Also remove 2 extraneous \n in messages.)

Signed-off-by: David Lamparter <equinox@diac24.net>
2019-02-19 21:38:23 +01:00
David Lamparter 3ec9556728 watchfrr: build in defaults for -r/-s/-k
There's no good reason to not have these options default to the
installation path of tools/watchfrr.sh.  Doing so allows us to ditch
watchfrr_options from daemons/daemons.conf completely.

Fixes: #3652
Signed-off-by: David Lamparter <equinox@diac24.net>
2019-02-19 21:34:31 +01:00
David Lamparter 1bc91be4b8 tools/tarsource.sh: deal with AC_INIT []
configure.ac got cleaned up, now there's [] around the version number.

Signed-off-by: David Lamparter <equinox@diac24.net>
2019-02-19 21:34:08 +01:00
David Lamparter 4734c22a4f tools/tarsource.sh: support FRR as a git submodule
a git submodule will have .git as a file instead of a directory... which
breaks tarsource.sh.

Signed-off-by: David Lamparter <equinox@diac24.net>
2019-02-19 21:34:08 +01:00
David Lamparter 380fe10b16 tools: don't watch nonexistent daemons
If we try to monitor a nonexisting daemon in watchfrr, it will
(currently) forever wait at startup since the vty connection will never
come up.  Just drop the daemon from the daemon list in such a case.

Signed-off-by: David Lamparter <equinox@diac24.net>
2019-02-19 21:34:08 +01:00
David Lamparter 6b37587791 tools/tarsource.sh: keep version info on non-git
extraver won't have any useful value on a non-git run.

Signed-off-by: David Lamparter <equinox@diac24.net>
2019-02-19 21:34:06 +01:00
David Lamparter 3e662ed3f1 tools: update build-debian-package.sh
Signed-off-by: David Lamparter <equinox@diac24.net>
2019-02-19 21:34:06 +01:00
David Lamparter 3f406e3f8e tools/tarsource.sh: fix GZIP_ENV
Some older versions of Automake don't escape this properly.

Signed-off-by: David Lamparter <equinox@diac24.net>
2019-02-19 21:32:19 +01:00
David Lamparter 74afa5e686 debian: cleanly split off from dist tarball
The debian/ directory is distributed separately for tarballs in 3.0
(quilt) format.  Including it in the dist tarball causes problems with
automake when the separately distributed debian directory is unpacked on
top of the dist tarball;  the clean and correct thing to do here is to
not include the debian/ directory in dist tarballs.

Users have two choices for building FRR Debian packages:
- build straight off git
- build from a "frr.tar" + "frr-debian.tar"

The tarsource.sh tool does the right thing when invoked with the -D
("Debian") option.

Signed-off-by: David Lamparter <equinox@diac24.net>
2019-02-19 21:31:18 +01:00
David Lamparter 081253fcd5 tools/tarsource.sh: create debian changelog
Signed-off-by: David Lamparter <equinox@diac24.net>
2019-02-19 21:31:18 +01:00
David Lamparter b3c4c164b5 debian: make package "official"
Move us into place in debian/

Signed-off-by: David Lamparter <equinox@diac24.net>
2019-02-19 21:30:54 +01:00
David Lamparter e14560a7e6 tools: add new tarsource.sh helper
It cleans your house and cooks dinner.  Or maybe it creates a clean dist
tarball for you, plus a Debian .dsc if you have dpkg installed - and
GPG-signs the result appropriately if requested.

In any case the resulting tarball should be distributed for our
releases.

Signed-off-by: David Lamparter <equinox@diac24.net>
2019-02-19 21:30:50 +01:00
Mark Stapp 95ce849b58 libs, rip, isis: change northbound operation enum to DESTROY
Change the northbound lib operation from DELETE to DESTROY;
make the required changes in the users of the northbound, in
the cli, rip, ripng, and isis.

Signed-off-by: Mark Stapp <mjs@voltanet.io>
2019-02-11 15:49:49 -02:00
David Lamparter 0240fee6f4
Merge pull request #3715 from qlyoung/fix-systemd-deps
tools: fix systemd dependency graph
2019-02-11 07:50:16 +01:00
Quentin Young efbf903d61 tools: fix systemd dependency graph
Currently our systemd dependencies look something like this (example
from vanilla Debian 9):

$ systemctl list-dependencies frr
frr.service
● ├─system.slice
● └─sysinit.target
  ...

$ systemctl list-dependencies --reverse frr
frr.service
● └─network-online.target
●   └─apt-daily.service

Note that sysinit.target does not depend on any network* service or
target.

In other words, unless there is a service that requires
network-online.service, even if FRR is enabled it will not be started.
Therefore network-online.target is the wrong unit to have in WantedBy=,
as it is not always started.

This patch updates our service file so that it is properly started by
the system when enabled, delayed until networking is up, and if possible
delayed until after NetworkManager, systemd-networkd or any other
networking configuration manager has finished performing its tasks -
i.e. after network-online.target.

After these changes our new dependency graph looks like this:

$ systemctl list-dependencies frr
frr.service
● ├─system.slice
● │ └─networking.service
● ├─network.target
● └─sysinit.target
  ...

$ systemctl list-dependencies --reverse frr
frr.service
● └─multi-user.target
●   └─graphical.target

This way, FRR will be started by multi-user.target (just like most
applications), but delayed until after networking has been configured.

In the same stroke, this should also fix issues on systems that do not
provide "networking.service" (such as CentOS 7).

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
Signed-off-by: David Lamparter <equinox@diac24.net>
2019-02-06 19:47:43 +00:00