1
0
mirror of https://git.FreeBSD.org/src.git synced 2024-11-23 07:31:31 +00:00

netlink: Don't directly access ifnet members

Summary:
Remove the final direct access of struct ifnet members from netlink.
Since only the first address is used, create the iterator and then free,
without fully iterating.

Reviewed By:	kp
Sponsored by:	Juniper Networks, Inc.
Differential Revision: https://reviews.freebsd.org/D42972
This commit is contained in:
Justin Hibbits 2024-10-31 11:09:48 -04:00
parent 3f2eb1ac23
commit b224af946a

View File

@ -322,11 +322,13 @@ dump_iface(struct nl_writer *nw, if_t ifp, const struct nlmsghdr *hdr,
*/
if (if_getaddrlen(ifp) != 0) {
struct ifaddr *ifa;
struct ifa_iter it;
NET_EPOCH_ENTER(et);
ifa = CK_STAILQ_FIRST(&ifp->if_addrhead);
ifa = ifa_iter_start(ifp, &it);
if (ifa != NULL)
dump_sa(nw, IFLA_ADDRESS, ifa->ifa_addr);
ifa_iter_finish(&it);
NET_EPOCH_EXIT(et);
}