diff options
author | Claudio Jeker <claudio@cvs.openbsd.org> | 2013-06-04 02:39:11 +0000 |
---|---|---|
committer | Claudio Jeker <claudio@cvs.openbsd.org> | 2013-06-04 02:39:11 +0000 |
commit | 1afa7269daa41211bb8ff6ba19d458b8c134cdf9 (patch) | |
tree | 8c35f246921667b47f0ebb100f6ecef35b0874cf /usr.sbin/ldpd | |
parent | 58e79569174ae7812da7dbfc19b71709322a4c20 (diff) |
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
Diffstat (limited to 'usr.sbin/ldpd')
-rw-r--r-- | usr.sbin/ldpd/interface.c | 4 | ||||
-rw-r--r-- | usr.sbin/ldpd/neighbor.c | 11 |
2 files changed, 13 insertions, 2 deletions
diff --git a/usr.sbin/ldpd/interface.c b/usr.sbin/ldpd/interface.c index 3441b564eee..aea184212f1 100644 --- a/usr.sbin/ldpd/interface.c +++ b/usr.sbin/ldpd/interface.c @@ -1,4 +1,4 @@ -/* $OpenBSD: interface.c,v 1.18 2013/06/04 02:28:27 claudio Exp $ */ +/* $OpenBSD: interface.c,v 1.19 2013/06/04 02:39:10 claudio Exp $ */ /* * Copyright (c) 2005 Claudio Jeker <claudio@openbsd.org> @@ -225,6 +225,8 @@ if_start_hello_timer(struct iface *iface) { struct timeval tv; + send_hello(HELLO_LINK, iface, NULL); + timerclear(&tv); tv.tv_sec = iface->hello_interval; if (evtimer_add(&iface->hello_timer, &tv) == -1) diff --git a/usr.sbin/ldpd/neighbor.c b/usr.sbin/ldpd/neighbor.c index b04628980f2..a9bd0f5d7fd 100644 --- a/usr.sbin/ldpd/neighbor.c +++ b/usr.sbin/ldpd/neighbor.c @@ -1,4 +1,4 @@ -/* $OpenBSD: neighbor.c,v 1.37 2013/06/04 02:34:48 claudio Exp $ */ +/* $OpenBSD: neighbor.c,v 1.38 2013/06/04 02:39:10 claudio Exp $ */ /* * Copyright (c) 2009 Michele Marchetto <michele@openbsd.org> @@ -466,6 +466,7 @@ nbr_establish_connection(struct nbr *nbr) { struct sockaddr_in local_sa; struct sockaddr_in remote_sa; + struct adj *adj; nbr->fd = socket(AF_INET, SOCK_STREAM, 0); if (nbr->fd == -1) { @@ -494,6 +495,14 @@ nbr_establish_connection(struct nbr *nbr) remote_sa.sin_port = htons(LDP_PORT); remote_sa.sin_addr.s_addr = nbr->addr.s_addr; + /* + * Send an extra hello to guarantee that the remote peer has formed + * an adjacency as well. + */ + LIST_FOREACH(adj, &nbr->adj_list, nbr_entry) + send_hello(adj->source.type, adj->source.link.iface, + adj->source.target); + if (connect(nbr->fd, (struct sockaddr *)&remote_sa, sizeof(remote_sa)) == -1) { if (errno == EINPROGRESS) { |