History log of /openbsd-current/usr.sbin/ldpd/interface.c
Revision (<<< Hide revision tags) (Show revision tags >>>) Date Author Comments
# 1.52 08-Mar-2023 guenther

Delete obsolete /* ARGSUSED */ lint comments.

ok miod@ millert@


Revision tags: OPENBSD_6_6_BASE OPENBSD_6_7_BASE OPENBSD_6_8_BASE OPENBSD_6_9_BASE OPENBSD_7_0_BASE OPENBSD_7_1_BASE OPENBSD_7_2_BASE
# 1.51 28-Jun-2019 deraadt

When system calls indicate an error they return -1, not some arbitrary
value < 0. errno is only updated in this case. Change all (most?)
callers of syscalls to follow this better, and let's see if this strictness
helps us in the future.


Revision tags: OPENBSD_6_1_BASE OPENBSD_6_2_BASE OPENBSD_6_3_BASE OPENBSD_6_4_BASE OPENBSD_6_5_BASE
# 1.50 03-Mar-2017 renato

Minor tweaks.


# 1.49 03-Mar-2017 renato

Allow to run on a non-default rdomain.

OK claudio@


# 1.48 03-Sep-2016 renato

Rework the sending of address messages.

* Respect the session's negotiated maximum pdu length and split the
sending of our local addresses into multiple messages if necessary;

* Log sent/received addresses;

* Add new wrappers to send only one address (send_address_single)
and to send all addresses of the given address-family
(send_address_all). These wrappers create a temporary list of addresses
to be sent, and send_address() then acts on this last.


Revision tags: OPENBSD_6_0_BASE
# 1.47 01-Jul-2016 renato

Several minor tweaks.


# 1.46 18-Jun-2016 renato

Fix removal of dual-stack neighbors.


# 1.45 09-Jun-2016 renato

Send a fatal notification when the last hello adjacency is deleted.

RFC 5036 says:
"When the last Hello adjacency for an LDP session is
deleted, the LSR terminates the LDP session by sending a Notification
message and closing the transport connection".

Send a "Hold Timer Expired" notification when the triggering event is
a hello hold time timeout. In the other cases, like disabling LDP on an
interface, send a "Shutdown" notification instead.

Before this patch we were just closing the neighbor's transport
connection.

Fixes the following ANVL LDP tests: 7.17 and 23.3.


# 1.44 23-May-2016 renato

Update copyright information.


# 1.43 23-May-2016 renato

Remove superfluous includes.


# 1.42 23-May-2016 renato

Make functions and variables static whenever possible.

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.


# 1.41 23-May-2016 renato

Add support for IPv6 (RFC 7552).

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.


# 1.40 23-May-2016 renato

Enable changing the router-id via config reload.

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.


# 1.39 23-May-2016 renato

Several fixes in the config reload handling.


# 1.38 23-May-2016 renato

Create network sockets on the parent process.

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.


# 1.37 23-May-2016 renato

Copy structs by assignment instead of memcpy.

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.


# 1.36 23-May-2016 renato

Fix mess caused by my commit script.

I screwed up everything... trying to fix now.


# 1.35 23-May-2016 renato

Move setsockopt helper functions to a separate file.

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_*.


# 1.34 23-May-2016 renato

Remove unnecessary mirroring of sockets.


# 1.33 23-May-2016 renato

Simplify removal of targeted neighbors and adjacencies.

Unlink these structures inside their own delete function rather than from
the outside.


# 1.32 23-May-2016 renato

Standardize some log messages and fix some inconsistencies.

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.


# 1.31 23-May-2016 renato

More renaming.

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)


# 1.30 23-May-2016 renato

Remove duplicated code in timer functions.


# 1.29 23-May-2016 renato

We don't need a separate function for sending address withdraws.

Address and Address Withdraw messages have the exact same format, only
their type is different.


# 1.28 23-May-2016 renato

Move some code around.

This patch doesn't introduce any logical change.


# 1.27 23-May-2016 renato

Replace manually written function names with __func__.


Revision tags: OPENBSD_5_9_BASE
# 1.26 27-Sep-2015 stsp

As done for bgpd recently, rename if_mediatype to if_type in ldpd.
And some ifmedia64 fixes.
"move forward" deraadt@


