Bug 238688 - Does not listen on IPv4 when IPv4-mapped addresses are disabled
Summary: Does not listen on IPv4 when IPv4-mapped addresses are disabled
Status: RESOLVED FIXED
Alias: None
Product: ktorrent
Classification: Applications
Component: general (show other bugs)
Version: unspecified
Platform: Debian unstable Linux
: NOR normal
Target Milestone: ---
Assignee: Joris Guisson
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-05-24 15:42 UTC by Modestas Vainius
Modified: 2010-07-05 20:17 UTC (History)
0 users

See Also:
Latest Commit:
Version Fixed In:
Sentry Crash Report:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Modestas Vainius 2010-05-24 15:42:51 UTC
Version:           unspecified (using KDE 4.4.3) 
OS:                Linux

The bug is in libktorrent v4.0rc1. Please check the header of the following patch for up-to-date details. Current header is copy & pasted bellow.

http://git.debian.org/?p=pkg-kde/kde-extras/libktorrent.git;a=blob;f=debian/patches/debian_disable_ipv6_only.diff


Description: Always bind IPv6 sockets to IPv4 as well
 If net.ipv6.bindv6only = 1 (Linux defaults to net.ipv6.bindv6only = 0) is set
 (a new default for Debian Linux since Squeeze), IPv6 sockets are not bound to
 IPv4 by default. This made KTorrent not listen on IPv4 (see Debian bug).
 However, an application may explicitly set IPV6_V6ONLY socket option to 0 in
 order to enforce contrary behaviour on Linux and other systems which support
 IPv4-mapped addresses.
 .
 Unfortunately, this fix is just a workaround and my attempt at damage control.
 According to [1], not all IPv6 stacks support IPv4-mapped addresses (Windows,
 OpenBSD, Debian kFreeBSD do not support them). What is more, as far as I can
 tell, net.ipv6.bindv6only=1 like behaviour is default on *BSD. So KTorrent
 without IPV6_V6ONLY explicitly set to 0 used to bind to IPv6-only addresses on
 these systems. Only Linux and OSX default to net.ipv6.bindv6only=0 like
 behaviour.
 .
 The proper fix would be to open two sockets: one AF_INET6 with IPV6_V6ONLY and
 another AF_INET one. I recommend you to read the thread [2] about bindv6only=1
 in Debian in order to better understand this issue.
 .
 1. http://en.wikipedia.org/wiki/IPv6#IPv4-mapped_addresses
 2. http://news.gmane.org/find-root.php?message_id=%3c20091024182431.GB13333%40bongo.bofh.it%3e
Author: Modestas Vainius <modax@debian.org>
Bug-Debian: http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=581896
Origin: vendor
Forwarded: yes
Last-Update: 2010-05-24


Reproducible: Always




Regardless of bindv6only/IP6_V6ONLY setting, sockets appear as {tcp,udp}6 in netstat. However, you may check if IPv4 works by trying to connect 127.0.0.1:<port> with e.g. telnet/netcat.

Again, the right solution is to open two sockets for both IPv6 and IPv4.
Comment 1 Joris Guisson 2010-05-25 21:04:19 UTC
SVN commit 1130596 by guisson:

Patch from modax: Make sure that KT binds correctly on systems with net.ipv6.bindv6only set to 1 

CCBUG: 238688

 M  +3 -0      ChangeLog  
 M  +10 -2     src/net/socket.cpp  


WebSVN link: http://websvn.kde.org/?view=rev&revision=1130596
Comment 2 Joris Guisson 2010-05-25 21:05:52 UTC
This is a workaround for the stable branch, final solution with 2 sockets will follow in trunk shortly.
Comment 3 Joris Guisson 2010-07-02 18:50:04 UTC
SVN commit 1145353 by guisson:

First batch of changes to make libktorrent listen on all addresses an interface is on instead of just one.
The modifications have been done for:
- TCP server
- DHT
- UDP tracker socket

In the process also convert some classes to d pointers, and increase the usage of shared pointers for some things.

CCBUG: 238688

 M  +1 -0      CMakeLists.txt  
 M  +4 -4      dht/announcetask.cpp  
 M  +1 -1      dht/announcetask.h  
 M  +13 -13    dht/dht.cpp  
 M  +8 -14     dht/dht.h  
 M  +2 -2      dht/kbucket.cpp  
 M  +1 -1      dht/kbucket.h  
 M  +2 -2      dht/node.cpp  
 M  +2 -2      dht/node.h  
 M  +6 -3      dht/nodelookup.cpp  
 M  +1 -1      dht/nodelookup.h  
 M  +3 -4      dht/rpccall.cpp  
 M  +7 -7      dht/rpccall.h  
 M  +65 -65    dht/rpcmsg.cpp  
 M  +44 -22    dht/rpcmsg.h  
 M  +182 -146  dht/rpcserver.cpp  
 M  +12 -20    dht/rpcserver.h  
 M  +2 -2      dht/task.cpp  
 M  +3 -3      dht/task.h  
 M  +7 -7      interfaces/serverinterface.cpp  
 M  +1 -0      net/CMakeLists.txt  
 A             net/serversocket.cpp   [License: GPL (v2+)]
 A             net/serversocket.h   [License: GPL (v2+)]
 M  +1 -9      net/socket.cpp  
 M  +3 -2      net/socket.h  
 M  +0 -1      torrent/globals.cpp  
 M  +47 -46    torrent/server.cpp  
 M  +3 -16     torrent/server.h  
 M  +1 -1      tracker/udptracker.cpp  
 M  +2 -2      tracker/udptracker.h  
 M  +96 -80    tracker/udptrackersocket.cpp  
 M  +12 -15    tracker/udptrackersocket.h  
 M  +16 -0     util/functions.cpp  
 M  +3 -0      util/functions.h  


WebSVN link: http://websvn.kde.org/?view=rev&revision=1145353
Comment 4 Joris Guisson 2010-07-05 19:57:41 UTC
SVN commit 1146324 by guisson:

Modify µTP code to listen on all addresses

CCBUG: 238688

 M  +3 -0      ChangeLog  
 M  +57 -21    src/net/serversocket.cpp  
 M  +34 -1     src/net/serversocket.h  
 M  +99 -79    src/utp/utpserver.cpp  
 M  +0 -2      src/utp/utpserver.h  
 M  +11 -5     src/utp/utpserver_p.h  


WebSVN link: http://websvn.kde.org/?view=rev&revision=1146324
Comment 5 Joris Guisson 2010-07-05 20:17:31 UTC
SVN commit 1146328 by guisson:

Ensure that webinterface plugin works properly with bindv6only flag on.

This is the last change for bug 238688, which can now be closed

BUG: 238688

 M  +1 -0      ChangeLog  
 M  +19 -27    plugins/webinterface/httpserver.cpp  
 M  +4 -5      plugins/webinterface/httpserver.h  


WebSVN link: http://websvn.kde.org/?view=rev&revision=1146328