summaryrefslogtreecommitdiff
path: root/lib
AgeCommit message (Collapse)Author
2023-03-25lib/clippy: bail out on newline inside stringDavid Lamparter
While C compilers will generally process strings across lines, we really don't want that. I rather treat this as the indication of the typo it probably is warn about it than support this odd C edge case. Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2023-03-25lib/clippy: don't SEGV on invalid tokens in DEFPYDavid Lamparter
The token value can be NULL if we run into something that failed to parse. Throw a Python exception rather than SEGV. Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2023-03-24*: Fixup formatting issues due to reorderingDonald Sharp
All the event changes exposed a bunch of places where we were not properly following our standards. Just clean them up in one big fell swoop. Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2023-03-24*: Convert event.h to frrevent.hDonald Sharp
We should probably prevent any type of namespace collision with something else. Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2023-03-24*: Convert `struct event_master` to `struct event_loop`Donald Sharp
Let's find a better name for it. Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2023-03-24*: Convert thread_master_XXX functions to event_master_XXXDonald Sharp
Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2023-03-24*: Convert THREAD_XXX macros to EVENT_XXX macrosDonald Sharp
Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2023-03-24lib, zebra: Convert THREAD_TIMER_STRLEN to EVENT_TIMER_STRLENDonald Sharp
Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2023-03-24lib: change cpu_thread_history to cpu_event_historyDonald Sharp
Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2023-03-24lib: convert xref_threadsched to xref_eventschedDonald Sharp
Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2023-03-24lib: convert thread internal lists to event internal listsDonald Sharp
Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2023-03-24*: Convert struct thread_master to struct event_master and it's ilkDonald Sharp
Convert the `struct thread_master` to `struct event_master` across the code base. Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2023-03-24*: Convert a bunch of thread_XX to event_XXDonald Sharp
Convert these functions: thread_getrusage thread_cmd_init thread_consumed_time thread_timer_to_hhmmss thread_is_scheduled thread_ignore_late_timer Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2023-03-24*: Convert thread_should_yield and thread_set_yield_timeDonald Sharp
Convert thread_should_yield and thread_set_yield_time to event_should_yield and event_set_yield_time Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2023-03-24*: Convert thread_timer_remain_XXX to event_timer_remain_XXXDonald Sharp
Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2023-03-24*: Convert thread_execute to event_executeDonald Sharp
Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2023-03-24lib: Convert THREAD_YIELD_TIME_SLOT to EVENT_YIELD_TIME_SLOTDonald Sharp
Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2023-03-24*: Convert thread_fetch and thread_call to event_fetch and event_callDonald Sharp
Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2023-03-24lib: Convert thread_type to event_type and make an enumDonald Sharp
a) Convert thread types to a enum b) Convert MTYPES to EVENT instead of THREAD Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2023-03-24*: Convert thread_cancelXXX to event_cancelXXXDonald Sharp
Modify the code base so that thread_cancel becomes event_cancel Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2023-03-24*: Convert thread_add_XXX functions to event_add_XXXDonald Sharp
Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2023-03-24*: Rename `struct thread` to `struct event`Donald Sharp
Effectively a massive search and replace of `struct thread` to `struct event`. Using the term `thread` gives people the thought that this event system is a pthread when it is not Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2023-03-24*: Rename thread.[ch] to event.[ch]Donald Sharp
This is a first in a series of commits, whose goal is to rename the thread system in FRR to an event system. There is a continual problem where people are confusing `struct thread` with a true pthread. In reality, our entire thread.c is an event system. In this commit rename the thread.[ch] files to event.[ch]. Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2023-03-23Merge pull request #13074 from donaldsharp/hash_clean_and_freeDonatas Abraitis
*: Add a hash_clean_and_free() function
2023-03-22lib: mgmtd: fix build warnings (as error)dev/mgmtdChristian Hopps
Signed-off-by: Christian Hopps <chopps@labn.net>
2023-03-22lib: staticd: vtysh: apply frrbot style requirementsChristian Hopps
Signed-off-by: Christian Hopps <chopps@labn.net>
2023-03-22lib, mgmtd: Add few fixes for commit-check and rollbackPushpasis Sarkar
This commit contains fixes for the following issues found - 'mgmt commit check' issued through 'vtysh -f' was actually commtting the changeset. - On config validation failure backend, mgmtd was not passing the correct error-reason to frontend. - 'mgmt rollback ...' was reverting the change on backend, but config on mgmtd daemon remains intact Signed-off-by: Pushpasis Sarkar <pushpasis@gmail.com>
2023-03-22mgmtd: lib: utilize msglib constructed from the removed codeChristian Hopps
Signed-off-by: Christian Hopps <chopps@labn.net>
2023-03-22lib: new message library for mgmtd client and adaptersChristian Hopps
Signed-off-by: Christian Hopps <chopps@labn.net>
2023-03-21mgmtd: Enroll Staticd as a backend client for MGMTDChristian Hopps
This commmit introduces Staticd as a backend client for the MGMTd framework. All the static commands will be diverted to the MGMT daemon and will use the transactional model to make changes to the internal state. Similar mechanism can be used by other daemons to use the MGMT framework in the future. This commit includes the following functionalities in the changeset: 1. Diverts all the staticd (config only) commands to MGMTd. 2. Enrolls staticd as a backend client to use the MGMT framework. 3. Modify the staticd NB config handlers so that they can be compiled into a library and loaded in the MGMTd process context. Co-authored-by: Pushpasis Sarkar <pushpasis@gmail.com> Co-authored-by: Abhinay Ramesh <rabhinay@vmware.com> Co-authored-by: Ujwal P <ujwalp@vmware.com> Signed-off-by: Yash Ranjan <ranjany@vmware.com>
2023-03-21mgmtd: Add MGMT Transaction FrameworkYash Ranjan
This commit introduces the MGMT Transaction framework that takes management requests from one (or more) frontend client sessions, translates them into transactions and drives them to completion in co-oridination with one (or more) backend client daemons involved in the request. This commit includes the following functionalities in the changeset: 1. Introduces the actual Transaction module. Commands added related to transaction are: a. show mgmt transaction all 2. Adds support for commit rollback feature which stores upto the 10 commit buffers. Each commit has a commit-id which can be used to rollback to the exact configuration state. Commands supported for this feature are: a. show mgmt commit-history b. mgmt rollback commit-id COMMIT_ID 3. Add hidden commands to enable record various performance metrics: a. mgmt performance-measurement b. mgmt reset-statistic Co-authored-by: Pushpasis Sarkar <pushpasis@gmail.com> Co-authored-by: Abhinay Ramesh <rabhinay@vmware.com> Co-authored-by: Ujwal P <ujwalp@vmware.com> Signed-off-by: Yash Ranjan <ranjany@vmware.com>
2023-03-21mgmtd: Add MGMT Backend Interface FrameworkChristian Hopps
This commit introduces the MGMT Backend Interface which can be used by back-end management client daemons like BGPd, Staticd, Zebra to connect with new FRR Management daemon (MGMTd) and utilize the new FRR Management Framework to let any Frontend clients to retrieve any operational data or manipulate any configuration data owned by the individual Backend daemon component. This commit includes the following functionalities in the changeset: 1. Add new Backend server for Backend daemons connect to. 2. Add a C-based Backend client library which can be used by daemons to communicate with MGMTd via the Backend interface. 3. Maintain a backend adapter for each connection from an appropriate Backend client to facilitate client requests and track one or more transactions initiated from Frontend client sessions that involves the backend client component. 4. Add the following commands to inspect various Backend client related information a. show mgmt backend-adapter all b. show mgmt backend-yang-xpath-registry c. show mgmt yang-xpath-subscription Co-authored-by: Pushpasis Sarkar <pushpasis@gmail.com> Co-authored-by: Abhinay Ramesh <rabhinay@vmware.com> Co-authored-by: Ujwal P <ujwalp@vmware.com> Signed-off-by: Yash Ranjan <ranjany@vmware.com>
2023-03-21mgmtd: Add MGMT Frontend Interface FrameworkChristian Hopps
This commit introduces the Frontend Interface which can be used by front-end management clients like Netconf server, Restconf Server and CLI to interact with new FRR Management daemon (MGMTd) to access and sometimes modify FRR management data. This commit includes the following functionalities in the changeset: 1. Add new Frontend server for clients connect to. 2. Add a C-based Frontend client library which can be used by Frontend clients to communicate with MGMTd via the Frontend interface. 3. Maintain a frontend adapter for each connection from an appropriate Frontend client to facilitate client requests and track one or more client sessions across it. 4. Define the protobuf message format for messages to be exchanged between MGMTd Frontend module and the Frontend client. 5. This changeset also introduces an instance of MGMT Frontend client embedded within the lib/vty module that can be leveraged by any FRR daemon to connect to MGMTd's Frontend interface. The same has been integrated with and initialized within the MGMTd daemon's process context to implement a bunch of 'set-config', 'commit-apply', 'get-config' and 'get-data' commands via VTYSH Co-authored-by: Pushpasis Sarkar <pushpasis@gmail.com> Co-authored-by: Abhinay Ramesh <rabhinay@vmware.com> Co-authored-by: Ujwal P <ujwalp@vmware.com> Signed-off-by: Yash Ranjan <ranjany@vmware.com>
2023-03-21mgmtd: Bringup MGMTD daemon and datastore module supportChristian Hopps
Features added in this commit: 1. Bringup/shutdown new management daemon 'mgmtd' along with FRR. 2. Support for Startup, Candidate and Running DBs. 3. Lock/Unlock DS feature using pthread lock. 4. Load config from a JSON file onto candidate DS. 5. Save config to a JSON file from running/candidate DS. 6. Dump candidate or running DS contents on the terminal or a file in JSON/XML format. 7. Maintaining commit history (Full rollback support to be added in future commits). 8. Addition of debug commands. Co-authored-by: Yash Ranjan <ranjany@vmware.com> Co-authored-by: Abhinay Ramesh <rabhinay@vmware.com> Co-authored-by: Ujwal P <ujwalp@vmware.com> Signed-off-by: Pushpasis Sarkar <pushpasis@gmail.com>
2023-03-21*: Add a hash_clean_and_free() functionDonald Sharp
Add a hash_clean_and_free() function as well as convert the code to use it. This function also takes a double pointer to the hash to set it NULL. Also it cleanly does nothing if the pointer is NULL( as a bunch of code tested for ). Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2023-03-21Merge pull request #13061 from donaldsharp/bfd_use_after_freeDonatas Abraitis
lib: on bfd peer shutdown actually stop event
2023-03-20lib:fix clear route-map cmd using DEFPYSindhu Parvathi Gopinathan
Due to the wrong input argv id, "argv[idx_word]->arg" fetched in-correctly and it clears all the route-maps instead of specific one. Now correct argv id is passed to clear the given route-map counters. Also, use RMAP_NAME which allows to show list of configured route-maps in the system. After Fix:- Ticket:#3407773 Issue:3407773 Testing: UT done Before: TORC11# clear route-map counters <cr> WORD route-map name After: TORC11# clear route-map counters <cr> RMAP_NAME route-map name my-as Signed-off-by: Chirag Shah <chirag@nvidia.com> Signed-off-by: Sindhu Parvathi Gopinathan's <sgopinathan@nvidia.com>
2023-03-20lib: on bfd peer shutdown actually stop eventDonald Sharp
When deleting a bfd peer during shutdown, let's ensure that any scheduled events are actually stopped. ==7759== Invalid read of size 4 ==7759== at 0x48BF700: _bfd_sess_valid (bfd.c:419) ==7759== by 0x48BF700: _bfd_sess_send (bfd.c:470) ==7759== by 0x492F79C: thread_call (thread.c:2008) ==7759== by 0x48E9BD7: frr_run (libfrr.c:1223) ==7759== by 0x1C739B: main (bgp_main.c:550) ==7759== Address 0xfb687a4 is 4 bytes inside a block of size 272 free'd ==7759== at 0x48369AB: free (in /usr/lib/x86_64-linux-gnu/valgrind/vgpreload_memcheck-amd64-linux.so) ==7759== by 0x48BFA5A: bfd_sess_free (bfd.c:535) ==7759== by 0x2B7034: bgp_peer_remove_bfd (bgp_bfd.c:339) ==7759== by 0x29FF8A: peer_free (bgpd.c:1160) ==7759== by 0x29FF8A: peer_unlock_with_caller (bgpd.c:1192) ==7759== by 0x2A0506: peer_delete (bgpd.c:2633) ==7759== by 0x208190: bgp_stop (bgp_fsm.c:1639) ==7759== by 0x20C082: bgp_event_update (bgp_fsm.c:2751) ==7759== by 0x492F79C: thread_call (thread.c:2008) ==7759== by 0x48E9BD7: frr_run (libfrr.c:1223) ==7759== by 0x1C739B: main (bgp_main.c:550) ==7759== Block was alloc'd at ==7759== at 0x4837B65: calloc (in /usr/lib/x86_64-linux-gnu/valgrind/vgpreload_memcheck-amd64-linux.so) ==7759== by 0x48F53AF: qcalloc (memory.c:116) ==7759== by 0x48BF98D: bfd_sess_new (bfd.c:397) ==7759== by 0x2B76DC: bgp_peer_configure_bfd (bgp_bfd.c:298) ==7759== by 0x2B76DC: bgp_peer_configure_bfd (bgp_bfd.c:279) ==7759== by 0x29BA06: peer_group2peer_config_copy (bgpd.c:2803) ==7759== by 0x2A3D96: peer_create_bind_dynamic_neighbor (bgpd.c:4107) ==7759== by 0x2A4195: peer_lookup_dynamic_neighbor (bgpd.c:4239) ==7759== by 0x21AB72: bgp_accept (bgp_network.c:422) ==7759== by 0x492F79C: thread_call (thread.c:2008) ==7759== by 0x48E9BD7: frr_run (libfrr.c:1223) ==7759== by 0x1C739B: main (bgp_main.c:550) tl;dr -> Effectively, in this test setup we have 300 dynamic bgp sessions all of which are using bfd. When a peer collision is detected or we remove the peers, if an event has been scheduled but not actually executed yet the event event was not actually being stopped, leaving the bsp pointer on the thread->arg and causing a crash when it is executed. Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2023-03-19lib: Destroy `any` flag when creating a prefix-list entry with prefixDonatas Abraitis
The same as 61c07b9d43529f69f48ca54f4f0213cff52b5d0a, but forgot to put IPv6 in place. Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2023-03-18Merge pull request #13024 from ↵Donald Sharp
opensourcerouting/fix/bgpd_prefix-list_changes_not_affected lib: Adjust only any flag for prefix-list entries if destroying
2023-03-17lib: Adjust only `any` flag for prefix-list entries if destroyingDonatas Abraitis
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-16lib: Speedup prefix-list readin by a large factorDonald Sharp
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-15lib: adapt clippy to Python 3.8+ init APIDavid Lamparter
The old initialization/config API is deprecated in Python 3.11. Make clippy use the new one added in 3.8 if it's that version or newer. Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2023-03-09lib, bgpd: Add more debugs to GR Capability exchangeDonald Sharp
a) Make it legible what type of message is being passed back and forth instead of having to guess it from the insufficient debugs b) Make it explicit which bgp instance is sending this data c) Cleanup bgp_zebra_update to have a cleaner api Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2023-02-27Merge pull request #12866 from anlancs/lib/dotas-zeroDonatas Abraitis
lib: some ASNUMs should be forbidden
2023-02-24lib: some ASNUMs should be forbiddenanlan_cs
In current code, some ASNUMs with redundant zero are legal, e.g. "1.01", "01.1", "1.001", "001.1", and more. They should be forbidden. Signed-off-by: anlan_cs <vic.lan@pica8.com>
2023-02-24Merge pull request #12889 from LabNConsulting/chopps/fix-nb-context-argDonald Sharp
lib: fix init. use of nb_context to be by value not by reference
2023-02-24Merge pull request #12751 from Pdoijode/pdoijode/ospf-vrf-neighbor-detail-1Donatas Abraitis
ospfd: Added missing fields and option to query specific neighbor in VRF
2023-02-23lib: fix init. use of nb_context to be by value not by referenceChristian Hopps
Pass context argument by value on initialization to be clear that the value is used/saved but not a pointer to the value. Previously the northbound code was incorrectly holding a pointer to stack allocated context structs. However, the structure definition also had some musings (ifdef'd out code) and a comment that might be taken to imply that user data could follow the structure and thus be maintained by the code; it won't; so it can't; so get rid of the disabled misleading code/text from the structure definition. The common use case worked b/c the transaction which cached the pointer was created and freed inside a single function call (`nb_condidate_commit`) that executed below the stack allocation. All other use cases (grpc, confd, sysrepo, and -- coming soon -- mgmtd) were bugs. Signed-off-by: Christian Hopps <chopps@labn.net>
2023-02-23lib, bgpd: bmp was not specifying l2vpn afiDonald Sharp
The l2vpn afi was not being properly displayed when a show run was being issued. Add a afi2str_lower function and use it. Fixes: #12867 Signed-off-by: Donald Sharp <sharpd@nvidia.com>