]> git.proxmox.com Git - mirror_frr.git/log
mirror_frr.git
3 years agolib: add support for scripts directory
Quentin Young [Mon, 30 Nov 2020 22:37:18 +0000 (17:37 -0500)]
lib: add support for scripts directory

Specify default via --with-scriptdir at compile time, override default
with --scriptdir at runtime. If unspecified, it's {sysconfdir}/scripts
(usually /etc/frr/scripts)

Signed-off-by: Quentin Young <qlyoung@nvidia.com>
3 years agobuild: HAVE_LUA -> HAVE_SCRIPTING
Quentin Young [Mon, 30 Nov 2020 22:01:03 +0000 (17:01 -0500)]
build: HAVE_LUA -> HAVE_SCRIPTING

And also guard all scripting-related stuff with HAVE_SCRIPTING.

Signed-off-by: Quentin Young <qlyoung@nvidia.com>
3 years agobgpd: update routemap scripting example
Quentin Young [Sun, 29 Nov 2020 21:01:59 +0000 (16:01 -0500)]
bgpd: update routemap scripting example

- Change from "match command <foo>" to "match script <script>"
- Use new scripting API

Signed-off-by: Quentin Young <qlyoung@nvidia.com>
3 years agolib: use appropriate MTYPE for scripts
Quentin Young [Mon, 30 Nov 2020 04:21:31 +0000 (23:21 -0500)]
lib: use appropriate MTYPE for scripts

Signed-off-by: Quentin Young <qlyoung@nvidia.com>
3 years agolib: add ability to decode from lua scripts
Quentin Young [Mon, 30 Nov 2020 03:09:58 +0000 (22:09 -0500)]
lib: add ability to decode from lua scripts

This implements the ability to get results out from lua scripts after
they've run.

For each C type we support passing to Lua, there is a corresponding
`struct frrscript_codec`. This struct contains a typename field - just a
string identifying the type - and two function pointers. The first
function pointer, encode, takes a lua_State and a pointer to the C value
and pushes some corresponding Lua representation onto the stack. The
second, decode, assumes there is some Lua value on the stack and decodes
it into the corresponding C value.

Each supported type's `struct frrscript_codec` is registered with the
scripting stuff in the library, which creates a mapping between the type
name (string) and the `struct frrscript_codec`. When calling a script,
you specify arguments by passing an array of `struct frrscript_env`.
Each of these structs has a void *, a type name, and a desired binding
name. The type names are used to look up the appropriate function to
encode the pointed-at value onto the Lua stack, then bind the pushed
value to the provided binding name, so that the converted value is
accessible by that name within the script.

Results work in a similar way. After a script runs, call
frrscript_get_result() with the script and a `struct frrscript_env`.
The typename and name fields are used to fetch the Lua value from the
script's environment and use the registered decoder for the typename to
convert the Lua value back into a C value, which is returned from the
function. The caller is responsible for freeing these.

frrscript_call()'s macro foo has been stripped, as the underlying
function now takes fixed arrays. varargs have awful performance
characteristics, they're hard to read, and structs are more defined than
an order sensitive list.

Signed-off-by: Quentin Young <qlyoung@nvidia.com>
3 years agolib: add more type encoders, register existings
Quentin Young [Sun, 29 Nov 2020 23:00:35 +0000 (18:00 -0500)]
lib: add more type encoders, register existings

Signed-off-by: Quentin Young <qlyoung@nvidia.com>
3 years agolib: change encoder_func signature
Quentin Young [Sun, 29 Nov 2020 22:43:16 +0000 (17:43 -0500)]
lib: change encoder_func signature

None of the core lua_push* functions return anything, and it helps to
not have to wrap those when using them as function pointers for our
encoder system, so change the type of our custom encoders to return void
as well.

Signed-off-by: Quentin Young <qlyoung@nvidia.com>
3 years agolib: add more type encoder funcs
Quentin Young [Sun, 29 Nov 2020 21:00:36 +0000 (16:00 -0500)]
lib: add more type encoder funcs

- in_addr
- in6_addr
- sockunion

Signed-off-by: Quentin Young <qlyoung@nvidia.com>
3 years agolib: cleanup / refactor scripting foo
Quentin Young [Sun, 29 Nov 2020 19:51:52 +0000 (14:51 -0500)]
lib: cleanup / refactor scripting foo

- fix 'struct lua_State'
- change includes to library style
- rename encoder funcs to look like lua_push* funcs
- fix erroneous doc comment on prefix encoder
- remove unused (and broken) convenience func

Signed-off-by: Quentin Young <qlyoung@nvidia.com>
3 years agolib: better load-time error handling for scripts
Quentin Young [Sun, 29 Nov 2020 18:21:50 +0000 (13:21 -0500)]
lib: better load-time error handling for scripts

Signed-off-by: Quentin Young <qlyoung@nvidia.com>
3 years agolib: encode plen when passing prefixes to scripts
Quentin Young [Sun, 29 Nov 2020 18:21:14 +0000 (13:21 -0500)]
lib: encode plen when passing prefixes to scripts

Signed-off-by: Quentin Young <qlyoung@nvidia.com>
3 years agolib: close lua state when destroying script
Quentin Young [Sun, 29 Nov 2020 07:33:18 +0000 (02:33 -0500)]
lib: close lua state when destroying script

Signed-off-by: Quentin Young <qlyoung@nvidia.com>
3 years agolib: add better script error handling
Quentin Young [Sun, 29 Nov 2020 07:33:07 +0000 (02:33 -0500)]
lib: add better script error handling

Signed-off-by: Quentin Young <qlyoung@nvidia.com>
3 years agolib: initialize scripting system in libfrr
Quentin Young [Sun, 29 Nov 2020 07:02:26 +0000 (02:02 -0500)]
lib: initialize scripting system in libfrr

Signed-off-by: Quentin Young <qlyoung@nvidia.com>
3 years agolib: export zlog functions to scripts
Quentin Young [Sun, 29 Nov 2020 07:01:33 +0000 (02:01 -0500)]
lib: export zlog functions to scripts

