summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorclaudio <claudio@openbsd.org>2013-06-04 02:39:10 +0000
committerclaudio <claudio@openbsd.org>2013-06-04 02:39:10 +0000
commit38f2007957caa0a04fffce448cc15a5158f6baf0 (patch)
tree71963b8a6d87d68f84bb71cf15d3de1b1325d2db
parentAlways accept TCP connection requests and identify to which neighbor (diff)
downloadwireguard-openbsd-38f2007957caa0a04fffce448cc15a5158f6baf0.tar.xz
wireguard-openbsd-38f2007957caa0a04fffce448cc15a5158f6baf0.zip
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
-rw-r--r--usr.sbin/ldpd/interface.c4
-rw-r--r--usr.sbin/ldpd/neighbor.c11
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) {