18269e767SBrooks Davis.\" Copyright (c) 2008 Cisco Systems. All rights reserved. 28269e767SBrooks Davis.\" Author: Julian Elischer 38269e767SBrooks Davis.\" 48269e767SBrooks Davis.\" Redistribution and use in source and binary forms, with or without 58269e767SBrooks Davis.\" modification, are permitted provided that the following conditions 68269e767SBrooks Davis.\" are met: 78269e767SBrooks Davis.\" 1. Redistributions of source code must retain the above copyright 88269e767SBrooks Davis.\" notice, this list of conditions and the following disclaimer. 98269e767SBrooks Davis.\" 2. Neither the name of the Cisco Systems nor the names of its employees 108269e767SBrooks Davis.\" may be used to endorse or promote products derived from this software 118269e767SBrooks Davis.\" without specific prior written permission. 128269e767SBrooks Davis.\" 138269e767SBrooks Davis.\" THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND 148269e767SBrooks Davis.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 158269e767SBrooks Davis.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 168269e767SBrooks Davis.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE 178269e767SBrooks Davis.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 188269e767SBrooks Davis.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 198269e767SBrooks Davis.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 208269e767SBrooks Davis.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 218269e767SBrooks Davis.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 228269e767SBrooks Davis.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 238269e767SBrooks Davis.\" SUCH DAMAGE. 248269e767SBrooks Davis.\" 25*010ee821SMark Johnston.Dd January 10, 2025 268269e767SBrooks Davis.Dt SETFIB 2 278269e767SBrooks Davis.Os 288269e767SBrooks Davis.Sh NAME 298269e767SBrooks Davis.Nm setfib 308269e767SBrooks Davis.Nd set the default FIB (routing table) for the calling process 318269e767SBrooks Davis.Sh LIBRARY 328269e767SBrooks Davis.Lb libc 338269e767SBrooks Davis.Sh SYNOPSIS 348269e767SBrooks Davis.In sys/socket.h 358269e767SBrooks Davis.Ft int 368269e767SBrooks Davis.Fn setfib "int fib" 378269e767SBrooks Davis.Sh DESCRIPTION 388269e767SBrooks DavisThe 398269e767SBrooks Davis.Fn setfib 408269e767SBrooks Davissystem call sets the associated FIB (routing table) for all sockets opened 418269e767SBrooks Davissubsequent to the call, to be that of the argument 428269e767SBrooks Davis.Fa fib . 438269e767SBrooks DavisThe 448269e767SBrooks Davis.Fa fib 458269e767SBrooks Davisargument 468269e767SBrooks Davismust be greater than or equal to 0 478269e767SBrooks Davisand less than the current system maximum which 488269e767SBrooks Davismay be retrieved by the 498269e767SBrooks Davis.Va net.fibs 508269e767SBrooks Davissysctl. 518269e767SBrooks DavisThe system maximum is set in the kernel configuration file with 528269e767SBrooks Davis.Bd -ragged -offset indent 538269e767SBrooks Davis.Cd "options ROUTETABLES=" Ns Em N 548269e767SBrooks Davis.Ed 558269e767SBrooks Davis.Pp 568269e767SBrooks Davisor in 578269e767SBrooks Davis.Pa /boot/loader.conf 58*010ee821SMark Johnstonor 59*010ee821SMark Johnston.Pa /etc/sysctl.conf 608269e767SBrooks Daviswith 618269e767SBrooks Davis.Pp 628269e767SBrooks Davis.Dl net.fibs= Ns Qq Em N 638269e767SBrooks Davis.Pp 648269e767SBrooks Daviswhere 658269e767SBrooks Davis.Em N 66*010ee821SMark Johnstonis an integer smaller than 65536. 67*010ee821SMark JohnstonNote that the number of FIBs may be increased after booting, but cannot be 68*010ee821SMark Johnstonreduced. 69*010ee821SMark Johnston.Pp 70*010ee821SMark JohnstonThe maximum of 65536 is due to the implementation storing 71*010ee821SMark Johnstonthe FIB number in a 16-bit field in the 728269e767SBrooks Davis.Xr mbuf 9 738269e767SBrooks Davispacket header, however it is not suggested that one use such a large number 748269e767SBrooks Davisas memory is allocated for every FIB regardless of whether it is used, and 758269e767SBrooks Davisthere are places where all FIBs are iterated over. 768269e767SBrooks Davis.Pp 778269e767SBrooks DavisThe default FIB of the process will be applied to all protocol families 788269e767SBrooks Davisthat support multiple FIBs, and ignored by those that do not. 798269e767SBrooks DavisThe default FIB for a process may be overridden for a socket with the use 808269e767SBrooks Davisof the 818269e767SBrooks Davis.Dv SO_SETFIB 828269e767SBrooks Davissocket option. 838269e767SBrooks Davis.Sh RETURN VALUES 848269e767SBrooks Davis.Rv -std setfib 858269e767SBrooks Davis.Sh ERRORS 868269e767SBrooks DavisThe 878269e767SBrooks Davis.Fn setfib 888269e767SBrooks Davissystem call 898269e767SBrooks Daviswill fail and no action will be taken and return 908269e767SBrooks Davis.Er EINVAL 918269e767SBrooks Davisif the 928269e767SBrooks Davis.Fa fib 938269e767SBrooks Davisargument is greater than the current system maximum. 948269e767SBrooks Davis.Sh SEE ALSO 958269e767SBrooks Davis.Xr setfib 1 , 968269e767SBrooks Davis.Xr setsockopt 2 978269e767SBrooks Davis.Sh STANDARDS 988269e767SBrooks DavisThe 998269e767SBrooks Davis.Fn setfib 1008269e767SBrooks Davissystem call is a 1018269e767SBrooks Davis.Fx 1028269e767SBrooks Davisextension however similar extensions 1038269e767SBrooks Davishave been added to many other 1048269e767SBrooks Davis.Ux 1058269e767SBrooks Davisstyle kernels. 1068269e767SBrooks Davis.Sh HISTORY 1078269e767SBrooks DavisThe 1088269e767SBrooks Davis.Fn setfib 1098269e767SBrooks Davisfunction appeared in 1108269e767SBrooks Davis.Fx 7.1 . 111