I think you need a mg_msg->nlmsg_type == RTM_GETROUTE . Does that work?