Commit Graph

4978 Commits

Author SHA1 Message Date
Donald Sharp
ed6cec97d7 *: Add resolve via default flag 2021-09-27 12:38:08 -04:00
Igor Ryzhov
a8a5b21514
Merge pull request #9429 from yar-fed/vtysh-err-not-running
vtysh: Add error code if daemon is not running
2021-09-22 22:52:52 +03:00
Donald Sharp
86b2043033
Merge pull request #9646 from LabNConsulting/ziemba/skiplist-level-counters-int
lib: skiplist: clean up level counter implementation
2021-09-22 07:21:14 -04:00
G. Paul Ziemba
c324b10f28 lib: skiplist: clean up level counter implementation
Signed-off-by: G. Paul Ziemba <paulz@labn.net>
2021-09-21 17:03:53 -07:00
Donald Sharp
5b311cf18d
Merge pull request #9052 from mjstapp/dplane_incoming_dev
zebra: Move incoming netlink interface address change events to the dplane pthread
2021-09-21 10:51:37 -04:00
Yaroslav Fedoriachenko
a32f6a107f vtysh: Add error code if daemon is not running
After `<daemon_name> is not running` message vtysh does not return
error. For example if you disable ospf in `/etc/frr/daemons` and run
`vtysh -c configure -c "router ospf"` it prints the message to stderr,
but returns 0.

This commit will make vtysh return error when not in interractive mode.

But if you run commands from vtysh, you will still be able to enter
views and exit them if daemon is not running.

Signed-off-by: Yaroslav Fedoriachenko <yar.fed99@gmail.com>
2021-09-21 17:51:04 +03:00
Igor Ryzhov
0de76236b1 lib: significantly improve nb cli command sorting
Instead of sorting each command one-by-one using listnode_add_sort, add
them to the list without sorting and then sort the list only once.

Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2021-09-17 12:00:58 +03:00
Donald Sharp
827ddd5a1d
Merge pull request #9596 from LabNConsulting/ziemba/printfrr-nexthop
printfrr %pNHcg, %pNHci
2021-09-15 20:23:30 -04:00
Stephen Worley
bc4477ecbd
Merge pull request #9608 from idryzhov/vtysh-segfault
lib: fix segfault on question mark on empty line
2021-09-15 11:43:37 -04:00
Donald Sharp
21ecdb1f34 lib: Fix usage of default
case default has snuck into our code base for switches
over enumerated types.  Remove.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2021-09-14 13:27:19 -04:00
G. Paul Ziemba
016cfe701e lib,doc,tests: printfrr %pNHcg, %pNHci
Signed-off-by: G. Paul Ziemba <paulz@labn.net>
2021-09-14 10:06:57 -07:00
G. Paul Ziemba
52fad8f656 lib/module.c and callers of frrmod_load(): fix error messages
frrmod_load() attempts to dlopen() several possible paths
    (constructed from its basename argument) until one succeeds.

    Each dlopen() attempt may fail for a different reason, and
    the important one might not be the last one. Example:

	dlopen(a/foo): file not found
	dlopen(b/foo): symbol "bar" missing
	dlopen(c/foo): file not found

    Previous code reported only the most recent error. Now frrmod_load()
    describes each dlopen() failure.

Signed-off-by: G. Paul Ziemba <paulz@labn.net>
2021-09-14 09:51:49 -07:00
Igor Ryzhov
b8c01bba53
Merge pull request #9486 from slankdev/slankdev-srv6-no-cli-1
CLI to delete SRv6 locator
2021-09-14 19:04:03 +03:00
Mark Stapp
9c86ee1e02 lib,zebra: use more const
Use const in ipX_martian apis, and in some zebra apis.

Signed-off-by: Mark Stapp <mjs.ietf@gmail.com>
2021-09-14 10:31:45 -04:00
Igor Ryzhov
6ccb661c08 lib: fix segfault on question mark on empty line
Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2021-09-14 15:12:23 +03:00
Igor Ryzhov
f17030115f
Merge pull request #9364 from LabNConsulting/ziemba/vrf_name_to_id-unknown
vrf_name_to_id(): remove and change callers to use vrf_lookup_by_name()
2021-09-14 13:16:24 +03:00
Donatas Abraitis
7d18da9671
Merge pull request #9586 from idryzhov/bgp-default-originate-rmap-fixes
BGP default-originate with route-map fixes
2021-09-12 20:50:36 +03:00
Donatas Abraitis
0f64a435db
Merge pull request #9475 from iqras23/change1
bgpd: VRF-Lite fix nexthop type
2021-09-12 20:47:18 +03:00
Quentin Young
32acb4a7ad
Merge pull request #9497 from opensourcerouting/cli-better-no 2021-09-09 12:22:53 -04:00
Igor Ryzhov
c212584717 lib: add ability to supply separate match/set objects to routemaps
Sometimes it's needed to match by fields of one object but set fields of
another object. The following commit is an example.

Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2021-09-08 23:37:50 +03:00
G. Paul Ziemba
a383d4d201 vrf_name_to_id(): remove
vrf_name_to_id() returned VRF_DEFAULT when the vrf name was
    unknown, hiding errors. Per community recommendation, vrf_name_to_id()
    is now removed and the few callers now use vrf_lookup_by_name()
    directly.

