]> git.puffer.fish Git - mirror/frr.git/log
mirror/frr.git
3 years agoospfd: fix null pointer dereference when flushing an opaque LSA
Renato Westphal [Mon, 31 May 2021 13:27:51 +0000 (10:27 -0300)]
ospfd: fix null pointer dereference when flushing an opaque LSA

Call ospf_lsa_flush() before free_opaque_info_per_id() since the
latter can deallocate the LSA that is going to be flushed.

Also, there's no need to set the LSA MaxAge to OSPF_LSA_MAXAGE
manually as the ospf_lsa_flush() function already takes care of that.

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
3 years agoospfd: fix dangling pointer when exiting from the helper mode
Renato Westphal [Mon, 31 May 2021 13:27:51 +0000 (10:27 -0300)]
ospfd: fix dangling pointer when exiting from the helper mode

When exiting from the helper mode for a given router after an
unsuccessful graceful restart, removing the neighborship to that
router straight away leads to a dangling pointer in the associated
interface, which inevitably leads to a crash. To solve this
problem, schedule the removal of the neighbor instead of removing
it immediately.

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
3 years agoospfd: fix crash when logging a Grace-LSA
Renato Westphal [Mon, 31 May 2021 13:27:51 +0000 (10:27 -0300)]
ospfd: fix crash when logging a Grace-LSA

Change the "show_ospf_grace_lsa_info" callback to account for the
fact that the "vty" parameter can be null.

This fixes a crash that happens when "debug ospf packet ls-update
detail" is configured and a Grace-LSA is sent or received.

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
3 years agoospfd: fix small issue when exiting from the GR helper mode
Renato Westphal [Mon, 31 May 2021 13:27:51 +0000 (10:27 -0300)]
ospfd: fix small issue when exiting from the GR helper mode

When exiting from the GR helper mode, recalculate the DR only for
interfaces of the appropriate types (broadcast and NMBA).

This fixes a problem where the state of a neighbor reachable over a
p2p interface was changing from Full/DROther to Full/Backup across
a graceful restart.

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
3 years agoospfd: fix GR helper initialization and termination
Renato Westphal [Mon, 31 May 2021 13:27:51 +0000 (10:27 -0300)]
ospfd: fix GR helper initialization and termination

Since a single ospfd process can have multiple OSPF interfaces
configured, we need to separate the global GR initialization and
termination from per-instance initialization and termination.

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
3 years agodoc: replace "passive-interface IFNAME" with "ip ospf passive"
Igor Ryzhov [Sat, 5 Jun 2021 14:53:23 +0000 (17:53 +0300)]
doc: replace "passive-interface IFNAME" with "ip ospf passive"

Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
3 years agoospfd: fix passive interface configuration
Igor Ryzhov [Fri, 4 Jun 2021 14:47:32 +0000 (17:47 +0300)]
ospfd: fix passive interface configuration

Currently, passive interface flag is configured from the router node
using "passive-interface IFNAME". There are multiple problems with this
command:
- it is not in line with all other interface-related commands - other
  parameters are configured from the interface node using "ip ospf"
  prefix
- it is not in line with OSPFv3 - passive flag is configured from the
  interface node using "ipv6 ospf6 passive" command
- most importantly, it doesn't work correctly when the interface is in
  a different VRF - when using VRF-lite, it incorrectly changes the
  vrf_id of the interface and it becomes desynced with the actual state;
  when using netns, it creates a new fake interface and configures it
  instead of configuring the necessary interface

To fix all the problems, this commit adds a new command to the interface
configuration node - "ip ospf passive". The purpose of the command is
completely the same, but it works correctly in a multi-VRF environment.

The old command is preserved for the backward compatibility, but the
warning is added that it is deprecated because it doesn't work correctly
with VRFs.

Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
3 years agolib: fix address sanitizer crash on `find`
Rafael Zalamena [Mon, 7 Jun 2021 14:02:16 +0000 (11:02 -0300)]
lib: fix address sanitizer crash on `find`

Fix the following address sanitizer crash when running the command `find`:

  ERROR: AddressSanitizer: dynamic-stack-buffer-overflow
  WRITE of size 1 at 0x7fff4840fc1d thread T0
      0  in print_cmd ../lib/command.c:1541
      1  in cmd_find_cmds ../lib/command.c:2364
      2  in find ../vtysh/vtysh.c:3732
      3  in cmd_execute_command_real ../lib/command.c:995
      4  in cmd_execute_command ../lib/command.c:1055
      5  in cmd_execute ../lib/command.c:1219
      6  in vtysh_execute_func ../vtysh/vtysh.c:486
      7  in vtysh_execute ../vtysh/vtysh.c:671
      8  in main ../vtysh/vtysh_main.c:721
      9  in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x270b2)
      10 in _start (/usr/bin/vtysh+0x21f64d)

Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
3 years agozebra: fix config after exit from vrf
Igor Ryzhov [Wed, 2 Jun 2021 14:27:02 +0000 (17:27 +0300)]
zebra: fix config after exit from vrf

When the VRF node is exited using "exit" or "quit", there's still a VRF
pointer stored in the vty context. If you try to configure some router
related command, it will be applied to the previous VRF instead of the
default VRF. For example:

```
(config)# vrf test
(config-vrf)# ip router-id 1.1.1.1
(config-vrf)# do show run
...
!
vrf test
 ip router-id 1.1.1.1
 exit-vrf
!
...
(config-vrf)# exit
(config)# ip router-id 2.2.2.2
(config)# do show run
...
!
vrf test
 ip router-id 2.2.2.2
 exit-vrf
!
...
```

