Page MenuHomeFreeBSD

netlink: Don't directly access ifnet members
AcceptedPublic

Authored by jhibbits on Dec 8 2023, 9:18 PM.
Tags
None
Referenced Files
Unknown Object (File)
Mon, Oct 21, 9:03 PM
Unknown Object (File)
Oct 8 2024, 5:30 AM
Unknown Object (File)
Oct 5 2024, 4:15 PM
Unknown Object (File)
Oct 1 2024, 10:40 PM
Unknown Object (File)
Sep 27 2024, 6:34 AM
Unknown Object (File)
Sep 8 2024, 5:42 PM
Unknown Object (File)
Sep 8 2024, 3:51 AM
Unknown Object (File)
Aug 26 2024, 1:22 PM

Details

Reviewers
melifaro
bz
kp
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.

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Skipped
Unit
Tests Skipped
Build Status
Buildable 54885
Build 51774: arc lint + arc unit

Event Timeline

kp added inline comments.
sys/netlink/route/iface.c
329

While it does nothing now I'd have to assume that there's some anticipated need for ifa_iter_finish() to either clean up the iterator or to release a lock (or epoch or ..).

Wouldn't it belong more after the ifa != NULL check and dump_sa() call?

sys/netlink/route/iface.c
329

I think ifa should survive until the epoch exits, ifa_iter_finish() is used to clean up the iterator itself. It's quite likely that I don't understand epoch, and I'm not opposed to moving it before the ifa_iter_finish() if that is the case.

That said, on second thought I do see a possibility where ifa might point to just a static internal buffer in the iterator, overwritten each time through the loop and cleaned up at the end.

This revision is now accepted and ready to land.Dec 9 2023, 9:18 PM

I don't understand the change. The epoch protection is already right here. We can safely use CK_STAILQ_FIRST.

I don't understand the change. The epoch protection is already right here. We can safely use CK_STAILQ_FIRST.

It's not about safety, it's because netlink shouldn't know ifnet guts, it's a more generic interface. I'm trying to remove net/if_private.h from if_var.h as soon as possible, and this is the last netlink piece that touches directly.

Got it. Looks like there is also an assumption here that the first address is always the link level address. Maybe we just need to provide KPI if_getlladdr? May I ask to wait for Alexander melifaro@ to reappear before we proceed forward with that?

P.S. I'm also waiting for him on my netlink reviews.

Got it. Looks like there is also an assumption here that the first address is always the link level address. Maybe we just need to provide KPI if_getlladdr? May I ask to wait for Alexander melifaro@ to reappear before we proceed forward with that?

P.S. I'm also waiting for him on my netlink reviews.

Looking, we do have if_getlladdr(). It looks like the correct fix in 7d482240 should have been to just wrap the existing call in the epoch. @bz?