Signed-off-by: G. Paul Ziemba <paulz@labn.net>
2021-09-07 09:47:24 -07:00
Hiroki Shirokura
15588d7b63 lib: add zapi encode/decode func for srv6 locator
Signed-off-by: Hiroki Shirokura <slank.dev@gmail.com>
2021-09-07 12:54:01 +00:00
Kantesh Mundaragi
0789eb69e5 bgpd: VRF-Lite fix nexthop type
Description:
Change is intended for fixing the following issues related to vrf route leaking:

Routes with special nexthops i.e. blackhole/sink routes when imported,
are not programmed into the FIB and corresponding nexthop is set as 'inactive',
nexthop interface as 'unknown'.

While importing/leaking routes between VRFs, in case of special nexthop(ipv4/ipv6)
once bgp announces route(s) to zebra, nexthop type is incorrectly set as
NEXTHOP_TYPE_IPV6_IFINDEX/NEXTHOP_TYPE_IFINDEX
i.e. directly connected even though we are not able to resolve through an interface.
This leads to nexthop_active_check marking nexthop !NEXTHOP_FLAG_ACTIVE.
Unable to find the active nexthop(s), route is not programmed into the FIB.

Whenever BGP leaks routes, set the correct nexthop type, so that route gets resolved
and correctly programmed into the FIB, in the imported vrf.

Co-authored-by: Kantesh Mundaragi <kmundaragi@vmware.com>
Signed-off-by: Iqra Siddiqui <imujeebsiddi@vmware.com>
2021-09-07 01:50:06 -07:00
Donald Sharp
3702e8577f
Merge pull request #9563 from opensourcerouting/build-strict-prototypes
build: `-Wstrict-prototypes` (+ BSD `sed`)
2021-09-06 12:28:33 -04:00
Donald Sharp
0e099318c8 lib: Remove unused function vrf_generate_id
Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2021-09-02 09:19:48 -04:00
Donald Sharp
c2ad0a0d40
Merge pull request #9106 from opensourcerouting/clippy-elf-bsd-cond
lib/clippy: fix forgotten conditional
2021-09-02 07:31:10 -04:00
David Lamparter
9fb83ab17d *: fix for -Wstrict-prototypes
Just some "void" missing between empty braces.

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2021-09-02 13:00:35 +02:00
David Lamparter
14040553bc lib: fix hook defs for -Wstrict-prototypes
Without this, the hook code creates functions with empty parameter lists
like "void hook_something()", which is not a proper C prototype.  It
needs to be "void hook_something(void)".  Add some macro shenanigans to
handle that.

... and make the plumbing functions "inline" too.

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2021-09-02 13:00:35 +02:00
Russ White
ce4f3813f0
Merge pull request #9439 from ton31337/feature/set_ext_community_to_none
bgpd: Route-map `set extcommunity none`
2021-09-01 12:55:45 -04:00
Russ White
3c65c73ffa
Merge pull request #9502 from idryzhov/cmd-vtysh-cleanup
lib, vtysh: make node-processing code more generic
2021-08-30 15:58:06 -04:00
David Lamparter
3816ea6bb6 lib/clippy: fix forgotten conditional
This fixes some spurious warnings on *BSD, where `elffile_add_dynreloc`
isn't used since `elf_getdata_rawchunk` is not available.

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2021-08-28 14:27:17 +02:00
Russ White
648c73647d
Merge pull request #9488 from pguibert6WIND/fix_nhrp_neigh_state
Fix nhrp neigh state
2021-08-27 19:00:45 -04:00
Donald Sharp
4cc6d2cef6 lib: Send c-bit when not using bfdd as daemon of choice
Commit: 4b983eef2c

Modified the zapi send receive of the c-bit to only
be under the HAVE_BFDD.  If you are using ptm-bfd
then the decoder function still expects this to be
sent down.  This commit puts this behavior back

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2021-08-27 09:32:27 -04:00
David Lamparter
8268be3d16
Merge pull request #9496 from idryzhov/vrf-cmd-init-unused-arg
lib: remove unused argument from vrf_cmd_init
2021-08-27 10:39:45 +02:00
David Lamparter
3be280bb8c lib: fix indentation trainwreck in command_py
Hooooo boooooyyyy... that `default` sure was in an "interesting" place.

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2021-08-26 21:08:51 +02:00
David Lamparter
90c8406c20 lib: add ![...] syntax for easy "no" forms
This allows defining a CLI command like this:
  `[no] some setting ![VALUE]`
