Page MenuHomeFreeBSD

IfAPI: add if_getaddr()
AcceptedPublic

Authored by glebius on Dec 12 2024, 2:12 PM.
Tags
None
Referenced Files
F143201229: D48052.diff
Tue, Jan 27, 8:54 AM
Unknown Object (File)
Sun, Jan 25, 12:27 PM
Unknown Object (File)
Thu, Jan 22, 10:33 AM
Unknown Object (File)
Thu, Jan 22, 8:07 AM
Unknown Object (File)
Dec 28 2025, 2:03 PM
Unknown Object (File)
Dec 20 2025, 8:19 PM
Unknown Object (File)
Nov 28 2025, 3:07 PM
Unknown Object (File)
Nov 6 2025, 5:53 AM

Details

Reviewers
bz
jhibbits
zlei
Group Reviewers
network
Summary

Augment the KPI with new if_getaddr(), that returns struct sockaddr_dl
pointer for the interface link level address.

The existing if_getlladdr(), which calculates pointer to the actual
address withing the sockaddr_dl, is already widely used and its name
reminds the old LLADDR() macro, which is helpful to BSD old timers. It
isn't helpful for newcomers, though. But the wide use of if_getlladdr()
really prevents a sweeping change just for better naming purposes. While
most consumers are happy with if_getlladdr(), some new consumers want full
access to sockaddr_dl, that the new function provides.

Diff Detail

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

Event Timeline

This revision is now accepted and ready to land.Dec 12 2024, 3:14 PM
zlei added inline comments.
sys/net/if.c
4900

Do we want to assert that sdl_family == AF_LINK to guard from misusage ?

sys/net/if.c
4900

Emm, maybe user also want uninitialized ifa_addr ?

sys/net/if.c
4900

Do we want to assert that sdl_family == AF_LINK to guard from misusage ?

If we ever do that, we should do that when the address is set, not get.

Looks good to me.

sys/net/if.c
4900

Do we want to assert that sdl_family == AF_LINK to guard from misusage ?

If we ever do that, we should do that when the address is set, not get.

Fair enough.