summaryrefslogtreecommitdiff
path: root/lib/plist.c
AgeCommit message (Collapse)Author
2023-09-22lib: don't announce prefix delete for duplicatesRafael Zalamena
When deleting a duplicated prefix list entry don't announce the change to route map listeners, otherwise they will be removing rules that shouldn't be removed causing the prefix that still exist in the prefix-list to be not evaluated anymore. Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
2023-09-22Revert "lib : fix duplicate prefix list delete"Rafael Zalamena
This reverts commit 394ed767e7207805a6d916b01b1f1d4743c03dd1.
2023-05-09lib : fix duplicate prefix list deleteSamanvitha B Bhargav
Problem statement: Step-1: pl1 - 10.10.10.10/24 with deny sequence 1 Step-2: pl1 - 10.10.10.10/24 with permit sequence 2 Step-3: pl1 - 20.20.20.20/24 with deny sequence 1 Now we end up deleting permit sequence 2, which might blackhole the traffic. RCA: Whenever we have multiple prefix lists, having same prefix and different subnet range, delete or replace of prefix list would result in delete of entry in route-map prefix table. Fix: We will skip deleting prefix list entry from routemap prefix table, if we have the multiple prefix lists having same prefix. Signed-off-by: Samanvitha B Bhargav <bsamanvitha@vmware.com>
2023-02-09*: auto-convert to SPDX License IDsDavid Lamparter
Done with a combination of regex'ing and banging my head against a wall. Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2022-10-26build, vtysh: extract vtysh commands from .xrefDavid Lamparter
Rather than running selected source files through the preprocessor and a bunch of perl regex'ing to get the list of all DEFUNs, use the data collected in frr.xref. This not only eliminates issues we've been having with preprocessor failures due to nonexistent header files, but is also much faster. Where extract.pl would take 5s, this now finishes in 0.2s. And since this is a non-parallelizable build step towards the end of the build (dependent on a lot of other things being done already), the speedup is actually noticeable. Also files containing CLI no longer need to be listed in `vtysh_scan` since the .xref data covers everything. `#ifndef VTYSH_EXTRACT_PL` checks are equally obsolete. Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2022-09-14lib: Fix skip of every other plist deletionDonald Sharp
When bulk deleting prefix lists on shutdown the code was calling plist_delete, which removed the item from the master->str list, and then popping the next item on the list and just dropping it on the floor. The pop is not needed. Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2022-04-19lib: Prevent crash after shutdown requestDonald Sharp
Recent commit e92508a741e03b8721ccb3424cbebe4d5476e9d changed the prefix_master->str to a RB tree. This introduced a condition whnere on shutdown the prefix list was removed from the master list and then operated on by passing around a name. Which was then used to lookup the prefix list again when we operated on the code. This change to a RB Tree first deleted the item from the RB tree first thus introducing this crash Crash: (gdb) bt index=0x556c07d59650, pentry=0x556c07d29380) at lib/routemap.c:2397 arg=0x7ffdbf84bc60) at lib/hash.c:267 event=RMAP_EVENT_PLIST_DELETED) at lib/routemap.c:2489 Grab the first item on the list, clean it and then remove it. Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2022-03-11lib: Convert prefix_master->str to a RB TreeDonald Sharp
The prefix_master->str data structure was a sorted list of the prefix names. Not that big of a deal other than insertion and deletion is insanely expensive when you have a large number of unique prefix-lists. In my test config file that I discovered this, I have 587 unique prefix lists spread out acros ~26k lines of prefix-lists. When reading this config file into FRR the read time goes from 690 seconds to 650 seconds. Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2021-12-14bgpd: fix BGP ORF Prefix-length matchingMartin Winter
BGP ORF Prefix list incorrectly rejected list with a GE or LE to match the actual prefix. Signed-off-by: Martin Winter <mwinter@opensourcerouting.org>
2021-11-29Merge pull request #10124 from ton31337/feature/vty_jsonIgor Ryzhov
2021-11-25lib: Convert vty_out to vty_json for JSONDonatas Abraitis
Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
2021-11-25*: Remove unused variablesDonatas Abraitis
Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
2021-11-25lib: Replace prefix2str for JSON to %pFXDonatas Abraitis
Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
2021-11-17lib: use vty_json()David Lamparter
Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2021-10-28lib: Add autocomplete for prefix-list under route-mapsDonatas Abraitis
``` exit1-debian-9(config-route-map)# match ip route-source prefix-list ? <cr> PREFIXLIST_NAME IP prefix-list name p1 p2 ``` Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
2021-08-05bgpd: Fix misleading comments for some partsDonatas Abraitis
Mostly just retrun => return and misleading comments at all. Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
2021-08-02lib: add "json" option to "show ip[v6] prefix-list"Renato Westphal
Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2021-07-06lib: add command to test prefix-list matchDavid Lamparter
While we do have `show ip prefix-list NAME A.B.C.D/M`, that doesn't actually run the prefix list matching code. While the result would hopefully be the same anyway, let's have a way to call the actual prefix list match code and get a result. (As an aside, this might be useful for scripting to do a quick "is this prefix in that prefix list" check.) Signed-off-by: David Lamparter <equinox@diac24.net>
2021-07-06lib, 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>
2021-04-14*: cleanup number-named access-lists and prefix-listsIgor Ryzhov
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-03-24lib: remove "ip prefix-list sequence-number" commandIgor Ryzhov
Before the transition of prefix-lists to northbound, this setting controlled whether sequence numbers were displayed in the config. After the transition, sequence numbers are always displayed in the configuration, and this command only controls the output of the show commands, which is not very useful. This command is not even shown in the config anymore. Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2021-03-22Merge pull request #8121 from opensourcerouting/macro-cleanupDonatas Abraitis
*: require ISO C11 + semicolons after file-scope macros
2021-03-17*: require semicolon after DEFINE_MTYPE & coDavid Lamparter
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-01lib: fix a crash in plist updateChirag Shah
Problem: Prefix-list with mulitiple rules, an update to a rule/sequence with different prefix/prefixlen reset prefix-list next-base pointer to avoid having stale value. In some case the old next-bast's reference leads to an assert in tri (trie_install_fn ) add. bt: (object=0x55576a4c8a00, updptr=0x55576a4b97e0) at lib/plist.c:560 (plist=0x55576a4a1770, pentry=0x55576a4c8a00) at lib/plist.c:585 (ple=0x55576a4c8a00) at lib/plist.c:745 (args=0x7fffe04beb50) at lib/filter_nb.c:1181 Solution: Reset prefix-list next-base pointer whenver a sequence/rule is updated. Ticket:CM-33109 Testing Done: Signed-off-by: Chirag Shah <chirag@nvidia.com> Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
2020-10-17lib: Convert usage of strings to %pFX and %pRNDonald Sharp
Convert over to using the %pFX and %pRN modifiers to output strings to allow us to consolidate on one standard for printing prefixes. Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2020-06-05lib: fix route map crash on prefix list removalRafael Zalamena
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-05lib: properly apply prefix list entriesRafael Zalamena
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-05lib: fix prefix list installationRafael Zalamena
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-05lib: migrate filter configuration writerRafael Zalamena
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-05lib: migrate prefix-list to use northboundRafael Zalamena
Implement all northbound CLI commands for prefix lists. Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
2020-06-05lib: export prefix-lists functionsRafael Zalamena
Export all functions that are going to be used by the northbound. Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
2020-04-20*: sprintf -> snprintfQuentin Young
Replace sprintf with snprintf where straightforward to do so. - sprintf's into local scope buffers of known size are replaced with the equivalent snprintf call - snprintf's into local scope buffers of known size that use the buffer size expression now use sizeof(buffer) - sprintf(buf + strlen(buf), ...) replaced with snprintf() into temp buffer followed by strlcat Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2020-04-16Merge pull request #6135 from opensourcerouting/cli-node-cleanupDonald Sharp
*: clean up the mess that is CLI command nodes
2020-04-16bgpd, lib: Use bool instead of uint8_t for community/prefix-list "any"Donatas Abraitis
That's only 0/1, useful to use just a bool for that. Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
2020-04-16*: move CLI node names to cmd_node->nameDavid Lamparter
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*: remove second parameter on install_node()David Lamparter
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*: remove cmd_node->vtyshDavid Lamparter
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*: clean up cmd_node initializersDavid Lamparter
... and use named assignments everywhere (so I can change the struct.) Signed-off-by: David Lamparter <equinox@diac24.net>
2020-03-29*: fix format string warningsDavid Lamparter
Signed-off-by: David Lamparter <equinox@diac24.net>
2020-03-04*: Use true/false instead of 1/0 when assigning variable for bool typeDonatas Abraitis
Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
2020-02-27lib: Cleanup set but unused variablesDonald Sharp
There existed some variables set but never used. Clean this up. Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2020-02-18lib: Optimizing route-maps - Part-3Naveen Thanikachalam
* This commit implements the code style suggestions from Polychaeta. * This commit also introduces a CLI to toggle the optimization and, a hidden CLI to display the contents of the constructed prefix tree. Signed-off-by: NaveenThanikachalam <nthanikachal@vmware.com>
2020-02-18lib: Optimizing route-maps - Part-1Naveen Thanikachalam
* This commit introduces the building blocks. A per-route-map prefix tree is introduced. This tree will consist of the prefixes defined within the prefix-lists that are added to the match clause of that route-map. Signed-off-by: NaveenThanikachalam <nthanikachal@vmware.com>
2020-02-13*: Remove break after returnDonatas Abraitis
Just a deadcode. Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
2020-02-04*: remove null check before XFREEQuentin Young
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2020-02-03*: don't null after XFREE; XFREE does this itselfQuentin Young
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2019-12-03lib: fix heap buf overflow when adding prefix orfQuentin Young
Don't lose your way Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2019-08-06*: fix ctype (isalpha & co.) castsDavid Lamparter
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-06-20lib: Keep proper count of prefix-list hit-count when usedVisakha Erina
When a prefix-list is applied to a BGP neighbor to deny the learning of specific routes, the hit count is showing 0 for BGP even though the routes are being filtered correctly due to the configured prefix-list. Before fix: c1# show ip prefix-list nag seq 10 ZEBRA: seq 10 permit any (hit count: 0, refcount: 0) BGP: seq 10 permit any (hit count: 0, refcount: 0) c1# show ip prefix-list nag seq 5 ZEBRA: seq 5 deny 1.0.1.0/24 (hit count: 0, refcount: 0) BGP: seq 5 deny 1.0.1.0/24 (hit count: 0, refcount: 0) Fix: Increment the prefix-list's hit count whenever a rule match occurs. After Fix: c1# show ip prefix-list nag seq 10 ZEBRA: seq 10 permit any (hit count: 0, refcount: 0) BGP: seq 10 permit any (hit count: 6, refcount: 0) c1# show ip prefix-list nag seq 5 ZEBRA: seq 5 deny 1.0.1.0/24 (hit count: 0, refcount: 0) BGP: seq 5 deny 1.0.1.0/24 (hit count: 1, refcount: 0) Signed-off-by: Visakha Erina visakha.erina@broadcom.com
2019-06-07lib, pimd, sharpd: Various output string cleanupsDonald Sharp
Various compilers in our CI system were complaining about various auto-conversions. Let's get these cleaned up a bit more. Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>