Add:

- log.warn()
- log.error()
- log.notice()
- log.info()
- log.debug()

to the global namespace for each script

Signed-off-by: Quentin Young <qlyoung@nvidia.com>
3 years agolib: allow passing arguments to scripts
Quentin Young [Sun, 29 Nov 2020 07:00:26 +0000 (02:00 -0500)]
lib: allow passing arguments to scripts

- Add ability to pass arguments when calling a script
- Add macros to define arguments and results

Signed-off-by: Quentin Young <qlyoung@nvidia.com>
3 years agolib: fix hash issues in scripting foo
Quentin Young [Sun, 29 Nov 2020 06:59:02 +0000 (01:59 -0500)]
lib: fix hash issues in scripting foo

Signed-off-by: Quentin Young <qlyoung@nvidia.com>
3 years agolib: update script encoder signatures
Quentin Young [Sun, 29 Nov 2020 06:50:03 +0000 (01:50 -0500)]
lib: update script encoder signatures

Update the two test functions that encode a prefix and an interface to
match the encoder_func signature expected by the scripting infra.

Signed-off-by: Quentin Young <qlyoung@nvidia.com>
3 years agolib: add macros to count variadic args
Quentin Young [Sun, 29 Nov 2020 06:49:06 +0000 (01:49 -0500)]
lib: add macros to count variadic args

Magical macro used to compute the number of arguments passed to a
variadic macro.

Signed-off-by: Quentin Young <qlyoung@nvidia.com>
3 years agolib: make encoder type a typedef
Quentin Young [Sun, 29 Nov 2020 04:33:27 +0000 (23:33 -0500)]
lib: make encoder type a typedef

Need to use it for casts regularly.

Signed-off-by: Quentin Young <qlyoung@nvidia.com>
3 years agolib: add 'script <type> foo' test command
Quentin Young [Sun, 29 Nov 2020 02:51:42 +0000 (21:51 -0500)]
lib: add 'script <type> foo' test command

Signed-off-by: Quentin Young <qlyoung@nvidia.com>
3 years agolib: start adding generic scripting stuff
Quentin Young [Sun, 29 Nov 2020 00:02:39 +0000 (19:02 -0500)]
lib: start adding generic scripting stuff

Rather than let Luaisms propagate from the start, this is some generic
wrapper stuff that defines some semantics for interacting with scripts
that aren't specific to the underlying language.

The concept I have in mind for FRR's idea of a script is:

- has a name
- has some inputs, which have types
- has some outputs, which have types

I don't want to even say they have to be files; maybe we can embed
scripts in frr.conf, for example. Similarly the types of inputs and
outputs are probably going to end up being some language-specific setup.

For now, we will stick to this simple model, but the plan is to add full
object support (ie calling back into C).

This shouldn't be misconstrued as prepping for multilingual scripting
support, which is a bad idea for the following reasons:

- Each language would require different FFI methods, and specifically
  different object encoders; a lot of code
- Languages have different capabilities that would have to be brought to
  parity with each other; a lot of work
- Languages have *vastly* different performance characteristics; bad
  impressions, lots of issues we can't do anything about
- Each language would need a dedicated maintainer for the above reasons;
  pragmatically difficult
- Supporting multiple languages fractures the community and limits the
  audience with which a given script can be shared

The only pro for multilingual support would be ease of use for users not
familiar with Lua but familiar with one of the other supported
languages. This is not enough to outweigh the cons.

In order to get rich scripting capabilities, we need to be able to pass
representations of internal objects to the scripts. For example, a
script that performs some computation based on information about a peer
needs access to some equivalent of `struct peer` for the peer in
question. To transfer these objects from C-space into Lua-space we need
to encode them onto the Lua stack. This patch adds a mapping from
arbitrary type names to the functions that encode objects of that type.

For example, the function that encodes `struct peer` into a Lua table
could be registered with:

  bgp_peer_encoder_func(struct frrscript *fs, struct peer *peer)
  {
     // encode peer to Lua table, push to stack in fs->scriptinfo->L
  }

  frrscript_register_type_encoder("peer", bgp_peer_encoder_func);

Later on when calling a script that wants a peer, the plan is to be able
to specify the type name like so:

  frrscript_call(script, "peer", peer);

Using C-style types for the type names would have been nice, it might be
possible to do this with preprocessor magic or possibly python
preprocessing later on.

Signed-off-by: Quentin Young <qlyoung@nvidia.com>
mergeme no stdlib

Signed-off-by: Quentin Young <qlyoung@nvidia.com>
3 years agolib: add Lua stack dumper
Quentin Young [Sun, 11 Aug 2019 19:44:04 +0000 (19:44 +0000)]
lib: add Lua stack dumper

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
3 years agolib: move bgp routemap stuff out of frrlua.[ch]
Quentin Young [Sun, 11 Aug 2019 19:23:35 +0000 (19:23 +0000)]
lib: move bgp routemap stuff out of frrlua.[ch]

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
3 years agolib: remove frrlua_initialize
Quentin Young [Sun, 11 Aug 2019 18:35:16 +0000 (18:35 +0000)]
lib: remove frrlua_initialize

This was toy code used for testing purposes. Code calling Lua should be
very explicit about what is loaded into the Lua state. Also, the
allocator used is exactly the same allocator used by default w/
luaL_newstate().

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
3 years agolib: allow exporting all logging functions to Lua
Quentin Young [Fri, 9 Aug 2019 20:13:07 +0000 (20:13 +0000)]
lib: allow exporting all logging functions to Lua

Add a function that will export FRR's logging functions into a Lua
table, and add that table to the table of your choice (usually _ENV).

For instance, to add logging to the global environment:

  lua_gettable(L, LUA_REGISTRYINDEX);
  lua_gettable(L, LUA_RIDX_GLOBALS);
  frrlua_export_logging(L);

Then the following functions are globally accessible to any Lua scripts
running with state L:

  - log.debug()
  - log.info()
  - log.notice()
  - log.warn()
  - log.error()

