Commit graph

96 commits

Author SHA1 Message Date
Piotr Suchy 70e5005cba lib, vtysh, topotests: fix 'show ip[v6] access-list ... json' formatting
Similarly to recently fixed 'show ip[v6] prefix-list ...' - PR#15750,
json output is not valid for 'show ip[v6] access-list ... json' commands,
as it goes through all the running daemons and for each one it calls
'filter_show' creating a new json object. To aggreagate the output
and create a valid json that can later be parsed, the commands were
moved to vtysh and formatted accordingly

Signed-off-by: Piotr Suchy <piotrsuchy@proton.me>
2024-05-14 13:22:20 +02:00
Igor Ryzhov a9460ae713 lib: fix access-list entry update
When an access-list entry is updated, current NB code calls notification
hooks for each updated field. It means that when multiple fields of an
entry are changed in a single commit, the hooks are run with an interim
state of an access-list instead of a final one. To fix the issue, we
should call the hooks once, after all fields of an entry are updated.

Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2024-02-26 01:04:57 +02:00
Christian Hopps 63ca751c11 lib: convert filters to mgmtd
Signed-off-by: Christian Hopps <chopps@labn.net>
2024-01-26 12:34:23 -05: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 b5bb6c6764 lib: use json-printf in filter code
(This is mostly just to exercise the code, the actual replacement needs
to be a cocci script.)

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2021-11-17 16:01:30 +01:00
David Lamparter ad9df66ce2 lib: use vty_json()
Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2021-11-17 16:01:30 +01:00
Donatas Abraitis c60dec369a lib: Add autocomplete for access-lists
Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
2021-10-31 20:26:06 +02:00
Igor Ryzhov d555177021
Merge pull request #9751 from ewlumpkin/comment_spelling_fixes
lib: fix spelling nits in more lib files' comments
2021-10-14 02:05:44 +03:00
Igor Ryzhov 7e86999140 *: cleanup number-named access-lists in CLI
There's no more difference between number-named and word-named access-lists.
This commit removes separate arguments for number-named ACLs from CLI.

Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2021-10-08 19:25:41 +03:00
ewlumpkin 214d8a60e1 lib: fix spelling nits in more lib files
Signed-off-by: ewlumpkin <ewlumpkin@gmail.com>
2021-10-05 21:42:57 +00: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
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 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
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
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
David Lamparter bf8d3d6aca *: require semicolon after DEFINE_MTYPE & co
Back when I put this together in 2015, ISO C11 was still reasonably new
and we couldn't require it just yet.  Without ISO C11, there is no
"good" way (only bad hacks) to require a semicolon after a macro that
ends with a function definition.  And if you added one anyway, you'd get
"spurious semicolon" warnings on some compilers...

With C11, `_Static_assert()` at the end of a macro will make it so that
the semicolon is properly required, consumed, and not warned about.

Consistently requiring semicolons after "file-level" macros matches
Linux kernel coding style and helps some editors against mis-syntax'ing
these macros.

Signed-off-by: David Lamparter <equinox@diac24.net>
2021-03-17 06:18:17 +01:00
Donatas Abraitis af3b34f690 lib: Convert inet_ntoa to %pI4
Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
2020-10-22 15:32:50 +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 e0caeadd48 lib: fix filter northbound double removal
Don't auto remove filter main access list data structure, it has to be
done manually (or via northbound).

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
Rafael Zalamena 4cf2450162 lib: export access-lists shared functions
These functions are going to be used by the new filter northbound
implementation.

Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
2020-06-05 14:31:26 -03:00
Donald Sharp 4eeb00b020 lib: Allow deletion of some access-lists
Recent rework of access lists to allow sequence numbers
accidently introduced the inability to delete some
access lists.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2020-06-03 20:01:48 -04:00
Donatas Abraitis 7d16d76f4c lib: Delete the entire access-list only if there are no more entries
When you enter the access-list with the same sequence number but with a
different prefix AND access-list has only a single entry, then the entry
is deleted and the whole access-list is deleted.

That means that "replace entry" never be re-inserted.

With fix:
```
~# vtysh -c 'c' -c 'access-list 1 seq 10 permit 127.0.0.10/32'
~# vtysh -c 'sh run' | grep access-list
access-list 1 seq 10 permit 127.0.0.10/32
~# vtysh -c 'c' -c 'access-list 1 seq 10 permit 127.0.0.20/32'
~# vtysh -c 'sh run' | grep access-list
access-list 1 seq 10 permit 127.0.0.20/32
~# vtysh -c 'c' -c 'access-list 1 seq 11 permit 127.0.0.11/32'
~# vtysh -c 'sh run' | grep access-list
access-list 1 seq 10 permit 127.0.0.20/32
access-list 1 seq 11 permit 127.0.0.11/32
~# vtysh -c 'c' -c 'no access-list 1 seq 10 permit 127.0.0.20/32'
~# vtysh -c 'sh run' | grep access-list
access-list 1 seq 11 permit 127.0.0.11/32
~#
```

Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
2020-04-27 12:13:48 +03:00
Donatas Abraitis 7351b95754 lib: Convert access_list_empty to bool
Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
2020-04-27 12:13:04 +03:00
Donald Sharp 50cf5243c1 lib: prefix must be a valid pointer at this point
Coverity does not understand how our CLI works.  Make it
happy that we have tested it's existence

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2020-04-16 20:17:22 -04:00
David Lamparter f4b8291fcb *: move CLI node names to cmd_node->name
And again for the name.  Why on earth would we centralize this, just so
people can forget to update it?

