]> git.ipfire.org Git - thirdparty/unbound.git/commitdiff
- Set SO_REUSEADDR on outgoing tcp connections to fix the bind before
authorWouter Wijngaards <wouter@nlnetlabs.nl>
Mon, 8 May 2017 10:41:03 +0000 (10:41 +0000)
committerWouter Wijngaards <wouter@nlnetlabs.nl>
Mon, 8 May 2017 10:41:03 +0000 (10:41 +0000)
  connect limited tcp connections.  With the option tcp connections
  can share the same source port (for different destinations).

git-svn-id: file:///svn/unbound/trunk@4151 be551aaa-1e26-0410-a405-d3ace91eadb9

doc/Changelog
services/outside_network.c

index bf78e5189316ab51188677f20cbdae794de35270..f22d39e3e671acbbc51c02df52434b1aaeb689aa 100644 (file)
@@ -1,5 +1,8 @@
 8 May 2017: Wouter
        - Fix tcp-mss failure printout text.
+       - Set SO_REUSEADDR on outgoing tcp connections to fix the bind before
+         connect limited tcp connections.  With the option tcp connections
+         can share the same source port (for different destinations).
 
 2 May 2017: Ralph
        - Added mesh_add_sub to add detached mesh entries.
index 525ae2e5e6f88ffd29e32652c62e35c08493b4db..89518ce19d08aafa7269150eafce6888b7c722a4 100644 (file)
@@ -204,6 +204,9 @@ outnet_tcp_take_into_use(struct waiting_tcp* w, uint8_t* pkt, size_t pkt_len)
 {
        struct pending_tcp* pend = w->outnet->tcp_free;
        int s;
+#ifdef SO_REUSEADDR
+       int on = 1;
+#endif
        log_assert(pend);
        log_assert(pkt);
        log_assert(w->addrlen > 0);
@@ -225,6 +228,13 @@ outnet_tcp_take_into_use(struct waiting_tcp* w, uint8_t* pkt, size_t pkt_len)
                return 0;
        }
 
+#ifdef SO_REUSEADDR
+       if(setsockopt(s, SOL_SOCKET, SO_REUSEADDR, (void*)&on,
+               (socklen_t)sizeof(on)) < 0) {
+               verbose(VERB_ALGO, "outgoing tcp:"
+                       " setsockopt(.. SO_REUSEADDR ..) failed");
+       }
+#endif
        if (w->outnet->tcp_mss > 0) {
 #if defined(IPPROTO_TCP) && defined(TCP_MAXSEG)
                if(setsockopt(s, IPPROTO_TCP, TCP_MAXSEG,