Commit Graph

4978 Commits

Author SHA1 Message Date
Donald Sharp
575a25974b lib: Add ZCAP_IPC_LOCK
We'll need ZCAP_IPC_LOCK for future work coming down the pike
related to dataplane work being done.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2021-05-11 19:54:40 -04:00
Rafael Zalamena
34723b2fad
Merge pull request #8639 from idryzhov/isis-new-bfd-lib
isisd: rework BFD integration
2021-05-09 17:10:42 -03:00
David Lamparter
de10458d6e
Merge pull request #8380 from mjstapp/nexthop_cmp_basic 2021-05-09 19:29:45 +02:00
Igor Ryzhov
d0bb3c542c
Merge pull request #8632 from wesleycoakley/le-32-128-fix
lib: ip prefix-list "le" and "ge" bug squish
2021-05-07 12:05:59 +03:00
Igor Ryzhov
c97b34cf1a lib: remove old bfd library
This commit also adds missing `bfd_protocol_integration_set_shutdown` to
ospf6d and pimd.

Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2021-05-07 12:03:57 +03:00
Wesley Coakley
6907bb6bbf
lib: ip prefix-list enforce expected ge le behavior
When specifying only an "le" for an existing ip prefix-list qualified with
both an "le" and "ge" make sure to remove the "ge" property so it does
not stay in the tree.

E.g. Saying these two things in order:

ip prefix-list test seq 1 permit 1.1.0.0/16 ge 18 le 24
ip prefix-list test seq 1 permit 1.1.0.0/16 ge 18

... should result in the second statement "overwriting" the first like
this:

vxdev-arch# do show ip prefix-list
ZEBRA: ip prefix-list foobar: 3 entries
   seq 1 permit 15.0.0.0/16 ge 18

Previously this did not happen and "le" would stick around since it was
never given NB_OP_DESTROY and purged from the data tree.

