Page MenuHomeFreeBSD

socket: Move SO_SETFIB handling to protocol layers
ClosedPublic

Authored by markj on Jan 24 2025, 5:04 PM.
Tags
None
Referenced Files
Unknown Object (File)
Wed, Feb 26, 9:51 AM
Unknown Object (File)
Wed, Feb 19, 5:19 PM
Unknown Object (File)
Feb 9 2025, 5:48 AM
Unknown Object (File)
Feb 9 2025, 12:23 AM
Unknown Object (File)
Feb 6 2025, 5:51 PM
Unknown Object (File)
Feb 5 2025, 11:23 PM
Unknown Object (File)
Feb 5 2025, 9:37 AM
Unknown Object (File)
Feb 4 2025, 5:02 PM

Details

Summary

In particular, we store a FIB number in both struct socket and in struct
inpcb. When updating the FIB number with setsockopt(SO_SETFIB), make
the update atomic. This is required to support the new bind_all_fibs
mode, since in that mode changing the FIB of a bound socket is not
permitted.

This requires a bit more code, but avoids a layering violation in
sosetopt(), where we hard-code the list of protocol families that
implement SO_SETFIB.

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.Jan 24 2025, 5:04 PM

The change definitely improves, but some questions remain :) Why do we need to store fib both in socket and inpcb? I believe it belongs only to the inpcb, cause many sockets (unix, netlink, ...) doesn't have a notion of forwarding. The rtsock(4) doesn't have notion of forwarding, but we use it configure other protocols forwarding, hence it needs fib. But it has its own pcb that of course can store fib.

This revision is now accepted and ready to land.Jan 24 2025, 5:49 PM

The change definitely improves, but some questions remain :) Why do we need to store fib both in socket and inpcb? I believe it belongs only to the inpcb, cause many sockets (unix, netlink, ...) doesn't have a notion of forwarding. The rtsock(4) doesn't have notion of forwarding, but we use it configure other protocols forwarding, hence it needs fib. But it has its own pcb that of course can store fib.

From what I can see, there is no really good reason to have it in the socket as well. I agree that we should (eventually) remove so_fibnum, so that there's only a single source of truth. I will try adding a mechanism to get the current FIB as well (i.e., a new sockopt).

Update raw socket option handlers as well.

Also fix a small bug: rip(6)_ctloutput() wasn't checking whether it was
handling a SOPT_GET or an SOPT_SET in the SO_SETFIB handler.

This revision now requires review to proceed.Jan 28 2025, 6:09 PM
This revision was not accepted when it landed; it landed in state Needs Review.Feb 6 2025, 4:28 PM
This revision was automatically updated to reflect the committed changes.