Commit Graph

4978 Commits

Author SHA1 Message Date
Yash Ranjan
f71ed6df3e ospf6d: "clear ipv6 ospf6 process" command
Adding the "clear ipv6 ospf6 command" . It resets
the ospfv3 datastructures and clears the database
as well as route tables. It resets the neighborship
by restarting the interface state machine.
If the user wants to change the router-id, this
command updates the router-id to the latest static
router-id and starts the neighbor formation with
the new router-id.

Signed-off-by: Yash Ranjan <ranjany@vmware.com>
2021-06-27 20:56:10 -07:00
Donald Lee
19eee398d4 lib: add comments for functions
Signed-off-by: Donald Lee <dlqs@gmx.com>
2021-06-25 17:29:15 +08:00
Donald Sharp
c81d78cf1c lib: Add some hash name differentiation for Command Hash's
Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2021-06-24 10:51:34 -04:00
David Lamparter
13f9aea383 build: add -Werror to xrelfo log format warnings
Adding a `\n' should now produce a warning.  Controlled by `-Werror` so
if you're doing a dev build and it's warning about some `prefix2str`
that should be converted to `%pFX`, you can turn off `-Werror` to fix it
later like with all other warnings.

Signed-off-by: David Lamparter <equinox@diac24.net>
2021-06-24 16:42:59 +02:00
David Lamparter
6418e2d342 lib: try CLOCK_THREAD_CPUTIME_ID
This might be faster if at some point in the future the Linux vDSO
supports CLOCK_THREAD_CPUTIME_ID without making a syscall.  (Same
applies for other OSes.)

Signed-off-by: David Lamparter <equinox@diac24.net>
2021-06-24 16:42:59 +02:00
David Lamparter
45f0118832 lib: make cputime checks runtime options (v2)
...really no reason to force this into a compile time decision.  The
only point is avoiding the getrusage() syscall, which can easily be a
runtime decision.

[v2: also split cputime & walltime limits]

Signed-off-by: David Lamparter <equinox@diac24.net>
2021-06-24 16:42:59 +02:00
Donald Sharp
2afd15f5c6
Merge pull request #8656 from opensourcerouting/xref-5424-prep-2
lib: preparations for RFC5424 syslog support
2021-06-23 06:08:41 -04:00
Patrick Ruddy
fa855f8fa3
Merge pull request #6695 from adharkar/frr-master-gateway_ip
EVPN route type-5 gateway IP overlay Index
2021-06-23 09:23:54 +01:00
Donald Lee
62510c0948 lib: use in6addr comparator in test
Signed-off-by: Donald Lee <dlqs@gmx.com>
2021-06-23 00:58:04 +08:00
Donald Lee
8192b47173 lib: Pop tables off Lua stack when decoding
Signed-off-by: Donald Lee <dlqs@gmx.com>
2021-06-23 00:58:04 +08:00
Donald Lee
81fde499e5 lib: Use noop decoder for bgp_script values
Signed-off-by: Donald Lee <dlqs@gmx.com>
2021-06-22 05:08:25 +08:00
Donald Lee
7e058da5bc lib: Add lua noop decoder
Use this noop decoder for const values (since we can't mutate a const
value passed into frrscript_call anyways) or values we don't want to
write a decoder for.

Signed-off-by: Donald Lee <dlqs@gmx.com>
2021-06-22 05:03:12 +08:00
Donald Lee
b7da61c1d1 bgpd: Update bgp_script encoders and decoders
This is an example of creating encoders and decoders for user defined
structs and registering them in the ENCODE_ARGS DECODE_ARGS macro
in frrscript.

Signed-off-by: Donald Lee <dlqs@gmx.com>
2021-06-22 05:03:07 +08:00
Donald Lee
bdc1085d7b lib: Update script SCRIPT command
Can now test out script by modifying a prefix

Signed-off-by: Donald Lee <dlqs@gmx.com>
2021-06-22 05:02:12 +08:00
Donald Lee
3a3cfe4762 lib: Add decoder functions
Split existing lua_to* functions into two functions:
 - lua_decode_*: unmarshall Lua values into an existing C data structure
 - lua_to*: allocate *and* unmarshall Lua values into C data structure
This allows us to mutate C data structures passed into frrscript_call,
without allocation

Signed-off-by: Donald Lee <dlqs@gmx.com>
2021-06-22 05:02:03 +08:00
Donald Lee
c2642aab24 lib: Add basic encoders
Signed-off-by: Donald Lee <dlqs@gmx.com>
2021-06-22 04:55:19 +08:00
Donald Lee
43a5106d42 lib: make frrscript_call encode args based on type
Signed-off-by: Donald Lee <dlqs@gmx.com>
2021-06-22 04:51:22 +08:00
Donald Lee
249cd5daa7 lib: Add MAP_LIST macro
Signed-off-by: Donald Lee <dlqs@gmx.com>
2021-06-22 04:46:16 +08:00
Igor Ryzhov
f5eef2d5a8 lib: remove vrf-interface config when removing the VRF
If we have the following configuration:
```
vrf red
 smth
 exit-vrf