`vrf-exit` works correctly, because it stores a pointer to the default
VRF into the vty context (but weirdly keeping the VRF_NODE instead of
changing it to CONFIG_NODE).

Instead of relying on the behavior of exit function, always use the
default VRF when in CONFIG_NODE.

Another problem is missing `VTY_CHECK_CONTEXT`. If someone deletes the
VRF in which node the user enters the command, then zebra applies the
command to the default VRF instead of throwing an error.

Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
3 years agobfdd: forbid setting interface for multihop sessions
Igor Ryzhov [Fri, 28 May 2021 12:25:36 +0000 (15:25 +0300)]
bfdd: forbid setting interface for multihop sessions

Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
3 years agobfdd: don't store interface pointer for multihop sessions
Igor Ryzhov [Fri, 28 May 2021 11:33:44 +0000 (14:33 +0300)]
bfdd: don't store interface pointer for multihop sessions

It breaks "neighbor A.B.C.D update-source" config in BGP.

Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
3 years agolib: fix default ttl for single-hop bfd sessions
Igor Ryzhov [Tue, 1 Jun 2021 14:59:24 +0000 (17:59 +0300)]
lib: fix default ttl for single-hop bfd sessions

The TTL field is actually the number of hops, not a TTL.

Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
3 years agolib: fix bfd multihop
Igor Ryzhov [Thu, 27 May 2021 17:02:56 +0000 (20:02 +0300)]
lib: fix bfd multihop

Never send an interface name/index for multihop sessions. It breaks
"neighbor A.B.C.D update-source" config in BGP.

Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
3 years agobgpd: fix enabling bfd debug
Igor Ryzhov [Fri, 28 May 2021 08:55:27 +0000 (11:55 +0300)]
bgpd: fix enabling bfd debug

When enabling bfd debug from the enable mode, library debugging is not
enabled.

Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
3 years agolib: fix output of "list" and "find" commands
Igor Ryzhov [Wed, 2 Jun 2021 23:02:45 +0000 (02:02 +0300)]
lib: fix output of "list" and "find" commands

Currently, we output the command exactly how it is defined in DEFUN.
We shouldn't output varnames and excessive whitespace.

Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
3 years agolib, vtysh: reduce code duplication
Igor Ryzhov [Wed, 2 Jun 2021 21:29:51 +0000 (00:29 +0300)]
lib, vtysh: reduce code duplication

Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
3 years agodoc: add separate section for nexthop tracking
Igor Ryzhov [Wed, 2 Jun 2021 14:51:09 +0000 (17:51 +0300)]
doc: add separate section for nexthop tracking

"ip nht resolve-via-default" is currently placed in "Link Parameters
Commands" section. Add a separate section and missing IPv6 counterpart.

Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
3 years agodoc: fix link-params commands
Igor Ryzhov [Wed, 2 Jun 2021 14:39:26 +0000 (17:39 +0300)]
doc: fix link-params commands

Remove redundant prefix.

Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
3 years agobfdd: fix bfd key structure
Igor Ryzhov [Tue, 1 Jun 2021 17:30:13 +0000 (20:30 +0300)]
bfdd: fix bfd key structure

There's a padding byte between "mhop" and "peer" fields in this structure.
This structure is sometimes passed by value to functions and used in
assignments. The standard doesn't guarantee that the padding bytes are
copied on assignments. As this structure is used as a hash key, having
this padding byte with unspecified value can lead to unwanted behavior.

Fix the possible issue by making the "mhop" field to be 2 bytes. Also
make the struct packed as a precaution for future changes.

Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
3 years agodoc: remove varnames from command descriptions
Igor Ryzhov [Wed, 2 Jun 2021 23:19:36 +0000 (02:19 +0300)]
doc: remove varnames from command descriptions

Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
3 years agoospfd: if destroy the whole ospf, then remove ospf's interface config: passive-interface
anlancs [Wed, 2 Jun 2021 02:51:49 +0000 (10:51 +0800)]
ospfd: if destroy the whole ospf, then remove ospf's interface config: passive-interface

Signed-off-by: anlancs <anlan_cs@tom.com>
3 years agodoc: Replace single tick with double tick under developer/topotests.rst
Donatas Abraitis [Wed, 2 Jun 2021 05:48:25 +0000 (08:48 +0300)]
doc: Replace single tick with double tick under developer/topotests.rst

Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
3 years agopathd: fix render candidate-path bandwidth
Emanuele Di Pascale [Tue, 18 May 2021 13:52:44 +0000 (15:52 +0200)]
pathd: fix render candidate-path bandwidth

the config for dynamic candidate paths with bandwidth preferences
was using a different order of keywords (required bandwidth X) than
the corresponding command (bandwidth X required). This confuses
frr-reload, and possibly users too. Make both use the same order.

Signed-off-by: Emanuele Di Pascale <emanuele@voltanet.io>
3 years agodoc: update VRF support description
Igor Ryzhov [Wed, 12 May 2021 15:49:00 +0000 (18:49 +0300)]
doc: update VRF support description

Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
3 years agotests: remove tcp_l3mdev_accept setting
Igor Ryzhov [Fri, 7 May 2021 08:19:58 +0000 (11:19 +0300)]
tests: remove tcp_l3mdev_accept setting

This is not necessary anymore with fixed `vrf_bind`.

Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
3 years agolib: fix binding to a vrf
Igor Ryzhov [Thu, 6 May 2021 23:49:40 +0000 (02:49 +0300)]
lib: fix binding to a vrf

