Page MenuHomeFreeBSD

IfAPI: add if_getaddr()
AcceptedPublic

Authored by glebius on Dec 12 2024, 2:12 PM.
Tags
None
Referenced Files
Unknown Object (File)
Mon, Oct 13, 3:01 AM
Unknown Object (File)
Thu, Sep 25, 8:24 AM
Unknown Object (File)
Sep 10 2025, 6:31 AM
Unknown Object (File)
Sep 9 2025, 12:47 PM
Unknown Object (File)
Sep 4 2025, 12:36 PM
Unknown Object (File)
Aug 28 2025, 6:36 AM
Unknown Object (File)
Aug 20 2025, 10:38 AM
Unknown Object (File)
Aug 17 2025, 6:39 PM

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.