Commit graph

35 commits

Author SHA1 Message Date
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
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
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 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
varasteh b3511a7247 [filter]: change return code for errors
CMD_WARNING is replaced by CMD_WARNING_CONFIG_FAILED

Signed-off-by: varasteh <mahdy.varasteh@gmail.com>
2021-02-08 16:02:32 +03:30
Rafael Zalamena 866f48f2df lib: silently ignore duplicated values
Keep the previous CLI behavior of silently ignoring access lists which
contain the same value.

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

Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
2020-12-04 18:12:58 -03:00
Rafael Zalamena 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
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 070783e693 lib: fix a crash in zebra style access list
When removing an IPv4 prefix configuration the wrong amount of bytes
will be read from `struct prefix_ipv4` from `DEFPY`, so lets use the
proper function for this.

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

YANG users will not notice this change.

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

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

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

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

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2020-08-03 15:17:03 -03:00
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 a26305a8ba build: fix frr-format warnings
Unfortunately, the way the frr-format plugin is set up, snprintf() with
PRId64 can generate false warnings :|.  Easy workaround is to use
snprintfrr().

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2020-06-19 01:09:10 +02:00
Rafael Zalamena 49e3e49d72 lib: use relative XPath to filter entry attributes
We can avoid a big amount of `snprintf` by using relative XPath in
`nb_cli_apply_changes`.

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

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

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

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

Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
2020-06-05 14:36:54 -03:00
Rafael Zalamena 88b8bfdc8a lib: fix two filter cli problems
- Show the correct cisco style access list extended information.
- `assert` action so static analyzer doesn't complain about possible
  NULL usage.

Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
2020-06-05 14:36:54 -03:00
Rafael Zalamena 25ceb5d807 lib: fix access list mac removal command
Copy & paste mistake: MAC commands need `X:X:X:X:X:X` and not
`X:X::X:X/M` types. Also, MAC access-list don't use `exact-match`.

Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
2020-06-05 14:36:53 -03:00
Rafael Zalamena c7d3de9ff2 lib: add 'no ... remark LINE' commands
Implement the commands `no ... remark LINE` for cisco and zebra style
access lists to match `ipX prefix-list description LINE` command set.

It useful when you just want to go through the command history and
prepend a `no` to a `remark` or `description` command. Example:

```
access-list foo remark just another acl
!
! ...
!
! Suddenly we decide we no longer think that remark is useful,
! lets press up key to find that line in history and append `no`:
no access-list foo remark just another acl
```

Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
2020-06-05 14:36:53 -03:00
Rafael Zalamena 1d7b156e7e lib: bump filter CLI XPath buffers size
Bump the size of the buffers so the new compilers don't complain about
possible truncation:
```
lib/filter_cli.c: In function ‘ipv6_prefix_list_magic.isra.0’:
lib/filter_cli.c:1336:5: error: ‘%lld’ directive output may be truncated writing between 1 and 20 bytes into a region of size between 16 and 527 [-Werror=format-truncation=]
 1336 |     "%s/entry[sequence='%" PRId64 "']", xpath, sseq);
      |     ^~~~~~~~~~~~~~~~~~~~~~
lib/filter_cli.c:1336:25: note: format string is defined here
 1336 |     "%s/entry[sequence='%" PRId64 "']", xpath, sseq);
lib/filter_cli.c:1336:5: note: directive argument in the range [-9223372036854775803, 9223372036854775807]
 1336 |     "%s/entry[sequence='%" PRId64 "']", xpath, sseq);
      |     ^~~~~~~~~~~~~~~~~~~~~~
```

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 63895e83cb lib: fix filter northbound crash when batching
Look up next sequence number by checking XPath instead of trying to
access unallocated context data structures.

This only applies for creation, on destroy the data structures must be
there.

Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
2020-06-05 14:36:52 -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 89b7c834a5 lib: migrate prefix-list to use northbound
Implement all northbound CLI commands for prefix lists.

Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
2020-06-05 14:36:52 -03:00
Rafael Zalamena b62578bd9b lib: migrate filter CLI to use northbound
Migrate all filter commands to use the newly implemented northbound.

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