with VALUE being optional for the "no" form, but required for the
positive form.  It's just a `[...]` where the empty branch can only be
taken for commands starting with `no`.

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2021-08-26 21:03:44 +02:00
Igor Ryzhov
c1e7a5e45e lib: make node_parent more generic
Instead of adding a separate case clause for every node, just find the
node structure in the global list and get its parent node from there.

Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2021-08-26 19:43:23 +03:00
Christian Hopps
d448e2c5f9
Merge pull request #9331 from idryzhov/explicit-exit
*: explicitly print "exit" at the end of every node config
2021-08-26 11:57:33 -04:00
Igor Ryzhov
cfc369c43a lib: remove unused argument from vrf_cmd_init
Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2021-08-26 12:01:22 +03:00
Philippe Guibert
80f6b5faeb lib, zebra: complete the ndm flags on zclient api
Insist on the fact that zclient neighbor state flags are
mapped over netlink state flags. List all the defines
currently known on kernel, and create a netlink API to
convert netlink values to zclient values. The function is
simplified as it is a 1-1 match.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2021-08-26 09:19:42 +02:00
Philippe Guibert
c4e1fd52a1 nhrp, zebra, lib: pass exact received neighbor state value to nhrp
As NHRP expects some notification of neighboring entries on GRE
interface, when a new interface notification is encountered, the
exact neighbor state flag is found. Previously, the flag passed
to the upper layer was forced to NDM_STATE which is REACHABLE,
as can be seen on below trace:

2021/08/25 10:58:39 NHRP: [QQ0NK-1H449] Netlink: new-neigh 102.1.1.1 dev gre1 lladdr 10.125.0.2 nud 0x2 cache used 1 type 5

When passing the real value, NHRP received an other value like STALE.

2021/08/25 11:28:44 NHRP: [QQ0NK-1H449] Netlink: new-neigh 102.1.1.1 dev gre1 lladdr 10.125.0.2 nud 0x4 cache used 0 type 5

This flag is important for NHRP, as it permits to monitor the link
layer of NHRP entries.

Fixes: d603c0774e ("nhrp, zebra, lib: enforce usage of zapi_neigh_ip structure")

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2021-08-26 09:19:42 +02:00
Donatas Abraitis
3e324ff419
Merge pull request #9466 from idryzhov/vrf-netns
lib, zebra: move vrf netns commands from lib to zebra
2021-08-26 07:46:19 +03:00
Donatas Abraitis
d10bda270e *: Drop break after using frr_help_exit() in switch/case
Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
2021-08-25 10:49:05 +03:00
Igor Ryzhov
14b066917b lib: remove the dependency on bgpd code
The library code should not depend on a specific daemon's code.

Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2021-08-24 17:42:37 +03:00
Igor Ryzhov
37cb0475e1 lib, zebra: move vrf netns commands from lib to zebra
"[no] netns NAME" commands are part of the lib, but they are actually
zebra-only:
- they are using vrf_netns_handler_create and its description clearly
  says that it "should be called from zebra only"
- vtysh sends these commands only to zebra
- only zebra outputs the netns related config
- zebra notifies other daemons about netns attachment

Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2021-08-23 23:54:12 +03:00
Igor Ryzhov
07679ad98a *: explicitly print "exit" at the end of every node config
There is a possibility that the same line can be matched as a command in
some node and its parent node. In this case, when reading the config,
this line is always executed as a command of the child node.

For example, with the following config:
```
router ospf
 network 193.168.0.0/16 area 0
!
mpls ldp
 discovery hello interval 111
!
```
Line `mpls ldp` is processed as command `mpls ldp-sync` inside the
`router ospf` node. This leads to a complete loss of `mpls ldp` node
configuration.

To eliminate this issue and all possible similar issues, let's print an
explicit "exit" at the end of every node config.

This commit also changes indentation for a couple of existing exit
commands so that all existing commands are on the same level as their
corresponding node-entering commands.

Fixes #9206.

Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2021-08-23 22:08:20 +03:00
Stephen Worley
95b4a691dd
Merge pull request #9337 from dlqs/lua2
lib: check return on str2sockunion
2021-08-23 08:20:33 -06:00
Mark Stapp
8fd5502b0c lib: avoid double-free in zmq wrapper callbacks
There were paths where the zmq wrapper lib could call user
callbacks that would free the internal context struct, but the
context was then used in the lib code. Use a boolean to avoid
freeing the context within an application callback.

Restore logic that frees the context within the 'cancel' api.

Signed-off-by: Mark Stapp <mjs.ietf@gmail.com>
2021-08-19 13:31:33 -04:00
Mark Stapp
cf2182c013 lib: clear caller's pointer when freeing context struct
The zeromq lib wrapper uses an internal context struct to help
interact with the libfrr event mechanism. When freeing that
context struct, ensure the caller's pointer is also cleared.

Signed-off-by: Mark Stapp <mjs.ietf@gmail.com>
2021-08-19 13:31:33 -04:00
Christian Hopps
11ca35875c pimd: change ranges to 1..max, type align with IETF YANG.
While defaults are good picks for "reasonable" guesses, min and max
range values really aren't. Operators and experimenters often like to
configure "unreasonable" values to stress test, tests boundary
conditions and explore innovations.

With that in mind, change all ranges to 1..max (of type).

