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)
Wed, May 8, 6:15 PM
Unknown Object (File)
Wed, May 8, 1:35 PM
Unknown Object (File)
Wed, May 8, 1:26 PM
Unknown Object (File)
Wed, May 1, 9:50 PM
Unknown Object (File)
Feb 11 2024, 11:30 AM
Unknown Object (File)
Jan 26 2024, 9:17 PM
Unknown Object (File)
Jan 18 2024, 1:23 PM
Unknown Object (File)
Jan 12 2024, 8:24 AM

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?