These are bound to zlog_debug, zlog_info, etc. They only take one string
argument for now but this shouldn't be an issue given Lua's builtin
facilities for formatting strings.

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
3 years agolib: add interface -> table encoder
Quentin Young [Sat, 11 May 2019 01:51:19 +0000 (01:51 +0000)]
lib: add interface -> table encoder

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
3 years ago*: add Lua 5.3 as a dependency
Quentin Young [Thu, 23 May 2019 21:01:49 +0000 (21:01 +0000)]
*: add Lua 5.3 as a dependency

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
3 years agolib: clean up frrlua.[ch]
Quentin Young [Sat, 11 May 2019 00:55:50 +0000 (00:55 +0000)]
lib: clean up frrlua.[ch]

* Use frrlua_* prefix to differentiate from Lua builtins
* Allow frrlua_initialize to pass an empty script
* Fixup naming of table accessors
* Fixup naming of prefix -> table encoder
* Fixup BGP routemap code to new function names
* Fix includes for frrlua.h
* Clean up doc comments

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
3 years agoMerge pull request #7601 from patrasar/pim_fix
Donald Sharp [Tue, 1 Dec 2020 20:53:53 +0000 (15:53 -0500)]
Merge pull request #7601 from patrasar/pim_fix

Pim fix

3 years agoMerge pull request #7617 from deastoe/dplane-fpm-lsp
Rafael Zalamena [Tue, 1 Dec 2020 19:01:09 +0000 (16:01 -0300)]
Merge pull request #7617 from deastoe/dplane-fpm-lsp

zebra: dplane FPM LSP support

3 years agoMerge pull request #7641 from rampxxxx/fix_run_folder
Donald Sharp [Tue, 1 Dec 2020 17:40:40 +0000 (12:40 -0500)]
Merge pull request #7641 from rampxxxx/fix_run_folder

Fix run folder permissions

3 years agoMerge pull request #7483 from AnuradhaKaruppiah/evpn-mh-dad
Patrick Ruddy [Tue, 1 Dec 2020 17:37:32 +0000 (17:37 +0000)]
Merge pull request #7483 from AnuradhaKaruppiah/evpn-mh-dad

bgpd, zebra: Keep DAD disabled if EVPN MH is turned on

3 years agoMerge pull request #7632 from idryzhov/vtysh-memory-fixes
Donald Sharp [Tue, 1 Dec 2020 17:08:52 +0000 (12:08 -0500)]
Merge pull request #7632 from idryzhov/vtysh-memory-fixes

vtysh memory fixes

3 years agoMerge pull request #7642 from donaldsharp/remove_pimd_version
Mark Stapp [Tue, 1 Dec 2020 16:59:31 +0000 (11:59 -0500)]
Merge pull request #7642 from donaldsharp/remove_pimd_version

pimd: Remove pim_version.c it is never used

3 years agoMerge pull request #7640 from opensourcerouting/bfd-echo-minttl-check
Donald Sharp [Tue, 1 Dec 2020 14:31:57 +0000 (09:31 -0500)]
Merge pull request #7640 from opensourcerouting/bfd-echo-minttl-check

bfdd: session specific command type checks

3 years agopimd: mesh group not removed when configured for multiple groups
Sarita Patra [Wed, 25 Nov 2020 11:00:06 +0000 (03:00 -0800)]
pimd: mesh group not removed when configured for multiple groups

Issue:
Configure msdp mesh mg1 for 2 groups.
ip msdp mesh-group mg1 member 1.1.1.1
ip msdp mesh-group mg1 member 1.1.1.2

Remove mg1 for 1.1.1.1
no ip msdp mesh-group mg1 member 1.1.1.1

mg1 for 1.1.1.1 still present. This is fixed.

Signed-off-by: Sarita Patra <saritap@vmware.com>
3 years agopimd: rp not removed when configured for multiple groups
Sarita Patra [Wed, 25 Nov 2020 08:26:25 +0000 (00:26 -0800)]
pimd: rp not removed when configured for multiple groups

Issue:
Configure RP.
ip pim rp 20.0.0.1 239.1.1.1/32
ip pim rp 20.0.0.1 239.1.1.2/32

Remove RP.
no ip pim rp 20.0.0.1 239.1.1.1/32
Rp is not removed. This is fixed now.

Signed-off-by: Sarita Patra <saritap@vmware.com>
3 years agopimd: Remove pim_version.c it is never used
Donald Sharp [Tue, 1 Dec 2020 12:57:45 +0000 (07:57 -0500)]
pimd: Remove pim_version.c it is never used

The pim_version.[c|h] files are never used and we are getting
warnings about PIM_VERSION changing pointer sizes from
newer versions of the compiler.  I see no reason to keep this

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
3 years agoMerge pull request #7404 from vishaldhingra/pim
Donald Sharp [Tue, 1 Dec 2020 12:48:54 +0000 (07:48 -0500)]
Merge pull request #7404 from vishaldhingra/pim

pimd: (*,G) Prune processing doesn't remove SGRpt ifchannel

3 years agoMerge pull request #7578 from mjstapp/fix_pim_subdir_am
Donald Sharp [Tue, 1 Dec 2020 12:41:33 +0000 (07:41 -0500)]
Merge pull request #7578 from mjstapp/fix_pim_subdir_am

pimd: fix build and compilation errors

3 years agotools: Fix run folder permissions
Javier Garcia [Tue, 1 Dec 2020 11:28:39 +0000 (12:28 +0100)]
tools: Fix run folder permissions

In the case of some linux distros the /var/run dir is mounted
with tmpfs so in every reboot it's removed.
Then the frrcommon.sh will recreate it without 'x' perm
So no pid file cannot be created in /var/run/frr

Signed-off-by: Javier Garcia <rampxxxx@gmail.com>
3 years agobfdd: session specific command type checks
Rafael Zalamena [Tue, 1 Dec 2020 11:01:37 +0000 (08:01 -0300)]
bfdd: session specific command type checks

Replace the unclear error message:

```
% Failed to edit configuration.

YANG error(s):
 Schema node not found.
 YANG path: /frr-bfdd:bfdd/bfd/sessions/single-hop[dest-addr='192.168.253.6'][interface=''][vrf='default']/minimum-ttl
```

