]> git.proxmox.com Git - mirror_frr.git/log
mirror_frr.git
5 years agobgpd: display the list of iprules attached to a fs entry
Philippe Guibert [Fri, 30 Nov 2018 13:56:40 +0000 (14:56 +0100)]
bgpd: display the list of iprules attached to a fs entry

the list of iprules is displayed in the 'show bgp ipv4 flowspec detail'
The list of iprules is displayed, only if it is installed.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
5 years agobgpd: change priority of fs pbr rules
Philippe Guibert [Fri, 30 Nov 2018 13:13:37 +0000 (14:13 +0100)]
bgpd: change priority of fs pbr rules

two kind of rules are being set from bgp flowspec: ipset based rules,
and ip rule rules. default route rules may have a lower priority than
the other rules ( that do not support default rules). so, if an ipset
rule without fwmark is being requested, then priority is arbitrarily set
to 1. the other case, priority is set to 0.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
5 years agobgpd: notify callback when ip rule from/to rule has been configured
Philippe Guibert [Thu, 29 Nov 2018 13:35:41 +0000 (14:35 +0100)]
bgpd: notify callback when ip rule from/to rule has been configured

because ip rule creation is used to not only handle traffic marked by
fwmark; but also for conveying traffic with from/to rules, a check of
the creation must be done in the linked list of ip rules.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
5 years agobgpd: conversion from fs to pbr: support for ip rule from/to
Philippe Guibert [Thu, 29 Nov 2018 14:17:36 +0000 (15:17 +0100)]
bgpd: conversion from fs to pbr: support for ip rule from/to

adding/suppressing flowspec to pbr is supported. the add and the remove
code is being added. now,bgp supports the hash list of ip rule list.
The removal of bgp ip rule is done via search. The search uses the
action field. the reason is that when a pbr rule is added, to replace an
old one, the old one is kept until the new one is installed, so as to
avoid traffic to be cut. This is why at one moment, one can have two
same iprules with different actions. And this is why the algorithm
covers this case.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
5 years agobgpd: ip rule zebra layer adapted to handle both cases
Philippe Guibert [Thu, 29 Nov 2018 14:14:41 +0000 (15:14 +0100)]
bgpd: ip rule zebra layer adapted to handle both cases

now, ip rule can be created from two differnt ways; however a single
zebra API has been defined. so make it consistent by adding a parameter
to the bgp zebra layer. the function will handle the rest.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
5 years agobgpd: the fs entry is valid for any rule only, by using ipruleset cmd
Philippe Guibert [Thu, 29 Nov 2018 14:08:36 +0000 (15:08 +0100)]
bgpd: the fs entry is valid for any rule only, by using ipruleset cmd

Before, it was not possible to create any rules. Now, it is possible to
have flowspec rules relying only on ip rule command. The check is done
here.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
5 years agobgpd: an hash list of pbr iprule is created
Philippe Guibert [Thu, 29 Nov 2018 14:12:03 +0000 (15:12 +0100)]
bgpd: an hash list of pbr iprule is created

that iprule list stands for the list of fs entries that are created,
based only on ip rule from/to rule.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
5 years agobgpd: upon bgp fs study, determine if iprule can be used
Philippe Guibert [Thu, 29 Nov 2018 14:04:52 +0000 (15:04 +0100)]
bgpd: upon bgp fs study, determine if iprule can be used

instead of using ipset based mechanism to forward packets, there are
cases where it is possible to use ip rule based mechanisms (without
ipset). Here, this applies to simple fs rules with only 'from any' or
'to any'.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
5 years agobgpd: remove useless fields in bgp_pbr_entry_main
Philippe Guibert [Thu, 29 Nov 2018 14:03:03 +0000 (15:03 +0100)]
bgpd: remove useless fields in bgp_pbr_entry_main

main bgp structure that contains fs information is being cleaned.
some fields are removed.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
5 years agoMerge pull request #3668 from opensourcerouting/fix-file-and-syslog
Quentin Young [Thu, 24 Jan 2019 22:10:07 +0000 (17:10 -0500)]
Merge pull request #3668 from opensourcerouting/fix-file-and-syslog

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

