Changeset View
Changeset View
Standalone View
Standalone View
sys/netlink/route/iface.c
Show First 20 Lines • Show All 369 Lines • ▼ Show 20 Lines | if (attrs->ifi_type != 0 && attrs->ifi_index != ifp->if_type) | ||||
return (false); | return (false); | ||||
if (attrs->ifla_ifname != NULL && strcmp(attrs->ifla_ifname, if_name(ifp))) | if (attrs->ifla_ifname != NULL && strcmp(attrs->ifla_ifname, if_name(ifp))) | ||||
return (false); | return (false); | ||||
/* TODO: add group match */ | /* TODO: add group match */ | ||||
return (true); | return (true); | ||||
} | } | ||||
static int | |||||
dump_cb(struct ifnet *ifp, void *_arg) | |||||
{ | |||||
struct netlink_walkargs *wa = (struct netlink_walkargs *)_arg; | |||||
if (!dump_iface(wa->nw, ifp, &wa->hdr, 0)) | |||||
return (ENOMEM); | |||||
return (0); | |||||
} | |||||
/* | /* | ||||
* {nlmsg_len=52, nlmsg_type=RTM_GETLINK, nlmsg_flags=NLM_F_REQUEST, nlmsg_seq=1662842818, nlmsg_pid=0}, | * {nlmsg_len=52, nlmsg_type=RTM_GETLINK, nlmsg_flags=NLM_F_REQUEST, nlmsg_seq=1662842818, nlmsg_pid=0}, | ||||
* {ifi_family=AF_PACKET, ifi_type=ARPHRD_NETROM, ifi_index=0, ifi_flags=0, ifi_change=0}, | * {ifi_family=AF_PACKET, ifi_type=ARPHRD_NETROM, ifi_index=0, ifi_flags=0, ifi_change=0}, | ||||
* [ | * [ | ||||
* [{nla_len=10, nla_type=IFLA_IFNAME}, "vnet9"], | * [{nla_len=10, nla_type=IFLA_IFNAME}, "vnet9"], | ||||
* [{nla_len=8, nla_type=IFLA_EXT_MASK}, RTEXT_FILTER_VF] | * [{nla_len=8, nla_type=IFLA_EXT_MASK}, RTEXT_FILTER_VF] | ||||
* ] | * ] | ||||
*/ | */ | ||||
▲ Show 20 Lines • Show All 49 Lines • ▼ Show 20 Lines | rtnl_handle_getlink(struct nlmsghdr *hdr, struct nlpcb *nlp, struct nl_pstate *npt) | ||||
/* | /* | ||||
* Fetching some link properties require performing ioctl's that may be blocking. | * Fetching some link properties require performing ioctl's that may be blocking. | ||||
* Address it by saving referenced pointers of the matching links, | * Address it by saving referenced pointers of the matching links, | ||||
* exiting from epoch and going through the list one-by-one. | * exiting from epoch and going through the list one-by-one. | ||||
*/ | */ | ||||
NL_LOG(LOG_DEBUG2, "Start dump"); | NL_LOG(LOG_DEBUG2, "Start dump"); | ||||
if_foreach_sleep(match_iface, &attrs, dump_cb, &wa); | struct if_iter_ext_params params = { | ||||
.match_cb = match_iface, | |||||
.match_arg = &attrs, | |||||
.can_sleep = true, | |||||
}; | |||||
struct if_iter it; | |||||
for (if_t ifp = if_iter_ext_start(&it, ¶ms); ifp; ifp = if_iter_ext_next(&it)) | |||||
dump_iface(wa.nw, ifp, &wa.hdr, 0); | |||||
NL_LOG(LOG_DEBUG2, "End dump, iterated %d dumped %d", wa.count, wa.dumped); | NL_LOG(LOG_DEBUG2, "End dump, iterated %d dumped %d", wa.count, wa.dumped); | ||||
if (!nlmsg_end_dump(wa.nw, error, &wa.hdr)) { | if (!nlmsg_end_dump(wa.nw, error, &wa.hdr)) { | ||||
NL_LOG(LOG_DEBUG, "Unable to finalize the dump"); | NL_LOG(LOG_DEBUG, "Unable to finalize the dump"); | ||||
return (ENOMEM); | return (ENOMEM); | ||||
} | } | ||||
return (error); | return (error); | ||||
▲ Show 20 Lines • Show All 611 Lines • Show Last 20 Lines |