!
interface red vrf red
 smth
```
And we delete the VRF using "no vrf red" command, we end up with:
```
interface red
 smth
```
Interface config is preserved but moved to the default VRF.

This is not an expected behavior. We should remove the interface config
when the VRF is deleted.

Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2021-06-21 18:04:46 +03:00
Renato Westphal
2f0884023a
Merge pull request #8749 from pjdruddy/bitfield_mtype
lib: add an MTYPE for bitfields
2021-06-19 12:16:48 -03:00
Renato Westphal
1e810976e2
Merge pull request #8864 from idryzhov/fix-vtysh-vrf-change
lib: fix interface configuration after vrf change
2021-06-19 12:15:40 -03:00
David Lamparter
ca4849b374
Merge pull request #8876 from idryzhov/remove-pure
lib: remove pure attribute from functions that modify memory
2021-06-19 14:32:43 +02:00
David Lamparter
ca846ff82c lib: fix printf format on NetBSD
*sigh*.  It doesn't accept `%m` otherwise.

Signed-off-by: David Lamparter <equinox@diac24.net>
2021-06-18 21:05:21 +02:00
David Lamparter
c6610ea98f lib: make a few log symbols accessible
Might've made a few things too many `static` there.

Signed-off-by: David Lamparter <equinox@diac24.net>
2021-06-18 21:05:21 +02:00
David Lamparter
5c58f5d336 lib: save instance number in zlog
Signed-off-by: David Lamparter <equinox@diac24.net>
2021-06-18 21:05:21 +02:00
David Lamparter
78598fd019 lib: cache PID & TID in zlog code
glibc removed its pid cache a while back, and grabbing this from TLS is
faster than repeatedly calling the kernel...

Also use `intmax_t` which is more appropriate for both PID & TID.

Signed-off-by: David Lamparter <equinox@diac24.net>
2021-06-18 21:05:21 +02:00
David Lamparter
8b94cb4388 lib: include \n in zlog_msg_text()
Since the file targets append one anyway, save them some extra work.
syslog can use `%.*s` since it's "forced" printf by API anyway.

Signed-off-by: David Lamparter <equinox@diac24.net>
2021-06-18 21:05:21 +02:00
David Lamparter
243ff228a9 lib: add RFC3164 logging timestamps
This is old-style syslog, used among other things for /dev/log.

Signed-off-by: David Lamparter <equinox@diac24.net>
2021-06-18 21:05:21 +02:00
David Lamparter
f6caaa6524 lib: use fbuf for zlog_msg_ts()
Signed-off-by: David Lamparter <equinox@diac24.net>
2021-06-18 21:05:21 +02:00
David Lamparter
e3daa82c18 lib: record output argument positions in zlog
printfrr() recently acquired the capability to record start/end of
formatting outputs.  Make use of this in the zlog code so logging
targets have access to this information.

(This also records how long the `[XXXXX-XXXXX][EC 9999999]` prefix was
so log targets can choose to skip over it.)

Signed-off-by: David Lamparter <equinox@diac24.net>
2021-06-18 20:56:53 +02:00
David Lamparter
ba9256d2d0 lib: add hook for show logging CLI
... so additional targets can print their state.

Signed-off-by: David Lamparter <equinox@diac24.net>
2021-06-18 20:56:53 +02:00
David Lamparter
9c2aa91921 lib: de-conflict log-filter CLI command
`log-filter WORD` was giving me a serious headache since it also matches
`log WORD` due to the way the CLI token handling works.  This meant that
a mistyped `log something` command would silently be interpreted as a
filter string, causing me serious headscratching and WTFs until I
figured what was going on.

Remove this UX pitfall so noone else falls into it.  (Since the command
was never saved to config, renaming it shouldn't cause trouble.)

[Also I apparently forgot to update the docs when I transferred this
over to the new zlog bits...]

TODO for a rainy day:  since we collect all the CLI commands anyway, we
should warn somewhere for "2nd level ambiguous" commands like this.

Signed-off-by: David Lamparter <equinox@diac24.net>
2021-06-18 20:56:53 +02:00
Igor Ryzhov
4f08c715db lib: remove pure attribute from functions that modify memory
Almost all functions currently marked with pure attribute acquire a
route_node lock. By marking them pure we allow compiler to optimize the
code and not call them when it already knows the return value. This is
completely incorrect.

Only two of eleven functions can be marked as pure. And they still won't
be optimized because they are never called from the same function twice.
Let's remove the ext_pure macro completely to reduce the chance of
repeating this mistake in the future.

Fixes #8866, #8809, #8595, #6992.

Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2021-06-18 19:54:40 +03:00
Donald Sharp
d7193080af
Merge pull request #8478 from mjstapp/fix_nb_grpc_shutdown
lib: stop grpc pthread at shutdown
2021-06-18 08:52:44 -04:00
Pat Ruddy
0e2deb5878 lib: add an MTYPE for bitfields
it is handy to be able to see allocated bitfields in the show
memory output.

Signed-off-by: Pat Ruddy <pat@voltanet.io>
2021-06-18 09:34:43 +01:00
Igor Ryzhov
763725cd5e lib: fix interface configuration after vrf change
This commit fixes the following problem:

- enter the interface node
- move the interface to another VRF
- try to continue configuring the interface

It is not possible to continue configuration because the XPath stored in
the vty doesn't correspond with the actual state of the system anymore.

For example:
```
nfware# conf
nfware(config)# interface enp2s0

