Commit graph

74 commits

Author SHA1 Message Date
Mark Stapp 1378ebf640 ldpd: clean up warnings from -Wshadow
Clean up various variable-shadow warnings in ldpd.

Signed-off-by: Mark Stapp <mjs@cisco.com>
2025-04-08 14:41:27 -04:00
David Lamparter 95a737ed1b ldpd: use zlog recirculation for subprocesses
This way, full functionality of `zlog_*` is available.

Having `fatal()` be wrappers around `assertf()` also means we get
backtraces, which is not the case for a plain `exit(1)`.

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2024-03-10 12:42:14 +01:00
Donald Sharp 07b91ca096 *: Let's use the native IFNAMSIZ instead of INTERFACE_NAMSIZ
INTERFACE_NAMSIZ is just a redefine of IFNAMSIZ and IFNAMSIZ
is the standard for interface name length on all platforms
that FRR currently compiles on.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2023-11-21 08:08:29 -05:00
Donald Sharp 24a58196dd *: Convert event.h to frrevent.h
We should probably prevent any type of namespace collision
with something else.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2023-03-24 08:32:17 -04:00
Donald Sharp cd9d053741 *: Convert struct event_master to struct event_loop
Let's find a better name for it.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2023-03-24 08:32:17 -04:00
Donald Sharp 2453d15dbf *: Convert struct thread_master to struct event_master and it's ilk
Convert the `struct thread_master` to `struct event_master`
across the code base.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2023-03-24 08:32:17 -04:00
Donald Sharp e6685141aa *: Rename struct thread to struct event
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 08:32:17 -04:00
Donald Sharp cb37cb336a *: Rename thread.[ch] to event.[ch]
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-24 08:32:16 -04: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
Rafael Zalamena 3682bd90f3 *: use FRR interface name definition everywhere
Don't rely on the OS interface name length definition and use the FRR
definition instead.

Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
2022-05-02 13:00:12 -03:00
Donald Sharp cc9f21da22 *: Change thread->func to return void instead of int
The int return value is never used.  Modify the code
base to just return a void instead.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2022-02-23 19:56:04 -05:00
lynne ff5279ba48 ldpd: make allowing broken-lsps to be installed with pop operation configurable
If LDP is miss configured in a setup and the router has LSPs with no remote
label, this code installs the LSP with a pop instruction of the top-level
label so the packet can be forwarded using IP.   This is a best-effort
attempt to deliver labeled IP packets to their final destination instead of
dropping them.    If this config is turned off the code will only install
LSPs that have a valid remote label.

Signed-off-by: Lynne Morrison <lynne@voltanet.io>
2021-05-03 09:02:36 -04: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
Fredi Raspall ce510d2e0e ldpd: defer register for info until configured
Instead of registering to receive default-VRF information and routes
when first connected to zebra, defer the registration until some ldp
configuration is entered.

This avoids redistributing IPv4/IPv6 routes to ldpd when not needed.

Signed-off-by: Fredi Raspall <fredi@voltanet.io>
Signed-off-by: Emanuele Di Pascale <emanuele@voltanet.io>
2021-04-26 10:00:37 +02: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
David Lamparter 96244aca23 *: require semicolon after DEFINE_QOBJ & co.
Again, see previous commits.

Signed-off-by: David Lamparter <equinox@diac24.net>
2021-03-17 06:18:37 +01:00
David Lamparter 8451921b70 *: require semicolon after DEFINE_HOOK & co.
See previous commit.

Signed-off-by: David Lamparter <equinox@diac24.net>
2021-03-17 06:18:17 +01:00
Karen Schoener d4d6e7d87e ldpd: Add support for the read-only snmp mib objects that are statistics
Add support for the read-only snmp mib objects as described in RFC 3815
that are statistics.

Signed-off-by: Lynne Morrison <lynne@voltanet.io>
Signed-off-by: Karen Schoener <karen@voltanet.io>
2021-03-16 10:23:34 -04:00
Karen Schoener f9a4d683dc ldpd: Add support for read-only snmp mib objects (excluding statistics)
Add support for read-only snmp mib objects as described in RFC 3815,
excluding statistics.

