Commit graph

18 commits

Author SHA1 Message Date
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