]> git.puffer.fish Git - mirror/frr.git/log
mirror/frr.git
6 years agozebra: unlock route-node when processing dplane results 3852/head
Mark Stapp [Thu, 21 Feb 2019 21:41:24 +0000 (16:41 -0500)]
zebra: unlock route-node when processing dplane results

Unlock the route-node datastruct we access while processing
results from the async dataplane. [7.0]

Signed-off-by: Mark Stapp <mjs@voltanet.io>
6 years agoMerge pull request #3818 from pguibert6WIND/70_donotcrash_when_config_l3vpn
Donald Sharp [Tue, 19 Feb 2019 18:11:23 +0000 (13:11 -0500)]
Merge pull request #3818 from pguibert6WIND/70_donotcrash_when_config_l3vpn

bgpd: do not crash when removing ip vpn entries

6 years agoMerge pull request #3828 from opensourcerouting/7.0-assorted-fixes
Donald Sharp [Tue, 19 Feb 2019 18:10:10 +0000 (13:10 -0500)]
Merge pull request #3828 from opensourcerouting/7.0-assorted-fixes

[7.0] Assorted fixes

6 years agoMerge pull request #3833 from opensourcerouting/requires_initscript
Donald Sharp [Tue, 19 Feb 2019 18:09:34 +0000 (13:09 -0500)]
Merge pull request #3833 from opensourcerouting/requires_initscript

Revert "redhat: don't Requires initscript on systemd based distros"

6 years agoMerge pull request #3815 from opensourcerouting/7.0/doc-pager-theme
Quentin Young [Tue, 19 Feb 2019 17:41:35 +0000 (12:41 -0500)]
Merge pull request #3815 from opensourcerouting/7.0/doc-pager-theme

[7.0] doc: VTYSH_PAGER docs + new FRR theme

6 years agoMerge pull request #3819 from pguibert6WIND/cve_2017_3224
Jafar Al-Gharaibeh [Tue, 19 Feb 2019 16:25:27 +0000 (10:25 -0600)]
Merge pull request #3819 from pguibert6WIND/cve_2017_3224

ospfd: address CVE-2017-3224

6 years agoRevert "redhat: don't Requires initscript on systemd based distros" 3833/head
Liam McBirnie [Fri, 1 Feb 2019 09:55:27 +0000 (19:55 +1000)]
Revert "redhat: don't Requires initscript on systemd based distros"

This reverts commit ec59a1559cce612d04131639653eddf65d69e868.

Frr.init (called by frr.service) requires functions provided by
/etc/init.d/functions (part of the initscripts package).

Signed-off-by: Liam McBirnie <liam.mcbirnie@boeing.com>
6 years agoMerge pull request #3820 from pguibert6WIND/70_ospfv3_misc_fixes
David Lamparter [Tue, 19 Feb 2019 12:52:48 +0000 (13:52 +0100)]
Merge pull request #3820 from pguibert6WIND/70_ospfv3_misc_fixes

ospfv3 misc fixes

6 years agozebra: fix the "show ip import-check" command 3828/head
Renato Westphal [Thu, 17 Jan 2019 22:55:39 +0000 (20:55 -0200)]
zebra: fix the "show ip import-check" command

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
6 years agopython: make DEFPY provide the text token of fixed parameters
Renato Westphal [Sat, 19 Jan 2019 19:24:09 +0000 (17:24 -0200)]
python: make DEFPY provide the text token of fixed parameters

In the CLI code, each cmd_token has both a "text" field, containing
the full token text (e.g. "unicast"), and an "arg" field,
containing the original text entered by the user (which might be
an abbreviation, like "uni" instead of "unicast").

To avoid the need to handle abbreviations, the recommended pattern
for DEFUN commands is to use the "text" value of fixed parameters
and the "arg" value of everything else.

