From: Florian Westphal <fw@strlen.de>
To: David Ahern <dsahern@gmail.com>
Cc: netdev@vger.kernel.org
Subject: JOIN_ANYCAST breakage w. "net: ipv6: put host and anycast routes on device with address"
Date: Tue, 14 Nov 2017 18:36:16 +0100 [thread overview]
Message-ID: <20171114173616.GA24842@breakpoint.cc> (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;
}
next reply other threads:[~2017-11-14 17:37 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-11-14 17:36 Florian Westphal [this message]
2017-11-15 15:57 ` JOIN_ANYCAST breakage w. "net: ipv6: put host and anycast routes on device with address" David Ahern
2017-11-18 0:09 ` David Ahern
2017-11-20 11:56 ` Florian Westphal
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20171114173616.GA24842@breakpoint.cc \
--to=fw@strlen.de \
--cc=dsahern@gmail.com \
--cc=netdev@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).