There are two possible use-cases for the `vrf_bind` function:
- bind socket to an interface in a vrf
- bind socket to a vrf device

For the former case, there's one problem - success is returned when the
interface is not found. In that case, the socket is left unbound without
throwing an error.

For the latter case, there are multiple possible problems:
- If the name is not set, then the socket is left unbound (zebra, vrrp).
- If the name is "default" and there's an interface with that name in the
  default VRF, then the socket is bound to that interface.
- In most daemons, if the router is configured before the VRF is actually
  created, we're trying to open and bind the socket right after the
  daemon receives a VRF registration from zebra. We may not receive the
  VRF-interface registration from zebra yet at that point. Therefore,
  `if_lookup_by_name` fails, and the socket is left unbound.

This commit fixes all the issues and updates the function description.

Suggested-by: Pat Ruddy <pat@voltanet.io>
Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
3 years agobgpd: pass correct vrf_id to vrf_socket when creating bgp view socket
Igor Ryzhov [Mon, 31 May 2021 19:12:31 +0000 (22:12 +0300)]
bgpd: pass correct vrf_id to vrf_socket when creating bgp view socket

Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
3 years agoospf6d: fix using vrf interface as a loopback
Igor Ryzhov [Fri, 28 May 2021 13:14:34 +0000 (16:14 +0300)]
ospf6d: fix using vrf interface as a loopback

Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
3 years agoisisd: fix using vrf interface as a loopback
Igor Ryzhov [Fri, 28 May 2021 15:45:40 +0000 (18:45 +0300)]
isisd: fix using vrf interface as a loopback

Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
3 years agoisisd, ospf6d, pimd: set vrf_id when creating bfd sessions
Igor Ryzhov [Mon, 31 May 2021 10:57:55 +0000 (13:57 +0300)]
isisd, ospf6d, pimd: set vrf_id when creating bfd sessions

Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
3 years agopceplib: fix mixup of global/local variables
Igor Ryzhov [Fri, 28 May 2021 17:39:37 +0000 (20:39 +0300)]
pceplib: fix mixup of global/local variables

CID 1502790

Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
3 years agoospf6d: unlink router from vrf on deletion
Igor Ryzhov [Thu, 27 May 2021 10:16:40 +0000 (13:16 +0300)]
ospf6d: unlink router from vrf on deletion

Otherwise `ospf6_lookup_by_vrf_id` returns stale pointer.

Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
3 years agoMerge pull request #8791 from LabNConsulting/chopps/backport-always-batch
Donald Sharp [Tue, 8 Jun 2021 15:31:13 +0000 (11:31 -0400)]
Merge pull request #8791 from LabNConsulting/chopps/backport-always-batch

northbound: KISS always batch yang config (file read), it's faster

3 years agoMerge pull request #8786 from pjdruddy/backport_ospf6_socket_non_blocking_read
Rafael Zalamena [Mon, 7 Jun 2021 12:41:46 +0000 (09:41 -0300)]
Merge pull request #8786 from pjdruddy/backport_ospf6_socket_non_blocking_read

Backport ospf6 socket non blocking read

3 years agoMerge pull request #8799 from FRRouting/mergify/bp/dev/8.0/pr-8706
Mark Stapp [Mon, 7 Jun 2021 11:54:21 +0000 (07:54 -0400)]
Merge pull request #8799 from FRRouting/mergify/bp/dev/8.0/pr-8706

