summaryrefslogtreecommitdiff
path: root/usr.sbin/ldpd
AgeCommit message (Collapse)Author
2016-05-23Update copyright information.Renato Westphal
2016-05-23Remove superfluous includes.Renato Westphal
2016-05-23Make functions and variables static whenever possible.Renato Westphal
The benefits of this include: * clean up of the ldpd global namespace; * improved readability; * more hints to the compiler/linker to generate more efficient code. Whenever possible, move global static variables to a smaller scope (function). All extern variables are now declared in header files to avoid unnecessary duplication. This patch also cleans up the indentation of all function prototypes and global variables.
2016-05-23Add support for IPv6 (RFC 7552).Renato Westphal
This includes: * Full compliance to RFC 7552; * Support for MD5 on LDPov6 sessions; * Support for pseudowires over IPv6 LSPs (we're probably the world's first implementation doing this); * Support for the IPv6 explicit-null label; * Knob to specify the prefered address-family for TCP transport connections; * Knob to use cisco non-compliant format to send and interpret the Dual-Stack capability TLV.
2016-05-23Assorted fixes and small cleanup.Renato Westphal
Nothing really interesting here.
2016-05-23Remove redundant new lines in print_config().Renato Westphal
2016-05-23Reject null labels for PW-ID FECs.Renato Westphal
2016-05-23Start sentences on new lines in ldpd.conf(5).Renato Westphal
2016-05-23Introduce a garbage collector for dead entries in the LIB.Renato Westphal
If we lose a route and all of its associated labels, then there's no point on keeping an entry for it in the LIB.
2016-05-23Simplify label allocation.Renato Westphal
Whenever we lose a route, unset the local label. If the same route is learned again later, allocate a new label for it. No need to be economic with labels, it's not worth the added complexity.
2016-05-23Use SO_BINDANY before binding sockets to the transport-address.Renato Westphal
This allows ldpd to start on a system without any IP address and bind to the transport-address successfully. Without this patch, we'd need to monitor the new addresses from the kernel and create the network sockets only when the transport-address is available in the system.
2016-05-23Enable changing the router-id via config reload.Renato Westphal
Now ldpd can start without a router-id, since it can be set later. Since a router-id of 0.0.0.0 is invalid, interfaces and targeted-neighbors will check for a valid router-id in order to be activated. When the router-id is changed, all the neighborships are reset.
2016-05-23Several fixes in the config reload handling.Renato Westphal
2016-05-23Don't create l2vpn targeted neighbors inside the config parser.Renato Westphal
When removing a configured pseudowire, we remove the associated tnbr in ldpe_l2vpn_pw_exit(). So, when a new pseudowire is configured, it makes sense to create its tnbr in ldpe_l2vpn_pw_init() to keep things consistent.
2016-05-23Add an exception for kernels built without PFKEYv2 support.Renato Westphal
2016-05-23Create network sockets on the parent process.Renato Westphal
We drop our privileges in ldpe right after we create the network sockets. The problem is that we might want to change the transport-address and reload the config, in which case we need new sockets. To allow that, always create the network sockets in the parent process and pass them to ldpe via imsg.
2016-05-23Reuse lde_address_find() inside lde_check_mapping().Renato Westphal
2016-05-23Fix bugs in pseudowire parameters negotiation.Renato Westphal
2016-05-23Copy structs by assignment instead of memcpy.Renato Westphal
Copying by straight assignment is shorter, easier to read and has a higher level of abstraction. We'll only avoid it when copying from an unaligned source (e.g., network buffers). In addition, copy in_addr structs directly.
2016-05-23Move socket creation and setup into a specialized function.Renato Westphal
Right now we use three network sockets in ldpd: * the discovery socket (udp+mcast); * the extended discovery socket (udp); * the session socket (tcp). When we introduce IPv6 support, we'll get three more sockets. In order to prevent code duplication in the future, add a specialized function that creates a socket according to the given type (and address-family later). This also improves readability because it makes it easier to see the differences between each socket.
2016-05-23Fix mess caused by my commit script.Renato Westphal
I screwed up everything... trying to fix now.
2016-05-23Move setsockopt helper functions to a separate file.Renato Westphal
IPv6 support is coming and we don't want to pollute the interface.c file with too many of these helper functions. Also, rename these functions from if_set_* to sock_set_*.
2016-05-23Fix fd leak in error path.Renato Westphal
2016-05-23Rework L2VPN code.Renato Westphal
2016-05-23Fix bug in the processing of label withdraws and releases.Renato Westphal
The F_MAP_PW_ID flag is only set for PW-ID mappings, which means that we were ignoring all label withdraws and label releases for non PW-ID FECs.
2016-05-23Remove protection that was prevent pseudowires to be updated in the kernel.Renato Westphal
During the setup of a pseudowire, it might change its parameters (e.g. control-word) once the negotiation with the remote peer is done.
2016-05-23Fix warnings when compiling with -pedantic.Renato Westphal
2016-05-23Release allocated memory before exiting.Renato Westphal
2016-05-23Make send_labelmessage() more robust.Renato Westphal
Immediately return from this function if the given list of mappings is empty. This way we have more freedom when sending label messages, not having to care with corner cases.
2016-05-23Fix check of when a wildcard group PW-ID FEC is valid or not.Renato Westphal
In addition to label mappings, wildcard group PW-ID FECs are invalid in label requests and label abort requests too.
2016-05-23clear_config() should only deallocate memory and nothing else.Renato Westphal
clear_config() is called when the parser fails (at startup or config reload). While cleaning up the allocated memory, the parser should not log anything, after all the daemon's running configuration is untouched. So, in this case, we se should clear the partial config by hand and avoid functions like if_del().
2016-05-23Check for local label before trying to install pseudowire.Renato Westphal
While here, add a comment about ECMP and pseudowires.
2016-05-23Do not accept incomplete pseudowires in the configuration.Renato Westphal
There's no point on keeping in the config something that can not be used, it just adds unnecessary complexity. Also, it's better to warn the user that there's something wrong rather than play nice and ignore the problem.
2016-05-23Minor adjustments in l2vpn code.Renato Westphal
* Define a new constant for the default pseudowire type; * On l2vpn_new(), initialize the l2vpn lists with LIST_NEW (cosmetic because the struct was calloc'ed); * Add a const qualifier to the second parameter of l2vpn_find(); * Remove l2vpn_if_del() and use just free() instead.
2016-05-23Remove unnecessary mirroring of sockets.Renato Westphal
2016-05-23Fix byte order issues with notification messages.Renato Westphal
2016-05-23Simplify removal of targeted neighbors and adjacencies.Renato Westphal
Unlink these structures inside their own delete function rather than from the outside.
2016-05-23Remove unnecessary break statements.Renato Westphal
2016-05-23Reuse nbr_pending_connect() on nbr_del().Renato Westphal
2016-05-23Standardize some log messages and fix some inconsistencies.Renato Westphal
We were using several different names for the same thing in our log messages: neighbor, neighbor ID, nbr ID and LSR ID. Standardize to always use "lsr-id" to refer to a neighbor. Also: * Use log_warnx() instead of log_warn() when appropriate; * Use fatal(x) instead of err(x) when appropriate; * Fix some inconsistent log messages.
2016-05-23Make neighbor parameters per lsr-id not per transport-address.Renato Westphal
With the advent of IPv6 support, a single neighbor can have two different transport-addresses: one for ipv4 and one for ipv6. In order to define neighbor-specific parameters in an indistinguishable way, define them by lsr-id. This way we can switch between LDPov4 and LDPov6 and keep the same configuration.
2016-05-23Rework the way we handle income connection requests.Renato Westphal
The logic of the previous code was to accept all TCP connection requests (destined to port 646) and create a tcp_conn structure for each them. Once the first packet of a connection was received, we would analyze the LDP Initialization message and identify its origin by looking at the LSR-ID field. When parsing a received TCP packet, we would need to distinguish between two cases: tcp packet from an LDP neighbor and tcp packet from a newborn connection (not associated with any neighbor yet). For this reason, the session_read() function was quite complicated. Also, we were not keeping track of the allocated tcp_conn structures. So, we were subject to memory leaks and even DOS attacks. With this patch, we also accept all TCP connection requests, but with two major differences: * We identify the neighbor by the source address of the SYN packet. This is possible because we don't support label spaces, so the transport-address by itself is enough to identify a neighbor, we don't need to wait for the Initialization message; * If there's no matching adjacency for this neighbor, then we start a timer of 5 seconds. If we receive a Hello packet from this neighbor within this interval, then we stop this timer and move on in the Initialization state machine. Otherwise, we send a No Hello Notification message and close the socket. We try to avoid sending the No Hello notification as much as possible because it triggers the backoff exponential in the remote peer, which considerably slow down the session establishment process. In summary, this new approach allows for a simpler code and fixes the memory leak problem mentioned before.
2016-05-23More renaming.Renato Westphal
Rename a few more things to improve readability. * s/F_PW_CONTROLWORD_CONF/F_PW_CWORD_CONF/ (shorter) * s/F_PW_CONTROLWORD/F_PW_CWORD/ (shorter) * s/LDPD_FLAG_*/F_LDPD_*/ (consistency) * s/lde_nbr_address/lde_addr/ (shorter) * s/ldp_discovery_socket/ldp_disc_socket/ (shorter) * s/ldp_ediscovery_socket/ldp_edisc_socket/ (shorter) * s/ldp_sendboth/main_imsg_compose_both/ (consistency) * s/cons/total/ (makes more sense) * s/kaddr/ka/ (consistency with remaining code) * Always use 'ln' for lde_nbrs (consistency)
2016-05-23Rename a few constants to avoid confusion.Renato Westphal
In ldpd we have the map structure, which is used to represent a label message, and the fec structure, used to store FECs in the LIB. As of now, ldpd supports two type of FECs: * IPv4 prefix (FEC_TYPE_IPV4); * PWID (FEC_TYPE_PWID). For the label messages, the following contants were being used: * FEC_WILDCARD; * FEC_PREFIX (IPv4 or IPv6); * FEC_PWID. Since these contants have similar names to the previous ones, rename them to: * MAP_TYPE_WILDCARD; * MAP_TYPE_PREFIX; * MAP_TYPE_PWID.
2016-05-23Remove unused code.Renato Westphal
2016-05-23Several improvements in the parsing of UDP/Hello packets.Renato Westphal
* Fix check of the packet's size and the "PDU Length" field; * Add check for the "Message Length" field; * Check for invalid labelspace earlier. * Use if_lookup() on disc_recv_iface() to reduce one level of identation; Additionally, add the following safeguards: * Check for unicast link hellos; * Check for multicast targeted hellos; * Validate packet's source address; * Validate received transport-address. Put the ancillary function bad_ip_addr() into a new file, util.c, which will be used later for several other things.
2016-05-23Don't ignore notification messages before the session is operational.Renato Westphal
This was preventing us from triggering the backoff exponential timer after receiving a 'No Hello' notification.
2016-05-23Improve the parser of TCP/session packets.Renato Westphal
Add more safeguards against malformed packets and fix existing ones. Also, rename a few variables and constants to match their real meaning. For example, rename gen_msg_tlv() to gen_msg_hdr() because this function generates an LDP header, not a TLV. Finally, clean-up all the send_* functions so they all follow the same pattern.
2016-05-23Respect the received Max PDU Length field.Renato Westphal
2016-05-23Fix issue with the exponential backoff timer.Renato Westphal
Do not start the exponential backoff timer when playing the passive role of the session establishment process. RFC 5036 - Section 2.5.3 says: "The specific session establishment action that must be delayed is the attempt to open the session transport connection by the LSR playing the active role".