Commit Graph

150 Commits

Author SHA1 Message Date
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
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
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
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
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
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
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
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
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
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
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
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
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
a0a7dead0b tools/frr-reload.py: support -N pathspace
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
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
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
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 6a00e91d99f7f98d857c2056d0dcfeba48966581

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
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
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
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
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
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
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
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
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
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
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
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
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
Don Slice
2a2b64e487 tools: stop frr-reload.py from trying to delete the vrf context
Problem seen when removing last config item under the vrf context,
where frr-reload.py tries instead to delete the vrf context itself.
Since that is not permitted on an active vrf, the command errors
out and nothing is deleted.

Signed-off-by: Don Slice <dslice@cumulusnetworks.com>
2018-12-14 13:11:05 +00:00
jpmondet
1c64265f86
frr-reload.py: Add python2 & python3 compatibility.
Signed-off-by: jpmondet <jp@mondet.org>
2018-09-26 21:45:33 +02:00
Don Slice
d60f480010 tools: correct frr-reload.py handling of bgp vni/exit-vni config
Problem reported that when a peer-group was added in certain
configurations, it would be rejected because of the order of the
commands put in by nclu. Issued turned out to be how frr-reload.py
was handling the sub-sub-context of the vni under the address-family
and subsequently how it handled the following exit-vni.

Ticket: CM-21996
Signed-off-by: Don Slice <dslice@cumulusnetworks.com>
2018-08-10 09:59:24 -07:00
Don Slice
cc27402c4d tools: handle exit-vrf as end of context block
Ticket: CM-21048
Signed-off-by: Don Slice <dslice@cumulusnetworks.com>
2018-07-19 18:38:54 +00:00
Christian Franke
6bd0508a89 tools/frr-reload.py: process vnc settings as sub-context
Signed-off-by: Christian Franke <chris@opensourcerouting.org>
2018-03-12 17:30:16 +01:00
Daniel Walton
9d877afc13 tools: frr-reload 'vni' keyword does not always create a sub-context
Signed-off-by: Daniel Walton <dwalton@cumulusnetworks.com>
2018-01-17 15:57:50 +00:00
Daniel Walton
b05a1d3c03 tools: frr-reload do not attempt deleting lines that cannot be deleted
Signed-off-by: Daniel Walton <dwalton@cumulusnetworks.com>

There are several lines that we cannot do a "no" on
- frr version
- frr defaults
- password
- line vty

frr-reload should ignore these if asked to do a "no" on them
2017-11-10 18:30:25 +00:00
Daniel Walton
4c76e59220 tools: frr-reload remove Cumulus Linux release numbers from comments
Signed-off-by: Daniel Walton <dwalton@cumulusnetworks.com>

The "3.0", etc in the comments were referring to Cumulus Linux 3.0 which
was confusing now that FRR has a 3.0
2017-11-10 17:57:42 +00:00
Daniel Walton
028bcc883f tools: frr-reload combine "'router bgp' and line" checks
Signed-off-by: Daniel Walton <dwalton@cumulusnetworks.com>

We had multiple places checking for

    if ctx_keys[0].startswith('router bgp') and line

Combine these into a single check
2017-11-10 17:47:13 +00:00
Daniel Walton
c755f5c434 tools: frr-reload avoid del/add of BGP table-map
Signed-off-by: Daniel Walton <dwalton@cumulusnetworks.com>
2017-11-10 17:41:43 +00:00
Daniel Walton
89cca49b3a tools: frr-reload.py ignore multiple whitespaces
Signed-off-by: Daniel Walton <dwalton@cumulusnetworks.com>

Without this fix frr-reload would do a del/add even if the only
difference were bogus whitespaces.

root@cel-redxp-10[nclu]# /usr/lib/frr/frr-reload.py --test
/etc/frr/frr.conf

Lines To Delete
===============

router bgp 100
 no bgp router-id 1.1.1.1