Revision tags: OPENBSD_5_8_BASE
# 1.25 21-Jul-2015 renato

Add configuration reload support.

ok claudio@


# 1.24 21-Jul-2015 renato

Improve handling of addresses on ldpe.

This is a preliminary work for the the next patch (sigup config
reload). We want to make sure that the ldpe process can handle duplicated
addresses.

The idea is to alloc two different if_addr structures for each address,
and link one in the global list of addresses (used to send address
messages) and link the other to the associated interface list of
addresses.

Doing that we will be able to call kif_redistribute() after reloading
the config file and activate the new LDP enabled interfaces.

NOTE: Interfaces are created at config parse time and the child
processes inherit them on fork() so there's no need to send a status
update at startup.

ok claudio@


# 1.23 19-Jul-2015 renato

Add missing LIST_INIT's.

ok claudio@


# 1.22 21-Mar-2015 renato

Remove interface finite state machine.

In the name of simplicity, remove the interface FSM that was inherited
from ospfd. In ldpd interfaces are just up or down, so keeping a
FSM for that is an overkill. Now instead of calling if_fsm(), just
call if_update() whenever a relevant event occurs (status change,
address addition/removal).

Additional notes:
1 - s/if_act_/if_/

2 - Remove the IMSG_IFUP and IMSG_IFDOWN events. Now whenever an
interface changes its state a IMSG_IFSTATUS event will be generated
with the new status.

kroute.c ldpd.h ldpe.c ldpe.h CVS:


# 1.21 21-Mar-2015 renato

ldpd: Remove attached adjacencies whenever an interface is disabled
for whatever reason.

If one interface is disabled, the holdtimer of the attached adjacencies
will eventually timeout after a few seconds. But there's no need
to wait when we know that the interface is disabled. In these cases,
remove the attached adjacencies to speedup the convergence process.


Revision tags: OPENBSD_5_5_BASE OPENBSD_5_6_BASE OPENBSD_5_7_BASE
# 1.20 15-Oct-2013 renato

Minor fixes on if_del() and nbr_new().

if_del(): this function is always called after an IF_EVT_DOWN event so
there's no need to cleanup things here;

nbr_new(): C structs shouldn't be copied directly.

OK claudio@


Revision tags: OPENBSD_5_4_BASE
# 1.19 04-Jun-2013 claudio

Speed-up the session establishment process
* Send an extra Hello message before attempting to connect to a remote
peer to guarantee that it formed an adjacency with us as well;
* Don't wait for the first timeout to send the first Hello message.
Both tricks together will allow for fast session establish since with both
optimizations passive role neighbors can open the connection immediatly by
sending and receiving the hellos at the same time as the TCP session.
From Renato Westphal


# 1.18 04-Jun-2013 claudio

Cleanup ctl commands and remove unused variables inherited from ospfd
From Renato Westphal


# 1.17 04-Jun-2013 claudio

Implement support for adjacencies and targeted hellos
Refactor adjacencies out of the neighbor handling so that it is possible to
have more complex topologies with targeted sessions.
From Renato Westphal


# 1.16 04-Jun-2013 claudio

fix some minor issues before proceeding with the remaining patches from
Renato Westphal. Diff by Renato Westphal


# 1.15 03-Jun-2013 claudio

Remove the IMSG_NEIGHBOR_CHANGE message
Unlike OSPF, LDP has no concept of intermediate states. A session is
either operational or not operational as far as the label distribution
engine (lde) is concerned. In this case, the IMSG_NEIGHBOR_UP and
IMSG_NEIGHBOR_DOWN messages are enough.
Diff by Renato Westphal


# 1.14 03-Jun-2013 claudio

Implement support for multiple addresses per interface.
This replaces the way addresses and interface are chained together.
In ospfd there was a 1 to 1 mapping (with iface clones) but LDP does
not have that limitation.
Diff from Renato Westphal


# 1.13 01-Jun-2013 claudio

Drop support for passive interfaces.
Support for passive interfaces was inherited from ospfd but it doesn't
make any sense at all for ldpd.
Diff from Renato Westphal


# 1.12 01-Jun-2013 claudio