<-- move the enp2s0 to a different VRF -->

nfware(config-if)# ip router isis 1
% Failed to get iface dnode in candidate DB
```

To fix the issue, go through all connected vty shells and update the
stored XPath.

Suggested-by: Renato Westphal <renato@opensourcerouting.org>
Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2021-06-18 03:27:46 +03:00
Donatas Abraitis
aa6fe908f3 lib: Do not double-assign freed pointer to NULL
It's already done by XFREE.

Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
2021-06-17 10:14:38 +03:00
Mark Stapp
de800c10af lib: cleanup and stop grpc pthread
At shutdown, try to stop the grpc module and its
dedicated pthread cleanly.

Signed-off-by: Mark Stapp <mjs@voltanet.io>
2021-06-15 11:08:19 -04:00
Igor Ryzhov
f9fa6ee74c
Merge pull request #8838 from LabNConsulting/chopps/fix-nb-edit-cli
lib: do not attempt to create default nodes from NULL tree node
2021-06-15 12:18:29 +03:00
Christian Hopps
4da08e016b
lib: do not attempt to create default nodes from NULL tree node
Perform same NULL check for dependent node creation code too.

Signed-off-by: Christian Hopps <chopps@labn.net>
2021-06-12 09:10:18 +00:00
Stephen Worley
ea0d70b1c4 lib: terminate default vrf last
Always terminate default VRF last during FRR shutdown.

On shutdown we were simply looping over the RB tree and terminating
VRFs from the ROOT. This is not guaranteed to be the default last ever.

Instead switch to RB_SAFE and skip the default VRF till the very end.

Signed-off-by: Stephen Worley <sworley@nvidia.com>
2021-06-11 11:48:23 -04:00
Donald Sharp
6dbaa012be
Merge pull request #8807 from mjstapp/fix_srv6_delete
lib,zebra: srv6 cleanup
2021-06-09 09:07:53 -04:00
Olivier Dugeon
3898a4522f
Merge pull request #8798 from opensourcerouting/ospfd-fixes
ospfd: assorted fixes
2021-06-09 09:06:42 +02:00
Quentin Young
fdb7f5d54f
Merge pull request #8593 from idryzhov/cmd-ambiguous
vtysh: fix searching commands in parent nodes
2021-06-08 15:41:45 +00:00
Renato Westphal
461d106dae lib, ospfd, ospf6d: fix logging of pointer addresses
The %p printf format specifier does already print the pointer address
with a leading "0x" prefix (indicating a hexadecimal number). There's
no need to add that prefix manually.

While here, replace explicit function names in log messages by
__func__.

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2021-06-08 11:50:44 -03:00
Quentin Young
7b450535c9
Merge pull request #8713 from LabNConsulting/chopps/grpc-unit-test 2021-06-08 14:00:10 +00:00
Ameya Dharkar
d0a4ee6010 bgpd: Add "set evpn gateway-ip" clause for route-map
- Add following set clause for route-maps
  "set evpn gateway-ip <ipv4|ipv6 >A.B.C.D|X:X::X:X"
- When this route-map is applied as outboubd policy in BGP, it will set the
  gateway-ip in BGP attribute For EVPN type-5 routes.

Example configuration:

route-map RMAP-EVPN_GWIP permit 5
 set evpn gateway-ip ipv4 50.0.2.12
 set evpn gateway-ip ipv6 50:0:2::12

router bgp 101
 bgp router-id 10.100.0.1
 neighbor 10.0.1.2 remote-as 102
 !
 address-family l2vpn evpn
  neighbor 10.0.1.2 activate
  neighbor 10.0.1.2 route-map RMAP-EVPN_GWIP out
  advertise-all-vni
 exit-address-family

Signed-off-by: Ameya Dharkar <adharkar@vmware.com>
2021-06-07 17:58:22 -07:00
Rafael Zalamena
77af3a34ba lib: fix address sanitizer crash on find
Fix the following address sanitizer crash when running the command `find`:

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

Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
2021-06-07 11:14:25 -03:00
Mark Stapp
4b220ad052 lib: add dtor for srv6 locator chunk list
Add a delete function for the chunk list in an srv6
locator.

Signed-off-by: Mark Stapp <mjs@voltanet.io>
2021-06-07 09:52:33 -04:00
Rafael Zalamena
455d14ae31
Merge pull request #8778 from idryzhov/fix-zebra-vrf
zebra: fix config after exit from vrf
2021-06-07 08:59:10 -03:00
Rafael Zalamena
a36dd4c930
Merge pull request #8758 from idryzhov/bfd-fixes
BFD fixes
2021-06-07 08:34:06 -03:00
Rafael Zalamena
4548fb256c
Merge pull request #8781 from idryzhov/fix-list-find
lib: fix output of "list" and "find" commands
2021-06-07 08:32:31 -03:00
Christian Hopps
deca28a33b tests: add grpc unit test
Test uses staticd which required some C++ header protections.
Additionally, the test also runs in the ubuntu20 docker container as
grpc is supported there by the packaging system.

Signed-off-by: Christian Hopps <chopps@labn.net>
2021-06-06 18:03:17 +00:00
Quentin Young
6198bc98be
Merge pull request #8706 from LabNConsulting/chopps/fix-grpc-threading 2021-06-04 20:31:34 +00:00
Mark Stapp
e4768d32b8
Merge pull request #5865 from slankdev/slankdev-zebra-srv6-manager
zebra: srv6 manager
2021-06-04 13:41:55 -04:00
Igor Ryzhov
58929633fb zebra: fix config after exit from vrf
When the VRF node is exited using "exit" or "quit", there's still a VRF
pointer stored in the vty context. If you try to configure some router
related command, it will be applied to the previous VRF instead of the
default VRF. For example:

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

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

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

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

Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2021-06-04 19:02:32 +03:00
Igor Ryzhov
5b96d81c86 lib: fix output of "list" and "find" commands
Currently, we output the command exactly how it is defined in DEFUN.
We shouldn't output varnames and excessive whitespace.

Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2021-06-03 02:03:20 +03:00
Igor Ryzhov
c22789620d lib, vtysh: reduce code duplication
Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2021-06-03 02:03:15 +03:00
Donald Sharp
d64162ce84
Merge pull request #8210 from LabNConsulting/chopps/always-batch
northbound: KISS always batch yang config, it's faster.
2021-06-02 18:13:42 -04:00
Hiroki Shirokura
c60c1ade86 *: delete ZEBRA_FLAG_SEG6*_ROUTE and add ZAPI_NEXTHOP_FLAG_SEG6*
https://github.com/FRRouting/frr/pull/5865#discussion_r597670225

As this comment says. ZEBRA_FLAG_XXX should not have been used.
To communicate SRv6 Route Information. A simple Nexthop Flag would
have been sufficient for SRv6 information. And I fixed the whole
thing that way.

Signed-off-by: Hiroki Shirokura <slank.dev@gmail.com>
2021-06-02 10:24:48 -04:00
Hiroki Shirokura
eab0f8f0a2 lib,sharpd,zebra: update nexthop object with nh_srv6
Signed-off-by: Hiroki Shirokura <slank.dev@gmail.com>
2021-06-02 10:24:48 -04:00
Hiroki Shirokura
0548592691 *: eliminate redundant info from srv6 locator zapi
Signed-off-by: Hiroki Shirokura <slank.dev@gmail.com>
2021-06-02 10:24:48 -04:00
Hiroki Shirokura
7b778857f8 zebra: drop un-needed info in locator-zapi
Signed-off-by: Hiroki Shirokura <slank.dev@gmail.com>
2021-06-02 10:24:48 -04:00
Hiroki Shirokura
a9510347aa zebra: delete unneeded zebra_srv6_manager_connect
Signed-off-by: Hiroki Shirokura <slank.dev@gmail.com>
2021-06-02 10:24:48 -04:00
Hiroki Shirokura
4c6a567d72 lib: erase wrong comments by copy-paste
Signed-off-by: Hiroki Shirokura <slank.dev@gmail.com>
2021-06-02 10:24:48 -04:00
Hiroki Shirokura
8dcb27e6d9 lib: eliminate odd line-break
Signed-off-by: Hiroki Shirokura <slank.dev@gmail.com>
2021-06-02 10:24:48 -04:00
Hiroki Shirokura
fbaa42f744 lib: integrate srv6-nexthop-cmp functions
I agree with the PR review from mstap and merged
the following two functions into one.

- zapi_nexthop_seg6_cmp
- zapi_nexthop_seg6local_cmp

[note]
If both of them have more complex extensions in the future,
I think it will be less confusing to remove the integration
of these functions and make them as separate functions as
before.

Signed-off-by: Hiroki Shirokura <slank.dev@gmail.com>
2021-06-02 10:24:48 -04:00
Hiroki Shirokura
1bda3e627d *: use one line init instead of memset and format it
Signed-off-by: Hiroki Shirokura <slank.dev@gmail.com>
2021-06-02 10:24:48 -04:00
Hiroki Shirokura
326591dcdb lib: fix json style to camel-case instead of underscores
Signed-off-by: Hiroki Shirokura <slank.dev@gmail.com>
2021-06-02 10:24:48 -04:00
Hiroki Shirokura
ac6a9479af zebra: add zapi_srv6_locator_chunk_{en,de}code
Signed-off-by: Hiroki Shirokura <slank.dev@gmail.com>
2021-06-02 10:24:48 -04:00
Hiroki Shirokura
618538f8ab lib: add usual func to install SRv6 localsid (step4)
This commit add usuful function to configure SRv6 localsid
which is represented with seg6local lwt route.
Now, it can support only NEXTHOP_TYPE_IFINDEX route.
Actual configurationof SRv6 localsid is performed with
ZEBRA_ROUTE_ADD. So this is just a wrapper function
for route-install.

Signed-off-by: Hiroki Shirokura <slank.dev@gmail.com>
2021-06-02 10:24:48 -04:00
Hiroki Shirokura
bfaab44d1e *: new cli-nodes for BGP SRv6 VPNv4 (step4)
This commit add just CLI-nodes for MP-BGP VPN configuration
with SRv6 backend rather than MPLS. Actual configuration cli
will be implemented after this commit.

Example Configuration follow.
This cli design is based on Cisco IOS-XR but actual cli
tree design is defferent between FRR and Cisco.
It's just based on cisco.

ref:
https://www.cisco.com/c/en/us/td/docs/routers/asr9000/software/asr9k-r6-6/segment-routing/configuration/guide/b-segment-routing-cg-asr9000-66x/b-segment-routing-cg-asr9000-66x_chapter_011.html#concept_hwj_trf_dlb

router bgp 1
 bgp router-id 1.1.1.1
 !
 segment-routing srv6 ! new cli-node
  locator LOC1 ! this cli will be added after this commit.
 !
!

Signed-off-by: Hiroki Shirokura <slank.dev@gmail.com>
2021-06-02 10:24:48 -04:00
Hiroki Shirokura
4df9d8592b *: fix code format accourding to checkpatch
Signed-off-by: Hiroki Shirokura <slank.dev@gmail.com>
2021-06-02 10:24:48 -04:00
Hiroki Shirokura
2aa01034f3 lib: add new nexthop's attributes seg6 (step3)
This commit add new nexthop's addional object for SRv6
routing about seg6 route. Before this commit,
we can add MPLS info as additional object on nexthop.
This commit make it add more support about seg6 routes.

seg6 routes are ones of the LWT routing mechanism,
so configuration of seg6local routes is performed by
ZEBRA_ROUTE_SEND, it's same as MPLS configuration.

Real configuration implementation isn't implemented at
this commit. later commit add that. This commit add
only nexthop additional object and some misc functions.

Signed-off-by: Hiroki Shirokura <slank.dev@gmail.com>
2021-06-02 10:24:47 -04:00
Hiroki Shirokura
f2867068e6 lib: add new structures for srv6-locator (step2)
This commit is a part of #5853 works that add new structures for
SRv6-locator. This structure will be used by zebra and another
routing daemon and its ZAPI messaging to manage SRv6-locator.
Encoder/decoder for ZAPI stream is also added by this commit.

Real configuration mechanism isn't implemented at this commit.
later commit add real configure implementation. This commit add only
SRv6-locator's structures and misc functions.

Signed-off-by: Hiroki Shirokura <slank.dev@gmail.com>
2021-06-02 10:24:47 -04:00
Hiroki Shirokura
6c0a7c0941 *: new cli-nodes for SRv6 manager (step2)
This commit is a part of #5853 that add new cmd-node for SRv6 configuration.
This commit just add cmd-node and moving node cli only, acutual SRv6 config
command isn't added. (that is added later commit. of this branch)

new cli nodes:
* SRv6
* SRv6-locators
* SRv6-locator

Signed-off-by: Hiroki Shirokura <slank.dev@gmail.com>
2021-06-02 10:24:47 -04:00
Hiroki Shirokura
cb7775a974 lib: add new nexthop's attributes seg6local (step1)
This commit is a part of #5853 works that add new nexthop's addional
object for SRv6 routing about seg6local route. Before this commit,
we can add MPLS info as additional object on nexthop.
This commit make it add more support about seg6local routes.

seg6local routes are ones of the LWT routing mechanism,
so configuration of seg6local routes is performed by
ZEBRA_ROUTE_SEND, it's same as MPLS configuration.

Real configuration implementation isn't implemented at this commit.
later commit add that. This commit add only nexthop additional object
and some misc functions.

Signed-off-by: Hiroki Shirokura <slank.dev@gmail.com>
2021-06-02 10:24:47 -04:00
Hiroki Shirokura
7a4b49bdd1 lib: refactor func prototype seg6local_context2str (step1)
Make seg6local_context2str function's prototype better.
This function is added on commit e496b4203, and function
interface's considering wasn't enough.

Signed-off-by: Hiroki Shirokura <slank.dev@gmail.com>
2021-06-02 10:24:47 -04:00
Christian Hopps
fd396924d6 northbound: KISS always batch yang config (file read), it's faster
The backoff code assumed that yang operations always completed quickly.
It checked for > 100 YANG modeled commands happening in under 1 second
to enable batching. If 100 yang modeled commands always take longer than
1 second batching is never enabled. This is the exact opposite of what
we want to happen since batching speeds the operations up.

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

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

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

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

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

Signed-off-by: Christian Hopps <chopps@labn.net>
2021-06-02 14:05:26 +00:00
Rafael Zalamena
d532d1092e
Merge pull request #8644 from idryzhov/fix-vrf-bind
lib: fix binding to a vrf
2021-06-02 10:47:10 -03:00
Quentin Young
c99313762a
Merge pull request #8353 from opensourcerouting/llvm-20210327 2021-06-01 19:08:32 +00:00
Donald Sharp
465d4a6c5b
Merge pull request #8304 from mjstapp/fix_zmq_xref
lib: fix use of xrefs in zmq wrapper
2021-06-01 13:59:51 -04:00
Christian Hopps
b680134e11 lib: fix threading bug in GRPC code
The code that actually calls FRR northbound functions needs to be running in the
master thread. The previous code was running on a GRPC pthread. While fixing
moved to more functional vs OOP to make this easier to see.

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

Signed-off-by: Christian Hopps <chopps@labn.net>
2021-06-01 15:27:54 +00:00
Igor Ryzhov
7bb5c50c83 lib: fix default ttl for single-hop bfd sessions
The TTL field is actually the number of hops, not a TTL.

Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2021-06-01 18:08:29 +03:00
Igor Ryzhov
b6c87c3576 lib: fix bfd multihop
Never send an interface name/index for multihop sessions. It breaks
"neighbor A.B.C.D update-source" config in BGP.

Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2021-06-01 18:07:54 +03:00
Donatas Abraitis
ef3b48cfe1 lib: Time to remove CONFDATE block
Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
2021-06-01 12:33:43 +03:00
Igor Ryzhov
36eef8586d lib: fix binding to a vrf
There are two possible use-cases for the `vrf_bind` function:
- bind socket to an interface in a vrf
- bind socket to a vrf device

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

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

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

Suggested-by: Pat Ruddy <pat@voltanet.io>
Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2021-05-31 22:12:55 +03:00
Rafael Zalamena
72b9e0cf84
Merge pull request #8718 from taspelund/fix_pfx-tree_default
lib: fix handling of rmap prefix-tree default node
2021-05-25 12:31:03 -03:00
Mark Stapp
9f6b060f63
Merge pull request #8720 from idryzhov/fix-vrf-newline
lib: fix missing newline
2021-05-24 11:40:24 -04:00
Mark Stapp
2d3eb91699
Merge pull request #8498 from ton31337/feature/opaque_data_void_zebra
Zebra OPAQUE data from other daemons stuff
2021-05-24 07:48:02 -04:00
Igor Ryzhov
d9f1279475 lib: fix missing newline
Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2021-05-24 13:27:23 +03:00
Trey Aspelund
4718791c8f lib: fix handling of rmap prefix-tree default node
Prior to this commit, updating a prefix-list that is referenced by a
route-map clause will unconditionally delete the root node of that
route-map's prefix-tree (used with route-map optimization).
This is problematic because routes not matching a more specific node
in the tree (i.e. other prefix-list sequences) will not fall-back to
the default node, thus they will not hit any route-map sequences.
This commit ensures that an update to a prefix-list will only delete
the default node while adding the first/only seq to the list.

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

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

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

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

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

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

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

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

                                                      peer475-out seq 5

IPv6 Prefix                                           Route-map Index List
_______________                                       ____________________

BGP:

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

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

                                                      peer475-out seq 5

IPv6 Prefix                                           Route-map Index List
_______________                                       ____________________

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

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

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

                                                      peer475-out seq 5

IPv6 Prefix                                           Route-map Index List
_______________                                       ____________________

BGP:

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

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

                                                      peer475-out seq 5

IPv6 Prefix                                           Route-map Index List
_______________                                       ____________________

ub20(config)#

Fixes: 8410
Signed-off-by: Trey Aspelund <taspelund@nvidia.com>
2021-05-21 22:25:24 +00:00
Christian Hopps
44cd2b2c2a lib: fix northbound merge code (libyang)
lyd_merge_tree replaces dest siblings with source siblings, not what we
want. Instead lyd_merge_siblings to keep both. Instead lyd_merge_siblings
to keep both.

Signed-off-by: Christian Hopps <chopps@labn.net>
2021-05-20 07:38:09 +00:00
Igor Ryzhov
f96c2b6dc2 lib: fix coverity warnings
CID 1504894

Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2021-05-19 16:22:24 +03:00
Christian Hopps
af1b88e990 lib: libyang2 add missed conversion
Signed-off-by: Christian Hopps <chopps@labn.net>
2021-05-17 22:13:59 -04:00
Donatas Abraitis
94effaf032 zebra: Send more OPAQUE data from BGP
This includes community and large-community data.

```
exit1-debian-9# show ip route 172.16.16.1/32
Routing entry for 172.16.16.1/32
  Known via "bgp", distance 20, metric 0, best
  Last update 00:00:23 ago
  * 192.168.0.2, via eth1, weight 1
    AS-Path          : 65030
    Communities      : 65001:1 65001:2 65001:3 65001:4 65001:5 65001:6
    Large-Communities: 65001:123:1 65001:123:2
```

Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
2021-05-14 22:12:33 +03:00
Martin Winter
d8baf3db2d
Merge pull request #8144 from LabNConsulting/chopps/ly2
libyang2
2021-05-14 01:12:06 +02:00
Christian Hopps
3bb513c399 lib: adapt to version 2 of libyang
Compile with v2.0.0 tag of `libyang2` branch of:
https://github.com/CESNET/libyang

staticd init load time of 10k routes now 6s vs ly1 time of 150s

Signed-off-by: Christian Hopps <chopps@labn.net>
2021-05-13 16:24:48 -04:00
Donald Sharp
e524fc1e2c
Merge pull request #8659 from mjstapp/fix_connected_multi
lib,zebra: Use a flag to track down status for connected addrs
2021-05-13 07:23:42 -04:00
Mark Stapp
e3d901f863 lib,zebra: Use a flag to track down status for connected addrs
Track 'down' state of connected addresses with a new flag. We
may have multiple addresses on an interface that share a prefix;
in those cases, we need to determine when the first address
is valid, to install a connected route, and similarly detect
when the last address goes 'down', to remove the connected
route.

Signed-off-by: Mark Stapp <mjs@voltanet.io>
2021-05-12 09:37:00 -04:00
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