While we're here add optional ignored values in the "no" CLI forms.

Signed-off-by: Christian Hopps <chopps@labn.net>
2021-08-18 22:08:33 -04:00
Donatas Abraitis
bb4dcdd13e bgpd: Add an ability to set extcommunity to none in route-maps
Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
2021-08-18 14:14:52 +03:00
Russ White
e709f411e9
Merge pull request #9365 from idryzhov/fix-plist-dup-check
lib: fix prefix-list duplication check
2021-08-17 09:55:34 -04:00
Russ White
55a3d3cef2
Merge pull request #9385 from idryzhov/bgpd-match-evpn-default-route-crash
bgpd: fix segfault when re-adding "match evpn default-route" rule
2021-08-17 09:54:25 -04:00
Igor Ryzhov
40d9855588
Merge pull request #9404 from neirbowj/notcares
Scan lib/resolver.c only when c-ares is installed
2021-08-17 11:28:22 +03:00
Igor Ryzhov
5838d3b452
Merge pull request #9265 from ton31337/fix/extcommunity_lb_route-map_persistent
bgpd: Extended community bandwidth fixes
2021-08-16 12:26:25 +03:00
John W. O'Brien
433d9af2a6 lib: Scan lib/resolver.c only when c-ares is installed
Scan lib/resolver.c only when c-ares is installed

Signed-off-by: John W. O'Brien <john@saltant.com>
2021-08-15 12:54:37 -04:00
Quentin Young
0c0830c599 lib: add frrstr_hex to hexdump buffers
Signed-off-by: Quentin Young <qlyoung@nvidia.com>
2021-08-12 16:25:57 -04:00
Igor Ryzhov
30475121ad bgpd: fix segfault when re-adding "match evpn default-route" rule
When using "match evpn default-route" rule, match_arg is NULL and strcmp
is not happy with that. There's already a special function named rulecmp
that handles such situations.

Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2021-08-12 19:08:46 +03:00
Igor Ryzhov
667dcc277c lib: fix prefix-list duplication check
Currently, when we check the new prefix-list entry for duplication, we
only take filled in fields into account and ignore optional fields.
For example, if we already have `ip prefix-list A 0.0.0.0/0 le 32` and
we try to add `ip prefix-list A 0.0.0.0/0`, it is treated as duplicate.
We should always compare all prefix-list fields when doing the check.

Fixes #9355.

Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2021-08-10 22:31:42 +03:00
Donald Lee
0db2bfc5ac lib: Remove extraneous braces
Signed-off-by: Donald Lee <dlqs@gmx.com>
2021-08-10 15:37:30 +08:00
Donald Lee
2ed598ba6b lib: Enable consecutive frrscript_call
Previous:
 - frrscript_load: push Lua function onto stack
 - frrscript_call: calls Lua function

Now:
 - frrscript_load: checks Lua function
 - frrscript_call: pushes and calls Lua function (first clear the stack)

So now we just need one frrscript_load for consecutive frrscript_call.
frrscript_call does not recompile or reload the script file, it just
keys it from the global Lua table (where it should already be).

Signed-off-by: Donald Lee <dlqs@gmx.com>
2021-08-10 07:35:32 +08:00
Mark Stapp
c123e9df54
Merge pull request #9299 from donaldsharp/zebra_should_continue
Zebra should continue
2021-08-09 13:16:10 -04:00
Quentin Young
edc6ea2ec5
Merge pull request #9273 from dlqs/luadofilefix
lib: Fix dead code from lua_dofile
2021-08-09 09:55:35 -04:00
Donald Lee
a852e5a62d lib: check return on str2sockunion
Signed-off-by: Donald Lee <dlqs@gmx.com>
2021-08-09 17:19:28 +08:00
Donatas Abraitis
e885e97d87
Merge pull request #9325 from anlancs/fix-lib-warning
lib: Fix coverity warning of return value
2021-08-09 10:34:38 +03:00
anlan_cs
4b0d126794 lib: Fix coverity warning of return value
Suppress coverity warning on unchecked str2sockunion's return value.