Don't allow enabling LDP on loopback and carp interfaces.
LDP should be allowed only on physical or tunnel interfaces.
Diff by Renato Westphal


# 1.11 30-May-2013 claudio

Fix bug when starting ldpd with a configured interface in the down state.
If a given interface is down at startup, don't promote it to the ACTIVE
state.
Diff from Renato Westphal [renatowestphal at gmail.com]


# 1.10 30-May-2013 claudio

Stop trying to send hello messages if the interface is down.
Diff from Renato Westphal [renatowestphal at gmail.com]


Revision tags: OPENBSD_5_2_BASE OPENBSD_5_3_BASE
# 1.9 14-May-2012 sthen

Don't display a nonsense uptime for an inactive interface. ldpd fix from
Rafael Zalamena on tech@, I also applied it to ospfd. ok phessler@


Revision tags: OPENBSD_5_0_BASE OPENBSD_5_1_BASE
# 1.8 04-Jul-2011 claudio

LINK_STATE_IS_UP() cleanup userland part. There is no need to special
case carp(4) interfaces anymore. LINK_STATE_IS_UP() almost always does
the right job.
OK deraadt@ henning@

This needs a -current kernel or link state may be not reported correctly.


Revision tags: OPENBSD_4_9_BASE
# 1.7 10-Jan-2011 claudio

Fix a bad heritage from ospfd. Make neighbors independent of interfaces.
They are not bound as strongly as in ospf and causes problems when the
TCP connection is established from an not connected IP (e.g. a loopback).
Use three RB trees to sort the neighbor list by id, addr and peerid.
More cleanup is needed but this makes ldpd work against peers using
loopback IPs. Problem found, reported and fix tested again by Marcel Wiget.


Revision tags: OPENBSD_4_8_BASE
# 1.6 19-May-2010 claudio

Remove yet another ospf leftover that is not needed here. This time
neighbor self and all the madness surrounding this amazing concept.
LDP is not self aware so there is no need for this.
OK michele@


# 1.5 29-Apr-2010 claudio

Remove some more ospfd-ism from the interface code. This time remove
of most of the IF_TYPE_ special cases and most interface types.
Point-to-point and broadcast still present because of find_iface()
which needs addtional fixing.
OK michele@


# 1.4 15-Apr-2010 claudio

Cleanup the interface FSM by removing most of the ospfd specific states
that have nothing to do with LDP.
OK michele@


# 1.3 15-Apr-2010 claudio

Instead of having three ways of setting fds non-blocking use
session_socket_blockmode() everywhere.
Additionally make two fatal() distinguishable.
OK michele@


Revision tags: OPENBSD_4_7_BASE
# 1.2 18-Feb-2010 claudio

We need to set SO_REUSEADDR before doing the bind() of the tcp socket.
It does not help to set SO_REUSEPORT after doing the bind.
Fixes failures to start ldpd because of TIME_WAIT sessions.
OK michele


Revision tags: OPENBSD_4_6_BASE
# 1.1 01-Jun-2009 michele

Welcome ldpd, the Label Distribution Protocol daemon.
Built using the imsg/three process framework, its main aim
is to redistribute MPLS labels between peers.

Right now it has some really basic functionalities,
the basic protocol works and peers are able to exchange
labels and insert them in the kernel.
It still does not react to changes of topology.

Not yet connected to the builds.

ok claudio@ deraadt@


# 1.51 28-Jun-2019 deraadt

When system calls indicate an error they return -1, not some arbitrary
value < 0. errno is only updated in this case. Change all (most?)
callers of syscalls to follow this better, and let's see if this strictness
helps us in the future.


Revision tags: OPENBSD_6_1_BASE OPENBSD_6_2_BASE OPENBSD_6_3_BASE OPENBSD_6_4_BASE OPENBSD_6_5_BASE
# 1.50 03-Mar-2017 renato

Minor tweaks.


# 1.49 03-Mar-2017 renato

Allow to run on a non-default rdomain.

OK claudio@


# 1.48 03-Sep-2016 renato

Rework the sending of address messages.

* Respect the session's negotiated maximum pdu length and split the
sending of our local addresses into multiple messages if necessary;

* Log sent/received addresses;

* Add new wrappers to send only one address (send_address_single)
and to send all addresses of the given address-family
(send_address_all). These wrappers create a temporary list of addresses
to be sent, and send_address() then acts on this last.


