Page MenuHomeFreeBSD

IfAPI: add if_getaddr()
AcceptedPublic

Authored by glebius on Dec 12 2024, 2:12 PM.
Tags
None
Referenced Files
Unknown Object (File)
Wed, Jan 1, 5:38 AM
Unknown Object (File)
Dec 18 2024, 8:18 PM
Unknown Object (File)
Dec 18 2024, 5:26 PM
Unknown Object (File)
Dec 18 2024, 3:46 PM
Unknown Object (File)
Dec 18 2024, 2:29 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.