diff --git a/lib/libc/sys/getsockopt.2 b/lib/libc/sys/getsockopt.2 index 548e2f738e2..868f40e9777 100644 --- a/lib/libc/sys/getsockopt.2 +++ b/lib/libc/sys/getsockopt.2 @@ -177,7 +177,7 @@ for the socket .It Dv SO_PROTOTYPE Ta "SunOS alias for the Linux SO_PROTOCOL (get only)" .It Dv SO_ERROR Ta "get and clear error on the socket (get only)" .It Dv SO_RERROR Ta "enables receive error reporting" -.It Dv SO_SETFIB Ta "set the associated FIB (routing table) for the socket (set only)" +.It Dv SO_FIB Ta "get or set the associated FIB (routing table) for the socket" .El .Pp The following options are recognized in @@ -360,7 +360,7 @@ or with the error .Er EWOULDBLOCK if no data were received. .Pp -.Dv SO_SETFIB +.Dv SO_FIB 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 diff --git a/sys/kern/uipc_socket.c b/sys/kern/uipc_socket.c index 58090b28fcc..58e374d7aed 100644 --- a/sys/kern/uipc_socket.c +++ b/sys/kern/uipc_socket.c @@ -4101,6 +4101,12 @@ integer: error = sooptcopyout(sopt, &optval, sizeof optval); break; + case SO_FIB: + SOCK_LOCK(so); + optval = so->so_fibnum; + SOCK_UNLOCK(so); + goto integer; + case SO_DOMAIN: optval = so->so_proto->pr_domain->dom_family; goto integer; diff --git a/sys/sys/socket.h b/sys/sys/socket.h index 65b5c5ee001..b2afc735a38 100644 --- a/sys/sys/socket.h +++ b/sys/sys/socket.h @@ -166,7 +166,8 @@ typedef __uintptr_t uintptr_t; #define SO_LISTENQLIMIT 0x1011 /* socket's backlog limit */ #define SO_LISTENQLEN 0x1012 /* socket's complete queue length */ #define SO_LISTENINCQLEN 0x1013 /* socket's incomplete queue length */ -#define SO_SETFIB 0x1014 /* use this FIB to route */ +#define SO_FIB 0x1014 /* get or set socket FIB */ +#define SO_SETFIB SO_FIB /* backward compat alias */ #define SO_USER_COOKIE 0x1015 /* user cookie (dummynet etc.) */ #define SO_PROTOCOL 0x1016 /* get socket protocol (Linux name) */ #define SO_PROTOTYPE SO_PROTOCOL /* alias for SO_PROTOCOL (SunOS name) */