Lines To Add
============

router bgp 100
 bgp   router-id 1.1.1.1
root@cel-redxp-10[nclu]#
2017-11-10 17:19:08 +00:00
Daniel Walton
2f52ad9627 tools: frr-reload.py should exit(1) if vtysh config mode is locked
Signed-off-by: Daniel Walton <dwalton@cumulusnetworks.com>
2017-09-27 18:47:47 +00:00
Daniel Walton
478f9ce277 tools: frr-reload capture stderr so we can log it
Signed-off-by: Daniel Walton <dwalton@cumulusnetworks.com>
2017-09-19 13:54:35 +00:00
Daniel Walton
8ad1fe6cae tools: frr-reload support for "no no" scenario
Signed-off-by: Daniel Walton <dwalton@cumulusnetworks.com>
2017-09-19 13:06:49 +00:00
Daniel Walton
7918b33541 tools: frr-reload.py support for vni under 'address-family l2vpn evpn'
Signed-off-by: Vivek Venkatraman <vivek@cumulusnetworks.com>
2017-09-08 13:27:23 +00:00
Daniel Walton
596074af62 vtysh: vtysh -f FOO should exit non-zero if it hits an error
Signed-off-by: Daniel Walton <dwalton@cumulusnetworks.com>

Today if we hit an error while apply the contents of file FOO that error
does not bubble up to a non-zero exit.
2017-08-16 20:22:59 +00:00
Daniel Walton
5014d96f0f bgpd, tools, vtysh: Handle config migration from 'address-family evpn' to 'address-family l2vpn evpn'
Ticket: CM-16747
Signed-off-by: Daniel Walton <dwalton@cumulusnetworks.com>
Reviewed-by:   Quentin Young <qlyoung@cumulusnetworks.com>
2017-08-08 10:28:50 -04:00
Jafar Al-Gharaibeh
1a8c43f114 tools: update to use FRR name
Signed-off-by: Jafar Al-Gharaibeh <jafar@atcorp.com>
2017-07-12 13:26:22 -05:00
David Lamparter
92eedda1fb Merge branch stable/2.0 into stable/3.0
Conflicts:
	bgpd/bgp_fsm.c
	ospf6d/ospf6_lsa.c
	ospfd/ospf_vty.c
	zebra/redistribute.c

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2017-05-18 12:23:13 +02:00
Daniel Walton
e80c8c5531 tools: Allow frr-reload.py to know about agentx
Signed-off-by: Daniel Walton <dwalton@cumulusnetworks.com>
Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2017-05-17 00:25:28 +00:00
Daniel Walton
ec3fd95774 tools: frr-reload.py VtyshMarkException needs to include "vtysh -m"
output

Signed-off-by: Daniel Walton <dwalton@cumulusnetworks.com>
2017-05-17 00:23:38 +00:00
Daniel Walton
619c4e3acf frr-reload.py fails on "no debug ospf6 message unknown"
Signed-off-by: Daniel Walton <dwalton@cumulusnetworks.com>
2017-05-17 00:22:00 +00:00
Daniel Walton
970c956816 tools: frr-reload removes "ipv6 nd ra-interval" and "no ipv6 nd supp"
Signed-off-by: Daniel Walton <dwalton@cumulusnetworks.com>
2017-05-17 00:18:33 +00:00
Daniel Walton
afa2e8e187 tools: reload handle removal of entire address-family section under BGP
Signed-off-by: Daniel Walton <dwalton@cumulusnetworks.com>

