Subject: Re: Is there any necessary to add multicast route for a loopback device?

From: Li Wei <[email-masked]>
Date: Thu, 01 Dec 2011 14:01:27 +0800

Eric Dumazet wrote:
> Le jeudi 01 décembre 2011 à 12:31 +0800, Li Wei a écrit :
>>> From: Li Wei <[email-masked]>
>>> Date: Thu, 01 Dec 2011 10:30:00 +0800
>>>
>>>> what's your opinion?
>>> I have many higher priority tasks than this issue, so it is a poor
>>> idea to try and force me to look into this.
>>>
>>> If no other developer cares to answer, maybe it isn't all that
>>> important.
>>>
>>>
>> My apologize :(
> 
> It would help us if you provide a test program an setup script, because
> we have litle time to figure out what exact problem you hit.
> 
> 
> 
> 
> 

Thanks Eric!

The following is the test code:
================================= cut ====================================
#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <errno.h>

#define MADDR	"ff00::00"

int main(int argc, char **argv) {
	struct ipv6_mreq mreq;
	struct in6_addr addr;
	unsigned int mcast_if;
	int sk;

	if((sk = socket(AF_INET6, SOCK_DGRAM, 0)) == -1) {
		printf("socket\n");
		exit(1);
	}

	inet_pton(AF_INET6, MADDR, &addr);
	mreq.ipv6mr_multiaddr = addr;

	printf("== join a multicast group with the interface index is specified as 0 ==\n");
	mreq.ipv6mr_interface = 0;
	if (setsockopt(sk, IPPROTO_IPV6, IPV6_JOIN_GROUP,
		       (char *) &mreq, sizeof(mreq)) == -1) {
		perror("setsockopt IPV6_JOIN_GROUP");
		exit(1);
	}

	close(sk);

	printf("OK\n");
	return 0;
}
================================= cut ====================================

My aim is to join a multicast group without the interface index specified, as the RFC 3493
(5.2 Sending and Receiving Multicast Packets) said "If the interface index is specified as 0,
the kernel chooses the local interface.".

When this test run on Fedora 15(ipv6 enabled), it failed and return error ENODEV.

This problem can be reproduced by the following steps:
1. enable ipv6 if you haven't
# modprobe ipv6
2. make all network interfaces down
# ip link set lo down; ip link set eth0 down; ...
3. set a ipv6 address for lo
# ip addr add ::1/128 dev lo
4. make all interfaces up
# ip link set lo up; ip link set eth0 up; ...

run test and it will return ENODEV