SO_SETFIB socket option
Naveen Gujje
gujjenaveen at gmail.com
Sat Feb 12 09:46:16 UTC 2011
Hi All,
On my FreeBSD 7.2 box, I've two routing tables (FIBs). Fib 0 and Fib 1
(net.fibs = 2).
I have a simple echo client which is the counterpart of an echo server
running somewhere.
If I run this echo client against fib 0 as 'setfib 0 ./echo-client', it
properly uses Fib 0.
But, if I run this echo client against Fib 0 by using setsockopt & SO_SETFIB
option, setsockopt fails with EINVAL.
setsockopt & SO_SETFIB for Fib 1 succeeds. But it fails for Fib 0.
By looking at the man page and /sys/kern/uipc_socket.c
Excerpt from setsockopt(2) man page:
"SO_SETFIB can be used to over-ride the default FIB (routing table) for
the given socket. The value must be from 0 to one less than the number
returned from the sysctl net.fibs."
and this contrasts with the code in /sys/kern/uipc_socket.c
<http://fxr.watson.org/fxr/source/kern/uipc_socket.c?v=FREEBSD72#L2210>
case SO_SETFIB
<http://fxr.watson.org/fxr/ident?v=FREEBSD72;im=bigexcerpts;i=SO_SETFIB>:
<http://fxr.watson.org/fxr/source/kern/uipc_socket.c?v=FREEBSD72#L2211>
error
<http://fxr.watson.org/fxr/ident?v=FREEBSD72;im=bigexcerpts;i=error> =
sooptcopyin <http://fxr.watson.org/fxr/ident?v=FREEBSD72;im=bigexcerpts;i=sooptcopyin>(sopt,
&optval, sizeof optval,
<http://fxr.watson.org/fxr/source/kern/uipc_socket.c?v=FREEBSD72#L2212>
sizeof optval);
<http://fxr.watson.org/fxr/source/kern/uipc_socket.c?v=FREEBSD72#L2213>
if (optval < 1 || optval > rt_numfibs
<http://fxr.watson.org/fxr/ident?v=FREEBSD72;im=bigexcerpts;i=rt_numfibs>)
{
<http://fxr.watson.org/fxr/source/kern/uipc_socket.c?v=FREEBSD72#L2214>
error
<http://fxr.watson.org/fxr/ident?v=FREEBSD72;im=bigexcerpts;i=error> =
EINVAL <http://fxr.watson.org/fxr/ident?v=FREEBSD72;im=bigexcerpts;i=EINVAL>;
<http://fxr.watson.org/fxr/source/kern/uipc_socket.c?v=FREEBSD72#L2215>
goto bad;
}
Where as both Fib 0 and Fib 1 work fine if I use setfib() call.
So, am confused if the code is incorrect or man page.
I want to run the echo-client process against Fib 1, but selectively change
it to Fib 0 for few connections.
So, is this possible with the current freebsd multiple routing table (MRT)?
Thanks,
Naveen G.
More information about the freebsd-hackers
mailing list