The internal miniserver.c uses INADDR_ANY instead of the HostIP/IfName provided when initializing libupnp. But, this HostIP/IfName gets used for the UDP socket when multicasting SSDP messages.
In my situation this causes a problem, since I want to use libupnp with 127.0.0.1 (localhost) but the SSDP multicast gets signalled to the regular network interface as well, where another software connects to the miniserver, thus binding the miniserver's socket to that particular interface and not to 127.0.0.1 (INADDRY_ANY binds the socket to the first interface a connection attempt is received from).
Attached patch fixes this issue for IPV4. Unfortunately, I don't know how to handle this for IPV6 (which I don't need btw.).
Is there any reason to explicitly use INADDR_ANY for the miniserver? Or could you consider using the attached patch and extend it for IPV6?
This updated patch should fix it for both IPv4 and IPv6.
Klaus,
I have committed Nick's patch, please test and report.
Regards,
Marcelo.
Test result was positive; I could only test IPV4, not IPV6 case, though.
Regards,
Klaus
Hi Marcelo, sorry but I think you've committed the IPv4 only patch in 4f98a55c. I added IPv6 support in the first comment but forgot to rename the patch to make it clear, sorry.
Ok Nick, just did the correction to your first patch.
Klaus, would you mind testing the new version, since it is different from the other one?
Regards,
Marcelo.
Hi Marcelo,
Test result was positive on this one too. Again, I could only test IPV4, not IPV6 case.
Thanks for committing the patch!
Regards,
Klaus
Ok, Klaus, thanks!
Closing the issue.
Forwarding an email I have received from Uwe Kleine-König.
Control: tag 813249 + upstream
[adding Marcelo Roberto Jimenez (i.e. upstream) to Cc]
Hello,
On 01/30/2016 11:05 PM, Uwe Kleine-König wrote:
No, it's not, it's a regression from
that is upstream bug 127[1]. When reverting that one, vlc works as
expected (and before).
While searching for the problem I stumbled about the following paragraph
in ipv6(7):
ERRORS
ENODEV The user tried to bind(2) to a link-local IPv6 address,
but the sin6_scope_id in the supplied sockaddr_in6
structure is not a valid interface index.
This doesn't match EINVAL that I'm seeing, but still is the problem I
think. libupnp (and also netcat) pass 0, which isn't a valid scope_id.
(The valid scope_ids can be determined from either $(ip link) or with
the SIOCGIFINDEX ioctl on a socket (see netdevice(7)). Not sure how
portable to non-Linux architectures that is though.
Best regards
Uwe
Last edit: Marcelo Roberto Jimenez 2016-02-01
Hi,
I ran across this thread while trying to figure out why VLC fails to find any UPnP/DLNA servers on my local network. Reverting the miniserver_IPV4_INADDR_ANY.patch and rebuilding resolved the issue for me. I realize that this is opting for one use case over the other, but the patch (which is now committed in the 1.6.20 release) is preventing use of VLC as a UPnP/DLNA client.
Perhaps you could revisit this for the next release?
Thank you,
tony
Other references:
* https://bugs.launchpad.net/ubuntu/+source/libupnp/+bug/1571199
* https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=813249
Hi Tony,
shoudln't using INADDR_ANY as IP address during libupnp initialization have the same effect as reverting the patch? Since before the patch, INADDR_ANY was used internally for binding instead of the IP address supplied during initialzation. So wouldn't the best solution be to keep the patch but change the initialization of libupnp, probably inside VLC?
Best regards,
Klaus
Hi Klaus,
That's a good idea. I'll look into getting VLC working against an unpatched libupnp (version 1.6.20).
Cheers,
tony