Signed-off-by: Lynne Morrison <lynne@voltanet.io>
Signed-off-by: Karen Schoener <karen@voltanet.io>
2021-02-24 17:34:05 -05:00
Renato Westphal 077d336aa7 ldpd: add support for RLFA clients
Add an API that allows IGP client daemons to register/unregister
RLFAs with ldpd.

IGP daemons need to be able to query the LDP labels needed by RLFAs
and monitor label updates that might affect those RLFAs. This is
similar to the NHT mechanism used by bgpd to resolve and monitor
recursive nexthops.

This API is based on the following ZAPI opaque messages:
* LDP_RLFA_REGISTER: used by IGP daemons to register an RLFA with ldpd.
* LDP_RLFA_UNREGISTER_ALL: used by IGP daemons to unregister all of
  their RLFAs with ldpd.
* LDP_RLFA_LABELS: used by ldpd to send RLFA labels to the registered
  clients.

For each RLFA, ldpd needs to return the following labels:
* Outer label(s): the labels advertised by the adjacent routers to
  reach the PQ node;
* Inner label: the label advertised by the PQ node to reach the RLFA
  destination.

For the inner label, ldpd automatically establishes a targeted
neighborship with the PQ node if one doesn't already exist. For that
to work, the PQ node needs to be configured to accept targeted hello
messages. If that doesn't happen, ldpd doesn't send a response to
the IGP client daemon which in turn won't be able to activate the
previously computed RLFA.

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2021-01-08 22:22:11 -03:00
Karen Schoener e1894ff70f ldpd: Adding support for LDP IGP Synchronization
Signed-off-by: Lynne Morrison <lynne@voltanet.io>
Signed-off-by: Karen Schoener <karen@voltanet.io>
2020-09-09 10:45:41 -04:00
lynne 6bbdd9e979 ldpd and Zebra: Expand existing debug commands.
L2VPN PW are very hard to determine why they do not come up.  The following
fixes expand the existing show commands in ldp and zebra to display a
reason why the PW is in the DOWN state and also display the labeled nexthop
route selected to reach the PW peer.  By adding this information it will
provide the user some guidance on how to debug the PW issue.  Also fixed an
assert if labels were changed for a PW that is between directly connected
peers.

Signed-off-by: Lynne Morrison <lynne@voltanet.io>
2020-05-11 16:22:52 -04:00
lynne 2d1aa1e887 ldpd: fix ACL rule modification
Changes to ACL rules were not applied to LDP.  This fix allows
LDP to be notified when a rule in an ACL filter is modified by
the user. The filter is properly applied to the LDP session.
The filter may cause a LDP session to go down/up or to remove/add
labels being advertised/received from a neighbor.

Signed-off-by: Lynne Morrison <lynne@voltanet.io>
Signed-off-by: Karen Schoener <karen@voltanet.io>
2020-04-29 12:27:17 -04:00
Renato Westphal 1a3ff5236c
Merge pull request #5851 from volta-networks/feat_ldp_oc_review
ldpd: adding support for LDP ordered label distribution control
2020-03-23 10:55:20 -03:00
Karen Schoener aff1743c64 ldpd: adding support for LDP ordered label distribution control
LDP ordered label distribution control only binds a label to
a FEC if it is the egress LSR, or the router received a label
binding for a FEC from the next hop router.  In this mode,
an MPLS router will create a label binding for each FEC and
distribute it to its neighbors so long as he has a entry in
the RIB for the destination.

