Page MenuHomeFreeBSD

net/ethernet.h: Add make_ether_addr()
Needs ReviewPublic

Authored by ivy on Aug 5 2025, 5:57 PM.
Tags
None
Referenced Files
Unknown Object (File)
Sat, Oct 4, 8:18 PM
Unknown Object (File)
Mon, Sep 22, 5:17 PM
Unknown Object (File)
Sun, Sep 21, 9:46 PM
Unknown Object (File)
Sun, Sep 21, 4:25 PM
Unknown Object (File)
Wed, Sep 17, 1:41 PM
Unknown Object (File)
Wed, Sep 17, 10:06 AM
Unknown Object (File)
Sep 14 2025, 8:17 AM
Unknown Object (File)
Sep 13 2025, 8:40 AM

Details

Reviewers
None
Group Reviewers
network
Summary

This function turns an array of octets into a struct ether_addr,
which is useful when type-safe code (which uses ether_addr) wants
to interoperate with the many parts of the kernel where addresses
are stored as plain byte arrays.

To avoid sacrificing performance for safety, make the function
static inline.

Diff Detail

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

Event Timeline

ivy requested review of this revision.Aug 5 2025, 5:57 PM

this came up while hacking on if_bridge but i thought it might be more generally useful.

The struct ether_addr is a thin wrapper of ETHER_ADDR_LEN octets. A memcpy should be simple and enough, so what's the value of this inline function ?

Could you explain why a simple type casting is not enough?