Revision tags: OPENBSD_6_0_BASE
# 1.47 01-Jul-2016 renato

Several minor tweaks.


# 1.46 18-Jun-2016 renato

Fix removal of dual-stack neighbors.


# 1.45 09-Jun-2016 renato

Send a fatal notification when the last hello adjacency is deleted.

RFC 5036 says:
"When the last Hello adjacency for an LDP session is
deleted, the LSR terminates the LDP session by sending a Notification
message and closing the transport connection".

Send a "Hold Timer Expired" notification when the triggering event is
a hello hold time timeout. In the other cases, like disabling LDP on an
interface, send a "Shutdown" notification instead.

Before this patch we were just closing the neighbor's transport
connection.

Fixes the following ANVL LDP tests: 7.17 and 23.3.


# 1.44 23-May-2016 renato

Update copyright information.


# 1.43 23-May-2016 renato

Remove superfluous includes.


# 1.42 23-May-2016 renato

Make functions and variables static whenever possible.

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.


# 1.41 23-May-2016 renato

Add support for IPv6 (RFC 7552).

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.


# 1.40 23-May-2016 renato

Enable changing the router-id via config reload.

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.


# 1.39 23-May-2016 renato

Several fixes in the config reload handling.


# 1.38 23-May-2016 renato

Create network sockets on the parent process.

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.


# 1.37 23-May-2016 renato

Copy structs by assignment instead of memcpy.

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.


# 1.36 23-May-2016 renato

Fix mess caused by my commit script.

I screwed up everything... trying to fix now.


# 1.35 23-May-2016 renato

Move setsockopt helper functions to a separate file.

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_*.


# 1.34 23-May-2016 renato

Remove unnecessary mirroring of sockets.


# 1.33 23-May-2016 renato

Simplify removal of targeted neighbors and adjacencies.

Unlink these structures inside their own delete function rather than from
the outside.


# 1.32 23-May-2016 renato

Standardize some log messages and fix some inconsistencies.

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.


# 1.31 23-May-2016 renato

More renaming.

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)


# 1.30 23-May-2016 renato

Remove duplicated code in timer functions.


# 1.29 23-May-2016 renato

We don't need a separate function for sending address withdraws.

Address and Address Withdraw messages have the exact same format, only
their type is different.


# 1.28 23-May-2016 renato

Move some code around.

This patch doesn't introduce any logical change.


# 1.27 23-May-2016 renato

Replace manually written function names with __func__.


Revision tags: OPENBSD_5_9_BASE
# 1.26 27-Sep-2015 stsp

As done for bgpd recently, rename if_mediatype to if_type in ldpd.
And some ifmedia64 fixes.
"move forward" deraadt@


Revision tags: OPENBSD_5_8_BASE
# 1.25 21-Jul-2015 renato

Add configuration reload support.

ok claudio@


# 1.24 21-Jul-2015 renato

Improve handling of addresses on ldpe.

This is a preliminary work for the the next patch (sigup config
reload). We want to make sure that the ldpe process can handle duplicated
addresses.

The idea is to alloc two different if_addr structures for each address,
and link one in the global list of addresses (used to send address
messages) and link the other to the associated interface list of
addresses.

Doing that we will be able to call kif_redistribute() after reloading
the config file and activate the new LDP enabled interfaces.

NOTE: Interfaces are created at config parse time and the child
processes inherit them on fork() so there's no need to send a status
update at startup.

ok claudio@


# 1.23 19-Jul-2015 renato

Add missing LIST_INIT's.

ok claudio@


# 1.22 21-Mar-2015 renato

Remove interface finite state machine.

In the name of simplicity, remove the interface FSM that was inherited
from ospfd. In ldpd interfaces are just up or down, so keeping a
FSM for that is an overkill. Now instead of calling if_fsm(), just
call if_update() whenever a relevant event occurs (status change,
address addition/removal).

Additional notes:
1 - s/if_act_/if_/

2 - Remove the IMSG_IFUP and IMSG_IFDOWN events. Now whenever an
interface changes its state a IMSG_IFSTATUS event will be generated
with the new status.

kroute.c ldpd.h ldpe.c ldpe.h CVS:


# 1.21 21-Mar-2015 renato

ldpd: Remove attached adjacencies whenever an interface is disabled
for whatever reason.

If one interface is disabled, the holdtimer of the attached adjacencies
will eventually timeout after a few seconds. But there's no need
to wait when we know that the interface is disabled. In these cases,
remove the attached adjacencies to speedup the convergence process.


Revision tags: OPENBSD_5_5_BASE OPENBSD_5_6_BASE OPENBSD_5_7_BASE
# 1.20 15-Oct-2013 renato

Minor fixes on if_del() and nbr_new().

if_del(): this function is always called after an IF_EVT_DOWN event so
there's no need to cleanup things here;

nbr_new(): C structs shouldn't be copied directly.

OK claudio@


Revision tags: OPENBSD_5_4_BASE
# 1.19 04-Jun-2013 claudio

Speed-up the session establishment process
* Send an extra Hello message before attempting to connect to a remote
peer to guarantee that it formed an adjacency with us as well;
* Don't wait for the first timeout to send the first Hello message.
Both tricks together will allow for fast session establish since with both
optimizations passive role neighbors can open the connection immediatly by
sending and receiving the hellos at the same time as the TCP session.
From Renato Westphal


# 1.18 04-Jun-2013 claudio

Cleanup ctl commands and remove unused variables inherited from ospfd
From Renato Westphal


# 1.17 04-Jun-2013 claudio

Implement support for adjacencies and targeted hellos
Refactor adjacencies out of the neighbor handling so that it is possible to
have more complex topologies with targeted sessions.
From Renato Westphal


# 1.16 04-Jun-2013 claudio

fix some minor issues before proceeding with the remaining patches from
Renato Westphal. Diff by Renato Westphal


# 1.15 03-Jun-2013 claudio

Remove the IMSG_NEIGHBOR_CHANGE message
Unlike OSPF, LDP has no concept of intermediate states. A session is
either operational or not operational as far as the label distribution
engine (lde) is concerned. In this case, the IMSG_NEIGHBOR_UP and
IMSG_NEIGHBOR_DOWN messages are enough.
Diff by Renato Westphal


# 1.14 03-Jun-2013 claudio

Implement support for multiple addresses per interface.
This replaces the way addresses and interface are chained together.
In ospfd there was a 1 to 1 mapping (with iface clones) but LDP does
not have that limitation.
Diff from Renato Westphal


# 1.13 01-Jun-2013 claudio

Drop support for passive interfaces.
Support for passive interfaces was inherited from ospfd but it doesn't
make any sense at all for ldpd.
Diff from Renato Westphal


# 1.12 01-Jun-2013 claudio

Don't allow enabling LDP on loopback and carp interfaces.
LDP should be allowed only on physical or tunnel interfaces.
Diff by Renato Westphal


# 1.11 30-May-2013 claudio

Fix bug when starting ldpd with a configured interface in the down state.
If a given interface is down at startup, don't promote it to the ACTIVE
state.
Diff from Renato Westphal [renatowestphal at gmail.com]


# 1.10 30-May-2013 claudio

Stop trying to send hello messages if the interface is down.
Diff from Renato Westphal [renatowestphal at gmail.com]


Revision tags: OPENBSD_5_2_BASE OPENBSD_5_3_BASE
# 1.9 14-May-2012 sthen

Don't display a nonsense uptime for an inactive interface. ldpd fix from
Rafael Zalamena on tech@, I also applied it to ospfd. ok phessler@


Revision tags: OPENBSD_5_0_BASE OPENBSD_5_1_BASE
# 1.8 04-Jul-2011 claudio

LINK_STATE_IS_UP() cleanup userland part. There is no need to special
case carp(4) interfaces anymore. LINK_STATE_IS_UP() almost always does
the right job.
OK deraadt@ henning@

This needs a -current kernel or link state may be not reported correctly.


Revision tags: OPENBSD_4_9_BASE
# 1.7 10-Jan-2011 claudio

Fix a bad heritage from ospfd. Make neighbors independent of interfaces.
They are not bound as strongly as in ospf and causes problems when the
TCP connection is established from an not connected IP (e.g. a loopback).
Use three RB trees to sort the neighbor list by id, addr and peerid.
More cleanup is needed but this makes ldpd work against peers using
loopback IPs. Problem found, reported and fix tested again by Marcel Wiget.