Signed-off-by: anlan_cs <anlan_cs@tom.com>
2021-08-07 21:57:55 -04:00
Donald Sharp
f932b4eef3
Merge pull request #9313 from idryzhov/bgp-zebra-opaque
BGP opaque data improvements
2021-08-07 15:12:02 -04:00
Igor Ryzhov
b5bb70e377 bgpd: add protection against too large opaque data structure
BGP opaque data shouldn't be larger than zebra's buffer.

Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2021-08-06 17:09:46 +03:00
Igor Ryzhov
a9bf0ff268 bgpd: use longer aspath string in opaque data
32 bytes are not enough to carry relatively long AS paths so let's make
the buffer larger.

Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2021-08-06 17:06:39 +03:00
Donatas Abraitis
639caccfeb bgpd: Fix misleading comments for some parts
Mostly just retrun => return and misleading comments at all.

Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
2021-08-05 16:29:52 +03:00
Donald Sharp
b7457b40cd lib: Blackhole nexthops cannot be used as part of label generation
Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2021-08-04 13:34:03 -04:00
Donald Sharp
1ae0e1b315 lib: Convert assert to error and record it instead of aborting
When we get a bad value for the opaque data length, instead
of stopping the program, discard the data and move on.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2021-08-04 11:13:26 -04:00
Donald Lee
868b41d97b lib: Fix dead code from lua_dofile
Signed-off-by: Donald Lee <dlqs@gmx.com>
2021-08-03 13:36:24 -04:00
Russ White
1358f9d10a
Merge pull request #9259 from opensourcerouting/moar-json
*: can't get enough JSON
2021-08-03 09:13:12 -04:00
Donatas Abraitis
71bdae66b2 bgpd: Keep extcommunity bandwidth commands persistent in route-maps
~/frr# vtysh -c 'conf' -c 'route-map testas permit 10' -c 'set extcommunity bandwidth 321'
~/frr# vtysh -c 'show route-map testas' | grep 321
    extcommunity bandwidth 321 non-transitive
~/frr# vtysh -c 'sh run' | grep 321
~/frr#

Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
2021-08-03 14:38:53 +03:00
Renato Westphal
488599bfa2
Merge pull request #9232 from idryzhov/interface-node-cleanup
*: cleanup interface node installation
2021-08-02 21:13:29 -03:00
Renato Westphal
58e2857d23 lib: add "json" option to "show ip[v6] prefix-list"
Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2021-08-02 17:19:45 -03:00
Renato Westphal
856ed18ae9 lib: add "json" option to "show route-map"
Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2021-08-02 16:05:44 -03:00
Renato Westphal
068ab9018b lib: add "json" option to "show ip[v6] access-list"
Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2021-08-02 16:05:44 -03:00
Igor Ryzhov
72928fa1aa
Merge pull request #9238 from leonshaw/fix/netns-delete
lib, zebra: Preserve user-configured VRF on netns deletion
2021-08-02 18:12:19 +03:00
Quentin Young
41d3d77496
Merge pull request #8982 from dlqs/lua-func-stack 2021-08-02 13:51:35 +00:00
Xiao Liang
6910315f6f lib, zebra: Preserve user-configured VRF on netns deletion
Don't clear VRF's user-configured flag when netns is deleted.

Signed-off-by: Xiao Liang <shaw.leon@gmail.com>
2021-07-30 14:53:45 +08:00
Igor Ryzhov
9da01b0b7b *: cleanup interface node installation
The only difference in daemons' interface node definition is the config
write function. No need to define the node in every daemon, just pass
the callback as an argument to a library function and define the node
there.

Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2021-07-29 21:35:25 +03:00
Donald Lee
b5e790ee4d lib: Add parens around macro args
Signed-off-by: Donald Lee <dlqs@gmx.com>
2021-07-29 05:52:22 +08:00
Donald Lee
9e3a277b04 lib: Fix condition for snprintf
Signed-off-by: Donald Lee <dlqs@gmx.com>
2021-07-29 05:52:22 +08:00
Donald Sharp
fb1df4cd13 lib: prevent crash in make check in some situations
When running `make check` against a build that zeromq enabled
the test_zmq unit test was crashing.  The commit:

e08165def1

Introduced this crash.  Removing the part of the commit
that was causing the crash in the test.  This is mainly
to get `make check` working again for those people using
zeromq in their builds.