With:

```
frr(config-bfd-peer)# minimum-ttl 250
% Minimum TTL is only available for multi hop sessions.

! or

frr(config-bfd-peer)# echo
% Echo mode is only available for single hop sessions.
frr(config-bfd-peer)# echo-interval 300
% Echo mode is only available for single hop sessions.
```

Reported-by: Trae Santiago
Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
3 years agodoc: add description of the new memory macro
Igor Ryzhov [Tue, 1 Dec 2020 08:39:40 +0000 (11:39 +0300)]
doc: add description of the new memory macro

Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
3 years agoMerge pull request #7630 from donaldsharp/snmp_clarity
Donatas Abraitis [Tue, 1 Dec 2020 08:32:06 +0000 (10:32 +0200)]
Merge pull request #7630 from donaldsharp/snmp_clarity

doc: Explicitly call out need to add snmp module

3 years agoMerge pull request #7631 from mjstapp/fix_pw_ctx_leak
Donald Sharp [Mon, 30 Nov 2020 18:48:38 +0000 (13:48 -0500)]
Merge pull request #7631 from mjstapp/fix_pw_ctx_leak

zebra: free dplane ctx after pw update

3 years agovtysh: fix incorrect memory statistics
Igor Ryzhov [Mon, 30 Nov 2020 15:50:51 +0000 (18:50 +0300)]
vtysh: fix incorrect memory statistics

As code comment states, 1 count of MTYPE_COMPLETION is leaked for each
autocompleted token. Let's manually decrement the counter before passing
the pointer to readline.

Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
3 years agovtysh: fix memory leak
Igor Ryzhov [Mon, 30 Nov 2020 15:44:10 +0000 (18:44 +0300)]
vtysh: fix memory leak

Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
3 years agozebra: free dplane ctx after pw update
Mark Stapp [Mon, 30 Nov 2020 15:02:40 +0000 (10:02 -0500)]
zebra: free dplane ctx after pw update

Free the dplane contexts used for pseudowire updates; we were
leaking these.

Signed-off-by: Mark Stapp <mjs@voltanet.io>
3 years agodoc: Explicitly call out need to add snmp module
Donald Sharp [Mon, 30 Nov 2020 13:39:29 +0000 (08:39 -0500)]
doc: Explicitly call out need to add snmp module

The documentation implied how snmp works.  Explicitly call
it out a bit more for future users.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
3 years agoMerge pull request #7621 from idryzhov/fix-cisco-access-list
Rafael Zalamena [Mon, 30 Nov 2020 12:16:33 +0000 (09:16 -0300)]
Merge pull request #7621 from idryzhov/fix-cisco-access-list

yang: fix cisco access list source value

3 years agozebra: dplane FPM LSP table walk
Duncan Eastoe [Fri, 27 Nov 2020 16:12:22 +0000 (16:12 +0000)]
zebra: dplane FPM LSP table walk

Add routines to walk the LSP table and generate FPM updates for all
entries. A walk of the LSP table is triggered when (re-)connecting
to an FPM.

Signed-off-by: Duncan Eastoe <duncan.eastoe@att.com>
3 years agoMerge pull request #7620 from ckishimo/cosmetic2
Rafael Zalamena [Mon, 30 Nov 2020 11:53:33 +0000 (08:53 -0300)]
Merge pull request #7620 from ckishimo/cosmetic2

ospfd: fix a couple of typos

3 years agoMerge pull request #7584 from opensourcerouting/topotest-asan-fix
Donald Sharp [Fri, 27 Nov 2020 22:35:08 +0000 (17:35 -0500)]
Merge pull request #7584 from opensourcerouting/topotest-asan-fix

tests: Fix Topotest runs with newerversion of Address Sanitizer

3 years agoyang: fix cisco access list source value
Igor Ryzhov [Fri, 27 Nov 2020 18:53:25 +0000 (21:53 +0300)]
yang: fix cisco access list source value

Source value must be a choice between host, network and any, not a set
of all three.

Fixes #7599.

Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
3 years agotests: Ignore YANG stderr messages in test_all_protocol_startup test
Martin Winter [Fri, 27 Nov 2020 02:20:16 +0000 (03:20 +0100)]
tests: Ignore YANG stderr messages in test_all_protocol_startup test

Signed-off-by: Martin Winter <mwinter@opensourcerouting.org>
3 years agotests: Fix logging output directory for older tests
Martin Winter [Fri, 27 Nov 2020 02:16:55 +0000 (03:16 +0100)]
tests: Fix logging output directory for older tests

Signed-off-by: Martin Winter <mwinter@opensourcerouting.org>
3 years agotests: Fix FRR process shutdown in failed topotest teardown phase
Martin Winter [Wed, 25 Nov 2020 21:59:40 +0000 (22:59 +0100)]
tests: Fix FRR process shutdown in failed topotest teardown phase

Signed-off-by: Martin Winter <mwinter@opensourcerouting.org>
3 years agotests: Fix Topotest runs with newerversion of Address Sanitizer
Martin Winter [Mon, 23 Nov 2020 03:06:07 +0000 (04:06 +0100)]
tests: Fix Topotest runs with newerversion of Address Sanitizer

Fix Address Sanitizer Issue detection with newer ASAN versions

Signed-off-by: Martin Winter <mwinter@opensourcerouting.org>
3 years agozebra: dplane FPM handle LSP install/update/delete
Duncan Eastoe [Fri, 27 Nov 2020 15:45:35 +0000 (15:45 +0000)]
zebra: dplane FPM handle LSP install/update/delete

Export netlink_lsp_msg_encoder() and use it to encode and send netlink
messages concerning LSP updates to connected FPMs.

Signed-off-by: Duncan Eastoe <duncan.eastoe@att.com>
3 years agoMerge pull request #7614 from donaldsharp/more_use_after_free
Renato Westphal [Fri, 27 Nov 2020 11:51:24 +0000 (08:51 -0300)]
Merge pull request #7614 from donaldsharp/more_use_after_free

