Page MenuHomeFreeBSD

socket: Export the FIB number of sockets
ClosedPublic

Authored by markj on Oct 28 2024, 5:04 PM.
Tags
None
Referenced Files
F104132192: D47315.diff
Tue, Dec 3, 10:59 PM
Unknown Object (File)
Wed, Nov 27, 7:16 PM
Unknown Object (File)
Mon, Nov 18, 4:59 PM
Unknown Object (File)
Fri, Nov 15, 10:06 PM
Unknown Object (File)
Mon, Nov 4, 9:14 PM
Unknown Object (File)
Nov 2 2024, 5:25 AM
Unknown Object (File)
Nov 2 2024, 4:58 AM
Unknown Object (File)
Nov 1 2024, 11:06 AM

Details

Summary

Sponsored by: Klara, Inc.
Sponsored by: Stormshield

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

markj requested review of this revision.Oct 28 2024, 5:04 PM
zlei added a subscriber: zlei.

Looks good to me.

sys/sys/socketvar.h
618–619

struct xsocket is used as KPI. I wonder if we should prefer fixed sized int, aka int32_t for exported so_fibnum. Thought on either 32bit or 64bit architectures sizeof int == sizeof int32_t.

This revision is now accepted and ready to land.Nov 1 2024, 6:57 AM
sys/kern/uipc_socket.c
5036

The fib of socket is readonly once set. So I think no need to read it under lock.

markj marked an inline comment as done.Nov 1 2024, 1:05 PM
markj added inline comments.
sys/kern/uipc_socket.c
5036

Somewhat surprisingly, this is not true: see the SO_SETFIB setsockopt handler.

Right now, that option handler does not use any locking. I have a patch which adds it in order to synchronize a new check. In particular, I want to disallow changing the FIB of a listening socket, so we have:

SOCK_LOCK(so);
if (SOLISTENING(so)) {
    error = EINVAL;
    ...

since SOLISTENING() requires some synchronization.

So, I prefer to keep the locking here, even though it is formally unnecessary for now.

sys/kern/uipc_socket.c
5036

Yes, you are right. I missed SO_SETFIB setsockopt handler while doing the quick review.

This revision was automatically updated to reflect the committed changes.