Fixes: #9176
Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2021-07-28 14:41:46 -04:00
Jafar Al-Gharaibeh
213d980ff9
Merge pull request #9007 from donaldsharp/pbr_stuff
add ability to match on proto to pbr
2021-07-27 15:09:29 -05:00
Donald Lee
84c92002d2 lib: formatting
Signed-off-by: Donald Lee <dlqs@gmx.com>
2021-07-26 23:48:23 +08:00
Donald Lee
78f1ac2574 lib: Add new MTYPE for script results
Signed-off-by: Donald Lee <dlqs@gmx.com>
2021-07-26 23:27:56 +08:00
Donald Lee
6ffeb9f79f bgpd: Comment for included
Signed-off-by: Donald Lee <dlqs@gmx.com>
2021-07-26 22:47:50 +08:00
Donatas Abraitis
66aa87d03e
Merge pull request #8637 from opensourcerouting/pim-vrf-acl-fixes
Pim vrf acl fixes
2021-07-26 12:20:54 +03:00
Donald Lee
36cf58c785 lib: Rename decode_int
Signed-off-by: Donald Lee <dlqs@gmx.com>
2021-07-24 03:41:40 +08:00
Donald Lee
4093300ee8 lib: zlog err in error cases during lua loading
Signed-off-by: Donald Lee <dlqs@gmx.com>
2021-07-24 03:40:57 +08:00
Donald Lee
6d28552d2d lib: comment typo
Signed-off-by: Donald Lee <dlqs@gmx.com>
2021-07-24 03:35:09 +08:00
Donald Lee
8be973f5c2 lib: Add function name to script command
Signed-off-by: Donald Lee <dlqs@gmx.com>
2021-07-24 00:45:22 +08:00
Donald Lee
1da9c4bdbb lib: Use negative indices and add comments
Signed-off-by: Donald Lee <dlqs@gmx.com>
2021-07-24 00:45:22 +08:00
Donald Lee
1763ed2655 lib: Cap script_name length
Signed-off-by: Donald Lee <dlqs@gmx.com>
2021-07-24 00:45:22 +08:00
Donald Lee
67b64027b2 lib: parens around macro args
Signed-off-by: Donald Lee <dlqs@gmx.com>
2021-07-23 20:48:16 +08:00
Donald Lee
08bf2b41b8 lib: formatting
Signed-off-by: Donald Lee <dlqs@gmx.com>
2021-07-23 20:43:24 +08:00
Donald Lee
70d995abd4 lib: Comment on how macro works
Signed-off-by: Donald Lee <dlqs@gmx.com>
2021-07-23 20:43:24 +08:00
Donald Sharp
0775caa958
Merge pull request #9082 from ton31337/feature/bgp_alias_route-map_match
bgpd: `match alias` for route-map
2021-07-22 08:30:15 -04:00
Donald Sharp
918af5a40b
Merge pull request #9102 from opensourcerouting/autoconf-fix-gcov
build: fix LDFLAGS confusion & gcov
2021-07-21 19:26:15 -04:00
David Lamparter
63116a7008 build: fix AM_LDFLAGS usage (and gcov)
like the other automake variables, setting `xyz_LDFLAGS` causes
`AM_LDFLAGS` to be ignored for `xyz`.  For some reason I had in my mind
that automake doesn't do this for LDFLAGS, but... it does.  (Which is
consistent with `_CFLAGS` and co.)

So, all the libraries and modules have been ignoring `AM_LDFLAGS` (which
includes `SAN_FLAGS` too).  Set up new `LIB_LDFLAGS` and
`MODULE_LDFLAGS` to handle all of this correctly (and move these bits to
a central location.)

Fixes: #9034
Fixes: 0c4285d77e ("build: properly split CFLAGS from AC_CFLAGS")
Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2021-07-21 17:10:08 +02:00
Igor Ryzhov
d9331fc67c lib, zebra: fix exit from link-params node
When exiting from link-params node, we must not decrement xpath_index
because it is not incremented when entering the node.

Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2021-07-21 17:23:45 +03:00
Donatas Abraitis
2690f18cc8 bgpd: Add route-map match alias command
Will be handy to filter BGP prefixes by using BGP community alias
instead of numerical community values.

Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
2021-07-21 09:26:14 +03:00
Donald Lee
2ce634e2ad lib: formatting
Signed-off-by: Donald Lee <dlqs@gmx.com>
2021-07-19 23:28:01 +08:00
Mark Stapp
0a0875df5b lib: remove quagga from route_types.txt
Remove the q-word.

Signed-off-by: Mark Stapp <mjs@voltanet.io>
2021-07-19 08:43:48 -04:00
Donald Lee
596b44af8a lib: Remove warning about script not found
Signed-off-by: Donald Lee <dlqs@gmx.com>
2021-07-18 06:32:03 +08:00
Donald Lee
7472871eef lib: Comment functions
Signed-off-by: Donald Lee <dlqs@gmx.com>
2021-07-18 06:32:03 +08:00
Donald Lee
2b67227e6e lib: Add int encoder/decoder
Signed-off-by: Donald Lee <dlqs@gmx.com>
2021-07-18 06:32:03 +08:00
Donald Lee
8878080b1b lib: Remove ../ include
Signed-off-by: Donald Lee <dlqs@gmx.com>
2021-07-18 06:32:03 +08:00
Donald Lee
64d457d7ac lib: Rename frrscript_unload to delete
frrscript_load now loads a function instead of a file, so frrscript_unload
should be renamed since it does not unload a function.

Signed-off-by: Donald Lee <dlqs@gmx.com>
2021-07-18 06:32:03 +08:00
Donald Lee
b664092990 lib: standardize zlog error messages
Signed-off-by: Donald Lee <dlqs@gmx.com>
2021-07-18 06:32:03 +08:00
Donald Lee
ad6e9b854d test: Use frrscript_unload
Signed-off-by: Donald Lee <dlqs@gmx.com>
2021-07-18 06:32:03 +08:00
Donald Lee
fae19fa56d lib: frrscript unload deallocates Lua function
Signed-off-by: Donald Lee <dlqs@gmx.com>
2021-07-18 06:32:03 +08:00
Donald Lee
8a79921ca3 lib: format macro slashes
Signed-off-by: Donald Lee <dlqs@gmx.com>
2021-07-18 06:32:03 +08:00
Donald Lee
06947ddeac lib: Add frrscript_get_result
Signed-off-by: Donald Lee <dlqs@gmx.com>
2021-07-18 06:32:03 +08:00
Donald Lee
24ff8520af lib: frrscript_call check name before decode
Signed-off-by: Donald Lee <dlqs@gmx.com>
2021-07-18 06:32:03 +08:00
Donald Lee
cb5de23140 lib: update frrscript unload
Signed-off-by: Donald Lee <dlqs@gmx.com>
2021-07-18 06:32:03 +08:00
Donald Lee
a71096fb0a lib: Update Script command example to call function
Signed-off-by: Donald Lee <dlqs@gmx.com>
2021-07-18 06:32:03 +08:00
Donald Lee
40d038d2a1 lib: Change frrscript_call to call function instead
There is some rather heavy error checking logic in frrscript_call. Normally
I'd put this in the _frrscript_call function, but the error checking needs
to happen before the encoders/decoders in the macro are called.

