Multicast in Libbsd
Joel Sherrill
joel at rtems.org
Fri Jun 19 21:12:47 UTC 2020
This turned out to be a trivial problem but hard to figure out. :(
The code has a POSIX_Init which initializes the stack and then calls the
application's main() which spawns a number of threads which start using the
stack. I disabled the POSIX_Init from calling main(), added mcast-listener
and mcast-writer (standard net code I had) as shell programs, and then
telnet'ed into the target. I could telnet in twice and run a listener in
one session and a writer in another. This proved that multicast was working
and made me wonder if there was a race condition on stack initialization
since it takes a little while to login twice and run two programs.
I put a sleep(10) before calling main() and the program came up. Based on
its output, it got through initialization but then faulted. I tracked that
down to RTEMS implementation of posix_devctl() being correct and the
adapter being used on Linux was incorrect.
*** Is there a reliable way to know the stack is settled out before the
application can run?
*** I still have to get the multicast out of qemu but that's another issue.
Thanks for the suggestions everyone.
--joel
On Fri, Jun 19, 2020 at 2:35 PM Heinz Junkes <junkes at fhi-berlin.mpg.de>
wrote:
> I can agree with Cedric.
>
> I use rtems5 with rtems-libbsd. I initialize the network interfaces of my
> target via dhcpcd
> and the interfaces are automatically multicast capable.
>
> This works without creating a route:
>
> if (setsockopt(conf->udp, IPPROTO_IP, IP_ADD_MEMBERSHIP,
> (char *) &mreq, sizeof(mreq))!=0) {
> struct sockaddr_in temp;
> char name[40];
> ...
>
> Heinz
>
>
> > On 19. Jun 2020, at 17:53, Cedric Berger <cedric at precidata.com> wrote:
> >
> > On 18.06.20 22:47, Joel Sherrill wrote:
> >
> >> Hi
> >>
> >> I have an example FACE application I am trying to port to RTEMS. This
> is a multi-question email:
> >>
> >> First, it fails with EADDRNOTAVAIL on this call:
> >>
> >> // Subscribe to multicast group
> >> struct ip_mreq mreq;
> >> rc = inet_pton(AF_INET, multicastGroup_m,
> &mreq.imr_multiaddr.s_addr);
> >> mreq.imr_interface.s_addr = htonl(INADDR_ANY);
> >> rc = setsockopt(
> >> new_socket,
> >> IPPROTO_IP,
> >> IP_ADD_MEMBERSHIP,
> >> &mreq,
> >> sizeof(mreq)
> >> );
> >>
> >> I assume that is because there is no multicast route. On Linux, you
> have to do an ifconfig and route to have a multicast route, but I haven't
> been able to find a multicast setup example for FreeBSD. The Linux commands
> are:
> >>
> >> ifconfig lo multicast
> >> route add -net 224.0.0.0 netmask 240.0.0.0 dev lo
> > This:
> >
> > https://gist.github.com/hostilefork/f7cae3dc33e7416f2dd25a402857b6c6
> >
> > Compiles and run without any special configuration on FreeBSD 12.1
> >
> > The handbook claims that "Multicast applications do not require any
> special configuration in order to run on FreeBSD"
> >
> > https://www.freebsd.org/doc/handbook/network-routing.html
> >
> > Following is the routing table on a FreeBSD jail with no special 224
> route needed.
> >
> > Cédric
> >
> > # netstat -nr
> > Routing tables
> >
> > Internet:
> > Destination Gateway Flags Netif Expire
> > default 172.18.12.1 UGS epair25b
> > 127.0.0.1 link#1 UH lo0
> > 172.18.12.0/24 link#3 U epair25b
> > 172.18.12.25 link#3 UHS lo0
> >
> > Internet6:
> > Destination Gateway Flags
> Netif Expire
> > ::/96 ::1 UGRS
> lo0
> > ::1 link#1 UH
> lo0
> > ::ffff:0.0.0.0/96 ::1 UGRS
> lo0
> > fe80::/10 ::1 UGRS
> lo0
> > fe80::%lo0/64 link#1 U
> lo0
> > fe80::1%lo0 link#1 UHS
> lo0
> > ff02::/16 ::1 UGRS
> lo0
> >
> >
> >
> > _______________________________________________
> > devel mailing list
> > devel at rtems.org
> > http://lists.rtems.org/mailman/listinfo/devel
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.rtems.org/pipermail/devel/attachments/20200619/9318884d/attachment.html>
More information about the devel
mailing list