* under certain conditions netlink will not report adding a new ipv6 address
@ 2015-02-11 10:50 Radu Benea
0 siblings, 0 replies; only message in thread
From: Radu Benea @ 2015-02-11 10:50 UTC (permalink / raw)
To: netdev
Hello.
I found that the netlink monitoring interface does not report adding a new ipv6 address unless:
- the interface is up
- the network cable is plugged in
Deleting the ipv6 address is reported even in these conditions.
Only tested this with e1000e since it's the only network adapter I have.
To test this just turn the network interface down, add an ipv6 address, then remove it... you will only see the deladdr message.
Example test commands:
ip link set dev devname down
ip -6 addr add 2001::5 dev devname
ip -6 addr del 2001::5 dev devname
Sample test code below.
#include <string.h>
#include <sys/socket.h>
#include <linux/netlink.h>
#include <linux/rtnetlink.h>
#include <stdio.h>
#include <unistd.h>
int main(int, char * [])
{
struct sockaddr_nl sa;
int fd;
int len;
char buf[4096];
struct iovec iov = { buf, sizeof(buf) };
struct msghdr msg;
struct nlmsghdr *nh;
memset(&sa, 0, sizeof(sa));
sa.nl_family = AF_NETLINK;
sa.nl_pid = getpid();
sa.nl_groups = RTMGRP_IPV6_IFADDR;
fd = socket(AF_NETLINK, SOCK_RAW, NETLINK_ROUTE);
bind(fd, (struct sockaddr *)&sa, sizeof(sa));
while (1) {
msg = {&sa, sizeof(sa), &iov, 1, NULL, 0, 0};
len = recvmsg(fd, &msg, 0);
for (nh = (struct nlmsghdr *)buf; NLMSG_OK(nh, len); nh = NLMSG_NEXT(nh, len)) {
/* The end of multipart message. */
switch (nh->nlmsg_type) {
case RTM_NEWADDR:
printf("Received newaddr from netlink monitor\n");
break;
case RTM_DELADDR:
printf("Received deladdr from netlink monitor\n");
break;
default:
printf("Received unexpected message type %d from netlink monitor\n", nh->nlmsg_type);
break;
}
}
}
}
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2015-02-11 10:58 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-02-11 10:50 under certain conditions netlink will not report adding a new ipv6 address Radu Benea
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).