Commit Graph

8805 Commits

Author SHA1 Message Date
Xin LI
5d699a2889 Fix build. 2008-05-10 09:22:17 +00:00
Julian Elischer
a15370c6aa 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

PR:
Reviewed by:	several including rwatson, bz and mlair (parts each)
Approved by:
Obtained from:	Ironport systems/Cisco
MFC after:
Security:
2008-05-09 23:00:22 +00:00
John Baldwin
0f0e3d5f39 Use a sledgehammer cast (that was in the original patch to boot) to
quiet a warning on 64-bit platforms now that 'size' is an int and not a
size_t.
2008-05-07 21:00:50 +00:00
John Baldwin
5e72af30cb Fix reading the address of a znode_phys from a znode on 64-bit platforms
where sizeof(pointer) != sizeof(int).

MFC after:	1 week
PR:		amd64/123456
Submitted by:	KOIE Hidetaka | hide koie.org
2008-05-07 18:27:38 +00:00
John Baldwin
9227912617 The debug.sizeof.znode sysctl returns an int, not a size_t. This can cause
a hang on 64-bit platforms.

MFC after:	1 week
PR:		amd64/123456
Submitted by:	KOIE Hidetaka | hide koie.org
2008-05-07 17:55:28 +00:00
John Baldwin
02e50214ff Only output details about the current working directory of a process if
the vnode pointer is not NULL.  This avoids spurious warnings in fstat -v
output for kernel processes.

MFC after:	1 week
PR:		amd64/123456
Submitted by:	KOIE Hidetaka | hide koie.org
2008-05-07 17:49:31 +00:00
Doug Rabson
33f1219925 Fix conflicts after heimdal-1.1 import and add build infrastructure. Import
all non-style changes made by heimdal to our own libgssapi.
2008-05-07 13:53:12 +00:00
Garance A Drosehn
3f8c1392ef Update the date on the man-page to reflect the date that the '-u name'
change was committed, instead of when I had first started writing it...
2008-05-06 16:06:02 +00:00
Bruce M Simpson
a0ad4c4d37 Relinquish exclusive TTY access when tip(1) or cu(1) exit.
Previously they would have left TIOCEXCL enabled, requiring
either a reboot or use of tip/cu as the root user.

Observed when running QEMU with character devices redirected to pty instances.

MFC after:	2 weeks
2008-05-03 02:29:02 +00:00
Hiroki Sato
f1675e84a5 Add AUTHORS section[*] and fix HISTORY section.
Requested by:		Dave Yost (original author)[*]
History checked by:	The CSRG Archives
MFC after:		3 days
2008-05-02 16:23:47 +00:00
Tim Kientzle
01770c7983 Documentation updates:
* --format can be used with -r or -u
  * -o is a synonym for --format=ustar when used with -c, -r, or -u
Also, fix the erroneous sanity check that suppressed --format with -r or -u.
2008-05-02 05:40:05 +00:00
Tim Kientzle
2e4e881bef bsdtar --version should succeed. 2008-05-02 05:18:47 +00:00
Tim Kientzle
c40b056519 New bsdtar test harness. Still rather skimpy, but a lot easier
to run and maintain than the old scripts that used to be here.
2008-05-02 05:17:16 +00:00
Tim Kientzle
a0a88a1e98 Allow -r with -T even if there are no files on the command line.
PR: bin/123246
MFC after: 3 days
2008-05-02 05:14:58 +00:00
Pawel Jakub Dawidek
6e679990b9 Fix some section references. 2008-04-29 08:16:05 +00:00
Pawel Jakub Dawidek
f1025ba7c7 The referenced section name is 'Formats', not 'FORMATS'. 2008-04-29 07:35:31 +00:00
Ruslan Ermilov
562f2f71eb Don't depend on the modification time of the "zfs" subdir. 2008-04-29 06:54:12 +00:00
Ruslan Ermilov
24c9b0c84e - Fix makefile so it doesn't break the build in some corner cases. [1]
- Remove an extra copy of zfs.c.

Reported by:	yar [1]
2008-04-29 06:48:00 +00:00
Xin LI
b6d9e1f355 ANSIfy function prototypes. While I am there, constify some parameters and
make use of C99 sparse initialization for static variables, this makes talk(1)
to compile cleanly with WARNS=6.
2008-04-28 21:08:42 +00:00
Sean Farley
41a05be4ea Capitalize "Eve". This is the correct form and now matches
calendar.usholiday.

MFC after:	3 days
2008-04-24 01:37:12 +00:00
Gabor Pali
491851f994 Add:
- myself to the doc committers' graph
- my birthday to the FreeBSD calendar

Approved by:	gabor (mentor)
2008-04-22 15:42:20 +00:00
Robert Watson
070356d1fb Use ddb(4), not DDB(4) for man page cross-references.
MFC after:	3 days
Reported by:	novel
2008-04-21 17:09:53 +00:00
Robert Watson
b27c1c8db7 Provide more detailed information about each procstat(1) display mode,
including a key to fields in each mode and flag abbreviations.

MFC after:	3 days
X-MFC-note:	POSIX shared memory memory objects aren't in 7-STABLE yet
2008-04-19 13:40:42 +00:00
Robert Watson
ba8ca9db9c It is a bug that procstat(8) works only on live kernels and not crashdumps;
document in case anyone wants to work on fixing this.

MFC after:	3 days
2008-04-19 12:39:15 +00:00
Garance A Drosehn
a414225db1 Add the '-u name' option to the env command, which will completely unset
the given variable name (removing it from the environment, instead of
just setting it to a null value).

