I am playing around with the patchset “my” student generated during this years GSoC (the code for all projects is available from Google). In short, it gives you the possibility to query from userland, which optional kernel features are available. I have let him mostly do those features, which are not so easy to detect from userland, or where the detection could trigger an autoload of a kernel module.
I let the output speak for himself, first the output before his patchset:
kern.features.compat_freebsd7: 1
kern.features.compat_freebsd6: 1
kern.features.posix_shm: 1
And now with his patchset:
kern.features.compat_freebsd6: 1
kern.features.compat_freebsd7: 1
kern.features.ffs_snapshot: 1
kern.features.geom_label: 1
kern.features.geom_mirror: 1
kern.features.geom_part_bsd: 1
kern.features.geom_part_ebr: 1
kern.features.geom_part_ebr_compat: 1
kern.features.geom_part_mbr: 1
kern.features.geom_vol: 1
kern.features.invariant_support: 1
kern.features.kdtrace_hooks: 1
kern.features.kposix_priority_scheduling: 1
kern.features.ktrace: 1
kern.features.nfsclient: 1
kern.features.nfsserver: 1
kern.features.posix_shm: 1
kern.features.pps_sync: 1
kern.features.quota: 1
kern.features.scbus: 1
kern.features.softupdates: 1
kern.features.stack: 1
kern.features.sysv_msg: 1
kern.features.sysv_sem: 1
kern.features.sysv_shm: 1
kern.features.ufs_acl: 1
With his patches we have a total of 84 kernel features which can be queried (obviously I do not have all optional options enabled in the kernel which produces this output). All of the features also have a description, and it is easy to add more features. As an example I present what is necessary to produce the kern.features.stack output:
./kern/subr_stack.c:FEATURE(stack, “Support for capturing kernel stack”);
There is also a little userland application (and a library interface) which allows to query several features from scripts/applications with the possibility to pretend a feature is not there (the requirement for this was for ports; pretending a feature is there if it is not was ruled out because such run-time detection is only necessary for things which have to run soon and pretending some feature is there while it is not will cause big problems). Unfortunately the man page for the application is not yet ready, but I’m sure you can figure out how to use it.
The names of the features and the description follows an easy scheme, what is written down in NOTES is used as a name and a description for the feature (an exception is geom_part_X, there we decided to use a common theme (“GEOM partitioning class for XXX”) which is distinct from the corresponding geom_X class). If you have complains about what is used in a specific feature, do not complain to him: change it in NOTES and the feature will follow.
If you have questions, suggestions, or some other interest to contact him, his FreeBSD address is kibab@. Feel free to encourage him to go ahead with the next steps (finishing the man page, splitting up the patches into sensible pieces and presenting them on appropriate mailinglists for review).
GD Star Rating
loading…
GD Star Rating
loading…
Tags: autoload,
google,
gsoc,
kernel module,
kernel stack,
library interface,
posix,
priority scheduling,
shm,
subr —
After another mail where I explained a little bit of the linuxulator behavior, it is time to try to make an easy text which I can reference in future answers. If someone wants to add parts of this explanation to the FreeBSD handbook, go ahead.
Linux emulation? No, “native” execution (sort of)!
First, the linuxulator is not an emulation. It is “just” a binary interface which is a little bit different from the FreeBSD-“native”-one. This means that the binary files in FreeBSD and Linux are both files which comply to the ELF specification.
When the FreeBSD kernel loads an ELF file, it looks if it is a FreeBSD ELF file or a Linux ELF file (or some other flavor it knows about). Based upon this it looks up appropriate actions in a table for this binary (it can also differentiate between 64-bit and 32-bit, and probably other things too).
The FreeBSD-table is always compiled in (for a better big picture: at least on an AMD/Intel 64-bit platform there is also the possibility to include a 32-bit version of this table additionally, to be able to execute 32-bit programs on 64-bit systems), and other ones like the Linux one can be loaded additionally into the kernel (or build statically in the kernel, if desired).
Those tables contain some parameters and pointers which allow to execute the binary. If a program is making a system call, the kernel will look up the correct function inside this table. It will do this for FreeBSD binaries, and for Linux binaries. This means that there is no emulation/simulation (overhead) going on… at least ideally. Some behavior is a little bit differently between Linux and FreeBSD, so that a little bit of translation/house-keeping has to go on for some Linux system calls for the underlying FreeBSD kernel functions.
This means that a lot of Linux stuff in FreeBSD is handled at the same speed as if this Linux program would be a FreeBSD program.
Linux file/directory tricks
When the kernel detects a Linux program, it is also playing some tricks with files and directories (also a property of the above mentioned table in the kernel, so theoretically the kernel could play tricks for FreeBSD programs too).
If you look up for a file or directory /A, the kernel will first look for /compat/linux/A, and if it does not find it, it will look for /A. This is important! For example if you have an empty /compat/linux/home, any application which wants to display the contents of /home will show /compat/linux/home. As it is empty, you see nothing. If this application does not allow you to enter a directory manually via the keyboard, you have lost (ok, you can remove /compat/linux/home or fill it with what you want to have). If you can enter a directory via the keyboard, you could enter /home/yourlogin, this would first let the kernel look for /compat/linux/home/yourlogin, and as it can not find it then have a look for /home/yourlogin (which we assume is there), and as such would display the contents of your home directory.
This implies several things:
- you can hide FreeBSD directory contents from Linux programs while still being able to access the content
- “badly” programmed Linux applications (more correctly: Linux programs which make assumptions which do not hold in FreeBSD) can prevent you from accessing FreeBSD files, or files which are the same in Linux and FreeBSD (like /etc/group which is not available in /compat/linux in the linux_base ports, so that the FreeBSD one is read)
- you can have different files for Linux than for FreeBSD
The Linux userland
The linux_base port in FreeBSD is coming from a plain installation of Linux packages. The difference is that some files are deleted, either because we can not use them in the linuxulator, or because they exist already in the FreeBSD tree at the same place and we want that the Linux programs use the FreeBSD file (/etc/group and /etc/passwd come to mind). The installation also marks binary programs as Linux programs, so that the kernel knows which kernel-table to consult for system calls and such (this is not really necessary for all binary programs, but it is harder to script the correct detection logic, than to just “brand” all binary programs).
Additionally some configurations are made to (hopefully) make it do the right thing out of the box. The complete setup of the linux_base ports is done to let Linux programs integrate into FreeBSD. This means if you start acroread or skype, you do not want to have to have to configure some things in /compat/linux/etc/ first to have your fonts look the same and your user IDs resolved to names (this does not work if you use LDAP or kerberos or other directory services for the user/group ID management, you need to configure this yourself). All this should just work and the application windows shall just pop up on your screen so that you can do what you want to do. Some linux_base ports also do not work on all FreeBSD releases. This can be because some kernel features which this linux_base ports depends upon is not available (yet) in FreeBSD. Because of this you should not choice a linux_base port yourself. Just go and install the program from the Ports Collection and let it install the correct linux_base port automatically (a different FreeBSD release may have a different default linux_base port).
A note of caution, there are instructions out there which tell how to install more recent linux_base ports into FreeBSD releases which do not have them as default. You do this on your own risk, it may or may not work. It depends upon which programs you use and at which version those programs are (or more technically, which kernel features they depend upon). If it does not work for you, you just have two possibilities: revert back and forget about it, or update your FreeBSD version to a more recent one (but it could be the case, that even the most recent development version of FreeBSD does not have support for what you need).
Linux libraries and “ELF file OS ABI invalid”-error messages
Due to the above explained fact about file/directory tricks by the kernel, you have to be careful with (additional) Linux libraries. When a Linux program needs some libraries, several directories (specified in /compat/linux/etc/ld.so.conf) are searched. Let us assume that the /compat/linux/etc/ld.so.conf specifies to search in /A, /B and /C. This means the FreeBSD kernel first gets a request to open /A/libXYZ. Because of this he first tries /compat/linux/A/libXYZ, and if it does not exist he tries /A/libXYZ. When this fails too, the Linux runtime linker tries the next directory in the config, so that the kernel looks now for /compat/linux/B/libXYZ and if it does not exist for /B/libXYZ.
Now assume that libXYZ is in /compat/linux/C/ as a Linux library, and in /B as a FreeBSD library. This means that the kernel will first find the FreeBSD library /B/libXYZ. The Linux binary which needs it can not do anything with this FreeBSD library (which depends upon the FreeBSD syscall table and FreeBSD symbols from e.g. libc), and the Linux runtime linker will bail out because of this (actually he sees that the lin is not of the required type by reading the ELF header of it). Unfortunately the Linux runtime linker will not continue to search for another library with the same name in another directory (at least this was the case last time I checked and modified the order in which the Linux runtime linker searches for libraries… this has been a while, so he may be smarter now) and you will see the above error message (if you started the linux program in a terminal).
The bottom line of all this is: the error message about ELF file OS ABI invalid just means that the Linux program was not able to find the correct Linux library and got a FreeBSD library instead. Go, install the corresponding Linux library, and make sure the Linux program can find it instead of the FreeBSD library (do not forget to run “/compat/linux/sbin/ldconfig –r /compat/linux” if you make changes by hand instead of using a port, else your changes may not be taken into account).
Constraints regarding chroot into /compat/linux
The linux_base ports are designed to have a nice install-and-start experience. The drawback of this is, that there is not a full Linux system in /compat/linux, so doing a chroot into /compat/linux will cause trouble (depending on what you want to do). If you want to chroot into the linux system on your FreeBSD machine, you better install a linux_dist port. A linux_dist port can be installed in parallel to a linux_base port. Both of them are independent and as such you need to redo/copy configuration changes you want to have in both environments.
GD Star Rating
loading…
GD Star Rating
loading…
Tags: amd intel,
binary interface,
bit systems,
freebsd handbook,
freebsd kernel,
intel 64 bit,
kernel functions,
linux binaries,
linux elf,
linux program —
In the last days I migrated all my internal services to IPv6.
All my jails have an IPv4 and an IPv6 address now. All Apaches (I have one for my picture gallery, one for webmail, and one for internal management) now listen on the internal IPv6 address too. Squid is updated from 2.x to 3.1 (the most recent version in the Ports Collection) and I added some IPv6 ACLs. The internal Postfix is configured to handle IPv6 too (it is delivering everything via an authenticated and encrypted channel to a machine with a static IPv4 address for final delivery). My MySQL does not need an IPv6 address, as it is only listening to requests via IPC (the socket is hardlinked between jails). All ssh daemons are configured to listen to IPv6 too. The IMAP and CUPS server was picking the new IPv6 addresses automatically. I also updated Samba to handle IPv6, but due to lack of a Windows machine which prefers IPv6 over IPv4 for CIFS access (at least I think my Windows XP netbook only tries IPv4 connections) I can not really test this.
Only my Wii is a little bit behind, and I have not checked if my Sony-TV will DTRT (but for this I first have to get some time to have a look if I have to update my DD-WRT firmware on the little WLAN-router which is “extending the cable” from the TV to the internal network, and I have to look how to configure IPv6 with DD-WRT).
GD Star Rating
loading…
GD Star Rating
loading…
Tags: dd wrt firmware,
internal management,
ipv4 address,
ipv6 address,
ipv6 addresses,
ipv6 ipv4,
netbook,
sony tv,
wii,
wlan router —
In the FreeBSD mailinglists I stumbled over a post which refers to a blog-post which describes why ZFS seems to be slow (on Solaris).
In short: ZFS guarantees that the NFS client does not experience silent corruption of data (NFS server crash and loss of data which is supposed to be already on disk for the client). A recommendation is to enable the disk-cache for disks which are completely used by ZFS, as ZFS (unlike UFS) is aware of disk–caches. This increases the performance to what UFS is delivering in the NFS case.
There is no in-deep description of what it means that ZFS is aware of disk-caches, but I think this is a reference to the fact that ZFS is sending a flush command to the disk at the right moments. Letting aside the fact that there are disks out there which lie to you about this (they tell the flush command finished when it is not), this would mean that this is supported in FreeBSD too.
So everyone who is currently disabling the ZIL to get better NFS performance (and accept silent data corruption on the client side): move your zpool to dedicated (no other real FS than ZFS, swap and dump devices are OK) disks (honest ones) and enable the disk-caches instead of disabling the ZIL.
I also recommend that people which have ZFS already on dedicated (and honest) disks have a look if the disk-caches are enabled.
GD Star Rating
loading…
GD Star Rating
loading…
Tags: data corruption,
disk cache,
disk caches,
nfs client,
nfs performance,
nfs server,
server crash,
ufs,
zfs,
zil —
After enabling IPv6 in my WLAN router, I also enabled IPv6 in my FreeBSD systems. I have to tell that the IPv6 chapter in the FreeBSD handbook does not contain as much information as I would like to have about this.
Configuring the interfaces of my two 9–current systems to also carry a specific IPv6 address (an easy one from the ULA I use) was easy after reading the man-page for rc.conf. After a little bit of experimenting it came down to:
ifconfig_rl0_ipv6=“inet6 ::2:1 prefixlen 64 accept_rtadv“
ipv6_defaultrouter=”<router address>”
Apart from this address (I chose it because the IPv4 address ends in “.2″, this way I can add some easy to remember addresses for this machine if needed), I also have two automatically configured addresses. One is with the same ULA and some not so easy to remember end (constructed from the MAC address), and one is from the official prefix the router constructed out of the official IPv4 address from the ISP (+ the same end than the other end).
Additionally I also have all my jails on this machine with an IPv6 address now (yes, they are like “…:2:100″ with the :100 because the IPv4 address ends in “.100″). Still TODO is the conversion of all the services in the jails to also listen on the IPv6 address.
I already changed the config of my internal DNS to have the IPv6 addresses for all systems, listen on the IPv6 address (when I add an IPv6 network to allow-query/allow-query-cache/allow-recursion bind does not want to start). And as I was there, I also enabled the DNSSEC verification (but I get a lot of error messages in the logs: “unable to convert errno to isc_result: 42: Protocol not available”, one search result which talks exactly about this error tells it is a “cosmetic error”…).
I noticed that an IPv6 ping between two physical machines takes a little bit more time than an IPv4 ping (no IPsec enabled). It surprised me that this is such a noticeable difference (not within the std-dev at all):
— m87.Leidinger.net ping statistics —
10 packets transmitted, 10 packets received, 0.0% packet loss
round-trip min/avg/max/stddev = 0.168÷0.193÷0.220÷0.017 ms
— m87.Leidinger.net ping6 statistics —
10 packets transmitted, 10 packets received, 0.0% packet loss
round-trip min/avg/max/std-dev = 0.207÷0.325÷0.370÷0.047 ms
The information I miss in the FreeBSD handbook in the IPv6 chapter is what those other IPv6 related services are and when/how to configure them. I have an idea now what this radvd is, but I am not sure what the interaction is with the accept_rtadv setting for ifconfig (and I do not think I need it, as my WLAN router seems to do it already). I know that I get the IPv6-friendly network neighborhood displayed with ndp(8). I did not have a look at enabling IPv6 multicast support in FreeBSD, and I do not know what those other IPv6 options for rc.conf do.
GD Star Rating
loading…
GD Star Rating
loading…
Tags: address ends,
cosmetic error,
current systems,
freebsd handbook,
freebsd systems,
ipv4 address,
ipv6 address,
ipv6 addresses,
ipv6 network,
wlan router —