Signed-off-by: Wesley Coakley <wcoakley@nvidia.com>
2021-05-06 14:07:06 -04:00
Donatas Abraitis
ed0e57e3f0 bgpd: Create BGP alias names for community/large-community
Show alias name instead of numerical value in `show bgp <prefix>. E.g.:

```
root@exit1-debian-9:~/frr# vtysh -c 'sh run' | grep 'bgp community alias'
bgp community alias 65001:123 community-1
bgp community alias 65001:123:1 lcommunity-1
root@exit1-debian-9:~/frr#
```

```
exit1-debian-9# sh ip bgp 172.16.16.1/32
BGP routing table entry for 172.16.16.1/32, version 21
Paths: (2 available, best #2, table default)
  Advertised to non peer-group peers:
  65030
    192.168.0.2 from home-spine1.donatas.net(192.168.0.2) (172.16.16.1)
      Origin incomplete, metric 0, valid, external, best (Neighbor IP)
      Community: 65001:12 65001:13 community-1 65001:65534
      Large Community: lcommunity-1 65001:123:2
      Last update: Fri Apr 16 12:51:27 2021
exit1-debian-9#
```

Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
2021-05-05 16:37:00 +03:00
Mark Stapp
3d4b999fab
Merge pull request #8237 from pguibert6WIND/nhrp_use_zebra_2
Nhrp use zebra 2
2021-05-05 07:57:04 -04:00
Donatas Abraitis
48c2039199
Merge pull request #8564 from rameshabhinay/bgp_tcp_mss
bgpd: Support tcp-mss for bgp neighbors
2021-05-05 13:45:39 +03:00
Donald Sharp
eda0ea2949 lib: Remove dead code
The distribute_list_init command is not used and is setup
code that will never be used because it makes assumptions about
how distribute-lists work that are fundamentally incorrect.

Remove the code.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2021-05-04 16:23:37 -04:00
Donald Sharp
458133dbc5 lib, ripd, ripngd, vtysh: Move distribute list to correct spot
Allow the `distribute-list...` command in ripd and ripngd to
work correctly.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2021-05-04 16:23:37 -04:00
Donald Sharp
df19c76a53 lib: Abstract parsing of distribute lists
Abstract the parsing of distribute lists so that we
don't have as much cut-n-paste code.

This is a setup commit for future work.  In effect
current distribute-list handling is all kinds of messed up

a) eigrp and babel both attempt to use distribute-lists, they just plain
don't work.
b) `distribute-list` is only sent to rip.  `ipv6 distribute-list`
is sent to ripngd.  If you use `distribute-list` under `router ripng`
it sends the command to rip but ripd is in the wrong mode and it
never works.
c) Should ripngd care about v4 and v6 specific distribute-lists?
This dichotomy was added for babel but babel has been broke
about this since day 1( see a ).

All in all we need to unwind this whole mess.  Make distribute-list
commands specific to the daemons( so that we can be in the right
sub-mode ).  But the parsing is going to be the same across all
daemons.  So let's provide that functionality in `lib/distribute.c`

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2021-05-04 16:23:37 -04:00
Mark Stapp
338ec3b867 lib: add basic nexthop comparison api
Add a simpler, more limited nexthop comparison function. This
compares a few key attributes, such as vrf, gateway, labels.

Signed-off-by: Mark Stapp <mjs@voltanet.io>
2021-05-04 15:51:01 -04:00
Mark Stapp
26dddc01a8 lib: Fix label-stack comparison for nexthops
Use the correct number of octets in the comparison of
nexthops' label stacks.

Signed-off-by: Mark Stapp <mjs@voltanet.io>
2021-05-04 11:18:08 -04:00
Abhinay Ramesh
4ab467017e bgpd: Support tcp-mss for bgp neighbors
Problem Statement:
=================
In scale setup BGP sessions start flapping.

RCA:
====
In virtualized environment there are multiple places where
MTU need to be set. If there are some places were MTU is not set
properly then there is chances that BGP packets get fragmented,
in scale setup this will lead to BGP session flap.

Fix:
====
A new tcp option is provided as part of this implementation,
which can be configured per neighbor and helps to set the TCP
max segment size. User need to derive the path MTU between the BGP
neighbors and set that value as part of tcp-mss setting.

1. CLI Configuration:
	[no] neighbor <A.B.C.D|X:X::X:X|WORD> tcp-mss (1-65535)

2. Running config
    frr# show running-config
    router bgp 100
     neighbor 198.51.100.2 tcp-mss 150       => new entry
     neighbor 2001:DB8::2 tcp-mss 400        => new entry

3. Show command
    frr# show bgp neighbors 198.51.100.2
    BGP neighbor is 198.51.100.2, remote AS 100, local AS 100, internal link
    Hostname: frr
      Configured tcp-mss is 150, synced tcp-mss is 138     => new display

4. Show command json output

    frr# show bgp neighbors 2001:DB8::2 json
    {
      "2001:DB8::2":{
        "remoteAs":100,
        "bgpTimerKeepAliveIntervalMsecs":60000,
        "bgpTcpMssConfigured":400,                               => new entry
        "bgpTcpMssSynced":388,                                  => new entry

Risk:
=====
Low - This is a config driven feature and it sets the max segment
size for the TCP session between BGP peers.

Tests Executed:
===============
Have done manual testing with three router topology.
1. Executed basic config and un config scenarios
2. Verified if the config is updated in running config
   during config and no config operation
3. Verified the show command output in both CLI format and
   JSON format.
4. Verified if TCP SYN messages carry the max segment size
   in their initial packets.
5. Verified the behaviour during clear bgp session.
6. done packet capture to see if the new segment size
   takes effect.

Signed-off-by: Abhinay Ramesh <rabhinay@vmware.com>
2021-05-04 06:21:24 +00:00
David Lamparter
02fb02de37 lib: kill unused list_filter_out_nodes()
pimd was the only user of this function, and that has gone away now.
So just kill the function.

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2021-05-03 20:56:55 +02:00
David Lamparter
507e0e5d66 lib: add *_swap_all to typesafe containers
Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2021-05-03 20:55:04 +02:00
Mark Stapp
f71e1ff6a9
Merge pull request #8545 from opensourcerouting/assert-our-own
*: make our own assert() actually work
2021-05-03 11:17:36 -04:00
David Lamparter
9cd090488c
Merge pull request #8479 from mjstapp/zlog_immediate 2021-05-03 10:40:54 +02:00
David Lamparter
4f1a6d98da lib: fix random C++ compat problem w/ printfrr
These hoops to get warnings for mis-printing `uint64_t` are apparently
breaking some C++ bits...

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2021-05-02 16:27:17 +02:00
David Lamparter
64dd77361f lib: rework how we "override" assert()
The previous method, using zassert.h and hoping nothing includes
assert.h (which, on glibc at least, just does "#undef assert" and puts
its own definition in...) was fragile - and actually broke undetected.

Just provide our own assert.h and control overriding by putting it in a
separate directory to add to the include path (or not.)

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2021-05-02 16:27:17 +02:00
Donald Sharp
188acbb9a3 lib: Provide some better error handling for operator
When an operator encounters a situation where the number
of FD's open is greater than what we have been configured
to legitimately handle via uname or the `--limit-fds` command
line, abort with a message that they should be able to
debug and figure out what is going on.

Fixes: #8596
Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2021-05-02 07:41:11 -04:00
Philippe Guibert
aea6c49e01 nhrpd: cleaning netlink gre information
flush netlink related dependencies with gre information.
Add some linux headers required to compile with it.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2021-04-30 10:33:18 +02:00
Philippe Guibert
d17af8dd04 lib, zebra: get gre information
the get gre information code is obtained by nhrp, via zebra.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2021-04-30 10:33:18 +02:00
Philippe Guibert
632d83067c zebra: add 3 new gre commands, and enforce synchro mecanism
3 new gre commands are available:
- GRE_GET to permit a daemon to retrieve gre information.
- GRE_UPDATe is the reply message from zebra to the daemon. as it is a
  syncronous request, the GRE_GET expected will have to match the vrf id
  where the gre information is wished. this has an impact on label
  manager with change in APIs.
- SET_GRE_SOURCE. this command will be stubbed for now, assuming that
  the gre interface is set accordingly by external script.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2021-04-30 10:33:18 +02:00
Rafael Zalamena
c962ab93a8
Merge pull request #8570 from qlyoung/revert-ringbuf-readv
Revert "bgpd: improve socket read performance"
2021-04-29 18:32:52 -03:00
Rafael Zalamena
5418880923
Merge pull request #7165 from qlyoung/fix-zapi-codec-badness
Fix zapi codec badness
2021-04-29 13:50:16 -03:00
Quentin Young
6c55ee964e Revert "lib: add ringbuf socket read function"
This reverts commit d9d7af1a52.
2021-04-29 12:12:32 -04:00
Pavel Ivashchenko
4bb7f7c2dd vtysh: fix searching commands in parent nodes
Do not check parent command nodes in case of ambiguous and incomplete commands

Signed-off-by: Pavel Ivashchenko <pivashchenko@nfware.com>
2021-04-29 18:35:07 +03:00
Igor Ryzhov
55ea3f2ec5
Merge pull request #8110 from rgirada/rmap_nb
lib: Routemap is not getting applied upon changing the routemap action
2021-04-29 17:29:55 +03:00
rgirada
4fc5dafd1c lib: Routemap is not getting applied upon changing the routemap action
Description:
	This looks broken after NB changes in routemap. When routemap
	action modified from permit to deny, it is expected to apply
	the new action on the filtered routes before the action in the
	routemap data structure has been changed. But currently this is
	not handled by the corresponding northbound API.

Signed-off-by: Rajesh Girada <rgirada@vmware.com>
2021-04-29 17:23:37 +03:00
Mark Stapp
ca4681d151
Merge pull request #8559 from idryzhov/fix-printfrr-test-build
tests: fix build warning
2021-04-29 10:12:44 -04:00
Igor Ryzhov
faaa943137 tests: fix build warning
FMT_NSTD_BEGIN should be before the first use of "expr".

Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2021-04-29 03:28:04 +03:00
Quentin Young
bbad027684 lib, bgpd, zebra: RA interval is unsigned
Use unsigned value for all RA requests to Zebra

- encoding signed int as unsigned is bad practice
- RA interval is never, and should never be, negative

Signed-off-by: Quentin Young <qlyoung@nvidia.com>
2021-04-28 11:43:50 -04:00
Donatas Abraitis
a1fc0cb01e
Merge pull request #8471 from idryzhov/cleanup-num-named-lists
*: cleanup number-named access-lists and prefix-lists
2021-04-28 08:33:24 +03:00
Russ White
0a9fdfee67
Merge pull request #8527 from opensourcerouting/fixes-20210421
lib: fix zlog assert() & CLI node_exit
2021-04-27 15:14:12 -04:00
Stephen Worley
829c939a88
Merge pull request #8488 from mjstapp/more_workqueue
lib, zebra: use zebra workqueue for NHG updates
2021-04-27 11:59:33 -04:00
Mark Stapp
8123bf2bd6
Merge pull request #8534 from opensourcerouting/threads-vs-fork
lib, pathd PCEP: creating threads before forking does _not_ work
2021-04-26 07:57:15 -04:00
Igor Ryzhov
2ccc493333
Merge pull request #8495 from opensourcerouting/ospfv3-bfd-rework
ospf6d: rework BFD integration and add BFD profiles support
2021-04-24 00:47:31 +03:00
David Lamparter
642ac49da4 *: remaining zassert => assert
Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2021-04-23 12:25:51 +02:00
David Lamparter
6a0eb6885b *: drop zassert.h
It's not actually working properly...

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2021-04-23 12:06:35 +02:00
David Lamparter
1f8031f79a *: make sure config.h or zebra.h is first
`config.h` has all the defines from autoconf, which may include things
that switch behavior of other included headers (e.g. _GNU_SOURCE
enabling prototypes for additional functions.)

So, the first include in any `.c` file must be either `config.h` (with
the appropriate guard) or `zebra.h` (which includes `config.h` first
thing.)

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2021-04-23 12:06:35 +02:00
Rafael Zalamena
ac506cb20e lib: BFD session handling improvement
Don't uninstall sessions if the address, interface, VRF or TTL didn't change.

Update the library documentation to make it clear to other developers.

Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
2021-04-22 16:10:04 -03:00
Rafael Zalamena
464e6541b1 lib: fix possible crash on BFD notification
Allow sessions to remove themselves from the notifications without
risking crashes.

Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
2021-04-22 15:12:18 -03:00
Rafael Zalamena
b38f1fd03d
Merge pull request #8536 from idryzhov/bfd-enabled
lib: remove enabled flag for bfd sessions
2021-04-22 15:06:48 -03:00
Igor Ryzhov
e82acdce22 lib: remove enabled flag for bfd sessions
Currently this flag is only helpful in an extremely rare situation when
the BFD session registration was unsuccessful and after that zebra is
restarted. Let's remove this flag to simplify the API. If we ever want
to solve the problem of unsuccessful registration/deregistration, this
can be done using internal flags, without API modification.

Also add the error log to help user understand why the BFD session is
not working.

Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2021-04-22 16:39:29 +03:00
David Lamparter
38554d3ae6 lib: hard-fail creating threads before fork()
Creating any threads before we fork() into the background (if `-d` is
given) is an extremely dangerous footgun;  the threads are created in
the parent and terminated when that exits.

This is extra dangerous because while testing, you'd often run the
daemon in foreground without `-d`, and everything works as expected.

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2021-04-22 13:25:38 +02:00
David Lamparter
bf645e31f6 lib: add frr_config_pre hook
... for any initialization that needs to run after forking, but that
would be racy if it were just scheduled on the thread_master (since the
config load is also just a thread callback, ordering would be undefined
for another scheduled thread callback.)

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2021-04-22 13:20:34 +02:00
David Lamparter
2bafda27a6 lib: rename very_late_init hook to config_post
very_late_init doesn't really say what this does, config_post is much
more descriptive.  (A config_pre is coming in a jiffy.)

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2021-04-22 13:16:20 +02:00
David Lamparter
e3476061fe lib: correctly exit CLI nodes on file config load
The (legacy) code for reading split configs tries to execute config
commands in parent nodes, but doesn't call the node_exit function when
it goes up to a parent node.  This breaks BGP RPKI setup (and extended
syslog, which is in the next commit.)

Doing this correctly is a slight bit involved since the node_exit
callbacks should only be called if the command is actually executed on a
parent node.

Signed-off-by: David Lamparter <equinox@diac24.net>
2021-04-21 16:25:38 +02:00
David Lamparter
db2baed166 lib: fix possible assert() fail in zlog_fd()
If the last message in a batched logging operation isn't printed due to
priority, this skips the code that flushes prepared messages through
writev() and can trigger the assert() at the end of zlog_fd().

Since any logmsg above info priority triggers a buffer flush, running
into this situation requires a log file target configured for info
priority, at least 1 message of info priority buffered, a debug message
buffered after that, and then a buffer flush (explicit or due to buffer
full).

I haven't seen this chain of events happen in the wild, but it needs
fixing anyway.

Signed-off-by: David Lamparter <equinox@diac24.net>
2021-04-21 16:25:33 +02:00
David Lamparter
1b636c0ad4 build: run autoupdate
AC_TRY_COMPILE is deprecated too.  Also configure.ac isn't executable.

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2021-04-21 15:42:37 +02:00
David Lamparter
19083e4f75 build: remove deprecated AC_WORDS_BIGENDIAN
Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2021-04-21 15:42:37 +02:00
David Lamparter
0c4285d77e build: properly split CFLAGS from AC_CFLAGS
`CFLAGS` is a "user variable", not intended to be controlled by
configure itself.  Let's put all the "important" stuff in AC_CFLAGS and
only leave debug/optimization controls in CFLAGS.

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2021-04-21 15:42:36 +02:00
David Lamparter
09781197b6 build: make builddir include path consistent
... by referencing all autogenerated headers relative to the root
directory.  (90% of the changes here is `version.h`.)

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2021-04-21 15:42:33 +02:00
Mark Stapp
7c945dff61 lib: add 'log immediate-mode' cli
Add a cli to control immediate-output mode for logs and debugs.
Add this to the user docs also.

Signed-off-by: Mark Stapp <mjs@voltanet.io>
2021-04-20 12:55:08 -04:00
Mark Stapp
42ddefe816 libs: add api to enable immediate output of zlog
The log module buffers outgoing messages by default; add an
api to turn that off, and emit messages immediately.

Signed-off-by: Mark Stapp <mjs@voltanet.io>
2021-04-20 12:48:06 -04:00
David Lamparter
4b4935bbc2 lib: fix bogus unlinkat() warning in zlog TLS exit
Only try to unlink the buffer if we actually set it up beforehand...

Signed-off-by: David Lamparter <equinox@diac24.net>
2021-04-19 05:47:09 +02:00
David Lamparter
5be4799dc5 lib: don't print 2 backtraces for crashes
abort() raises SIGABRT, which would confusingly cause a 2nd backtrace to
be printed after the first one...

Signed-off-by: David Lamparter <equinox@diac24.net>
2021-04-19 05:35:04 +02:00
Mark Stapp
861ea6f268
Merge pull request #8465 from opensourcerouting/vtysh-scan-snafu
fix vtysh_scan SNAFUs
2021-04-16 08:23:20 -04:00
David Lamparter
ee4dcee834 vtysh: add lib/thread.c to vtysh_scan
Signed-off-by: David Lamparter <equinox@diac24.net>
2021-04-15 23:12:45 +02:00
David Lamparter
9cb089fc43 vtysh: add lib/resolver.c to vtysh_scan
Signed-off-by: David Lamparter <equinox@diac24.net>
2021-04-15 23:12:45 +02:00
David Lamparter
c4e57cd52e vtysh: add lib/spf_backoff.c to vtysh_scan
Signed-off-by: David Lamparter <equinox@diac24.net>
2021-04-15 23:12:45 +02:00
David Lamparter
48843422d3 vtysh: add lib/log_vty.c to vtysh_scan
Rather than copying everything over, include the file in vtysh_scan for
automatic pickup.

Signed-off-by: David Lamparter <equinox@diac24.net>
2021-04-15 23:12:45 +02:00
Quentin Young
dc92ca52c5
Merge pull request #8483 from opensourcerouting/asan-fix
lib: disable ASAN redzone around xref_p/xref_array
2021-04-15 20:46:35 +00:00
Mark Stapp
90b0718e07 lib: add 2string for zapi nhg result codes
Add a utility '2string' function for daemon nhg result codes.

Signed-off-by: Mark Stapp <mjs@voltanet.io>
2021-04-15 14:17:02 -04:00
Igor Ryzhov
dceb1b6223
Merge pull request #8477 from opensourcerouting/lib-bfd-fix 2021-04-15 09:32:23 +03:00
David Lamparter
1b958b2ef8 lib: disable ASAN redzone around xref_p/xref_array
The "xref_p" variables are placed in the "xref_array" section
specifically so they're next to each other and we get an array at the
end.  The ASAN redzone that is inserted around global variables is
breaks that since it'd be inserted before and after each of the array
items.  So disable the ASAN redzone for these variables (and only these
variables, nothing else should be affected.)

Signed-off-by: David Lamparter <equinox@diac24.net>
2021-04-15 06:27:34 +02:00
Renato Westphal
1e3937b33d
Merge pull request #8467 from idryzhov/fix-acl-delete
lib: fix access-list deletion
2021-04-14 23:58:39 -03:00
Rafael Zalamena
9c39d19742 lib: fix BFD crash on interface removal
- Handle badly formatted messages (don't set `ifp` in that case)
- Handle unread messages (e.g. when family is not don't trigger `assert`)

Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
2021-04-14 15:28:09 -03:00
Patrick Ruddy
5bb91468c5
Merge pull request #8003 from donaldsharp/timings
lib: Differentiate between real and cpu bound processes
2021-04-14 18:33:18 +01:00
Igor Ryzhov
3eff8e2f44 *: cleanup number-named access-lists and prefix-lists
A long time ago there was a difference between number-named and string-named
access/prefix-lists. Currently we always treat the name as a string and
there is no need for a separate list for number-named lists.

Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2021-04-14 17:18:13 +03:00
Donald Sharp
8a2ec9102f
Merge pull request #8320 from idryzhov/prefix-list-seqnum
lib: remove "ip prefix-list sequence-number" command
2021-04-14 09:21:28 -04:00
Igor Ryzhov
8c4796a22d lib: fix access-list deletion
Problems with the current implementation:
* Delete hook is called before the deletion of the access-list from the
  master list, which means that daemons processing this hook successfully
  find this access-list, store a pointer to it in their structures, and
  right after that the access-list is freed. Daemons end up having stale
  pointer to the freed structure.
* Route-maps are not notified of the deletion.

This commit fixes both issues.

Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2021-04-14 13:08:18 +03:00
Russ White
0ae24ff566
Merge pull request #8414 from idryzhov/fix-filter-cli
various acl/plist cli fixes
2021-04-13 11:38:51 -04:00
Quentin Young
54bb4ab3ec
Merge pull request #8426 from idryzhov/fix-interface-nb-stale-pointers
lib: fix interface nb stale pointers
2021-04-13 15:26:51 +00:00
Mark Stapp
f3dbd9d3ef
Merge pull request #8145 from pguibert6WIND/nhrp_use_zebra
nhrp: use zebra
2021-04-13 08:02:56 -04:00
Philippe Guibert
88217099de zebra, lib: replace ZEBRA_ROUTE_NEIGH with simplified version
do not add a new route type, and consider 0 as a value meaning
that zebra should be the owner.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2021-04-13 08:58:54 +02:00
Philippe Guibert
d603c0774e nhrp, zebra, lib: enforce usage of zapi_neigh_ip structure
zapi_nbr structure is renamed to zapi_neigh_ip.
Initially used to set a neighbor ip entry for gre interfaces, this
structure is used to get events from the zebra layer to nhrp layer.

The ndm state has been added, as it is needed on both sides.
The zebra dplane layer is slightly modified.

Also, to clarify what ZEBRA_NEIGH_ADD/DEL means, a rename is done:
it is called now ZEBRA_NEIGH_IP_ADD/DEL, and it signified that this
zapi interface permits to set link operations by associating ip
addresses to link addresses.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2021-04-13 08:58:49 +02:00
Renato Westphal
b6241291ee
Merge pull request #8389 from idryzhov/route-map-optimization-nb
lib: convert route-map optimization to NB
2021-04-13 00:26:20 -03:00
David Lamparter
1df904706c
Merge pull request #8288 from qlyoung/readd-space-support-to-find-command 2021-04-13 02:22:46 +02:00
Mark Stapp
53c42c82de
Merge pull request #8421 from opensourcerouting/xrelfo-arm
fix xrelfo on ARM(32) & cross-compile
2021-04-12 08:07:05 -04:00
Igor Ryzhov
af736200e1 lib: fix interface nb stale pointers
The first change in this commit is the processing of the VRF termination.
When we terminate the VRF, we should not delete the underlying interfaces,
because there may be pointers to them in the northbound configuration. We
should move them to the default VRF instead.

Because of the first change, the VRF interface itself is also not deleted
when deleting the VRF. It should be handled in netlink_link_change. This
is done by the second change.

Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2021-04-12 10:56:04 +03:00
Igor Ryzhov
38133c4a11 lib, doc: add "route-map NAME optimization" command
Currently we have a "route-map optimization" command which is entered
from inside the route-map entry but actually applies to the whole
route-map. In addition, this command is not shown in the running-config
and not stored to the startup-config during "write".

Let's add a new command on the config node level to control this setting
and show it in the running-config to make possible to save it during
"write".

The old command is saved for the backward compatibility but hidden and
marked as deprecated.

Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2021-04-09 20:58:36 +03:00
Philippe Guibert
0a27a2fef5 zebra, lib: handle NEIGH_ADD/DELETE to zebra dataplane framework
EVPN neighbor operations were already done in the zebra dataplane
framework. Now that NHRP is able to use zebra to perform neighbor IP
operations (by programming link IP operations), handle this operation
under dataplane framework:
- assign two new operations NEIGH_IP_INSTALL and NEIGH_IP_DELETE; this
is reserved for GRE like interfaces:
example: ip neigh add A.B.C.D lladdr E.F.G.H
- use 'struct ipaddr' to store and encode the link ip address
- reuse dplane_neigh_info, and create an union with mac address
- reuse the protocol type and use it for neighbor operations; this
permits to store the daemon originating this neighbor operation.
a new route type is created: ZEBRA_ROUTE_NEIGH.
- the netlink level functions will handle a pointer, and a type; the
type indicates the family of the pointer: AF_INET or AF_INET6 if the
link type is an ip address, mac address otherwise.
- to keep backward compatibility with old queries, as no extension was
done, an option NEIGH_NO_EXTENSION has been put in place
- also, 2 new state flags are used: NUD_PERMANENT and NUD_FAILED.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2021-04-09 18:29:58 +02:00
Philippe Guibert
451e2b8c7e lib: add api to configure neighbor table per interface
this api is needed for nhrp. the goal is to implement it in zebra, while
other daemon will used it.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2021-04-09 18:29:58 +02:00
Philippe Guibert
05657ec2b7 nhrp, lib, zebra: add/del neighbor entry possible from nhrp
a zebra api is extended to offer ability to add or remove neighbor
entry from daemon. Also this extension makes possible to add neigh
entry, not only between IPs and macs, but also between IPs and NBMA IPs.
This API supports configuring ipv6/ipv4 entries with ipv4/ipv6 lladdr.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2021-04-09 18:29:58 +02:00
Philippe Guibert
7723e8d3fd zebra: link layer config and notification, implementation in zebra
zebra implements zebra api for configuring link layer information. that
can be an arp entry (for ipv4) or ipv6 neighbor discovery entry. This
can also be an ipv4/ipv6 entry associated to an underlay ipv4 address,
as it is used in gre point to multipoint interfaces.
this api will also be used as monitoring. an hash list is instantiated
into zebra (this is the vrf bitmap). each client interested in those entries
in a specific vrf, will listen for following messages: entries added, removed,
or who-has messages.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2021-04-09 18:29:58 +02:00
Philippe Guibert
fda64ab443 lib: link layer neighbor registration and notification, define API msgs
This patch implements new zapi api to get neighbor information that zebra knows
and that other daemons may need to know. Actually, nhrp daemons is
interested in getting the neighbor information on gre interfaces, and
the API will be used for that.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2021-04-09 18:29:58 +02:00
Igor Ryzhov
83c4442202 ospfd: fix crash on "show ip ospf neighbor detail"
Fixes #8419.

Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2021-04-09 11:24:51 +03:00
David Lamparter
81693617a2 lib: add DT_REL to elf_py/clippy ELF code
ARM (32-bit) needs DT_REL... and here I was hoping I could avoid the
trouble.

Fixes: #8355
Signed-off-by: David Lamparter <equinox@diac24.net>
2021-04-08 00:00:08 +02:00
Quentin Young
767f67a456 lib, vtysh: re-add support for spaces in 'find'
Lost ability to handle them in the regex patch

Signed-off-by: Quentin Young <qlyoung@nvidia.com>
2021-04-07 13:39:56 -04:00
Igor Ryzhov
1dc32c419d lib: delete empty access-lists
We should delete the access-list when the last entry and remark is
deleted. This is already done for prefix-lists.

Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2021-04-06 23:18:47 +03:00
Igor Ryzhov
ad2b07055c lib: fix deletion of empty prefix-lists
We delete the prefix-list when its last entry is deleted, but the check
is missed when we delete the description.

Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2021-04-06 23:18:47 +03:00
Igor Ryzhov
a0145975e3 lib: fix usage of operational data in CLI
CLI must never use operational data, because this won't work in
transactional mode. Rework search for prefix-list/access-list entries
using only candidate config.

Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2021-04-06 23:18:47 +03:00
Mark Stapp
e08165def1 lib: logic and macro cleanup in frr_zmq shim
Fix a couple of logic/macro issues in the frr_zmq shim
module.

Signed-off-by: Mark Stapp <mjs@voltanet.io>
2021-04-06 14:41:45 -04:00
Mark Stapp
1dffe35773 lib: use public task-scheduling apis
The frr_zmq shim was trying to use some internal scheduling
macros, and that was causing trouble. Just use the public
apis.

Signed-off-by: Mark Stapp <mjs@voltanet.io>
2021-04-06 14:40:39 -04:00
Igor Ryzhov
451e6dcfc7 lib: fix check for duplicated access-list entries
The correct string representation for "empty" type is an empty string.

Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2021-04-06 20:38:24 +03:00
Igor Ryzhov
3ebeec9446 lib: convert route-map optimization to NB
Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2021-04-06 19:00:21 +03:00
Donald Sharp
f243fd3d90
Merge pull request #8376 from mjstapp/fix_remove_inet6_ntoa
lib, ripngd: Remove inet6_ntoa
2021-04-02 09:31:36 -04:00
Mark Stapp
cc6e7d13d5
Merge pull request #8358 from idryzhov/fix-nb-vrf-crash
*: modify VRF_CONFIGURED flag only in VRF NB layer
2021-04-01 16:42:03 -04:00
Mark Stapp
e2efe13327
Merge pull request #8350 from opensourcerouting/printfrr-revamp
lib: `printfrr()` care package
2021-03-31 09:10:30 -04:00
Mark Stapp
b5058075b3 lib: remove inet6_ntoa api
Remove inet6_ntoa() - used static buffer, not needed.

Signed-off-by: Mark Stapp <mjs@voltanet.io>
2021-03-31 08:32:48 -04:00
David Lamparter
2c12c904ea lib: save errno in vty_out()
... so `%m` works correctly, without us trampling over `errno` before we
get to formatting it.

Signed-off-by: David Lamparter <equinox@diac24.net>
2021-03-30 22:34:56 +02:00
David Lamparter
7b183fd8ea lib: add %dPF & %dSO formats
Just quick helpers to print `AF_*` and `SOCK_*` constants.

Signed-off-by: David Lamparter <equinox@diac24.net>
2021-03-30 22:34:56 +02:00
David Lamparter
94f7840495 lib: fix & improve %pSU format
This wasn't quite formatting IPv6+port in a useful way (no brackets),
and printing the scope ID (interface index) and unix addrs is useful
too.

Signed-off-by: David Lamparter <equinox@diac24.net>
2021-03-30 22:34:56 +02:00
David Lamparter
7798203f5c lib: add %pSQ and %pSE string escape formats
These are for string quoting (`%pSQ`) and string escaping (`%pSE`); the
sets / escape methods are currently rather "basic" and might be extended
in the future.

Signed-off-by: David Lamparter <equinox@diac24.net>
2021-03-30 22:34:56 +02:00
David Lamparter
a4cb97a6c1 lib: add %*pHX + %*pHS hexdump in printfrr
(I'll get to `zlog_hexdump()` in a separate pass.)

Signed-off-by: David Lamparter <equinox@diac24.net>
2021-03-30 22:34:51 +02:00
David Lamparter
bb12115e0b lib: add %pFB extension to print struct fbuf *
Useful to insert output from another bprintfrr() call.

Signed-off-by: David Lamparter <equinox@diac24.net>
2021-03-30 22:32:59 +02:00
David Lamparter
9c4380daee lib: add %pVA recursive printfrr
Analogous to Linux kernel `%pV` (but our mechanism expects 2 specifier
chars and `%pVA` is clearer anyway.)

Signed-off-by: David Lamparter <equinox@diac24.net>
2021-03-30 22:32:59 +02:00
David Lamparter
cb4928ce77 lib: add FMT_NSTD() for non-standard printf exts
... to suppress the warnings when using something that isn't quite ISO C
compatible and would otherwise cause compiler warnings from `-Wformat`.

Signed-off-by: David Lamparter <equinox@diac24.net>
2021-03-30 22:32:59 +02:00
David Lamparter
2d9a4e2931 lib: allow discerning unspec width in printfrr ext
With 0 currently the default value for the width specifier, it's not
possible to discern that from a %*p where 0 was passed as the length
parameter.  Use -1 to allow for that.

Signed-off-by: David Lamparter <equinox@diac24.net>
2021-03-30 22:32:59 +02:00
David Lamparter
3ea7943059 lib: put printfrr extension args into struct
... for easier extensibility.  Add width, # and - flags while at it.

Signed-off-by: David Lamparter <equinox@diac24.net>
2021-03-30 22:32:55 +02:00
Sarita Patra
d5d737a2df lib: Modifications to route-map NB
This commit introduces the changes to the library route-map
north-bound callback implementation in order to align it to
the modified yang definitions.

Signed-off-by: NaveenThanikachalam <nthanikachal@vmware.com>
Signed-off-by: Sarita Patra <saritap@vmware.com>
2021-03-30 22:58:42 +03:00
Russ White
fb7c845e0d
Merge pull request #8311 from idryzhov/nb-sorting
Sort route-maps/access-lists/prefix-lists by sequence number in running-config
2021-03-30 10:37:31 -04:00
Russ White
a2d351d19e
Merge pull request #8137 from Orange-OpenSource/ospf_ls
ospfd: Add Link State support
2021-03-30 10:28:37 -04:00
Russ White
1c5168bd0b
Merge pull request #8369 from idryzhov/filter-fixes
access-list and prefix-list fixes
2021-03-30 10:21:37 -04:00
Igor Ryzhov
4179f151fe lib: fix checking for duplicated prefix-list entries
Restore the behavior that was before the NB conversion.

Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2021-03-30 00:37:52 +03:00
Igor Ryzhov
bf79e92316 lib: restore checks for duplicated prefix-list entries
The checks were incorrectly removed in commit 4d2f546f under the
assumption that it is needed only in CLI. Actually the checks are needed
for the case when the sequence number is explicitly set by a user.

Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2021-03-30 00:25:19 +03:00
Igor Ryzhov
4c53bdb1b9 lib: finish consolidation of prefix-list nb callbacks
There was an attempt to consolidate the code in commit fae60215, but the
work was not actually finished and some necessary checks were missed.

Let's finish it.

Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2021-03-30 00:15:28 +03:00
Igor Ryzhov
18abe2b91e lib: fix checking for duplicated access-list entries
Restore the behavior that was before the NB conversion.

Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2021-03-29 22:54:03 +03:00
Igor Ryzhov
b9b794db21 *: modify VRF_CONFIGURED flag only in VRF NB layer
This is to fix the crash reproduced by the following steps:

* ip link add red type vrf table 1

  Creates VRF.

* vtysh -c "conf" -c "vrf red"

  Creates VRF NB node and marks VRF as configured.

* ip route 1.1.1.0/24 2.2.2.2 vrf red
* no ip route 1.1.1.0/24 2.2.2.2 vrf red
  (or similar l3vni set/unset in zebra)

  Marks VRF as NOT configured.

* ip link del red

  VRF is deleted, because it is marked as not configured, but NB node
  stays.

Subsequent attempt to configure something in the VRF leads to a crash
because of the stale pointer in NB layer.

Fixes #8357.

Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2021-03-29 00:52:39 +03:00
David Lamparter
5d38779233 lib: fix transparent_union for clang++
clang does not accept __attribute__((transparent_union)) in C++ source
code.  We don't need it there anyway so let's just limit it to C.

Signed-off-by: David Lamparter <equinox@diac24.net>
2021-03-27 20:59:39 +01:00
David Lamparter
487eefcfbe lib: record output positions in printfrr
This replaces `%n` with a safe, out-of-band option that simply records
the start and end offset of the output produced for each `%...`
specifier.

The old `%n` code is removed.

Signed-off-by: David Lamparter <equinox@diac24.net>
2021-03-27 17:01:29 +01:00
David Lamparter
eba599a397 lib: print (null) rather than NULL
... for consistency with `%s`, which also prints `(null)`.

Signed-off-by: David Lamparter <equinox@diac24.net>
2021-03-27 16:56:56 +01:00
David Lamparter
212e04e5a7 lib: rework printfrr extensions to output directly
Allowing printfrr extensions to directly write to the output buffer has
a few advantages:
- there is no arbitrary length limit imposed (previously 64)
- the output doesn't need to be copied another time
- the extension can directly use bprintfrr() to put together pieces

The downside is that the theoretical length (regardless of available
buffer space) must be computed correctly.

Extended unit tests to test these paths a bit more thoroughly.

Signed-off-by: David Lamparter <equinox@diac24.net>
2021-03-27 16:56:55 +01:00
David Lamparter
9a5d359ce8
Merge pull request #8317 from mjstapp/fix_short_printfrr_buf 2021-03-26 19:40:21 +01:00
Donald Sharp
9b8e01cae4 lib: Incorporate Wall and Cpu warning into show thread cpu
Incorporate into the `show thread cpu` the number of times
we have issued warnings about a particular thread being
too slow.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2021-03-26 13:27:45 -04:00
Donald Sharp
039d547f6f lib: Differentiate between real and cpu bound processes
When generating SLOW_THREAD warnings let's differentiate between
a cpu bound process and a wall bound process.  Effectively
a slow thread can now be a process in FRR doing lots of work( cpu bound )
or wall bound ( the cpu is heavy load and a FRR process may be pre-empted
and never scheduled ).

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2021-03-26 11:41:57 -04:00
Patrick Ruddy
694df37daf
Merge pull request #8154 from AnuradhaKaruppiah/evpn-mh-irb-2
bgpd, lib, zebra: Complete support for sym-IRB with EVPN-MH
2021-03-26 12:16:01 +00:00
Anuradha Karuppiah
7bfa7d0233 lib/zebra: zapi for installing EVPN nexthops from bgp
EVPN nexthops are installed as remote neighs by zebra. This was earlier
done only via VRF IPvX uni routes imported from EVPN routes.

With EVPN-MH these VRF routes now reference a L3NHG which is setup based
on the EAD and doesn't include the RMAC. To workaround that BGP now
consolidates and maintains EVPN nexthops which are then sent to zebra.

zebra sets up these nexthops as L3-VNI nh entries using a dummy type-1
route as reference.

Ticket: CM-31398

Signed-off-by: Anuradha Karuppiah <anuradhak@cumulusnetworks.com>
2021-03-25 17:09:53 -07:00
Pat Ruddy
9e26322126 lib, bgpd: add a specific oid_copy function for IPv6 addrs
Do not overload the v4 oid_copy_addr function for ipv6
coverity does not like this kind of thing.

Signed-off-by: Pat Ruddy <pat@voltanet.io>
2021-03-25 15:24:50 +00:00
Igor Ryzhov
c560085f4d
Merge pull request #8184 from opensourcerouting/bfd-bgp-napi
bgpd,lib: rework BGP BFD integration
2021-03-24 10:36:26 +03:00
Igor Ryzhov
fe11f66b8c lib: remove "ip prefix-list sequence-number" command
Before the transition of prefix-lists to northbound, this setting
controlled whether sequence numbers were displayed in the config.
After the transition, sequence numbers are always displayed in the
configuration, and this command only controls the output of the show
commands, which is not very useful. This command is not even shown in
the config anymore.

Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2021-03-24 00:37:54 +03:00
Mark Stapp
ff7c213c65 lib: enlarge the local buffer for printfrr extension tokens
Make the local buffer offered to printfrr extension tokens
bigger; existing size wasn't quite enough for some of the
more elaborate struct prefix types.

Signed-off-by: Mark Stapp <mjs@voltanet.io>
2021-03-23 14:48:58 -04:00
Rafael Zalamena
3e6376b813 lib: small BFD session notifier improvement
Cache current monotime to avoid unnecessary calls.

Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
2021-03-23 12:40:09 -03:00
Rafael Zalamena
a099abe55b lib: new BFD integration API
New BFD protocol integration API with abstractions to fix most common
protocol integration errors:

 - Set address family together with the source/destination addresses

 - Set the TTL together with the single/multi hop option

 - Set/unset profile/interface easily

 - Keep the arguments so we don't have to rebuild them every time

 - Install/uninstall functions that keep track of current state so the
  daemon doesn't have to

 - Reinstall when critical configuration changes (address, multi hop
   etc...)

 - Reconfigure BFD when the daemon restarts automatically

 - Automatically calls the user defined callback for session update

 - Shutdown handler for all protocols

Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
2021-03-23 12:40:09 -03:00
Olivier Dugeon
b0c0b43348 lib: Update Link State Database
Add new status for Vertex, Edge and Subnet to manage their
respective states in the data base.

Add new functions:
 - to register/unregister server and client
 - to show content of the Database (VTY and Json output)
 - to update and compare subnets
 - to clean vertex and ted from ORPHAN elements
 - to convert message or stream into a Link State Element and update
   Link State Database accordingly to message event

Change Edge and Vertex key computation by using the host order systematically.
This impact mostly key based on IPv4 addresses where `ntohl()` function must
be used when searching a Vertex or Edge by key.

Update the documentation accordingly

Signed-off-by: Olivier Dugeon <olivier.dugeon@orange.com>
2021-03-23 15:39:29 +01:00
Igor Ryzhov
73695730f5 lib: sort prefix-list commands by sequence-number in running-config
Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2021-03-23 16:24:40 +03:00
Igor Ryzhov
ae253f502e lib: sort access-list commands by sequence-number in running-config
Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2021-03-23 16:24:40 +03:00
Igor Ryzhov
de8936be5e lib: sort route-map commands by sequence number in running-config
Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2021-03-23 16:24:40 +03:00
Igor Ryzhov
c6f1f711bf lib: add ability to sort CLI commands printed by NB layer
Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2021-03-23 16:24:40 +03:00
Igor Ryzhov
634aa8253e lib: simplify nb_cli_show_dnode_cmds
Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2021-03-23 14:57:33 +03:00
David Lamparter
833a54b757 lib: fix xref hash calculation
... to make it do what it says it does.

Signed-off-by: David Lamparter <equinox@diac24.net>
2021-03-22 12:50:27 +01:00
David Lamparter
a3c6749860 lib: add [XXXXX-XXXXX] log prefix & config
This logs the unique ID prefix from the xref that each log message call
has, and adds on/off knobs for both EC and unique ID printing.

Signed-off-by: David Lamparter <equinox@diac24.net>
2021-03-22 12:50:27 +01:00
David Lamparter
0e3967d766 lib: remove flog() macro
It was only used in one place.

Signed-off-by: David Lamparter <equinox@diac24.net>
2021-03-22 12:50:27 +01:00
David Lamparter
1b293b2be4 lib: get rid of flog() usage in NB code
This parametrized use of flog with variable EC and priority doesn't mesh
particularly well with the xref code & there isn't really much reason to
not use fixed/constant calls like this.

Signed-off-by: David Lamparter <equinox@diac24.net>
2021-03-22 12:50:27 +01:00
David Lamparter
e6b3732e90 lib: add bputs/bputch fbuf (bprintfrr) helpers
Just small utilities for when you already have a struct fbuf (i.e. when
bprintfrr() is used to construct longer text from multiple pieces.)

Signed-off-by: David Lamparter <equinox@diac24.net>
2021-03-22 12:50:27 +01:00
Donatas Abraitis
37916b2b11
Merge pull request #8121 from opensourcerouting/macro-cleanup
*: require ISO C11 + semicolons after file-scope macros
2021-03-22 11:00:34 +02:00
Santosh P K
de40463b54
Merge pull request #8008 from chiragshah6/yang_nb5
[lib, yang] : multiple fixes in prefix-list northbound conversion
2021-03-17 16:25:54 +05:30
David Lamparter
941b5172ea lib: temporary workaround for LabN CI
Accept macros without ; for LabN CI *only*.  This is a bit hairy since
we can't generate warnings for this, so it's very limited in both scope
and duration.

Signed-off-by: David Lamparter <equinox@diac24.net>
2021-03-17 06:24:03 +01:00
David Lamparter
67b0f40c98 *: require semicolon after FRR_CFG_DEFAULT_*
... again ...

Signed-off-by: David Lamparter <equinox@diac24.net>
2021-03-17 06:18:39 +01:00
David Lamparter
80413c2073 *: require semicolon after FRR_DAEMON_INFO & co.
... again ...

Signed-off-by: David Lamparter <equinox@diac24.net>
2021-03-17 06:18:39 +01:00
David Lamparter
960b9a5383 *: require semicolon after DEFINE_<typesafe...>
Again, see previous commits.

Signed-off-by: David Lamparter <equinox@diac24.net>
2021-03-17 06:18:39 +01:00
David Lamparter
96244aca23 *: require semicolon after DEFINE_QOBJ & co.
Again, see previous commits.

Signed-off-by: David Lamparter <equinox@diac24.net>
2021-03-17 06:18:37 +01:00
David Lamparter
8451921b70 *: require semicolon after DEFINE_HOOK & co.
See previous commit.

Signed-off-by: David Lamparter <equinox@diac24.net>
2021-03-17 06:18:17 +01:00
David Lamparter
bf8d3d6aca *: require semicolon after DEFINE_MTYPE & co
Back when I put this together in 2015, ISO C11 was still reasonably new
and we couldn't require it just yet.  Without ISO C11, there is no
"good" way (only bad hacks) to require a semicolon after a macro that
ends with a function definition.  And if you added one anyway, you'd get
"spurious semicolon" warnings on some compilers...

With C11, `_Static_assert()` at the end of a macro will make it so that
the semicolon is properly required, consumed, and not warned about.

Consistently requiring semicolons after "file-level" macros matches
Linux kernel coding style and helps some editors against mis-syntax'ing
these macros.

Signed-off-by: David Lamparter <equinox@diac24.net>
2021-03-17 06:18:17 +01:00
David Lamparter
15c05f1edf *: require ISO C11 (or C++11)
It's 2021... time to drop some 10yo compat stuff.

Signed-off-by: David Lamparter <equinox@diac24.net>
2021-03-17 06:18:17 +01:00
David Lamparter
247c7e27a9 snmp: change -std=gnu99 to -std=gnu11
The point of the `-std=gnu99` was to override a `-std=c99` that may be
coming in from net-snmp.  However, we want C11, not C99.

Signed-off-by: David Lamparter <equinox@diac24.net>
2021-03-17 06:18:17 +01:00
Mark Stapp
cc01c03434
Merge pull request #8230 from donaldsharp/flex_more
more switchover to using our builtin printf functionality
2021-03-15 08:36:23 -04:00
Renato Westphal
e1908ceb42
Merge pull request #7945 from volta-networks/feat_isis_snmp
isisd: add support for read-only snmp mibs objects
2021-03-14 22:14:27 -03:00
Renato Westphal
70d453d2a0
Merge pull request #8160 from idryzhov/fix-show-yang-oper
lib: fix crash when iterating over nb operational data
2021-03-14 21:04:37 -03:00
David Lamparter
ad6f7449ef *: remove remaining severity prefixes
Having a "warning:" prefix on a debug message is particularly dumb...

Signed-off-by: David Lamparter <equinox@diac24.net>
2021-03-14 22:56:07 +01:00
Donald Sharp
a0ee6f3224 lib: Convert to builtin printf functionality
Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2021-03-14 22:56:07 +01:00
Mark Stapp
6ff2514b41
Merge pull request #8124 from pguibert6WIND/ipsec_iptable_dplane
zebra: move netfilter contexts to zebra dplane
2021-03-10 16:43:15 -05:00
Philippe Guibert
ef524230a6 zebra: move ipset and ipset_entry to zebra dplane contexts
like it has been done for iptable contexts, a zebra dplane context is
created for each ipset/ipset entry event. The zebra_dplane_ctx job is
then enqueued and processed by separate thread. Like it has been done
for zebra_pbr_iptable context, the ipset and ipset entry contexts are
encapsulated into an union of structures in zebra_dplane_ctx.

There is a specificity in that when storing ipset_entry structure, there
was a backpointer pointer to the ipset structure that is necessary
to get some complementary information before calling the hook. The
proposal is to use an ipset_entry_info structure next to the ipset_entry,
in the zebra_dplane context. That information is used for ipset_entry
processing. The ipset name and the ipset type are the only fields
 necessary.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2021-03-10 14:57:32 +01:00
Mark Stapp
44a5e50763 lib: use correct type in add_event xref
the add_event api xref should use THREAD_EVENT, rather than
THREAD_TIMER.

Signed-off-by: Mark Stapp <mjs@voltanet.io>
2021-03-09 13:41:58 -05:00
Russ White
da0a277fae
Merge pull request #6807 from opensourcerouting/xref-extract
xrefs extraction tool
2021-03-09 07:58:43 -05:00
Rafael Zalamena
d9d7af1a52 lib: add ringbuf socket read function
Implement new ringbuf function to do the proper socket reads without
the need of intermediary buffers.

Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
2021-03-05 18:17:27 -03:00
Chirag Shah
fae6021583 lib: consolidate plist nb callbacks
Signed-off-by: Chirag Shah <chirag@nvidia.com>
2021-03-03 19:47:56 -08:00
Russ White
8b52859575
Merge pull request #8175 from mjstapp/fix_printfrr_nulls
lib, bgpd: handle NULL inputs in printfrr extensions
2021-03-02 11:36:49 -05:00
lynne
1ee746d990 isisd: support for snmp
Add support for read only mib objects from RFC4444.

Signed-off-by: Lynne Morrison <lynne@voltanet.io>
Signed-off-by: Karen Schoener <karen@voltanet.io>
2021-03-02 10:06:31 -05:00
Donald Sharp
fe914c4b60
Merge pull request #7951 from mjstapp/fix_cancel_event
libs, bgpd: improve task cancellation by argument value
2021-03-02 07:21:47 -05:00
Chirag Shah
f7f101156e lib: fix a crash in plist update
Problem:
Prefix-list with mulitiple rules, an update to
a rule/sequence with different prefix/prefixlen
reset prefix-list next-base pointer to avoid
having stale value.

In some case the old next-bast's reference leads
to an assert in tri (trie_install_fn ) add.

bt:
(object=0x55576a4c8a00, updptr=0x55576a4b97e0) at lib/plist.c:560
(plist=0x55576a4a1770, pentry=0x55576a4c8a00) at lib/plist.c:585
(ple=0x55576a4c8a00) at lib/plist.c:745
(args=0x7fffe04beb50) at lib/filter_nb.c:1181

Solution:
Reset prefix-list next-base pointer whenver a
sequence/rule is updated.

Ticket:CM-33109
Testing Done:

Signed-off-by: Chirag Shah <chirag@nvidia.com>
Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
2021-03-01 16:04:31 -08:00
Chirag Shah
b12bcae462 lib: fix plist le ge reset value
merge conflict leads to incorrect reset value for
prefix-list less than and greater than equal values.

Signed-off-by: Chirag Shah <chirag@nvidia.com>
2021-03-01 16:04:31 -08:00
Chirag Shah
978ca5d5ba lib: plist validation use enum type
In prefix-list nortbound callback's validation
phase, use type as enum rather string for better
performance.

Signed-off-by: Chirag Shah <chirag@nvidia.com>
2021-03-01 16:04:31 -08:00
Chirag Shah
4d2f546f82 lib: remove prefix-list dup api in validation phase
Following patch
" lib: disallow access list duplicated values"
introduce a libyang dnode iterator for every prefix-list
config which adds an overhead of traversal all prefix dnodes
and degrades the performance in scaled prefix-list config.

This check is not necessary in prefix-list northbound callbacks
as there won't be a case where prefix-list config comes to nb
callback without sequence number.

The dup check is only necessary for the vtysh case for backward
compatiblity reason where cli can be accepted without sequence number.

Ticket: CM-32035
Reviewed By: CCR-11096
Testing Done:

Signed-off-by: Chirag Shah <chirag@nvidia.com>
2021-03-01 16:04:31 -08:00
Chirag Shah
6440741834 yang: remove when statement from prefix-list
Remove when statements from prefix-list yang OM,
and do the same check in frr validation phase.
This helps a bit in perfomance of prefix-lists
scale config.

Ticket:CM-32035
Reviewed By:CCR-11096
Testing Done:

Signed-off-by: Chirag Shah <chirag@nvidia.com>
2021-03-01 16:04:31 -08:00
Mark Stapp
8e2c653ed3 lib: protect printfrr extensions from NULL input
Protect the lib printfrr extension handlers from NULL inputs.

Signed-off-by: Mark Stapp <mjs@voltanet.io>
2021-03-01 15:41:30 -05:00
Mark Stapp
e0b5ca875b lib: print NULL for NULL nexthops
Instead of crashing, print "NULL" when printfrr callback for
nexthops is called for a NULL nexthop argument.

Signed-off-by: Mark Stapp <mjs@voltanet.io>
2021-03-01 08:51:13 -05:00
Santosh P K
0a1e7b612a
Merge pull request #8073 from idryzhov/vtysh-show-config
lib: allow "show config running" command for non-transactional CLI
2021-03-01 18:40:06 +05:30
Igor Ryzhov
baa1d4aff6 lib: fix crash when iterating over nb operational data
Example:
```
show yang operational-data /frr-routing:routing/control-plane-protocols/control-plane-protocol[type='frr-staticd:staticd'][name='staticd'][vrf='default'] staticd
```

Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2021-02-26 19:17:28 +03:00
Quentin Young
7a32a3ec53
Merge pull request #8023 from volta-networks/feat_add_agentx_enabled_hook
lib: add agentx_enabled hook
2021-02-24 13:24:33 -05:00
Mark Stapp
15869cd81d
Merge pull request #8035 from qlyoung/remove-more-sprintf
*: remove more sprintf()
2021-02-23 15:55:02 -05:00
Russ White
33d1282f3d
Merge pull request #8095 from idryzhov/fix-nb-stale-pointers
fix stale pointers in northbound nodes
2021-02-23 11:15:31 -05:00
David Lamparter
5e085e529d lib: get rid of padding in struct cmd_element
This makes the Python code looking at xrefs much easier.

Signed-off-by: David Lamparter <equinox@diac24.net>
2021-02-23 16:56:58 +01:00
David Lamparter
2621bb8b8d lib/xref: record log message format args
Apparently you can do `#__VA_ARGS__` and it actually does something
sensible, so here we go recording the format parameters for log messages
into the xref.

This allows some more checking in xrelfo.py, e.g. hints to use `%pFX`
and co.

Signed-off-by: David Lamparter <equinox@diac24.net>
2021-02-23 16:56:58 +01:00
David Lamparter
a1e6ab1e93 build: extract xrefs
Signed-off-by: David Lamparter <equinox@diac24.net>
2021-02-23 16:56:58 +01:00
David Lamparter
5609b3af49 lib/clippy: add libelf wrapper
This adds _clippy.ELFFile, which provides a fast wrapper around libelf.
The API is similar to / a subset of pyelfutils, which unfortunately is
painfully slow (to the tune of minutes instead of seconds.)

The idea is that xrefs can be read out of ELF files by reading out the
"xref_array" section or "FRRouting/XREF" note.

Signed-off-by: David Lamparter <equinox@diac24.net>
2021-02-23 16:56:58 +01:00
Igor Ryzhov
2ada626940 lib: register dependency between control plane protocol and vrf nb nodes
When the control plane protocol is created, the vrf structure is
allocated, and its address is stored in the northbound node.
The vrf structure may later be deleted by the user, which will lead to
a stale pointer stored in this node.

Instead of this, allow daemons that use the vrf pointer to register the
dependency between the control plane protocol and vrf nodes. This will
guarantee that the nodes will always be created and deleted together, and
there won't be any stale pointers.

Add such registration to staticd and pimd.

Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2021-02-22 18:53:24 +03:00
Igor Ryzhov
09b150ef2a lib: add definitions for vrf xpaths
Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2021-02-22 18:53:24 +03:00
Igor Ryzhov
f182d8d8a2 lib: add ability to register dependencies between northbound nodes
Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2021-02-22 18:53:24 +03:00
Donald Sharp
5e8229578a lib: Reduce getrusage/monotime for event handling
When handling a large number of events at one time
FRR will call monotime and getrusage 2 times for each
event.  With this change modify the code to change
this to (X events / 2) + 1 calls of getrusage and monotime

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2021-02-22 09:20:33 -05:00
Emanuele Di Pascale
c364a0962b lib: fix c++ usage of zlog
Since some recent commit, building c++ code attempting to use zlog_debug
(or any other level) would fail with the following complaint:

lib/zlog.h:91:3: sorry, unimplemented: non-trivial designated
initializers not supported
   };
   ^