PR:		bin/65649
MFC after:	2 weeks
2008-04-17 23:17:09 +00:00
Randall Stewart
4db051c8a5 Fixes typo's in sctp.c 2008-04-16 17:40:30 +00:00
Ruslan Ermilov
d3bf3b9a7a system_info.cpustates isn't sparse, so a bitmask of available CPU states
is redundant (I think it's a leftover from an older implementation).
2008-04-11 11:39:26 +00:00
Ruslan Ermilov
3aaa083285 Allocate enough memory for pcpu_cp_time[] to stop sysctl() from
writing outside of array bounds.  This fully fixes -P display on
i386, where kern.cp_times prints zeroes for non-existing CPUs.
2008-04-11 11:34:09 +00:00
Jeff Roberson
86b3e19077 - Add support for interrupt bindig to cpuset(1). Interrupts are bound
by specifying the interrupt with -x <irq>.  The irq number matches
   those displayed by vmstat -i.

Sponsored by:	Nokia
2008-04-11 03:27:42 +00:00
Ruslan Ermilov
f89db4357e Fix "top -P" (&' mistyped as &&' and a botched logic).
The bug was unnoticed on non-i386 because mp_maxid is
initialized differently, kern.cp_times doesn't print
zeroes for non-existing CPUs, so no "writing outside of
array bounds" happens.

MFC after:	3 days
2008-04-10 16:17:54 +00:00
Ruslan Ermilov
e83412c9ca Add forgotten -H, -h, and -P to usage(). 2008-04-10 09:56:57 +00:00
Warner Losh
5859ace94f MFp4(mips2-jnpr):
Add mips support.
2008-04-04 21:35:13 +00:00
Warner Losh
268f9be78d Add mips support. 2008-04-04 21:33:41 +00:00
Ruslan Ermilov
da647ae946 Spell -t option's argument by name. 2008-04-02 09:41:29 +00:00
Ruslan Ermilov
dbdb679c6f Remove options MK_LIBKSE and DEFAULT_THREAD_LIB now that we no longer
build libkse.  This should fix WITHOUT_LIBTHR builds as a side effect.
2008-03-29 17:44:40 +00:00
John Birrell
e327f52446 The sources covered by Sun's CDDL have been repo copied below the
src/cddl and src/sys/cddl directories per the core@ decision following
the license review.

This change modifies the affected Makefiles to reference the sources
in their new location.
2008-03-27 23:21:25 +00:00
John Birrell
d97cdd3349 Allow awk (the one true one!) to handle 64 files instead of just 20.
The current FreeBSD syscall generation script uses all 20 and I need
another open file.

It's a shame that something named as the 'one-true-awk' is so limited
by an old denition like FOPEN_MAX when it could just make the file
handling dynamic.

This is done to avoid touching contrib sources on a vendor branch.
2008-03-27 01:33:26 +00:00
Christian Brueffer
662cac9f23 Fix some "in in" typos in comments.
PR:		121490
Submitted by:	Anatoly Borodin <anatoly.borodin@gmail.com>
Approved by:	rwatson (mentor), jkoshy
MFC after:	3 days
2008-03-26 07:32:08 +00:00
Christian S.J. Peron
582908b314 Catch netstat up for the new bpf stats structures. Print 64 bit values
properly.

Sponsored by:	Seccuris Inc
MFC after:	4 months
2008-03-24 13:50:39 +00:00
Ruslan Ermilov
2f93f6470b Fix splitting into words of the .for expression to allow for
spaces in values.  Without this change, the following valid
call broke due to parsing of .MAKEFLAGS in bsd.symver.mk:

cd /usr/src/lib/libc && make -n DEBUG_FLAGS="-DFOO -DBAR"

Spotted by:	Igor Sysoev
Submitted by:	Maxim Dounin, ru
MFC after:	1 week
2008-03-24 12:33:28 +00:00
Ruslan Ermilov
8c9dc249d1 Fix bugs in the previous revision. 2008-03-24 09:47:44 +00:00
Dag-Erling Smørgrav
6567d14f5e Fix usage string. 2008-03-20 09:53:45 +00:00
Hajimu UMEMOTO
bd2327cd5e Change .8s port name restriction to .15s.
This change corresponds to inet.c 1.13.

MFC after:	1 week
2008-03-18 15:04:05 +00:00
Tim Kientzle
3b56813eb0 Fix --fast-read by decrementing the remaining patterns to be matched,
instead of incrementing.

Pointy hat: me
Thanks to: Tomasz Przygoda
MFC after: 3 days
2008-03-18 06:18:49 +00:00
Antoine Brodin
887019fbbc Initialize variable "now" before using it (it is used by the LEFTEARTH
macro)

PR:		121418
Submitted by:	Atsuo Ohki
Approved by:	rwatson (mentor)
MFC after:	1 month
2008-03-17 18:31:43 +00:00
David Schultz
0e286f086c Add a -n option to split(1) to split files into N chunks rather than
having to specify the right number of bytes.

Obtained from:	NetBSD
Submitted by:	Jan Schaumann <jschauma@netmeister.org>
PR:		113175
2008-03-16 15:15:32 +00:00
Tim Kientzle
9ef493f9c6 style(9) fix to add whitespace around an '=' sign and restore
a comment that got accidentally dropped.
2008-03-15 05:08:21 +00:00
Tim Kientzle
1fd0d1f6de Support NetBSD's --insecure as a synonym for -P. 2008-03-15 03:28:39 +00:00
Tim Kientzle
ef1108fe61 Document --chroot. 2008-03-15 03:25:26 +00:00
Tim Kientzle
8fc7d6f52c Support -q (from NetBSD) as a synonym for --fast-read (the old FreeBSD
extension to GNU tar).

Thanks to: Joerg Sonnenberger
2008-03-15 03:18:24 +00:00