Commit graph

48 commits

Author SHA1 Message Date
Christian Hopps 63ca751c11 lib: convert filters to mgmtd
Signed-off-by: Christian Hopps <chopps@labn.net>
2024-01-26 12:34:23 -05:00
Christian Hopps 2c01083d35 lib: all: remove './' from xpath 22% speedup
fixes #8299

Signed-off-by: Christian Hopps <chopps@labn.net>
2023-11-29 14:37:23 -05:00
Donald Sharp 32894bf8af
Merge pull request #13024 from opensourcerouting/fix/bgpd_prefix-list_changes_not_affected
lib: Adjust only any flag for prefix-list entries if destroying
2023-03-18 07:31:12 -04:00
Donatas Abraitis 61c07b9d43 lib: Adjust only any flag for prefix-list entries if destroying
Before this patch, if we destroy `any` flag for a prefix-list entry, we always
set destination as 0.0.0.0/0 and/or ::/0.

This means that, if we switch from `ip prefix-list r1-2 seq 5 deny any` to
`ip prefix-list r1-2 seq 5 permit 10.10.10.10/32` we will have
`permit any` eventually, which broke ACLs.

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2023-03-17 14:54:39 +02:00
Donald Sharp e2e8f8dd51 lib: Speedup prefix-list readin by a large factor
Reading in prefix-lists is reading in the specified
prefix list and validating that the prefix is unique
2 times.  This makes no sense.  Relax the requirement
that a prefix list can limit this as well as completely
remove this check.  Validation then just becomes
does this prefix-list specified actually make sense
and that is taken care of by the the cli code.

Reading in prefix-lists was looking for duplicate prefixes
2 times instead of doing it just one time.  Let's just
not do it at all.

By doing this change, The code changes from never
completing for a 27k long prefix-list to taking
just under 30 seconds, with 4 daemons processing
this data.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2023-03-16 10:40:35 -04:00
David Lamparter acddc0ed3c *: auto-convert to SPDX License IDs
Done with a combination of regex'ing and banging my head against a wall.

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2023-02-09 14:09:11 +01:00
David Lamparter ae08de9f42 *: fix non-const northbound XPath format strings
Passing a pre-formatted buffer in these places needs a `"%s"` in front
so it doesn't get formatted twice.

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2023-01-27 12:01:20 +01:00
Donald Sharp 05a95ab8ad lib: Prevent Uninitialized usage of data
Valgrind is reporting that prefix is being used uninitialized.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2022-07-16 18:59:51 -04:00
Donald Sharp f0a5b4cb19 lib: Use AF_UNSPEC intead of setting to 0
Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2022-02-07 13:21:55 -05: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
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
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
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
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 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
Chirag Shah fae6021583 lib: consolidate plist nb callbacks
Signed-off-by: Chirag Shah <chirag@nvidia.com>
2021-03-03 19:47:56 -08:00
Chirag Shah b12bcae462 lib: fix plist le ge reset value
merge conflict leads to incorrect reset value for
prefix-list less than and greater than equal values.

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

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

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

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

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

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

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

Signed-off-by: Chirag Shah <chirag@nvidia.com>
2021-03-01 16:04:31 -08:00
Rafael Zalamena 54d153f786 lib: disallow prefix list duplicated values
Don't allow users to create multiple entries in the same list with the
same value to keep the behavior previously to northbound migration.

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

Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
2020-12-04 18:11:45 -03:00
Donald Sharp e3a48b60e2 lib: Relax usage of ip prefix-list A.B.C.D/M ge Y
Currently the prefix length M must be less than Y.
Relax this restriction to allow M to be less than or equal
to Y.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2020-10-17 13:36:19 -04:00
Rafael Zalamena b1993be687 lib: fix cisco access list wildcard usage
Don't attempt to compress the wildcard information to fit a `/M`, but
use its own full 4 byte field.

Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
2020-10-04 07:05:17 -03:00
Santosh P K 371ded520b
Merge pull request #6987 from Niral-Networks/acl_fix
lib, ospf : Fix when redist is performed with route-map using access-list
2020-09-03 09:51:21 +05:30
Kaushik 1eb17c771b lib : Fix when redist is performed with route-map using access-list.
1. Added new API for add/delete acl with route map notify.