Revision tags: OPENBSD_4_8_BASE
# 1.6 19-May-2010 claudio

Remove yet another ospf leftover that is not needed here. This time
neighbor self and all the madness surrounding this amazing concept.
LDP is not self aware so there is no need for this.
OK michele@


# 1.5 29-Apr-2010 claudio

Remove some more ospfd-ism from the interface code. This time remove
of most of the IF_TYPE_ special cases and most interface types.
Point-to-point and broadcast still present because of find_iface()
which needs addtional fixing.
OK michele@


# 1.4 15-Apr-2010 claudio

Cleanup the interface FSM by removing most of the ospfd specific states
that have nothing to do with LDP.
OK michele@


# 1.3 15-Apr-2010 claudio

Instead of having three ways of setting fds non-blocking use
session_socket_blockmode() everywhere.
Additionally make two fatal() distinguishable.
OK michele@


Revision tags: OPENBSD_4_7_BASE
# 1.2 18-Feb-2010 claudio

We need to set SO_REUSEADDR before doing the bind() of the tcp socket.
It does not help to set SO_REUSEPORT after doing the bind.
Fixes failures to start ldpd because of TIME_WAIT sessions.
OK michele


Revision tags: OPENBSD_4_6_BASE
# 1.1 01-Jun-2009 michele

Welcome ldpd, the Label Distribution Protocol daemon.
Built using the imsg/three process framework, its main aim
is to redistribute MPLS labels between peers.

Right now it has some really basic functionalities,
the basic protocol works and peers are able to exchange
labels and insert them in the kernel.
It still does not react to changes of topology.

Not yet connected to the builds.

ok claudio@ deraadt@


Revision tags: OPENBSD_6_1_BASE OPENBSD_6_2_BASE
# 1.50 03-Mar-2017 renato

Minor tweaks.


# 1.49 03-Mar-2017 renato

Allow to run on a non-default rdomain.

OK claudio@


# 1.48 03-Sep-2016 renato

Rework the sending of address messages.

* Respect the session's negotiated maximum pdu length and split the
sending of our local addresses into multiple messages if necessary;

* Log sent/received addresses;

* Add new wrappers to send only one address (send_address_single)
and to send all addresses of the given address-family
(send_address_all). These wrappers create a temporary list of addresses
to be sent, and send_address() then acts on this last.


Revision tags: OPENBSD_6_0_BASE
# 1.47 01-Jul-2016 renato

Several minor tweaks.


# 1.46 18-Jun-2016 renato

Fix removal of dual-stack neighbors.


# 1.45 09-Jun-2016 renato

Send a fatal notification when the last hello adjacency is deleted.

RFC 5036 says:
"When the last Hello adjacency for an LDP session is
deleted, the LSR terminates the LDP session by sending a Notification
message and closing the transport connection".

Send a "Hold Timer Expired" notification when the triggering event is
a hello hold time timeout. In the other cases, like disabling LDP on an
interface, send a "Shutdown" notification instead.

Before this patch we were just closing the neighbor's transport
connection.

Fixes the following ANVL LDP tests: 7.17 and 23.3.


# 1.44 23-May-2016 renato

Update copyright information.


# 1.43 23-May-2016 renato

Remove superfluous includes.


# 1.42 23-May-2016 renato

Make functions and variables static whenever possible.

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.


# 1.41 23-May-2016 renato

Add support for IPv6 (RFC 7552).

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.


# 1.40 23-May-2016 renato

Enable changing the router-id via config reload.

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.


# 1.39 23-May-2016 renato

Several fixes in the config reload handling.


# 1.38 23-May-2016 renato

Create network sockets on the parent process.

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.


# 1.37 23-May-2016 renato

Copy structs by assignment instead of memcpy.

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.


# 1.36 23-May-2016 renato

Fix mess caused by my commit script.

I screwed up everything... trying to fix now.


# 1.35 23-May-2016 renato

Move setsockopt helper functions to a separate file.

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_*.


# 1.34 23-May-2016 renato

Remove unnecessary mirroring of sockets.