Using DEFPY, however, the CLI parameters are automagically turned
into C variables which are initialized under the hood (so that
they're conveniently ready for use). The problem is that this
initialization was always using the "arg" value of the parameters,
which was leading to problems like these:

  debian# show ipv6 route isi
  Unknown route type
  debian#
  debian# conf t
  debian(config)# router isis 1
  debian(config-router)# redistribute ipv4 st level-1
  % Configuration failed.

  Invalid value "st" in "protocol" element.
  YANG path: /frr-isisd:isis/instance[area-tag='1']/redistribute/ipv4[protocol='st']/protocol

To fix these problems (and probably others too), make DEFPY commands
auto-detect the type of the input parameters and use either the
"arg" or "text" value from the cmd_tokens accordingly.

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
6 years agolib: remove the vrf_is_mapped_on_netns() function
Renato Westphal [Sat, 19 Jan 2019 19:19:13 +0000 (17:19 -0200)]
lib: remove the vrf_is_mapped_on_netns() function

Now that all daemons receive the VRF backend from zebra, we can get
rid of vrf_is_mapped_on_netns() in favor of using the more convenient
vrf_is_backend_netns() function, which doesn't require any argument.

This commit also fixes the following problem:
  debian(config)# ip route 50.0.0.0/8 blackhole vrf FAKE table 2
  % table param only available when running on netns-based vrfs

Even when zebra was started with the --vrfwnetns, the error
above would be displayed since the VRF FAKE didn't exist, which
would make vrf_is_mapped_on_netns() return 0 incorrectly. Using
vrf_is_backend_netns() this problem doesn't happen anymore.

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
6 years agozebra, lib: send VRF backend to the client daemons
Renato Westphal [Sat, 19 Jan 2019 19:19:13 +0000 (17:19 -0200)]
zebra, lib: send VRF backend to the client daemons

Add a new field in the ZEBRA_CAPABILITIES zapi message specifying
the VRF backend in use.

For simplicity, make the zclient code call vrf_configure_backend()
to apply the received value automatically instead of requiring
the daemons to do that themselves in their zebra_capabilities()
callbacks.

Additionally, call zebra_vrf_update_all() only after sending the
capabilities message to the client, so that it will know which VRF
backend is in use when processing the VRF messages.

This commit fixes a couple of bugs in the "interface" CLI command and
associated northbound callbacks, which behave differently depending
on the VRF backend in use. Before this commit, the vrf_backend
variable would always be set to VRF_BACKEND_NETNS in the client
daemons, even when zebra was started without the --vrfwnetns option.
This could lead to inconsistent behavior and subtle bugs under
specific circumstances.

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
6 years agolib: simplify detection of when the user is leaving the CLI config mode
Renato Westphal [Sat, 19 Jan 2019 01:23:45 +0000 (23:23 -0200)]
lib: simplify detection of when the user is leaving the CLI config mode

We can make use of the vty->config variable to know when the CLI
user is in the configuration mode or not. This is much simpler
than obtaining this information from the vty node, and also a more
robust solution (the three switch statements below, for example,
were out of sync).

Also, fix a bug where vty->config wasn't being unset in the
vty_config_exit() function (bug introduced by commit f344c66ea3).

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
6 years agolib: reset the vty xpath index when entering the config mode
Renato Westphal [Sat, 19 Jan 2019 00:58:58 +0000 (22:58 -0200)]
lib: reset the vty xpath index when entering the config mode

The CLI code uses the vty->xpath[] array and the vty->xpath_index
variables to keep track of where the user is in the configuration
hierarchy. As such, we were resetting vty->xpath_index to zero
whenever the user exited from the configuration mode in order to
keep the index valid. We weren't doing this in the vty_stop_input()
function however, which is called when the user types ^C in the
terminal. This was leading to bugs like this:

  zebra> en
  zebra# conf t
  zebra(config)# interface eth0
  zebra(config-if)# ^C
  zebra# conf t
  zebra(config)# interface eth0
  % Configuration failed.

  Schema node not found.
  YANG path: /frr-interface:lib/interface[name='eth0'][vrf='default']/frr-interface:lib

To fix this, do something more clever: instead of resetting the
XPath index whenever the user exits from the configuration mode,
do that when the user enters in the configuration mode. This way
the XPath index needs to be reset in a single place only, not to
mention it's a more robust solution.

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
6 years agodoc: fix small inconsistencies in the table of zapi command values
Renato Westphal [Fri, 18 Jan 2019 18:06:00 +0000 (16:06 -0200)]
doc: fix small inconsistencies in the table of zapi command values

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
6 years agozebra: send link parameters to zclients once they request interface info
Renato Westphal [Fri, 18 Jan 2019 18:06:00 +0000 (16:06 -0200)]
zebra: send link parameters to zclients once they request interface info

We were sending ZEBRA_INTERFACE_LINK_PARAMS messages under the
following circumstances:
* New interface was created (via kernel or config);
* Interface went from down to up;
* Update in the link-params configuration.

Now also send ZEBRA_INTERFACE_LINK_PARAMS messages whenever a zclient
connects and sends a ZEBRA_INTERFACE_ADD request. Without this fix,
the client daemons don't receive interface link parameters if they
are configured in the zebra startup configuration.

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
6 years agolib: use the correct VRF ID when parsing INTERFACE_LINK_PARAMS messages
Renato Westphal [Fri, 18 Jan 2019 18:06:00 +0000 (16:06 -0200)]
lib: use the correct VRF ID when parsing INTERFACE_LINK_PARAMS messages

Bug found during code inspection.

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
6 years agolib: fix checking of clients subscribed to receive default routes
Renato Westphal [Fri, 18 Jan 2019 18:06:00 +0000 (16:06 -0200)]
lib: fix checking of clients subscribed to receive default routes

In these two functions, we were using VRF_DEFAULT instead of the
VRF ID passed as a parameter when checking if the given client
subscribed to receive default routes or not. This prevented the
"default-originate" command from ospfd/isisd from working correctly
under specific circumstances.

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
6 years agodoc: update build instructions for freebsd on how to obtain libyang
Renato Westphal [Mon, 14 Jan 2019 18:29:18 +0000 (16:29 -0200)]
doc: update build instructions for freebsd on how to obtain libyang

Unfortunately the first version of the FreeBSD libyang port contained
a bug in which the libyang pkginfo file wasn't being installed
correctly in the system, and this prevented the FRR build system from
detecting the library. This bug was already fixed months ago but some
FreeBSD package repositories still have the old bugged version of the
port. This means we can't suggest people to install libyang using
"pkg install" since this causes problems for most people. In this
case, suggest FreeBSD users to build and install libyang manually
as we suggest for other BSD platforms.

This commit should be reverted once all FreeBSD package repositories
are updated with the new version of the libyang port.

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
6 years agolib: update suggestions related to some northbound errors
Renato Westphal [Mon, 14 Jan 2019 18:29:18 +0000 (16:29 -0200)]
lib: update suggestions related to some northbound errors

Since commit 3a11599c, the FRR YANG modules are embedded inside the
binaries and no longer need to be loaded from the file system. This
way, it's impossible for the FRR binaries and YANG modules to be out
of sync anymore. As such, update the suggestions of the northbound
error codes.

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
6 years agolib: don't abort when incomplete xpath is given by the user
Renato Westphal [Mon, 14 Jan 2019 18:29:18 +0000 (16:29 -0200)]
lib: don't abort when incomplete xpath is given by the user

Instead of aborting when an incomplete xpath is given to the
nb_oper_data_iterate() function, just return an error so that the
callers have a chance to treat this error. Aborting based on invalid
user input is never the right thing to do.

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
6 years agolib: fix "use of uninitialised value" valgrind warning
Renato Westphal [Mon, 14 Jan 2019 18:29:18 +0000 (16:29 -0200)]
lib: fix "use of uninitialised value" valgrind warning

When FRR is built without the --enable-config-rollbacks option,
the nb_db_transaction_save() function does nothing and the
"transaction_id" output parameter is left uninitialized. For
this reason, all northbound clients should initialize the
"transaction_id" argument before calling nb_candidate_commit() or
nb_candidate_commit_apply() (except when a NULL pointer is given,
which is the case of the confd and sysrepo plugins).

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
6 years agolib: fix "may be used uninitialized" build warning
Renato Westphal [Mon, 14 Jan 2019 18:29:18 +0000 (16:29 -0200)]
lib: fix "may be used uninitialized" build warning

We are already handling all possible four cases from the "nb_event"
enumeration, so this problem can't happen in practice. Initialize the
"ref" variable to zero to silence the warning.

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
6 years agolib, zebra: add AFI parameter to the ZEBRA_REDISTRIBUTE_DEFAULT_* messages
Renato Westphal [Fri, 11 Jan 2019 21:20:13 +0000 (19:20 -0200)]
lib, zebra: add AFI parameter to the ZEBRA_REDISTRIBUTE_DEFAULT_* messages

Some daemons like ospfd and isisd have the ability to advertise a
default route to their peers only if one exists in the RIB. This
is what the "default-information originate" commands do when used
without the "always" parameter.

For that to work, these daemons use the ZEBRA_REDISTRIBUTE_DEFAULT_ADD
message to request default route information to zebra. The problem
is that this message didn't have an AFI parameter, so a default route
from any address-family would satisfy the requests from both daemons
(e.g. ::/0 would trigger ospfd to advertise a default route to its
peers, and 0.0.0.0/0 would trigger isisd to advertise a default route
to its IPv6 peers).

Fix this by adding an AFI parameter to the
ZEBRA_REDISTRIBUTE_DEFAULT_{ADD,DELETE} messages and making the
corresponding code changes.

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
6 years agoMerge pull request #3824 from opensourcerouting/isis-fix-3533
Donald Sharp [Tue, 19 Feb 2019 00:28:23 +0000 (19:28 -0500)]
Merge pull request #3824 from opensourcerouting/isis-fix-3533

[7.0] isisd: skip over deleted fragments

6 years agoisisd: skip over deleted fragments 3824/head
David Lamparter [Mon, 18 Feb 2019 20:34:06 +0000 (21:34 +0100)]
isisd: skip over deleted fragments

Since LSP fragments are also on our lspdb dict, lsp_tick() needs to skip
over them after calling lsp_destroy().  Otherwise it ends up accessing
free'd memory.

Fixes: #3533
Signed-off-by: David Lamparter <equinox@diac24.net>
6 years agoospf6d: reset the global ospf6 pointer 3820/head
Philippe Guibert [Fri, 15 Feb 2019 16:42:13 +0000 (17:42 +0100)]
ospf6d: reset the global ospf6 pointer

reset the global ospf6 pointer.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
6 years agoospf6d: upon interface deletion, the area if list may be updated
Philippe Guibert [Thu, 14 Feb 2019 13:04:45 +0000 (14:04 +0100)]
ospf6d: upon interface deletion, the area if list may be updated

there are some events where the list of interfaces per area should be
reviewed due to an interface is being removed. This fix avoids having
some memory leak.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
6 years agoospf6d: closing server socket when leaving ospf6d
Philippe Guibert [Thu, 14 Feb 2019 13:06:41 +0000 (14:06 +0100)]
ospf6d: closing server socket when leaving ospf6d

this commit brings consistency as it closes the socket used to carry
ospfv3 messages.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
6 years agoospf6d: unitialised buffer zone used by socket
Philippe Guibert [Thu, 14 Feb 2019 13:10:03 +0000 (14:10 +0100)]
ospf6d: unitialised buffer zone used by socket

a buffer zone is initialised, before being used by server socket.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
6 years agoospfd: address CVE-2017-3224 3819/head
Chirag Shah [Sat, 26 Jan 2019 01:21:24 +0000 (17:21 -0800)]
ospfd: address CVE-2017-3224

Based on the vulnerability mentioned in 793496 an attacker can craft an
LSA with MaxSequence number wtih invalid links and not set age to MAX_AGE
so the lsa would not be flush from the database.

To address the issue, check incoming LSA is MaxSeq but Age is not set
to MAX_AGE 3600, discard the LSA from processing it.
Based on  RFC-2328 , When a LSA update sequence reaches MaxSequence
number, it should be prematurely aged out from the database with age set
to MAX_AGE (3600).

Ticket:CM-18989
Reviewed By:
Testing Done:

Signed-off-by: Chirag Shah <chirag@cumulusnetworks.com>
6 years agobgpd: do not crash when removing ip vpn entries 3818/head
Philippe Guibert [Mon, 21 Jan 2019 16:19:53 +0000 (17:19 +0100)]
bgpd: do not crash when removing ip vpn entries

when removing bgp instance, the parsing of rm->info contexts must be
protected. Also, the main level of hierarchy of rds must not be
allocated more than once.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
6 years agodoc: document VTYSH_PAGER and "terminal paginate" 3815/head
David Lamparter [Mon, 18 Feb 2019 13:23:03 +0000 (14:23 +0100)]
doc: document VTYSH_PAGER and "terminal paginate"

Signed-off-by: David Lamparter <equinox@diac24.net>
6 years agodoc: orange FRR theme
David Lamparter [Mon, 18 Feb 2019 12:57:43 +0000 (13:57 +0100)]
doc: orange FRR theme

Signed-off-by: David Lamparter <equinox@diac24.net>
6 years agoMerge pull request #3784 from qlyoung/fix-aspath-prepend-heap-uaf-7.0
Renato Westphal [Wed, 13 Feb 2019 14:09:38 +0000 (12:09 -0200)]
Merge pull request #3784 from qlyoung/fix-aspath-prepend-heap-uaf-7.0

[7.0] bgpd: fix as-path prepend heap uaf

6 years agobgpd: fix as-path prepend heap uaf 3784/head
Quentin Young [Tue, 29 Jan 2019 16:13:39 +0000 (16:13 +0000)]
bgpd: fix as-path prepend heap uaf

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
6 years agoMerge pull request #3716 from qlyoung/fix-systemd-deps-7.0
David Lamparter [Mon, 11 Feb 2019 06:50:25 +0000 (07:50 +0100)]
Merge pull request #3716 from qlyoung/fix-systemd-deps-7.0

[7.0] tools: fix systemd dependency graph

6 years agoMerge pull request #3763 from opensourcerouting/snap-7.0
Donald Sharp [Sat, 9 Feb 2019 13:03:22 +0000 (08:03 -0500)]
Merge pull request #3763 from opensourcerouting/snap-7.0

[7.0] Snap Package Update for 7.0

6 years agoMerge pull request #3757 from manuhalo/log_hook_7.0
Renato Westphal [Sat, 9 Feb 2019 01:54:47 +0000 (23:54 -0200)]
Merge pull request #3757 from manuhalo/log_hook_7.0

[7.0] lib: add hooks for external logging function

6 years agosnapcraft: Add FabricD to Snap package 3763/head
Martin Winter [Thu, 7 Feb 2019 23:12:14 +0000 (15:12 -0800)]
snapcraft: Add FabricD to Snap package

Signed-off-by: Martin Winter <mwinter@opensourcerouting.org>
6 years agosnapcraft: Update bgpd to use newer rpki lib
Martin Winter [Thu, 7 Feb 2019 22:44:47 +0000 (14:44 -0800)]
snapcraft: Update bgpd to use newer rpki lib

Signed-off-by: Martin Winter <mwinter@opensourcerouting.org>
6 years agosnapcraft: Add missing staticd.conf.default
Martin Winter [Thu, 7 Feb 2019 15:07:25 +0000 (07:07 -0800)]
snapcraft: Add missing staticd.conf.default

Signed-off-by: Martin Winter <mwinter@opensourcerouting.org>
6 years agosnapcraft: Add libyang to snap package
Martin Winter [Thu, 17 Jan 2019 19:02:04 +0000 (11:02 -0800)]
snapcraft: Add libyang to snap package

Signed-off-by: Martin Winter <mwinter@opensourcerouting.org>
6 years agosnapcraft: Don't stage libc6
Martin Winter [Thu, 17 Jan 2019 19:01:05 +0000 (11:01 -0800)]
snapcraft: Don't stage libc6

Signed-off-by: Martin Winter <mwinter@opensourcerouting.org>
6 years agosnapcraft: Update RTRLIB to 0.6.3
Martin Winter [Thu, 17 Jan 2019 16:32:47 +0000 (08:32 -0800)]
snapcraft: Update RTRLIB to 0.6.3

Signed-off-by: Martin Winter <mwinter@opensourcerouting.org>
6 years agoMerge pull request #3663 from opensourcerouting/7.0/yang-embed-extensions
Donald Sharp [Fri, 8 Feb 2019 21:21:53 +0000 (16:21 -0500)]
Merge pull request #3663 from opensourcerouting/7.0/yang-embed-extensions

[7.0] yang: embed extensions

6 years agolib: add hooks for external logging function 3757/head
Emanuele Di Pascale [Fri, 25 Jan 2019 13:40:27 +0000 (14:40 +0100)]
lib: add hooks for external logging function

Signed-off-by: Emanuele Di Pascale <emanuele@voltanet.io>
6 years agoMerge pull request #3750 from opensourcerouting/7.0/rpki-fixes
Donald Sharp [Thu, 7 Feb 2019 22:24:22 +0000 (17:24 -0500)]
Merge pull request #3750 from opensourcerouting/7.0/rpki-fixes

[7.0] RPKI fixes

6 years agobgpd: fix crash when trying to remove non-existing rpki cache 3750/head
Marcel Röthke [Thu, 7 Feb 2019 16:16:19 +0000 (17:16 +0100)]
bgpd: fix crash when trying to remove non-existing rpki cache

Signed-off-by: Marcel Röthke <marcel.roethke@haw-hamburg.de>
6 years agobgpd: fix "show rpki cache-server" for ssh caches
Marcel Röthke [Thu, 7 Feb 2019 16:12:16 +0000 (17:12 +0100)]
bgpd: fix "show rpki cache-server" for ssh caches

Fix #3662

Signed-off-by: Marcel Röthke <marcel.roethke@haw-hamburg.de>
6 years agobgpd: make valgrind suppression more generic 3663/head
David Lamparter [Thu, 7 Feb 2019 15:25:33 +0000 (16:25 +0100)]
bgpd: make valgrind suppression more generic

No point in restriction the suppression that far down the call stack.

Signed-off-by: David Lamparter <equinox@diac24.net>
6 years agotools: fix systemd dependency graph 3716/head
Quentin Young [Wed, 6 Feb 2019 19:40:55 +0000 (19:40 +0000)]
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>
6 years agolib: yang: use common yang_ctx_new_setup()
David Lamparter [Mon, 4 Feb 2019 21:56:50 +0000 (22:56 +0100)]
lib: yang: use common yang_ctx_new_setup()

After creating a libyang context, we need to hook up our callback to use
embedded built-in modules.  I hadn't added this to the yang translator
code.

Also, ly_ctx_new fails if the search directory doesn't exist.  Since
that's not a hard error for us, work around that and ignore inaccessible
YANG_MODELS_DIR.  (This is needed for snap packages.)

Signed-off-by: David Lamparter <equinox@diac24.net>
6 years agoMerge pull request #3708 from pguibert6WIND/detach_vrf_labels_del_bgp_70
Donald Sharp [Thu, 31 Jan 2019 00:36:39 +0000 (19:36 -0500)]
Merge pull request #3708 from pguibert6WIND/detach_vrf_labels_del_bgp_70

[7.0] bgpd: detach vrf labels allocated, when removing bgp instance

6 years agobuild: fix a whole bunch of *FLAGS
David Lamparter [Wed, 30 Jan 2019 17:11:54 +0000 (18:11 +0100)]
build: fix a whole bunch of *FLAGS

- some target_CFLAGS that needed to include AM_CFLAGS didn't do so
- libyang/sysrepo/sqlite3/confd CFLAGS + LIBS weren't used at all
- consistently use $(FOO_CFLAGS) instead of @FOO_CFLAGS@
- 2 dependencies were missing for clippy

Signed-off-by: David Lamparter <equinox@diac24.net>
6 years agobuild, lib/yang: bake in extensions if possible
David Lamparter [Fri, 30 Nov 2018 20:42:25 +0000 (21:42 +0100)]
build, lib/yang: bake in extensions if possible

Starting with libyang 0.16.74, we can load internally embedded yang
extensions instead of going through the file system/dlopen.  Detect
support for this at build time and use if available.

NB: the fallback mechanism will go away in a short while.

Signed-off-by: David Lamparter <equinox@diac24.net>
6 years agobgpd: detach vrf labels allocated, when removing bgp instance 3708/head
Philippe Guibert [Mon, 28 Jan 2019 16:54:50 +0000 (17:54 +0100)]
bgpd: detach vrf labels allocated, when removing bgp instance

bgp instance is disabling the label allocated to reach vrf entity.
previously, only vrf disabling was removing the label. now, when bgp
leaves, bgp instance also frees the label used.

PR=62306
Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
Acked-by: Julien Floret <julien.floret@6wind.com>
6 years agoMerge pull request #3683 from opensourcerouting/70-ospf6-fix-mcast
Donald Sharp [Tue, 29 Jan 2019 16:03:49 +0000 (11:03 -0500)]
Merge pull request #3683 from opensourcerouting/70-ospf6-fix-mcast

7.0: ospf6d: fix multicast join race on FreeBSD

6 years agoospf6d: fix FreeBSD IPv6 multicast group join race 3683/head
Rafael Zalamena [Sat, 26 Jan 2019 15:49:35 +0000 (13:49 -0200)]
ospf6d: fix FreeBSD IPv6 multicast group join race

Avoid a IPv6 multicast group join race by delaying the group install
before processing all event queue.

Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
(cherry picked from commit bc482dc0caeed76505623426edf58c6de48f013e)

6 years agoospf6d: keep track of the socket set thread
Rafael Zalamena [Wed, 23 Jan 2019 12:25:30 +0000 (10:25 -0200)]
ospf6d: keep track of the socket set thread

When using the timer to set the socket multicast options, keep track
of the thread pointer. If we lose the thread reference we might have
situations where multicast is enabled when it should be disabled and
vice versa.

Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
(cherry picked from commit f80003b0e12a090b34e2ab9547ed072ff02c33ba)

6 years agoospf6d: don't queue interface events
Rafael Zalamena [Wed, 23 Jan 2019 12:06:49 +0000 (10:06 -0200)]
ospf6d: don't queue interface events

Apply interface event as soon as possible instead of queueing an event
for it.

Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
(cherry picked from commit 849576ee962518c926c6a264a497e873210941e8)

6 years agoMerge pull request #3667 from opensourcerouting/7.0/fix-file-and-syslog
Quentin Young [Thu, 24 Jan 2019 22:10:38 +0000 (17:10 -0500)]
Merge pull request #3667 from opensourcerouting/7.0/fix-file-and-syslog

[7.0] fix "log file" + "log syslog"

6 years agolib: don't disable "log file" on "log syslog" 3667/head
David Lamparter [Thu, 24 Jan 2019 17:59:03 +0000 (18:59 +0100)]
lib: don't disable "log file" on "log syslog"

FRR log targets are independent, so "log syslog" must not disable
"log file" output.

Fixes: #3551
Fixes: 0204baa87630b210c71d9ae0e2569cff0fb0539b
Signed-off-by: David Lamparter <equinox@diac24.net>
6 years agoMerge pull request #3645 from opensourcerouting/ldpd-pdu-length-fix-7.0
Donald Sharp [Wed, 23 Jan 2019 01:08:48 +0000 (20:08 -0500)]
Merge pull request #3645 from opensourcerouting/ldpd-pdu-length-fix-7.0

[7.0] ldpd: fix corner case in which we wouldn't respect the max pdu length

6 years agoldpd: fix corner case in which we wouldn't respect the max pdu length 3645/head
Renato Westphal [Tue, 22 Jan 2019 19:50:33 +0000 (17:50 -0200)]
ldpd: fix corner case in which we wouldn't respect the max pdu length

The calculation to know when an LDP PDU went past the maximum
negotiated PDU length was wrong because it wasn't taking the
"Version" and "PDU Length" fields into account (total of four
bytes). Fix this.

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
6 years agoMerge pull request #3628 from manuhalo/fix_ospf_vl_del_7.0
Donald Sharp [Tue, 22 Jan 2019 14:08:35 +0000 (09:08 -0500)]
Merge pull request #3628 from manuhalo/fix_ospf_vl_del_7.0

[7.0] ospfd: fix no virtual-link cmd

6 years agoMerge pull request #3637 from opensourcerouting/70-fbsd-route-fix
Donald Sharp [Tue, 22 Jan 2019 14:05:50 +0000 (09:05 -0500)]
Merge pull request #3637 from opensourcerouting/70-fbsd-route-fix

7.0: zebra: fix a few problems with routing socket

6 years agozebra: make routing socket debug user friendlier 3637/head
Rafael Zalamena [Thu, 17 Jan 2019 22:24:31 +0000 (20:24 -0200)]
zebra: make routing socket debug user friendlier

Implement a addrs RTA to string translator to provide more useful
debug output.

Example:

ifam_read_mesg: ifindex 2, ifname em1, ifam_addrs NETMASK,IFP,IFA
  ifam_flags 0x4, addr 2001:db8:1::1/64 broad (unspec) dst (unspec)
  gateway (unspec)

Instead of:

ifam_read_mesg: ifindex 2, ifname em1, ifam_addrs 0x34
  ifam_flags 0x4, addr 2001:db8:1::1/64 broad (unspec) dst (unspec)
  gateway (unspec)

Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
6 years agozebra: fix debug messages in ifam_read_mesg
Rafael Zalamena [Thu, 17 Jan 2019 16:37:53 +0000 (14:37 -0200)]
zebra: fix debug messages in ifam_read_mesg

Use the proper address family to convert binary address to string.

Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
6 years agozebra: fix debug prefix string size
Rafael Zalamena [Thu, 17 Jan 2019 15:15:20 +0000 (13:15 -0200)]
zebra: fix debug prefix string size

`gate_buf` should be big enough to hold IPv6 addresses and `inet_ntop`
should be run in the correct `sockaddr` struct member.

Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
6 years agozebra: fix debug messages with prefixes
Rafael Zalamena [Thu, 17 Jan 2019 15:12:13 +0000 (13:12 -0200)]
zebra: fix debug messages with prefixes

Debug messages should use `prefix_buf` and `prefix2str` should only be
called once in `kernel_rtm`.

Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
6 years agozebra: use rta_getattr for NETMASK
Rafael Zalamena [Fri, 18 Jan 2019 20:28:58 +0000 (18:28 -0200)]
zebra: use rta_getattr for NETMASK

IPv6 uses AF_LINK to represent netmasks, this commit unbreaks
`rtm_read_mesg` that was broke on the `rta_get*` refactory.

Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
6 years agozebra: fix routing socket AF_LINK handling on NETMASK
Rafael Zalamena [Thu, 17 Jan 2019 22:46:11 +0000 (20:46 -0200)]
zebra: fix routing socket AF_LINK handling on NETMASK

IPv6 netmasks use AF_LINK family type and puts the correct amount of
set bits in the data structure. If we only copy the SDL header we
won't get all IPv6 address length, we must copy the whole extension of
the `sockaddr_in6` struct (which is provided in `destlen` parameter).

Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
6 years agozebra: remove unused functions
Rafael Zalamena [Thu, 17 Jan 2019 15:19:30 +0000 (13:19 -0200)]
zebra: remove unused functions

Remove two unused functions in `zebra/rt_socket.c`.

Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
6 years agozebra: use proper sockaddr size in kernel_rtm
Rafael Zalamena [Thu, 17 Jan 2019 13:09:09 +0000 (11:09 -0200)]
zebra: use proper sockaddr size in kernel_rtm

`sockaddr` `len` field is the address type size and not the mask length.

Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
6 years agoMerge pull request #3615 from pguibert6WIND/priorise_default_vrf_configured_v70
Renato Westphal [Fri, 18 Jan 2019 21:42:10 +0000 (19:42 -0200)]
Merge pull request #3615 from pguibert6WIND/priorise_default_vrf_configured_v70

Priorise default vrf configured

6 years agoospfd: fix no virtual-link cmd 3628/head
Emanuele Di Pascale [Fri, 18 Jan 2019 11:39:28 +0000 (12:39 +0100)]
ospfd: fix no virtual-link cmd

the  command was not checking
correctly in all cases whether the virtual link existed. This caused
bugs in some corner cases, e.g. when two virtual links were created,
one of them was deleted, and the second one was reset with no
authentication - this would instead create a new virtual link with
the area in decimal format.

Signed-off-by: Emanuele Di Pascale <emanuele@voltanet.io>
6 years agozebra: do not create vrf if name already set to default vrf at startup 3615/head
Philippe Guibert [Fri, 28 Dec 2018 13:27:45 +0000 (14:27 +0100)]
zebra: do not create vrf if name already set to default vrf at startup

if the default vrf name is manually set, by passing -o parameter to
zebra, then this should be detected when walking the list of netns
available in the system. If a netns called vrf0 is present, then it
should be ignored.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
6 years agozebra: start the netns notification mechanism after ns initialisation
Philippe Guibert [Fri, 21 Dec 2018 15:25:20 +0000 (16:25 +0100)]
zebra: start the netns notification mechanism after ns initialisation

when zebra is run, by using vrf netns backend mode, then the parser
detector of netns is run before forcing the default vrf to a possible
value. In that case, there is a possibility that the forced '-o' option
will create a second vrf with same name, whereas this option should be
there to uniquely have a default vrf with a value.
To make things consistent, the forced value will be priorised. Then, the
notifier will attempt to create vrf contexts. The expectation is that
the creation will fail, due to an already present vrf with same name.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
6 years agoMerge pull request #3594 from pguibert6WIND/flowspec_support_nh_tracking_70
Lou Berger [Tue, 15 Jan 2019 16:50:38 +0000 (11:50 -0500)]
Merge pull request #3594 from pguibert6WIND/flowspec_support_nh_tracking_70

bgpd: flowspec redirect IP info is retrieved into nh tracking

6 years agoMerge pull request #3608 from opensourcerouting/70-bfd-24-minutes
Donald Sharp [Mon, 14 Jan 2019 15:26:56 +0000 (10:26 -0500)]
Merge pull request #3608 from opensourcerouting/70-bfd-24-minutes

7.0: bfdd: Fix timer print-out function

6 years agobfdd: Fix timer print-out function 3608/head
Donald Sharp [Sat, 12 Jan 2019 21:22:32 +0000 (16:22 -0500)]
bfdd: Fix timer print-out function

The timer2str function thought 24 minutes was an hour and had a
couple of other issues that needed to be corrected.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
(cherry picked from commit 23586b0552ee08e24d4c1f54bb4913c48c1e14aa)

6 years agoMerge pull request #3593 from donaldsharp/label_to_zebra_7.0
Renato Westphal [Mon, 14 Jan 2019 12:47:03 +0000 (10:47 -0200)]
Merge pull request #3593 from donaldsharp/label_to_zebra_7.0

bgpd: Do not send a label to zebra that it doesn't understand

6 years agobgpd: flowspec redirect IP info is retrieved into nh tracking 3594/head
Philippe Guibert [Tue, 4 Dec 2018 08:33:21 +0000 (09:33 +0100)]
bgpd: flowspec redirect IP info is retrieved into nh tracking

redirect IP nh of flowspec entry is retrieved so that the nexthop
IP information is injected into the nexthop tracking, and is associated
to the bgp_path structure. This permits validating or unvalidating the
bgp_path for injection in zebra or not.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
6 years agoMerge pull request #3598 from pguibert6WIND/handle_multiple_netns_delete_event_70
Donald Sharp [Fri, 11 Jan 2019 12:32:35 +0000 (07:32 -0500)]
Merge pull request #3598 from pguibert6WIND/handle_multiple_netns_delete_event_70

zebra: handle multiple events for netns deletion event

6 years agozebra: handle multiple events for netns deletion event 3598/head
Philippe Guibert [Tue, 18 Dec 2018 17:00:31 +0000 (18:00 +0100)]
zebra: handle multiple events for netns deletion event

When handling events from /var/run/netns folder, if several netns are
removed at the same time, only the first one is deleted in the frr. Fix
this behaviour by applying continue in the loop.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
6 years agoMerge pull request #3596 from donaldsharp/pthread_7.0
Mark Stapp [Thu, 10 Jan 2019 18:27:02 +0000 (13:27 -0500)]
Merge pull request #3596 from donaldsharp/pthread_7.0

dev/7.0 DC of #3589 and #3590

6 years agolib: Convert RUSAGE_SELF to RUSAGE_THREAD where we can 3596/head
Donald Sharp [Wed, 9 Jan 2019 17:18:21 +0000 (12:18 -0500)]
lib: Convert RUSAGE_SELF to RUSAGE_THREAD where we can

When using getrusage, we have multiple choices about what
to call for data gathering about this particular thread of execution.

RUSAGE_SELF -> This means gather all cpu run time for all pthreads associated
with this process.

RUSAGE_THREAD -> This means gather all cpu run time for this particular
pthread.

Clearly with data gathering for slow thread as well as `show thread cpu`
it would be preferable to gather only data about the current running
pthread.  This probably was the original behavior of using RUSAGE_SELF
when we didn't have multiple pthreads.  So it didn't matter so much.

Prior to this change, 10 iterations of 1 million routes install/remove
from zebra would give us this cpu time for the dataplane pthread:

Showing statistics for pthread Zebra dplane thread
--------------------------------------------------
                      CPU (user+system): Real (wall-clock):
Active   Runtime(ms)   Invoked Avg uSec Max uSecs Avg uSec Max uSecs  Type  Thread
    0     280902.149    326541      860   2609982      550   2468910    E  dplane_thread_loop

After this change we are seeing this:

Showing statistics for pthread Zebra dplane thread
--------------------------------------------------
                      CPU (user+system): Real (wall-clock):
Active   Runtime(ms)   Invoked Avg uSec Max uSecs Avg uSec Max uSecs  Type  Thread
    0      58045.560    334944      173    277226      539   2502268    E  dplane_thread_loop

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
6 years agolib, bgpd: Convert frr_pthread_set_name to only cause it to set os name of the thread
Donald Sharp [Wed, 9 Jan 2019 19:59:22 +0000 (14:59 -0500)]
lib, bgpd: Convert frr_pthread_set_name to only cause it to set os name of the thread

The current invocation of frr_pthread_set_name was causing it reset the os_name.
There is no need for this, we now always create the pthread appropriately
to have both name and os_name.  So convert this function to a simple
call through of the pthread call now.

Before(any of these changes):
sharpd@robot ~/frr1> ps -L -p 16895
  PID   LWP TTY          TIME CMD
16895 16895 ?        00:01:39 bgpd
16895 16896 ?        00:00:54
16895 16897 ?        00:00:07 bgpd_ka

After:
sharpd@donna ~/frr1> ps -L -p 1752
  PID   LWP TTY          TIME CMD
 1752  1752 ?        00:00:00 bgpd
 1752  1753 ?        00:00:00 bgpd_io
 1752  1754 ?        00:00:00 bgpd_ka

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
6 years agolib: Cleanup thread name setting to happen at start
Donald Sharp [Wed, 9 Jan 2019 19:32:44 +0000 (14:32 -0500)]
lib: Cleanup thread name setting to happen at start

When we start a thread we always call fpt_run and since
the last commit we know os_name is filled with something,
therefore we can just set the name on startup.

This creates this output now for zebra:

sharpd@donna ~/frr2> ps -L -p 25643
  PID   LWP TTY          TIME CMD
25643 25643 ?        00:00:00 zebra
25643 25644 ?        00:00:00 Zebra dplane
25643 25684 ?        00:00:00 zebra_apic
sharpd@donna ~/frr2>

I removed the abstraction to frr_pthread_set_name because
it was snprintf'ing into the same buffer which was the
real bug here( the first character of os_name became null).
In the next commit I'll remove that api because
it is unneeded and was a horrible hack to get
this to work for the one place it was wanted.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
6 years agolib: On frr_pthread_new save a os_name
Donald Sharp [Wed, 9 Jan 2019 18:41:46 +0000 (13:41 -0500)]
lib: On frr_pthread_new save a os_name

On call of frr_pthread_new, save the os_name if given,
if not given use the name passed in( shortening to fit
in available space ) and finally if the name was not
passed in use the default value.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
6 years agobgpd: Do not send a label to zebra that it doesn't understand 3593/head
Donald Sharp [Wed, 9 Jan 2019 13:48:37 +0000 (08:48 -0500)]
bgpd: Do not send a label to zebra that it doesn't understand

When using an `import vrf` mechanism we are marking
the vrf label as BGP_PREVENT_VRF_2_VRF_LEAK, and then sending
this down to zebra.  Since zebra knows nothing about this special
value, convert it to a value that it does know MPLS_LABEL_NONE.

This bug was introduced by: 13b7e7f007833c4e2942f40cbd2c2f93a2767e78

And shows up with this error message in the zebra log:

2019/01/09 08:25:16 ZEBRA: Extended Error: Label >= configured maximum in platform_labels
2019/01/09 08:25:16 ZEBRA: [EC 4043309093] netlink-cmd (NS 0) error: Invalid argument, type=RTM_NEWROUTE(24), seq=8, pid=3321825991
2019/01/09 08:25:16 ZEBRA: [EC 4043309103] LSP Install Failure: 4294967294

And zebra kept the label as:
donna.cumulusnetworks.com# show mpls table
 Inbound                            Outbound
   Label     Type          Nexthop     Label
--------  -------  ---------------  --------
      -2      BGP            GREEN
      -2      BGP             BLUE

After this fix, neither the labels are stored in zebra nor do we see
the log error message.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
6 years agoMerge pull request #3585 from pguibert6WIND/fix_vrf_netns_broken_70
Donald Sharp [Tue, 8 Jan 2019 18:28:28 +0000 (13:28 -0500)]
Merge pull request #3585 from pguibert6WIND/fix_vrf_netns_broken_70

zebra: update local ns_id field

6 years agoMerge pull request #3584 from opensourcerouting/70-freebsd-route-fix
Donald Sharp [Tue, 8 Jan 2019 18:20:46 +0000 (13:20 -0500)]
Merge pull request #3584 from opensourcerouting/70-freebsd-route-fix

dev/7.0: zebra: fix FreeBSD breakage

6 years agozebra: update local ns_id field 3585/head
Philippe Guibert [Mon, 7 Jan 2019 08:55:10 +0000 (09:55 +0100)]
zebra: update local ns_id field

ns_id field must be synced with ns_id from netns service.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
6 years agozebra: fix another FreeBSD warning message 3584/head
Rafael Zalamena [Tue, 8 Jan 2019 12:37:22 +0000 (10:37 -0200)]
zebra: fix another FreeBSD warning message

When an empty netmask a wrong end size is calculated, lets handle this
corner case to avoid spurious warning messages.

Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
(cherry picked from commit 2d100aa5f12d1b5e09411fd27d0e3938cf4305db)

6 years agozebra: fix FreeBSD warning on fresh OS boot
Rafael Zalamena [Tue, 8 Jan 2019 12:32:28 +0000 (10:32 -0200)]
zebra: fix FreeBSD warning on fresh OS boot

Handle corner case where a warning log message is issued on interface
address netmask handling with sockaddr type AF_LINK: it may come empty
or with match all (all 0xFF).

In the first case all lengths are zero and we only need to copy the
first bytes, second case it comes with a zero index and all 0xFF bytes.

In any case we only need to figure out a few of the first bytes instead
of all data.

Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
(cherry picked from commit 75e710df7a21d980bba9e5b2260408a3b30d4145)

6 years agozebra: implement FreeBSD route attr handling
Rafael Zalamena [Tue, 8 Jan 2019 10:14:28 +0000 (08:14 -0200)]
zebra: implement FreeBSD route attr handling

When porting routing socket macro data handling to functions, the
attribute function was forgotten. The only difference between the
attribute and address handler is the family type check.

Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
(cherry picked from commit 19fb538dc116c837af3bb1a76526cbb9a39d1bfc)

6 years agoMerge pull request #3576 from LabNConsulting/working/7.0/no-bgp-attr-255
Donald Sharp [Mon, 7 Jan 2019 23:45:06 +0000 (18:45 -0500)]
Merge pull request #3576 from LabNConsulting/working/7.0/no-bgp-attr-255

7.0: bgpd: don't use BGP_ATTR_VNC(255) unless ENABLE_BGP_VNC_ATTR is defined

6 years agoMerge pull request #3573 from manuhalo/dev7_fix_isis_p2p
Donald Sharp [Mon, 7 Jan 2019 22:31:46 +0000 (17:31 -0500)]
Merge pull request #3573 from manuhalo/dev7_fix_isis_p2p

[dev/7.0] isisd: fix point-to-point network type config