5 years agolib: don't disable "log file" on "log syslog"
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>
5 years agoMerge pull request #3642 from donaldsharp/sequence
Mark Stapp [Thu, 24 Jan 2019 14:16:12 +0000 (09:16 -0500)]
Merge pull request #3642 from donaldsharp/sequence

zebra: Add code to track sequence number from zebra_router

5 years agozebra: Add code to track sequence number from zebra_router
Donald Sharp [Tue, 22 Jan 2019 12:39:14 +0000 (07:39 -0500)]
zebra: Add code to track sequence number from zebra_router

The sequence number used should be unique and increase by 1
for netlink commands.  This will allow the code to match
up batched commands to actual requests, so that we can signal
the failure correctly back.

So start the movement and tracking of sequence numbers as
an atomic uint32_t in zebra_router.  Modify the dataplane
code to start tracking contexts from this value.

In future commits we will move more of the sequencing
data into using this value.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
5 years agoMerge pull request #3655 from rubenk/macos-fixes
David Lamparter [Thu, 24 Jan 2019 12:51:37 +0000 (13:51 +0100)]
Merge pull request #3655 from rubenk/macos-fixes

A few small build fixes for Mac OS

5 years agoMerge pull request #3658 from rubenk/fix-old-style-definitions
Donald Sharp [Thu, 24 Jan 2019 11:47:22 +0000 (06:47 -0500)]
Merge pull request #3658 from rubenk/fix-old-style-definitions

Treewide: use ANSI function definitions

5 years agoTreewide: use ANSI function definitions
Ruben Kerkhof [Thu, 24 Jan 2019 09:12:36 +0000 (10:12 +0100)]
Treewide: use ANSI function definitions

Signed-off-by: Ruben Kerkhof <ruben@rubenkerkhof.com>
5 years agoMerge pull request #3508 from chiragshah6/evpn_dev2
Russ White [Wed, 23 Jan 2019 18:44:46 +0000 (13:44 -0500)]
Merge pull request #3508 from chiragshah6/evpn_dev2

zebra: EVPN remote entry delete check local entry presence

5 years agoMerge pull request #3650 from donaldsharp/mpls_compile_issue
Mark Stapp [Wed, 23 Jan 2019 17:56:56 +0000 (12:56 -0500)]
Merge pull request #3650 from donaldsharp/mpls_compile_issue

zebra: Fix compile issues introduced by recent commit on newer compilers

5 years agoOnly check for .interp when we have objcopy
Ruben Kerkhof [Tue, 22 Jan 2019 17:39:47 +0000 (18:39 +0100)]
Only check for .interp when we have objcopy

On Mac OS, where we don't have objcopy, ./configure logs:

checking for objcopy... no
checking for .interp value to use... ./configure: line 22174: conftest.interp: No such file or directory

Signed-off-by: Ruben Kerkhof <ruben@rubenkerkhof.com>
5 years agoRedirect output of ranlib to /dev/null
Ruben Kerkhof [Tue, 22 Jan 2019 17:32:08 +0000 (18:32 +0100)]
Redirect output of ranlib to /dev/null

