netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* JOIN_ANYCAST breakage w. "net: ipv6: put host and anycast routes on device with address"
@ 2017-11-14 17:36 Florian Westphal
  2017-11-15 15:57 ` David Ahern
  2017-11-18  0:09 ` David Ahern
  0 siblings, 2 replies; 4+ messages in thread
From: Florian Westphal @ 2017-11-14 17:36 UTC (permalink / raw)
  To: David Ahern; +Cc: netdev

Hi David

This test program no longer works with 4.14
(recvfrom: Resource temporarily unavailable)

after reverting commit
4832c30d5458387ff2533ff66fbde26ad8bb5a2d
(net: ipv6: put host and anycast routes on device with address)

it will work again ("OK").

Could you please have a look at this?

Thanks!
----------------------
#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <string.h>
#include <netinet/in.h>
#include <errno.h>
#include <sys/ioctl.h>

#include <unistd.h>
#include <stdint.h>

#define ADDR	"fe80::1"
#define MAGIC	0x1c3c01a

int main(int argc, char *argv[])
{
	struct ipv6_mreq nreq = {};
	struct sockaddr_in6 addr = {
		.sin6_family = AF_INET6,
		.sin6_port = htons(12345),
	};
	int fd, fd2, index, tmp;

	if (argc < 2)
		return 1;

	fd = socket(AF_INET6, SOCK_DGRAM, 0);
	fd2 = socket(AF_INET6, SOCK_DGRAM, 0);
	if (fd < 0 || fd2 < 0) {
		perror("socket");
		return 1;
	}
	index = if_nametoindex(argv[1]);
	if (index <= 0) {
		perror("if_nametoindex");
		return 1;
	}

	nreq.ipv6mr_interface = index;
	inet_pton(AF_INET6, ADDR, &nreq.ipv6mr_multiaddr);
	if (setsockopt(fd, IPPROTO_IPV6, IPV6_JOIN_ANYCAST,
	    &nreq, sizeof(nreq)) < 0) {
		perror("setsockopt");
		return 1;
	}

	addr.sin6_addr = in6addr_any;
	if (bind(fd, (struct sockaddr *)&addr, sizeof(addr)) < 0) {
		perror("bind");
		return 1;
	}

	addr.sin6_port = htons(12346);
	inet_pton(AF_INET6, "::", &addr.sin6_addr);
	if (bind(fd2, (struct sockaddr *)&addr, sizeof(addr)) < 0) {
		perror("bind");
		return 1;
	}

	inet_pton(AF_INET6, ADDR, &addr.sin6_addr);
	addr.sin6_port = htons(12345);
	tmp = MAGIC;
	if (sendto(fd2, &tmp, sizeof(tmp), 0,
			(struct sockaddr *)&addr, sizeof(addr)) < 0) {
		perror("sendto");
		return 1;
	}

	if (recvfrom(fd, (void *)&tmp, sizeof(tmp), MSG_DONTWAIT,
				NULL, NULL) < 0) {
		perror("recvfrom");
		return 1;
	}

	if (tmp != MAGIC)
		return 111;

	puts("OK");
	return 0;
}

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2017-11-20 11:57 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-11-14 17:36 JOIN_ANYCAST breakage w. "net: ipv6: put host and anycast routes on device with address" Florian Westphal
2017-11-15 15:57 ` David Ahern
2017-11-18  0:09 ` David Ahern
2017-11-20 11:56   ` Florian Westphal

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).