ldpd: Prevent usage after free

3 years agoMerge pull request #7593 from opensourcerouting/bgp_features_ospf_fix
Donald Sharp [Thu, 26 Nov 2020 23:36:54 +0000 (18:36 -0500)]
Merge pull request #7593 from opensourcerouting/bgp_features_ospf_fix

tests: Make ospf in bgp_features testsuite predictable

3 years agoMerge pull request #7611 from opensourcerouting/docker_key_update
Donald Sharp [Thu, 26 Nov 2020 23:33:12 +0000 (18:33 -0500)]
Merge pull request #7611 from opensourcerouting/docker_key_update

tests: Update topotest Dockerfile to pick up keys from deb repo

3 years agoldpd: Prevent usage after free
Donald Sharp [Thu, 26 Nov 2020 23:23:57 +0000 (18:23 -0500)]
ldpd: Prevent usage after free

error 26-Nov-2020 14:35:02 ERROR: AddressSanitizer: heap-use-after-free on address 0x631000024838 at pc 0x55cefae977e9 bp 0x7ffdd3546860 sp 0x7ffdd3546850
error 26-Nov-2020 14:35:02 READ of size 4 at 0x631000024838 thread T0
error 26-Nov-2020 14:35:02     #0 0x55cefae977e8 in ldpe_imsg_compose_parent_sync ldpd/ldpe.c:256
error 26-Nov-2020 14:35:02     #1 0x55cefae9ab13 in vlog ldpd/log.c:53
error 26-Nov-2020 14:35:02     #2 0x55cefae9b21f in log_info ldpd/log.c:102
error 26-Nov-2020 14:35:02     #3 0x55cefae96eae in ldpe_shutdown ldpd/ldpe.c:237
error 26-Nov-2020 14:35:02     #4 0x55cefae99254 in ldpe_dispatch_main ldpd/ldpe.c:585
error 26-Nov-2020 14:35:02     #5 0x55cefaf93875 in thread_call lib/thread.c:1681
error 26-Nov-2020 14:35:02     #6 0x55cefae97304 in ldpe ldpd/ldpe.c:136
error 26-Nov-2020 14:35:02     #7 0x55cefae5a2e2 in main ldpd/ldpd.c:322
error 26-Nov-2020 14:35:02     #8 0x7f4ef0c33b96 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x21b96)
error 26-Nov-2020 14:35:02     #9 0x55cefae525e9 in _start (/usr/lib/frr/ldpd+0xb35e9)
error 26-Nov-2020 14:35:02
error 26-Nov-2020 14:35:02 0x631000024838 is located 65592 bytes inside of 65632-byte region [0x631000014800,0x631000024860)
error 26-Nov-2020 14:35:02 freed by thread T0 here:
error 26-Nov-2020 14:35:02     #0 0x7f4ef21e37a8 in __interceptor_free (/usr/lib/x86_64-linux-gnu/libasan.so.4+0xde7a8)
error 26-Nov-2020 14:35:02     #1 0x55cefae96e91 in ldpe_shutdown ldpd/ldpe.c:234
error 26-Nov-2020 14:35:02     #2 0x55cefae99254 in ldpe_dispatch_main ldpd/ldpe.c:585
error 26-Nov-2020 14:35:02     #3 0x55cefaf93875 in thread_call lib/thread.c:1681
error 26-Nov-2020 14:35:02     #4 0x55cefae97304 in ldpe ldpd/ldpe.c:136
error 26-Nov-2020 14:35:02     #5 0x55cefae5a2e2 in main ldpd/ldpd.c:322
error 26-Nov-2020 14:35:02     #6 0x7f4ef0c33b96 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x21b96)
error 26-Nov-2020 14:35:02
error 26-Nov-2020 14:35:02 previously allocated by thread T0 here:
error 26-Nov-2020 14:35:02     #0 0x7f4ef21e3d28 in __interceptor_calloc (/usr/lib/x86_64-linux-gnu/libasan.so.4+0xded28)
error 26-Nov-2020 14:35:02     #1 0x55cefae9725d in ldpe ldpd/ldpe.c:127
error 26-Nov-2020 14:35:02     #2 0x55cefae5a2e2 in main ldpd/ldpd.c:322
error 26-Nov-2020 14:35:02     #3 0x7f4ef0c33b96 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x21b96)

Clean this problem up in the same way as the previous commit

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
3 years agotests: Update topotest Dockerfile to pick up keys from deb repo
Martin Winter [Thu, 26 Nov 2020 13:50:38 +0000 (14:50 +0100)]
tests: Update topotest Dockerfile to pick up keys from deb repo

Signed-off-by: Martin Winter <mwinter@opensourcerouting.org>
3 years agoMerge pull request #7603 from donaldsharp/ospf_crash_fix
Donatas Abraitis [Thu, 26 Nov 2020 12:53:18 +0000 (14:53 +0200)]
Merge pull request #7603 from donaldsharp/ospf_crash_fix

ospfd: Prevent crash by accessing memory not owned.

3 years agoMerge pull request #7586 from kuldeepkash/bgp_multi_vrf
Donatas Abraitis [Thu, 26 Nov 2020 07:48:54 +0000 (09:48 +0200)]
Merge pull request #7586 from kuldeepkash/bgp_multi_vrf

tests: Add tests to bgp_multi_vrf_topo2

3 years agotests: Make ospf convergence predictable by setting if priority
Martin Winter [Mon, 23 Nov 2020 22:34:51 +0000 (23:34 +0100)]
tests: Make ospf convergence predictable by setting if priority

Added OSPF priorities to force a predictable DR/Backup router selection

Signed-off-by: Martin Winter <mwinter@opensourcerouting.org>
3 years agoMerge pull request #7600 from pjdruddy/evpn-mh-sa
Donald Sharp [Wed, 25 Nov 2020 21:30:29 +0000 (16:30 -0500)]
Merge pull request #7600 from pjdruddy/evpn-mh-sa

bgpd: correctly store allocated ES struct

