summaryrefslogtreecommitdiff
path: root/lib
AgeCommit message (Collapse)Author
2021-08-26Merge pull request #9186 from FRRouting/mergify/bp/stable/8.0/pr-8637Donald Sharp
Pim vrf acl fixes (backport #8637)
2021-08-24Merge pull request #9424 from FRRouting/mergify/bp/stable/8.0/pr-9385Mark Stapp
bgpd: fix segfault when re-adding "match evpn default-route" rule (backport #9385)
2021-08-21lib, pimd: add address match mode to prefix listsDavid Lamparter
... 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> (cherry picked from commit 2b6b16fc21d35693914231509c8710eff6a58c4a)
2021-08-18Merge pull request #9425 from FRRouting/mergify/bp/stable/8.0/pr-9365Martin Winter
lib: fix prefix-list duplication check (backport #9365)
2021-08-17lib: fix prefix-list duplication checkIgor Ryzhov
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> (cherry picked from commit 667dcc277c15c0bddc785f9b949d658f8d815818)
2021-08-17bgpd: fix segfault when re-adding "match evpn default-route" ruleIgor Ryzhov
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> (cherry picked from commit 30475121ad590f8e44ebb2601776ae94df976069)
2021-08-17lib: Scan lib/resolver.c only when c-ares is installedJohn W. O'Brien
Scan lib/resolver.c only when c-ares is installed Signed-off-by: John W. O'Brien <john@saltant.com> (cherry picked from commit 433d9af2a6463d975cd746b1013f6cbe675fc2ab)
2021-08-16bgpd: Keep extcommunity bandwidth commands persistent in route-mapsDonatas Abraitis
~/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> (cherry picked from commit 71bdae66b2c105302f7af9fc0c1deb657e2418d9)
2021-08-03lib, zebra: Preserve user-configured VRF on netns deletionXiao Liang
Don't clear VRF's user-configured flag when netns is deleted. Signed-off-by: Xiao Liang <shaw.leon@gmail.com> (cherry picked from commit 6910315f6f3ddd66d8929cb82deaf96d13a2bfbf)
2021-07-25Merge pull request #9172 from FRRouting/mergify/bp/stable/8.0/pr-8864Donatas Abraitis
lib: fix interface configuration after vrf change (backport #8864)
2021-07-25Merge pull request #9173 from FRRouting/mergify/bp/stable/8.0/pr-8824Martin Winter
isisd, ospfd: update interface_link_params callback to check for change (backport #8824)
2021-07-24isisd, ospfd: update interface_link_params callback to check for changeKaren Schoener
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> (cherry picked from commit 0b4124c18cb826849f18af58dbc712db7d14b993)
2021-07-24lib: fix interface configuration after vrf changeIgor Ryzhov
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> (cherry picked from commit 763725cd5e431cb4f4ec385e35b312cc7807163a)
2021-07-24*: unify prefix copyingIgor Ryzhov
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> (cherry picked from commit b08dcc3f3f0b128b4662f3be86eb53075e93ac9f)
2021-07-24Merge pull request #9157 from FRRouting/mergify/bp/stable/8.0/pr-9105Martin Winter
vtysh, lib, zebra: fix exit from link-params and pseudowire nodes (backport #9105)
2021-07-23build: fix `AM_LDFLAGS` usage (and gcov)David Lamparter
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: 0c4285d77eb ("build: properly split CFLAGS from AC_CFLAGS") Signed-off-by: David Lamparter <equinox@opensourcerouting.org> (cherry picked from commit 63116a7008706988136785ffa011cefee0355193)
2021-07-23lib, zebra: fix exit from link-params nodeIgor Ryzhov
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> (cherry picked from commit d9331fc67c3c68302930f64fada992512e18f7d2)
2021-07-22lib: remove vrf-interface config when removing the VRFIgor Ryzhov
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> (cherry picked from commit f5eef2d5a8a471fe6e4ec4f6acfa3dbf190eda5d)
2021-07-08lib: Allow ZAPI_MESSAGE_OPAQUE_LENGTH length of dataDonald Sharp
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> (cherry picked from commit 3b1849be3211bdc7c53bdeb0d982863dfe0284d0)
2021-06-19Merge pull request #8882 from idryzhov/8.0-backports-06-18Donald Sharp
8.0 backports
2021-06-19lib: remove pure attribute from functions that modify memoryIgor Ryzhov
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> (cherry picked from commit 4f08c715db6893ff439d0a39bf4506cd26256d13)
2021-06-18lib: cleanup and stop grpc pthreadMark Stapp
At shutdown, try to stop the grpc module and its dedicated pthread cleanly. Signed-off-by: Mark Stapp <mjs@voltanet.io>
2021-06-18lib: terminate default vrf lastStephen Worley
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-18Merge pull request #8858 from FRRouting/mergify/bp/dev/8.0/pr-8838Donald Sharp
lib: do not attempt to create default nodes from NULL tree node (backport #8838)
2021-06-15lib: do not attempt to create default nodes from NULL tree nodeChristian Hopps
Perform same NULL check for dependent node creation code too. Signed-off-by: Christian Hopps <chopps@labn.net> (cherry picked from commit 4da08e016b5753558ffe61db532af8a2f9b6a8a5)
2021-06-09lib, ospfd, ospf6d: fix logging of pointer addressesRenato Westphal
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-08lib: fix address sanitizer crash on `find`Rafael Zalamena
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-08zebra: fix config after exit from vrfIgor Ryzhov
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-08lib: fix default ttl for single-hop bfd sessionsIgor Ryzhov
The TTL field is actually the number of hops, not a TTL. Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2021-06-08lib: fix bfd multihopIgor Ryzhov
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-08lib: fix output of "list" and "find" commandsIgor Ryzhov
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-08lib, vtysh: reduce code duplicationIgor Ryzhov
Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2021-06-08lib: fix binding to a vrfIgor Ryzhov
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-06-08Merge pull request #8791 from LabNConsulting/chopps/backport-always-batchDonald Sharp
northbound: KISS always batch yang config (file read), it's faster
2021-06-05lib: fix threading bug in GRPC codeChristian Hopps
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> (cherry picked from commit b680134e1122cdbb67f5c6ed158ee712255ee3cc)
2021-06-03northbound: KISS always batch yang config (file read), it's fasterChristian Hopps
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-03lib: logic and macro cleanup in frr_zmq shimMark Stapp
Fix a couple of logic/macro issues in the frr_zmq shim module. Signed-off-by: Mark Stapp <mjs@voltanet.io>
2021-06-03lib: use public task-scheduling apisMark Stapp
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-06-01lib: Time to remove CONFDATE blockDonatas Abraitis
Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com> (cherry picked from commit ef3b48cfe1c2516c6c6490fc38682a7f640b534b)
2021-05-27lib: fix missing newlineIgor Ryzhov
Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2021-05-27lib: fix northbound merge code (libyang)Christian Hopps
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-27lib: fix coverity warningsIgor Ryzhov
CID 1504894 Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2021-05-26lib: fix handling of rmap prefix-tree default nodeTrey Aspelund
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> (cherry picked from commit 4718791c8f7101379f99fa7174e8ccaf80573433)
2021-05-17lib: libyang2 add missed conversionChristian Hopps
Signed-off-by: Christian Hopps <chopps@labn.net>
2021-05-14Merge pull request #8144 from LabNConsulting/chopps/ly2Martin Winter
libyang2
2021-05-13lib: adapt to version 2 of libyangChristian Hopps
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-13Merge pull request #8659 from mjstapp/fix_connected_multiDonald Sharp
lib,zebra: Use a flag to track down status for connected addrs
2021-05-12lib,zebra: Use a flag to track down status for connected addrsMark Stapp
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-11lib: Add ZCAP_IPC_LOCKDonald Sharp
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-09Merge pull request #8639 from idryzhov/isis-new-bfd-libRafael Zalamena
isisd: rework BFD integration