lib/zlog.h:105:26: note: in expansion of macro ‘_zlog_ref’
 #define zlog_debug(...)  _zlog_ref(LOG_DEBUG, __VA_ARGS__)

This is due to out-of-order initialization of the xrefdata struct
fields. Setting them all in the order in which they are defined
fixes the issue.

Signed-off-by: Emanuele Di Pascale <emanuele@voltanet.io>
2021-02-22 10:38:42 +01:00
Donald Sharp
f52aee04b3 lib: Free memory leak in error path in clippy
When running clippy, the main function in it's
error path could leak the memory pointed to by name.
Fix this.  This was/is reported by clang SA.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2021-02-20 07:40:01 -05:00
Quentin Young
0f3073387b lib: use right type for wconv() return val
Signed-off-by: Quentin Young <qlyoung@nvidia.com>
2021-02-19 11:58:11 -05:00
Donald Sharp
dc86ef74e6
Merge pull request #8079 from pjdruddy/pr-snmp-coverity
MPLSL3VPN snmp coverity fixes
2021-02-19 08:54:02 -05:00
Donald Sharp
c6b8506c6c
Merge pull request #8103 from mjstapp/fix_thread_awaken
lib: don't awaken from poll for every timer
2021-02-19 08:21:31 -05:00
Mark Stapp
e7d9e44b02 lib: pass the thread_master to process_timers()
Pass the thread_master pointer to process_timers() as we
do for other list-processing apis.

Signed-off-by: Mark Stapp <mjs@voltanet.io>
2021-02-18 09:42:03 -05:00
Mark Stapp
96fe578a64 lib: don't awaken from poll for every timer
Only ask the event-loop poll() to awaken if a newly-added timer
actually might have changed the required timeout. Also compute
timer deadline outside of mutex locks.

Signed-off-by: Mark Stapp <mjs@voltanet.io>
2021-02-18 09:42:03 -05:00
Mark Stapp
4322dea7e0 lib: remove unneeded arg from timer api
Timers are always type TIMER - remove 'type' arg from some
timer apis.

Signed-off-by: Mark Stapp <mjs@voltanet.io>
2021-02-18 09:42:03 -05:00
Mark Stapp
a582429008 lib: small code cleanup in thread.c
Fix an indentation in thread.c.

Signed-off-by: Mark Stapp <mjs@voltanet.io>
2021-02-18 09:41:38 -05:00
Quentin Young
4da4b9d4f1 lib: fix some misc SA warnings
- clippy.c: fix valid memleak
- defun_lex.l: suppress warnings in generated code
- northbound_cli.c: suppress warning in eldritch libyang macro

Signed-off-by: Quentin Young <qlyoung@nvidia.com>
2021-02-17 17:01:06 -05:00
Pat Ruddy
5a224c19f1 bgpd, lib: add oid2in6_addr utility and use it
The existing code was using the oid2in_addr API to copy IPv6
addresses passing an IPv6 length. Create a utility to do this
properly and avoid annoying coverity with type checking.

Signed-off-by: Pat Ruddy <pat@voltanet.io>
2021-02-17 13:35:31 +00:00
Karen Schoener
ec48460efd lib: add agentx_enabled hook
Adding agentx_enabled hook.

This permits the main LDP process to signal the lde and ldpe
processes when agentx is enabled.

Signed-off-by: Karen Schoener <karen@voltanet.io>
2021-02-16 11:53:42 -05:00
David Lamparter
f1db813dbb *: fix format string SNAFUs
Signed-off-by: David Lamparter <equinox@diac24.net>
2021-02-16 00:47:51 +01:00
Donald Sharp
a6d1b6a043
Merge pull request #8075 from opensourcerouting/assorted-20210212
lib: bunch of random small fixes
2021-02-15 15:20:18 -05:00
David Lamparter
e0a5979d58 lib: fix CRNL causing empty prompt lines
CR, NL and CRNL are all OK, but CRNL shouldn't get treated as 2
newlines (which causes an empty command to be executed => empty prompt
line.)

Signed-off-by: David Lamparter <equinox@diac24.net>
2021-02-15 01:29:44 +01:00
David Lamparter
ab699721a1 lib: stop parallel-passing vty_sock, detangle
The FDs are in struct vty, and there's ->fd and ->wfd, which shouldn't
be confused.  Passing vty_sock along separately just creates mixups.

Signed-off-by: David Lamparter <equinox@diac24.net>
2021-02-15 01:28:52 +01:00
Donald Sharp
97e21b4bd8 lib, bgpd: smux_trap return code is never used
The return code from smux_trap is never used.  If we have
never used it after all this time.  Remove the return from
the function.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2021-02-14 16:18:39 -05:00
David Lamparter
1d5453d607 *: remove tabs & newlines from log messages
Neither tabs nor newlines are acceptable in syslog messages.  They also
break line-based parsing of file logs.

Signed-off-by: David Lamparter <equinox@diac24.net>
2021-02-14 15:36:51 +01:00
Donatas Abraitis
44b0793e88
Merge pull request #8036 from qlyoung/disable-mallinfo
lib: support mallinfo2() if available
2021-02-13 10:46:15 +02:00
Quentin Young
78ae07dbca
Merge pull request #8039 from m-varasteh/master
[filter]: change return code for errors
2021-02-12 13:32:44 -05:00
David Lamparter
b6bc1ee8d3 lib: de-uglify -t option + log stdout combo
The logging code writes log messages with a `\n` line ending, meanwhile
the VTY code switches it so you need `\r\n`...

And we don't flush the newline after executing a command either.

After this patch, starting daemons like `zebra/zebra -t` should provide
a nice development/debugging experience with a VTY open right there on
stdio and `log stdout` interspersed.

(This is already documented in the man pages, it just looked like sh*t
previously since the log messages didn't newline correctly.)

Signed-off-by: David Lamparter <equinox@diac24.net>
2021-02-12 19:29:36 +01:00
David Lamparter
877057b67a lib: have a lib_privs for ... lib privs
Logging code might want to raise privs for file operations.

Signed-off-by: David Lamparter <equinox@diac24.net>
2021-02-12 19:28:52 +01:00
David Lamparter
6e3253b979 lib: memorize what fds were open at startup
... in case the user does something like `zebra 3>logfile`.  Also useful
for some module purposes, maybe even feeding config at some point in the
future.

Signed-off-by: David Lamparter <equinox@diac24.net>
2021-02-12 19:28:22 +01:00
Igor Ryzhov
bcbe60d456 lib: allow "show config running" command for non-transactional CLI
This command doesn't rely on transactional CLI and works perfectly for
daemons converted to northbound configuration.

Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2021-02-12 18:18:34 +03:00
Quentin Young
51ab4dbaad lib: support mallinfo2()
mallinfo() is deprecated as of glibc 2.33 and emits a warning if used.
Support mallinfo2() if available.

Signed-off-by: Quentin Young <qlyoung@qlyoung.net>
2021-02-10 18:35:15 -05:00
Stephen Worley
3d26211e08
Merge pull request #7508 from sudhanshukumar22/zebra-vrf-delete
zebra: treat vrf add for existing vrf as update
2021-02-10 02:05:10 -05:00
Martin Winter
7a9c641d5c
Merge pull request #7917 from pjdruddy/l3vpn-mpls-snmp-upstream-1
L3vpn mpls snmp upstream 1
2021-02-10 01:37:58 +01:00
Quentin Young
7533cad751 *: remove more sprintf()
Should be just a couple non-development, non-test occurrences of this
function left now.

Signed-off-by: Quentin Young <qlyoung@qlyoung.net>
2021-02-09 15:40:40 -05:00
Igor Ryzhov
18e196f6fa vrf: use wrappers to change VRF_CONFIGURED flag
Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2021-02-09 22:39:32 +03:00
Igor Ryzhov
966806294b vrf: mark vrf as configured when entering vrf node
The VRF must be marked as configured when user enters "vrf NAME" command.

Otherwise, the following problem occurs:

`ip link add red type vrf table 1`

  VRF structure is allocated.

`vtysh -c "conf t" -c "vrf red"`

  `lib_vrf_create` is called, and pointer to the VRF structure is stored
  to the nb_config_entry.

`ip link del red`

  VRF structure is freed (because it is not marked as configured), but
  the pointer is still stored in the nb_config_entry.

`vtysh -c "conf t" -c "no vrf red"`

  Nothing happens, because VRF structure doesn't exist. It means that
  `lib_vrf_destroy` is not called, and nb_config_entry still exists in
  the running config with incorrect pointer.

`ip link add red type vrf table 1`

  New VRF structure is allocated.

`vtysh -c "conf t" -c "vrf red"`

  `lib_vrf_create` is NOT called, because the nb_config_entry for that
  VRF name still exists in the running config.

After that all NB commands for this VRF will use incorrect pointer to
the freed VRF structure.

Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2021-02-09 21:38:45 +03:00
Mark Stapp
a9318a3287 libs, bgpd: improve task cancellation by argument value
Extend the thread_cancel_event api so that it's more complete:
look in all the lists of events, including io and timers, for
matching tasks. Add a limited version of the api that only
examines tasks in the event and ready queues.

BGP appears to require the old behavior, so change its macro
to use the more limited cancel api.

Signed-off-by: Mark Stapp <mjs@voltanet.io>
2021-02-09 12:10:51 -05:00
Mark Stapp
aea25d1ec8 libs: make the task cancellation struct private
No reason for the thread/task cancellation struct to be public:
move it out of the header file. Also add a flags field.

Signed-off-by: Mark Stapp <mjs@voltanet.io>
2021-02-09 12:10:51 -05:00
varasteh
b3511a7247 [filter]: change return code for errors
CMD_WARNING is replaced by CMD_WARNING_CONFIG_FAILED

Signed-off-by: varasteh <mahdy.varasteh@gmail.com>
2021-02-08 16:02:32 +03:30
Donald Sharp
37a74717c7 *: Fix usage of bfd_adj_event
Valgrind reports:

469901-==469901==
469901-==469901== Conditional jump or move depends on uninitialised value(s)
469901:==469901==    at 0x3A090D: bgp_bfd_dest_update (bgp_bfd.c:416)
469901-==469901==    by 0x497469E: zclient_read (zclient.c:3701)
469901-==469901==    by 0x4955AEC: thread_call (thread.c:1684)
469901-==469901==    by 0x48FF64E: frr_run (libfrr.c:1126)
469901-==469901==    by 0x213AB3: main (bgp_main.c:540)
469901-==469901==  Uninitialised value was created by a stack allocation
469901:==469901==    at 0x3A0725: bgp_bfd_dest_update (bgp_bfd.c:376)
469901-==469901==
469901-==469901== Conditional jump or move depends on uninitialised value(s)
469901:==469901==    at 0x3A093C: bgp_bfd_dest_update (bgp_bfd.c:421)
469901-==469901==    by 0x497469E: zclient_read (zclient.c:3701)
469901-==469901==    by 0x4955AEC: thread_call (thread.c:1684)
469901-==469901==    by 0x48FF64E: frr_run (libfrr.c:1126)
469901-==469901==    by 0x213AB3: main (bgp_main.c:540)
469901-==469901==  Uninitialised value was created by a stack allocation
469901:==469901==    at 0x3A0725: bgp_bfd_dest_update (bgp_bfd.c:376)

On looking at bgp_bfd_dest_update the function call into bfd_get_peer_info
when it fails to lookup the ifindex ifp pointer just returns leaving
the dest and src prefix pointers pointing to whatever was passed in.

Let's do two things:

a) The src pointer was sometimes assumed to be passed in and sometimes not.
Forget that.  Make it always be passed in
b) memset the src and dst pointers to be all zeros.  Then when we look
at either of the pointers we are not making decisions based upon random
data in the pointers.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2021-02-07 14:59:53 -05:00
Donald Sharp
fd5e11240c
Merge pull request #8004 from opensourcerouting/xref-cxx
lib/xref: fix C++ issues
2021-02-03 11:23:15 -05:00
David Lamparter
cbb1337a30 lib/xref: fix initializer order for C++
[v2: drop designated initializer names]

Signed-off-by: David Lamparter <equinox@diac24.net>
2021-02-03 11:54:24 +01:00
David Lamparter
6c3aa850ea lib/xref: fix frrtrace() calls in thread code
This didn't exist yet when the xref code came around, and since
frrtrace() gets collapsed to nothing by the preprocessor when
tracepoints are disabled, it didn't cause any compiler errors...

Signed-off-by: David Lamparter <equinox@diac24.net>
2021-02-03 00:55:07 +01:00
David Lamparter
08a73c422d lib/xref: work around GCC bug 41091
gcc fucks up global variables with section attributes when they're used
in templated C++ code.  The template instantiation "magic" kinda breaks
down (it's implemented through COMDAT in the linker, which clashes with
the section attribute.)

The workaround provides full runtime functionality, but the xref
extraction tool (xrelfo.py) won't work on C++ code compiled by GCC.

FWIW, clang gets this right.

Signed-off-by: David Lamparter <equinox@diac24.net>
2021-02-03 00:55:07 +01:00
David Lamparter
96a7061450 lib/xref: restore lost extern "C" beginning
The `}` is still there, but the `extern "C" {` got lost somewhere,
probably in a rebase...

Signed-off-by: David Lamparter <equinox@diac24.net>
2021-02-03 00:54:59 +01:00
Igor Ryzhov
1ac88792c0 *: fix all backets
Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2021-02-02 19:11:25 +03:00
Russ White
8f57f7413c
Merge pull request #6766 from opensourcerouting/xref
lib: xrefs - general cross-references & unique IDs
2021-02-02 07:44:21 -05:00
Pat Ruddy
4eb8c74f6c lib: allow traps with differently indexed objects
The function smux_trap only allows the paaasin of one index which is
applied to all indexed objects. However there is a requirement for
differently indexed objects within a singe trap. This commit
introduces a new function smux_trap_multi_index which can be called
with an array of indices. If this array is onf length 1 the original
smux_trap behaviour is maintained. smux_trap now calls the new
function with and index array length of 1 to avoid changes to
existing callers.

Signed-off-by: Pat Ruddy <pat@voltanet.io>
2021-02-02 09:37:14 +00:00
Pat Ruddy
62e66e55bf bgpd: add SNMP support for mplsL3VpnRte Table
Add MIB support for the route table in RFC4382

Signed-off-by: Pat Ruddy <pat@voltanet.io>
2021-02-02 09:37:12 +00:00
Pat Ruddy
834182ba36 lib: add SNMP_OCTET macro
Add SNMP macro to allow a singe octet to be returned

Signed-off-by: Pat Ruddy <pat@voltanet.io>
2021-02-02 09:37:11 +00:00
Pat Ruddy
8902dba642 lib: add IANA defines and IPv6 macro
Add defines for IANA SNMP routing protocol values
Add macro for returning an IPv6 address to the SNMP agent.

Signed-off-by: Pat Ruddy <pat@voltanet.io>
2021-02-02 09:37:10 +00:00
Pat Ruddy
4f13e83dcd lib: add utilities to encode/decode an int in SNMP oid
Add 2 functions to encode/decode intergers to/from SNMP OIDs. Make
sure oid is in network format.

Signed-off-by: Pat Ruddy <pat@voltanet.io>
2021-02-02 09:37:08 +00:00
Pat Ruddy
0760a74d2f lib: add utility to get the next index in a vrf
Add if_vrf_lookup_by_index_next to get the next ifindex in a vrf
given the previous ifindex or 0 for the first.

Signed-off-by: Pat Ruddy <pat@voltanet.io>
2021-02-02 09:37:08 +00:00
Pat Ruddy
0d020cd6d9 bgpd, lib: add mplsL3VpnVrf table
Add SNMP support for L3vpn Vrf table as defined in [RFC4382]
Keep track of vrf status for the table and for future traps.

Signed-off-by: Pat Ruddy <pat@voltanet.io>
2021-02-02 09:37:06 +00:00
Pat Ruddy
8e0373314c lib: add utility to count interfaces connected to a vrf
Run through the vrf's interface list and return a count, skipping
the l3mdev which has a name which matches the vrf name.

Signed-off-by: Pat Ruddy <pat@voltanet.io>
2021-02-02 09:37:04 +00:00
Donatas Abraitis
8adc13a854
Merge pull request #7985 from donaldsharp/eigrp_uninited
bunch of valgrind issues
2021-02-02 09:14:24 +02:00
Donald Sharp
cf8ba91e32
Merge pull request #7994 from opensourcerouting/disable-printf-n
lib/printf: disable `%n` specifier
2021-02-01 20:41:27 -05:00
David Lamparter
738cca0ab4 lib/printf: disable %n specifier
We don't use `%n` anywhere, so the only purpose it serves is enabling
exploits.

(I thought about this initially when adding printfrr, but I wasn't sure
we don't use `%n` anywhere, and thought I'll check later, and then just
forgot it...)

Signed-off-by: David Lamparter <equinox@diac24.net>
2021-02-01 18:33:18 +01:00
sudhanshukumar22
75d26fb313 zebra: treat vrf add for existing vrf as update
Description: When we get a new vrf add and vrf with same name, but different vrf-id already
exists in the database, we should treat vrf add as update.
This happens mostly when there are lots of vrf and other configuration being replayed.
There may be a stale vrf delete followed by new vrf add. This
can cause timing race condition where vrf delete could be missed and
further same vrf add would get rejected instead of treating last arrived
vrf add as update.

Treat vrf add for existing vrf as update.
Implicitly disable this VRF to cleanup routes and other functions as part of vrf disable.
Update vrf_id for the vrf and update vrf_id tree.
Re-enable VRF so that all routes are freshly installed.

Above 3 steps are mandatory since it can happen that with config reload
stale routes which are installed in vrf-1 table might contain routes from
older vrf-0 table which might have got deleted due to missing vrf-0 in new configuration.

Signed-off-by: sudhanshukumar22 <sudhanshu.kumar@broadcom.com>
2021-02-01 08:33:13 -08:00
David Lamparter
01485adb9d lib/xref: add xrefs for install_element()
Combined with the DEFUN xrefs, this means we can extract the full CLI
tree from a binary file.

Signed-off-by: David Lamparter <equinox@diac24.net>
2021-02-01 17:28:11 +01:00
David Lamparter
feb06e7a93 lib/xref: add xrefs for DEFUNs
This allows grabbing a list of all DEFUNs and their help texts through
the xref extraction mechanics.

Signed-off-by: David Lamparter <equinox@diac24.net>
2021-02-01 17:28:11 +01:00
David Lamparter
131879fb92 lib/xref: add xrefs on zlog_* calls
This allows extracting a list of all log messages including their ECs
and autogenerated unique IDs for them.

Signed-off-by: David Lamparter <equinox@diac24.net>
2021-02-01 17:28:09 +01:00
David Lamparter
60a3efec24 lib/xref: use to transport thread_* file/line/func
Just a better way of doing what was previously the "debugargdef" macro.

Signed-off-by: David Lamparter <equinox@diac24.net>
2021-02-01 17:20:41 +01:00
David Lamparter
b2fa8c0fa3 lib/xref: put setup calls in libraries
Our "true" libraries (i.e. not modules) don't invoke neither
FRR_DAEMON_INFO nor FRR_MODULE_SETUP, hence XREF_SETUP isn't invoked
either.  Invoke it directly to get things working.

Signed-off-by: David Lamparter <equinox@diac24.net>
2021-02-01 17:18:51 +01:00
David Lamparter
8e427c2938 lib: "xref" identifier infrastructure
This adds the machinery for cross reference points (hence "xref") for
things to be annotated with source code location or other metadata
and/or to be uniquely identified and found at runtime or by dissecting
executable files.

The extraction tool to walk down an ELF file is done and working but
needs some more cleanup and will be added in a separate commit.

Signed-off-by: David Lamparter <equinox@diac24.net>
2021-02-01 17:18:02 +01:00
David Lamparter
3c191fb138 lib: move frr_weak_random to header file
Makes more sense to have this as a static inline.  Also I don't want to
be forced to link network.o into clippy ;)

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2021-02-01 17:08:13 +01:00
Donald Sharp
84d951d0cb lib: Line up show thread cpu output appropriately
The output from `show thread cpu` was not lined up appropriately
for the header line.  As well as the function name we were
calling in the output.  Fix it.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2021-02-01 08:59:18 -05:00
Donald Sharp
63e040391d lib: Prevent unininted usage of data
Valgrind reports that some data being used in the
stack unwind of a crash is being used uninitailized.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2021-01-30 16:19:08 -05:00
Rafael Zalamena
ecf497baed
Merge pull request #7953 from mjstapp/fix_more_ntoa
libs, ospfd: remove inet_ntoa
2021-01-29 08:01:03 -03:00
Donald Sharp
a2157a13a5 lib: Remove #if 0 code
Just some more dead code that has been sitting unused for
a very long time.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2021-01-28 14:04:02 -05:00
Mark Stapp
acc847c999 libs, ospfd: remove inet_ntoa
inet_ntoa not permitted - replace instances.

Signed-off-by: Mark Stapp <mjs@voltanet.io>
2021-01-27 15:00:10 -05:00
Duncan Eastoe
e3490d1fa2 lib: restore blank line after show route header
In 5a3cf85391 the trailing empty line
following the "show ip(v6) route" header was removed. Restore it for
consistency.

Signed-off-by: Duncan Eastoe <duncan.eastoe@att.com>
2021-01-27 12:19:52 +00:00
Mark Stapp
ff6fd1cc8a
Merge pull request #7923 from donaldsharp/gcc10-cleanups
Gcc10 cleanups
2021-01-25 12:30:52 -05:00
Donald Sharp
431deca7ea
Merge pull request #7905 from mjstapp/fix_zapi_nhg
zebra, sharpd: async results for NHGs
2021-01-25 10:29:04 -05:00
Donald Sharp
ea6caa1f52 lib: Wrapper a function to make gcc-10 happy
gcc-10 is complaining:

lib/frrscript.c:42:14: error: cast between incompatible function types from ‘const char * (*)(lua_State *, const char *)’ to ‘void (*)(lua_State *, const void *)’ [-Werror=cast-function-type]
   42 |   .encoder = (encoder_func)lua_pushstring,
      |              ^

Wrapper it to make it happy.  Not sure what else to do.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2021-01-25 09:15:36 -05:00
Donald Sharp
833c1f9fd1 lib: Prevent possible memory overwrite
fname is MAXPATHLEN and scriptdir and fs->name are less then
MAXPATHLEN but the combination of those two + the `.lua` are
greater than the MAXPATHLEN.  Just give us more room to prevent
a coding boo boo.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2021-01-25 09:15:36 -05:00
Mark Stapp
284c5a4584
Merge pull request #7906 from donaldsharp/sig_abrt
lib: Allow us to catch abort and do some small cleanup
2021-01-22 15:33:27 -05:00
Donald Sharp
3fb4be227a lib: Allow us to catch abort and do some small cleanup
When FRR intentionally asserts currently, the assertion
stops program execution and any debug logs currently
in play may just be lost completely.

Attempt to grab the abort and cleanup the log file, maybe we'll have
something useful.  New behavior:

zebra: lib/plist.c:562: void trie_install_fn(struct prefix_list_entry *, struct prefix_list_entry **): Assertion `object->next_best == *updptr || !*updptr' failed.
ZEBRA: Received signal 6 at 1611269027 (si_addr 0x7700138569, PC 0x7fdb210cec81); aborting...
ZEBRA: zlog_signal+0xb3                   7fdb2140aa73     7ffdd8f67c90 /lib/libfrr.so.0 (mapped at 0x7fdb213af000)
ZEBRA: core_handler+0xd8                  7fdb21433e38     7ffdd8f67d90 /lib/libfrr.so.0 (mapped at 0x7fdb213af000)
ZEBRA: funlockfile+0x50                   7fdb2126c140     7ffdd8f67f00 /lib/x86_64-linux-gnu/libpthread.so.0 (mapped at 0x7fdb21258000)
ZEBRA:     ---- signal ----
ZEBRA: gsignal+0x141                      7fdb210cec81     7ffdd8f684b0 /lib/x86_64-linux-gnu/libc.so.6 (mapped at 0x7fdb21093000)
ZEBRA: abort+0x123                        7fdb210b8537     7ffdd8f685d0 /lib/x86_64-linux-gnu/libc.so.6 (mapped at 0x7fdb21093000)
ZEBRA: ?                                  7fdb210b840f     7ffdd8f68700 /lib/x86_64-linux-gnu/libc.so.6 (mapped at 0x7fdb21093000)
ZEBRA: __assert_fail+0x42                 7fdb210c7602     7ffdd8f68750 /lib/x86_64-linux-gnu/libc.so.6 (mapped at 0x7fdb21093000)
ZEBRA: trie_install_fn+0x131              7fdb214200c1     7ffdd8f68780 /lib/libfrr.so.0 (mapped at 0x7fdb213af000)
ZEBRA: trie_walk_affected+0x44            7fdb2141fe14     7ffdd8f687a0 /lib/libfrr.so.0 (mapped at 0x7fdb213af000)
ZEBRA: prefix_list_trie_add+0x12f         7fdb2141e8ff     7ffdd8f687e0 /lib/libfrr.so.0 (mapped at 0x7fdb213af000)
ZEBRA: prefix_list_entry_update_finish+0x192     7fdb2141e752     7ffdd8f68830 /lib/libfrr.so.0 (mapped at 0x7fdb213af000)
ZEBRA: lib_prefix_list_entry_prefix_modify+0xa4     7fdb213faea4     7ffdd8f68860 /lib/libfrr.so.0 (mapped at 0x7fdb213af000)
ZEBRA: lib_prefix_list_entry_ipv4_prefix_modify+0xf     7fdb213fa6af     7ffdd8f688c0 /lib/libfrr.so.0 (mapped at 0x7fdb213af000)
ZEBRA: nb_callback_configuration+0x422     7fdb214175c2     7ffdd8f688d0 /lib/libfrr.so.0 (mapped at 0x7fdb213af000)
ZEBRA: nb_candidate_commit_apply+0x66     7fdb21414d86     7ffdd8f68d60 /lib/libfrr.so.0 (mapped at 0x7fdb213af000)
ZEBRA: nb_candidate_commit+0x66           7fdb21415146     7ffdd8f691f0 /lib/libfrr.so.0 (mapped at 0x7fdb213af000)
ZEBRA: nb_cli_classic_commit+0x5f         7fdb2141784f     7ffdd8f69230 /lib/libfrr.so.0 (mapped at 0x7fdb213af000)
ZEBRA: nb_cli_apply_changes+0x4ec         7fdb21417e8c     7ffdd8f6b270 /lib/libfrr.so.0 (mapped at 0x7fdb213af000)
ZEBRA: ip_prefix_list+0x552               7fdb213f7bb2     7ffdd8f6d780 /lib/libfrr.so.0 (mapped at 0x7fdb213af000)
ZEBRA: cmd_execute_command_real+0x14c     7fdb213e554c     7ffdd8f6e0f0 /lib/libfrr.so.0 (mapped at 0x7fdb213af000)
ZEBRA: cmd_execute_command+0x5d           7fdb213e52bd     7ffdd8f6e130 /lib/libfrr.so.0 (mapped at 0x7fdb213af000)
ZEBRA: cmd_execute+0xa1                   7fdb213e5651     7ffdd8f6e180 /lib/libfrr.so.0 (mapped at 0x7fdb213af000)
ZEBRA: vty_execute+0x253                  7fdb2144b643     7ffdd8f6e1d0 /lib/libfrr.so.0 (mapped at 0x7fdb213af000)
ZEBRA: vtysh_read+0xf9                    7fdb214494d9     7ffdd8f70210 /lib/libfrr.so.0 (mapped at 0x7fdb213af000)
ZEBRA: thread_call+0x8f                   7fdb214419ef     7ffdd8f70450 /lib/libfrr.so.0 (mapped at 0x7fdb213af000)
ZEBRA: frr_run+0x298                      7fdb214091a8     7ffdd8f705d0 /lib/libfrr.so.0 (mapped at 0x7fdb213af000)
ZEBRA: main+0x300                               42e760     7ffdd8f70740 /usr/lib/frr/zebra (mapped at 0x400000)
ZEBRA: __libc_start_main+0xea             7fdb210b9d0a     7ffdd8f70820 /lib/x86_64-linux-gnu/libc.so.6 (mapped at 0x7fdb21093000)
ZEBRA: _start+0x2a                              42022a     7ffdd8f708f0 /usr/lib/frr/zebra (mapped at 0x400000)
ZEBRA: in thread vtysh_read scheduled from lib/vty.c:2688
core_handler: showing active allocations in memory group libfrr
core_handler: memstats:  Buffer                        :      2 *         24
core_handler: memstats:  Host config                   :      3 * (variably sized)
core_handler: memstats:  Command Tokens                :   4117 *         72
core_handler: memstats:  Command Token Text            :   2964 * (variably sized)
core_handler: memstats:  Command Token Help            :   2964 * (variably sized)
core_handler: memstats:  Command Argument              :      7 * (variably sized)
core_handler: memstats:  Command Argument Name         :   1083 * (variably sized)
core_handler: memstats:  RCU thread                    :      2 *        128
core_handler: memstats:  FRR POSIX Thread              :      4 * (variably sized)
core_handler: memstats:  POSIX sync primitives         :      4 * (variably sized)
core_handler: memstats:  Graph                         :     25 *          8
core_handler: memstats:  Graph Node                    :   4795 *         32
core_handler: memstats:  Hash                          :    104 * (variably sized)
core_handler: memstats:  Hash Bucket                   :  33272 *         32
core_handler: memstats:  Hash Index                    :     52 * (variably sized)
core_handler: memstats:  Interface                     :     11 *        272
core_handler: memstats:  Connected                     :     28 *         48
core_handler: memstats:  Link List                     :     83 *         40
core_handler: memstats:  Link Node                     :    127 *         24
core_handler: memstats:  Temporary memory              :  36903 * (variably sized)
core_handler: memstats:  Module loading name           :      1 *         13
core_handler: memstats:  Nexthop                       :      9 *        136
core_handler: memstats:  NetNS Context                 :      2 * (variably sized)
core_handler: memstats:  NetNS Name                    :      1 *         18
core_handler: memstats:  Northbound Node               :    640 *       1168
core_handler: memstats:  Northbound Configuration      :      2 *         16
core_handler: memstats:  Northbound Configuration Entry:  32398 *       1032
core_handler: memstats:  Prefix List                   :      1 *         80
core_handler: memstats:  Prefix List Str               :      1 *         26
core_handler: memstats:  Prefix List Entry             :  32397 *        128
core_handler: memstats:  Prefix List Trie Table        :    196 *       4096
core_handler: memstats:  Prefix                        :     28 *         48
core_handler: memstats:  Privilege information         :      3 * (variably sized)
core_handler: memstats:  Stream FIFO                   :      1 *         64
core_handler: memstats:  Route table                   :     22 *         56
core_handler: memstats:  Route node                    :     54 * (variably sized)
core_handler: memstats:  Thread                        :     25 *        168
core_handler: memstats:  Thread master                 :     12 * (variably sized)
core_handler: memstats:  Thread Poll Info              :      6 *       8192
core_handler: memstats:  Thread stats                  :     16 *         72
core_handler: memstats:  Typed-hash bucket             :     15 * (variably sized)
core_handler: memstats:  Typed-heap array              :      1 *        576
core_handler: memstats:  Vector                        :   9646 *         16
core_handler: memstats:  Vector index                  :   9646 * (variably sized)
core_handler: memstats:  VRF                           :      1 *        200
core_handler: memstats:  VTY                           :      2 * (variably sized)
core_handler: memstats:  Work queue                    :      3 * (variably sized)
core_handler: memstats:  Work queue name string        :      2 * (variably sized)
core_handler: memstats:  YANG module                   :      6 *         48
core_handler: memstats:  log thread-local buffer       :      3 *       9752
core_handler: showing active allocations in memory group logging subsystem
core_handler: memstats:  log file target               :      1 *         88
core_handler: showing active allocations in memory group Label Manager
core_handler: showing active allocations in memory group Table Manager
core_handler: showing active allocations in memory group zebra
core_handler: memstats:  Zebra Interface Information   :     11 *        488
core_handler: memstats:  Router Advertisement Prefix   :      2 *         48
core_handler: memstats:  Zebra DPlane Provider         :      1 *        232
core_handler: memstats:  Route Entry                   :     24 *         88
core_handler: memstats:  RIB destination               :     20 *         88
core_handler: memstats:  Nexthop Group Entry           :      9 *         88
core_handler: memstats:  Nexthop Group Connected       :      9 *         40
core_handler: memstats:  Zebra Name Space              :      5 * (variably sized)
core_handler: memstats:  RIB table info                :      4 *         16
core_handler: memstats:  ZEBRA VRF                     :      1 *       4744
core_handler: memstats:  MH global info                :      1 *        128
2021/01/21 17:43:47 ZEBRA: object->next_best: 0x0 updptr: 0x11b4ea0 *updptr: 0x11b5e10
2021/01/21 17:43:47 ZEBRA: object->next_best: 0x11b62b0 updptr: 0x11b4eb0 *updptr: 0x0
2021/01/21 17:43:47 ZEBRA: object->next_best: 0x0 updptr: 0x11b5818 *updptr: 0x11b7090
2021/01/21 17:43:47 ZEBRA: object->next_best: 0x0 updptr: 0x11b5888 *updptr: 0x0
2021/01/21 17:43:47 ZEBRA: object->next_best: 0x0 updptr: 0x11b5910 *updptr: 0x0
2021/01/21 17:43:47 ZEBRA: object->next_best: 0x0 updptr: 0x11b59a0 *updptr: 0x11b87b0
2021/01/21 17:43:47 ZEBRA: object->next_best: 0x0 updptr: 0x11b7100 *updptr: 0x11b87b0
2021/01/21 17:43:47 ZEBRA: object->next_best: 0x0 updptr: 0x11b75a0 *updptr: 0x11b87b0
2021/01/21 17:43:47 ZEBRA: object->next_best: 0x0 updptr: 0x11b7a40 *updptr: 0x11b87b0
2021/01/21 17:43:47 ZEBRA: object->next_best: 0x0 updptr: 0x11b7ee0 *updptr: 0x11b87b0
2021/01/21 17:43:47 ZEBRA: object->next_best: 0x11b8c50 updptr: 0x11b8380 *updptr: 0x11b8c50
2021/01/21 17:43:47 ZEBRA: object->next_best: 0x11b90f0 updptr: 0x11b8820 *updptr: 0x11b90f0
2021/01/21 17:43:47 ZEBRA: object->next_best: 0x11b9590 updptr: 0x11b8cc0 *updptr: 0x11b9590
2021/01/21 17:43:47 ZEBRA: object->next_best: 0x11b9a30 updptr: 0x11b9160 *updptr: 0x11b9a30
2021/01/21 17:43:47 ZEBRA: object->next_best: 0x11b9ed0 updptr: 0x11b9600 *updptr: 0x11b9ed0
2021/01/21 17:43:47 ZEBRA: object->next_best: 0x11ba370 updptr: 0x11b9aa0 *updptr: 0x11ba370
2021/01/21 17:43:47 ZEBRA: object->next_best: 0x11ba810 updptr: 0x11b9f40 *updptr: 0x11ba810
2021/01/21 17:43:47 ZEBRA: object->next_best: 0x11bacb0 updptr: 0x11ba3e0 *updptr: 0x11bacb0
2021/01/21 17:43:47 ZEBRA: object->next_best: 0x11bb150 updptr: 0x11b4e20 *updptr: 0x0
2021/01/21 17:43:47 ZEBRA: object->next_best: 0x11bb5f0 updptr: 0x11c2560 *updptr: 0x11c1710
fish: Job 2, “sudo /usr/lib/frr/zebra --log s…” terminated by signal SIGABRT (Abort)

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2021-01-21 17:48:36 -05:00
Donatas Abraitis
07b37df9b3 lib: List all possible well-known communities in CLI (COMMUNITY_VAL_STR)
```
exit1-debian-9(config-route-map)# set community
  AA:NN  Community number in AA:NN format (where AA and NN are (0-65535)) or local-AS|no-advertise|no-export|internet|graceful-shutdown|accept-own-nexthop|accept-own|route-filter-translated-v4|route-filter-v4|route-filter-translated-v6|route-filter-v6|llgr-stale|no-llgr|blackhole|no-peer or additive
  none   No community attribute