Signed-off-by: David Lamparter <equinox@diac24.net>
2020-04-16 12:53:59 +02:00
David Lamparter 612c2c15d8 *: remove second parameter on install_node()
There is really no reason to not put this in the cmd_node.

And while we're add it, rename from pointless ".func" to ".config_write".

[v2: fix forgotten ldpd config_write]

Signed-off-by: David Lamparter <equinox@diac24.net>
2020-04-16 12:53:00 +02:00
David Lamparter 249a771b63 *: remove cmd_node->vtysh
The only nodes that have this as 0 don't have a "->func" anyway, so the
entire thing is really just pointless.

Signed-off-by: David Lamparter <equinox@diac24.net>
2020-04-16 12:53:00 +02:00
David Lamparter 62b346eefa *: clean up cmd_node initializers
... and use named assignments everywhere (so I can change the struct.)

Signed-off-by: David Lamparter <equinox@diac24.net>
2020-04-16 12:53:00 +02:00
Donald Sharp 5037cc3eb4 lib: Cleanup set but unused variables
There existed some variables set but never used.  Clean this up.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2020-02-27 09:41:58 -05:00
Donatas Abraitis 752022670a *: Remove break after return
Just a deadcode.

Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
2020-02-13 15:39:54 +02:00
Donatas Abraitis 975a328e2e *: Replace s_addr 0 => INADDR_ANY
Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
2020-02-06 09:00:12 +02:00
Quentin Young e1b36e132b *: remove null check before XFREE
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2020-02-04 13:19:37 -05:00
Quentin Young b3ba5dc7fe *: don't null after XFREE; XFREE does this itself
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2020-02-03 11:22:13 -05:00
David Lamparter eb51bb9b1f lib: random unused bits cleanup
Signed-off-by: David Lamparter <equinox@diac24.net>
2019-12-14 12:41:19 +01:00
Philippe Guibert 2bf92084b7 lib: no filter operations fix on appropriate access-list name
some vty no operations were not removing the entry of the access-list,
since the access-list name was not retrieved correctly. the index was
not correct for 'no ipv6 access-list WORD' operations, but also for one 'no
access-list WORD [..] any' operation.

PR=66244
Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
Acked-by: Alain Ritoux <alain.ritoux@6wind.com>
2019-11-19 13:33:36 +01:00
Donald Sharp d06244b7d4 lib: Coverity SA doesn't trust the CLI
Fix with some asserts to show Coverity SA that we mean
real(:trademark:) business.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2019-10-16 13:38:29 -04:00
David Lamparter fefa5e0ff5 *: fix ctype (isalpha & co.) casts
The correct cast for these is (unsigned char), because "char" could be
signed and thus have some negative value.  isalpha & co. expect an int
arg that is positive, i.e. 0-255.  So we need to cast to (unsigned char)
when calling any of these.

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2019-08-06 16:54:52 +02:00
Donatas Abraitis 358189ad83 filter: Introduce sequence number for access-list
Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
2019-07-08 11:05:31 +03:00
Quentin Young 9f5dc3192e *: remove casts of XMALLOC / XCALLOC
No cast necessary for void *

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2019-02-25 23:00:46 +00:00
Quentin Young 0a22ddfbb1 *: remove null check before XFREE
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2019-02-25 23:00:46 +00:00
Ruben Kerkhof 4d762f2607 Treewide: use ANSI function definitions
Signed-off-by: Ruben Kerkhof <ruben@rubenkerkhof.com>
2019-01-24 11:21:59 +01:00
Quentin Young 6163c6cca1 lib: change M:A:C to X:X:X:X:X:X
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2018-10-24 21:44:33 +00:00
Mark Stapp 123214efb8 libs, daemons: use const in route-map apply
Use 'const prefix *' in route-map apply apis; led to some
corresponding changes in several daemons.

Signed-off-by: Mark Stapp <mjs@voltanet.io>
2018-07-23 10:34:35 -04:00
F. Aragon 2e1cc43679
eigrpd lib pimd zebra: dead code (PVS-Studio)
Signed-off-by: F. Aragon <paco@voltanet.io>
2018-07-06 01:10:15 +02:00
Quentin Young d7c0a89a3a
*: use C99 standard fixed-width integer types
The following types are nonstandard:
- u_char
- u_short
- u_int
- u_long
- u_int8_t
- u_int16_t
- u_int32_t

Replace them with the C99 standard types:
- uint8_t
- unsigned short
- unsigned int
- unsigned long
- uint8_t
- uint16_t
- uint32_t

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2018-03-27 15:13:34 -04:00
Mitesh Kanjariya 8367c32764 bgpd: Intialize all the variables used in argv_find.
Ticket: CM-17706
Review: CCR-6639
Testing: Manual (test failing in min test for ARM)

Signed-off-by: Mitesh Kanjariya <mitesh@cumulusnetworks.com>
2017-09-20 14:56:23 -07:00
David Lamparter 3b0f6068a8 lib: some final MAC access-list fixes
- couldn't load back written configs because it was trying to parse
  "any" as MAC address
- don't need special-casing in filter_match_zebra(), exact is going to
  be 0 for AF_ETHERNET anyway
- some vty formatting was slightly different
- is_zero_mac now static to prefix.c

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2017-08-09 20:30:34 +02:00