Opened 8 years ago

Closed 8 years ago

#2738 closed Bug (fixed)

DHT dosn't detect an ipv6 or ipv4 address change

Reported by: chris-jericho Owned by: klapaucjusz
Priority: High Milestone: 2.00
Component: libtransmission Version: 1.76
Severity: Normal Keywords: dht
Cc: jch@…

Description

After either an ipv6 or ipv4 address change, Transmission keeps using the old addresses for DHT communication (udp), even if the addresses aren't configured anymore on the interface (!), until it is restarted. TCP connections to peers quickly die and are retried with the new addresses, though.

Transmission should have a way to detect when a network parameter has changed. Adium, for example, does this on OSX : If I disable airport (wireless connection), Adium sets all my IM accounts offline and tries to reconnect them automatically as soon as a network connection becomes available.

The bug happens when either the ipv6, ipv4 or both address change.

Attachments (2)

0001-Fix-rebinding-of-the-IPv6-DHT-socket.patch (3.5 KB) - added by jch 8 years ago.
0001-Fix-the-IPv6-DHT-broken-by-r10616.patch (1.5 KB) - added by jch 8 years ago.

Download all attachments as: .zip

Change History (23)

comment:1 Changed 8 years ago by chris-jericho

I figured out I forgot to say I'm using OSX Leopard (10.5.8) powerpc.

comment:2 Changed 8 years ago by jch

Are you positive about that?

The IPv4 address change should be taken into account straight away (the IPv4 socket is not bound to a particular address). The IPv6 address change will be noticed within 30 minutes (check tr_globalIPv6).

--Juliusz

comment:3 Changed 8 years ago by charles

  • Keywords needinfo added

chris-jericho: if you wait 30 minutes as suggested by jch, does the IPv6 address change get noticed?

comment:4 Changed 8 years ago by chris-jericho

Sorry for the late reply, I was out of town.

I just tested it for more than 45 minutes and the ipv6 change isn't noticed at all. Transmission keeps using the old address (maybe it doesn't rebind the socket?) forever for outgoing DHT packets.

As I was tired of playing with ifconfig just to remove/change addresses I enabled the ipv6 privacy extensions, which generates a different address each time you reconnect to the network. This can be enabled with sysctl -w net.inet6.ip6.use_tempaddr=1 . Thus, to get another ipv6 in my subnet all I need to do is turn airport off and on again.

A tcpdump trace still shows that after 4 reconnects and more than half an hour, T still uses the old address it was bound to when it started. No reply is ever received, though (which is expected as the address used isn't assigned to the interface anymore)

I can make a tcpdump trace if you want.

comment:5 Changed 8 years ago by charles

  • Cc jch@… added

CC'ing jch in case he missed the response

comment:6 Changed 8 years ago by jch

  • Keywords dht added; ipv4 ipv6 address change needinfo removed
  • Owner set to jch

comment:7 Changed 8 years ago by jch

Confirmed.

comment:8 Changed 8 years ago by jch

My bad, I didn't realise that bind cannot rebind an already-bound socket.

Here's a quick fix, a proper fix will need to wait until I add the needed interface to the DHT, which is not completely trivial.

Chris, do you confirm the issue for IPv4 too? If so, that's something else.

comment:9 Changed 8 years ago by jch

  • Owner changed from jch to charles

comment:10 Changed 8 years ago by charles

  • Priority changed from Normal to Low

comment:11 Changed 8 years ago by chris-jericho

I think the issue showed up while changing ipv4 addresses with ifconfig too, but i'm not sure. I'll test this week end when I'm on a mac (i'm on linux here).

Is it possible to have a nightly build with your patch applied? So I can test whether it fixes the problem for v6 or not. (I still can't find Xcode for leopard anywhere...)

comment:12 Changed 8 years ago by charles

  • Version changed from 1.76+ to 1.76

comment:13 Changed 8 years ago by chris-jericho

Well I sometimes find OSX's inner workings quite puzzling... When changing the ipv4 address via the network configuration panel, the change is immediately picked up. When using ifconfig, it's not... go figure, but at least, it seems to work as expected over ipv4.

I still couldn't test your patch, though.

comment:14 Changed 8 years ago by charles

jch: is this patch still valid? Should it be included in 2.00?

comment:15 Changed 8 years ago by charles

  • Milestone changed from None Set to 2.00
  • Owner changed from charles to klapaucjusz

21:55:46 < CIA-40> charles * r10616 libtransmission/tr-dht.c: (trunk libT) commit jch's patch for #2738: "fix rebinding of the IPv DHT socket"

comment:16 Changed 8 years ago by charles

  • Resolution set to fixed
  • Status changed from new to closed

comment:17 Changed 8 years ago by jch

Reopening, this is not quite done yet.

This version deals fine with address changes, but it doesn't yet do the right thing if the machine loses/acquires IPv6 while Transmission is running. Fixing that is not completely trivial, and will require changes to third-party/dht/.

comment:18 Changed 8 years ago by jch

  • Milestone changed from 2.00 to Sometime
  • Resolution fixed deleted
  • Status changed from closed to reopened

comment:19 Changed 8 years ago by jch

Sorry for that. Please apply.

--Juliusz

comment:20 Changed 8 years ago by jch

  • Component changed from Transmission to libtransmission
  • Milestone changed from Sometime to 2.00
  • Priority changed from Low to High

comment:21 Changed 8 years ago by livings124

  • Resolution set to fixed
  • Status changed from reopened to closed

r10623 applies the patch (with tr_bool instead of ints :-p)

Note: See TracTickets for help on using tickets.