IP_FREEBIND with IPv6

From: David Madore <hidden>
Date: 2013-09-24 09:33:15

Dear list,

I have two questions regarding the IP_FREEBIND option in IPv6.

Consider the following script, which sets IP_FREEBIND and then tries
to bind to some arbitrary non-local IPv6 address:

### cut after ###
#! /usr/bin/env python
import socket
if not hasattr(socket, 'IP_FREEBIND'):
    socket.IP_FREEBIND = 15
s = socket.socket(socket.AF_INET6, socket.SOCK_DGRAM)
s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
s.setsockopt(socket.SOL_IP, socket.IP_FREEBIND, 1)
s.bind(("fd42:dead:beef::1", 0))
print "success"
### cut before ###

* This fails (with EADDRNOTAVAIL) under the long-term 3.2 kernels (I
  tried with 3.2.50 and also the current Debian stable kernel,
  3.2.0-4-amd64).  On the other hand, it succeeds with a more recent
  kernel (I tried 3.10.10).  Is this to be considered a bug in the 3.2
  kernel?  I attempted to find which commit fixed this behavior,
  without success: can someone point out to the appropriate patch?
  Could this conceivably be proposed for inclusion in 3.2?

* If one sets net.ipv4.ip_nonlocal_bind to 1 then (according to ip(7))
  the script should work even without the s.setsockopt(socket.SOL_IP,
  socket.IP_FREEBIND, 1) line.  I have failed to make this work on any
  version of the kernel.  Again, is this a bug or a misunderstanding
  on my part of what net.ipv4.ip_nonlocal_bind should do?  (I am aware
  it says "ipv4" in the sysctl name, but since there is no
  corresponding net.ipv6.ip_nonlocal_bind, I don't see what else one
  is supposed to use.)

Best regards,

-- 
     David A. Madore
   ( http://www.madore.org/~david/ )
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help