Signed-off-by: Lynne Morrison <lynne@voltanet.io>
Signed-off-by: Karen Schoener <karen@voltanet.io>
2020-03-20 17:11:33 -04:00
Donald Sharp 6cd8093d32 ldpd: During code inspection we are mixing data sizes
As I understand it ldpd was originally developed as a standalone
daemon for *BSD land.  Then ported to FRR.  FRR uses ifindex_t
as the base type for the ifindex.  Mixing `unsigned short` and
`int` and `unsigned int` is going to lead to fun somewhere
along the way.  Especially when we get to run on a system
with ifindex churn( I'm looking at you docker ).

Attempt to convert all of ldpd to think of the ifindex as a
`ifindex_t`.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2020-03-11 09:03:17 -04:00
Ruben Kerkhof 54ca644b6e ldpd: fix another linking issue with GCC-10
Signed-off-by: Ruben Kerkhof <ruben@rubenkerkhof.com>
2020-03-08 20:18:11 +01:00
Renato Westphal e132dea064 zebra: identify MPLS FTNs by route type and instance
Use the route type and instance instead of the route distance
to identify MPLS FTNs. This is a more robust approach since the
routing daemons can modify the distance of their announced routes
via configuration, which can cause inconsistencies.

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2019-09-06 21:06:11 -03:00
F. Aragon 4149ef7c0f
ldpd: buffer underflow, thread safety (PVS-Studio)
This commit fixes two issues:
- memcpy() using containers of different sizes when using addr2sa(), mixing
  'struct sockaddr_storage' and 'union sockunion'.
- addr2sa() function not being thread safe (using a local static variable as
  container.

Signed-off-by: F. Aragon <paco@voltanet.io>
2018-07-04 00:01:22 +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
Renato Westphal 3c5b5220f7 zebra, ldpd: fix display of pseudowire status
In some circumstances zebra and ldpd would display a pseudowire as UP
when in reality it's not (example: MTU mismatch between the two ends). Fix
this to avoid confusion.

Reported-by: ßingen <bingen@voltanet.io>
Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2017-11-29 20:39:19 -02:00
Jorge Boncompte cd85bc2e0b lib: standardize use of queue.h
The simple queue implementation in OpenBSD and FreeBSD are called diferently,
standardize in the use of the FreeBSD version and map the missing names only
if we compile on OpenBSD.

Signed-off-by: Jorge Boncompte <jbonor@gmail.com>
2017-08-17 17:47:05 +02:00
Renato Westphal 87b5f1b77b ldpd: integrate with the pseudowire manager in zebra
If we receive a notification from zebra indicating that the installation
of a pseudowire has failed (e.g. no reachability), send a PW Status
notification to the remote peer (or a Label Withdraw if the remote peer
doesn't support the PW Status TLV).

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2017-08-09 12:35:16 +02:00
ßingen 6833ae01bc zebra: add pseudowire manager
Base framework for supporting MPLS pseudowires in FRR.

A consistent zserv interface is provided so that any client daemon
(e.g. ldpd, bgpd) can install/uninstall pseudowires in a standard
way. Static pseudowires can also be implemented by using the same
interface.

When zebra receives a request to install a pseudowire and the installation
in the kernel or hardware fails, a notification is sent back to the
client daemon and a new install attempt is made every 60 seconds (until
it succeeds).

Support for external dataplanes is provided by the use of hooks to
install/uninstall pseudowires.

Signed-off-by: ßingen <bingen@voltanet.io>
Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2017-08-09 12:35:15 +02:00
Donald Sharp 9bff805755 ldpd: Switch to using ETH_ALEN
Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2017-08-04 09:06:14 -04:00
Renato Westphal e4a82008c6 ldpd: further improvements in the configuration handling
This patch attempts to make the code easier to read by removing a
global variable and changing a few other things. Also, ldpd now calls
merge_config() only after reading the whole initial configuration at
startup, instead of doing that for every command in the configuration
file.

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2017-06-02 22:15:17 -03:00
Donald Sharp 05ba625af7 Merge remote-tracking branch 'origin/stable/3.0' 2017-05-02 15:52:09 -04:00
Donald Sharp 20abb742ed Merge pull request #431 from opensourcerouting/fix-iface-renames
Fix interface renames
2017-05-01 14:17:42 -04:00
Renato Westphal 988ded8d12 ldpd: respect link-detect configuration
We shouldn't check the operational status of an interface in ldpd if
it's configured with "no link-detect" in zebra. That's what all the
other routing daemons do.

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2017-05-01 11:33:23 -03:00
Renato Westphal 9cf67225be ldpd: fixes to handle interface renames properly
Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2017-05-01 09:37:41 -03:00
Renato Westphal 274f5abf24 ldpd: simplify initialization of the child processes
In order to have separate ASLR/cookies per process, ldpd calls exec()
in the child processes after fork() (this is also known as the fork+exec
model).

This is an important security feature but it makes the initialization
of the child processes a bit more complicated as they're not a copy of
the parent anymore, so all parameters given via command line are lost.

To solve this problem, we were creating an argv array by hand with all
necessary parameters and providing it to the exec() syscall. This works
but it's a very ugly solution. This patch introduces a different approach
to solve the problem: send an IMSG_INIT message to the child processes
with all parameters they need in order to initialize properly. This
makes adding additional initialization parameters much more convenient
and less error prone.

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2017-04-26 10:36:30 -03:00
Renato Westphal 01d1458f6a ldpd: remove two unused imsg types
Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2017-04-24 20:30:58 -03:00
Renato Westphal fa68f9da9e ldpd: split log.c into two files
This is basically to keep in sync with OpenBSD's ldpd(8) where the same
change was done.

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2017-04-24 20:30:58 -03:00
Renato Westphal 1d75a89d85 ldpd: do not consume vty_conf when updating the configuration
David Lamparter gave the idea of keeping vty_conf as a permanent copy of
ldpd_conf in order to simplify the CLI code and facilitate the integration
with his cap'n proto framework in the future. Doing this demanded quite
some effort but it was worth it as the code looks much better now.

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2017-03-31 13:51:53 -03:00
Renato Westphal dbce358222 ldpd: do a full configuration reload upon receiving a SIGHUP
The rationale here is to do something very similar to what the original
OpenBSD's ldpd(8) does to reload configuration files:
* create a new empty base configuration (vty_conf);
* parse the configuration file and store the result in vty_conf;
* merge the new configuration into the current configuration.

To do this, introduce a new global variable called "sighup" so that ldpd
doesn't attempt to merge vty_conf into ldpd_conf for each command in
the configuration file, which would be very disruptive. vty_conf should
be merged only after the whole configuration file is parsed in order to
avoid taking actions like shutting down neighbors when not necessary.

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2017-03-27 14:54:57 -03:00
Renato Westphal 56b8a8d231 ldpd: simplify handling of configuration commands
The logic to make configuration changes in ldpd is as follows:
1 - duplicate the current configuration;
2 - modify the duplicated configuration (delta);
3 - merge the duplicated configuration into the current configuration.

We can however change things a little bit in order to simplify the code.

If we provide a global vty_conf variable and make sure that it's
always an up-to-date duplicate of ldpd_conf, then we don't need to call
ldp_dup_config() in the callback of each configuration command. Instead
of that, we just need to duplicate ldpd_conf in the startup of the daemon
and in the end of the ldp_reload() function. Doing this is safe because,
due to the single-threaded nature of the parent process, it's impossible
to have multiple requests to change the configuration at the same time.

Also, we can remove the *_ref() functions and do something much simpler
instead.  The problem we have to deal with here is that VTY_GET_CONTEXT()
returns a pointer to an element of ldpd_conf, and what we want is a
pointer to an element of vty_conf (e.g. an l2vpn).  To solve this,
we just need to look for the equivalent element inside vty_conf using
standard functions from ldpd like l2vpn_find() and others.

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2017-03-27 14:54:28 -03:00
Donald Sharp 7bd48975b9 Merge pull request #286 from opensourcerouting/ldpd-tshoot
Ldpd tshoot
2017-03-24 07:17:06 -04:00
Renato Westphal 0f7b5df925 ldpd: provide more detailed information in some show commands
Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2017-03-20 21:42:14 -03:00
Renato Westphal 99cfc17f76 ldpd: add commands to show sent/rcvd capabilities
Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2017-03-20 21:42:14 -03:00
Renato Westphal bc0eb287fa ldpd: provide both a brief and a detailed version of some show commands
Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2017-03-20 21:42:14 -03:00