Skip to contentSkip to conversation

JOIN_ANYCAST breakage w. "net: ipv6: put host and anycast routes on device with address"

DISCUSSION Florian Westphal 2 participants 4 messages Nov 14, 2017 – Nov 20, 2017

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

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;
}
#1 lore raw
Quoted 5 lines · Florian Westphal

Hi David

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

Quoted 7 lines

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?

Nothing obvious jumps out. At keep digging and get back to you. Most likely will be a few days.

#2 lore raw
In reply to Florian Westphal
Quoted 5 lines · Florian Westphal

Hi David

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

Quoted 8 lines

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?

This restores the previous behavior:

net/ipv6/route.c +0 -0
index 05eb7bc36156..1c29d9bcedc3 100644
@@ -1019,7 +1019,7 @@ static struct net_device

*ip6_rt_get_dev_rcu(struct rt6_info *rt)

 {
        struct net_device *dev = rt->dst.dev;

- if (rt->rt6i_flags & RTF_LOCAL) {
+ if (rt->rt6i_flags & (RTF_LOCAL | RTF_ANYCAST)) {
/* for copies of local routes, dst->dev needs to be the
* device if it is a master device, the master device if
* device is enslaved, and the loopback as the default

#3 lore raw
Quoted 30 lines · David Ahern
Quoted 5 lines · Florian Westphal

Hi David

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

Quoted 8 lines

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?

This restores the previous behavior:

net/ipv6/route.c +1 -1
index 05eb7bc36156..1c29d9bcedc3 100644
@@ -1019,7 +1019,7 @@ static struct net_device
 *ip6_rt_get_dev_rcu(struct rt6_info *rt)
 {
        struct net_device *dev = rt->dst.dev;
 
-       if (rt->rt6i_flags & RTF_LOCAL) {
+       if (rt->rt6i_flags & (RTF_LOCAL | RTF_ANYCAST)) {
                /* for copies of local routes, dst->dev needs to be the
                 * device if it is a master device, the master device if
Quoted 1 line

* device is enslaved, and the loopback as the default

Looks like it, thanks David!