summaryrefslogtreecommitdiffstats
path: root/lib/libc
Commit message (Collapse)AuthorAgeFilesLines
* Remove useless call to getdtablesize(2) in fdopen(3) and its uselessantoine2008-05-101-4/+0
| | | | | | | | | variable nofile. PR: 123109 Submitted by: Christoph Mallon Approved by: rwatson (mentor) MFC after: 1 month
* Misc mdoc improvements and a typo fix.brueffer2008-05-101-6/+10
|
* Add setfib.2 to the list of man pages to addjulian2008-05-091-1/+1
|
* setfib.2 got left out of the last commitjulian2008-05-091-0/+79
|
* Add code to allow the system to handle multiple routing tables.julian2008-05-092-0/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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: PR: Submitted by: Reviewed by: Approved by: Obtained from: MFC after: Security:
* Keep versions on a dependency chain to exclude even remote possiblitykan2008-05-071-1/+1
| | | | of private version ever getting index 2.
* Add a comment stating not to bump the FBSDprivate version.deischen2008-05-061-1/+3
| | | | Don't inherit the public namespace from the private namespace.
* Retire the __fgetcookie(), __fgetpendout(), and __fsetfileno() accessorsjhb2008-05-053-30/+0
| | | | as we aren't hiding FILE's internals anymore.
* Expose FILE's internals to the world again in all their glory. Restorejhb2008-05-0510-140/+23
| | | | | all the previous inline optimizations as well. FILE is back to using __mbstate_t, struct pthread *, and struct pthread_mutex *.
* Do not read away the target directory entry when encountering deletedkib2008-05-053-8/+9
| | | | | | | | | | | | | files after a seekdir(). The seekdir shall set the position for the next readdir operation. When the _readdir_unlocked() encounters deleted entry, dd_loc is already advanced. Continuing the loop leads to premature read of the target entry. Submitted by: Marc Balmer <mbalmer at openbsd org> Obtained from: OpenBSD MFC after: 2 weeks
* Add __fgetcookie(), __fgetpendout() and __fsetfileno() to the privatemarcel2008-05-042-0/+9
| | | | name space.
* Unbreak build: gnu sort has been configured to grope inside structmarcel2008-05-031-0/+7
| | | | | | | __sFILE. It's opaque now, so add a function that returns the pending output bytes. Pointy hat: jhb
* Unbreak build: libftpio gropes inside struct __sFILE. Implementmarcel2008-05-031-0/+14
| | | | | | | | accessor functions for its benefit now thaat FILE is opaque. I'm sure there's a better way. I leave that for people to work on in a src tree that isn't broken. Pointy hat: jhb
* Fix a comment.jasone2008-05-031-1/+1
|
* Next round of stdio changes: Remove all inlining of stdio operations andjhb2008-05-0212-112/+200
| | | | | | | | | | | | | | | | move the definition of the type backing FILE (struct __sFILE) into an internal header. - Remove macros to inline certain operations from stdio.h. Applications will now always call the functions instead. - Move the various foo_unlocked() functions from unlocked.c into foo.c. This lets some of the inlining macros (e.g. __sfeof()) move into foo.c. - Update a few comments. - struct __sFILE can now go back to using mbstate_t, pthread_t, and pthread_mutex_t instead of knowing about their private, backing types. MFC after: 1 month Reviewed by: kan
* Include libc_private.h for the declaration of __isthreaded instead ofjhb2008-05-021-0/+1
| | | | | | relying on namespace pollution in stdio.h. MFC after: 3 days
* Add a separate tree to track arena chunks that contain dirty pages.jasone2008-05-011-157/+133
| | | | | | | This substantially improves worst case allocation performance, since O(lg n) tree search can be used instead of O(n) tree iteration. Use rb_wrap() instead of directly calling rb_*() macros.
* Add rb_wrap(), which creates C function wrappers for most rb_*()jasone2008-05-011-36/+194
| | | | | | | | | | macros. Add rb_foreach_next() and rb_foreach_reverse_prev(), which make it possible to re-synchronize tree iteration after the tree has been modified. Rename rb_tree_new() to rb_new().
* o Add MIPS to the list of architectures with defined TLS_TCB_ALIGNgonzo2008-04-291-2/+2
| | | | | | o Stick with TLS Variant II for MIPS for the moment. Approved by: imp
* Set QUANTUM_2POW_MIN and SIZEOF_PTR_2POW parameters for MIPSgonzo2008-04-291-0/+5
| | | | Approved by: imp
* Check for integer overflow before calling sbrk(2), since it uses ajasone2008-04-291-0/+7
| | | | signed increment argument, but the size is an unsigned integer.
* Correct minor typos in SCTP man pages.rwatson2008-04-282-2/+1
| | | | MFC after: 3 days
* Add support files for compiling with soft-float. This has beenmarcel2008-04-273-0/+448
| | | | | copied from ARM and modified to warrant the duplication. Oh, and to make it work for PowerPC :-)
* Add mips support libc from the mips2-jnpr branch of perforce.imp2008-04-2660-0/+3908
|
* Have the man page catch up with the namespace pollution cleanup thatscf2008-04-261-1/+0
| | | | | | | | | | occurred between 2001-2003. Thanks to bde for the history lesson[1] concerning sys/types.h and the many system calls that at one time (pre-2001) were required by POSIX to include it. 1. http://lists.freebsd.org/pipermail/freebsd-arch/2008-April/008126.html MFC after: 3 days
* Stricter check for integer overflow.ru2008-04-241-0/+2
|
* Implement red-black trees without using parent pointers, and store thejasone2008-04-232-116/+947
| | | | | | | | | color bit in the least significant bit of the right child pointer, in order to reduce red-black tree linkage overhead by ~2X as compared to sys/tree.h. Use the new red-black tree implementation in malloc, which drops memory usage by ~0.5 or ~1%, for 32- and 64-bit systems, respectively.
* Fix a leak in the recent fixes for file descriptors > SHRT_MAX. In thejhb2008-04-221-0/+1
| | | | | | | | case of a file descriptor we can't handle, clear the FILE structure's flags so it can be reused. MFC after: 1 week Reported by: otto @ OpenBSD
* Document that you must include <sys/param.h> before <sys/cpuset.h>.antoine2008-04-202-0/+2
| | | | Approved by: rwatson (mentor)
* Don't forget to free() currency_symbol and asciivalue when multipleru2008-04-191-0/+4
| | | | | | | | conversion specifiers for them are present. Submitted by: Maxim Dounin <mdounin@mdounin.ru> Obtained from: NetBSD (partially) MFC after: 3 days
* Better strfmon(3) conversion specifiers sanity checking.ru2008-04-191-1/+8
| | | | | | | | | | There were no checks for left and right precisions at all, and a check for field width had integer overflow bug. Reported by: Maksymilian Arciemowicz Security: http://securityreason.com/achievement_securityalert/53 Submitted by: Maxim Dounin <mdounin@mdounin.ru> MFC after: 3 days
* Next stage of stdio cleanup: Retire __sFILEX and merge the fields back intojhb2008-04-1726-143/+72
| | | | | | | | | | | | | | | | | | | __sFILE. This was supposed to be done in 6.0. Some notes: - Where possible I restored the various lines to their pre-__sFILEX state. - Retire INITEXTRA() and just initialize the wchar bits (orientation and mbstate) explicitly instead. The various places that used INITEXTRA didn't need the locking fields or _up initialized. (Some places needed _up to exist and not be off the end of a NULL or garbage pointer, but they didn't require it to be initialized to a specific value.) - For now, stdio.h "knows" that pthread_t is a 'struct pthread *' to avoid namespace pollution of including all the pthread types in stdio.h. Once we remove all the inlines and make __sFILE private it can go back to using pthread_t, etc. - This does not remove any of the inlines currently and does not change any of the public ABI of 'FILE'. MFC after: 1 month Reviewed by: peter
* Implement fdopendir(3) by splitting __opendir2() into two parts, the upper partdelphij2008-04-164-6/+71
| | | | | | deals with the usual __opendir2() calls, and the rest part with an interface translator to expose fdopendir(3) functionality. Manual page was obtained from kib@'s work for *at(2) system calls.
* Style fixes to opendir.c:delphij2008-04-161-6/+3
| | | | | - Use /*- for copyright block; - ANSIfy.
* Sort MAN and MLINKS.ru2008-04-161-25/+26
|
* Connect newly added manpages to the build.ru2008-04-161-5/+15
| | | | Submitted by: kib
* Man pages for the openat(2), fexecve(2) and related syscalls.kib2008-04-1615-40/+1098
| | | | Reviewed by: ru
* Doh! Extra mips in the path. Remove these and wait until tomorrowimp2008-04-1611-600/+0
| | | | when I have more brain cells to try again.
* Turns out the machine/asm.h isn't needed here, since SYS.h alreadyimp2008-04-1610-12/+1
| | | | included it.
* FreeBSD/mips libc support. Merged from perforce mips2-jnpr branch.imp2008-04-1611-0/+611
|
* Implement POSIX function tcgetsid() which returns session id.davidxu2008-04-154-1/+84
| | | | PR: stand/107561
* Use calloc() instaed of zeroing memory ourselves.delphij2008-04-131-2/+1
|
* Unbreak the build for arm and powerpc.das2008-04-122-0/+3
| | | | Pointy hat to yours truly.
* Updates for changes in the way printf() handles hex floating pointdas2008-04-121-4/+5
| | | | numbers.
* Make several changes to the way printf handles hex floating point (%a):das2008-04-123-207/+206
| | | | | | | | | | | | | | | | | | | | | | | | | | 1. Previously, printing the number 1.0 could produce 0x1p+0, 0x2p-1, 0x4p-2, or 0x8p-3, depending on what happened to be convenient. This meant that printing a value as a double and printing the same value as a long double could produce different (but equivalent) results. The change is to always make the leading digit a 1, unless the number is 0. This solves the aforementioned problem and has several other advantages. 2. Use the FPU to do rounding. This is far simpler and more portable than manipulating the bits, and it fixes an obsure round-to-even bug. It also raises the exceptions now required by IEEE 754R. The drawbacks are that it is usually slightly slower, and it makes printf less effective as a debugging tool when the FPU is hosed (e.g., due to a buggy softfloat implementation). 3. On i386, twiddle the rounding precision so that (2) works properly for long doubles. 4. Make several simplifications that are now possible due to (2). 5. Split __hldtoa() into a separate file. Thanks to remko for access to a sparc64 box for testing.
* Fix some bugs that caused sparc64's quad precision sqrt to getdas2008-04-121-5/+5
| | | | | | the wrong answer for virtually all inputs. Thanks to remko for access to a sparc64 box for testing.
* Make the software emulator for long doubles set the FPU exceptiondas2008-04-121-0/+15
| | | | | | | flags appropriately. The next step is to make it raise a SIGFPE if any exceptions are unmasked. Thanks to remko for access to a sparc64 box for testing.
* Add memrchr(3).delphij2008-04-104-4/+74
| | | | Obtained from: OpenBSD
* Move the cpuset functions from FBSD_1.0 to FBSD_1.1. All symbols addeddeischen2008-04-071-5/+5
| | | | to 8.0 belong in the FBSD_1.1 symbol namespace.
* Add some compatibility code so that software which is built to use the newdfr2008-04-043-1/+92
| | | | | | | struct flock with l_sysid member can work properly on an an old kernel which doesn't support l_sysid. Sponsored by: Isilon Systems
OpenPOWER on IntegriCloud