Ticket #5086 enhancement new

Opened 2 years ago

Last modified 9 days ago

Accept IPv6 address literals (with embedded scope ids) in IReactorUDP.listenUDP

Reported by: exarkun Owned by:
Priority: normal Milestone:
Component: core Keywords: ipv6 review
Cc: Branch:
Author: Launchpad Bug:

Description (last modified by thijs) (diff)

Similarly to #5084, Twisted should provide low-level support for IPv6 UDP servers. IReactorUDP.listenUDP implementations should accept IPv6 address literals and set up a UDP port bound to that address.

Nothing about how IPv4 support is provided will change - IPv4 address literals and hostnames will continue to listen only on an IPv4 address. The default will still be to listen on INADDR_ANY, which does not include an IPv6 addresses.

The resulting IListeningPort will return an IPv6Address (see #5084) from its getHost implementations.

The protocol will be connected to an IUDPTransport implementation which also returns IPv6Address instances from its getHost implementation.

When a datagram is delivered to the server, the datagramReceived method will be invoked with the address returned by socket.recvfrom (nominally a 4 tuple giving address, port, flow info, and scope id), just as is the case for IPv4 (where only address and port are present in the tuple).

The IUDPTransport.write implementation in this case will also accept a 4 tuple of this sort. Sending to IPv6 addresses in this way is supported, but only if an IPv6 address literal was passed to listenUDP in the first place.

IUDPTransport.getHost is documented as returning IPv4Address instances. This should probably change.

Once this is resolved, Twisted servers should be able to bind UDP ports on IPv6 addresses, eg ::1 or fe80::1%lo0 or ::, as well as send datagrams to IPv6 address from such ports. Note that where the platform requires the scope id, IReactorUDP.listenUDP and IUDPTransport.write will require the scope id as well.

Attachments

fix-ipv6-literals-udp.patch Download (2.6 KB) - added by marto1_ 12 days ago.
fix-ipv6-literals-udp.2.patch Download (2.7 KB) - added by marto1_ 10 days ago.
Fixed patch, so all tests run, although twisted.scripts.test.test_tap2rpm fail sometimes.
fix-ipv6-literals-udp.3.patch Download (8.8 KB) - added by marto1_ 9 days ago.
fix-ipv6-literals-udp.4.patch Download (12.1 KB) - added by marto1_ 5 days ago.
Polished tests in twisted.test.test_udp
fix-ipv6-literals-udp.5.patch Download (25.7 KB) - added by marto1_ 3 days ago.
Here multicast works for v6 as far as loopback testing goes.

Change History

1

Changed 17 months ago by thijs

  • description modified (diff)

Changed 12 days ago by marto1_

2

Changed 12 days ago by marto1_

  • keywords review added

Changed 10 days ago by marto1_

Fixed patch, so all tests run, although twisted.scripts.test.test_tap2rpm fail sometimes.

3

Changed 10 days ago by exarkun

  • owner set to marto1_
  • keywords review removed

Thanks for your work on this issue. Can you also write unit tests for this functionality? All changes and new code needs to have complete automated test coverage before it can be applied to trunk.

Changed 9 days ago by marto1_

4

Changed 9 days ago by marto1_

  • keywords review added
  • owner marto1_ deleted

Changed 5 days ago by marto1_

Polished tests in twisted.test.test_udp

Changed 3 days ago by marto1_

Here multicast works for v6 as far as loopback testing goes.

Note: See TracTickets for help on using tickets.