The error checking looks messy but its really just nested ternary
expressions insite a larger statement expression.

Signed-off-by: Donald Lee <dlqs@gmx.com>
2021-07-18 06:32:03 +08:00
Donald Lee
f0cddf950f lib: create new frrscript_new
frrscript_new now creates a new frrscript
frrscript_load now loads a function (by allocating a new lua stack)

Signed-off-by: Donald Lee <dlqs@gmx.com>
2021-07-18 06:32:03 +08:00
Donald Lee
105ba9af8f lib: Change frrscript to hold many Lua states
Instead of 1 frrscript : 1 lua state, it is changed to 1 : N.
The states are hashed with their function names.

Signed-off-by: Donald Lee <dlqs@gmx.com>
2021-07-18 06:32:03 +08:00
Russ White
000df71ccd
Merge pull request #8767 from opensourcerouting/ospfd-gr
ospfd: introduce support for Graceful Restart (restarting mode)
2021-07-13 06:39:53 -04:00
Rafael Zalamena
1fe59b44fc lib,ospfd,ospf6d: remove duplicated function
Move `is_default_prefix` variations to `lib/prefix.h` and make the code
use the library version instead of implementing it again.

NOTE
----

The function was split into per family versions to cover all types.
Using `union prefixconstptr` is not possible due to static analyzer
warnings which cause CI to fail.

The specific cases that would cause this failure were:
 - Caller used `struct prefix_ipv4` and called the generic function.
 - `is_default_prefix` with signature using `const struct prefix *` or
   `union prefixconstptr`.

The compiler would complain about reading bytes outside of the memory
bounds even though it did not take into account the `prefix->family`
part.

Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
2021-07-09 07:55:25 -03:00
Donald Sharp
b94683f0db lib, zebra: add ip_proto to the filter data structure
Add ip_proto to the filter data structure and also account
for it in the hash when stored.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2021-07-08 11:12:47 -04:00
Donald Sharp
8096bd72aa zebra: Add ability to encode/decode netlink FRA_IP_PROTO for rule changes
Encode/Decode the FRA_IP_PROTO but do nothing with it at the moment.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2021-07-08 11:12:47 -04:00
Martin Winter
3f8fcd2caa
Merge pull request #8997 from donaldsharp/opaque_length
lib: Allow ZAPI_MESSAGE_OPAQUE_LENGTH length of data
2021-07-08 03:35:42 +02:00
Donald Sharp
3b1849be32 lib: Allow ZAPI_MESSAGE_OPAQUE_LENGTH length of data
We are sending up to ZAPI_MESSAGE_OPAQUE_LENGTH but checking
for one less.  We know the data will fit in it to that size.
Also we have asserts on the write to ensure we don't go over
it

Fixes: #8995
Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2021-07-07 16:01:32 -04:00
David Lamparter
f49e0be728 lib: fix coverity unused result warning
There's nothing that can be done here with an error.  Try to make
Coverity understand that this is intentional.

(I don't know if the `(void)` will actually fix the coverity warning,
but I don't really have a better way to figure it out beyond just
getting this merged and waiting for a result...)

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2021-07-07 14:58:14 +02:00
Quentin Young
e15106149f
Merge pull request #8508 from opensourcerouting/systemd-no-lib 2021-07-06 14:54:25 +00:00
Donald Sharp
acb4c44ef8
Merge pull request #8942 from ton31337/fix/cleanups_2
Another round of cleanup
2021-07-06 09:47:41 -04:00
David Lamparter
19cf3fc5ab
lib: add command to test prefix-list match
While we do have `show ip prefix-list NAME A.B.C.D/M`, that doesn't
actually run the prefix list matching code.  While the result would
hopefully be the same anyway, let's have a way to call the actual prefix
list match code and get a result.