# 1.33 23-May-2016 renato

Simplify removal of targeted neighbors and adjacencies.

Unlink these structures inside their own delete function rather than from
the outside.


# 1.32 23-May-2016 renato

Standardize some log messages and fix some inconsistencies.

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.


# 1.31 23-May-2016 renato

More renaming.

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)


# 1.30 23-May-2016 renato

Remove duplicated code in timer functions.


# 1.29 23-May-2016 renato

We don't need a separate function for sending address withdraws.

Address and Address Withdraw messages have the exact same format, only
their type is different.


# 1.28 23-May-2016 renato

Move some code around.

This patch doesn't introduce any logical change.


# 1.27 23-May-2016 renato

Replace manually written function names with __func__.


Revision tags: OPENBSD_5_9_BASE
# 1.26 27-Sep-2015 stsp

As done for bgpd recently, rename if_mediatype to if_type in ldpd.
And some ifmedia64 fixes.
"move forward" deraadt@


Revision tags: OPENBSD_5_8_BASE
# 1.25 21-Jul-2015 renato

Add configuration reload support.

ok claudio@


# 1.24 21-Jul-2015 renato

Improve handling of addresses on ldpe.

This is a preliminary work for the the next patch (sigup config
reload). We want to make sure that the ldpe process can handle duplicated
addresses.

The idea is to alloc two different if_addr structures for each address,
and link one in the global list of addresses (used to send address
messages) and link the other to the associated interface list of
addresses.

Doing that we will be able to call kif_redistribute() after reloading
the config file and activate the new LDP enabled interfaces.

NOTE: Interfaces are created at config parse time and the child
processes inherit them on fork() so there's no need to send a status
update at startup.

ok claudio@


# 1.23 19-Jul-2015 renato

Add missing LIST_INIT's.

ok claudio@


# 1.22 21-Mar-2015 renato

Remove interface finite state machine.

In the name of simplicity, remove the interface FSM that was inherited
from ospfd. In ldpd interfaces are just up or down, so keeping a
FSM for that is an overkill. Now instead of calling if_fsm(), just
call if_update() whenever a relevant event occurs (status change,
address addition/removal).

Additional notes:
1 - s/if_act_/if_/

2 - Remove the IMSG_IFUP and IMSG_IFDOWN events. Now whenever an
interface changes its state a IMSG_IFSTATUS event will be generated
with the new status.

kroute.c ldpd.h ldpe.c ldpe.h CVS:


# 1.21 21-Mar-2015 renato

ldpd: Remove attached adjacencies whenever an interface is disabled
for whatever reason.

If one interface is disabled, the holdtimer of the attached adjacencies
will eventually timeout after a few seconds. But there's no need
to wait when we know that the interface is disabled. In these cases,
remove the attached adjacencies to speedup the convergence process.


Revision tags: OPENBSD_5_5_BASE OPENBSD_5_6_BASE OPENBSD_5_7_BASE
# 1.20 15-Oct-2013 renato

Minor fixes on if_del() and nbr_new().

if_del(): this function is always called after an IF_EVT_DOWN event so
there's no need to cleanup things here;

nbr_new(): C structs shouldn't be copied directly.

OK claudio@


Revision tags: OPENBSD_5_4_BASE
# 1.19 04-Jun-2013 claudio

Speed-up the session establishment process
* Send an extra Hello message before attempting to connect to a remote
peer to guarantee that it formed an adjacency with us as well;
* Don't wait for the first timeout to send the first Hello message.
Both tricks together will allow for fast session establish since with both
optimizations passive role neighbors can open the connection immediatly by
sending and receiving the hellos at the same time as the TCP session.
From Renato Westphal


# 1.18 04-Jun-2013 claudio

Cleanup ctl commands and remove unused variables inherited from ospfd
From Renato Westphal


# 1.17 04-Jun-2013 claudio

Implement support for adjacencies and targeted hellos
Refactor adjacencies out of the neighbor handling so that it is possible to
have more complex topologies with targeted sessions.
From Renato Westphal


# 1.16 04-Jun-2013 claudio

fix some minor issues before proceeding with the remaining patches from
Renato Westphal. Diff by Renato Westphal


# 1.15 03-Jun-2013 claudio

