Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 23 Mar 2018 00:39:29 +0100
From:      Andreas Scherrer <ascherrer@gmail.com>
To:        freebsd-net@freebsd.org
Cc:        sunpoet@FreeBSD.org
Subject:   Re: Multicast/SSDP not working (on VLAN interface)
Message-ID:  <bc610a15-e583-517f-3e58-8b9e2ef62b95@gmail.com>
In-Reply-To: <201803220015.w2M0FFbg023791@pdx.rh.CN85.dnsmgr.net>
References:  <201803220015.w2M0FFbg023791@pdx.rh.CN85.dnsmgr.net>

next in thread | previous in thread | raw e-mail | index | archive | help
@sunpoet@FreeBSD.org: as you are the (brand new?) maintainer of the 
miniDLNA port for FreeBSD, my hopes are with you :D

tl;dr
"setsockopt" should be replaced by "sourcefilter" (at least in 
minissdp.c's "AddMulticastMembership)

On 22.03.18 01:15, Rodney W. Grimes wrote:

...

> Try as a very first rules:
> 
> ipfw add 1 log allow ip from any to 224.0.0.0/4
> ipfw add 2 log allow ip from 224.0.0.0/4 to any
> 
> DO NOT put any restricting clauses on these.. if this makes things
> work simply move them down a few rules until you find the point
> at which things stop working.

I tried this; to no avail.

But it got me on the right track! MiniDLNA was actually (trying to) send 
IGMPv3 packets (224.0.0.22) back to the client but they were following 
the default route!

The problem is here (please excuse if I do not get all the terminology 
right, I am not a network programmer):

The function "AddMulticastMembership" in minissdp.c uses the "ip_mreqn" 
struct to call "setsockopt" for "IP_ADD_MEMBERSHIP".

It is trying to use an interface index "imr.imr_ifindex = 
iface->ifindex" in "ip_mreqn".

The code I am talking about can be found here:
https://sourceforge.net/p/minidlna/git/ci/master/tree/minissdp.c#l69

Using an interface index for "IP_ADD_MEMBERSHIP" is not supported (since 
FreeBSD 7.0):

-----
A host must become a member of a multicast group before it can receive
datagrams sent to the group. To join a multicast group, use the 
IP_ADD_MEMBERSHIP option:

struct ip_mreq mreq;
setsockopt(s, IPPROTO_IP, IP_ADD_MEMBERSHIP, &mreq, sizeof(mreq));

where mreq is the following structure:

struct ip_mreq {
  struct   in_addr   imr_multiaddr; /* IP multicast address of group  */
  struct   in_addr   imr_interface; /* local IP address of interface  */
}

imr_interface should be set to the IP address of a particular multicast-
capable interface if the host is multihomed.  It may be set to 
INADDR_ANY to choose the default interface, although this is not 
recommended; this is considered to be the first interface corresponding 
to the default route. Otherwise, the first multicast-capable interface 
configured in the system will be used.

Prior to FreeBSD 7.0, if the imr_interface member is within the network
range 0.0.0.0/8, it is treated as an interface index in the system 
interface MIB, as per the RIP Version 2	MIB Extension (RFC-1724). In 
versions of FreeBSD since 7.0, this behavior is no longer supported. 
Developers should instead use the RFC 3678 multicast source filter APIs; 
in particular, MCAST_JOIN_GROUP.
-----

As documented here:
https://www.freebsd.org/cgi/man.cgi?query=ip&apropos=0&sektion=4&manpath=FreeBSD+11.1-RELEASE&arch=default&format=html

I have verified that things start to work when I forced the "other 
execution path" in "AddMulticastMembership" (using "ip_mreq" instead of 
"ip_mreqn"; I have achieved this by changing the "#ifdef 
HAVE_STRUCT_IP_MREQN" statement into it's negated form "#ifndef 
HAVE_STRUCT_IP_MREQN").

Unfortunately I am not qualified to (properly) fix this :(

I read the statement that MCAST_JOIN_GROUP should be used (meaning 
replace "setsockopt" with "sourcefilter", if I get that correctly). But 
I do not really understand what that means/how to do that.

https://www.freebsd.org/cgi/man.cgi?query=sourcefilter&apropos=0&sektion=3&manpath=FreeBSD+11.1-RELEASE&arch=default&format=html

If someone could point me in the right direction (a tutorial how 
"sourcefilter" must be used for example), I might be able to come up 
with something that can be developed into a proper patch. Of course, if 
someone can fix this right away, that would be even better.


Best regards
andreas



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?bc610a15-e583-517f-3e58-8b9e2ef62b95>