diff --git a/lib/libsys/getsockopt.2 b/lib/libsys/getsockopt.2 --- a/lib/libsys/getsockopt.2 +++ b/lib/libsys/getsockopt.2 @@ -175,7 +175,7 @@ .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 @@ -358,7 +358,7 @@ .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 --- a/sys/kern/uipc_socket.c +++ b/sys/kern/uipc_socket.c @@ -4106,6 +4106,12 @@ 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 --- a/sys/sys/socket.h +++ b/sys/sys/socket.h @@ -164,7 +164,8 @@ #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) */