Remove the IMSG_NEIGHBOR_CHANGE message
Unlike OSPF, LDP has no concept of intermediate states. A session is
either operational or not operational as far as the label distribution
engine (lde) is concerned. In this case, the IMSG_NEIGHBOR_UP and
IMSG_NEIGHBOR_DOWN messages are enough.
Diff by Renato Westphal


# 1.14 03-Jun-2013 claudio

Implement support for multiple addresses per interface.
This replaces the way addresses and interface are chained together.
In ospfd there was a 1 to 1 mapping (with iface clones) but LDP does
not have that limitation.
Diff from Renato Westphal


# 1.13 01-Jun-2013 claudio

Drop support for passive interfaces.
Support for passive interfaces was inherited from ospfd but it doesn't
make any sense at all for ldpd.
Diff from Renato Westphal


# 1.12 01-Jun-2013 claudio

Don't allow enabling LDP on loopback and carp interfaces.
LDP should be allowed only on physical or tunnel interfaces.
Diff by Renato Westphal


# 1.11 30-May-2013 claudio

Fix bug when starting ldpd with a configured interface in the down state.
If a given interface is down at startup, don't promote it to the ACTIVE
state.
Diff from Renato Westphal [renatowestphal at gmail.com]


# 1.10 30-May-2013 claudio

Stop trying to send hello messages if the interface is down.
Diff from Renato Westphal [renatowestphal at gmail.com]


Revision tags: OPENBSD_5_2_BASE OPENBSD_5_3_BASE
# 1.9 14-May-2012 sthen

Don't display a nonsense uptime for an inactive interface. ldpd fix from
Rafael Zalamena on tech@, I also applied it to ospfd. ok phessler@


Revision tags: OPENBSD_5_0_BASE OPENBSD_5_1_BASE
# 1.8 04-Jul-2011 claudio

LINK_STATE_IS_UP() cleanup userland part. There is no need to special
case carp(4) interfaces anymore. LINK_STATE_IS_UP() almost always does
the right job.
OK deraadt@ henning@

This needs a -current kernel or link state may be not reported correctly.


Revision tags: OPENBSD_4_9_BASE
# 1.7 10-Jan-2011 claudio

Fix a bad heritage from ospfd. Make neighbors independent of interfaces.
They are not bound as strongly as in ospf and causes problems when the
TCP connection is established from an not connected IP (e.g. a loopback).
Use three RB trees to sort the neighbor list by id, addr and peerid.
More cleanup is needed but this makes ldpd work against peers using
loopback IPs. Problem found, reported and fix tested again by Marcel Wiget.


Revision tags: OPENBSD_4_8_BASE
# 1.6 19-May-2010 claudio

Remove yet another ospf leftover that is not needed here. This time
neighbor self and all the madness surrounding this amazing concept.
LDP is not self aware so there is no need for this.
OK michele@


# 1.5 29-Apr-2010 claudio

Remove some more ospfd-ism from the interface code. This time remove
of most of the IF_TYPE_ special cases and most interface types.
Point-to-point and broadcast still present because of find_iface()
which needs addtional fixing.
OK michele@


# 1.4 15-Apr-2010 claudio

Cleanup the interface FSM by removing most of the ospfd specific states
that have nothing to do with LDP.
OK michele@


# 1.3 15-Apr-2010 claudio

Instead of having three ways of setting fds non-blocking use
session_socket_blockmode() everywhere.
Additionally make two fatal() distinguishable.
OK michele@


Revision tags: OPENBSD_4_7_BASE
# 1.2 18-Feb-2010 claudio

We need to set SO_REUSEADDR before doing the bind() of the tcp socket.
It does not help to set SO_REUSEPORT after doing the bind.
Fixes failures to start ldpd because of TIME_WAIT sessions.
OK michele


Revision tags: OPENBSD_4_6_BASE
# 1.1 01-Jun-2009 michele

Welcome ldpd, the Label Distribution Protocol daemon.
Built using the imsg/three process framework, its main aim
is to redistribute MPLS labels between peers.

Right now it has some really basic functionalities,
the basic protocol works and peers are able to exchange
labels and insert them in the kernel.
It still does not react to changes of topology.

Not yet connected to the builds.

ok claudio@ deraadt@