Menu

Can't join multicast group on OS X 10.8.5

2015-01-12
2015-01-14
  • Kyle Rhorer

    Kyle Rhorer - 2015-01-12

    Hello,

    I compiled uftp on OS X 10.9.5 because I'm not allowed to install gcc on the target systems. Target systems are 10.8.5. When I run uftpd on a target system, I get:

    $ ./uftpd -d -I en0 -x 5
    2015/01/11 20:12:17.517648: UFTP version 4.6  Copyright (C) 2001-2014  Dennis A. Bush
    2015/01/11 20:12:34.868112: tos / traffic class byte = 00
    2015/01/11 20:12:34.870525: [F2E8C048:0]: Received request from C0A81922 at 192.168.25.34 (192.168.25.34)
    2015/01/11 20:12:34.870536: [F2E8C048:0]: Using private multicast address 230.5.5.63
    2015/01/11 20:12:34.870542: [F2E8C048:0]: grtt = 0.532216
    2015/01/11 20:12:34.870551: [F2E8C048:0]: send time: 1421028754.868018
    2015/01/11 20:12:34.870557: [F2E8C048:0]: receive time: 1421028754.868127
    2015/01/11 20:12:34.870573: [F2E8C048:0]: Error joining multicast group: Invalid argument
    2015/01/11 20:12:36.369363: tos / traffic class byte = 00
    2015/01/11 20:12:36.370545: [F2E8C048:0]: Received request from C0A81922 at 192.168.25.34 (192.168.25.34)
    2015/01/11 20:12:36.370555: [F2E8C048:0]: Using private multicast address 230.5.5.63
    2015/01/11 20:12:36.370561: [F2E8C048:0]: grtt = 0.532216
    2015/01/11 20:12:36.370569: [F2E8C048:0]: send time: 1421028756.369128
    2015/01/11 20:12:36.370574: [F2E8C048:0]: receive time: 1421028756.369378
    2015/01/11 20:12:36.370584: [F2E8C048:0]: Error joining multicast group: Invalid argument
    

    I've tried adding a multicast route (route add -net 224.0.0.0/5 192.168....) but that did not help. I will try running on 10.9.5 to see if it works there but won't have access until tomorrow. In the mean time, does anyone have any suggestions?

    Thanks!

     
  • Kyle Rhorer

    Kyle Rhorer - 2015-01-12

    Just tried it from 10.9.5 and 10.10.1 with the same results as before:

    $ ./uftpd -d
    2015/01/12 10:17:02.552700: UFTP version 4.6  Copyright (C) 2001-2014  Dennis A. Bush
    2015/01/12 10:17:24.003351: [376E914A:0]: Received request from 8BA9CA23 at <redacted IP addr> (redacted)
    2015/01/12 10:17:24.003367: [376E914A:0]: Using private multicast address 230.5.5.180
    2015/01/12 10:17:24.003386: [376E914A:0]: Error joining multicast group: Invalid argument
    

    Here is some additional information:

    $ uname -a
    Darwin hostname.local 14.0.0 Darwin Kernel Version 14.0.0: Fri Sep 19 00:26:44 PDT 2014; root:xnu-2782.1.97~2/RELEASE_X86_64 x86_64
    $ make NO_ENCRYPTION=1
    gcc -g -Wall -DHAS_GETIFADDRS -DNO_ENCRYPTION    -c uftp_common.c
    gcc -g -Wall -DHAS_GETIFADDRS -DNO_ENCRYPTION    -c encrypt_none.c
    gcc -g -Wall -DHAS_GETIFADDRS -DNO_ENCRYPTION    -c server_announce.c
    gcc -g -Wall -DHAS_GETIFADDRS -DNO_ENCRYPTION    -c server_transfer.c
    gcc -g -Wall -DHAS_GETIFADDRS -DNO_ENCRYPTION    -c server_send.c
    gcc -g -Wall -DHAS_GETIFADDRS -DNO_ENCRYPTION    -c server_phase.c
    gcc -g -Wall -DHAS_GETIFADDRS -DNO_ENCRYPTION    -c server_common.c
    gcc -g -Wall -DHAS_GETIFADDRS -DNO_ENCRYPTION    -c server_config.c
    gcc -g -Wall -DHAS_GETIFADDRS -DNO_ENCRYPTION    -c server_init.c
    gcc -g -Wall -DHAS_GETIFADDRS -DNO_ENCRYPTION    -c server_main.c
    gcc -g -Wall -DHAS_GETIFADDRS -DNO_ENCRYPTION  -o uftp uftp_common.o encrypt_none.o server_announce.o server_transfer.o server_send.o server_phase.o server_common.o server_config.o server_init.o server_main.o -lc -lm   -lpthread
    gcc -g -Wall -DHAS_GETIFADDRS -DNO_ENCRYPTION    -c client_loop.c
    gcc -g -Wall -DHAS_GETIFADDRS -DNO_ENCRYPTION    -c client_announce.c
    gcc -g -Wall -DHAS_GETIFADDRS -DNO_ENCRYPTION    -c client_fileinfo.c
    gcc -g -Wall -DHAS_GETIFADDRS -DNO_ENCRYPTION    -c client_transfer.c
    gcc -g -Wall -DHAS_GETIFADDRS -DNO_ENCRYPTION    -c client_common.c
    gcc -g -Wall -DHAS_GETIFADDRS -DNO_ENCRYPTION    -c client_config.c
    gcc -g -Wall -DHAS_GETIFADDRS -DNO_ENCRYPTION    -c client_init.c
    gcc -g -Wall -DHAS_GETIFADDRS -DNO_ENCRYPTION    -c client_main.c
    gcc -g -Wall -DHAS_GETIFADDRS -DNO_ENCRYPTION    -c heartbeat_send.c
    gcc -g -Wall -DHAS_GETIFADDRS -DNO_ENCRYPTION  -o uftpd uftp_common.o encrypt_none.o client_loop.o client_announce.o client_fileinfo.o client_transfer.o client_common.o client_config.o client_init.o client_main.o heartbeat_send.o -lc -lm 
    gcc -g -Wall -DHAS_GETIFADDRS -DNO_ENCRYPTION    -c proxy_loop.c
    gcc -g -Wall -DHAS_GETIFADDRS -DNO_ENCRYPTION    -c proxy_upstream.c
    gcc -g -Wall -DHAS_GETIFADDRS -DNO_ENCRYPTION    -c proxy_downstream.c
    gcc -g -Wall -DHAS_GETIFADDRS -DNO_ENCRYPTION    -c proxy_common.c
    gcc -g -Wall -DHAS_GETIFADDRS -DNO_ENCRYPTION    -c proxy_config.c
    gcc -g -Wall -DHAS_GETIFADDRS -DNO_ENCRYPTION    -c proxy_init.c
    gcc -g -Wall -DHAS_GETIFADDRS -DNO_ENCRYPTION    -c proxy_main.c
    gcc -g -Wall -DHAS_GETIFADDRS -DNO_ENCRYPTION  -o uftpproxyd uftp_common.o encrypt_none.o proxy_loop.o proxy_upstream.o proxy_downstream.o proxy_common.o proxy_config.o proxy_init.o proxy_main.o heartbeat_send.o -lc -lm 
    gcc -g -Wall -DHAS_GETIFADDRS -DNO_ENCRYPTION    -c uftp_keymgt.c
    gcc -g -Wall -DHAS_GETIFADDRS -DNO_ENCRYPTION  -o uftp_keymgt uftp_keymgt.o uftp_common.o encrypt_none.o -lc -lm
    $ ifconfig en0
    en0: flags=8863<UP,BROADCAST,SMART,RUNNING,SIMPLEX,MULTICAST> mtu 1500
        options=10b<RXCSUM,TXCSUM,VLAN_HWTAGGING,AV>
        ether 10:dd:b1:xx:xx:xx 
        inet 192.168.1.5 netmask 0xffffff00 broadcast 192.168.1.255
        media: autoselect (1000baseT <full-duplex>)
        status: active  
    

    The end result is the same whether I specify NO_ENCRYPTION or not, but the compile is cleaner without encryption support and I don't need encryption for my particular use.

     

    Last edit: Kyle Rhorer 2015-01-12
  • Dennis Bush

    Dennis Bush - 2015-01-13

    It's puzzling that you're able to register on the public multicast address but not the private multicast address. I don't have a Mac handy so I can't try this out myself.

    Try using different private addresses (-P option on the server) to see if that makes a difference. Also, insert some extra logging right before the call to setsockopt (uftp_common.c:1764) to print the contents of the mreq struct to verify nothing's wrong there.

     
  • Kyle Rhorer

    Kyle Rhorer - 2015-01-14

    It seems that the setsockopt() call that's failing is the one at line 1633. I couldn't find the struct definition of group_req to properly print the whole structure. Here is the code starting at line 1630:

            if (fplist_len == 0) {
                greq.gr_interface = addrlist[i].ifidx;
                greq.gr_group = multi->ss;
                if (setsockopt(s, level, MCAST_JOIN_GROUP,
                        (char *)&greq, sizeof(greq)) == -1) {
                    log0(0, 0, "s=%d", s);
                    log0(0, 0, "level=%d", level);
                    log0(0, 0, "MCAST_JOIN_GROUP=%d", MCAST_JOIN_GROUP);
                    log0(0, 0, "greq.gr_interface=%d", greq.gr_interface);
                    log0(0, 0, "greq.gr_group=%d", greq.gr_group);
                    log0(0, 0, "greq=%s", (char *)&greq);
                    log0(0, 0, "sizeof(greq)=%d", sizeof(greq));
                    sockerror(group_id, 0, "Error joining multicast group");
                    return 0;
                }
    

    and here is the output:

    $ ./uftpd -d
    2015/01/13 23:38:32.742413: UFTP version 4.6  Copyright (C) 2001-2014  Dennis A. Bush
    2015/01/13 23:38:42.245343: [62339AB2:0]: Received request from 0A00000D at 10.0.0.13 (10.0.0.13)
    2015/01/13 23:38:42.245366: [62339AB2:0]: Using private multicast address 230.5.5.176
    2015/01/13 23:38:42.245397: s=3
    2015/01/13 23:38:42.245405: level=0
    2015/01/13 23:38:42.245412: MCAST_JOIN_GROUP=80
    2015/01/13 23:38:42.245447: greq.gr_interface=5
    2015/01/13 23:38:42.245455: greq.gr_group=512
    2015/01/13 23:38:42.245462: greq=
    2015/01/13 23:38:42.245468: sizeof(greq)=132
    2015/01/13 23:38:42.245475: [62339AB2:0]: Error joining multicast group: Invalid argument
    

    This is interface 5 (I'm on a different box than before):

    en1: flags=8863<UP,BROADCAST,SMART,RUNNING,SIMPLEX,MULTICAST> mtu 1500
        ether 00:26:08:xx:xx:xx 
        inet6 fe80::226:xxxx:xxxx:xxxx%en1 prefixlen 64 scopeid 0x5 
        inet 10.0.0.13 netmask 0xffffff00 broadcast 10.0.0.255
        nd6 options=1<PERFORMNUD>
        media: autoselect
        status: active
    
     

    Last edit: Kyle Rhorer 2015-01-14
  • Dennis Bush

    Dennis Bush - 2015-01-14

    It looks like the MCAST_JOIN_GROUP option doesn't work properly on OSX.

    On line 1602 of uftp_common.c is this:

    #if ((!defined WINDOWS) && (defined MCAST_JOIN_GROUP))
    

    Change it to this:

    #if 0
    

    and this will switch to using IP_ADD_MEMBERSHIP / IP_ADD_SOURCE_MEMBERSHIP to join multicast groups. I'll work on a more permanent fix for this.

     
  • Kyle Rhorer

    Kyle Rhorer - 2015-01-14

    Thank you! It is now able to transfer files on the same host via multicast. I will test transfers with multiple machines in the next day or so.

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.