When an entire address-family section is removed from under BGP, we
cannot just issue 'no address-family foo bar' as address-family line
doesn't support 'no'. We have to delete the individual lines under the
address-family.
2017-05-17 00:16:09 +00:00
Daniel Walton
825be4c27b tools: frr-reload.py should exit non-zero when "set src x.x.x.x" fails
Signed-off-by: Daniel Walton <dwalton@cumulusnetworks.com>
Reviewed-by:   Donald Sharp <sharpd@cumulusnetworks.com>
2017-05-17 00:14:37 +00:00
Daniel Walton
2ce26af100 tools: quagga-reload.py fails to change max-paths
Signed-off-by: Daniel Walton <dwalton@cumulusnetworks.com>
Reviewed-by:   Donald Sharp <sharpd@cumulusnetworks.com>
2017-04-04 18:51:32 +00:00
Martín Beauchamp
685e701ef3 Lowercase frr.conf 2017-03-09 09:45:00 -05:00
David Lamparter
a523ab9fc8 Merge branch 'frr/pull/236' ("tools: frr-reload.py needs to treat "mpls" as a single line context")
Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2017-03-07 16:02:41 +01:00
Daniel Walton
a11209a79b tools: frr-reload.py needs to treat "no " as a single line context
Signed-off-by: Daniel Walton <dwalton@cumulusnetworks.com>
Reviewed-by:   Donald Sharp <sharpd@cumulusnetworks.com>
2017-03-03 19:57:27 +00:00
Daniel Walton
45cb21bf96 tools: frr-reload.py needs to treat "mpls" as a single line context
Signed-off-by: Daniel Walton <dwalton@cumulusnetworks.com>
Reviewed-by:   Donald Sharp <sharpd@cumulusnetworks.com>
2017-03-01 21:20:34 +04:00
Martín Beauchamp
e20dc2ba06 Lowercase frr.conf 2017-02-27 13:26:20 -05:00
Daniel Walton
53bddc224c tools: frr-reload removes "ipv6 nd ra-interval" and "no ipv6 nd suppress-ra"
Signed-off-by: Daniel Walton <dwalton@cumulusnetworks.com>
2017-02-18 02:05:56 +12:00
Donald Sharp
0dca233ec0 *: Found some instances of Quagga.conf
Cleanup Quagga.conf -> Frr.conf

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2017-02-07 13:44:09 -05:00
Dinesh G Dutt
4d760f4255 tools: Silly typo in regex for catching ip route syntax
Ticket: CM-14600
Reviewed By: CCR-5615
Testing Done: Verifying the issue with/without the fix

I had intended the regexp to catch both ip and ipv6 routes, but somewhere
along the way, I left out the grouping in the regexp to catch if it was
ip or ipv6 at the start. This caused all the rest of the matches and replaces
to be off causing the issue reported by the bug.

Signed-off-by: Dinesh Dutt <ddutt@cumulusnetworks.com>
2017-01-30 13:40:53 -05:00
Dinesh G Dutt
0845b8727a tools: Fix unbound newaddr variable, fix too-broad except clauses
Ticket: CM-14351
Reviewed By: dwalton
Testing Done:attempts to run NCLU test failed, Daniel verified.

Uninit variable bug, plus missed adding ValueError to the except
clauses in a couple of places.

Signed-off-by: Dinesh Dutt <ddutt@cumulusnetworks.com>
2017-01-30 13:40:53 -05:00
Dinesh G Dutt
bb972e4465 tools: Normalize prefix-lists and IP networks for avoiding unnecessary reload
Ticket: CM-14280, CM-14281, CM-14286
Reviewed By: CCR-5546
Testing Done: quagga_service_test, bgp_enhe, bgp_vrf etc.

If the user specifies a network statement such as "network 1.1.1.1/24",
the running config shows this as "network 1.1.1.0/24" which causes
unnecessary withdrawl of the prefix and re-advertisement causing
perturbations. The same thing applies to prefix-lists and of course, IPv6
addresses.

IPv6 addresses were being normalized already, and so we use that same
function to handle the IPv6 portion of the issue. Interestingly community
strings were also getting ensnared in the normalized IPv6 function due to
the presence of ':', but thats OK.

