[<prev] [next>] [day] [month] [year] [list]
Message-ID: <1143006151.25025.1423651833494.JavaMail.zimbra@evozon.com>
Date: Wed, 11 Feb 2015 12:50:33 +0200 (EET)
From: Radu Benea <radu.benea@...zon.com>
To: netdev@...r.kernel.org
Subject: under certain conditions netlink will not report adding a new ipv6
address
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;
}
}
}
}
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Powered by blists - more mailing lists