3 years agoMerge pull request #7608 from qlyoung/fix-missing-sockunion-init
Mark Stapp [Wed, 25 Nov 2020 21:07:08 +0000 (16:07 -0500)]
Merge pull request #7608 from qlyoung/fix-missing-sockunion-init

bgpd: remove unused, uninitialized sockunion

3 years agoMerge pull request #7607 from pguibert6WIND/topo_python3_preparation
Mark Stapp [Wed, 25 Nov 2020 19:22:10 +0000 (14:22 -0500)]
Merge pull request #7607 from pguibert6WIND/topo_python3_preparation

Topo python3 preparation

3 years agobgpd: correctly store allocated ES struct
Pat Ruddy [Wed, 25 Nov 2020 10:18:45 +0000 (10:18 +0000)]
bgpd: correctly store allocated ES struct

in the rare situation where we allocate the ES during the path link
we fail to check/store the allocated ES pointer thus leading to a
NULL dereference later in the function.

Signed-off-by: Pat Ruddy <pat@voltanet.io>
3 years agoMerge pull request #7602 from donaldsharp/ldp_use_after_free
Renato Westphal [Wed, 25 Nov 2020 17:51:53 +0000 (14:51 -0300)]
Merge pull request #7602 from donaldsharp/ldp_use_after_free

ldpd: Prevent usage after free

3 years agobgpd: remove unused, uninitialized sockunion
Quentin Young [Wed, 25 Nov 2020 17:49:06 +0000 (12:49 -0500)]
bgpd: remove unused, uninitialized sockunion

Signed-off-by: Quentin Young <qlyoung@nvidia.com>
3 years agotopotests: precise importation folder
Philippe Guibert [Tue, 24 Nov 2020 13:10:16 +0000 (13:10 +0000)]
topotests: precise importation folder

the topolog importation folder must be precised. otherwise following
error message appears:

root@dut-vm:~/topotests/bgp_flowspec# python3 test_bgp_flowspec_topo.py
Traceback (most recent call last):
  File "test_bgp_flowspec_topo.py", line 96, in <module>
    from lib.lutil import lUtil
  File "/root/topotests/bgp_flowspec/../lib/lutil.py", line 25, in <module>
    from topolog import logger
ImportError: No module named 'topolog'
root@dut-vm:~/topotests/bgp_flowspec#

The same error occurs with lutil and bgprib which are 2 libraries
located under lib/ folder. Some precisions are added too.

PR=71290
Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
3 years agotopotests: python3, replace iteritems with items
Philippe Guibert [Wed, 25 Nov 2020 16:23:19 +0000 (16:23 +0000)]
topotests: python3, replace iteritems with items

replace iteritems() calls with items()

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
3 years agotopotests: python3, rename iterkey() with key() for dictionary usage
Philippe Guibert [Wed, 25 Nov 2020 12:49:45 +0000 (12:49 +0000)]
topotests: python3, rename iterkey() with key() for dictionary usage

dictionary method iterkey() is not used in python3 and is replaced with
key() method.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
3 years agotopotests: python3, fix error ValueError: can't have unbuffered text I/O
Philippe Guibert [Wed, 25 Nov 2020 09:32:51 +0000 (09:32 +0000)]
topotests: python3, fix error ValueError: can't have unbuffered text I/O

This error occurs when passing some 0 values to open() extra argument.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
3 years agotopotests: python3, replace execfile with exec
Philippe Guibert [Wed, 25 Nov 2020 09:37:15 +0000 (09:37 +0000)]
topotests: python3, replace execfile with exec

python3 does not support execfile implementation.
replace it with open and exec api that are available in both python 2
and 3 implementations.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
3 years agoospfd: Prevent crash by accessing memory not owned.
Donald Sharp [Wed, 25 Nov 2020 14:49:28 +0000 (09:49 -0500)]
ospfd: Prevent crash by accessing memory not owned.

When allocating memory for the `struct ospf_metric` we
were using `uint32_t` instead of the actual size of this
structure.  When we wrote to it we would be writing
into other people's memory.

Found-by: Amol Lad
Signed-off-by: Donald Sharp <sharpd@nvidia.com>
3 years agoldpd: Prevent usage after free
Donald Sharp [Wed, 25 Nov 2020 12:36:43 +0000 (07:36 -0500)]
ldpd: Prevent usage after free

We are using data after it has been freed and handed back to the
OS.
Address Sanitizer output:

error 23-Nov-2020 18:53:57 ERROR: AddressSanitizer: heap-use-after-free on address 0x631000024838 at pc 0x55f825998f58 bp 0x7fffa5b0f5b0 sp 0x7fffa5b0f5a0
error 23-Nov-2020 18:53:57 READ of size 4 at 0x631000024838 thread T0
error 23-Nov-2020 18:53:57     #0 0x55f825998f57 in lde_imsg_compose_parent_sync ldpd/lde.c:226
error 23-Nov-2020 18:53:57     #1 0x55f8259ca9ed in vlog ldpd/log.c:48
error 23-Nov-2020 18:53:57     #2 0x55f8259cb1c8 in log_info ldpd/log.c:102
error 23-Nov-2020 18:53:57     #3 0x55f82599e841 in lde_shutdown ldpd/lde.c:208
error 23-Nov-2020 18:53:57     #4 0x55f8259a2703 in lde_dispatch_parent ldpd/lde.c:666
error 23-Nov-2020 18:53:57     #5 0x55f825ac3815 in thread_call lib/thread.c:1681
error 23-Nov-2020 18:53:57     #6 0x55f825998d5e in lde ldpd/lde.c:160
error 23-Nov-2020 18:53:57     #7 0x55f82598a289 in main ldpd/ldpd.c:320
error 23-Nov-2020 18:53:57     #8 0x7fe3f749db96 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x21b96)
error 23-Nov-2020 18:53:57     #9 0x55f825982579 in _start (/usr/lib/frr/ldpd+0xb3579)
error 23-Nov-2020 18:53:57
error 23-Nov-2020 18:53:57 0x631000024838 is located 65592 bytes inside of 65632-byte region [0x631000014800,0x631000024860)
error 23-Nov-2020 18:53:57 freed by thread T0 here:
error 23-Nov-2020 18:53:57     #0 0x7fe3f8a4d7a8 in __interceptor_free (/usr/lib/x86_64-linux-gnu/libasan.so.4+0xde7a8)
error 23-Nov-2020 18:53:57     #1 0x55f82599e830 in lde_shutdown ldpd/lde.c:206
error 23-Nov-2020 18:53:57     #2 0x55f8259a2703 in lde_dispatch_parent ldpd/lde.c:666
error 23-Nov-2020 18:53:57     #3 0x55f825ac3815 in thread_call lib/thread.c:1681
error 23-Nov-2020 18:53:57     #4 0x55f825998d5e in lde ldpd/lde.c:160
error 23-Nov-2020 18:53:57     #5 0x55f82598a289 in main ldpd/ldpd.c:320
error 23-Nov-2020 18:53:57     #6 0x7fe3f749db96 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x21b96)
error 23-Nov-2020 18:53:57
error 23-Nov-2020 18:53:57 previously allocated by thread T0 here:
error 23-Nov-2020 18:53:57     #0 0x7fe3f8a4dd28 in __interceptor_calloc (/usr/lib/x86_64-linux-gnu/libasan.so.4+0xded28)
error 23-Nov-2020 18:53:57     #1 0x55f825998cb7 in lde ldpd/lde.c:151
error 23-Nov-2020 18:53:57     #2 0x55f82598a289 in main ldpd/ldpd.c:320
error 23-Nov-2020 18:53:57     #3 0x7fe3f749db96 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x21b96)
error 23-Nov-2020 18:53:57