quagga's running config changes 'null0' and 'blackhole' keywords into 'Null0'.
For example: ip route 10.1.1.0/24 blackhole' is displayed as
'ip route 10.1.1.0/24 Null0'. Reload mistakes this and issues a delete of the
Null0 route followed by an add of the "blackhole" route. Unnecessary, and
results in unexpected routing perturabations.

Also fix prefix-list's le/ge behavior: It always prints ge first even if the
user has specified le followed by ge, and it doesn't print l3 32/128 if ge
is also specified, else it prints them.

Signed-off-by: Dinesh Dutt <ddutt@cumulusnetworks.com>
2017-01-30 13:40:53 -05:00
Dinesh G Dutt
768bf950cf tools: Handle deletes of entire interface context as deleting each line
Ticket: CM-14260
Reviewed By: CCR-14260
Testing Done: quagga reload tests (quagga_service, bgp_enhe etc.)

Quagga reload handles deletes of entire context by issuing a "no.." on the
entire context itself instead of deleting each individual line of the context.
However, this doesn't work when the context is "interface" since its not
allowed to do "no interface <ifname>" inside quagga. So special case this by
deleting each individual line of the context.

Signed-off-by: Dinesh Dutt <ddutt@cumulusnetworks.com>
2017-01-30 13:40:53 -05:00
Dinesh G Dutt
0bf7cc2888 tools: Handle lack of "seq" in prefix-list statements.
Ticket: CM-14259
Reviewed By: CCR-5527
Testing Done:

If users specify "ip prefix-list FOO permit 1.2.3.4/24", running config
displays that line as "ip prefix-list FOO seq 5 permit 1.2.3.4/24", which
causes reload to delete the running config line and add back the one in
the config.

This patch fixes that.

Signed-off-by: Dinesh Dutt <ddutt@cumulusnetworks.com>
2017-01-30 13:40:49 -05:00
Dinesh G Dutt
4b78098d79 tools: Don't overwrite Quagga.conf on reload, unless user specified.
Ticket: CM-14059
Reviewed By: CCR-5524
Testing Done: the usual

At some point in the 3.x release cycle, it was decided to overwrite the
user's Quagga.conf configuration file with the output of running config
when the user did a quagga reload. This is problematic for several reasons
such as: losing user-specified comments, upsetting network automation
scripts which think some thing has changed all the time from the specified
config etc.

This patch fixes this issue by not overwriting the Quagga.conf file unless
the user specifies it via an additional option, or the file being used as
input to quagga reload isn't the default configuration file (incl. path).

Signed-off-by: Dinesh Dutt <ddutt@cumulusnetworks.com>
2017-01-30 13:40:40 -05:00
Dinesh G Dutt
78e31f4663 tools: Fix unnecessary routing perturbations due to old style config
Ticket: CM-14060
Reviewed By:
Testing Done:

There are two harmful problems (cause routing changes in the network) with the
2.5.x style config:
    one with the old style specification of "multipath as-relax", and
    the other with ip import-table, used by redistribute neighbor

In 2.5, we had the user specify 'no-as-set' as the suffix to
'bgp bestpath as-path multipath relax' to avoid quagga's default behavior
which'd cause weird routing problems. However, in 3.x, we made 'no-as-set' as
the default, and so its neither required to specify it nor is it shown in the
running config. This means when we do quagga reload, we remove the multipath
as-relax line and add it back with the no-as-set line. This causes all BGP
sessions to be reset.

The problem with the "ip import-table" is that it causes us to unimport the
routes and then add it back again, causing routing prefix changes throughout
the network, potentially causing blackholing of traffic.

This fix addresses both these issues and avoids the unnecessary routing blips.

Signed-off-by: Dinesh Dutt <ddutt@cumulusnetworks.com>
2017-01-30 13:40:04 -05:00
Donald Sharp
d8e4c43827 debian: Convert Quagga -> Frr
Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2017-01-04 09:25:20 -05:00