summaryrefslogtreecommitdiff
path: root/lib/libfrr.h
AgeCommit message (Collapse)Author
2024-07-24lib: mgmtd: fix too early daemon detach of mgmtdChristian Hopps
Correct FRR startup counts on a daemon's vty socket to be open when the parent process exits. The parent process waits for `frr_check_detach()` to be called by the child before exiting. The problem is when the `FRR_MANUAL_VTY_START` flag is set the vty socket was not opened but `frr_check_detach()` was called anyway. Instead add a bool option for `frr_check_detach()` to be called when the socket is opened with `frr_vty_serv_start()`, and do so when "manually" calling said function (i.e., when FRR_MANUAL_VTY_START is set). The `FRR_MANUAL_VTY_START` flag is only set by mgmtd. The reason we wait to open the vty socket is so that mgmtd can parse the various daemon specific config files it has taken over, after the event loop has started, but before we receive any possible new config from `vtysh`. fixes #16362 Signed-off-by: Christian Hopps <chopps@labn.net> (cherry picked from commit be9a6fc0ea8180a4aaa558c5402ea543427e2e7e)
2024-04-09lib: add simple generic version helpersMark Stapp
Add some simple helpers for generic major+minor+sub version values. Signed-off-by: Mark Stapp <mjs@cisco.com>
2024-02-01*: create a single registry of daemons' default port valuesMark Stapp
Create a single registry of default port values that daemons are using. Most of these are vty ports, but there are some others for features like ospfapi and zebra FPM. Signed-off-by: Mark Stapp <mjs@labn.net>
2024-01-27lib: create `frr_daemon_state_{load,save}`David Lamparter
These functions load daemon-specific persistent state from `/var/lib/frr` and supersede open-coded variants of similar calls in ospfd, ospf6d and isisd to save GR state and/or sequence numbers. Unlike the open-coded variants, the save call correctly `fsync()`s the saved data to ensure disk contents are consistent. Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2024-01-27lib: set up `frr_libstatedir`David Lamparter
This needs to be used for persistent state, which currently is misplaced into `/var/run` / `/run` where it gets deleted across reboots. Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2024-01-27build: nuke `ZEBRA_SERV_PATH`David Lamparter
This just unnecessarily complicates things by involving autoconf. Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2024-01-27*: rename `frr_vtydir` to `frr_runstatedir`David Lamparter
Also remove frr_init_vtydir(), just initialize to default. Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2023-05-30lib: mgmtd: add manual vty server start option and use itChristian Hopps
Signed-off-by: Christian Hopps <chopps@labn.net>
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 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*: 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-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-03-07lib: support multiple `--log` optionsDavid Lamparter
Allow simultaneously enabling syslog, stdout and/or file logs. Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2022-01-17lib: add frr_early_init hookDavid Lamparter
To bring up bits that use thread_master before other init happens. Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2021-12-14lib: shuffle around command line optionsDavid Lamparter
New `FRR_NO_SPLIT_CONFIG` flag for newly added daemons where we're just rolling without split config and always expect configs to be loaded via vtysh/integrated config. Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2021-11-11*: Convert quagga_signal_X to frr_signal_XDonald Sharp
Naming functions/data structures more appropriately for the project we are actually in. Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2021-04-22lib: hard-fail creating threads before fork()David Lamparter
Creating any threads before we fork() into the background (if `-d` is given) is an extremely dangerous footgun; the threads are created in the parent and terminated when that exits. This is extra dangerous because while testing, you'd often run the daemon in foreground without `-d`, and everything works as expected. Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2021-04-22lib: add frr_config_pre hookDavid Lamparter
... for any initialization that needs to run after forking, but that would be racy if it were just scheduled on the thread_master (since the config load is also just a thread callback, ordering would be undefined for another scheduled thread callback.) Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2021-04-22lib: rename very_late_init hook to config_postDavid Lamparter
very_late_init doesn't really say what this does, config_post is much more descriptive. (A config_pre is coming in a jiffy.) Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2021-03-17*: require semicolon after FRR_DAEMON_INFO & co.David Lamparter
... again ... Signed-off-by: David Lamparter <equinox@diac24.net>
2021-03-17*: require semicolon after DEFINE_HOOK & co.David Lamparter
See previous commit. Signed-off-by: David Lamparter <equinox@diac24.net>
2021-02-12lib: memorize what fds were open at startupDavid Lamparter
... in case the user does something like `zebra 3>logfile`. Also useful for some module purposes, maybe even feeding config at some point in the future. Signed-off-by: David Lamparter <equinox@diac24.net>
2020-12-01lib: add support for scripts directoryQuentin Young
Specify default via --with-scriptdir at compile time, override default with --scriptdir at runtime. If unspecified, it's {sysconfdir}/scripts (usually /etc/frr/scripts) Signed-off-by: Quentin Young <qlyoung@nvidia.com>
2020-11-18lib: add startup option to limit fdsMark Stapp
Add a startup-time option to limit the number of fds used by the thread/event infrastructure. If nothing is configured, the system ulimit is used. Signed-off-by: Mark Stapp <mjs@voltanet.io>
2020-09-15lib: postpone the sysrepo plugin initializationRenato Westphal
From Sysrepo's documentation: "Note: do not use fork() after creating a connection. Sysrepo internally stores PID of every created connection and this way a mismatch of PID and connection is created". Introduce a new "frr_very_late_init" hook in libfrr that is only called after the daemon is forked (when the '-d' option is used) and after the configuration is read. This way we can initialize the sysrepo plugin correctly even when the daemon is daemonized, and after the Sysrepo CLI commands are processed (only "debug northbound client sysrepo" for now). Fixes #7062 Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2020-03-19treewide: add attribute to functions that do not returnRuben Kerkhof
Signed-off-by: Ruben Kerkhof <ruben@rubenkerkhof.com>
2019-11-30*: make frr_yang_module_info constDavid Lamparter
Signed-off-by: David Lamparter <equinox@diac24.net>
2019-06-04*: Convert over to all -N namespace to change DAEMON_VTY_DIRDonald Sharp
When the user specifies -N namespace allow it to influence the frr_vtydir(DAEMON_VTY_DIR) to have namespace in it's path like so: $frrstate_dir/<namespace> Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2019-05-31lib: Add '--command-log-always` to all daemons startupDonald Sharp
Add 'no log commands' cli and at the same time add a --command-log-always to the daemon startup cli. If --command-log-always is specified then all commands are auto-logged and the 'no log commands' form of the command is now ignored. Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2019-02-11lib: add extern "C" {} blocks to all libfrr headersRenato Westphal
These are necessary to use functions defined in these headers from C++. Signed-off-by: David Lamparter <equinox@diac24.net> Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2018-10-27lib: introduce new northbound APIRenato Westphal
Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2018-10-02watchfrr, lib: cleanup & delay detachingDavid Lamparter
This cleans up watchfrr to be more "normal" like the other daemons in terms of what it does in main(), i.e. using the full frr_*() call set. Also, this changes the startup behaviour on watchfrr to stay attached on the daemon's parent process until startup is really complete. This should allow removing the "watchfrr.started" hack at some point. Signed-off-by: David Lamparter <equinox@diac24.net>
2018-06-19lib: Add --log-level to daemonsDonald Sharp
Add the ability to specify the designated log level at startup. --log-level <emergencies|alerts|critical|errors|warnings|notifications|informational|debugging> Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2018-06-19lib: Add new cli to specify where to output logs on startupDonald Sharp
When we are starting a daemon, allow the user to specify: --log <stdout|syslog|file:file_name> This can be used on early startup to put the log files where the end user wants them to show up. Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2018-06-19lib: Create a thread for reading in the cliDonald Sharp
The read in of cli was happening prior to thread event handling for non-integrated configs. This is interesting for 2 reasons: 1) Read-in of integrated configs was after thread event loop startup, so we had a difference of behavior 2) Read-in can cause a series of events that cause us to attempt to communicate with zebra. The zebra zapi connection only happens after the thread event loop has been started. This can cause data that is being written down to zebra to be lost and no real way to notice that this has happened and to recover gracefully. Modify the code to create a thread event for read in of client config. Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2018-06-19lib: Add ability to retry if backup is specifiedDonald Sharp
If we fail to read in the config file and we have specified a backup of the backup, attempt to read that information. Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2018-06-07bgpd, lib, ospf6d, vtysh: fix possible snprintf possible truncationDonald Sharp
With a new version of clang 6.0, the compiler is detecting more issues where we may be possibly be truncating the output string. Fix by increasing the size of the output string to make the compiler happy. Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2017-08-28lib: add -N/--pathspace optionDavid Lamparter
This allows running the daemons inside of Linux network namespaces without messing with an additional mount/fs namespace (or a ton of options). Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2017-08-24lib: centralized memstats-at-exitDavid Lamparter
adds a new all-daemon "debug memstats-at-exit" command. Also saves memstats to a file in /tmp, useful if a long-running daemon is having weird issues (e.g. in a user install). Fixes: #437 Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2017-08-15*: centralize some exit cleanup into libfrrDavid Lamparter
Start creating a counterpart to frr_init and frr_late_init. Unfortunately, some daemons don't do any exit handling, this doesn't change that just yet. Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2017-08-09Merge remote-tracking branch 'frr/master' into tcp-zebraDavid Lamparter
2017-08-08*: remove --enable-tcp-zebra, rework ZAPI pathDavid Lamparter
This adds "@tcp" as new choice on the -z option present in zebra and the protocol daemons. The --enable-tcp-zebra option on configure is no longer needed, both UNIX and TCP socket support is always available. Note that @tcp should not be used by default (e.g. in an init script), and --enable-tcp-zebra should never have been in any distro package builds, because **** TCP-ZEBRA IS A SECURITY PROBLEM **** It allows arbitrary local users to mess with the routing table and inject bogus data -- and also ZAPI is not designed to be robust against attacks. Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2017-08-02lib: --terminal option for all daemonsDavid Lamparter
This allows, among other things, piping in a configuration from stdin. Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2017-07-17*: reindentreindent-master-afterwhitespace / reindent
indent.py `git ls-files | pcregrep '\.[ch]$' | pcregrep -v '^(ldpd|babeld|nhrpd)/'` Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2017-05-18lib: detangle protocol name/instance from loggingDavid Lamparter
Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2017-05-15*: make consistent & update GPLv2 file headersDavid Lamparter
The FSF's address changed, and we had a mixture of comment styles for the GPL file header. (The style with * at the beginning won out with 580 to 141 in existing files.) Note: I've intentionally left intact other "variations" of the copyright header, e.g. whether it says "Zebra", "Quagga", "FRR", or nothing. Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2017-04-21lib: Add CLI option --moduledir to override default module location (needed ↵Martin Winter
for snap support) Signed-off-by: Martin Winter <mwinter@opensourcerouting.org>
2017-03-25lib: add hook infrastructureDavid Lamparter
Please refer to lib/hook.h for a description/documentation. Signed-off-by: David Lamparter <equinox@opensourcerouting.org>