The fix is to put this in global space.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
3 years agoMerge pull request #7594 from ton31337/feature/show_pfxSnt_for_show_bgp_summary
Donald Sharp [Wed, 25 Nov 2020 12:02:13 +0000 (07:02 -0500)]
Merge pull request #7594 from ton31337/feature/show_pfxSnt_for_show_bgp_summary

bgpd: Show pfxSnt in JSON output for show bgp summary even if not established

3 years agoMerge pull request #7502 from AnuradhaKaruppiah/evpn-mh-irb
Patrick Ruddy [Wed, 25 Nov 2020 09:57:56 +0000 (09:57 +0000)]
Merge pull request #7502 from AnuradhaKaruppiah/evpn-mh-irb

evpn-mh: support for symmetric routing

3 years agotests: Add tests to bgp_multi_vrf_topo2
Kuldeep Kashyap [Mon, 23 Nov 2020 04:37:55 +0000 (04:37 +0000)]
tests: Add tests to bgp_multi_vrf_topo2

1. Added 4 test cases for frr/daemon restart(chaos testing)

Signed-off-by: Kuldeep Kashyap <kashyapk@vmware.com>
3 years agobgpd: Show pfxSnt in JSON output for show bgp summary even if not established
Donatas Abraitis [Tue, 24 Nov 2020 08:22:01 +0000 (10:22 +0200)]
bgpd: Show pfxSnt in JSON output for show bgp summary even if not established

spine1-debian-9# show ip bgp summary json
{
"ipv4Unicast":{
  "routerId":"192.168.3.2",
  "as":200,
  "vrfId":0,
  "vrfName":"default",
  "tableVersion":4,
  "ribCount":1,
  "ribMemory":184,
  "peerCount":1,
  "peerMemory":23384,
  "peers":{
    "192.168.0.1":{
      "hostname":"exit1-debian-9",
      "remoteAs":100,
      "version":4,
      "msgRcvd":5,
      "msgSent":6,
      "tableVersion":0,
      "outq":0,
      "inq":0,
      "peerUptime":"00:00:09",
      "peerUptimeMsec":9000,
      "peerUptimeEstablishedEpoch":1606206209,
      "pfxRcd":0,
      "pfxSnt":0,
      "state":"Idle (Admin)",
      "connectionsEstablished":1,
      "connectionsDropped":1,
      "idType":"ipv4"
    }
  },
  "failedPeers":1,
  "totalPeers":1,
  "dynamicPeers":0,
  "bestPath":{
    "multiPathRelax":"false"
  }
}
}

Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
3 years agoMerge pull request #7591 from opensourcerouting/isisd-bug-fixes
Donald Sharp [Wed, 25 Nov 2020 01:59:50 +0000 (20:59 -0500)]
Merge pull request #7591 from opensourcerouting/isisd-bug-fixes

isisd: assorted bug fixes

3 years agoMerge pull request #7595 from ton31337/feature/bgpState_json
Donald Sharp [Wed, 25 Nov 2020 01:55:34 +0000 (20:55 -0500)]
Merge pull request #7595 from ton31337/feature/bgpState_json

bgpd: Add peerStatus for show bgp summary json

3 years agobgpd: enable L3NHG installation for EVPN host routes by default
Anuradha Karuppiah [Wed, 17 Jun 2020 18:43:58 +0000 (11:43 -0700)]
bgpd: enable L3NHG installation for EVPN host routes by default

L3NHG allows for fast failover of routed traffic (from remote-rack
to local-rack).

Signed-off-by: Anuradha Karuppiah <anuradhak@cumulusnetworks.com>
3 years agobgpd: add a config knob to enable use of L3 NHG for EVPN host routes
Anuradha Karuppiah [Mon, 18 May 2020 22:55:39 +0000 (15:55 -0700)]
bgpd: add a config knob to enable use of L3 NHG for EVPN host routes

Sample config -
vtysh -c "conf t"  -c "router bgp <N>" -c "address-family l2vpn evpn" -c "use-es-l3nhg"

Signed-off-by: Anuradha Karuppiah <anuradhak@cumulusnetworks.com>
3 years agobgpd: Use L3NHGs for symmetric IRB host routes
Anuradha Karuppiah [Fri, 15 May 2020 23:33:41 +0000 (16:33 -0700)]
bgpd: Use L3NHGs for symmetric IRB host routes

Two L3 next groups are installed per-VRF per-ES for v4 and v6. These
NHGs are used as an indirect destination for symmetric IRB host routes.

