From nobody Mon Apr 29 17:52:28 2024 X-Original-To: freebsd-hackers@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4VSrWp0j3sz5JmhD for ; Mon, 29 Apr 2024 17:52:38 +0000 (UTC) (envelope-from freebsd-rwg@gndrsh.dnsmgr.net) Received: from gndrsh.dnsmgr.net (pdx.rh.CN85.dnsmgr.net [65.75.216.6]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 4VSrWn42bXz4fDQ for ; Mon, 29 Apr 2024 17:52:37 +0000 (UTC) (envelope-from freebsd-rwg@gndrsh.dnsmgr.net) Authentication-Results: mx1.freebsd.org; none Received: from gndrsh.dnsmgr.net (localhost [127.0.0.1]) by gndrsh.dnsmgr.net (8.13.3/8.13.3) with ESMTP id 43THqUNk074360; Mon, 29 Apr 2024 10:52:30 -0700 (PDT) (envelope-from freebsd-rwg@gndrsh.dnsmgr.net) Received: (from freebsd-rwg@localhost) by gndrsh.dnsmgr.net (8.13.3/8.13.3/Submit) id 43THqS5l074359; Mon, 29 Apr 2024 10:52:28 -0700 (PDT) (envelope-from freebsd-rwg) From: "Rodney W. Grimes" Message-Id: <202404291752.43THqS5l074359@gndrsh.dnsmgr.net> Subject: Re: Multicast & Tunnel devices In-Reply-To: <2C4BC70A-750C-4E0F-B400-351CBBD6374B@webweaving.org> To: Dirk-Willem van Gulik Date: Mon, 29 Apr 2024 10:52:28 -0700 (PDT) CC: "Rodney W. Grimes" , FreeBSD Hackers X-Mailer: ELM [version 2.4ME+ PL121h (25)] List-Id: Technical discussions relating to FreeBSD List-Archive: https://lists.freebsd.org/archives/freebsd-hackers List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-freebsd-hackers@FreeBSD.org MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=US-ASCII X-Spamd-Bar: ---- X-Rspamd-Pre-Result: action=no action; module=replies; Message is reply to one we originated X-Spamd-Result: default: False [-4.00 / 15.00]; REPLY(-4.00)[]; ASN(0.00)[asn:10494, ipnet:65.75.216.0/23, country:US] X-Rspamd-Queue-Id: 4VSrWn42bXz4fDQ > > > > On 29 Apr 2024, at 03:09, Rodney W. Grimes wrote: > > > >> Would anyone know if there is something special with tunnel devices and multicast ? > >> > >> I?ve got some code that happily processes multicast packets on a normal interface; but appears not to do this on a tunnel interface. Tun0 shows multicast enabled: > >> > >> tun0: flags=8043 metric 0 mtu 1500 > >> > >> Tcpdump on that interface gives the expected thing (here with mDNS): > >> > >> tcpdump -n -i tun0 port 5353 > >> listening on tun0, link-type NULL (BSD loopback), capture size 262144 bytes > >> 19:26:03.976259 IP 10.31.0.6.5353 > 224.0.0.251.5353: 0 PTR (QM)? _raop._tcp.local. (34) > >> > >> And code, with a simple IP_ADD_MEMBERSHIP of the MC group on the IP of the local interface below works on a normal interface (e.g. igb0/10.0.0.1/24). > >> > >> ./listener 10.0.0.1 224.0.0.251 5353 > > > > Is 10.0.0.1 the IP address of tun0, or is it the address of some other interface? > > I suspect that the IP address of the tun0 interface is 10.31.0.6 from your tcpdump above. > > That is correct 10.0.0.1/8. 10.31.0.6 is another machine at the other end of the tunnel broadcasting. > > > IIRC you have to join multicast group on all interfaces you expect to receive mustcast packets on. > > > >> Received packet, len=128 > >> etc > >> > >> But yields no output if ran against above tun0 interface (while tcpdump on same is fine). Does that ring a bell with anyone ? > >> > >> Dw > >> > >> > >> int main(int argc, char *argv[]) > >> { > >> struct sockaddr_in addr; > >> struct ip_mreq mreq; > >> > >> // skip error trapping command line arguments > >> > >> char* ip = argv[1]; > >> char* group = argv[2]; > >> int port = atoi(argv[3]); // 0 if error, which is an invalid port > >> > >> memset(&addr, 0, sizeof(addr)); > >> addr.sin_family = AF_INET; > >> addr.sin_addr.s_addr = htonl(INADDR_ANY); > >> addr.sin_port = htons(port); > >> > >> mreq.imr_interface.s_addr = inet_addr(ip); > >> mreq.imr_multiaddr.s_addr = inet_addr(group); > >> > >> // skip error trapping on inet_addr > >> > >> int fd = socket(AF_INET, SOCK_DGRAM, 0); > >> // skip error trapping socket > >> > >> if (bind(fd, (struct sockaddr*) &addr, sizeof(addr)) < 0) { > >> // skip error trapping > >> > >> if (setsockopt(fd, IPPROTO_IP, IP_ADD_MEMBERSHIP, (char*) &mreq, sizeof(mreq)) < 0 ){ > >> // skip error trapping argumetns > >> > >> while (1) { > >> .. > >> int nbytes = recvfrom(fd,msgbuf,MSGBUFSIZE,0,(struct sockaddr *) &addr,&addrlen); > >> if (nbytes < 0) { > >> perror("recvfrom"); > >> return 1; > >> } > >> printf(?Received packet, len=%d\n", nbytes); > >> } > >> > -- Rod Grimes rgrimes@freebsd.org