```

Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
2021-01-21 16:00:52 +02:00
Mark Stapp
bdbef5edc6
Merge pull request #7233 from donaldsharp/route_map_optimizations
Route map optimizations
2021-01-19 13:20:02 -05:00
Mark Stapp
bf3ff67af2
Merge pull request #7888 from donaldsharp/1_19_coverity
lib: Fix up str2prefix usage in lua code
2021-01-19 12:42:49 -05:00
Russ White
619a77da10
Merge pull request #7781 from chiragshah6/evpn_dev
[yang,bgpd]  convert neighbor prefix-list and route-map to transactional clis
2021-01-19 11:26:34 -05:00
Donald Sharp
45e56ec4c2 lib: Fix up str2prefix usage in lua code
Two new coverity issues from inclusion of new lua code.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2021-01-19 09:29:50 -05:00
Mark Stapp
5898ce6f35 libs,zebra: remove zapi nhg encode and decode public apis
The raw zapi apis to encode and decode NHGs don't need to be
public; also add a little more validity-checking.

Signed-off-by: Mark Stapp <mjs@voltanet.io>
2021-01-19 08:48:54 -05:00
Russ White
a02d1bbfaa
Merge pull request #7884 from donaldsharp/null_stuff
Null stuff
2021-01-19 07:44:21 -05:00
Russ White
c0b6ef23f7
Merge pull request #7639 from qlyoung/frr-lua
Scripting
2021-01-19 07:17:03 -05:00
Donald Sharp
46e6f9f2ad lib: Correctly set temp file permissions
Set the temp file permissions to limit who can read
the file.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2021-01-18 09:32:00 -05:00
Donald Sharp
284a6f5ff1 lib: Keep track of route-map applications per section
When the routemap code was rewritten for performance the
code to track the number of times a particular section of
a route-map was applied was not correctly updated.  In
this case I found another sequence of events where the
number of times a section was invoked was not being correctly
kept.

Effectively in this case when route_map_get_index is called
and returns an index the route map has been applied( see that
skip_match_clause is set to true and then in the for loop
below the skip_match_clause is tested and index->applied is
incremented.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2021-01-15 19:34:33 -05:00
Donald Sharp
bf902d4c52 zebra: Create function to dump MACIP flags
Create a function to dump MACIP flags and to use it.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2021-01-13 13:22:27 -05:00
Donald Sharp
61e6de9d57 zebra: Add ability to display in human readable format re->flags and status
The re->flags and re->status in debugs were being dumped as hex values.
I can never quickly decode this.  Here is an idea.  Let's let FRR do
it for me.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2021-01-13 10:16:06 -05:00
Olivier Dugeon
4683138cda
Merge pull request #7707 from opensourcerouting/isisd-rlfa
isisd, ldpd: add Remote LFA support
2021-01-12 19:25:15 +01:00
Mark Stapp
fca58b0e4e libs,nhrpd: remove exec perm
Some source files got the exec bit set in a recent commit - undo
that.

Signed-off-by: Mark Stapp <mjs@voltanet.io>
2021-01-12 08:20:10 -05:00
Donald Sharp
279cca7639
Merge pull request #7747 from reubendowle/fixes/nhrpd
nhrpd fixes
2021-01-10 18:43:20 -05:00
Chirag Shah
f4eac84c5a yang: nbr plist nb conversion for more afi-safis
Signed-off-by: Chirag Shah <chirag@nvidia.com>
2021-01-09 23:06:02 -08:00
Renato Westphal
077d336aa7 ldpd: add support for RLFA clients
Add an API that allows IGP client daemons to register/unregister
RLFAs with ldpd.

IGP daemons need to be able to query the LDP labels needed by RLFAs
and monitor label updates that might affect those RLFAs. This is
similar to the NHT mechanism used by bgpd to resolve and monitor
recursive nexthops.

This API is based on the following ZAPI opaque messages:
* LDP_RLFA_REGISTER: used by IGP daemons to register an RLFA with ldpd.
* LDP_RLFA_UNREGISTER_ALL: used by IGP daemons to unregister all of
  their RLFAs with ldpd.
* LDP_RLFA_LABELS: used by ldpd to send RLFA labels to the registered
  clients.

For each RLFA, ldpd needs to return the following labels:
* Outer label(s): the labels advertised by the adjacent routers to
  reach the PQ node;
* Inner label: the label advertised by the PQ node to reach the RLFA
  destination.

For the inner label, ldpd automatically establishes a targeted
neighborship with the PQ node if one doesn't already exist. For that
to work, the PQ node needs to be configured to accept targeted hello
messages. If that doesn't happen, ldpd doesn't send a response to
the IGP client daemon which in turn won't be able to activate the
previously computed RLFA.

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2021-01-08 22:22:11 -03:00
Russ White
7e9492a9a6
Merge pull request #6810 from Orange-OpenSource/link_state
Lib: Add Link State Database
2021-01-05 10:25:38 -05:00
Olivier Dugeon
bbd85e2038 lib: Add Link State Database
Define new models for Link State Database a.k.a TED
and functions to manipulate the new database as well as exchange Link State
information through ZAPI Opaque message.

Signed-off-by: Olivier Dugeon <olivier.dugeon@orange.com>
2021-01-04 18:19:26 +01:00
Donatas Abraitis
1facc03e61
Merge pull request #7768 from donaldsharp/route_map_opt
Route map dependency fix
2020-12-19 15:02:15 +02:00
Donald Sharp
9149c63517 lib: Add a warning for when we are not operating correctly
There exists a possibilty that route map dependencies
have gotten wrong.  Prevent the crash and warn the user
that we may be in trouble.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2020-12-18 14:40:20 -05:00
Olivier Dugeon
065f7c7cc0
Merge pull request #7351 from opensourcerouting/feature/pathd
Add a new SR-TE policy management daemon and an optional PCEP module
2020-12-18 20:28:22 +01:00
Donald Sharp
02e7a369b8 lib: Fix dependency of match types in route-map code
Route-maps contain a hash of hash's that contain the
container type name ( say community or access list or whatever )
and then it has a hash of route-maps that this maps too

Suppose you have this:

!
frr version 7.3.1
frr defaults traditional
hostname eva
log stdout
!
debug route-map
!
router bgp 239
 neighbor 192.168.161.2 remote-as external
 !
 address-family ipv4 unicast
  neighbor 192.168.161.2 route-map foo in
 exit-address-family
!
bgp community-list standard 7000:40002 permit 7000:40002
bgp community-list standard 7000:40002 permit 7000:40003
!
route-map foo deny 20
 match community 7000:40002
!
route-map foo permit 10
!
line vty
!
end

You have a community hash which has an

7000:40002 entry

This entry has a hash of routemaps that are referencing it.  In this above
example it would have `foo` as the single entry.

Given the above config if you do this:

eva# conf
eva(config)# route-map foo deny 20
eva(config-route-map)# match community 7000:4003
eva(config-route-map)#

We would expect the `7000:40002` community hash to no longer have
a reference to the `foo` routemap.  Instead we see the code doing this:

2020/12/18 13:47:12 BGP: bgpd 7.3.1 starting: vty@2605, bgp@<all>:179
2020/12/18 13:47:47 BGP: Add route-map foo
2020/12/18 13:47:47 BGP: Route-map foo add sequence 10, type: permit
2020/12/18 13:47:57 BGP: Route-map foo add sequence 20, type: deny
2020/12/18 13:48:05 BGP: Adding dependency for filter 7000:40002 in route-map foo
2020/12/18 13:48:05 BGP: route_map_print_dependency: Dependency for 7000:40002: foo
2020/12/18 13:48:41 BGP: bgp_update_receive: rcvd End-of-RIB for IPv4 Unicast from 192.168.161.2 in vrf default
2020/12/18 13:49:19 BGP: Deleting dependency for filter 7000:4003 in route-map foo
2020/12/18 13:49:19 BGP: Adding dependency for filter 7000:4003 in route-map foo
2020/12/18 13:49:19 BGP: route_map_print_dependency: Dependency for 7000:4003: foo

Note how the code attempts to remove the dependency for `7000:4003` instead of the
dependency for `7000:40002`.  Then we create a new hash for `7000:4003` and then
install the routemap name in it.

This is wrong.  We should remove the `7000:40002` dependency and then install
a dependency for `7000:4003`.

Fix the code to do the right thing.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2020-12-18 14:22:09 -05:00
Donald Sharp
af87aff65d lib: Add some useful debugs to understand what is going on
Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2020-12-18 14:08:33 -05:00
Donald Sharp
db8db5804d lib: arg can never be NULL
Arg can never be null, get rid of an unneeded if statement

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2020-12-18 14:08:33 -05:00
Sebastien Merle
efba0985fc pathd: Add optional support for PCEP to pathd
This new dynamic module makes pathd behave as a PCC for dynamic candidate path
using the external library pcpelib https://github.com/volta-networks/pceplib .

The candidate paths defined as dynamic will trigger computation requests to the
configured PCE, and the PCE response will be used to update the policy.

It supports multiple PCE. The one with smaller precedence will be elected
as the master PCE, and only if the connection repeatedly fails, the PCC will
switch to another PCE.

Example of configuration:

segment-routing
 traffic-eng
  pcep
   pce-config CONF
    source-address ip 10.10.10.10
    sr-draft07
   !
   pce PCE1
    config CONF
    address ip 1.1.1.1
   !
   pce PCE2
    config CONF
    address ip 2.2.2.2
   !
   pcc
    peer PCE1 precedence 10
    peer PCE2 precedence 20
   !
  !
 !
!

Co-authored-by: Brady Johnson <brady@voltanet.io>
Co-authored-by: Emanuele Di Pascale <emanuele@voltanet.io>
Co-authored-by: GalaxyGorilla <sascha@netdef.org>
Co-authored-by: Javier Garcia <javier.garcia@voltanet.io>
Co-authored-by: Renato Westphal <renato@opensourcerouting.org>
Co-authored-by: Sebastien Merle <sebastien@netdef.org>
Signed-off-by: Sebastien Merle <sebastien@netdef.org>
2020-12-18 16:47:52 +01:00
Sebastien Merle
4d7b695d3a pathd: New SR-TE policy management daemon
This new daemon manages Segment-Routing Traffic-Engineering
(SR-TE) Policies and installs them into zebra. It provides
the usual yang support and vtysh commands to define or change
SR-TE Policies.

In a nutshell SR-TE Policies provide the possibility to steer
traffic through a (possibly dynamic) list of Segment Routing
segments to the endpoint of the policy. This list of segments
is part of a Candidate Path which again belongs to the SR-TE
Policy. SR-TE Policies are uniquely identified by their color
and endpoint. The color can be used to e.g. match BGP
communities on incoming traffic.

There can be multiple Candidate Paths for a single
policy, the active Candidate Path is chosen according to
certain conditions of which the most important is its
preference. Candidate Paths can be explicit (fixed list of
segments) or dynamic (list of segment comes from e.g. PCEP, see
below).

Configuration example:

segment-routing
 traffic-eng
  segment-list SL
   index 10 mpls label 1111
   index 20 mpls label 2222
  !
  policy color 4 endpoint 10.10.10.4
   name POL4
   binding-sid 104
   candidate-path preference 100 name exp explicit segment-list SL
   candidate-path preference 200 name dyn dynamic
  !
 !
!

There is an important connection between dynamic Candidate
Paths and the overall topic of Path Computation. Later on for
pathd a dynamic module will be introduced that is capable
of communicating via the PCEP protocol with a PCE (Path
Computation Element) which again is capable of calculating
paths according to its local TED (Traffic Engineering Database).
This dynamic module will be able to inject the mentioned
dynamic Candidate Paths into pathd based on calculated paths
from a PCE.

https://tools.ietf.org/html/draft-ietf-spring-segment-routing-policy-06

Co-authored-by: Sebastien Merle <sebastien@netdef.org>
Co-authored-by: Renato Westphal <renato@opensourcerouting.org>
Co-authored-by: GalaxyGorilla <sascha@netdef.org>
Co-authored-by: Emanuele Di Pascale <emanuele@voltanet.io>
Signed-off-by: Sebastien Merle <sebastien@netdef.org>
2020-12-18 16:34:02 +01:00
Gaurav Goyal
ddd8d8c845 nhrpd: Clear shortcut routes properly for all protocols
Currently when nhrp shortcuts are purged they will not be recreated. This
patch fixes that by ensuring the shortcut routes get purged correctly.

This situation can be reproduced by first allowing a shortcut to be created
then clearing the shortcut:
clear ip nhrp cache
clear ip nhrp shortcuts

Signed-off-by: Reuben Dowle <reuben.dowle@4rf.com>
2020-12-17 10:17:07 +13:00
Donald Sharp
8de2b3d990 lib, vtysh: Modify start/end configuration commands to be more hidden
There exists a world where some people have put `end` in their
configuration.  Then vtysh will command search for it and find
it and then bad things happen.

Ticket: CM-32665
Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2020-12-15 15:33:17 -05:00
Russ White
101ad544fa
Merge pull request #7678 from donaldsharp/aspath_to_zebra
Aspath to zebra
2020-12-10 10:38:14 -05:00
Donald Sharp
9696432fe5
Merge pull request #7677 from opensourcerouting/acl-back-compat
lib: restore previous access/prefix list behaviour
2020-12-10 08:14:34 -05:00
Donatas Abraitis
be268ed646 doc: update doc comment on hash_cmp (round 2)
Related: c8aad9c3a4

Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
2020-12-10 11:20:42 +02:00
Donatas Abraitis
b6f2da4f81
Merge pull request #7649 from qlyoung/fix-doc-comment-hashcmp
lib: update doc comment on hash_cmp
2020-12-10 11:07:06 +02:00
Karen Schoener
4d1e5644b7 ldpd, isisd, ospfd: Remove periodic ldp-sync hello message
Removing the obsolete ldp-sync periodic 'hello' message.

When ldp-sync is configured, IGPs take action if the LDP process goes down.

The IGPs have been updated to use the zapi client close callback to detect
the LDP process going down.

Signed-off-by: Karen Schoener <karen@voltanet.io>
2020-12-09 14:11:38 -05:00
Rafael Zalamena
4e32d023cd lib: prevent libyang abstraction memory leak
Call `ly_set_free()` on `YANG_ITER_STOP` as well.

Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
2020-12-09 09:57:28 -03:00
Donald Sharp
71c4870b2c lib: Add encode/decode of opaque data
Add a bit of code that allows for opaque data to be
sent from an upper level protocol to zebra.  This is just
pass through data that will be used as part of displaying
useful data about a route in a `show ip route` command
in future commits.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2020-12-08 09:06:08 -05:00
Donald Sharp
aab4eca1c0 lib, zebra: Fix overlapping message types
We had duplicate message id's.  Shit's broke yo.

Fix.  I have no idea how this properly worked.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2020-12-08 09:06:08 -05:00
Karen Schoener
581e797e02 zebra: Adding zapi client close notification
When zebra detects a client close, send a zapi client close
notification.

Signed-off-by: Karen Schoener <karen@voltanet.io>
2020-12-07 18:22:36 -05:00
Rafael Zalamena
866f48f2df lib: silently ignore duplicated values
Keep the previous CLI behavior of silently ignoring access lists which
contain the same value.

Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
2020-12-07 12:20:22 -03:00
Rafael Zalamena
54d153f786 lib: disallow prefix list duplicated values
Don't allow users to create multiple entries in the same list with the
same value to keep the behavior previously to northbound migration.

Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
2020-12-07 12:08:44 -03:00
Rafael Zalamena
208dc372cd lib: silently ignore duplicated values
Keep the previous CLI behavior of silently ignoring access lists which
contain the same value.

Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
2020-12-04 18:12:58 -03:00
Rafael Zalamena
f414129b0c lib: disallow access list duplicated values
Don't allow users to create multiple rules in the same list with the
same value to keep the behavior previously to northbound migration.

Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
2020-12-04 18:11:45 -03:00
Karen Schoener
32cfb544e9 isisd, ospfd: increase timeout to fix intermittent LDP Sync test failure
Currently, IGPs are coded to receive a 'hello' message from LDP every second.
Intermittently, LDP Sync topotests are failing because the IGPs fail to
receive this 'hello' message every second.
When the LDP Sync topotests fail, LDP logs show that LDP is processing
zapi messages for 1-2 seconds.

This is a shortterm fix, in order to prevent CI pipeline failures.
The longterm fix is in progress.

Signed-off-by: Karen Schoener <karen@voltanet.io>
2020-12-03 11:23:59 -05:00
Donald Sharp
0fb4ab0388
Merge pull request #6950 from opensourcerouting/bfd-distributed-v3
bfdd: distributed BFD
2020-12-02 20:50:47 -05:00
Quentin Young
b068d61304 lib: remove extraneous scripting debugs
Signed-off-by: Quentin Young <qlyoung@nvidia.com>
2020-12-01 18:37:14 -05:00
Quentin Young
bf6e726553 lib: use PREFIX_STRLEN in prefix encoder
Signed-off-by: Quentin Young <qlyoung@nvidia.com>
2020-12-01 18:37:14 -05:00
Quentin Young
e4e0229aba 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>
2020-12-01 18:37:14 -05:00
Quentin Young
fa22080d22 build: HAVE_LUA -> HAVE_SCRIPTING
And also guard all scripting-related stuff with HAVE_SCRIPTING.

Signed-off-by: Quentin Young <qlyoung@nvidia.com>
2020-12-01 18:37:14 -05:00
Quentin Young
1a3a91e211 lib: use appropriate MTYPE for scripts
Signed-off-by: Quentin Young <qlyoung@nvidia.com>
2020-12-01 18:37:14 -05:00
Quentin Young
f869ab17a7 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>
2020-12-01 18:37:14 -05:00
Quentin Young
eeb6172423 lib: add more type encoders, register existings
Signed-off-by: Quentin Young <qlyoung@nvidia.com>
2020-12-01 18:37:14 -05:00
Quentin Young
47dd873632 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>
2020-12-01 18:37:14 -05:00
Quentin Young
42ae55b5d4 lib: add more type encoder funcs
- in_addr
- in6_addr
- sockunion

Signed-off-by: Quentin Young <qlyoung@nvidia.com>
2020-12-01 18:37:14 -05:00
Quentin Young
9e47ee98a3 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>
2020-12-01 18:37:14 -05:00
Quentin Young
224782816d lib: better load-time error handling for scripts
Signed-off-by: Quentin Young <qlyoung@nvidia.com>
2020-12-01 18:37:14 -05:00
Quentin Young
00d9e83a3f lib: encode plen when passing prefixes to scripts
Signed-off-by: Quentin Young <qlyoung@nvidia.com>
2020-12-01 18:37:14 -05:00
Quentin Young
479d37cce0 lib: close lua state when destroying script
Signed-off-by: Quentin Young <qlyoung@nvidia.com>
2020-12-01 18:37:14 -05:00
Quentin Young
646b0cce88 lib: add better script error handling
Signed-off-by: Quentin Young <qlyoung@nvidia.com>
2020-12-01 18:37:14 -05:00
Quentin Young
e613a6f73c lib: initialize scripting system in libfrr
Signed-off-by: Quentin Young <qlyoung@nvidia.com>
2020-12-01 18:37:14 -05:00
Quentin Young
12bf07a5dc 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>
2020-12-01 18:37:14 -05:00
Quentin Young
3b002f1916 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>
2020-12-01 18:37:14 -05:00
Quentin Young
923431ef80 lib: fix hash issues in scripting foo
Signed-off-by: Quentin Young <qlyoung@nvidia.com>
2020-12-01 18:37:14 -05:00
Quentin Young
a3ce06c40b 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>
2020-12-01 18:37:14 -05:00
Quentin Young
9f79b3758d 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>
2020-12-01 18:37:14 -05:00
Quentin Young
f944ec671c lib: make encoder type a typedef
Need to use it for casts regularly.

Signed-off-by: Quentin Young <qlyoung@nvidia.com>
2020-12-01 18:37:14 -05:00
Quentin Young
3d19ffc5ef lib: add 'script <type> foo' test command
Signed-off-by: Quentin Young <qlyoung@nvidia.com>
2020-12-01 18:37:14 -05:00
Quentin Young
5f98c815b6 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>
2020-12-01 18:37:14 -05:00
Quentin Young
e93f19fb66 lib: add Lua stack dumper
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2020-12-01 18:37:14 -05:00
Quentin Young
0fe6a43d90 lib: move bgp routemap stuff out of frrlua.[ch]
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2020-12-01 18:37:14 -05:00
Quentin Young
f937164459 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>
2020-12-01 18:37:14 -05:00
Quentin Young
d473bdc7f1 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>
2020-12-01 18:37:14 -05:00
Quentin Young
cd6ca660c5 lib: add interface -> table encoder
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2020-12-01 18:37:14 -05:00
Quentin Young
6021965926 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>
2020-12-01 18:37:14 -05:00
Quentin Young
c8aad9c3a4 lib: update doc comment on hash_cmp
Signed-off-by: Quentin Young <qlyoung@nvidia.com>
2020-12-01 15:47:56 -05:00
Igor Ryzhov
6df43392d8 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>
2020-11-30 18:55:40 +03:00
Rafael Zalamena
91804f630c lib: add new stream function to reorganize buffer
The function was originally implemented for zebra data plane FPM plugin,
but another code places could use it.

Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
2020-11-24 07:54:07 -03:00
Donald Sharp
22d7226542
Merge pull request #7546 from mjstapp/limit_fds
lib: add startup-time option to limit fds used
2020-11-19 19:28:57 -05:00
Igor Ryzhov
62b439624b lib: fix local variable shadowing global one
start_config and end_config are already used as function names in DEFUN,
so the current naming is a little bit confusing. Let's use different
names for arguments.

Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2020-11-20 00:53:34 +03:00
Mark Stapp
b3ec3c3cb9
Merge pull request #7424 from donaldsharp/config_commands
lib, sharpd, vtysh: When reading a file in for config send start/end …
2020-11-19 12:40:50 -05:00
Donald Sharp
cac886dd53
Merge pull request #6145 from patrasar/pim_nb_code_upstream
pimd: northbound backend code
2020-11-19 11:03:00 -05:00
Donald Sharp
16ae941f4a lib: Add information log of how long configuration took to read in
Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2020-11-19 09:52:11 -05:00
Donald Sharp
f8e6ada882 lib, sharpd, vtysh: When reading a file in for config send start/end indicators
When reading a file in for configuration, send start and end indicators
to interested parties.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2020-11-19 09:52:11 -05:00
Donald Sharp
07d4bb8b9c lib: Stop socket from leaking.
Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2020-11-19 07:02:15 -05:00
Donatas Abraitis
53a85efa51
Merge pull request #7554 from donaldsharp/sockunion2hostprefix_watch_returns
bgpd, lib, nhrpd, zebra: verify return of sockunion2hostprefix
2020-11-19 11:26:02 +02:00
Donald Sharp
d377cf01e7
Merge pull request #7210 from idryzhov/route-types-disable-daemon
lib: respect --disable-daemon flags in route_types.h
2020-11-18 19:38:14 -05:00
Mark Stapp
1a9f340b6b lib: add startup option to limit fds
Add a startup-time option to limit the number of fds used
by the thread/event infrastructure. If nothing is configured,
the system ulimit is used.

Signed-off-by: Mark Stapp <mjs@voltanet.io>
2020-11-18 15:34:35 -05:00
Mark Stapp
84c709bc6e
Merge pull request #7555 from idryzhov/cppcheck-fixes
fix a couple of issues found by cppcheck
2020-11-18 14:29:25 -05:00
Mark Stapp
410a7b7058
Merge pull request #7553 from donaldsharp/mem_leak_ferr
lib: Cleanup mem-leaks in error case
2020-11-18 11:56:34 -05:00
Igor Ryzhov
65f18319c0 lib: fix macro style
We prefer semicolon in the actual code instead of macro elsewhere in the
code.

Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2020-11-18 19:14:03 +03:00
Donald Sharp
0154d8ce45 bgpd, lib, nhrpd, zebra: verify return of sockunion2hostprefix
The return from sockunion2hostprefix tells us if the conversion
succeeded or not.  There are places in the code where we
always assume that it just `works`, since it can fail
notice and try to do the right thing.

Please note that failure of this function for most cases
of sockunion2hostprefix is highly highly unlikely as that
the sockunion was already created and tested elsewhere
it's just that this function can fail.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2020-11-18 11:04:27 -05:00
Donald Sharp
1d06fc711a lib: Cleanup mem-leaks in error case
When we fail to properly lookup an error code, properly cleanup
on return.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2020-11-18 08:54:51 -05:00
Mark Stapp
926bc58f78
Merge pull request #7478 from donaldsharp/buffer
Buffer
2020-11-18 08:30:47 -05:00
Patrick Ruddy
d50f52b9da
Merge pull request #7511 from donaldsharp/vtysh_warn
Vtysh excessive/too little doc string re-instatement
2020-11-17 16:35:48 +00:00
Russ White
a1a41d5c6b
Merge pull request #7476 from opensourcerouting/bfd-fixes
bfdd,lib: integration fixes
2020-11-17 07:34:29 -05:00
Russ White
7dce3c57c2
Merge pull request #7518 from donaldsharp/asic_offload_more
Asic offload more
2020-11-17 07:27:41 -05:00
Donald Sharp
c8a400f374 lib: Change zlog_debug to zlog_err for doc string issues
Modify the code to change from zlog_debug to zlog_err.
vtysh was not outputting the vtysh doc string issues
after a change a couple of months back.  By changing
to error level we start seeing them on vtysh start up
again.  This will allow us to catch these issues
in the CI runs again.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2020-11-17 07:25:24 -05:00
Russ White
2bd9d50ca1
Merge pull request #7523 from donaldsharp/route_map_object_t
*: Remove route_map_object_t from the system
2020-11-17 07:16:12 -05:00
Donald Sharp
23961e75b9 lib: When aborting log data
When a FRR process dies due to SIGILL/SIGABORT/etc attempt
to drain the log buffer.  This code change is capturing
some missing logs that were not part of the log file on
a crash.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2020-11-16 15:12:43 -05:00
Donatas Abraitis
e5c317bcfa
Merge pull request #7526 from donaldsharp/i_am_a_robot_wumpalump
Cleanup on Aisle 5: Memory leaks, Uninited data and code snarfles
2020-11-16 17:32:30 +02:00
Donatas Abraitis
9ccd17bc12
Merge pull request #7510 from donaldsharp/xpath_stay
lib: Fix crash walking up command chain in bgp commands
2020-11-16 10:06:08 +02:00
Donald Sharp
7cfdb48554 *: Convert all usage of zclient_send_message to new enum
The `enum zclient_send_status` enum needs to be extended
throughout the code base to use the new states and
to fix up places where we tested against the return
value being non zero.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2020-11-15 15:04:52 -05:00
Donald Sharp
8a3f8f2e4a bgpd, lib, sharpd: Add enum for zclient_send_message return
Add a `enum zclient_send_status` for appropriate handling
of return codes from zclient_send_message.  Touch all the places
where we handle this.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2020-11-15 14:50:17 -05:00
Donald Sharp
db71415b41 bgpd, lib: Indicate when we are buffering instead of immediately sending down ZAPI
When FRR sends data over the ZAPI protocol from the upper levels to zebra, indicate
to the calling functions that we have started buffering data to be sent if the
socket is full underneath it.

Also add a call back function `zebra_buffer_write_ready` that we can call
when an upper level protocol's socket buffer has been drained.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2020-11-15 14:50:17 -05:00
Mark Stapp
32f7e999f2 lib: clean up out-of-date zapi comment
Clean up and edit a comment about zapi route encoding; was
outdated (or just ... wrong).

Signed-off-by: Mark Stapp <mjs@voltanet.io>
2020-11-15 14:50:17 -05:00
Mark Stapp
55e74ca925 zebra: use smaller stream buffer for zapi route notifications
The owner-notification zapi message is small; use a small buffer
for it.

Signed-off-by: Mark Stapp <mjs@voltanet.io>
2020-11-15 14:50:17 -05:00
Donald Sharp
0d32fbee6d lib, zebra: Add ability to read kernel notice of Offload Failed
The linux kernel is getting RTM_F_OFFLOAD_FAILED for kernel routes
that have failed to offload.  Write the code
to receive these notifications from the linux kernel
and store that data for display about the routes.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2020-11-15 10:12:50 -05:00
Donald Sharp
f18ba3cd18 bgpd, lib, staticd, tests: Convert to using FOREACH_AFI_SAFI
Move the FOREACH_AFI_SAFI macro from bgpd.h to zebra.h( GLOBAL's YOUALL )

Then convert all the places that have the two level for loop to
iterate over all afi/safis

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2020-11-14 18:53:03 -05:00
Donald Sharp
1782514fb9 *: Remove route_map_object_t from the system
The route_map_object_t was being used to track what protocol we were
being called against.  But each protocol was only ever calling itself.
So we had a variable that was only ever being passed in from route_map_apply
that had to be carried against and everyone was testing if that variable
was for their own stack.

Clean up this route_map_object_t from the entire system.  We should
speed some stuff up.  Yes I know not a bunch but this will add up.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2020-11-13 19:35:20 -05:00
Mark Stapp
15675d025d
Merge pull request #7474 from eololab/fix-crash-skiplist-debug
lib, bgpd: fix crash using skiplist debug function
2020-11-13 10:54:49 -05:00
Donald Sharp
1e93fbed31 lib: Fix crash walking up command chain in bgp commands
As part of normal processing we allow bgp commands to walk
up the command node chain.  We are experiencing this crash:

Thread 1 "bgpd" received signal SIGABRT, Aborted.
__GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:50
50	../sysdeps/unix/sysv/linux/raise.c: No such file or directory.
(gdb) bt
    assertion=0x7ffff7f3ba4f "set", file=0x7ffff7f3ba44 "lib/yang.c", line=413, function=<optimized out>)
    at assert.c:92
    line=413, function=0x7ffff7f3bc50 <__PRETTY_FUNCTION__.9> "yang_dnode_get") at assert.c:101
    vty=0x5555561715a0, argc=3, argv=0x555558601620) at bgpd/bgp_vty.c:9568
    cmd=0x0) at lib/command.c:937
    at lib/command.c:997
    matched=0x0, vtysh=0) at lib/command.c:1161
    at lib/vty.c:517
(gdb)

9582			bgp_glb_dnode = yang_dnode_get(vty->candidate_config->dnode,
(gdb) p vty->xpath
$8 = {
  "/frr-routing:routing/control-plane-protocols/control-plane-protocol[type='frr-bgp:bgp'][name='bgp'][vrf='default']/frr-bgp:bgp", '\000' <repeats 897 times>, '\000' <repeats 1023 times>, '\000' <repeats 1023 times>,
  '\000' <repeats 1023 times>, '\000' <repeats 1023 times>, '\000' <repeats 1023 times>, '\000' <repeats 1023 times>,
  '\000' <repeats 1023 times>}
(gdb) p vty->xpath_index
$9 = 0
(gdb)

We are effectively sending in an array index based upon vty->xpath_index( which is zero) but
the VTY_CURR_XPATH macro subtracts 1 from that value to find the appropriate xpath to use.
This of course subtracts 1 from 0 and we underflow the array.

The relevant section in a config file is this:

address-family ipv6 flowspec
  bgp maxim...

Effectively we were trying to walk up the command chain for flowspec to see
if the command is entered correctly.  There is a function vty_check_node_for_xpath_decrement
that was looking at bgp sub-modes to make the decision to allow us to decrement
the vty->xpath_index which did not have the v4 or v6 flowspec bgp sub modes in the
check.

Adding them in fixes the problem.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2020-11-12 15:15:52 -05:00
Santosh P K
9b936c5c36
Merge pull request #4770 from kssoman/fib
Advertise FIB installed routes to bgp peers
2020-11-12 18:59:24 +05:30
Emanuele Bovisio
bcbc2aa75e lib, bgpd: fix crash using skiplist debug function
calling "skiplist test" and then "skiplist debug",
there was a crash due to a freed pointer.

Agreed to remove static pointer (see PR #7474).

Signed-off-by: Emanuele Bovisio <emanuele.bovisio@eolo.it>
2020-11-10 19:01:56 +01:00
Donald Sharp
42e122614b
Merge pull request #7448 from mjstapp/fix_gcc10_formats
* : clean up format specifiers for gcc-10
2020-11-10 11:23:02 -05:00
Donatas Abraitis
4b0e387075
Merge pull request #7463 from louis-oui/netnsname
lib: change limit of netns name from 15 to 35 characters
2020-11-10 09:39:43 +02:00
Louis Scalbert
990374e1d2 lib: change limit of netns name from 15 to 35 characters
Extend the size of netns name to match linux permitted netns name size

Signed-off-by: Louis Scalbert <louis.scalbert@6wind.com>
2020-11-09 11:24:53 +01:00
Rafael Zalamena
a29c51a187 lib: notify BFD when adding new profile
When a BFD integrated session already exists setting the profile
doesn't cause a session update (or vice versa): fix this issue by
handling the other cases.

Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
2020-11-08 12:06:32 -03:00
Rafael Zalamena
4b983eef2c bfdd,lib: simplify integration protocol
Let the integration protocol always send the full configuration
instead of saving a few bytes. It will also allow protocols to specify
source address for IPv4 single hop connections and interface for multi
hop configuration.

Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
2020-11-08 12:06:32 -03:00
Sarita Patra
cf740d2e72 pimd: Northbound implementation for msdp mesh group, msdp peer commands
ip_msdp_peer
no_ip_msdp_peer
ip_msdp_mesh_group_member
no_ip_msdp_mesh_group_member
ip_msdp_mesh_group_source
no_ip_msdp_mesh_group_source
no_ip_msdp_mesh_group

Yang Model:
  augment /frr-routing:routing/frr-routing:control-plane-protocols/frr-routing:control-plane-protocol:
    +--rw pim
       +--rw address-family* [address-family]
          +--rw address-family          identityref
          +--rw msdp-mesh-group!
          |  +--rw mesh-group-name?   string
          |  +--rw member-ip*         ietf-inet-types:ip-address
          |  +--rw source-ip?         ietf-inet-types:ip-address
          +--rw msdp-peer* [peer-ip]
          |  +--rw peer-ip      ietf-inet-types:ip-address
          |  +--rw source-ip?   ietf-inet-types:ip-address

Signed-off-by: Sarita Patra <saritap@vmware.com>
2020-11-06 03:42:00 -08:00
Soman K S
77b38a4a7d bgpd: Advertise FIB installed routes to bgp peers (Part 1)
Issue:
The bgp routes learnt from peers which are not installed in kernel are
advertised to peers. This can cause routers to send traffic to these
destinations only to get dropped. The fix is to provide a configurable
option "bgp suppress-fib-pending". When the option is enabled, bgp will
advertise routes only if it these are successfully installed in kernel.

Fix (Part1) :
* Added message ZEBRA_ROUTE_NOTIFY_REQUEST used by client to request
  FIB install status for routes
* Added AFI/SAFI to ZAPI messages
* Modified the functions zapi_route_notify_decode(), zsend_route_notify_owner()
  and route_notify_internal() to include AFI, SAFI as parameters

Signed-off-by: kssoman <somanks@gmail.com>
2020-11-06 08:39:28 +05:30
Russ White
9f6c4d4d16
Merge pull request #7227 from chiragshah6/yang_dev
bgpd, yang : neighbor and peer-group config cmds to transactional clis
2020-11-05 14:32:39 -05:00
Mark Stapp
72327cf3e7 * : clean up format specifiers for gcc-10
gcc 10 complains about some of our format specs, fix them. Use
atomic size_t in thread stats, to work around platform
differences.

Signed-off-by: Mark Stapp <mjs@voltanet.io>
2020-11-04 16:56:17 -05:00
Quentin Young
b4d6e8559f lib: fix missed pointer update
Function argument changed from thread * to thread ** without updating
the corresponding tracepoint.

Signed-off-by: Quentin Young <qlyoung@nvidia.com>
2020-11-02 16:22:54 -05:00
Donald Sharp
502dd27af9
Merge pull request #7045 from mjstapp/fix_signals
lib: Resolve signal handling race in event loop
2020-10-28 19:29:29 -04:00
Mark Stapp
d81ca9a3fa lib: avoid signal-handling race with event loop poll call
Manage the main pthread's signal mask to avoid a signal-handling
race. Before entering poll, check for pending signals that the
application needs to handle. Use ppoll() to re-enable those
signals during the poll call.

Signed-off-by: Mark Stapp <mjs@voltanet.io>
2020-10-28 16:31:54 -04:00
Mark Stapp
1543c387be lib: add debug output for signal mask
Add an api that debugs the signals in a sigset.

Signed-off-by: Mark Stapp <mjs@voltanet.io>
2020-10-28 16:31:54 -04:00
Chirag Shah
fbace230b0 lib: add flowspec safi to identitiy ref parsing
Signed-off-by: Chirag Shah <chirag@nvidia.com>
2020-10-27 11:26:55 -07:00
Patrick Ruddy
dd51171227
Merge pull request #7158 from AnuradhaKaruppiah/mh-df-election
evpn-mh: support for DF election
2020-10-27 16:09:45 +00:00
Donald Sharp
ecbbcba1ef
Merge pull request #7026 from chiragshah6/yang_nb5
*: Convert bgp afi-safis configurations to transactional clis
2020-10-27 11:18:43 -04:00
Mark Stapp
976c5cc134 lib: add sigevent_check api
Add an api that blocks application-handled signals (SIGINT,
SIGTERM, e.g.) then tests whether any signals have been received.
This helps to manage a race between signal reception and the poll
call in the main event loop.

Signed-off-by: Mark Stapp <mjs@voltanet.io>
2020-10-26 16:46:40 -04:00
Anuradha Karuppiah
a2339ed9e3 lib, bgpd: move json_array_string_add to lib
json_array_string_add is used to add a string entry into a JSON
list. This API is needed by zebra so moving it from bgpd to lib.

Signed-off-by: Anuradha Karuppiah <anuradhak@cumulusnetworks.com>
2020-10-26 10:33:21 -07:00
Anuradha Karuppiah
74e2bd891d bgpd: support for DF election in EVPN-MH
DF (Designated forwarder) election is used for picking a single
BUM-traffic forwarded per-ES. RFC7432 specifies a mechanism called
service carving for DF election. However that mechanism has many
disadvantages -
1. LBs poorly.
2. Doesn't allow for a controlled failover needed in upgrade
scenarios.
3. Not easy to hw accelerate.

To fix the poor performance of service carving alternate DF mechanisms
have been proposed via the following drafts -
draft-ietf-bess-evpn-df-election-framework
draft-ietf-bess-evpn-pref-df

This commit adds support for the pref-df election mechanism which
is used as the default. Other mechanisms including service-carving
may be added later.

In this mechanism one switch on an ES is elected as DF based on the
preference value; higher preference wins with IP address acting
as the tie-breaker (lower-IP wins if pref value is the same).

Sample output
=============
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
torm-11# sh bgp l2vpn evpn es 03:00:00:00:00:01:11:00:00:01
ESI: 03:00:00:00:00:01:11:00:00:01
 Type: LR
 RD: 27.0.0.15:6
 Originator-IP: 27.0.0.15
 Local ES DF preference: 100
 VNI Count: 10
 Remote VNI Count: 10
 Inconsistent VNI VTEP Count: 0
 Inconsistencies: -
 VTEPs:
  27.0.0.16 flags: EA df_alg: preference df_pref: 32767
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
torm-11# sh bgp l2vpn evpn route esi 03:00:00:00:00:01:11:00:00:01
*> [4]:[03:00:00:00:00:01:11:00:00:01]:[32]:[27.0.0.15]
                    27.0.0.15                          32768 i
                    ET:8 ES-Import-Rt:00:00:00:00:01:11 DF: (alg: 2, pref: 100)
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

Signed-off-by: Anuradha Karuppiah <anuradhak@cumulusnetworks.com>
2020-10-26 10:26:21 -07:00
Quentin Young
0616c6589f
Merge pull request #7384 from opensourcerouting/nb-dyn-modules
lib: add API to load YANG modules on demand
2020-10-26 13:14:30 -04:00
Chirag Shah
dd90823b1d lib: handle exit cmd for bgp afi-safi nodes
In transactional cli mode, bgp address-family <afi> <afi>
node builds xpath on top of `router bgp` node's xpath.
When `exit` is applied under afi-safi commands, retain
xpath_index to 1 to keep using bgp global xpath.

Signed-off-by: Chirag Shah <chirag@nvidia.com>
2020-10-26 08:57:14 -07:00
Mark Stapp
cbd492990d
Merge pull request #7194 from qlyoung/tracing
Tracing
2020-10-24 16:50:35 -04:00
Renato Westphal
59e85ca1ba lib: add API to load YANG modules on demand
Make it possible to load YANG modules outside the main northbound
initialization. The primary use case is to support YANG modules
that are specific to an FRR plugin. Example: only load the PCEP
YANG module when the corresponding FRR plugin is loaded. Other use
cases might arise in the future.

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2020-10-23 18:18:22 -03:00
Renato Westphal
8d869d378b lib: combine two YANG schema iteration functions into one
Combine yang_snodes_iterate_module() and yang_snodes_iterate_all()
into an unified yang_snodes_iterate() function, where the first
"module" parameter is optional. There's no point in having two
separate YANG schema iteration functions anymore now that they are
too similar.

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2020-10-23 18:18:22 -03:00
Renato Westphal
9bde0b2569 lib: fix iteration over schema nodes of a single YANG module
The only safe way to iterate over all schema nodes of a given YANG
module is by iterating over all schema nodes of all YANG modules
and filter out the nodes that belong to other modules.

The original yang_snodes_iterate_module() code did the following:
1 - Iterate over all top-level schema nodes of the given module;
2 - Iterate over all augmentations of the given module.

While that iteration strategy is more efficient, it does't handle
well more complex YANG hierarchies containing nested augmentations
or self-augmenting modules. Any iteration that isn't done on the
resolved YANG data hierarchy is fragile and prone to errors.

Fixes regression introduced by commit 8a923b4851 where the
gen_northbound_callbacks tool was generating duplicate callbacks
for certain modules.

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2020-10-23 18:18:22 -03:00
Quentin Young
c7bb4f006b lib, bgpd: convert lttng tracepoints to frrtrace()
- tracepoint() -> frrtrace()
- tracelog() -> frrtracelog()
- tracepoint_enabled() -> frrtrace_enabled()

Also removes copypasta'd #ifdefs for those LTTng macros, those are
handled in lib/trace.h

Signed-off-by: Quentin Young <qlyoung@nvidia.com>
2020-10-23 15:13:51 -04:00
Quentin Young
552e2a306a lib: add trace.h, frrtrace(), support for USDT
Previous commits added LTTng tracepoints. This was primarily for testing
/ trial purposes; in practice we'd like to support arbitrary tracing
methods, and especially USDT probes, which SystemTap and dtrace expect,
and which are supported on at least one flavor of BSD (FreeBSD).

To that end this patch adds an frr-specific tracing macro, frrtrace(),
which proxies into either DTRACE_PROBEn() or tracepoint() macros
depending on whether --enable-usdt or --enable-lttng is passed at
compile time.

At some point this could be tweaked to allow compiling in both types of
probes. Ideally there should be some logic there to use LTTng's optional
support for generating USDT probes when both are requested.

No additional libraries are required to use USDT, since these probes are
a kernel feature and only need the <sys/sdt.h> header.

- add --enable-usdt to toggle use of LTTng tracepoints or USDT probes
- add new trace.h library header for use with tracepoint definition
  headers
- add frrtrace() wrapper macro; this should be used to define
  tracepoints instead of using tracepoint() or DTRACE_PROBEn()

Compilation with USDT does nothing as of this commit; the existing LTTng
tracepoints need to be converted to use the frrtrace*() macros in a
subsequent commit.

Signed-off-by: Quentin Young <qlyoung@nvidia.com>
2020-10-23 15:13:51 -04:00
Quentin Young
912d45a161 lib: move trace.h -> libfrr_trace.h
Signed-off-by: Quentin Young <qlyoung@nvidia.com>
2020-10-23 15:13:51 -04:00
Quentin Young
a72255a336 lib: add tracepoint for route table get
Signed-off-by: Quentin Young <qlyoung@nvidia.com>
2020-10-23 15:13:51 -04:00
Quentin Young
d92658f4f7 lib: add tracepoints for *malloc, list ops
- Add tracepoints for FRR malloc and free
- Add tracepoints for basic list operations

Signed-off-by: Quentin Young <qlyoung@nvidia.com>
2020-10-23 15:13:51 -04:00
Quentin Young
67a485d18f lib: add tracepoint for hash insertion
hash_get is used for both lookup and insert; add a tracepoint for when
we insert something into the hash

Signed-off-by: Quentin Young <qlyoung@nvidia.com>
2020-10-23 15:13:51 -04:00
Quentin Young
87879a5ecb lib: add tracepoints for pthread run, stop
Signed-off-by: Quentin Young <qlyoung@nvidia.com>
2020-10-23 15:13:51 -04:00
Quentin Young
1bd1ebaa08 lib: generate trace events for log messages
LTTng supports tracef() and tracelog() macros, which work like printf,
and are used to ease transition between logging and tracing. Messages
printed using these macros end up as trace events. For our uses we are
not interested in dropping logging, but it is nice to get log messages
in trace output, so I've added a call to tracelog() in zlog that dumps
our zlog messages as trace events.

Signed-off-by: Quentin Young <qlyoung@nvidia.com>
2020-10-23 15:13:51 -04:00
Quentin Young
abf96a87f3 lib: add tracepoints for hash ops, thread events
Define some initial tracepoints for hash table operations, thread
schedules, and thread cancels

Signed-off-by: Quentin Young <qlyoung@nvidia.com>
2020-10-23 15:13:51 -04:00
Quentin Young
0cbcadccf7 lib, configure.ac: initial LTTng support
This commit adds initial support for LTTng.

When --enable-lttng=no or is not specified, no tracing code is included.
When --enable-lttng=yes, LTTng tracing events are (will be) generated.

configure.ac:
- add --enable-lttng
- define HAVE_LTTNG when enabled
- minimum LTTng version: 2.12.0

lib:
- add trace.[ch]
- update subdir.am

Signed-off-by: Quentin Young <qlyoung@nvidia.com>
2020-10-23 15:13:51 -04:00
Quentin Young
02178900de lib: #undef _ASSERT_FUNCTION
Redefining it has issues depending on header order.

Signed-off-by: Quentin Young <qlyoung@nvidia.com>
2020-10-23 15:13:51 -04:00
Mark Stapp
5047884528 *: unify thread/event cancel macros
Replace all lib/thread cancel macros, use thread_cancel()
everywhere. Only the THREAD_OFF macro and thread_cancel() api are
supported. Also adjust thread_cancel_async() to NULL caller's pointer (if
present).

Signed-off-by: Mark Stapp <mjs@voltanet.io>
2020-10-23 12:16:52 -04:00
Mark Stapp
b3d6bc6ef0 * : update signature of thread_cancel api
Change thread_cancel to take a ** to an event, NULL-check
before dereferencing, and NULL the caller's pointer. Update
many callers to use the new signature.

Signed-off-by: Mark Stapp <mjs@voltanet.io>
2020-10-23 08:59:34 -04:00
Donatas Abraitis
af3b34f690 lib: Convert inet_ntoa to %pI4
Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
2020-10-22 15:32:50 +03:00
Donatas Abraitis
2dbe669bdf :* Convert prefix2str to %pFX
Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
2020-10-22 09:07:41 +03:00
Donatas Abraitis
9072f5c89a
Merge pull request #7311 from donaldsharp/table_lock_count
Abstract rn->lock accessing and cleanup usage to %pFX and %pRN
2020-10-20 16:04:15 +03:00
Patrick Ruddy
cecc76cdc5
Merge pull request #7300 from sworleys/EVPN-RType-NUMs
lib,bgpd: more evpn route-type numerical command versions
2020-10-20 11:05:31 +01:00
Donald Sharp
b219dda129 lib: Convert usage of strings to %pFX and %pRN
Convert over to using the %pFX and %pRN modifiers
to output strings to allow us to consolidate on
one standard for printing prefixes.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2020-10-17 13:39:10 -04:00
Donald Sharp
c10e14e96d *: Create/Use accessor functions for lock count
Create appropriate accessor functions for the rn->lock
data.  We should be accessing this data through accessor
functions since it is private data to the data structure.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2020-10-17 13:39:10 -04:00
Donald Sharp
e3a48b60e2 lib: Relax usage of ip prefix-list A.B.C.D/M ge Y
Currently the prefix length M must be less than Y.
Relax this restriction to allow M to be less than or equal
to Y.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2020-10-17 13:36:19 -04:00
Donald Sharp
d354e6e34f
Merge pull request #7317 from pjdruddy/pr-fix-evpn-prefix2string
Pr fix evpn prefix2string
2020-10-17 13:16:21 -04:00
Santosh P K
421791c5b6
Merge pull request #7235 from opensourcerouting/acl-wildcard-fix
lib,yang: cisco acl network wildcard fixes
2020-10-16 21:28:39 +05:30
Pat Ruddy
f137734bb4 bgpd: replace bgp_evpn_route2str with prefix2str
Remove bgp_evpn_route2str and replace calls with prefix2str

Signed-off-by: Pat Ruddy <pat@voltanet.io>
2020-10-16 11:54:30 +01:00
Pat Ruddy
8d78eeb54b lib: align prefixevpn2str output with bgp_evpn_route2str
We have 2 different routines to turn an evpn route into a string.
This commit aligns the two to the latest maintained version as a
first step in removing one of them.

Signed-off-by: Pat Ruddy <pat@voltanet.io>
2020-10-15 14:28:51 +01:00
Stephen Worley
247fb57d63 lib: consolidate evpn type help strings into macro
Consolidate evpn type help strings into one single
macro for use on commands that need to support all
the types.

Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
2020-10-13 16:13:16 -04:00
Donald Sharp
28ef0ee121 *: Use proper semantics for turning off thread
We have this pattern in the code base:

if (thread)
	THREAD_OFF(thread);

If we look at THREAD_OFF we check to see if thread
is non-null too.  So we have a double check.
This is unnecessary.  Convert to just using THREAD_OFF

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2020-10-12 08:35:18 -04:00
Stephen Worley
3717389c43 lib: add some EVPN help string constants
Add some EVPN help string constants to make use of
in later commits.

Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
2020-10-08 16:01:56 -04:00
Renato Westphal
9cfb2747ad
Merge pull request #7241 from chiragshah6/evpn_dev1
lib: add errmsg to nb rpc
2020-10-07 11:50:52 -03:00
Mark Stapp
5810419aa4
Merge pull request #7238 from sworleys/Nexthop-Same-First-Remove
lib: remove nexthop_same_firsthop() api
2020-10-06 08:33:35 -04:00
Chirag Shah
f63f5f1947 *: add errmsg to nb rpc
Display human readable error message in northbound rpc
transaction failure. In case of vtysh nb client, the error
message will be displayed to user.

Testing:

bharat# clear evpn dup-addr vni 1002 ip 11.11.11.11
Error type: generic error
Error description: Requested IP's associated MAC aa:aa:aa:aa:aa:aa is still
in duplicate state

Signed-off-by: Chirag Shah <chirag@nvidia.com>
2020-10-05 13:15:59 -07:00
Rafael Zalamena
b1993be687 lib: fix cisco access list wildcard usage
Don't attempt to compress the wildcard information to fit a `/M`, but
use its own full 4 byte field.

Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
2020-10-04 07:05:17 -03:00
Chirag Shah
a363b4b49b lib: increase the size of northbound max module
Increase the size of frr_yang_module_info
macro to accomodate bgp module list.

root@bharat:~/stash/frr# egrep "xpath" bgpd/bgp_nb.c | wc -l
1150

Signed-off-by: Chirag Shah <chirag@nvidia.com>
2020-10-03 11:25:37 -07:00
Chirag Shah
bc8c00cca1 *: add bgp yang files into makefiles
Signed-off-by: Chirag Shah <chirag@nvidia.com>
2020-10-03 11:25:37 -07:00
Stephen Worley
7403e15561 lib: remove nexthop_same_firsthop() api
Remove the nexthop_same_firsthop() api and just call nexthop_same().
Not entirely sure why we were using this function in the first place,
but now we are just marking dupes with it so lets just call a
common function and avoid issues.

Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
2020-10-02 17:25:36 -04:00
Igor Ryzhov
d7b86ae4fe vtysh: dynamically generate the list of daemons for commands
Some daemons were actually missing from the static definitions: nhrpd,
babeld, eigrpd and bfdd.

Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2020-10-02 15:06:27 +03:00
Igor Ryzhov
b3b4dfa5ae lib: respect --disable-daemon flags in route_types.h
* remove pre-generation of route_types.h from configure

  This change is a partial revert of commit 306ed6816. This is a little
  drawback, but at least "make lib/libfrr.la", mentioned in the commit,
  still works because route_types.h is forced to be built in f1b32b2e5.

* add "enabled" field to route_types.txt to track which daemon should
  be enabled to add the routing protocol to "show ip route" header and
  to redistribution list

Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2020-10-02 12:59:46 +03:00
Quentin Young
2fec17cd04 lib: fix zapi_nexthop_update_decode error rc
This function returns true on success and false otherwise. Returning -1
on error is equivalent to returning true.

Signed-off-by: Quentin Young <qlyoung@nvidia.com>
2020-09-30 18:22:33 -04:00
Stephen Worley
2173535298 lib,zebra,sharpd: add code for backup proto-NHs but disabled
Add the zapi code for encoding/decoding of backup nexthops for when
we are ready for it, but disable it for now so that we revert
to the old way with them.

When zebra gets a proto-NHG with a backup in it, we early fail and
tell the upper level proto. In this case sharpd. Sharpd then reverts
to the old way of installation with the route.

Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
2020-09-28 12:41:00 -04:00
Stephen Worley
c6ce9334b5 lib,sharpd: align zapi NHG apis a bit
Align the zapi NHG apis to be more consistent with the zapi_route
apis. Add a struct zapi_nhg to use for encodings as well.

Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
2020-09-28 12:41:00 -04:00
Stephen Worley
3509dd49c0 lib: add doc to clear-up hash_iterate multi deletion
Add some header documentation to make it clear that you
cannot delete more than one item during each iteration.
Doing so could cause memory corruption for next pointer
if its also deleted from the table.

Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
2020-09-28 12:41:00 -04:00
Stephen Worley
391c7a3b18 lib: add proto NHG Notif header to log command types
Add the proto Nexthop Group Notify Owner header to
the log command types for string conversion.

Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
2020-09-28 12:41:00 -04:00
Stephen Worley
ff9aca4f8d lib,zebra,sharpd: clang format
Clang format for NHG API and sharpd patches.

Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
2020-09-28 12:41:00 -04:00
Stephen Worley
2c7819b9d4 lib,zebra: fixup NHG notify zapi messaging
Make the message parameters align better with other zapi
notifications and change the ID to correctly be a uint32.

Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
2020-09-28 12:41:00 -04:00
Stephen Worley
cc6a0d7d80 Revert "lib,sharpd,pbrd: set installable nhg command"
This reverts commit 1844f45e30913b27cfd875036f865a0edadcf244.
2020-09-28 12:40:59 -04:00
Stephen Worley
b36bedd2c3 lib: add logging for ZEBRA_NHG_ADD[DEL]
Add logging info for the new zapi ZEBRA_NHG_ADD[DEL]
message types. With this patch, they are logged properly
when debugs are turned on.

Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
2020-09-28 12:40:59 -04:00
Stephen Worley
0de1db8f3b lib,sharpd,pbrd: set installable nhg command
Add a command `set installable` that allows configured nexthop
groups to be treated as separate/installable objects in the RIB.

A callback needs to be implemented per daemon to handle installing
the NHG into the rib via zapi when this command is set. This
patch includes the implementation for sharpd.

Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
2020-09-28 12:40:59 -04:00
Stephen Worley
54c6fa8e0a lib,doc: add onlink flag to nexthop group config
Add an `onlink` flag to nexthop group configuration.

Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
2020-09-28 12:40:59 -04:00
Stephen Worley
e90284d77f lib: add onlink flag to zapi_nh conversion helper
Add setting the onlink flag to the zapi_nh conversion
helper function so that we can set the onlink flag with
it when passing down NHGs from upper level protos.

Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
2020-09-28 12:40:59 -04:00
Stephen Worley
54c89c9377 zebra: NHG ID bounds macros
Determine the NHG ID spacing and lower bound with ZEBRA_ROUTE_MAX
in macros.

Directly set the upperbound to be the lower 28bits of the uint32_t ID
space (the top 4 are reserved for l2-NHGs). Round that number down
a bit to make it more even.

Convert all former lower_bound calls to just use the macro.

Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
2020-09-28 12:40:59 -04:00
Stephen Worley
6c67f41f9e zebra,lib: command to only install proto-based nexthops
Add a command/functionality to only install proto-based nexthops.
That is nexthops owned/created by upper level protocols, not ones
implicitly created by zebra.

There are some scenarios where you would not want zebra to be
arbitrarily installing nexthop groups and but you still want
to use ones you have control over via lib/nexthop_group config
and an upper level protocol.

Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
2020-09-28 12:40:59 -04:00
Stephen Worley
0885b1e3d9 zebra: implement protocol NHG Add/Del
Implement the underlying zebra functionality to Add/Del an
internal zebra and kernel NHG.

These NHGs are managed by the upperlevel protocols that send them
down via zapi messaging.

They are not put into the overall zebra NHG hash table and only
put into to the ID table. Therefore, different protos cannot
and will not share NHGs.

The proto is also set appropriately when sent to the kernel.

Expand the separation of Zebra hashed/shared/created NHGs and
proto created and mangaged NHGs.

Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
2020-09-28 12:40:59 -04:00
Donald Sharp
27141ea94e lib, zebra: Add ability to send down a nhgid over route install
Modify the send down of a route to use the nexthop group id
if we have one associated with the route.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2020-09-28 12:40:59 -04:00
Donald Sharp
2f35a820bf lib, zebra: Add ZAPI_NHG_ADD|DELETE
Add the ability to send a NHG from an upper level protocol down to
zebra.  ZAPI_NHG_ADD encompasses both the addition and replace
semantics ( If the id passed down does not exist yet, it's Add,
else it's a replace ).

Effectively zebra will take this nhg passed down save the nhg
in the id hash for nhg's and then create the appropriate nhg's
and finally install them into the linux kernel.  Notification
will be the ZAPI_NHG_NOTIFY_OWNER zapi message for normal
success/failure messaging to the installing protocol.

This work is being done to allow us to work with EVPN MH
which needs the ability to modify NHG's that BGP will own
and operate on.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2020-09-28 12:40:59 -04:00
Donald Sharp
224b3c8a79 lib: Add the ability to grab a nhg starting id
Add new function zclient_get_nhg_start that will allow an
upper level protocol to get a starting point for it's own
nhg space.  Give each protocol a space of 50 million.
zebra will own the space from 0 - 199999999 because
of SYSTEM, KERNEL and CONNECT route types.

This is the start of some work that will allow upper
level protocols to install and maintain their own NHG's.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2020-09-28 12:40:59 -04:00
Donald Sharp
7895c3bc4f lib: Tell the compiler we don't care about the return code
When calling yang_snodes_iterate_subtree we don't care about
the return code.  So explicitly say we don't care so that
SA tools can be on the same page as us.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2020-09-24 07:52:20 -04:00
Mark Stapp
ccda0eadac
Merge pull request #7155 from donaldsharp/TRAP
Offload/Trap
2020-09-23 16:06:37 -04:00
Donatas Abraitis
0ce5baaab1
Merge pull request #7018 from gouault6wind/show_ip_route
Clean up in vrf management
2020-09-23 08:45:09 +03:00
Mark Stapp
b6033bd1c1
Merge pull request #7067 from donaldsharp/remove_solaris
Remove solaris
2020-09-22 17:04:19 -04:00
Donald Sharp
5a3cf85391 lib, zebra: Add ability to read kernel notice of TRAP/OFFLOAD
The linux kernel is getting RTM_F_TRAP and RTM_F_OFFLOAD for
kernel routes that have an underlying asic offload.  Write the
code to receive these notifications from the linux kernel and
to store that data for display about the routes.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2020-09-22 15:57:43 -04:00
Donald Sharp
cae8bc967c *: Remove solaris from FRR
The Solaris code has gone through a deprecation cycle.  No-one
has said anything to us and worse of all we don't have any test
systems running Solaris to know if we are making changes that
are breaking on Solaris.  Remove it from the system so
we can clean up a bit.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2020-09-21 10:02:20 -04:00
Igor Ryzhov
2f272cb409 lib: don't execute command if pre-processing hook has failed
Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2020-09-21 16:12:29 +03:00
Igor Ryzhov
511942ba37 lib: fix regcomp error processing
* use actual error code instead of "false"
 * add missing new line

Before:
```
nfware# show interface | include (a]
% Regex compilation error: Success% Bad regexp '(a]'
% Unknown command: show interface | include (a]
```

After:
```
nfware# show interface | include (a]
% Regex compilation error: Unmatched ( or \(
% Bad regexp '(a]'
% Unknown command: show interface | include (a]
```

Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2020-09-21 15:35:56 +03:00
Christophe Gouault
1eb92f06c4 vrf: VRF_DEFAULT must be 0, remove useless code
Code was added in the past to support a value of VRF_DEFAULT different
from 0. This option was abandoned, the default vrf id is always 0.

Remove this code, this will simplify the code and improve performance
(use a constant value instead of a function that performs tests).

Signed-off-by: Christophe Gouault <christophe.gouault@6wind.com>
2020-09-21 10:17:35 +02:00
Christophe Gouault
7c1119cb7a lib: optimize vrf_id_to_name(VRF_DEFAULT) case
vrf_id_to_name() looks up in a RB_TREE to find the VRF entry, then
reads the name.

Avoid it for VRF_DEFAULT, which always exists and for which the
translation is straightforward.

Signed-off-by: Christophe Gouault <christophe.gouault@6wind.com>
2020-09-21 10:07:56 +02:00
Donald Sharp
0b8125588a
Merge pull request #7069 from opensourcerouting/fix-set-metric
lib: fix the "set metric" route-map command
2020-09-19 08:06:36 -04:00
Donald Sharp
3baa7b4c8e
Merge pull request #7079 from opensourcerouting/nested-yang-augmentations
lib: better support for nested YANG augmentations
2020-09-18 20:43:20 -04:00
Russ White
0a6e6613d7
Merge pull request #7089 from pguibert6WIND/netns-refactor
Netns refactor
2020-09-18 11:02:30 -04:00
Donald Sharp
0a822f99bf lib: Remove debug associated with vrf_get
The vrf_get function is called throughout the code base
so much so that when you turn on vrf debugging it eclipses
everything else to a degree that is completely unreasonable.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2020-09-18 07:14:55 -04:00
Donald Sharp
c7384cf86a lib: Add vrf name to vrf debugs
The vrf name was not being printed out in some vrf debugs.  Add
this data in so people don't have to remember the vrf id.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2020-09-17 20:17:14 -04:00
Donald Sharp
0cbee799d5 lib: Actually call nexthop_group_disable_vrf
When the nexthop-groups were added to FRR for some
reason the call to nexthop_group_disable_vrf was
not added although it was written.

Add it in.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2020-09-17 20:13:44 -04:00
Donald Sharp
32e3ca2bcc
Merge pull request #7103 from opensourcerouting/sysrepo-fixes
lib: sysrepo plugin fixes
2020-09-16 20:34:53 -04:00
Quentin Young
7ffcd8bd2d lib: set threadmaster name to 'default' if none
And also include the name of the threadmaster in its event hash name.

Signed-off-by: Quentin Young <qlyoung@nvidia.com>
2020-09-15 20:16:56 -04:00
Renato Westphal
bbeaa0333c lib: simplify handling of the sysrepo startup configuration
In the new Sysrepo, all SR_EV_ENABLED notifications are followed by
SR_EV_DONE notifications (assuming no errors occur), so there's no
need to special case the SR_EV_ENABLED event anymore (e.g. do full
transactions in one step).

While here, add a few more guarded debug messages to facilitate
troubleshooting.

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2020-09-15 16:00:07 -03:00
Renato Westphal
7dac19f7de lib: fix handling of deleted nodes in the sysrepo plugin
Make the sysrepo plugin ignore the deletion of configuration
nodes that don't exist anymore instead of logging an error and
rejecting the changes. This is necessary because Sysrepo delivers
delete notifications for all nodes of a deleted data tree instead
of delivering a single delete notification of the top-level subtree
node (which would suffice for the northbound layer).

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2020-09-15 15:56:53 -03:00
Renato Westphal
88e635ee63 lib: postpone the sysrepo plugin initialization
From Sysrepo's documentation:
"Note: do not use fork() after creating a connection. Sysrepo
internally stores PID of every created connection and this way a
mismatch of PID and connection is created".

Introduce a new "frr_very_late_init" hook in libfrr that is only
called after the daemon is forked (when the '-d' option is used)
and after the configuration is read. This way we can initialize
the sysrepo plugin correctly even when the daemon is daemonized,
and after the Sysrepo CLI commands are processed (only "debug
northbound client sysrepo" for now).

Fixes #7062

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2020-09-15 15:55:55 -03:00
Mark Stapp
cfa2115d02
Merge pull request #7093 from donaldsharp/pbr_flapping
Pbr flapping
2020-09-14 08:13:48 -04:00
Donald Sharp
43373bea5a
Merge pull request #7091 from opensourcerouting/nb-leafrefs
lib: fix crashes with leafrefs that point to non-implemented modules
2020-09-12 09:29:33 -04:00
Donald Sharp
58a1d24924 bgpd, lib, pbrd, zebra: Pass by ifname
When installing rules pass by the interface name across
zapi.

This is being changed because we have a situation where
if you quickly create/destroy ephermeal interfaces under
linux the upper level protocol may be trying to add
a rule for a interface that does not quite exist
at the moment.  Since ip rules actually want the
interface name ( to handle just this sort of situation )
convert over to passing the interface name and storing
it and using it in zebra.

Ticket: CM-31042
Signed-off-by: Stephen Worley <sworley@nvidia.com>
Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2020-09-11 20:04:45 -04:00
Renato Westphal
beb91114ec
Merge pull request #6789 from volta-networks/feat_ldp_igp_sync
ldpd: Add support for LDP-IGP Synchronization
2020-09-11 15:55:04 -03:00
Renato Westphal
8a923b4851 lib: better support for nested YANG augmentations
Change the way the YANG schema node iteration functions work so that
the northbound layer won't have issues with more complex YANG modules
that contain multiple levels of YANG augmentations or modules that
augment themselves indirectly (by augmenting groupings).

Summary of the changes:
* Change the yang_snodes_iterate_subtree() function to always follow
  augmentations and add an optional "module" parameter to narrow down
  the iteration to nodes of a single module (which is necessary in
  some cases). Also, remove the YANG_ITER_ALLOW_AUGMENTATIONS flag
  as it's no longer necessary.
* Change yang_snodes_iterate_all() to do a DFS iteration on the resolved
  YANG data hierarchy instead of iterating over each module and their
  augmentations sequentially.

Reported-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2020-09-11 15:46:40 -03:00
Renato Westphal
f267201bf5 lib: fix crashes with leafrefs that point to non-implemented modules
Whenever libyang loads a module that contains a leafref, it will
also implicitly load the module of the referring node if it's
not loaded already. That makes sense as otherwise it wouldn't be
possible to validate the leafref value correctly.

The problem is that loading a module implicitly violates the
assumption of the northbound layer that all loaded modules
are implemented (i.e. they have a northbound node associated
to each schema node). This means that loading a module that
isn't implemented can lead to crashes as the "priv" pointer
of schema nodes is no longer guaranteed to be valid. To fix this
problem, add a few null checks to ignore data nodes associated
to non-implemented modules.

The side effect of this change is harmless. If a daemon receives
configuration it doesn't support (e.g. BFD peers on staticd),
that configuration will be stored but otherwise ignored. This can
only happen when using a northbound client like gRPC, as the CLI
will never send to a daemon a command it doesn't support. This
minor problem should go away in the long run as FRR migrates to
a centralized management model, at which point the YANG-modeled
configuration of all daemons will be maintained in a single place.

Finally, update some daemons to stop implementing YANG modules
they don't need to (i.e. revert 1b741a01c and a74b47f5).

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2020-09-11 14:42:35 -03:00
Philippe Guibert
2961d0601c lib, zebra: reuse and adapt ns_list walk functionality
the walk routine is used by vxlan service to identify some contexts in
each specific network namespace, when vrf netns backend is used. that
walk mechanism is extended with some additional paramters to the walk
routine.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2020-09-11 18:26:23 +02:00
David Schweizer
12488d7c8d
lib: fix negating set metric route-map command
Changed negating set metric route-map command to be usable in
conjunction with the affirming command.

Signed-off-by: David Schweizer <dschweizer@opensourcerouting.org>
2020-09-10 09:14:58 +02:00
Renato Westphal
add39cde9d lib: fix the "set metric" route-map command
The "set metric" command wasn't processing metric additions and
subtractions (using + and -) correctly. Fix those problems.

Also, remove the "+metric" and "-metric" options since they don't
work and don't make any sense (they could be interpreted as unitary
increments/decrements but that was never supported).

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2020-09-09 14:53:26 -03:00
Karen Schoener
24e7c5c897 lib: adding support for LDP IGP Sync feature
Signed-off-by: Lynne Morrison <lynne@voltanet.io>
Signed-off-by: Karen Schoener <karen@voltanet.io>
2020-09-09 11:12:02 -04:00
Karen Schoener
e1894ff70f ldpd: Adding support for LDP IGP Synchronization
Signed-off-by: Lynne Morrison <lynne@voltanet.io>
Signed-off-by: Karen Schoener <karen@voltanet.io>
2020-09-09 10:45:41 -04:00
Mark Stapp
000ce30ee5
Merge pull request #7047 from qlyoung/fix-zlog-target-null-deref
lib: fix possible null dereference in zlog
2020-09-08 15:25:08 -04:00
Quentin Young
589b5e4802 lib: fix possible null dereference in zlog
In some cases one or both of the zlog targets in use here can be null,
we need to check for that.

Interestingly it appears we don't crash even when this is the case.
Undefined behavior ftw

Signed-off-by: Quentin Young <qlyoung@nvidia.com>
2020-09-08 11:43:40 -04:00
Renato Westphal
dcdaabcede
Merge pull request #7046 from qlyoung/fix-various-integer-issues
Fix various integer signedness / overflow issues
2020-09-04 22:33:48 -03:00
Renato Westphal
4c13526b07
Merge pull request #6971 from volta-networks/fix_ldp_no_config
ldpd: Fix issue when starting up LDP with no configuration.
2020-09-04 16:39:16 -03:00
lynne
955357174f ldpd: Fix issue when starting up LDP with no configuration.
LDP would mark all routes as learned on a non-ldp interface.  Then
when LDP was configured the labels were not updated correctly.  This
commit fixes issues 6841 and 6842.

Signed-off-by: Lynne Morrison <lynne@voltanet.io>
2020-09-04 09:24:47 -04:00
Quentin Young
06cf2c0c36 lib: add stream_rewind_getp()
stream_forward_getp() cannot be used with negative numbers due to the
size_t argument, we'll end up doing overflow arithmetic.

Signed-off-by: Quentin Young <qlyoung@nvidia.com>
2020-09-03 14:23:54 -04:00
Mark Stapp
f845960b3f lib: remove unused stream_get_data api
Signed-off-by: Mark Stapp <mjs@voltanet.io>
2020-09-03 12:37:55 -04:00
Santosh P K
371ded520b
Merge pull request #6987 from Niral-Networks/acl_fix
lib, ospf : Fix when redist is performed with route-map using access-list
2020-09-03 09:51:21 +05:30
Quentin Young
e6464fdc18 lib: remove overflow arithmetic from hash stats
Signed values get converted to unsigned for addition, so when the value
to adjust a stats variable for hash tables was negative this resulted in
overflow arithmetic, which we generally don't want.

Signed-off-by: Quentin Young <qlyoung@nvidia.com>
2020-09-02 16:54:41 -04:00
Quentin Young
e117b7c528 lib: explicitly cast -1 to uid_t
We should be explicit about what's happening here

Signed-off-by: Quentin Young <qlyoung@nvidia.com>
2020-09-02 16:54:38 -04:00
Donald Sharp
842b9211ac
Merge pull request #6997 from opensourcerouting/cisco-acl-name
lib,yang: allow cisco access lists to use names plus fixes
2020-09-02 08:26:57 -04:00
Russ White
edec686a2a
Merge pull request #7016 from donaldsharp/pbr_vrf_is_burf
Pbr vrf is burf
2020-09-01 10:31:20 -04:00
Renato Westphal
1bd4306909 lib: silence overly verbose CLI warning
When not using the transactional CLI mode, do not display a
warning when a YANG-modeled commmand doesn't perform any effective
configuration change.

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2020-08-31 11:59:54 -03:00
Kaushik
1eb17c771b lib : Fix when redist is performed with route-map using access-list.
1. Added new API for add/delete acl with route map notify.

Co-authored-by: harios <hari@niralnetworks.com>
Signed-off-by: Kaushik <kaushik@niralnetworks.com>
2020-08-31 04:25:10 -07:00
Donald Sharp
e7ff02539c lib: Note old ifindex on shutdown
If we have an interface configured in a daemon on shutdown
store the old ifindex value for retrieval on when it is
possibly recreated.

This is especially important for nexthop groups as that we
had at one point in time the ability to restore the
configuration but it was lost when we started deleting
all deleted interfaces.  We need the nexthop group subsystem
to also mark that it has configured an interface.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2020-08-28 07:51:06 -04:00
Donald Sharp
a251884bff lib: Allow nexthop simple display to take an alternate ifp name
The nexthop_group_write_nexthop_simple function outputs the
interface name, because we've stored the ifindex.  The problem
is that there are ephermeal interfaces in linux that can be
destroyed/recreated.  Allow us to keep that data and do something
a bit smarter to allow show run's and other show commands to continue
to work when the interface is deleted.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2020-08-28 07:51:06 -04:00
Stephen Worley
7992452008 lib: break up show nexthop API a bit for reuse
Not everything cares about the vrf and backup info. Break
up the API to add a simple version to just write gateway/interface
info.

Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
2020-08-27 16:13:48 -04:00
Rafael Zalamena
0ed507dda0 lib: refactory cisco access list net wildcard
Wildcards bits have the opposite representation of a network mask,
example:

192.168.0.0/24 has the following netmask 255.255.0.0 and the wildcard
representation is 0.0.255.255.

To avoid future confusion lets put those definitions into a macro so we
know for sure which form to use.

Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
2020-08-26 12:50:07 -03:00
Donald Sharp
c6d41e93e0
Merge pull request #5799 from pguibert6WIND/flowspec_ipv6
Flowspec ipv6
2020-08-26 08:26:46 -04:00
Rafael Zalamena
070783e693 lib: fix a crash in zebra style access list
When removing an IPv4 prefix configuration the wrong amount of bytes
will be read from `struct prefix_ipv4` from `DEFPY`, so lets use the
proper function for this.

Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
2020-08-25 10:35:46 -03:00
Rafael Zalamena
4204c59a99 lib: remove ambiguous cisco command
When configuring a access list rule with type `any` it is now ambiguous
between cisco and zebra because both have the same syntax, so lets
remove the cisco command to avoid that.

YANG users will not notice this change.

Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
2020-08-25 10:35:46 -03:00
Rafael Zalamena
4859a57e11 lib: fix filter extended address assignment
`nb_cli_enqueue_change` just points to the string values passed in
parameter, so we must use different strings for different function
calls (at least until `nb_cli_apply_changes`).

While here fix a variable name typo/copy paste error on destination host
case.

Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
2020-08-25 10:35:46 -03:00
Rafael Zalamena
59ed102f96 lib: allow cisco typed rules to use names
The restriction was already lift at the YANG model level, now lets
unlock the CLI as well.

Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
2020-08-25 10:35:46 -03:00
Donald Sharp
bcbd5081e7
Merge pull request #6976 from achernavin22/rip_tools_key_chain_reloading
lib, tools: fix reloading of key sub-context in key chains
2020-08-25 07:54:55 -04:00
Russ White
4a61502028
Merge pull request #6962 from mjstapp/fix_zapi_nh_sort
lib: zapi nexthop sort fixes
2020-08-25 07:13:46 -04:00
Renato Westphal
f4c3f7f60f
Merge pull request #6963 from chiragshah6/mdev
*: record northbound transaction based on control flag
2020-08-24 16:22:21 -03:00
Alexander Chernavin
deb95b373f lib, tools: fix reloading of key sub-context in key chains
When you add a key chain in the RIP configuration file and reload the
configurations via the frr-reload.py script, the script will fail and
the key chain will not appear in the running configuration. The reason
is that frr-reload.py doesn't recognize key as a sub-context.

Before this change, keys were generated this way:

    key chain test
     key 2
      key-string 123
     key 3
      key-string 456

With this change, keys will be generated this way:

    key chain test
     key 2
      key-string 123
     exit
     key 3
      key-string 456
     exit

This will allow frr-reload.py to see the key sub-context and correctly
reload them.

Signed-off-by: Alexander Chernavin <achernavin@netgate.com>
2020-08-24 09:54:55 -04:00
Philippe Guibert
4088180002 bgpd, lib: support for flow_label flowspec type
in ipv6 flowspec, a new type is defined to be able to do filtering rules
based on 20 bits flow label field as depicted in [0]. The change include
the decoding by flowspec, and the addition of a new attribute in policy
routing rule, so that the data is ready to be sent to zebra.
The commit also includes a check on fragment option, since dont fragment
bit does not exist in ipv6, the value should always be set to 0,
otherwise the flowspec rule becomes invalid.

[0] https://tools.ietf.org/html/draft-ietf-idr-flow-spec-v6-09

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2020-08-21 13:37:08 +02:00
Philippe Guibert
e4552d667a lib: add family attribute for flowspec prefix structure
to recognize whether a flowspec prefix has been carried out by
ipv4 flowspec or ipv6 flowspec ( actually, the hypothesis is that only
ipv4 flowspec is supported), then a new attribute should contain the
family value: AF_INET or AF_INET6. That value will be further used in
the BGP flowspec code.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2020-08-21 13:37:08 +02:00
Chirag Shah
390a886277 *: record transaction based on control flag
In case of config rollback is enabled,
record northbound transaction based on a control flag.
The actual frr daemons would set the flag to true via
nb_init from frr_init.
This will allow test daemon to bypass recording
transacation to db.

Signed-off-by: Chirag Shah <chirag@nvidia.com>
2020-08-20 14:12:04 -07:00
Mark Stapp
38fd3eda40 lib: zapi nexthop sort fixes
The sorting for zapi nexthops in zapi routes needs to match
the sorting of nexthops done in zebra. Ensure all zapi_nexthop
attributes are included in the sort.

Signed-off-by: Mark Stapp <mjs@voltanet.io>
2020-08-20 14:50:38 -04:00
Chirag Shah
6a7fb29c19 lib: add yang modules to native module list
Signed-off-by: Chirag Shah <chirag@nvidia.com>
2020-08-20 11:46:20 -07:00
Renato Westphal
24ed137c20 lib: adapt plugin to use new Sysrepo version
Sysrepo recently underwent a complete rewrite, where some substantial
architectural changes were made (the most important one being the
extinction of the sysrepod daemon). While most of the existing API
was preserved, quite a few backward-incompatible changes [1] were
introduced (mostly simplifications). This commit adapts our sysrepo
northbound plugin to those API changes in order for it to be compatible
with the latest Sysrepo version.

Additional notes:
* The old Sysrepo version is EOL and not supported anymore.
* The new Sysrepo version requires libyang 1.x.

Closes #6936

[1] https://github.com/sysrepo/sysrepo/blob/devel/CHANGES

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2020-08-20 11:53:46 -03:00
Rafael Zalamena
be8d09f125
Merge pull request #6924 from AnuradhaKaruppiah/mem-fixes
bgpd: fixes for problems found during EVPN fuzzing
2020-08-20 14:12:51 +00:00
Renato Westphal
0d206e9d85
Merge pull request #6945 from qlyoung/nb-more-messages
More gRPC logging + errmsg for no changes
2020-08-19 20:14:05 -03:00
Quentin Young
5bfb669b37 lib: fill nb errmsg when no changes during prep
During the prep phase to apply a northbound commit, if no changes were
detected make sure we fill the error message buffer to explain this.

Signed-off-by: Quentin Young <qlyoung@nvidia.com>
2020-08-19 14:24:32 -04:00
Mark Stapp
cfc0a51f96
Merge pull request #6939 from sworleys/NH-Vrf-Del
lib: fix crash in show nexthop when vrf deleted
2020-08-19 12:15:56 -04:00
Quentin Young
1058646261 lib: add better zlogging to gRPC Commit RPC
Signed-off-by: Quentin Young <qlyoung@nvidia.com>
2020-08-18 16:31:03 -04:00
Stephen Worley
c40e980601 lib: fix crash in show nexthop when vrf deleted
Fix a crash where if we issue a show run after a vrf has been
deleted we would crash here due to not null checking.

Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
2020-08-18 14:54:50 -04:00
Philippe Guibert
b1cc23b2cd zebra, lib: new API to get absolute netns val from relative netns val
when receiving a netlink API for an interface in a namespace, this
interface may come with LINK_NSID value, which means that the interface
has its link in an other namespace. Unfortunately, the link_nsid value
is self to that namespace, and there is a need to know what is its
associated nsid value from the default namespace point of view.
The information collected previously on each namespace, can then be
compared with that value to check if the link belongs to the default
namespace or not.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2020-08-18 09:25:06 -07:00
Philippe Guibert
20f4b2b071 zebra, lib: store relative default ns id in each namespace
to be able to retrieve the network namespace identifier for each
namespace, the ns id is stored in each ns context. For default
namespace, the netns id is the same as that value.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2020-08-18 09:25:06 -07:00
Philippe Guibert
2d4e4d39b7 zebra, lib: add an internal API to get relative default nsid in other ns
as remind, the netns identifiers are local to a namespace. that is to
say that for instance, a vrf <vrfx> will have a netns id value in one
netns, and have an other netns id value in one other netns.
There is a need for zebra daemon to collect some cross information, like
the LINK_NETNSID information from interfaces having link layer in an
other network namespace. For that, it is needed to have a global
overview instead of a relative overview per namespace.
The first brick of this change is an API that sticks to netlink API,
that uses NETNSA_TARGET_NSID. from a given vrf vrfX, and a new vrf
created vrfY, the API returns the value of nsID from vrfX, inside the
new vrf vrfY.
The brick also gets the ns id value of default namespace in each other
namespace. An additional value in ns.h is offered, that permits to
retrieve the default namespace context.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2020-08-18 09:25:06 -07:00
Philippe Guibert
07509878e3 zebra: importation of bgp evpn rt5 from vni with other netns
With vrf-lite mechanisms, it is possible to create layer 3 vnis by
creating a bridge interface in default vr, by creating a vxlan interface
that is attached to that bridge interface, then by moving the vxlan
interface to the wished vrf.
With vrf-netns mechanism, it is slightly different since bridged
interfaces can not be separated in different network namespaces. To make
it work, the setup consists in :
- creating a vxlan interface on default vrf.
- move the vxlan interface to the wished vrf ( with an other netns)
- create a bridge interface in the wished vrf
- attach the vxlan interface to that bridged interface

from that point, if BGP is enabled to advertise vnis in default vrf,
then vxlan interfaces are discovered appropriately in other vrfs,
provided that the link interface still resides in the vrf where l2vpn is
advertised.
to import ipv4 entries from a separate vrf, into the l2vpn, the
configuration of vni in the dedicated vrf + the advertisement of ipv4
entries in bgp vrf will import the entries in the bgp l2vpn.

the modification consists in parsing the vxlan interfaces in all network
namespaces, where the link resides in the same network namespace as the
bgp core instance where bgp l2vpn is enabled.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2020-08-18 09:25:06 -07:00
Quentin Young
4adddf0a29 lib: add STREAM_FORWARD_[GET|ENDP]
Safe stream macros for adjusting buffer pointers

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2020-08-15 08:24:54 -07:00
Renato Westphal
0fe5b904b7 lib: don't ignore error messages generated during the commit apply phase
While a configuration transaction can't be rejected once it reaches
the APPLY phase, we should allow NB callbacks to generate error
or warning messages when a configuration change is being applied.
That should be useful, for example, to return warnings back to
the user informing that the applied configuration has some kind of
inconsistency or is missing something in order to be effectively
activated. The infrastructure for this was already present, but the
northbound layer was ignoring all errors/warnings generated during
the apply/abort phases instead of returning them to the user. This
commit changes that.

In the gRPC plugin, extend the Commit() RPC adding a new
"error_message" field to the response type. This is necessary to
allow errors/warnings to be returned even when the commit operation
succeeds (since grpc::Status::OK doesn't support error messages
like the other status codes).

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2020-08-14 21:37:14 -03:00
Donald Sharp
40ce7a4203
Merge pull request #6889 from opensourcerouting/isisd-assorted-fixes
isisd minor fixes and enhancements
2020-08-14 12:50:03 -04:00
Rafael Zalamena
8bc38cbd9a lib: show prefix error message on command failure
Use `args->errmsg` instead of just `zlog_info` for registering the error
so the users don't need to check their log files.

Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
2020-08-13 19:59:47 -03:00
Donald Sharp
efe57f87de
Merge pull request #6869 from xThaid/zebra_arp
lib, zebra: add support for sending ARP requests
2020-08-13 09:47:52 -04:00
Jakub Urbańczyk
d68e74b41c lib, zebra: add support for sending ARP requests
We can make the Linux kernel send an ARP/NDP request by adding
a neighbour with the 'NUD_INCOMPLETE' state and the 'NTF_USE' flag.

This commit adds new dataplane operation as well as new zapi message
to allow other daemons send ARP/NDP requests.

Signed-off-by: Jakub Urbańczyk <xthaid@gmail.com>
2020-08-12 23:19:58 +02:00
Mark Stapp
ee7d41a437
Merge pull request #6906 from donaldsharp/poll_error
Poll error
2020-08-12 12:23:29 -04:00
Donald Sharp
d142453d6b lib: Properly handle POLLERR from poll()
There are situations where POLLERR will be returned.  But
since we were not handling it.  Thread processing effectively
is turned into an infinite loop, which is bad.

Modify the code so that if we receive a POLLERR we turn it
into a read event to be handled as an error from the handler
function.

This was discovered in pim:

Thread statistics for pimd:
Showing poll FD's for main
--------------------------
Count: 14/1024
	     0 fd:     9 events: 1 revents: 0		mroute_read
	     1 fd:    12 events: 1 revents: 0		vty_accept
	     2 fd:    13 events: 1 revents: 0		vtysh_accept
	     3 fd:    11 events: 1 revents: 0		zclient_read
	     4 fd:    15 events: 1 revents: 0		mroute_read
	     5 fd:    16 events: 1 revents: 0		mroute_read
	     6 fd:    17 events: 1 revents: 0		pim_sock_read
	     7 fd:    19 events: 1 revents: 0		pim_sock_read
	     8 fd:    21 events: 1 revents: 0		pim_igmp_read
	     9 fd:    22 events: 1 revents: 0		pim_sock_read
	    10 fd:    23 events: 1 revents: 0		pim_sock_read
	    11 fd:    20 events: 1 revents: 0		vtysh_read
	    12 fd:    18 events: 1 revents: 0		pim_sock_read
	    13 fd:    24 events: 0 revents: 0

strace was showing this line over and over and over:

poll([{fd=9, events=POLLIN}, {fd=12, events=POLLIN}, {fd=13, events=POLLIN}, {fd=11, events=POLLIN}, {fd=15, events=POLLIN}, {fd=16, events=POLLIN}, {fd=17, events=POLLIN}, {fd=19, events=POLLIN}, {fd=21, events=POLLIN}, {fd=22, events=POLLIN}, {fd=23, events=POLLIN}, {fd=20, events=POLLIN}, {fd=18, events=POLLIN}, {fd=6, events=POLLIN}], 14, 20) = 1 ([{fd=21, revents=POLLERR}])

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2020-08-12 09:49:20 -04:00
Donald Sharp
d279ef571e lib: Fixup comment indentations in thread.c
Somewhere along the way the indentation for comments got
all messed up.  Let's make it follow our standards and
also look right too.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2020-08-12 09:46:44 -04:00
Chirag Shah
47cd223441 lib: yang wrapper for getting empty type
Signed-off-by: Chirag Shah <chirag@cumulusnetworks.com>
2020-08-11 17:06:23 -07:00
Renato Westphal
0f16688138 lib: introduce new list_dup() API
This new function will be used by the upcoming TI-LFA code.

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2020-08-11 20:41:44 -03:00
Russ White
271ac28499
Merge pull request #6783 from opensourcerouting/feature/sr-te
lib, zebra: Add SR-TE policy infrastructure to zebra
2020-08-10 15:31:35 -04:00
Donald Sharp
8e3ac40d2c
Merge pull request #6483 from sylane/router-id-v6
zebra: add IPv6 router-id
2020-08-10 08:39:51 -04:00
Rafael Zalamena
2068453728 lib: fix missing doc string in route map
Add the missing route map doc string for call command.

Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
2020-08-07 14:37:02 -03:00
Donald Sharp
690e4f9dff
Merge pull request #6517 from vishaldhingra/submodule
lib: Add support to load submodules in embedded modules framework
2020-08-07 11:09:25 -04:00
Sebastien Merle
31f937fb43 lib, zebra: Add SR-TE policy infrastructure to zebra
For the sake of Segment Routing (SR) and Traffic Engineering (TE)
Policies there's a need for additional infrastructure within zebra.
The infrastructure in this PR is supposed to manage such policies
in terms of installing binding SIDs and LSPs. Also it is capable of
managing MPLS labels using the label manager, keeping track of
nexthops (for resolving labels) and notifying interested parties about
changes of a policy/LSP state. Further it enables a route map mechanism
for BGP and SR-TE colors such that learned BGP routes can be mapped
onto SR-TE Policies.

This PR does not introduce any usable features by now, it is just
infrastructure for other upcoming PRs which will introduce 'pathd',
a new SR-TE daemon.

Co-authored-by: Renato Westphal <renato@opensourcerouting.org>
Co-authored-by: GalaxyGorilla <sascha@netdef.org>
Signed-off-by: Sebastien Merle <sebastien@netdef.org>
2020-08-07 11:08:49 +02:00
GalaxyGorilla
b112b1abb4 lib: add possibility to search non-recursively for NB node entries
Signed-off-by: GalaxyGorilla <sascha@netdef.org>
2020-08-07 11:08:49 +02:00
Sebastien Merle
598b0dfcc9 lib: add generic struct ipaddr comparison function
Signed-off-by: Sebastien Merle <sebastien@netdef.org>
2020-08-07 11:08:49 +02:00
Rafael Zalamena
084cb75254
Merge pull request #6587 from AnuradhaKaruppiah/evpn-mh-pr-1
EVPN Multihoming part-1
2020-08-06 19:49:14 +00:00
Chirag Shah
532f9f17bc lib: yang afi-safi identityref translation
Add more afi safis in conversion to-from string
to indentityref.

Signed-off-by: Chirag Shah <chirag@cumulusnetworks.com>
2020-08-05 14:47:56 -07:00
Donatas Abraitis
2b42623bd3
Merge pull request #6847 from donaldsharp/time_to_rerun
Time to rerun
2020-08-05 17:34:46 +03:00
Anuradha Karuppiah
2ff12693b1 bgpd, lib: move EVPN route type def to lib and use it in the prefix macros
Use route names instead of route type number in the EVPN prefix
macros.

Signed-off-by: Anuradha Karuppiah <anuradhak@cumulusnetworks.com>
2020-08-05 06:46:13 -07:00
Anuradha Karuppiah
d0f699b505 lib: MAC-IP flags used by zebra and BGP for SYNC route handling
1. BGP informs zebra if a MAC-IP is a SYNC path and if it active on the
ES peer.
2. Zebra sends paths that are "local-inactive" with the proxy flag to
BGP.

Signed-off-by: Anuradha Karuppiah <anuradhak@cumulusnetworks.com>
2020-08-05 06:46:12 -07:00
Donald Sharp
e75e57491b lib, bgpd: Remove unused variable from structure
The `struct evpn_ead_addr` structure had a prefix length
associated with it.  This value was only ever set never
used.  Remove this from our system.  The other
nice thing about this change is that it puts back
the sizeof struct route_node to 192 bytes.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2020-08-05 06:46:12 -07:00
Anuradha Karuppiah
ce5160c081 zebra: Ethernet segment management and support for MAC-ECMP
1. Local ethernet segments are configured in zebra by attaching a
local-es-id and sys-mac to a access interface -
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
!
interface hostbond1
 evpn mh es-id 1
 evpn mh es-sys-mac 00:00:00:00:01:11
!
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
This info is then sent to BGP and used for the generation of EAD-per-ES
routes.

2. Access VLANs associated with an (ES) access port are translated into
ES-EVI objects and sent to BGP. This is used by BGP for the
generation of EAD-EVI routes.

3. Remote ESs are imported by BGP and sent to zebra. A list of VTEPs
is maintained per-remote ES in zebra. This list is used for the creation
of the L2-NHG that is used for forwarding traffic.

4. MAC entries with a non-zero ESI destination use the L2-NHG associated
with the ESI for forwarding traffic over the VxLAN overlay.

Please see zebra_evpn_mh.h for the datastruct organization details.

Signed-off-by: Anuradha Karuppiah <anuradhak@cumulusnetworks.com>
2020-08-05 06:46:12 -07:00
Anuradha Karuppiah
c44ab6f1f3 bgpd: support for Ethernet Segments and Type-1/EAD routes
This is the base patch that brings in support for Type-1 routes.
It includes support for -
- Ethernet Segment (ES) management
- EAD route handling
- MAC-IP (Type-2) routes with a non-zero ESI i.e. Aliasing for
  active-active multihoming
- Initial infra for consistency checking. Consistency checking
  is a fundamental feature for active-active solutions like MLAG.
  We will try to levarage the info in the EAD-ES/EAD-EVI routes to
  detect inconsitencies in access config across VTEPs attached to
  the same Ethernet Segment.

Functionality Overview -
========================
1. Ethernet segments are created in zebra and associated with
access VLANs. zebra sends that info as ES and ES-EVI objects to BGP.
2. BGP advertises EAD-ES and EAD-EVI routes for the locally attached
ethernet segments.
3. Similarly BGP processes EAD-ES and EAD-EVI routes from peers
and translates them into ES-VTEP objects which are then sent to zebra
as remote ESs.
4. Each ES in zebra is associated with a list of active VTEPs which
is then translated into a L2-NHG (nexthop group). This is the ES
"Alias" entry
5. MAC-IP routes with a non-zero ESI use the alias entry created in
(4.) to forward traffic i.e. a MAC-ECMP is done to these remote-ES
destinations.

EAD route management (route table and key) -
============================================
1. Local EAD-ES routes
a. route-table: per-ES route-table
key: {RD=ES-RD, ESI, ET=0xffffffff, VTEP-IP)
b. route-table: per-VNI route-table
Not added
c. route-table: global route-table
key: {RD=ES-RD, ESI, ET=0xffffffff)

2. Remote EAD-ES routes
a. route-table: per-ES route-table
Not added
b. route-table: per-VNI route-table
key: {RD=ES-RD, ESI, ET=0xffffffff, VTEP-IP)
c. route-table: global route-table
key: {RD=ES-RD, ESI, ET=0xffffffff)

3. Local EAD-EVI routes
a. route-table: per-ES route-table
Not added
b. route-table: per-VNI route-table
key: {RD=0, ESI, ET=0, VTEP-IP)
c. route-table: global route-table
key: {RD=L2-VNI-RD, ESI, ET=0)

4. Remote EAD-EVI routes
a. route-table: per-ES route-table
Not added
b. route-table: per-VNI route-table
key: {RD=0, ESI, ET=0, VTEP-IP)
c. route-table: global route-table
key: {RD=L2-VNI-RD, ESI, ET=0)

Please refer to bgp_evpn_mh.h for info on how the data-structures are
organized.

Signed-off-by: Anuradha Karuppiah <anuradhak@cumulusnetworks.com>
2020-08-05 06:46:12 -07:00
Anuradha Karuppiah
0447957e62 lib: timer: move the timer string api to lib
This api was earlier present in the daemon code but as multiple daemons
need it moving it to lib will avoid unnecessary copy-paste.

Signed-off-by: Anuradha Karuppiah <anuradhak@cumulusnetworks.com>
2020-08-05 06:46:12 -07:00
Anuradha Karuppiah
19bfb27486 lib: prefix: Add VTEP-IP to the EAD route prefix
In the global evpn routing table RD is part of the key. However in the
per-VNI routing table the key doesn't include the RD and we need more
than the ESI to distinguish between EAD routes from different VTEPs
attached to the same Ethernet Segment.

This commit also includes other definitions needed for managing an
ESI.

Signed-off-by: Anuradha Karuppiah <anuradhak@cumulusnetworks.com>
2020-08-05 06:46:12 -07:00
Anuradha Karuppiah
5c733b883d lib: allow listnode memory to be managed by the app
In most cases this memory is pre-allocated along with the base element.
Similarly it is stored in the base element to allow efficient del
without lookup (main reason for using DLL vs. SLL).

So (in most cases) there should be no need to manage the element/data
and listnode memories separately.

Signed-off-by: Anuradha Karuppiah <anuradhak@cumulusnetworks.com>
2020-08-05 06:46:12 -07:00
Anuradha Karuppiah
89fbf168c2 lib: bitfield: new macros for bit processing
New macros have been added for the following -
1. to efficiently iterate and execute functions on already set bits
2. to check if a bit is in use
3. to check if a bitfield has been initialized (this is to safetly
handle cases where the bitfield is freed and re-allocated).
4. to check if two bitfields have the same bits set

Signed-off-by: Anuradha Karuppiah <anuradhak@cumulusnetworks.com>
2020-08-05 06:46:12 -07:00
Pat Ruddy
bd23c84036 evpn-netns: Revert PR5077, has been re-worked post-refactor
Revert "zebra: support for macvlan interfaces"

This reverts commit bf69e212fd.

Revert "doc: add some documentation about bgp evpn netns support"

This reverts commit 89b97c33d7.

Revert "zebra: dynamically detect vxlan link interfaces in other netns"

This reverts commit de0ebb2540.

Revert "bgpd: sanity check when updating nexthop from bgp to zebra"

This reverts commit ee9633ed87.

Revert "lib, zebra: reuse and adapt ns_list walk functionality"

This reverts commit c4d466c830.

Revert "zebra: local mac entries populated in correct netnamespace"

This reverts commit 4042454891.

Revert "zebra: when parsing local entry against dad, retrieve config"

This reverts commit 3acc394bc5.

Revert "bgpd: evpn nexthop can be changed by default"

This reverts commit a2342a2412.

Revert "zebra: zvni_map_to_vlan() adaptation for all namespaces"

This reverts commit db81d18647.

Revert "zebra: add ns_id attribute to mac structure"

This reverts commit 388d5b438e.

Revert "zebra: bridge layer2 information records ns_id where bridge is"

This reverts commit b5b453a2d6.

Revert "zebra, lib: new API to get absolute netns val from relative netns val"

This reverts commit b6ebab34f6.

Revert "zebra, lib: store relative default ns id in each namespace"

This reverts commit 9d3555e06c.

Revert "zebra, lib: add an internal API to get relative default nsid in other ns"

This reverts commit 97c9e7533b.

Revert "zebra: map vxlan interface to bridge interface with correct ns id"

This reverts commit 7c990878f2.

Revert "zebra: fdb and neighbor table are read for all zns"

This reverts commit f8ed2c5420.

Revert "zebra: zvni_map_to_svi() adaptation for other network namespaces"

This reverts commit 2a9dccb647.

Revert "zebra: display interface slave type"

This reverts commit fc3141393a.

Revert "zebra: zvni_from_svi() adaptation for other network namespaces"

This reverts commit 6fe516bd4b.

Revert "zebra: importation of bgp evpn rt5 from vni with other netns"

This reverts commit 28254125d0.

Revert "lib, zebra: update interface name at netlink creation"

This reverts commit 1f7a68a2ff.

Signed-off-by: Pat Ruddy <pat@voltanet.io>
2020-08-05 06:46:12 -07:00
Donald Sharp
070d9eb9c8
Merge pull request #6727 from opensourcerouting/nb-cfg-backoff
lib: introduce configuration back-off timer for YANG-modeled commands
2020-08-04 13:54:55 -04:00
Donald Sharp
00aef028f6 lib: Put back applied count for route-maps
The applied count for individual sub sections of route-maps
was lost.  Put it back.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2020-08-04 10:16:14 -04:00
Donald Sharp
680b9b6258 lib: Allow no call WORD
The `no call` cli was not accepting the original CLI as
a quick cut-n-paste.  This fixes that.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2020-08-04 10:16:14 -04:00
Donald Sharp
b34232cf86 lib, tests: Add notation about whether or not a route-map is about to be reprocessed
When you make a change to a route-map or a prefix-list it depends on, note
that the route-map needs to be reprocessed for the change.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2020-08-04 10:16:09 -04:00
Kaushik
92d6f76988 lib,zebra,bgpd: Fix for nexthop as IPv4 mapped IPv6 address
Added a macro to validate the v4 mapped v6 address.
Modified bgp receive & send updates for v4 mapped v6 address as
nexthop and installing it as recursive nexthop in RIB.
Minor change in fpm while sending the routes for nexthop as
v4 mapped v6 address.

Signed-off-by: Kaushik <kaushik@niralnetworks.com>
2020-08-03 23:24:04 -07:00
Renato Westphal
b855e95fd3 lib: introduce configuration back-off timer for YANG-modeled commands
When using the default CLI mode, the northbound layer needs to create
a separate transaction to process each YANG-modeled command since
they are supposed to be applied immediately (there's no candidate
configuration nor the "commit" command like in the transactional
CLI). The problem is that configuration transactions have an overhead
associated to them, in big part because of the use of some heavy
libyang functions like `lyd_validate()` and `lyd_diff()`. As of
now this overhead is substantial and doesn't scale well when large
numbers of transactions need to be performed in sequence.

As an example, loading 50k prefix-lists using a single transaction
takes about 2 seconds on a modern CPU. Loading the same 50k
prefix-lists using 50k transactions can take more than an hour
to complete (which is unacceptable by any standard). To fix this
problem, some heavy optimization work needs to be done on libyang and
on the FRR northbound itself too (e.g. perform partial configuration
diffs whenever possible).  This, however, should be a long term
effort since these optimizations shouldn't be trivial to implement
and we're far from having the performance numbers we need.

In the meanwhile, this commit introduces a simple but efficient
workaround to alleviate the issue. In short, a new back-off timer
was introduced in the CLI to monitor and detect when too many
YANG-modeled commands are being received at the same time. When
a certain threshold is reached (100 YANG-modeled commands within
one second), the northbound starts to group all subsequent commands
into a single large transaction, which allows them to be processed
much faster (e.g. seconds and not hours).  It's essentially a
protection mechanism that creates dynamically-sized transactions
when necessary to prevent performance issues from happening. This
mechanism is enabled both when parsing configuration files and when
reading commands from a terminal.

The downside of this optimization is that, if several YANG-modeled
commands are grouped into the same transaction and at least one of
them fails, the whole transaction is rejected. This is undesirable
since users don't expect transactional behavior when that's not
enabled explicitly. To minimize this issue, the CLI will log all
commands that were rejected whenever that happens, to make the
user aware of what happened and have enough information to fix
the problem. Commands that fail due to parsing errors or CLI-level
validations in general are rejected separately.

Again, this proposed workaround is intended to be temporary. The
goal is to provided a quick fix to issues like #6658 while we work
on better long-term solutions.

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2020-08-03 15:17:03 -03:00
Renato Westphal
ca77b518bd *: introduce DEFPY_YANG & friends
DEFPY_YANG will allow the CLI to identify which commands are
YANG-modeled or not before executing them. This is going to be
useful for the upcoming configuration back-off timer work that
needs to commit pending configuration changes before executing a
command that isn't YANG-modeled.

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2020-08-03 15:17:03 -03:00
Quentin Young
25ee44b522
Merge pull request #6732 from opensourcerouting/printfrr-prep
*: preparations for printfrr coccinelle run
2020-07-29 14:29:34 -04:00
Donald Sharp
93d08879ad
Merge pull request #6769 from opensourcerouting/acl-regress
lib,yang: merge cisco/zebra access list styles
2020-07-29 09:57:39 -04:00
David Lamparter
fd2edd5ac1
Merge pull request #6792 from chiragshah6/pim_dev
*: pim igmp yang registery to appropriate makefile
2020-07-28 15:13:00 +02:00
vdhingra
65de8bc8d0 lib: Add support to load submodules in embedded modules framework
BGP Yang is using sub modules and at present FRR is not processing
submodules in embedded framework yang

Signed-off-by: VishalDhingra <vdhingra@vmware.com>
2020-07-28 00:39:32 -07:00
Renato Westphal
790953a387
Merge pull request #6765 from mjstapp/backup_nhg_netlink
lib,zebra: support multiple backup nexthops
2020-07-27 12:49:36 -03:00
Quentin Young
6df9625212
Merge pull request #6771 from opensourcerouting/netbsd-tls-buf
lib: fix TLS log buffer on NetBSD
2020-07-24 14:53:28 -04:00
Russ White
a90f46738a
Merge pull request #6730 from wesleycoakley/pbrd-dscp-ecn
DSCP / ECN-based PBR Matching
2020-07-23 12:08:38 -04:00
Chirag Shah
b37e4b282d *: pim igmp yang registery to appropriate makefile
Move pim and igmp yang files registery to appropriate makefiles.

In yang directory makefile move under `PIMD`
Remove pimd yang files from library makefile instead move them
to pimd makefile.

Signed-off-by: Chirag Shah <chirag@cumulusnetworks.com>
2020-07-22 23:22:23 -07:00
Quentin Young
9d9adc84c7
Merge pull request #6343 from opensourcerouting/watchfrr-n-20200505
watchfrr: add `-N` and `--netns` options
2020-07-22 12:07:14 -04:00
David Lamparter
33606a1547 watchfrr: add (network) namespace support
This adds -N and --netns options to watchfrr, allowing it to start
daemons with -N and switching network namespaces respectively.

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2020-07-22 12:56:04 +02:00
Quentin Young
65b86778c1
Merge pull request #6711 from GalaxyGorilla/bfd_isis_profiles
Add BFD profiles for IS-IS
2020-07-21 14:45:31 -04:00
Quentin Young
807b454043
Merge pull request #6435 from idryzhov/fix-no-vrf
vtysh: return success from "no vrf" when VRF doesn't exist
2020-07-21 11:48:34 -04:00
David Lamparter
97c8ca8808
Merge pull request #6777 from idryzhov/vtysh-defpy
vtysh: rework DEFPY processing in extract.pl
2020-07-21 13:36:33 +02:00
Igor Ryzhov
dc47ff5c3a vtysh: rework DEFPY processing in extract.pl
Currently, all DEFPY commands are translated into one-liners in
vtysh_cmd.c. After the patch, DEFPY commands are correctly indented just
like DEFUN/ALIAS commands.

Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2020-07-20 18:18:55 +03:00
Mark Stapp
3211b92b8f lib: add a backtrace when stream bounds check fails
Add a backtrace call when the stream code detects a bounds error,
to help with debugging.

Signed-off-by: Mark Stapp <mjs@voltanet.io>
2020-07-20 07:31:49 -04:00
David Lamparter
6a3b431b85 lib: fix TLS log buffer on NetBSD
... this didn't work on NetBSD.  Like, at all.  It returns a positive
error code from posix_fallocate() and then we bang our head against a
brick wall trying to write to the mmap'd buffer.

Signed-off-by: David Lamparter <equinox@diac24.net>
2020-07-20 06:29:06 +02:00
Rafael Zalamena
375d157f0e lib,yang: merge cisco/zebra access list styles
Merge the cisco style access list with zebra's logic so we can mix both
types of rules while keeping the commands.

With this the cisco style limitation of having 'destination-*' only for
specific number ranges no longer exist for users of YANG/northbound (the
CLI still has this limitation).

Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
2020-07-19 15:27:56 -03:00
Mark Stapp
850c85b980 lib: use const in nexthop_level() api
Use const in nexthop_level()

Signed-off-by: Mark Stapp <mjs@voltanet.io>
2020-07-17 13:12:33 -04:00
Mark Stapp
28593bccc2 lib: support multiple backup nexthops in nexthop group cli
Revise the nexthop-group cli to support multiple backups for
a single primary nexthop.

Signed-off-by: Mark Stapp <mjs@voltanet.io>
2020-07-17 13:12:33 -04:00
Mark Stapp
0cac0cf4a7 lib: add nexthop_str2backup
Add an api to convert an input list into an array of backup
nexthop indexes; useful for cli input.

Signed-off-by: Mark Stapp <mjs@voltanet.io>
2020-07-17 13:12:33 -04:00
Mark Stapp
474aebd939 lib,sharpd,zebra: initial support for multiple backup nexthops
Initial changes to support a nexthop with multiple backups. Lib
changes to hold a small array in each primary, zapi message
changes to support sending multiple backups, and daemon
changes to show commands to support multiple backups. The config
input for multiple backup indices is not present here.

Signed-off-by: Mark Stapp <mjs@voltanet.io>
2020-07-17 13:12:33 -04:00
Sebastien Merle
98a3fb0ab9 zebra: add IPv6 router-id
* add a vrf sub-command `[no] ipv6 router-id X:X::X:X`.
 * add command `[no] ipv6 router-id X:X::X:X [vrf NAME]` for backward
   compatibility.
 * add a vrf sub-command `[no] ip router-id A.B.C.D` and make the old
   one without `ip` an alias for it.
 * add a  command `[no] ip router-id A.B.C.D [vrf NAME]` for backward
   comptibility and make the old one without `ip` an alias for it.
 * add command `show ip router-id [vrf NAME]` and make
   the old one without `ip` an alias for it.
 * add command `show ipv6 router-id [vrf NAME]`.
 * add ZAPI commands `ZEBRA_ROUTER_ID_V6_ADD`,
   `ZEBRA_ROUTER_ID_V6_DELETE` and `ZEBRA_ROUTER_ID_V6_UPDATE`
   for deamons to get notified of the IPv6 router-id.
 * update zebra documentation.

Signed-off-by: Sebastien Merle <sebastien@netdef.org>
2020-07-17 17:39:05 +02:00
Mark Stapp
00a9b15005 zebra: include installed backup nexthops in kernel update
Include any installed backups when updating the local kernel
after processing an async notification. This includes routes'
nexthops and LSPs' nhlfes.

Add the 'b' character to the route show display and header to
indicate backup nexthops.

Signed-off-by: Mark Stapp <mjs@voltanet.io>
2020-07-16 14:18:37 -04:00
vdhingra
755100ac89 zebra: Moving afi-safi identity to lib
afi-safi identity handling should be in the common place.

Signed-off-by: VishalDhingra <vdhingra@vmware.com>
2020-07-16 08:40:42 -07:00
vdhingra
88fa5104a0 staticd : Configuration northbound implementation
1. Modifies the data structs to make the distance, tag and table-id
   property of a route, i.e created a hireachical data struct to save
   route and nexthop information.
2. Backend northbound implementation

Signed-off-by: VishalDhingra <vdhingra@vmware.com>
2020-07-16 08:33:00 -07:00
vdhingra
7441ea1afd lib : basic-routing backend configuration northbound code
Signed-off-by: VishalDhingra <vdhingra@vmware.com>
2020-07-16 08:33:00 -07:00
vdhingra
27802d3fee lib : Yang wrappers
1. To get the parent node
2. To auto delete the parent when last node in list gets deleted

Signed-off-by: VishalDhingra <vdhingra@vmware.com>
2020-07-16 08:33:00 -07:00
Donald Sharp
3eb15671ee
Merge pull request #6731 from opensourcerouting/style-string-prep
*: string coding style
2020-07-15 20:06:55 -04:00
Wesley Coakley
01f23affdb pbrd, zebra, lib: DSCP / ECN-based PBR Matching
Extend PBR maps to discriminate by Differentiated Services Code Point and / or
Explicit Congestion Notification fields. These fields are used in the IP header
for classifying network traffic.

      0     1     2     3     4     5     6     7
    +-----+-----+-----+-----+-----+-----+-----+-----+
    |          DS FIELD, DSCP           | ECN FIELD |
    +-----+-----+-----+-----+-----+-----+-----+-----+
      DSCP: differentiated services codepoint
      ECN:  Explicit Congestion Notification

Signed-off-by: Wesley Coakley <wcoakley@nvidia.com>
Signed-off-by: Saurav Kumar Paul <saurav@cumulusnetworks.com>
2020-07-15 12:59:36 -04:00
Russ White
9a4dee5c35
Merge pull request #6736 from NaveenThanikachalam/rmap_noop
libfrr: Retain return value if the best index is found
2020-07-15 10:51:41 -04:00
Quentin Young
1d4cfa5de1 Revert "Rpki Encapsulation"
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2020-07-14 15:38:20 -04:00
Naveen Thanikachalam
1410dd3f1b libfrr: Retain ret value if the best idx is found
While iteratively looking for a best match route-map index amongst
a list of potential best match route-map indices, if a candidate
best match index is already found, disregard the value returned by
the function route_map_apply_match() if it returns either RMAP_NOOP
or RMAP_NOMATCH in the following iterations.
This is because if a best match route-map index is found then, the
return value must always be set to RMAP_MATCH.

Signed-off-by: NaveenThanikachalam <nthanikachal@vmware.com>
2020-07-14 09:28:38 -07:00
Quentin Young
1f30402b92
Merge pull request #5015 from pguibert6WIND/rpki_vrf_encapsulation
Rpki Encapsulation
2020-07-14 11:52:47 -04:00
David Lamparter
bd0ab4d80a lib: add %pEA for struct ethaddr *
Signed-off-by: David Lamparter <equinox@diac24.net>
2020-07-14 11:15:57 +02:00
David Lamparter
02f686fff8 lib: add %pSU for union sockunion *
Signed-off-by: David Lamparter <equinox@diac24.net>
2020-07-14 11:15:53 +02:00
David Lamparter
dc5d018631 lib: add %pIA for struct ipaddr *
Signed-off-by: David Lamparter <equinox@diac24.net>
2020-07-14 11:15:47 +02:00
David Lamparter
713de9e394 lib/ipaddr: match constants to AF_*
No reason not to do this really.

Signed-off-by: David Lamparter <equinox@diac24.net>
2020-07-14 11:05:45 +02:00
David Lamparter
6cde4b4552 *: remove PRI[udx](8|16|32)
These are completely pointless and break coccinelle string replacements.

Scripted commit, idempotent to running:
```
python3 tools/stringmangle.py --pri8-16-32 `git ls-files | egrep '\.[ch]$'`
```

Signed-off-by: David Lamparter <equinox@diac24.net>
2020-07-14 10:43:40 +02:00
David Lamparter
3efd0893d0 *: un-split strings across lines
Remove mid-string line breaks, cf. workflow doc:

  .. [#tool_style_conflicts] For example, lines over 80 characters are allowed
     for text strings to make it possible to search the code for them: please
     see `Linux kernel style (breaking long lines and strings)
     <https://www.kernel.org/doc/html/v4.10/process/coding-style.html#breaking-long-lines-and-strings>`_
     and `Issue #1794 <https://github.com/FRRouting/frr/issues/1794>`_.

Scripted commit, idempotent to running:
```
python3 tools/stringmangle.py --unwrap `git ls-files | egrep '\.[ch]$'`
```

Signed-off-by: David Lamparter <equinox@diac24.net>
2020-07-14 10:37:25 +02:00
Quentin Young
6deb3954ff
Merge pull request #5301 from idryzhov/show-interface
[RFC] zebra: remove vrf parameter from "show interface ..." commands
2020-07-13 11:23:53 -04:00
Quentin Young
80fa508153
Merge pull request #6704 from mjstapp/pthread_block_signals
lib: block signals in child pthreads
2020-07-13 11:09:46 -04:00
Donald Sharp
373edbbc99
Merge pull request #6530 from mjstapp/backup_nhg_notify
lib, zebra: async notifications for backup routes and LSPs
2020-07-10 10:54:59 -04:00
GalaxyGorilla
bb99eb5df3 isisd: lib: refactor ISIS BFD API
Use `zclient_bfd_command` instead of `bfd_peer_sendmsg`.

Signed-off-by: GalaxyGorilla <sascha@netdef.org>
2020-07-10 12:51:04 +00:00
Donald Sharp
f24db7598e
Merge pull request #6403 from NaveenThanikachalam/FRR_RMAP_FIX
lib: Fix erroneous r-map behavior
2020-07-10 08:07:04 -04:00
GalaxyGorilla
4affdba79e *: add BFD profile support for IS-IS
BFD profiles can now be used on the interface level like this:

	interface eth1
	  ip router isis 1
          isis bfd
          isis bfd profile default

Here the 'default' profile needs to be specified as usual in the
bfdd configuration.

Signed-off-by: GalaxyGorilla <sascha@netdef.org>
2020-07-10 11:28:43 +00:00
Igor Ryzhov
cd980d0375 vtysh: return success from "no vrf" when VRF doesn't exist
It is possible that the same VRF exists in one daemon and doesn't exist
in another. In this case, "no vrf NAME" command execution will stop on
the first daemon without the VRF and it won't be possible to delete the
VRF from other daemons.

Such behavior can be reproduced with the following steps:
```
# ip link add test type vrf table 1
# vtysh -c "conf t" -c "vrf test" -c "ip route 1.1.1.1/32 blackhole"
# vtysh -c "show run"
...
vrf test
 ip route 1.1.1.1/32 blackhole
 exit-vrf
!
...
# ip link del test
# vtysh -c "conf t" -c "no vrf test"
% VRF test does not exist
# vtysh -c "show run"
...
vrf test
 ip route 1.1.1.1/32 blackhole
 exit-vrf
!
...
```

This commit fixes the issue by returning success from "no vrf" command
when VRF doesn't exist.

Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2020-07-09 19:20:32 +03:00
Mark Stapp
f4635e33a6 lib: block signals in child pthreads
Block signals in child/additional pthreads; frr daemons generally
expect that only the main thread will handle signals.

Signed-off-by: Mark Stapp <mjs@voltanet.io>
2020-07-09 11:21:10 -04:00
Mark Stapp
0e8542eef3 lib: test vrfs in nexthop_same_firsthop()
Test the two nexthops' vrfs, and convert api to 'bool' return.

Signed-off-by: Mark Stapp <mjs@voltanet.io>
2020-07-07 13:14:01 -04:00
Rafael Zalamena
f095133583 lib: fix route map description memory leak
Route map entries are not getting a chance to call `description` string
deallocation on shutdown or when the parent entry is destroyed, so lets
add a code to handle this in the `route_map_index_delete` function.

Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
2020-07-06 13:14:41 -03:00
Donald Sharp
7799deeed6
Merge pull request #6437 from opensourcerouting/bfd-profiles-bgp
bfdd,bgpd: profiles integration support
2020-07-02 12:22:44 -04:00
Philippe Guibert
4a42034fa8 bgpd: duplicate config commands into rpki-vrf subnode
rpki vrf subnode is instantiated under the vrf subnode.
It it to be noted that this commit contains a change in vtysh.
Actually, the output of bgp daemon from show running-config is extracted
in vtysh, and reengineered ( hence the vtysh_config.c change done). This
permits having a subnode under vrf sub node.
Also, add vrf node support to bgpd, as rpki command can not be found
under vrf node.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2020-07-02 08:17:51 +02:00
Wesley Coakley
20953065ff pbrd, lib: remember to free alloc'd qobj on delete
Signed-off-by: Wesley Coakley <wcoakley@nvidia.com>
2020-07-01 13:10:53 -04:00
Russ White
2fb1599f65
Merge pull request #6627 from qlyoung/clarify-prefix-bit-usage
lib: clarify usage of prefix_bit function
2020-06-23 10:39:03 -04:00
Quentin Young
adeb067232 lib: clarify usage of prefix_bit function
"prefixlen" is really a bit index

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2020-06-22 13:59:01 -04:00
Emanuele Di Pascale
741b1c4f10 lib: fix STREAM_GETF macro
a missing '!' operator was making any STREAM_GETF fail
when in fact it should have succeeded. As a consequence
of this, for example, many link-params of an interface
were not being read and populated.

Signed-off-by: Emanuele Di Pascale <emanuele@voltanet.io>
2020-06-22 19:04:06 +02:00
Igor Ryzhov
a2719d0e88 zebra: show interfaces from all VRFs in "show interface ..." commands
Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2020-06-22 10:09:35 +03:00
Jafar Al-Gharaibeh
e063f27136 build: Allow removal of build configs from version string
A new config option `--disable-version-build-config`
allows you to show short version string by dropping
"configured with:" and all of its build configs

Signed-off-by: Jafar Al-Gharaibeh <jafar@atcorp.com>
2020-06-19 11:15:43 -05:00
Donald Sharp
8dc1d92588
Merge pull request #6615 from opensourcerouting/build-assorted-20200619
build: assorted fixes (protobuf, frr-format)
2020-06-19 06:18:20 -04:00
David Lamparter
a26305a8ba build: fix frr-format warnings
Unfortunately, the way the frr-format plugin is set up, snprintf() with
PRId64 can generate false warnings :|.  Easy workaround is to use
snprintfrr().

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2020-06-19 01:09:10 +02:00
Mark Stapp
2be4d61a86 sharpd: add zclient session create and delete
Add a couple of clis and some simple support that allows sharpd to
create extra zapi client sessions.

Signed-off-by: Mark Stapp <mjs@voltanet.io>
2020-06-16 12:24:24 -04:00
streambinder
132b6a9139 lib: prefix: add prefix_rd type
Signed-off-by: streambinder <posta@davidepucci.it>
2020-06-15 15:34:49 +02:00
Rafael Zalamena
6a6b103657 lib: permit BFD library users to pass NULL
Add the proper handling for cases where user forgets or doesn't have the
pointer needed to call the library function.

Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
2020-06-12 14:25:53 -03:00
Mark Stapp
d617669d37 lib: don't try to change/reset capabilities if process has none
A couple of daemons take/use no capabilities/privs; allow cleanup
of the privs/capabilities library module even if a daemon has no
caps.

Signed-off-by: Mark Stapp <mjs@voltanet.io>
2020-06-11 15:31:54 -04:00
Mark Stapp
41b21bfa60 *: have daemons call frr_fini() at termination
Fix a number of library and daemon issues so that daemons can
call frr_fini() during normal termination. Without this,
temporary logging files are left behind in /var/tmp/frr/.

Signed-off-by: Mark Stapp <mjs@voltanet.io>
2020-06-11 15:31:54 -04:00
Donald Sharp
70cf5c6b04
Merge pull request #6557 from opensourcerouting/zlogbuf-litter
lib: set up TLS log buffer after forking
2020-06-10 18:59:25 -04:00
Renato Westphal
1821018078
Merge pull request #6542 from mjstapp/zebra_opaque_unicast
Zebra opaque unicast messages
2020-06-10 19:06:16 -03:00
David Lamparter
e2be26436a lib: set up TLS log buffer after forking
... it contains our pid, so doing it before fork leads to littering
buffers since we try to clean up with the forked pid...

Fixes: #6541
Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2020-06-10 20:30:02 +02:00
Santosh P K
57dd2f0097
Merge pull request #6414 from opensourcerouting/nb-error-handling
NB context + enhanced error handling
2020-06-10 22:47:07 +05:30
Mark Stapp
478ff17be6 lib,sharpd: add a SHARP_STR alias
Add a vty-friendly protocol name alias for sharpd.

Signed-off-by: Mark Stapp <mjs@voltanet.io>
2020-06-10 08:26:27 -04:00
Mark Stapp
387831ffc3 lib,zebra,sharpd: modify opaque zapi message to support unicast
Start modifying the OPAQUE zapi message to include optional
unicast destination zapi client info. Add a 'decode' api and
opaque msg struct to encapsulate that optional info.

Signed-off-by: Mark Stapp <mjs@voltanet.io>
2020-06-10 08:26:27 -04:00
Mark Stapp
d2ddc1416b lib,zebra: rename opaque decode api
Change name of an opaque zapi api to 'decode' to align with the
other zapi message parsing apis. Missed that in the original
opaque commits.

Signed-off-by: Mark Stapp <mjs@voltanet.io>
2020-06-10 08:16:10 -04:00
Donald Sharp
2d8c1bc235
Merge pull request #5323 from opensourcerouting/filter-nb
lib: migrate FRR filter to northbound
2020-06-10 06:59:32 -04:00
Donatas Abraitis
c415a4dcd4 lib: Make sure route_map_dep_data is not NULL before decrementing refcount
```
2  0x00007fb9adb07a10 in core_handler (signo=11, siginfo=0x7ffe1414a630, context=<optimized out>) at lib/sigevent.c:228
        sa_default = {__sigaction_handler = {sa_handler = 0x0, sa_sigaction = 0x0}, sa_mask = {__val = {0 <repeats 16 times>}}, sa_flags = 0, sa_restorer = 0x0}
        sigset = {__val = {8192, 0 <repeats 15 times>}}
3  <signal handler called>
No locals.
4  route_map_dep_update (type=RMAP_EVENT_CLIST_DELETED, rmap_name=0x55d807ddd410 "export4-as49917", dep_name=<optimized out>, dephash=0x55d807adf170) at lib/routemap.c:2750
        dep = 0x55d807d35b00
        dname = 0x55d8081ba560 "123:124"
        rname = 0x55d8081ba540 "export4-as49917"
        ret = 0
        dep_data = 0x0
        ret_dep_data = 0x0
        tmp_dep_data = {rname = 0x55d8081ba540 "export4-as49917", refcnt = 0}
5  route_map_upd8_dependency (type=RMAP_EVENT_CLIST_DELETED, arg=<optimized out>, rmap_name=0x55d807ddd410 "export4-as49917") at lib/routemap.c:2865
        upd8_hash = 0x55d807adf170
```

Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
2020-06-08 16:15:43 +03:00
Renato Westphal
7f4985f6e3
Merge pull request #6516 from qlyoung/fix-northbound-userdata-disappearance
lib: move all userdata when changing node xpath
2020-06-05 20:00:38 -03:00
Rafael Zalamena
49e3e49d72 lib: use relative XPath to filter entry attributes
We can avoid a big amount of `snprintf` by using relative XPath in
`nb_cli_apply_changes`.

Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
2020-06-05 16:42:16 -03:00
Rafael Zalamena
84fdeb2015 lib: filter remove extra CLI transaction
`acl_get_seq` should be able to get the sequence number from candidate
configuration without needing to commit anything midway.

Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
2020-06-05 16:42:16 -03:00
Rafael Zalamena
664ae7953a lib: filter remove unused variable
Remove variable that is not being used.

Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
2020-06-05 16:42:16 -03:00
Rafael Zalamena
a247b2b738 lib: remove filter northbound wrapper functions
Lets just use them directly to avoid extra code and to be extra clear
that we are using those callbacks.

Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
2020-06-05 16:42:16 -03:00
Rafael Zalamena
5ba66296f7 lib: don't set NULL after an XFREE
Avoid two assignment operations by just letting XFREE do its thing.

Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
2020-06-05 16:42:16 -03:00
Rafael Zalamena
be96651c93 lib: add YANG model enumerations for filter
Avoid magic numbers by using enumerations.

Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
2020-06-05 16:42:11 -03:00
Rafael Zalamena
019f8325a5 lib: implement legacy prefix list behaviour
Some tests expect that a prefix list structure is gone after all its
entries are removed, so lets keep that behaviour.

NOTE: users using YANG/northbound directly without CLI won't be
affected.

Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
2020-06-05 14:36:54 -03:00