Using L3NHGs allows for efficient failover of an ES (similar to the
use of L2NHGs) i.e. when an ES goes down the number of dataplane
updates are limited to 2xN (where N is the number of tenant VRFs
associated with the ES) instead of updating all host-routes behind the
ES.

Signed-off-by: Anuradha Karuppiah <anuradhak@cumulusnetworks.com>
3 years agozebra: change the nhg format from hex to dec for easy match up with the dp
Anuradha Karuppiah [Tue, 19 May 2020 00:52:52 +0000 (17:52 -0700)]
zebra: change the nhg format from hex to dec for easy match up with the dp

Dataplane/kernel prints the NHG and NH ids as decimal. Zebra
was printing it as hex (to display type vs. val). This became a
debugging hassle hence normalizing the format.

Signed-off-by: Anuradha Karuppiah <anuradhak@cumulusnetworks.com>
3 years agobgpd: commands to display L3 NHGs and MAC-IP paths linked to an ES
Anuradha Karuppiah [Sat, 9 May 2020 02:49:33 +0000 (19:49 -0700)]
bgpd: commands to display L3 NHGs and MAC-IP paths linked to an ES

Sample output -
===============
torm-11# sh bgp l2vpn evpn es-vrf
ES-VRF Flags: A Active
ESI                            VRF             Flags IPv4-NHG IPv6-NHG Ref
03:44:38:39:ff:ff:01:00:00:01  vrf3            A     1        0        2
03:44:38:39:ff:ff:01:00:00:01  vrf2            A     6        0        4
03:44:38:39:ff:ff:01:00:00:01  vrf1            A     7        0        4
03:44:38:39:ff:ff:01:00:00:02  vrf3            A     2        0        2
03:44:38:39:ff:ff:01:00:00:02  vrf2            A     4        0        4
03:44:38:39:ff:ff:01:00:00:02  vrf1            A     8        0        4

Signed-off-by: Anuradha Karuppiah <anuradhak@cumulusnetworks.com>
3 years agobgpd: use L3NHG while installing EVPN host routes in zebra
Anuradha Karuppiah [Sat, 9 May 2020 02:44:35 +0000 (19:44 -0700)]
bgpd: use L3NHG while installing EVPN host routes in zebra

Host routes imported into the VRF can have a destination ES (per-VRF)
which is set up as a L3NHG for efficient failover.

Signed-off-by: Anuradha Karuppiah <anuradhak@cumulusnetworks.com>
3 years agobgpd: Handle ES VTEP add/del to a host route
Anuradha Karuppiah [Sat, 9 May 2020 02:36:47 +0000 (19:36 -0700)]
bgpd: Handle ES VTEP add/del to a host route

1. MAC-IP routes in the VPN routing table are linked to the
destination ES for efficient handling for remote ES link flaps.
2. Only MAC-IP paths whose nexthops are active (added via EAD-ES)
are imported into the VRF routing table.

Signed-off-by: Anuradha Karuppiah <anuradhak@cumulusnetworks.com>
3 years agobgpd: L3NHG infrastructure for host routes in EVPN
Anuradha Karuppiah [Sat, 9 May 2020 02:24:56 +0000 (19:24 -0700)]
bgpd: L3NHG infrastructure for host routes in EVPN

ES-VRF entries are maintained for the purpose of L3-NHG creation -
1. Each ES-EVI entry is associated with a tenant VRF. This associaton
triggers the creation of an ES-VRF entry.
2. Type-2/MAC-IP routes are imported into a tenant VRF and programmed as
a /32 or host route entry in the dataplane. If the destination of
the host route is a remote-ES the route is programmed with the
corresponding (keyed in by {vrf,ES-id}) L3-NHG.
3. The reason for this indirection (route->L3-NHG, L3-NHG->list-of-VTEPs)
is to avoid route updates to the dplane when a remote-ES link flaps i.e.
instead of updating all the dependent routes the NHG's contents are
updated. This reduces the amount of dataplane updates (fewer nhg updates vs.
route updates) allowing for a faster failover.

Signed-off-by: Anuradha Karuppiah <anuradhak@cumulusnetworks.com>
3 years agobgpd: skip VRF import of MAC-IP routes that belong to locally attached hosts
Anuradha Karuppiah [Sat, 9 May 2020 02:19:57 +0000 (19:19 -0700)]
bgpd: skip VRF import of MAC-IP routes that belong to locally attached hosts

Local attached hosts are routed via the access ports using the neigh and
fdb/MAC dplane entries.

Signed-off-by: Anuradha Karuppiah <anuradhak@cumulusnetworks.com>
3 years agozebra: Keep DAD disabled if EVPN MH is turned on
Anuradha Karuppiah [Mon, 11 May 2020 01:02:37 +0000 (18:02 -0700)]
zebra: Keep DAD disabled if EVPN MH is turned on

DAD is not supported currently with EVPN-MH so we turn it off internally
when the first ES config is detected.

PS: Note that when all local ESs are deleted DAD will stay off and
will need to be cleared via a daemon restart.

Signed-off-by: Anuradha Karuppiah <anuradhak@cumulusnetworks.com>
3 years agoMerge pull request #7475 from eololab/add-more-parameters-for-crosscompilation
Quentin Young [Tue, 24 Nov 2020 16:44:29 +0000 (11:44 -0500)]
Merge pull request #7475 from eololab/add-more-parameters-for-crosscompilation

build: add more precious variables for cross-compilation

3 years agoMerge pull request #7560 from opensourcerouting/fix_topotest_logs
Donald Sharp [Tue, 24 Nov 2020 16:30:14 +0000 (11:30 -0500)]
Merge pull request #7560 from opensourcerouting/fix_topotest_logs

topotests: Fix logging by redirecting it to correct file

3 years agoospfd: fix a couple of typos
ckishimo [Tue, 24 Nov 2020 15:35:49 +0000 (07:35 -0800)]
ospfd: fix a couple of typos

Signed-off-by: ckishimo <carles.kishimoto@gmail.com>