./configure on Mac OS logs:
checking whether ranlib supports D option... error: /Library/Developer/CommandLineTools/usr/bin/ranlib: unknown option character `D' in: -D
Usage: /Library/Developer/CommandLineTools/usr/bin/ranlib [-sactfqLT] [-] archive [...]
no

This is quite noisy.

Signed-off-by: Ruben Kerkhof <ruben@rubenkerkhof.com>
5 years agoRedirect output of $AR check to /dev/null
Ruben Kerkhof [Tue, 22 Jan 2019 17:29:29 +0000 (18:29 +0100)]
Redirect output of $AR check to /dev/null

./configure logs this on Mac OS:

checking whether ar supports D option... /Library/Developer/CommandLineTools/usr/bin/ar: illegal option -- D
usage:  ar -d [-TLsv] archive file ...
ar -m [-TLsv] archive file ...
ar -m [-abiTLsv] position archive file ...
ar -p [-TLsv] archive [file ...]
ar -q [-cTLsv] archive file ...
ar -r [-cuTLsv] archive file ...
ar -r [-abciuTLsv] position archive file ...
ar -t [-TLsv] archive [file ...]
ar -x [-ouTLsv] archive [file ...]
no

This is quite noisy and we're only interested in the result of the
check, not the output.

Signed-off-by: Ruben Kerkhof <ruben@rubenkerkhof.com>
5 years agoMerge pull request #3648 from donaldsharp/master_version
Lou Berger [Wed, 23 Jan 2019 15:14:49 +0000 (10:14 -0500)]
Merge pull request #3648 from donaldsharp/master_version

*: Convert to new version number

5 years agoMerge pull request #3649 from donaldsharp/increase_timeout
Rafael Zalamena [Wed, 23 Jan 2019 13:34:10 +0000 (11:34 -0200)]
Merge pull request #3649 from donaldsharp/increase_timeout

topotests: Modify bgp convergence to be more than 120 seconds

5 years agozebra: Fix compile issues introduced by recent commit on newer compilers
Donald Sharp [Wed, 23 Jan 2019 01:55:55 +0000 (20:55 -0500)]
zebra: Fix compile issues introduced by recent commit on newer compilers

We were using dplane_ctx_get_status(ctx) and assigning that
value to zebra_dplane_status, not zebra_dplane_result( yeah what? )

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
5 years agoMerge pull request #3630 from opensourcerouting/fix-show-import-check
Donald Sharp [Wed, 23 Jan 2019 01:10:56 +0000 (20:10 -0500)]
Merge pull request #3630 from opensourcerouting/fix-show-import-check

zebra: fix the "show ip import-check" command

5 years agoMerge pull request #3644 from opensourcerouting/ldpd-pdu-length-fix
Donald Sharp [Wed, 23 Jan 2019 01:08:22 +0000 (20:08 -0500)]
Merge pull request #3644 from opensourcerouting/ldpd-pdu-length-fix

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

5 years agotopotests: Modify bgp convergence to be more than 120 seconds
Donald Sharp [Wed, 23 Jan 2019 01:00:55 +0000 (20:00 -0500)]
topotests: Modify bgp convergence to be more than 120 seconds

Waiting 10 seconds for bgp convergence makes no sense, especially
if the test system is under load and a node is started up before
the node it is connecting to is up. We should wait for the full
default of 120 seconds, plus a little time to ensure nothing is
screwed up too much.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
5 years ago*: Convert to new version number
Donald Sharp [Tue, 22 Jan 2019 23:31:33 +0000 (18:31 -0500)]
*: Convert to new version number

After much discussion we have decided to update the version of master
to 7.1 dev.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
5 years agoMerge pull request #3416 from mjstapp/dplane_mpls
Rafael Zalamena [Tue, 22 Jan 2019 21:38:24 +0000 (19:38 -0200)]
Merge pull request #3416 from mjstapp/dplane_mpls

Async dataplane: support mpls lsps

5 years agoldpd: fix corner case in which we wouldn't respect the max pdu length
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>
5 years agozebra: openbsd LSP update code
Mark Stapp [Mon, 26 Nov 2018 21:08:55 +0000 (16:08 -0500)]
zebra: openbsd LSP update code

Finish the LSP update code for the async dataplane for
the openbsd platform. Remove synch apis now that we've
converted to the async code path.

Signed-off-by: Mark Stapp <mjs@voltanet.io>
5 years agozebra: remove use of sync LSP update apis
Mark Stapp [Mon, 26 Nov 2018 21:07:51 +0000 (16:07 -0500)]
zebra: remove use of sync LSP update apis

Remove the last use of the pre-dataplane LSP update apis;
remove the stubs from the 'null' implementation file.

Signed-off-by: Mark Stapp <mjs@voltanet.io>
5 years agozebra: fix routing socket logic for labelled nexthops
Mark Stapp [Thu, 20 Dec 2018 18:20:49 +0000 (13:20 -0500)]
zebra: fix routing socket logic for labelled nexthops

Clarify and fix the logic used for labelled nexthops during
route updates on routing socket platforms.

Signed-off-by: Mark Stapp <mjs@voltanet.io>
5 years agozebra: fix debug test in routing-socket update path
Mark Stapp [Thu, 20 Dec 2018 18:22:22 +0000 (13:22 -0500)]
zebra: fix debug test in routing-socket update path

Fix the test used to pre-populate a string used in debugs
in the routing-socket route-update code path.

Signed-off-by: Mark Stapp <mjs@voltanet.io>
5 years agozebra: move LSP updates into dataplane subsystem
Mark Stapp [Thu, 15 Nov 2018 14:11:01 +0000 (09:11 -0500)]
zebra: move LSP updates into dataplane subsystem

Start performing LSP updates through the async dataplane
subsystem. This is plumbed through for linux/netlink.

Signed-off-by: Mark Stapp <mjs@voltanet.io>
5 years agoMerge pull request #3559 from opensourcerouting/zapi-sanity-checks
Quentin Young [Tue, 22 Jan 2019 18:53:08 +0000 (13:53 -0500)]
Merge pull request #3559 from opensourcerouting/zapi-sanity-checks

add a few moar sanity checks when encoding/decoding zapi routes

5 years agozebra: infra for LSP updates using dplane
Mark Stapp [Tue, 23 Oct 2018 14:57:01 +0000 (10:57 -0400)]
zebra: infra for LSP updates using dplane

Adding infra to zebra dplane to support LSP updates. Add
kernel api for LSP updates that uses a dataplane context; add
stub apis for netlink, bsd, and 'null' kernel paths. Add
version of netlink mpls update code that takes a dplane
context struct instead of a zebra lsp struct.

Signed-off-by: Mark Stapp <mjs@voltanet.io>
5 years agozebra: add apis to add and delete NHLFEs
Mark Stapp [Wed, 17 Oct 2018 19:54:53 +0000 (15:54 -0400)]
zebra: add apis to add and delete NHLFEs

Add public versions of zebra apis that add NHLFEs to an LSP,
and that free NHLFEs. The dataplane code needs to capture/copy
NHLFEs in order to do async LSP programming.

Signed-off-by: Mark Stapp <mjs@voltanet.io>
5 years agozebra: reorg dataplane context to support lsp info
Mark Stapp [Wed, 10 Oct 2018 15:36:53 +0000 (11:36 -0400)]
zebra: reorg dataplane context to support lsp info

Move route info to a separate struct and use a union in the
dplane context to hold either route or lsp info. Add
accessors for LSP info.

Signed-off-by: Mark Stapp <mjs@voltanet.io>
5 years agoFix compile error on Mac OS
Ruben Kerkhof [Tue, 22 Jan 2019 16:55:31 +0000 (17:55 +0100)]
Fix compile error on Mac OS

  CC       lib/frr_pthread.lo
lib/frr_pthread.c:128:40: error: too many arguments to function call, expected 1, have 3
        ret = pthread_setname_np(fpt->thread, fpt->os_name, NULL);
              ~~~~~~~~~~~~~~~~~~              ^~~~~~~~~~~~~~~~~~
/Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk/usr/include/pthread.h:512:1: note: 'pthread_setname_np' declared here
__API_AVAILABLE(macos(10.6), ios(3.2))

Mac OS does have pthread_setname_np, but we can't use it here since it
only accepts a single argument, the thread name, and thus only works for
the current thread.

Signed-off-by: Ruben Kerkhof <ruben@rubenkerkhof.com>
5 years agoFix 'make clean' os Mac OS
Ruben Kerkhof [Tue, 22 Jan 2019 16:50:02 +0000 (17:50 +0100)]
Fix 'make clean' os Mac OS

The find command on Mac OS needs a path as first argument, or else
it outputs:

find -name __pycache__ -o -name .pytest_cache | xargs rm -rf
find: illegal option -- n
usage: find [-H | -L | -P] [-EXdsx] [-f path] path ... [expression]
       find [-H | -L | -P] [-EXdsx] -f path [path ...] [expression]
find -name "*.pyc" -o -name "*_clippy.c" | xargs rm -f
find: illegal option -- n
usage: find [-H | -L | -P] [-EXdsx] [-f path] path ... [expression]
       find [-H | -L | -P] [-EXdsx] -f path [path ...] [expression]

Signed-off-by: Ruben Kerkhof <ruben@rubenkerkhof.com>
5 years agoMerge pull request #3633 from opensourcerouting/send-vrf-backend
Donald Sharp [Tue, 22 Jan 2019 14:11:58 +0000 (09:11 -0500)]
Merge pull request #3633 from opensourcerouting/send-vrf-backend

Send VRF backend to the client daemons

5 years agoMerge pull request #3627 from manuhalo/fix_ospf_vl_del_master
Donald Sharp [Tue, 22 Jan 2019 14:08:04 +0000 (09:08 -0500)]
Merge pull request #3627 from manuhalo/fix_ospf_vl_del_master

ospfd: fix no virtual-link cmd

5 years agoMerge pull request #3636 from opensourcerouting/defpy-text-tokens
Donald Sharp [Tue, 22 Jan 2019 14:06:58 +0000 (09:06 -0500)]
Merge pull request #3636 from opensourcerouting/defpy-text-tokens

python: make DEFPY provide the text token of fixed parameters

5 years agoMerge pull request #3641 from opensourcerouting/rsock-ipv6-fix
Donald Sharp [Tue, 22 Jan 2019 13:57:16 +0000 (08:57 -0500)]
Merge pull request #3641 from opensourcerouting/rsock-ipv6-fix

zebra: fix a few problems with routing socket

5 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>
(cherry picked from commit 7a163a7c59bd1a7e94da356ea033040ae17cef29)

5 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>
(cherry picked from commit 691e903879bcf88c872d74f6317784bd2187f3ca)

5 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>
(cherry picked from commit 914fea09d9e1a5379b7ed9fa43b0505a091395af)

5 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>
(cherry picked from commit a6c000318226b9c3e5c3010ea31c6941ac1dff43)

5 years agoMerge pull request #3631 from opensourcerouting/zapi_fixes
Russ White [Tue, 22 Jan 2019 01:25:08 +0000 (20:25 -0500)]
Merge pull request #3631 from opensourcerouting/zapi_fixes

Small zapi fixes

5 years agoMerge pull request #3632 from opensourcerouting/cli-xpath-fixes
Russ White [Tue, 22 Jan 2019 01:19:41 +0000 (20:19 -0500)]
Merge pull request #3632 from opensourcerouting/cli-xpath-fixes

Fix CLI issue introduced by the northbound + simplifications

5 years agoMerge pull request #3635 from opensourcerouting/rsock-debug-fix
Russ White [Tue, 22 Jan 2019 00:24:55 +0000 (19:24 -0500)]
Merge pull request #3635 from opensourcerouting/rsock-debug-fix

zebra: fix routing socket debug messages

5 years agoMerge pull request #3638 from pguibert6WIND/crash_manual_config_l3vpn
Russ White [Tue, 22 Jan 2019 00:20:53 +0000 (19:20 -0500)]
Merge pull request #3638 from pguibert6WIND/crash_manual_config_l3vpn

bgpd: do not crash when removing ip vpn entries

5 years agobgpd: do not crash when removing ip vpn entries
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>
5 years agozebra: merge four "show ip nht" commands into a single DEFPY
Renato Westphal [Mon, 21 Jan 2019 14:47:10 +0000 (12:47 -0200)]
zebra: merge four "show ip nht" commands into a single DEFPY

This is mostly to be consistent with the "show ip import-check"
command, which is very similar.

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
5 years agozebra: remove dead macro
Renato Westphal [Mon, 21 Jan 2019 14:39:35 +0000 (12:39 -0200)]
zebra: remove dead macro

This macro is not used since commit 078430f609e.

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
5 years agozebra: consolidate how we indentify address-families in the NHT code
Renato Westphal [Mon, 21 Jan 2019 14:30:36 +0000 (12:30 -0200)]
zebra: consolidate how we indentify address-families in the NHT code

Favor usage of the afi_t enumeration to identify address-families
over using the classic AF_INET[6] constants for that. The choice to
use either of the two seems to be mostly arbitrary throughout our
code base, which leads to confusion and bugs like the one fixed by
commit 6f95d11a1. To address this problem, favor usage of the afi_t
enumeration whenever possible, since 1) it's an enumeration (helps
the compilers to catch some bugs), 2) has a safi_t sibling and 3)
can be used to index static arrays. AF_INET[6] should then be used
only when interfacing with the kernel or external libraries like
libc. The family2afi() and afi2family() functions can be used to
convert between the two different representations back and forth.

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
5 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>
5 years agozebra: make routing socket debug user friendlier
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>
5 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>
5 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>
5 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>
5 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>
5 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>
5 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>
5 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>
5 years agoMerge pull request #3618 from chiragshah6/ospf_vrf_dev
Renato Westphal [Fri, 18 Jan 2019 21:48:05 +0000 (19:48 -0200)]
Merge pull request #3618 from chiragshah6/ospf_vrf_dev

ospfd: remove default originate max aged lsa

5 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>
5 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>
5 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>
5 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>
5 years agozebra: fix checking of clients subscribed to receive interface info
Renato Westphal [Fri, 18 Jan 2019 18:06:00 +0000 (16:06 -0200)]
zebra: fix checking of clients subscribed to receive interface info

client->ifinfo is a VRF bitmap, hence we need to use
vrf_bitmap_check() to check if a client is subscribed to receive
interface information for a particular VRF. Just checking if
the client->ifinfo value is set will always succeed since it's
a pointer initialized by zserv_client_create(). With this fix,
we'll stop sending interface messages from all VRFs to all clients,
even those that didn't subscribe to it.

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
5 years agozebra: fix the "show ip import-check" command
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>
5 years agoospfd: fix no virtual-link cmd
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>
5 years agoMerge pull request #3625 from donaldsharp/clist_strlen
Mark Stapp [Thu, 17 Jan 2019 16:25:45 +0000 (11:25 -0500)]
Merge pull request #3625 from donaldsharp/clist_strlen

bgpd: Use string length not sizeof the array

5 years agobgpd: Use string length not sizeof the array
Donald Sharp [Thu, 17 Jan 2019 01:43:53 +0000 (20:43 -0500)]
bgpd: Use string length not sizeof the array

strlen is the same as sizeof when the memory is dynamically allocated
but it is not the same when the memory being looked at is an array.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
5 years agoMerge pull request #3624 from mjstapp/fix_ldpd_bind
Rafael Zalamena [Wed, 16 Jan 2019 23:58:50 +0000 (21:58 -0200)]
Merge pull request #3624 from mjstapp/fix_ldpd_bind

ldpd: fix missing return value in bindany

5 years agoldpd: fix missing return value in bindany
Mark Stapp [Wed, 16 Jan 2019 21:35:10 +0000 (16:35 -0500)]
ldpd: fix missing return value in bindany

One of the socket utilities was missing a return value in
one of its ifdef'd paths.

Signed-off-by: Mark Stapp <mjs@voltanet.io>
5 years agoospfd: remove default origin max age lsa
Chirag Shah [Tue, 15 Jan 2019 00:55:44 +0000 (16:55 -0800)]
ospfd: remove default origin max age lsa

default-information originate does not work
if config is removed and re-added.

Ticket:CM-20026
Testing Done:
Validate default-information originate config
removed and re-added, check ospf lsa database, and peer
route cache entry for default route.

Signed-off-by: Chirag Shah <chirag@cumulusnetworks.com>
5 years agoMerge pull request #3617 from donaldsharp/cleanup_old_stale_netlink
Jafar Al-Gharaibeh [Tue, 15 Jan 2019 16:53:49 +0000 (11:53 -0500)]
Merge pull request #3617 from donaldsharp/cleanup_old_stale_netlink

zebra: Cleanup unnecessary check

5 years agoMerge pull request #3570 from donaldsharp/dire_warning
Lou Berger [Tue, 15 Jan 2019 16:44:25 +0000 (11:44 -0500)]
Merge pull request #3570 from donaldsharp/dire_warning

more doc stuff for configure

5 years agoMerge pull request #3610 from donaldsharp/bgp_default_doc
Lou Berger [Tue, 15 Jan 2019 15:27:09 +0000 (10:27 -0500)]
Merge pull request #3610 from donaldsharp/bgp_default_doc

doc: Add `[no] bgp default ipv4-unicast` documentation

5 years agoMerge pull request #3532 from donaldsharp/community_list_speedup
Lou Berger [Tue, 15 Jan 2019 15:05:20 +0000 (10:05 -0500)]
Merge pull request #3532 from donaldsharp/community_list_speedup

bgp Community list speedup

5 years agozebra: Cleanup unnecessary check
Donald Sharp [Tue, 15 Jan 2019 13:55:34 +0000 (08:55 -0500)]
zebra: Cleanup unnecessary check

We self include the enum that has the RTA_EXPIRES in it,
as such this will always be true.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
5 years agoMerge pull request #3180 from qlyoung/prefixlen-u8-to-u16
Renato Westphal [Tue, 15 Jan 2019 02:39:39 +0000 (00:39 -0200)]
Merge pull request #3180 from qlyoung/prefixlen-u8-to-u16

lib: convert prefixlen to 16-bit integer

5 years agoMerge pull request #3611 from opensourcerouting/nb-fixes
Donald Sharp [Mon, 14 Jan 2019 22:28:49 +0000 (17:28 -0500)]
Merge pull request #3611 from opensourcerouting/nb-fixes

Minor northbound fixes

5 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>
5 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>
5 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>
5 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>
5 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>
5 years agozebra: reject routes without nexthops
Renato Westphal [Wed, 2 Jan 2019 20:37:00 +0000 (18:37 -0200)]
zebra: reject routes without nexthops

Routes without nexthops don't make any sense, so we need to reject
them otherwise weird things can happen.

NOTE: blackhole routes aren't nexthop-less, they do have a single
nexthop of type NEXTHOP_TYPE_BLACKHOLE.

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
5 years agolib: add a few more sanity checks when encoding/decoding routes
Renato Westphal [Wed, 2 Jan 2019 20:26:11 +0000 (18:26 -0200)]
lib: add a few more sanity checks when encoding/decoding routes

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
5 years agoMerge pull request #3607 from opensourcerouting/default_information_afi
Donald Sharp [Mon, 14 Jan 2019 17:04:11 +0000 (12:04 -0500)]
Merge pull request #3607 from opensourcerouting/default_information_afi

lib, zebra: add AFI parameter to the ZEBRA_REDISTRIBUTE_DEFAULT_* messages

5 years agodoc: Add `[no] bgp default ipv4-unicast` documentation
Donald Sharp [Mon, 14 Jan 2019 16:32:44 +0000 (11:32 -0500)]
doc: Add `[no] bgp default ipv4-unicast` documentation

This command had no documentation so add it in.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com.
5 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>
5 years agoMerge pull request #3605 from donaldsharp/bfd_24_minutes
Rafael Zalamena [Mon, 14 Jan 2019 13:20:54 +0000 (11:20 -0200)]
Merge pull request #3605 from donaldsharp/bfd_24_minutes

bfdd: Fix timer print-out function

5 years agoMerge pull request #3567 from donaldsharp/cleanup_route_table_creation
Renato Westphal [Mon, 14 Jan 2019 12:56:07 +0000 (10:56 -0200)]
Merge pull request #3567 from donaldsharp/cleanup_route_table_creation

Route Table Handling and shows

5 years agoMerge pull request #3564 from chiragshah6/evpn_dev1
Renato Westphal [Mon, 14 Jan 2019 12:50:20 +0000 (10:50 -0200)]
Merge pull request #3564 from chiragshah6/evpn_dev1

zebra: use default vrf_id for zvrf reference

5 years agoMerge pull request #3588 from donaldsharp/bgp_label_nonsense
Renato Westphal [Mon, 14 Jan 2019 12:46:42 +0000 (10:46 -0200)]
Merge pull request #3588 from donaldsharp/bgp_label_nonsense

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