(As an aside, this might be useful for scripting to do a quick "is this
prefix in that prefix list" check.)

Signed-off-by: David Lamparter <equinox@diac24.net>
2021-07-06 01:44:35 +02:00
David Lamparter
2b6b16fc21
lib, pimd: add address match mode to prefix lists
... the PIM code is kinda misusing prefix lists to match addresses.
Considering the weird semantics of access-lists, I can't fault it.
However, prefix lists aren't great at matching addresses by default,
since they try to match the prefix length too.  So, here's an "address
match mode" for prefix lists to get that to work more reasonably.

Fixes: #8492
Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2021-07-06 01:44:34 +02:00
Renato Westphal
1051417011 ospfd: introduce support for Graceful Restart (restarting mode)
RFC 3623 specifies the Graceful Restart enhancement to the OSPF
routing protocol. This PR implements support for the restarting mode,
whereas the helper mode was implemented by #6811.

This work is based on #6782, which implemented the pre-restart part
and settled the foundations for the post-restart part (behavioral
changes, GR exit conditions, and on-exit actions).

Here's a quick summary of how the GR restarting mode works:
* GR can be enabled on a per-instance basis using the `graceful-restart
  [grace-period (1-1800)]` command;
* To perform a graceful shutdown, the `graceful-restart prepare ospf`
  EXEC-level command needs to be issued before restarting the ospfd
  daemon (there's no specific requirement on how the daemon should
  be restarted);
* `graceful-restart prepare ospf` will initiate the graceful restart
  for all GR-enabled instances by taking the following actions:
  o Flooding Grace-LSAs over all interfaces
  o Freezing the OSPF routes in the RIB
  o Saving the end of the grace period in non-volatile memory (a JSON
    file stored in `$frr_statedir`)
* Once ospfd is started again, it will follow the procedures
  described in RFC 3623 until it detects it's time to exit the graceful
  restart (either successfully or unsuccessfully).

Testing done:
* New topotest featuring a multi-area OSPF topology (including stub
  and NSSA areas);
* Successful interop tests against IOS-XR routers acting as helpers.

Co-authored-by: GalaxyGorilla <sascha@netdef.org>
Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2021-07-05 11:43:02 -03:00
Quentin Young
71bae95e4a
Merge pull request #8888 from dlqs/lua-call 2021-07-05 04:13:20 +00:00
Donatas Abraitis
8643c2e5f7 *: Replace 4/16 integers to IPV4_MAX_BYTELEN/IPV6_MAX_BYTELEN
Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
2021-07-01 23:54:39 +03:00
Donatas Abraitis
12256b84a5 *: Convert numeric 32 into IPV4_MAX_BITLEN for prefixlen
Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
2021-07-01 23:50:39 +03:00
Donatas Abraitis
13ccce6e7e *: Convert numeric 128 into IPV6_MAX_BITLEN for prefixlen
Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
2021-07-01 17:53:21 +03:00
Donatas Abraitis
936fbaef47 *: Replace IPV4_MAX_PREFIXLEN to IPV4_MAX_BITLEN
Just drop IPV4_MAX_PREFIXLEN at all, no need keeping both.

Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
2021-07-01 17:44:09 +03:00
Donatas Abraitis
f4d81e5507 *: Replace IPV6_MAX_PREFIXLEN to IPV6_MAX_BITLEN
Just drop IPV6_MAX_PREFIXLEN at all, no need keeping both.

Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
2021-07-01 17:41:09 +03:00
Renato Westphal
8b0ab1f8a0
Merge pull request #8780 from idryzhov/fix-zebra-coverity
zebra: fix a couple of coverity warnings
2021-06-30 16:08:35 -03:00
Donatas Abraitis
e702605d80 *: Do not check for XMALLOC/XCALLOC against NULLs
We don't check this pattern anywhere in the code basically, so let's
unify the code.

Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
2021-06-29 22:27:50 +03:00
Donatas Abraitis
0e2d70760d lib: Avoid using assignments within checks
Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
2021-06-29 22:27:49 +03:00
David Lamparter
247898d5d2 lib, watchfrr: remove HAVE_SYSTEMD, use own code
This replaces the external libsystemd dependency with... pretty much the
same amount of built-in code.  But with one fewer dependency and build
switch needed.

Also check `JOURNAL_STREAM` for future logging integration.

Signed-off-by: David Lamparter <equinox@diac24.net>
2021-06-29 17:57:04 +02:00
Olivier Dugeon
55a02e1ed4
Merge pull request #8824 from volta-networks/fix_check_for_link_param_change
isisd, ospfd: update interface_link_params callback to check for change
2021-06-29 16:53:54 +02:00
Igor Ryzhov
b08dcc3f3f *: unify prefix copying
There are a few places in the code where we use PREFIX_COPY(_IPV4/IPV6)
macro to copy a prefix. Let's always use prefix_copy function for this.

This should fix CID 1482142 and 1504610.

Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2021-06-29 16:11:47 +03:00
Igor Ryzhov
ba88ced84c
Merge pull request #8835 from ranjanyash54/clear_process
ospf6d: "clear ipv6 ospf6 process" command
2021-06-29 11:54:39 +03:00
Donatas Abraitis
7702d0b720
Merge pull request #8911 from donaldsharp/command_node
lib: Add some hash name differentiation for Command Hash's
2021-06-29 11:47:16 +03:00
Karen Schoener
0b4124c18c isisd, ospfd: update interface_link_params callback to check for change
Adding defensive code to the interface_link_params zebra callback
to check if the link params changed before taking action.

Signed-off-by: Karen Schoener <karen@voltanet.io>
2021-06-28 10:32:52 -04:00
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