lib: fix threading bug in GRPC code (backport #8706)

3 years agolib: fix threading bug in GRPC code 8799/head
Christian Hopps [Thu, 20 May 2021 06:50:34 +0000 (06:50 +0000)]
lib: fix threading bug in GRPC code

The code that actually calls FRR northbound functions needs to be running in the
master thread. The previous code was running on a GRPC pthread. While fixing
moved to more functional vs OOP to make this easier to see.

Also fix ly merge to merge siblings not throw the originals away.

Signed-off-by: Christian Hopps <chopps@labn.net>
(cherry picked from commit b680134e1122cdbb67f5c6ed158ee712255ee3cc)

3 years agoMerge pull request #8787 from mjstapp/fix_zmq_xref_8_0
Rafael Zalamena [Fri, 4 Jun 2021 17:41:37 +0000 (14:41 -0300)]
Merge pull request #8787 from mjstapp/fix_zmq_xref_8_0

lib: [8.0] fix use of xrefs in zmq wrapper

3 years agonorthbound: KISS always batch yang config (file read), it's faster 8791/head
Christian Hopps [Fri, 28 May 2021 19:16:18 +0000 (19:16 +0000)]
northbound: KISS always batch yang config (file read), it's faster

The backoff code assumed that yang operations always completed quickly.
It checked for > 100 YANG modeled commands happening in under 1 second
to enable batching. If 100 yang modeled commands always take longer than
1 second batching is never enabled. This is the exact opposite of what
we want to happen since batching speeds the operations up.

Here are the results for libyang2 code without and with batching.

| action        |  1K rts |  2K rts | 1K rts | 2K rts | 20k rts |
|               | nobatch | nobatch |  batch |  batch |   batch |
| Add IPv4      |    .881 |    1.28 |   .703 |   1.04 |    8.16 |
| Add Same IPv4 |    28.7 |     113 |   .590 |   .860 |    6.09 |
| Rem 1/2 IPv4  |    .376 |    .442 |   .379 |   .435 |    1.44 |
| Add Same IPv4 |    28.7 |     113 |   .576 |   .841 |    6.02 |
| Rem All IPv4  |    17.4 |    71.8 |   .559 |   .813 |    5.57 |

(IPv6 numbers are basically the same as iPv4, a couple percent slower)

Clearly we need this. Please note the growth (1K to 2K) w/o batching is
non-linear and 100 times slower than batched.

Notes on code: The use of the new `nb_cli_apply_changes_clear_pending`
is to commit any pending changes (including the current one). This is
done when the code would not correctly handle a single diff that
included the current changes with possible following changes. For
example, a "no" command followed by a new value to replace it would be
merged into a change, and the code would not deal well with that. A good
example of this is BGP neighbor peer-group changing. The other use is
after entering a router level (e.g., "router bgp") where the follow-on
command handlers expect that router object to now exists. The code
eventually needs to be cleaned up to not fail in these cases, but that
is for future NB cleanup.

Signed-off-by: Christian Hopps <chopps@labn.net>
3 years agolib: logic and macro cleanup in frr_zmq shim 8787/head
Mark Stapp [Tue, 6 Apr 2021 18:41:45 +0000 (14:41 -0400)]
lib: logic and macro cleanup in frr_zmq shim

Fix a couple of logic/macro issues in the frr_zmq shim
module.

Signed-off-by: Mark Stapp <mjs@voltanet.io>
3 years agolib: use public task-scheduling apis
Mark Stapp [Tue, 6 Apr 2021 18:40:39 +0000 (14:40 -0400)]
lib: use public task-scheduling apis

The frr_zmq shim was trying to use some internal scheduling
macros, and that was causing trouble. Just use the public
apis.

Signed-off-by: Mark Stapp <mjs@voltanet.io>
3 years agoospf6d: read ospf6 socket until failure 8786/head
Pat Ruddy [Wed, 3 Mar 2021 11:59:30 +0000 (11:59 +0000)]
ospf6d: read ospf6 socket until failure

To ensure we read all the datagrams availabe from a socket when the
read task is scheduled, make the read helper return and error or
continue enum and loop unitl an error is received.
This requires the read from the socket to be non blocking

Signed-off-by: Pat Ruddy <pat@voltanet.io>
3 years agoospf6d: create an ospf_read_helper function
Pat Ruddy [Wed, 3 Mar 2021 11:17:38 +0000 (11:17 +0000)]
ospf6d: create an ospf_read_helper function

Take the contents of ospf6_receive and split the funtionality that
deals with a single packet receipt and place it in a separate helper
function.
This is the first step in a refactor process to allow the ospf6_read
task to read until failure.

Signed-off-by: Pat Ruddy <pat@voltanet.io>
3 years agoMerge pull request #8774 from FRRouting/mergify/bp/dev/8.0/pr-8769
Mark Stapp [Wed, 2 Jun 2021 12:29:59 +0000 (08:29 -0400)]
Merge pull request #8774 from FRRouting/mergify/bp/dev/8.0/pr-8769

lib: Time to remove CONFDATE block (backport #8769)

3 years agolib: Time to remove CONFDATE block 8774/head
Donatas Abraitis [Tue, 1 Jun 2021 07:07:58 +0000 (10:07 +0300)]
lib: Time to remove CONFDATE block

Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
(cherry picked from commit ef3b48cfe1c2516c6c6490fc38682a7f640b534b)

3 years agoMerge pull request #8766 from idryzhov/8.0-backports-05
Donald Sharp [Tue, 1 Jun 2021 12:14:44 +0000 (08:14 -0400)]
Merge pull request #8766 from idryzhov/8.0-backports-05

8.0 backports

3 years agoospf6: fix memory leak in ospf6_abr_examin_summary 8766/head
Pat Ruddy [Tue, 25 May 2021 08:38:26 +0000 (09:38 +0100)]
ospf6: fix memory leak in ospf6_abr_examin_summary

Ensure that if allocated route is not added to a table then it is
deleted to avoid leaking memory.
Add a new memory type for route table so that ospf6 routes can be
distinguished in the show memory output in isolation.

Signed-off-by: Pat Ruddy <pat@voltanet.io>
3 years agostaticd: return SUCCESS when deleting non-existent route
Mark Stapp [Wed, 26 May 2021 18:30:51 +0000 (14:30 -0400)]
staticd: return SUCCESS when deleting non-existent route

Return SUCCESS if trying to delete route that doesn't exist.
This was always staticd's behavior before the northbound
conversion.

Signed-off-by: Mark Stapp <mjs@voltanet.io>
3 years agogrpc: improve checks for GRPC C++ requirements
Christian Hopps [Thu, 20 May 2021 06:46:34 +0000 (06:46 +0000)]
grpc: improve checks for GRPC C++ requirements

Signed-off-by: Christian Hopps <chopps@labn.net>
3 years agodocker: fix ubuntu containers
Igor Ryzhov [Thu, 27 May 2021 12:57:03 +0000 (15:57 +0300)]
docker: fix ubuntu containers

Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
3 years agoRevert "build: libyangv2 is mainlined, update"
Igor Ryzhov [Thu, 27 May 2021 12:56:06 +0000 (15:56 +0300)]
Revert "build: libyangv2 is mainlined, update"

This partially reverts commit 250335d47cc338fa1951494a9b78bf429016a7e5.

Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
3 years agobuild: libyangv2 is mainlined, update
Christian Hopps [Thu, 27 May 2021 10:28:01 +0000 (10:28 +0000)]
build: libyangv2 is mainlined, update

Signed-off-by: Christian Hopps <chopps@gmail.com>
3 years agoospf6d: Fix route map "set tag" command
Martin Buck [Wed, 26 May 2021 14:03:51 +0000 (16:03 +0200)]
ospf6d: Fix route map "set tag" command

So far, "set tag" was 99% implemented in ospf6d, but registration of the
hook functions was missing, causing "set tag" actions in route maps to be
ignored in ospf6d.

This commit adds the missing hook registration.

Signed-off-by: Martin Buck <mb-tmp-tvguho.pbz@gromit.dyndns.org>
3 years agogrpc: improve checks for GRPC C++ requirements
Christian Hopps [Thu, 20 May 2021 06:46:34 +0000 (06:46 +0000)]
grpc: improve checks for GRPC C++ requirements

Signed-off-by: Christian Hopps <chopps@labn.net>
3 years agoospf6d: fix debug message config write
Igor Ryzhov [Wed, 26 May 2021 08:48:09 +0000 (11:48 +0300)]
ospf6d: fix debug message config write

Fix the following issues:
- if "send" is combined with "recv-hdr", only "send" is shown
- if "recv" is combined with "send-hdr", only "recv" is shown
- if both "send-hdr" and "recv-hdr" are enabled, "; header only" is shown

Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
3 years agoospf6d: fix invalid "no debug ospf6 message unknown"
Igor Ryzhov [Wed, 26 May 2021 08:45:07 +0000 (11:45 +0300)]
ospf6d: fix invalid "no debug ospf6 message unknown"

The message is always shown in the config, because IS_OSPF6_DEBUG_MESSAGE
works incorrectly when negated because of missing outer brackets.

Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
3 years agoospf6d: fix possible crashes
Igor Ryzhov [Tue, 25 May 2021 18:58:55 +0000 (21:58 +0300)]
ospf6d: fix possible crashes

OSPF6 instance may not exist when processing interface state change.
Do not execute processing steps that require an instance if an area is
not configured for an interface.

Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
3 years agostaticd: fix distance processing
Igor Ryzhov [Tue, 25 May 2021 12:49:46 +0000 (15:49 +0300)]
staticd: fix distance processing

When the user adds the route + nexthop pair that already exists with a
different distance, we should replace it instead of adding a new one.

Likewise, when the user wants to delete the route + nexthop pair without
explicitly entering the distance, we should delete the route.

Fixes #8695.

Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
3 years agoospfd: Fix quick interface down up event handling in ospf
Donald Sharp [Mon, 24 May 2021 17:45:29 +0000 (13:45 -0400)]
ospfd: Fix quick interface down up event handling in ospf

When we get this sequence of events:

- zebra receives interface up, sends to ospf
- ospf receives intf up, processes( including neighbor formation and spf )
  and sends route to zebra for installation.
- zebra receives route for processing, schedules it too happen in the future
- zebra receives interface down event, sends to ospf
- zebra processes route X and marks it inactive because nexthop
  interface is down
- zebra receives interface up event, sends to ospf
- ospf receives both events and processes the change and decides
  that nothing has changed so it does not send any route change for X to zebra.

At this point zebra has a route from ospf that is marked as inactive, while
ospf believes that the route should be installed properly.

Modify the code such that on an interface down event, ospf marks the routes
as changed if the ifindex is being used for a nexthop, so that when ospf
is deciding if routes have changed post spf that it can just automatically
send that route down again if it still exists.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
3 years agodoc: remove "no" commands
Igor Ryzhov [Mon, 24 May 2021 15:38:48 +0000 (18:38 +0300)]
doc: remove "no" commands

Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
3 years agoospf6d: fix address sanitizer crash
Rafael Zalamena [Mon, 24 May 2021 11:30:26 +0000 (08:30 -0300)]
ospf6d: fix address sanitizer crash

Don't `memcpy` a `struct prefix` the memory size varies depending on the
original intended type. In this case the original type was (casted away)
`struct prefix_ipv6` and we tried to copy `struct prefix` which is
bigger.

Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
3 years agolib: fix missing newline
Igor Ryzhov [Mon, 24 May 2021 10:26:49 +0000 (13:26 +0300)]
lib: fix missing newline

Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
3 years agoisisd: fix missing VRF parameter
Igor Ryzhov [Fri, 21 May 2021 17:13:51 +0000 (20:13 +0300)]
isisd: fix missing VRF parameter

It was incorrectly removed in 1cbf96a.

Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
3 years agobgpd: fix aggregate-address command
Igor Ryzhov [Fri, 21 May 2021 17:10:41 +0000 (20:10 +0300)]
bgpd: fix aggregate-address command

Additional parameters are not mandatory.

Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
3 years agodoc: expand documentation on gRPC
Christian Hopps [Thu, 20 May 2021 14:03:37 +0000 (14:03 +0000)]
doc: expand documentation on gRPC

Add C++ and Python examples, and add compiling info, and known gRPC
version that works.

Signed-off-by: Christian Hopps <chopps@gmail.com>
3 years agoospfd: "ip ospf area" command can select wrong process
Don Slice [Wed, 19 May 2021 18:23:28 +0000 (14:23 -0400)]
ospfd: "ip ospf area" command can select wrong process

Found that in some circumstances, when the "ip ospf area"
command was entered for the default vrf, the wrong ospf
process would be used to check for the presence of a
"network" statement, causing the "ip ospf area" command to
be rejected. This was due to the command using the ospf
instance lookup to find the right ospf process, which can
be in error depending on when the processes were created.

Signed-off-by: Don Slice <dslice@nvidia.com>
3 years agolib: fix northbound merge code (libyang)
Christian Hopps [Thu, 20 May 2021 06:49:32 +0000 (06:49 +0000)]
lib: fix northbound merge code (libyang)

lyd_merge_tree replaces dest siblings with source siblings, not what we
want. Instead lyd_merge_siblings to keep both. Instead lyd_merge_siblings
to keep both.

Signed-off-by: Christian Hopps <chopps@labn.net>
3 years agoospfd: New code adds newline to log files
Donald Sharp [Wed, 19 May 2021 18:51:23 +0000 (14:51 -0400)]
ospfd: New code adds newline to log files

FRR is not using newlines in log messages.  Remove them.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
3 years agopbrd: fix coverity warning
Igor Ryzhov [Wed, 19 May 2021 13:24:21 +0000 (16:24 +0300)]
pbrd: fix coverity warning

CID 1500586

There was an attempt to fix it in 920bb6f7 but the commit didn't
actually fix the warning.

Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
3 years agolib: fix coverity warnings
Igor Ryzhov [Wed, 19 May 2021 12:53:16 +0000 (15:53 +0300)]
lib: fix coverity warnings

CID 1504894

Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
3 years agozebra: fix possible uninitialized value
Igor Ryzhov [Wed, 19 May 2021 11:59:00 +0000 (14:59 +0300)]
zebra: fix possible uninitialized value

Found by Coverity.

Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
3 years agobgpd: fix zebra bfd registration
Igor Ryzhov [Tue, 18 May 2021 20:31:52 +0000 (23:31 +0300)]
bgpd: fix zebra bfd registration

If there's no default router configured at the moment when bgpd is
connected to zebra, bgpd is not registered as a BFD client.

We should do the registration regardless of the config existence.

Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
3 years agoospfd: fix SID/Label Sub TLV size
Igor Ryzhov [Tue, 18 May 2021 15:25:14 +0000 (18:25 +0300)]
ospfd: fix SID/Label Sub TLV size

Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
3 years agobgpd: raise privs for SO_BINDTODEVICE
Igor Ryzhov [Tue, 18 May 2021 14:07:06 +0000 (17:07 +0300)]
bgpd: raise privs for SO_BINDTODEVICE

The priv raise was incorrectly dropped in 97896a9.

Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
3 years agodoc: remove redundant index directives
Igor Ryzhov [Tue, 18 May 2021 12:29:59 +0000 (15:29 +0300)]
doc: remove redundant index directives

Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
3 years agotests: Fix for multicast_pim_sm failure
Kuldeep Kashyap [Tue, 18 May 2021 01:50:49 +0000 (18:50 -0700)]
tests: Fix for multicast_pim_sm failure

Test case test_verify_mroute_when_5_different_receiver_joining_same_sources_p0
is failing intermittently in master. Fixed the issue.

Signed-off-by: Kuldeep Kashyap <kashyapk@vmware.com>
3 years agoospf6d: fix "default-information originate" in non-existing vrf
Igor Ryzhov [Mon, 17 May 2021 22:24:22 +0000 (01:24 +0300)]
ospf6d: fix "default-information originate" in non-existing vrf

If the default route redistribution is configured in OSPF6 router before
the VRF is created, then this is not currently registered in zebra after
the VRF creation.

Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
3 years agoospfd: fix "default-information originate" in non-existing vrf
Igor Ryzhov [Mon, 17 May 2021 22:23:35 +0000 (01:23 +0300)]
ospfd: fix "default-information originate" in non-existing vrf

If the default route redistribution is configured in OSPF router before
the VRF is created, then this is not currently registered in zebra after
the VRF creation.

Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
3 years agoisisd: fix build warning and simplify code
Igor Ryzhov [Mon, 17 May 2021 10:07:24 +0000 (13:07 +0300)]
isisd: fix build warning and simplify code

Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
3 years agopimd: Fix rare crash situation
Donald Sharp [Fri, 14 May 2021 13:46:36 +0000 (09:46 -0400)]
pimd: Fix rare crash situation

When running pim on an interface and that interface has
state and we move that interface into a different vrf
there exists a call path where we have not created the pimreg
device yet.  Prevent a crash in this rare situation.

Ticket: #2552763
Signed-off-by: Donald Sharp <sharpd@nvidia.com>
3 years agopimd: When bind fails give some extra data
Donald Sharp [Fri, 14 May 2021 13:44:12 +0000 (09:44 -0400)]
pimd: When bind fails give some extra data

When bind to a socket fails, let's give some color so we can
understand and fix the issue.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
3 years agopathd: Fix affinity command to exclude options to match implementation.
Javier Garcia [Thu, 13 May 2021 11:38:41 +0000 (13:38 +0200)]
pathd: Fix affinity command to exclude options to match implementation.

Including documentation update.

Signed-off-by: Javier Garcia <javier.garcia@voltanet.io>
3 years agopathd: Clean coverity issues after merge pathd link state feature.
Javier Garcia [Thu, 13 May 2021 11:17:44 +0000 (13:17 +0200)]
pathd: Clean coverity issues after merge pathd link state feature.

Signed-off-by: Javier Garcia <javier.garcia@voltanet.io>
3 years agotests: fix bgp_l3vpn_to_bgp_vrf
Igor Ryzhov [Wed, 12 May 2021 15:55:40 +0000 (18:55 +0300)]
tests: fix bgp_l3vpn_to_bgp_vrf

Too many arguments for format string.

Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
3 years agoospf6d: free "default-information originate" config when removing router
Igor Ryzhov [Fri, 7 May 2021 14:53:13 +0000 (17:53 +0300)]
ospf6d: free "default-information originate" config when removing router

Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
3 years agoospf6d: fix crash when removing router from vrf that doesn't exist
Igor Ryzhov [Fri, 7 May 2021 14:52:41 +0000 (17:52 +0300)]
ospf6d: fix crash when removing router from vrf that doesn't exist

`listgetdata(listhead(list))` crashes for an empty list.

Reproducible with:
```
router ospf6 vrf doesntexist
 default-information originate always
 exit
no router ospf6 vrf doesntexist
```

Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
3 years agoospf6d: always free redistribute config
Igor Ryzhov [Fri, 7 May 2021 14:05:40 +0000 (17:05 +0300)]
ospf6d: always free redistribute config

When the ospf6 instance in unknown VRF is deleted, the redistribution
config is not freed, because it is not registered in zebra. We should
always free the config regardless of zebra registration status.

Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
3 years agoisisd: fix dangling instances
Igor Ryzhov [Sun, 9 May 2021 13:43:29 +0000 (16:43 +0300)]
isisd: fix dangling instances

We only need an instance when we have at least one area configured in a
VRF. Currently we have the following issues:
- instance for the default VRF is always created
- instance is not removed after the last area config is removed

This commit fixes both issues.

Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
3 years agoisisd: fix memleak when deleting area and instance
Igor Ryzhov [Sun, 9 May 2021 13:09:38 +0000 (16:09 +0300)]
isisd: fix memleak when deleting area and instance

Release memory for all redistributed route info.

Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
3 years agoisisd: fix redistribution in vrf
Igor Ryzhov [Tue, 4 May 2021 21:10:31 +0000 (00:10 +0300)]
isisd: fix redistribution in vrf

When the redistribution is configured in non-default VRF, isisd should
redistribute routes from this VRF instead of default.

Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
3 years agoisisd: fix "default-information originate always"
Igor Ryzhov [Sun, 9 May 2021 14:07:39 +0000 (17:07 +0300)]
isisd: fix "default-information originate always"

We don't need to register for default routes from zebra, when the
origination type is set to "always".

Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
3 years agoisisd: deregister vrf from zebra when vrf is disabled
Igor Ryzhov [Tue, 4 May 2021 18:58:23 +0000 (21:58 +0300)]
isisd: deregister vrf from zebra when vrf is disabled

Currently the VRF is deregistered only when it is re-enabled again.

Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
3 years agopimd: Remove pim->vrf_id and use pim->vrf->vrf_id
Donald Sharp [Wed, 12 May 2021 18:31:45 +0000 (14:31 -0400)]
pimd: Remove pim->vrf_id and use pim->vrf->vrf_id

VRF creation can happen from either cli or from
knowledged about the vrf learned from zebra.
In the case where we learn about the vrf from
the cli, the vrf id is UNKNOWN.  Upon actual
creation of the vrf, lib/vrf.c touches up the vrf_id
and calls pim_vrf_enable to turn it on properly.
At this point in time we have a pim->vrf_id of
UNKNOWN and the vrf->vrf_id of the right value.

There is no point in duplicating this data.  So just
remove all pim->vrf_id and use the vrf->vrf_id instead
since we keep a copy of the pim->vrf pointer.

This will remove some crashes where we expect the
pim->vrf_id to be usable and it's not.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
3 years agopimd: There exists a path where on vrf bringup we do not create the pimreg
Donald Sharp [Mon, 3 May 2021 18:39:47 +0000 (14:39 -0400)]
pimd: There exists a path where on vrf bringup we do not create the pimreg

When creating configuration for a vrf *Before* the vrf has been
created, pim will not properly create the pimreg device and
we will promptly crash when we try to pass data.

Put some code checks in place to ensure that the pimreg is
created for vrf's.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
3 years agoospfd: Correct Coverity defects
Olivier Dugeon [Tue, 6 Apr 2021 10:09:25 +0000 (12:09 +0200)]
ospfd: Correct Coverity defects

When browsing or parsing OSPF LSA TLVs, we need to use the LSA length which is
part of the LSA header. This length, encoded in 16 bits, must be first
converted to host byte order with ntohs() function. However, Coverity Scan
considers that ntohs() function return TAINTED data. Thus, when the length is
used to control for() loop, Coverity Scan marks this part of the code as defect
with "Untrusted Loop Bound" due to the usage of Tainted variable. Similar
problems occur when browsing sub-TLV where length is extracted with ntohs().

To overcome this limitation, a size attribute has been added to the ospf_lsa
structure. The size is set when lsa->data buffer is allocated. In addition,
when an OSPF packet is received, the size of the payload is controlled before
contains is processed. For OSPF LSA, this allow a secure buffer allocation.
Thus, new size attribute contains the exact buffer allocation allowing a
strict control during TLV browsing.

This patch adds extra control to bound for() loop during TLV browsing to
avoid potential problem as suggested by Coverity Scan. Controls are based
on new size attribute of the ospf_lsa structure to avoid any ambiguity.

Signed-off-by: Olivier Dugeon <olivier.dugeon@orange.com>
3 years agoMerge pull request #8743 from taspelund/fix_pfx-tree_default_8.0
Igor Ryzhov [Thu, 27 May 2021 07:14:09 +0000 (10:14 +0300)]
Merge pull request #8743 from taspelund/fix_pfx-tree_default_8.0

[8.0] lib: fix handling of rmap prefix-tree default node

3 years agolib: fix handling of rmap prefix-tree default node 8743/head
Trey Aspelund [Fri, 21 May 2021 22:04:15 +0000 (22:04 +0000)]
lib: fix handling of rmap prefix-tree default node

Prior to this commit, updating a prefix-list that is referenced by a
route-map clause will unconditionally delete the root node of that
route-map's prefix-tree (used with route-map optimization).
This is problematic because routes not matching a more specific node
in the tree (i.e. other prefix-list sequences) will not fall-back to
the default node, thus they will not hit any route-map sequences.
This commit ensures that an update to a prefix-list will only delete
the default node while adding the first/only seq to the list.

Example config:
========
ip prefix-list peer475-out-pfxlist seq 45 permit 2.138.0.0/16
ip prefix-list peer475-out-pfxlist seq 50 permit 0.0.0.0/0
!
route-map peer475-out permit 5
 match ip address prefix-list peer475-out-pfxlist

Before:
========
ub20# do show route-map peer475-out prefix-table
ZEBRA:

IPv4 Prefix                                           Route-map Index List
_______________                                       ____________________
    0.0.0.0/0 (2)
(P)
                                                      peer475-out seq 5

    2.138.0.0/16 (2)
(P) 0.0.0.0/0

                                                      peer475-out seq 5
IPv6 Prefix                                           Route-map Index List
_______________                                       ____________________
BGP:
IPv4 Prefix                                           Route-map Index List
_______________                                       ____________________
    0.0.0.0/0 (2)
(P)
                                                      peer475-out seq 5
    2.138.0.0/16 (2)
(P) 0.0.0.0/0
                                                      peer475-out seq 5
IPv6 Prefix                                           Route-map Index List
_______________                                       ____________________
ub20# conf t
ub20(config)# ip prefix-list peer475-out-pfxlist seq 45 permit 2.138.0.0/16 le 32
ub20(config)# do show route-map peer475-out prefix-table
ZEBRA:
IPv4 Prefix                                           Route-map Index List
_______________                                       ____________________
    2.138.0.0/16 (2)
(P)
                                                      peer475-out seq 5
IPv6 Prefix                                           Route-map Index List
_______________                                       ____________________
BGP:
IPv4 Prefix                                           Route-map Index List
_______________                                       ____________________
    2.138.0.0/16 (2)
(P)
                                                      peer475-out seq 5
IPv6 Prefix                                           Route-map Index List
_______________                                       ____________________
ub20(config)#

After:
========
ub20(config)# do show route-map peer475-out prefix-table
ZEBRA:

IPv4 Prefix                                           Route-map Index List
_______________                                       ____________________
    0.0.0.0/0 (2)
(P)
                                                      peer475-out seq 5

    2.138.0.0/16 (2)
(P) 0.0.0.0/0

                                                      peer475-out seq 5

IPv6 Prefix                                           Route-map Index List
_______________                                       ____________________

BGP:

IPv4 Prefix                                           Route-map Index List
_______________                                       ____________________
    0.0.0.0/0 (2)
(P)
                                                      peer475-out seq 5

    2.138.0.0/16 (2)
(P) 0.0.0.0/0

                                                      peer475-out seq 5

IPv6 Prefix                                           Route-map Index List
_______________                                       ____________________

ub20(config)# ip prefix-list peer475-out-pfxlist seq 45 permit 2.138.0.0/16 le 32
ub20(config)# do show route-map peer475-out prefix-table
ZEBRA:

IPv4 Prefix                                           Route-map Index List
_______________                                       ____________________
    0.0.0.0/0 (2)
(P)
                                                      peer475-out seq 5

    2.138.0.0/16 (2)
(P) 0.0.0.0/0

                                                      peer475-out seq 5

IPv6 Prefix                                           Route-map Index List
_______________                                       ____________________

BGP:

IPv4 Prefix                                           Route-map Index List
_______________                                       ____________________
    0.0.0.0/0 (2)
(P)
                                                      peer475-out seq 5

    2.138.0.0/16 (2)
(P) 0.0.0.0/0

                                                      peer475-out seq 5

IPv6 Prefix                                           Route-map Index List
_______________                                       ____________________

ub20(config)#

Fixes: 8410
Signed-off-by: Trey Aspelund <taspelund@nvidia.com>
(cherry picked from commit 4718791c8f7101379f99fa7174e8ccaf80573433)

3 years agoMerge pull request #8717 from idryzhov/8.0-fix-missing-commands
Donald Sharp [Mon, 24 May 2021 10:47:32 +0000 (06:47 -0400)]
Merge pull request #8717 from idryzhov/8.0-fix-missing-commands

[8.0] bgpd: fix missing command installations

3 years agobgpd: fix missing command installations 8717/head
Igor Ryzhov [Fri, 21 May 2021 17:11:41 +0000 (20:11 +0300)]
bgpd: fix missing command installations

They were missed during BGP NB revert.

Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
3 years agoMerge pull request #8670 from idryzhov/bgp-nb-revert
Donald Sharp [Thu, 20 May 2021 15:26:32 +0000 (11:26 -0400)]
Merge pull request #8670 from idryzhov/bgp-nb-revert

[8.0] BGP NB revert

3 years agoMerge pull request #8702 from donaldsharp/dc_80
Donatas Abraitis [Thu, 20 May 2021 06:29:01 +0000 (09:29 +0300)]
Merge pull request #8702 from donaldsharp/dc_80

bgpd: recalc peer's sort after changing confed peers