+ rtnl = socket(AF_NETLINK, SOCK_DGRAM | SOCK_CLOEXEC, NETLINK_ROUTE);
+ struct sockaddr_nl rtnl_kernel = { .nl_family = AF_NETLINK };
+ connect(rtnl, (const struct sockaddr*)&rtnl_kernel, sizeof(rtnl_kernel));
+
+ int val = RTNLGRP_LINK;
+ setsockopt(rtnl, SOL_NETLINK, NETLINK_ADD_MEMBERSHIP, &val, sizeof(val));
+ fcntl(rtnl, F_SETOWN, ourpid);
+ fcntl(rtnl, F_SETFL, fcntl(sock, F_GETFL) | O_ASYNC);
+
+ struct {
+ struct nlmsghdr hdr;
+ struct ifinfomsg ifi;
+ } req = {
+ .hdr = {sizeof(req), RTM_GETLINK, NLM_F_REQUEST, 1, 0},
+ .ifi = {.ifi_index = if_index}
+ };
+ send(rtnl, &req, sizeof(req), 0);
+