Doing specific RTM_GETLINK or RTM_GETADDR

Philip Prindeville philipp_subx at redfish-solutions.com
Mon Jun 24 15:42:33 EDT 2013


I couldn't find documentation that said specifically if one can do a NLM_F_REQUEST | NLM_F_MATCH on a specific ifindex for an RTM_GETLINK or RTM_GETADDR.

I'm running Fedora (3.9.4) but also some older versions including uClinux and 2.6.39 (embedded) where this needs to work as well.

Even the following trivial query:

	msg = (struct nlmsghdr *) buf;
	memset(msg, 0, sizeof(*msg));

	msg->nlmsg_len = NLMSG_LENGTH(sizeof(struct ifinfomsg));
	msg->nlmsg_type = RTM_GETLINK;
	msg->nlmsg_flags = NLM_F_REQUEST | NLM_F_MATCH;
	msg->nlmsg_pid = 0;
	msg->nlmsg_seq = iter->seq++;

	NLMSG_DUMP(msg, "send2");

	info = (struct ifinfomsg *) NLMSG_DATA(msg);
	memset(info, 0, sizeof(*info));

	info->ifi_family = AF_NETLINK;
	info->ifi_index = iter->ifindex;


results in ALL of the interfaces being reported back (ditto for RTM_GETADDR). So if the NLM_F_MATCH flag doesn't control that, I don't understand what does.

Also, I was looking for documentation about (1) what version IFLA_AF_SPEC was introduced, and (2) how to parse it but I couldn't find that either.

If this isn't the correct place to ask, please let me know. 

Thanks,

-Philip




More information about the libnl mailing list