Co-authored-by: harios <hari@niralnetworks.com>
Signed-off-by: Kaushik <kaushik@niralnetworks.com>
2020-08-31 04:25:10 -07:00
Rafael Zalamena 0ed507dda0 lib: refactory cisco access list net wildcard
Wildcards bits have the opposite representation of a network mask,
example:

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

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

Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
2020-08-26 12:50:07 -03:00
Rafael Zalamena 8bc38cbd9a lib: show prefix error message on command failure
Use `args->errmsg` instead of just `zlog_info` for registering the error
so the users don't need to check their log files.

Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
2020-08-13 19:59:47 -03:00
Rafael Zalamena 375d157f0e lib,yang: merge cisco/zebra access list styles
Merge the cisco style access list with zebra's logic so we can mix both
types of rules while keeping the commands.

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

Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
2020-07-19 15:27:56 -03:00
David Lamparter 3efd0893d0 *: un-split strings across lines
Remove mid-string line breaks, cf. workflow doc:

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

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

Signed-off-by: David Lamparter <equinox@diac24.net>
2020-07-14 10:37:25 +02:00
Rafael Zalamena 664ae7953a lib: filter remove unused variable
Remove variable that is not being used.

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

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

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

Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
2020-06-05 16:42:11 -03:00
Rafael Zalamena cf4472c4f7 lib: implement additional CLI prefix list check
Changes:
- Move the `TODO` to the appropriated place and hint how to resolve
  it.
- Apply mask to prefix when storing it in the data structures. We
  can't just add a validation for it otherwise it will break old
  CLIs.

Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
2020-06-05 14:36:54 -03:00
Rafael Zalamena 81b5042285 lib: fix route map crash on prefix list removal
Changes:
- Refactor list entry deletion to use a function that properly notifies
  route map on deletion (fixes a heap-use-after-free).
- Prefix list entry wild card sets `le` to maximum IP mask value and
  `any` is a boolean.
- Fix prefix list trie removal order (in `prefix_list_entry_update_start`).
- Let only the `any` callback change the value of field `any`.

Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
2020-06-05 14:36:54 -03:00
Rafael Zalamena 744ad1afb4 lib: properly apply prefix list entries
After the commands started working I noticed that prefix lists were
still not working and displaying incorrect information in
`show ip prefix-list`.

Turns out `any` must be set to `0` when a prefix is set and the prefix
entry **must** be installed in the prefix list head.

Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
2020-06-05 14:36:53 -03:00
Rafael Zalamena a7b2821884 lib: fix prefix list installation
Based on the function `prefix_list_entry_add` and
`prefix_list_entry_delete` it was created two functions to replicate
its functionality without the assumption we are always alocating a new
prefix list entry.

Since the prefix list entry is stored in the YANG private data
structures, we want to avoid the allocation/free of memory that is
hold by the schema.

Every time a prefix list entry values change we must call
`prefix_list_entry_update_start` to uninstall the entry from prefix
list internal structures and then call
`prefix_list_entry_update_finish` to put them back.

The variable `installed` in the prefix list entry tracks the
installation status of the internal structure. It is possible that a
user unconfigures or forgets to add a `prefix` value and so we can't
install the entry until then.

Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
2020-06-05 14:36:53 -03:00
Rafael Zalamena 4362a7681d lib: fix prefix list mask length check
Implement the restriction from the old CLI to northbound.

Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
2020-06-05 14:36:53 -03:00
Rafael Zalamena cc82bcc161 lib: fix prefix list description command
Changes:
- Use `description` on CLI but `remark` on YANG like access-list (also
  because `description` is a reserved word).
- Rename YANG model field and northbound code.
- Fix wrong sequence type get.
- Fix wrong action XPath in action callback.
- Fix wrong concat in (ipv6|mac) access-list.

Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
2020-06-05 14:36:53 -03:00
Rafael Zalamena 1d3c4b664d lib: migrate filter configuration writer
Use northbound to write the configuration from now on. While here, fix
how `exact-match` configuration is being created.

Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
2020-06-05 14:36:53 -03:00
Rafael Zalamena ff94358e54 lib: fix rebase conflicts
Changes:
- Remove unused variable.
- Make prototypes static like the declaration.
- Fix new compilers complaint about uninitialized values.
- Fix new compilers complaint about small buffer for `snprintf` concatenation.

Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
2020-06-05 14:36:52 -03:00
Rafael Zalamena fb8884f355 lib: fix northbound conflicts
Changes:
- Use the northbound callback prototypes.
- Re-implement the removed function: `ipv4_network_addr` (more
  information: https://github.com/FRRouting/frr/pull/5535 )

Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
2020-06-05 14:36:52 -03:00
Rafael Zalamena 4470143be0 lib: implement filter northbound
Implement all access-list and prefix-list northbound callbacks.

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