freebsd-dev/usr.sbin
Julian Elischer 8b07e49a00 Add code to allow the system to handle multiple routing tables.
This particular implementation is designed to be fully backwards compatible
and to be MFC-able to 7.x (and 6.x)

Currently the only protocol that can make use of the multiple tables is IPv4
Similar functionality exists in OpenBSD and Linux.

From my notes:

-----

  One thing where FreeBSD has been falling behind, and which by chance I
  have some time to work on is "policy based routing", which allows
  different
  packet streams to be routed by more than just the destination address.

  Constraints:
  ------------

  I want to make some form of this available in the 6.x tree
  (and by extension 7.x) , but FreeBSD in general needs it so I might as
  well do it in -current and back port the portions I need.

  One of the ways that this can be done is to have the ability to
  instantiate multiple kernel routing tables (which I will now
  refer to as "Forwarding Information Bases" or "FIBs" for political
  correctness reasons). Which FIB a particular packet uses to make
  the next hop decision can be decided by a number of mechanisms.
  The policies these mechanisms implement are the "Policies" referred
  to in "Policy based routing".

  One of the constraints I have if I try to back port this work to
  6.x is that it must be implemented as a EXTENSION to the existing
  ABIs in 6.x so that third party applications do not need to be
  recompiled in timespan of the branch.

  This first version will not have some of the bells and whistles that
  will come with later versions. It will, for example, be limited to 16
  tables in the first commit.
  Implementation method, Compatible version. (part 1)
  -------------------------------
  For this reason I have implemented a "sufficient subset" of a
  multiple routing table solution in Perforce, and back-ported it
  to 6.x. (also in Perforce though not  always caught up with what I
  have done in -current/P4). The subset allows a number of FIBs
  to be defined at compile time (8 is sufficient for my purposes in 6.x)
  and implements the changes needed to allow IPV4 to use them. I have not
  done the changes for ipv6 simply because I do not need it, and I do not
  have enough knowledge of ipv6 (e.g. neighbor discovery) needed to do it.

  Other protocol families are left untouched and should there be
  users with proprietary protocol families, they should continue to work
  and be oblivious to the existence of the extra FIBs.

  To understand how this is done, one must know that the current FIB
  code starts everything off with a single dimensional array of
  pointers to FIB head structures (One per protocol family), each of
  which in turn points to the trie of routes available to that family.

  The basic change in the ABI compatible version of the change is to
  extent that array to be a 2 dimensional array, so that
  instead of protocol family X looking at rt_tables[X] for the
  table it needs, it looks at rt_tables[Y][X] when for all
  protocol families except ipv4 Y is always 0.
  Code that is unaware of the change always just sees the first row
  of the table, which of course looks just like the one dimensional
  array that existed before.

  The entry points rtrequest(), rtalloc(), rtalloc1(), rtalloc_ign()
  are all maintained, but refer only to the first row of the array,
  so that existing callers in proprietary protocols can continue to
  do the "right thing".
  Some new entry points are added, for the exclusive use of ipv4 code
  called in_rtrequest(), in_rtalloc(), in_rtalloc1() and in_rtalloc_ign(),
  which have an extra argument which refers the code to the correct row.

  In addition, there are some new entry points (currently called
  rtalloc_fib() and friends) that check the Address family being
  looked up and call either rtalloc() (and friends) if the protocol
  is not IPv4 forcing the action to row 0 or to the appropriate row
  if it IS IPv4 (and that info is available). These are for calling
  from code that is not specific to any particular protocol. The way
  these are implemented would change in the non ABI preserving code
  to be added later.

  One feature of the first version of the code is that for ipv4,
  the interface routes show up automatically on all the FIBs, so
  that no matter what FIB you select you always have the basic
  direct attached hosts available to you. (rtinit() does this
  automatically).

  You CAN delete an interface route from one FIB should you want
  to but by default it's there. ARP information is also available
  in each FIB. It's assumed that the same machine would have the
  same MAC address, regardless of which FIB you are using to get
  to it.

  This brings us as to how the correct FIB is selected for an outgoing
  IPV4 packet.

  Firstly, all packets have a FIB associated with them. if nothing
  has been done to change it, it will be FIB 0. The FIB is changed
  in the following ways.

  Packets fall into one of a number of classes.

  1/ locally generated packets, coming from a socket/PCB.
     Such packets select a FIB from a number associated with the
     socket/PCB. This in turn is inherited from the process,
     but can be changed by a socket option. The process in turn
     inherits it on fork. I have written a utility call setfib
     that acts a bit like nice..

         setfib -3 ping target.example.com # will use fib 3 for ping.

     It is an obvious extension to make it a property of a jail
     but I have not done so. It can be achieved by combining the setfib and
     jail commands.

  2/ packets received on an interface for forwarding.
     By default these packets would use table 0,
     (or possibly a number settable in a sysctl(not yet)).
     but prior to routing the firewall can inspect them (see below).
     (possibly in the future you may be able to associate a FIB
     with packets received on an interface..  An ifconfig arg, but not yet.)

  3/ packets inspected by a packet classifier, which can arbitrarily
     associate a fib with it on a packet by packet basis.
     A fib assigned to a packet by a packet classifier
     (such as ipfw) would over-ride a fib associated by
     a more default source. (such as cases 1 or 2).

  4/ a tcp listen socket associated with a fib will generate
     accept sockets that are associated with that same fib.

  5/ Packets generated in response to some other packet (e.g. reset
     or icmp packets). These should use the FIB associated with the
     packet being reponded to.

  6/ Packets generated during encapsulation.
     gif, tun and other tunnel interfaces will encapsulate using the FIB
     that was in effect withthe proces that set up the tunnel.
     thus setfib 1 ifconfig gif0 [tunnel instructions]
     will set the fib for the tunnel to use to be fib 1.

  Routing messages would be associated with their
  process, and thus select one FIB or another.
  messages from the kernel would be associated with the fib they
  refer to and would only be received by a routing socket associated
  with that fib. (not yet implemented)

  In addition Netstat has been edited to be able to cope with the
  fact that the array is now 2 dimensional. (It looks in system
  memory using libkvm (!)). Old versions of netstat see only the first FIB.

  In addition two sysctls are added to give:
  a) the number of FIBs compiled in (active)
  b) the default FIB of the calling process.

  Early testing experience:
  -------------------------

  Basically our (IronPort's) appliance does this functionality already
  using ipfw fwd but that method has some drawbacks.

  For example,
  It can't fully simulate a routing table because it can't influence the
  socket's choice of local address when a connect() is done.

  Testing during the generating of these changes has been
  remarkably smooth so far. Multiple tables have co-existed
  with no notable side effects, and packets have been routes
  accordingly.

  ipfw has grown 2 new keywords:

  setfib N ip from anay to any
  count ip from any to any fib N

  In pf there seems to be a requirement to be able to give symbolic names to the
  fibs but I do not have that capacity. I am not sure if it is required.

  SCTP has interestingly enough built in support for this, called VRFs
  in Cisco parlance. it will be interesting to see how that handles it
  when it suddenly actually does something.

  Where to next:
  --------------------

  After committing the ABI compatible version and MFCing it, I'd
  like to proceed in a forward direction in -current. this will
  result in some roto-tilling in the routing code.

  Firstly: the current code's idea of having a separate tree per
  protocol family, all of the same format, and pointed to by the
  1 dimensional array is a bit silly. Especially when one considers that
  there is code that makes assumptions about every protocol having the
  same internal structures there. Some protocols don't WANT that
  sort of structure. (for example the whole idea of a netmask is foreign
  to appletalk). This needs to be made opaque to the external code.

  My suggested first change is to add routing method pointers to the
  'domain' structure, along with information pointing the data.
  instead of having an array of pointers to uniform structures,
  there would be an array pointing to the 'domain' structures
  for each protocol address domain (protocol family),
  and the methods this reached would be called. The methods would have
  an argument that gives FIB number, but the protocol would be free
  to ignore it.

  When the ABI can be changed it raises the possibilty of the
  addition of a fib entry into the "struct route". Currently,
  the structure contains the sockaddr of the desination, and the resulting
  fib entry. To make this work fully, one could add a fib number
  so that given an address and a fib, one can find the third element, the
  fib entry.

  Interaction with the ARP layer/ LL layer would need to be
  revisited as well. Qing Li has been working on this already.

  This work was sponsored by Ironport Systems/Cisco

Reviewed by:    several including rwatson, bz and mlair (parts each)
Obtained from:  Ironport systems/Cisco
2008-05-09 23:03:00 +00:00
..
ac
accton
acpi These are the things that the tinderbox has problems with because it 2007-11-20 02:07:30 +00:00
adduser In the description of the password field, -w was meant, not the 2008-03-16 21:36:05 +00:00
amd Don't always link statically with libwrap. By the time amd(8) 2008-03-29 18:13:15 +00:00
ancontrol Remove duplicate headers <sys/socket.h> 2008-04-21 07:25:26 +00:00
apm
apmd getopt(3) returns -1, not EOF when out of args. 2007-02-05 07:35:23 +00:00
arlcontrol
arp Spell "blackhole" correctly and fix one grammar nit. 2008-03-24 22:57:55 +00:00
asf Make grammar a bit more consistent in this document. 2006-12-20 06:21:51 +00:00
atm
audit Enable building of OpenBSM command line tools: 2006-02-02 10:15:30 +00:00
auditd Enable building of OpenBSM command line tools: 2006-02-02 10:15:30 +00:00
auditreduce auditreduce now requires OpenBSM's config/config.h, so add that to the 2006-09-25 11:56:20 +00:00
authpf Do not bypass WARNS machinery by hadcoding -Werror into CFLAGS. 2006-09-21 18:16:22 +00:00
bluetooth Add mandatory "security description" SDP parameter to the PANU profile 2008-03-19 00:06:30 +00:00
boot0cfg "-b /boot/mbr" is redundant, /boot/mbr is the default boot code for fdisk(8). 2007-06-07 07:43:04 +00:00
boot98cfg Correct typo in usage message. 2007-12-19 03:31:44 +00:00
bootparamd Fix bootparamd on 64 bit platforms - at least amd64 was broken due to the 2008-01-30 13:48:37 +00:00
bsnmpd Keep the snmp_bridge(3) module up to date with if_bridge(4) and add an 2007-08-08 19:27:50 +00:00
btxld Allow for a zero length 'loader'. 2008-04-05 10:26:20 +00:00
burncd
cdcontrol getopt(3) returns -1, not EOF. 2008-02-19 07:09:19 +00:00
chkgrp
chown
chroot
ckdist Fix markup and change some layout; no content changes. 2006-12-27 13:52:57 +00:00
clear_locks Add missing library dependency. 2008-03-29 18:07:06 +00:00
config Fix a bug introduced by DEFAULTS feature. When the config file 2008-04-10 22:57:54 +00:00
cron Cleanup of userland __P use 2007-11-07 10:53:41 +00:00
crunch Cleanup of userland __P use 2007-11-07 10:53:41 +00:00
ctm
cxgbtool fix include names 2007-03-15 04:09:40 +00:00
daemon Unbreak rev 1.7's getopt usage. The -f switch does not take an argument. 2007-04-19 16:43:30 +00:00
dconschat Set the default escape character as described in the manpage of dconschat(8). 2007-07-12 13:08:00 +00:00
devinfo Bump up the limit for when to print the resources for a given resource 2007-10-27 13:06:15 +00:00
digictl
diskinfo Print provider's ident when in verbose mode. 2007-05-06 00:25:21 +00:00
dnssec-keygen Update bmake glue for the BIND 9.4.1 import. 2007-06-02 23:19:58 +00:00
dnssec-signzone Update bmake glue for the BIND 9.4.1 import. 2007-06-02 23:19:58 +00:00
editmap
edquota Document that quotas must be turned off on a file system and 2007-02-04 14:26:01 +00:00
eeprom Flush my typo fix queue for this directory. 2006-12-05 23:20:14 +00:00
extattr
extattrctl
faithd Cleanup of userland __P use 2007-11-07 10:53:41 +00:00
fdcontrol Force the use of the tbl(1) preprocessor. 2006-10-25 10:44:59 +00:00
fdformat Fix a nit noticed during translation. 2007-02-28 10:24:34 +00:00
fdread Remove unused variables. 2006-07-20 09:38:46 +00:00
fdwrite
fifolog Clean up makefiles and a manpage. 2008-04-10 14:02:00 +00:00
flowctl
freebsd-update Adjust recognize-shared-libraries regex to avoid matching symlinks to 2008-03-25 11:31:16 +00:00
ftp-proxy Link pf 4.1 to the build: 2007-07-03 12:46:08 +00:00
fwcontrol - add '-f' option to force root node. 2008-03-05 01:30:48 +00:00
getfmac
getpmac
gstat When the ms/req fields exceed 1 second, drop the fractions to fit more digits. 2008-01-06 12:12:44 +00:00
i4b I4B header files are now installed in include/i4b/ and no longer 2007-07-06 07:21:56 +00:00
ifmcstat mdoc fix: Add missing .El request 2007-10-30 16:04:23 +00:00
inetd o inetd(8) requires wait/nowait column in inetd.conf for 2008-01-12 21:09:48 +00:00
iostat Repeat iostat header after rows-3 instead of a hardcoded 20. 2008-01-22 11:18:51 +00:00
ip6addrctl Cleanup of userland __P use 2007-11-07 10:53:41 +00:00
ipfwpcap Add a signal handler for SIGINT to make sure that the PID file 2007-10-12 14:57:39 +00:00
IPXrouted Use printf formats which match the variable types without casts so we 2007-11-17 23:09:39 +00:00
jail Bump date. 2007-04-05 21:17:52 +00:00
jexec Markup fixes. 2006-09-29 17:57:04 +00:00
jls
kbdcontrol Some clarifications to make keyboard configuration under syscons. 2008-01-29 18:28:50 +00:00
kbdmap Output keymap choice to stderr so it is easier to parse for apps chained to 2007-08-27 21:56:42 +00:00
kernbb
keyserv Cleanup of userland __P use 2007-11-07 10:53:41 +00:00
kgmon Correct a typo 2006-06-29 09:18:16 +00:00
kgzip
kldxref These are the things that the tinderbox has problems with because it 2007-11-20 02:07:30 +00:00
lastlogin
lmcconfig Style. 2006-09-01 09:24:28 +00:00
lpr Cleanup of userland __P use 2007-11-07 10:53:41 +00:00
lptcontrol
mailstats
mailwrapper Markup fixes. 2006-09-29 17:57:04 +00:00
makemap
manctl
memcontrol
mergemaster In the following scenario: 2007-12-21 19:34:26 +00:00
mixer mixer(8) is WARNS=6 clean since 1.25. 2008-03-16 08:06:36 +00:00
mld6query These IPv6-only tools have no explicit dependency on the INET6 macro. 2006-07-27 15:31:13 +00:00
mlxcontrol
mount_nwfs Use sysctlbyname() instead of sysctl 2006-05-11 17:23:57 +00:00
mount_portalfs Decrease to WARNS=3. 2007-01-20 23:24:11 +00:00
mount_smbfs
mountd Remove hacks which filter out MNT_ROOTFS. 2008-03-05 07:55:07 +00:00
moused Use intmax_t instead of long when casting time_t. 2008-03-07 00:01:24 +00:00
mptable
mtest Import rewrite of IPv4 socket multicast layer to support source-specific 2007-06-12 16:24:56 +00:00
mtree Add the mtree.5 manpage. I'll come back soon and 2008-01-01 06:15:57 +00:00
named Update bmake glue for the BIND 9.4.1 import. 2007-06-02 23:19:58 +00:00
named-checkconf Update bmake glue for the BIND 9.4.1 import. 2007-06-02 23:19:58 +00:00
named-checkzone Update bmake glue for the BIND 9.4.1 import. 2007-06-02 23:19:58 +00:00
named.reload
ndiscvt If the .inf file did not have a Default entry for the registry key then write 2008-04-15 04:44:32 +00:00
ndp Cleanup of userland __P use 2007-11-07 10:53:41 +00:00
newsyslog Fix two typos. 2008-01-30 22:11:59 +00:00
nfsd Previous revision was broken on SPARC, fix it by using more appropriate type. 2005-12-21 10:12:05 +00:00
ngctl Remove options MK_LIBKSE and DEFAULT_THREAD_LIB now that we no longer 2008-03-29 17:44:40 +00:00
nghook
nologin Update nologin(5) to match the modern reality of login.conf(5) and PAM. 2007-05-10 11:22:24 +00:00
nscd These are the things that the tinderbox has problems with because it 2007-11-20 02:07:30 +00:00
ntp Delete description of non-existent options: "-4" and "-6". 2007-06-12 13:28:55 +00:00
nvram Revise markup. 2006-09-30 19:07:03 +00:00
ofwdump De-sparc64-ify (now that it's also installed on PowerPC). 2008-01-31 14:58:55 +00:00
pccard Cleanup of userland __P use 2007-11-07 10:53:41 +00:00
pciconf Include agpreg.h from it's new location. 2007-11-13 01:30:40 +00:00
periodic - The weekly periodic runs occur on Saturday mornings, not on Sunday mornings 2007-09-07 21:54:45 +00:00
pkg_install - Backout 1.15, it was committed by accident 2008-05-03 23:17:37 +00:00
pmccontrol Fix pmccontrol(8) on Intel Xeon's running in 64 bit mode. 2006-02-27 14:25:32 +00:00
pmcstat Fix 'make checkdpadd'. 2008-02-22 06:25:49 +00:00
pnpinfo Remove alpha left-overs. 2006-08-22 08:03:01 +00:00
portsnap Improve conformance to the HTTP specification by using case-insensitive 2008-02-13 20:46:23 +00:00
powerd getopt(3) returns -1, not EOF. 2008-02-18 03:19:25 +00:00
ppp Update to the "new" libalias API (and thus fix world breakage). 2008-03-12 14:34:34 +00:00
pppctl
pppd Add missing <stdlib.h> for exit() 2007-11-07 10:57:35 +00:00
pppstats Cleanup of userland __P use 2007-11-07 10:53:41 +00:00
praliases
praudit Enable building of OpenBSM command line tools: 2006-02-02 10:15:30 +00:00
procctl
pstat Significantly reduce the memory leak as noted in BUGS section for 2007-07-04 00:00:41 +00:00
pw Add the groupmod '-d' option to pw to allow the deletion of existing users 2008-02-23 01:25:22 +00:00
pwd_mkdb
quot o Check we have a non-NULL pointer to a super block before dereference it. 2006-09-30 07:34:20 +00:00
quotaon If two files systems, /a and /b are marked as having quotas enabled 2007-02-04 06:33:15 +00:00
rarpd
raycontrol
repquota Change the header to indicate which type of id is being displayed, 2007-09-19 01:10:31 +00:00
rip6query Cleanup of userland __P use 2007-11-07 10:53:41 +00:00
rmt
rndc Update bmake glue for the BIND 9.4.1 import. 2007-06-02 23:19:58 +00:00
rndc-confgen Update bmake glue for the BIND 9.4.1 import. 2007-06-02 23:19:58 +00:00
route6d Cleanup of userland __P use 2007-11-07 10:53:41 +00:00
rpc.lockd If we can't find or load the kernel NLM support, don't just go ahead and 2008-04-10 12:54:53 +00:00
rpc.statd Fix apparent mis-paste in previous check-in by author. 2008-04-06 22:08:17 +00:00
rpc.umntall
rpc.yppasswdd These are the things that the tinderbox has problems with because it 2007-11-20 02:07:30 +00:00
rpc.ypupdated Kill blank line at EOF. 2007-02-15 02:45:14 +00:00
rpc.ypxfrd o There is no securenets(5) man page, refer to ypserv(8). 2006-11-02 07:36:33 +00:00
rpcbind No network addresses in the system isn't a good excuse 2008-02-14 20:12:23 +00:00
rrenumd Cleanup of userland __P use 2007-11-07 10:53:41 +00:00
rtadvd Cleanup of userland __P use 2007-11-07 10:53:41 +00:00
rtprio
rtsold Cleanup of userland __P use 2007-11-07 10:53:41 +00:00
rwhod
sa Ensure that the -s flag truncates the accounting data. 2008-02-21 07:12:56 +00:00
sade o Change the warning dialog for the 'W' command in both the label 2008-05-05 06:31:41 +00:00
sendmail This FFR is no longer needed in sendmail 8.14 2007-04-09 01:45:52 +00:00
setfib Add code to allow the system to handle multiple routing tables. 2008-05-09 23:03:00 +00:00
setfmac An average consumer of fts(3) that avoids keeping pointers to old 2008-01-29 17:50:29 +00:00
setpmac
sicontrol
sliplogin
slstat Correct xref to systat(1) which was mispelled as ststat(1) in 1.5. 2005-11-29 16:33:44 +00:00
smbmsg Force the use of the tbl(1) preprocessor. 2006-10-25 10:44:59 +00:00
snapinfo Imagine a situation where: 2007-03-16 12:36:54 +00:00
spkrtest
spray
sysinstall Remove ftp.hk.super.net, the DNS isn't pointing to anything at the moment. 2008-04-08 19:43:00 +00:00
syslogd Two no-op fixes to improve corretness of syslogd code: 2008-02-20 21:54:41 +00:00
tcpdchk Reimplementation of world/kernel build options. For details, see: 2006-03-17 18:54:44 +00:00
tcpdmatch Reimplementation of world/kernel build options. For details, see: 2006-03-17 18:54:44 +00:00
tcpdrop Normalize usage output. 2007-10-31 13:49:20 +00:00
tcpdump Update for tcpdump 3.9.8 2007-10-16 02:32:44 +00:00
timed Typo fix. 2008-02-11 08:12:58 +00:00
traceroute Add AS lookup functionality. On each hop we query a whois server to 2008-02-20 23:29:53 +00:00
traceroute6 Give traceroute6 the ability to traceroute with packets with no 2008-02-10 21:06:38 +00:00
trpt Obey MK_INET6_SUPPORT. 2006-07-27 14:52:12 +00:00
tzsetup
ugidfw Add some new options to mac_bsdestended. We can now match on: 2006-04-23 17:06:18 +00:00
usbdevs
vidcontrol Tweak some wording and markup. 2006-12-22 23:23:59 +00:00
vipw
watch Allow watch(8) to use more than 10 snp* devices. This limitation was purely 2008-01-30 13:55:32 +00:00
watchdogd Don't exit from watchdogd on receiving a signal if we cannot stop the watchdog. 2006-12-15 22:47:36 +00:00
wlandebug update for vaps 2008-04-20 20:41:47 +00:00
wlconfig
wpa o update for vaps 2008-04-20 20:40:45 +00:00
yp_mkdb
ypbind
yppoll
yppush Remove unsafe use of asynchronous I/O (the SIGIO handler could cause 2006-08-16 12:58:41 +00:00
ypserv Add -P <port> option to allow binding to a specific port. 2008-02-03 17:39:37 +00:00
ypset Increase helpfulness in diagnostic message - ypbind running without -ypset or 2007-02-28 22:49:12 +00:00
zic getopt(3) returns -1, not EOF. 2008-02-19 07:09:19 +00:00
zzz
Makefile Remove options MK_LIBKSE and DEFAULT_THREAD_LIB now that we no longer 2008-03-29 17:44:40 +00:00
Makefile.inc