245 points · by pjmlp · 6y ago · 133 comments
In 2019, I simply wrote an ifconfig that uses the netlink API, because for portability I needed a Linux ifconfig that had a FreeBSD-like command-line syntax. It doesn't have the old interface aliasing mentioned in the headlined article, and has no problems setting up and reporting IPv6 addresses or additional IPv4 addresses.
* https://unix.stackexchange.com./a/504084/5132
* http://jdebp.uk./Softwares/nosh/guide/commands/ifconfig.xml
I have a system to convert Debian /etc/network/interfaces into a BSD-style rc.conf, which then in turn gets converted into a suite of native service bundles. One of the service bundles is ifconfig@interface , which invokes ifconfig with a uniform command-line syntax across Linux and FreeBSD, hence the need for a more FreeBSD-alike ifconfig on Linux.
* http://jdebp.uk./Softwares/nosh/guide/rcconf-amalgamation.ht...
Another off-topic question (using this forum as your author page is quite discouraging about sending you emails ....)
What's the reason for naming cyclog files with the time they were closed? (other than that's how djb did it?), since this information is available easily with 'ls -l'?
I use a logger that opens a $CREATE_TIMESTAMP.u file, and makes "current" a symbolic link to it; and on close renames it to ".s", which I find more intuitive and informative (also provides time between log creation and first message, which is unavailable with cyclog). I was considering changing the ".u"/".s" marking to be an attribute (-w or +i or +t to signify "safely closed") to help repeated rsyncs of log directories, but haven't done that yet.
I'm sure there's some useful aspect of existing cyclog/multilog behaviour that I'm missing, but I haven't been able to figure what it is for the last 10 years ...
* http://www.skarnet.org/lists.html
As for the filenames, yes the original reason was for compatibility with multilog, and of course all of the other tools that can process these log directories. I did set out, after all, to produce a cyclog workalike, with lessons from multilog incorporated. Note that said tools might not deal well with log directories where the same log file is available via two names, both "current" and something else.
Moreover, if you go and look at follow-log-directories you can see an additional benefit that it very efficiently skips its cursors over old files without having to look at their i-nodes because it knows that the filename is guaranteed to be a timestamp at or after the last log entry in the file.
Furthermore, if you go and read the cyclog manual, you'll find out why using the w permission bit had problems. (-:
1.41 is building up changes, by the way.
Thanks, that's two thing I've missed (because I never used it, I guess ..): This optimization and follow-log-directories+export-to-rsyslog which was introduced at a time I wasn't looking :)
> Furthermore, if you go and read the cyclog manual, you'll find out why using the w permission bit had problems. (-:
:) Indeed, thanks.
> 1.41 is building up changes, by the way.
Thanks! And since I've missed follow-log-directories (and export-to-rsyslog) before, maybe there's another tool I've missed that would make shipping log directories more efficient? I'm concerned with very-low-bandwidth, very-intermittently-connected servers in which rsync is a godsend and e.g. rsyslog and friends proved much less reliable and efficient; And the renaming of "current" makes it miss the fact that it already has an (almost complete) copy of said file under a different name.
Thanks again!
What happened?
The short version: > "As you can see, the GNU inetutils and NET-3 net-tools ifconfigs have some marked deficiencies, with respect to IPv6, with respect to interfaces that have multiple addresses, and with respect to functionality like -l.
> The IPv6 problem is in part some missing code in the tools themselves. But in the main it is caused by the fact that Linux does not (as other operating systems do) provide IPv6 functionality through the ioctl() interface. It only lets programs see and manipulate IPv4 addresses through the networking ioctl()s.
> Linux instead provides this functionality through a different interface, send() and recv() on a special, and somewhat odd, address family of sockets, AF_NETLINK.
> The GNU and NET-3 ifconfigs could have been adjusted to use this new API. The argument against doing so was that it was not portable to other operating systems, but these programs were in practice already not portable anyway so that was not much of an argument.
> But they weren't adjusted, and remain as aforeshown to this day."
Edit: Interesting,
https://jdebp.uk has the correct cert configured, whereas https://jdebp.uk. serves the cert as mentioned above.
The Apache web server that the bulk host is using for that site has a fairly poor implementation of HTTPS. It's unsatisfactory in various ways, some very technical, but what you're seeing here is the weird way it handles SNI.
By default when you say you want jdebp.uk. and there is no such virtual host (there's only jdebp.uk with no trailing dot) Apache will pick a default virtual host and act as though you asked for that, sending over the certificate for that host and so on. In this case, at a bulk hosting site, it's some unrelated Antiques Shop outfit, likely because that begins with 'A' which is the first letter of the alphabet.
This actually caused a problem for Let's Encrypt because their tls-sni-01 challenge type assumed nobody would be crazy enough to answer queries for a random name with a certificate chosen by somebody else entirely. But that's exactly what Apache is doing here. The current tls-alpn-01 challenge was introduced to fix that - it asks for a reserved ALPN service instead of a spurious SNI server name.
For example, try the following:
openssl s_client -connect jdebp.uk:443 -servername "jdebp.uk."
vs openssl s_client -connect jdebp.uk:443 -servername "jdebp.uk"
You'll notice that in the first case the default certificate is sent back, in the second case the certificate is correctly matched against the SNI.According to the Server header returned:
Server: Apache/2.4.41 (cPanel) OpenSSL/1.1.1d mod_bwlimited/1.4 Phusion_Passenger/5.3.7
Testing against an NGINX based server, I am not seeing the same results, in fact I am seeing the correct certificate being returned.More information: https://news.ycombinator.com/item?id=22632959
Apart from that, to circumvent badly configured paywall filters?
And it is factually inaccurate. Deprecation of ifconfig is a distro issue. "Linux" did not deprecate it. And the reason is that it was unmaintained, not that it couldn't handle multiple IP addresses. In fact it can, I still use it 50% of the time. Works fine for setting and displaying multiple addresses.
The Debian maintainers wanted to drop it, and the other distros all followed suit a couple years later. Good information and links here:
https://serverfault.com/questions/633087/where-is-the-statem...
"Linux maintains known bugs – and actively refuses to fix them. In fact, if you attempt to fix them, Linus will curse at you, as manifest by this email."
That is a bold statement but is not at all supported by the linked email. You'll see Linus cursing at a bad patch that would break something in userland, not for "maintaining a bug". He's preventing at least two bugs (unnecessary change to behavior and ENOENT is indeed the wrong return value). I think I liked the old Linus better...
So it's a shame. I'd love to read a series about BSD, but this is really just inaccurate propaganda.
I don't like this email thread, because some people are clearly trying to carefully find the breakage and fix it, but Linus yelling at people is all that people ever see from it. So the conversation changes from fixing a bug to insults and anger.
Unmaintained sounds like a very good reason to me. It's not just whether there is 1 or 2 addresses per interface. The rot set in when Alexy re-did the Linux kernels network infrastructure back god knows when (its decades ago now), and wrote his own user space tool to configure it. That tool was ip. It not only handled multi ip addresses per interface - it handled multiple routing tables, multiple link types, routing rules and a whole pile of other things. And that single tool has been growing ever since - it's now huge. Type typing "man ip-<tab><tab>" on a cli that supports tab completion some time.
Effectively the task of keeping up with the kernel's new features kept growing and at some point the ifconfig maintainers gave up. It was all over bar the shouting at the point. The only surprising thing is the shouting has gone on for literally decades, and as this article demonstrates continues to this day. Lets hope the same angst over systemd doesn't continue for the same amount of time.
Just like like systemd there are things that rub me the wrong way of course. Coping the Cisco IOS style of command line usage rather than using the Linux style is for me one of those things. But it happened for a reason - Alexy set the standard when he wrote the first version of ip, and he was trying to emulate the features provided by a Cisco router at the time.
It's difficult to take him seriously when he picks and chooses when to enforce his supposed "never break userland" ethos.
Now, they are obviously free to do that and ZoL needs to work around it. But it's silly to argue that this was not an intentional breakage of a system which many people use and cannot be worked around out-of-kernel. Yes, it's not userspace code but it did cause regressions for users. Linus and GregKH have always disliked ZFS because they feel it was designed to be incompatible with Linux (and they're entitled to that view, however wrong it may be) so it's unsurprising that they are against doing anything that may help ZoL.
Furthermore it is profoundly curious to claim that a cross platform filesystem that began life on Solaris and existed for years as a stable complete work before being ported to several OS including Linux becomes by virtue of a bridge a derivative work of Linux. It's magical thinking.
It is entirely acceptable that they aren't responsible for out of tree code working but it would be great if they didn't deliberately sabotage other projects which is what they did here.
>My tolerance for ZFS is pretty non-existant. Sun explicitly did not want their code to work on Linux, so why would we do extra work to get their code to work properly?
The extra work is 10 seconds of work. How childish and unprofessional.
Edit: Breaking ZFS is not a great example — as sibling comment points out, that is a kernel module using kernel-internal APIs, not userspace syscall ABI. The Linux kernel notoriously considers all kernel interfaces unstable. GregKH has in the past characterized this as a feature, not a bug.
“You think you want a stable kernel interface, but you really do not, and you don't even know it. What you want is a stable running driver, and you get that only if your driver is in the main kernel tree.”
— Greg Kroah-Hartman <greg@kroah.com>
https://www.kernel.org/doc/html/latest/process/stable-api-no...
RE getrandom(2): As Linus said several times, we don't break userspace rule does not apply to security bugs. If there's no other way to fix security bug other than breaking userspace, then userspace has to be broken, for obvious reason. If you don't understand that reason, you shouldn't really have a say in any such critical decision.
The argument doesn't hang together. He can't claim that changes to userland tools aren't possible whilst at the same time claiming it's because the existing interfaces never change.
That said — new ioctls could be added and new ifconfig could use those? Old ifconfig and user programs could continue using the old ABIs.
Also something like WSL would be impossible
I suspect the order of cause and effect is reversed. Linux is amazingly successful and as a result containers were shaped to fit the capabilities and needs of Linux. The reason Linux has a strong syscall ABI is because it doesn't have a userspace. Glibc is only loosely related to the kernel and cannot be the kernel's ABI compatibility layer, as they are wholly independent projects.
Another way of looking at this is that the overhead and additional abstraction of containers is a workaround for the deficiencies of Linux jail/zone facilities (i.e., it doesn't have them; you have to carefully piece together a secure sandbox out of various cgroup and namespace components).
> Also something like WSL would be impossible
Some interesting things about that:
1. WSLv1 was a partial Linux syscall emulator, sure.
2. Microsoft gave up on that approach and WSLv2 is just an Ubuntu VM running in HyperV. So maybe it was impossible anyway — Linux just provides a ton of system calls and it will always be difficult to faithfully implement all of them. And as some side threads have noted, Linux likes to break ABI of sysfs files all the time. But those don't count, for some reason.
3. FreeBSD has a linux syscall emulation layer (that long predates WSL) using essentially the same premise as WSLv1. You're correct that this style of implementation (syscall ABI) only works due to Linux's syscall ABI choices.
4. However, something like WSL is not impossible against a shlib ABI. The canonical example here is WINE. WINE implements (much of) the Windows NT shared library (DLL) level stable ABI. The same could be done for other systems that provide ABI stability at the DLL level, such as MacOS or FreeBSD.
I kind of said the same thing just now:
I think this is not specific to Linux at all, and is not really about kernel ABI. This is a problem I see a lot, often in proprietary software too. Firstly, people opt to rewrite before they fix or even before they fully understand the old thing. Secondly, people confuse interface with implementation, and often don't bother trying to make their rewrites interoperable with the old thing.
Another example of that last one, in Linux from the late 90s, is ALSA. FreeBSD for example chose to fix the problems and maintain the old OSS API for audio devices. Linux introduced a very complicated new API.
[By the way, I spotted one sort of technical error in the article. I don't think most software keeps private copies of kernel data structures in their source tree. Rather, when they #include the kernel headers, they end up using an effectively-private version of those structures and constants in their object code. This is slightly different but a similar result.]
But it's telling that nobody stepped up and actually bothered to do that despite all the bitching and moaning.
Successful code is generally produced to solve problems, not fullfil some abstract ideals
https://news.ycombinator.com/item?id=22628938
But with the Linux ecosystem's inertia being what it is, rather than the 2 existing implementations of ifconfig in use being displaced by this better one... now there are just 3 implementations of ifconfig in use.
As mentioned in the Stack Exchange thread linked in that post, a different someone submitted a relevant patch to one of those existing implementations – way back in 2013. But it was never accepted. More inertia.
The reason is that people want the software to have full functionality no matter what system is used for building it. You can build on an old system, with a kernel that totally lacks the functionality, and produce a binary that can use the new kernel interfaces when run on a system that has them.
> It is often at the cutting edge of kernel interfaces
Is it? It seems like support for Linux-specific features can take years. The getrandom system call, for example:
I feel that /sbin/ip is in almost every way a better tool than /sbin/ifconfig, is that not the concensus?
> Linux introduced a very complicated new API.
Which highlights the fact that the moment you want to have in-depth interactions with a driver for a piece of hardware ioctls are the wrong choice.
OSS was great if you had exceptionally simple needs.. the moment you want to do "professional" audio it was a nightmare. ALSA is _somewhat_ better for this, and I honestly wish they went with a more netlink(3) style API instead of an IOCTL driven one.
What's the point of pantomiming the old thing when the old thing wasn't designed properly in the first place?
1) name. It’s to configure the interface
2) default format. Far better spaced than “ip”’s various outputs. I find “ip -o a” just about manageable, but if config shows data far more cleanly imo
alias ipa 'ip -br -color a'
alias ipl 'ip -br -color link'
Night and day! I try to not use the aliases because I'm often on servers without them, but the options for brief and color with the command to list adapters or links at the end it one all sys admins should memorize. It returns output that isn't terrible.According to the manpage, -color can be shortened to -c and link shortened to `l`, as `addr` can be shortened to `a`. -br stands for -brief, which knowing makes it easier to remember.
ip -br -c a
ip -br -c l
Now I need the aliases less.In case somebody is wondering the output looks like:
$ ip -br -color a
eth0 x.x.x.x/16 xxxx::xxxx:xxxx:xxxx:xxxx/64
lo 127.0.0.1/8 ::1/128
wifi0 x.x.x.x/24 xxxx::xxxx:xxxx:xxxx:xxxx/64
wifi1 x.x.x.x/16 xxxx::xxxx:xxxx:xxxx:xxxx/64
wifi2 x.x.x.x/16 xxxx::xxxx:xxxx:xxxx:xxxx/64
$ ip -br -color link
eth0 xx:xx:xx:xx:xx:xx <>
lo 00:00:00:00:00:00 <LOOPBACK,UP>
wifi0 xx:xx:xx:xx:xx:xx <BROADCAST,MULTICAST,UP>
wifi1 xx:xx:xx:xx:xx:xx <>
wifi2 xx:xx:xx:xx:xx:xx <> alias ip='ip -brief -color'
which propogates the options to everything. Then if you need the full output, just call ip without the alias: $ \ip a
$ \ip lWell, no. What you do is create a new struct with correct behavior and let new applications use that. The old struct becomes deprecated but continues to exist until things stop using it. Which may be indefinitely, but that's not really a lot more work than maintaining a compatibility library to serve the same purpose.
The thing with ip vs. ifconfig was more to do with there being somebody interested in creating ip and nobody interested in maintaining ifconfig. If you want to go add support for multiple addresses on the same interface to ifconfig, nobody is stopping you -- in fact that has already happened now.
I've almost replaced route with "ip route" as well. arp isn't fully replaced yet in muscle memory.
Also, as a comment on the article, ip can now fully replace brctl. (and iw replaces iwconfig and iwlist).
Or maybe only show them in the basic use case when they are set to something other than the default?
All of the "valid_lft" lines add a lot of visual noise.
Really, just some whitespace in between the interfaces like in ifconfig would go a long way.
$ ip -br a
lo UNKNOWN 127.0.0.1/8 ::1/128
eth0 UP 10.123.45.67/24 fe80::7ed3:aff:fe51:4612/64
$ ip -br l
lo UNKNOWN 00:00:00:00:00:00 <LOOPBACK,UP,LOWER_UP>
eth0 UP 7c:d3:0a:51:46:12 <BROADCAST,MULTICAST,UP,LOWER_UP>If it were necessary to use the matching version of userland tools to your kernel version, then a container engine would only be able to run container images that match the kernel version -- you wouldn't be able to run containers based on two different versions of Debian, for example.
The 4.13 kernel introduced a change to effectively namespace sysctl settings (prevent the change from default from being copied to the host system into container processes). This broke any container runtimes that relied on host-wide sysctl settings.
[1] https://github.com/aws/amazon-ecs-agent/issues/789
[2] https://success.docker.com/article/ipvs-connection-timeout-i...
In fact, prior to Linux 5.5, Linux had a direct sysctl syscall and removed it — which, uh, is clearly an ABI break.
With Linux's sysctl pseudo-fs model, you can argue the actual structure and behavior is just some aspect of sysfs, and the open/read/write syscalls are obviously not broken, but I think that's pretty simplistic. sysctls (and sysfs) are provided by the kernel.
Linux doesn't break ABIs that Linus judges to be worth more stable than rototilled. That's all. Usually Linus swings conservative on this.
That's pretty impressive.
- bonded interfaces
- with vlans
- with multiple IPs
If this sounds unrealistic, it was the standard config for index arbitrage at an investment bank.
The interfaces, added with distro scripts, will use `ip` and all the interfaces will show up in `ip addr` and work perfectly. ifconfig won't show about half of them - they won't be up, or down, they just won't appear.
I think the distro tooling used ip under the covers. I didn't care one way or the other. Nor did the users.
Yes it is a problem, to some programs doing, say, nice FFI to get at that ioctl and structure cleanly instead of forking and piping some utilities and text-processing their output.
The concept of an ABI, and one that is stable, is very real and important.
I use multiple addresses a lot, and recall having used them through ifconfig for years, probably well over a decade. Anyway, at least on Debian, the package net-tools brings ifconfig it back, again with full multiple addresses support.
# uname -v
#1 SMP Debian 5.4.19-1 (2020-02-13)
# ifconfig
enp2s0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.10.42 netmask 255.255.255.0 broadcast 192.168.10.255
inet6 fe80::2e4d:54ff:fed8:7b59 prefixlen 64 scopeid 0x20<link>
ether 2c:4d:54:d8:7b:59 txqueuelen 1000 (Ethernet)
RX packets 1162942 bytes 1627138668 (1.5 GiB)
RX errors 0 dropped 42049 overruns 0 frame 0
TX packets 546159 bytes 41181499 (39.2 MiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536
inet 127.0.0.1 netmask 255.0.0.0
inet6 ::1 prefixlen 128 scopeid 0x10<host>
loop txqueuelen 1000 (Local Loopback)
RX packets 16 bytes 818 (818.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 16 bytes 818 (818.0 B)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
# ifconfig enp2s0:1 192.168.1.42
# ifconfig
enp2s0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.10.42 netmask 255.255.255.0 broadcast 192.168.10.255
inet6 fe80::2e4d:54ff:fed8:7b59 prefixlen 64 scopeid 0x20<link>
ether 2c:4d:54:d8:7b:59 txqueuelen 1000 (Ethernet)
RX packets 1163011 bytes 1627147417 (1.5 GiB)
RX errors 0 dropped 42089 overruns 0 frame 0
TX packets 546185 bytes 41184061 (39.2 MiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
enp2s0:1: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.1.42 netmask 255.255.255.0 broadcast 192.168.1.255
ether 2c:4d:54:d8:7b:59 txqueuelen 1000 (Ethernet)
lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536
inet 127.0.0.1 netmask 255.0.0.0
inet6 ::1 prefixlen 128 scopeid 0x10<host>
loop txqueuelen 1000 (Local Loopback)
RX packets 16 bytes 818 (818.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 16 bytes 818 (818.0 B)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0 ifconfig enp2s0:1 192.168.1.42
Now try ip addr add dev enp2s0 192.168.42.1/24
and observe how ifconfig ignores the second IP on the same interface. enp2s0:1 is an alias to enp2s0, not enp2s0 itself. To replicate your ifconfig command, you'd use ip addr add dev enp2s0 192.168.1.42/32 label enp2s0:1
and then it shows up in ifconfig as well.Meanwhile having an explicit label can be nice in other situations if you want to replace an address instead of merely adding a new one.
I also seem to recall running into issues dealing with IPv6 with ifconfig that I worked around by switching to ip. I don't remember the specifics however.
Overall I wish ifconfig had been updated, I still find it a lot more user friendly that iproute. In particular the default output of a plain "ifconfig" is vastly more readable IMO: https://svkt.org/~simias/up/20200319-165513_ip.png
In general these days I use ip in scripts and ifconfig (when available) interactively. I don't love having to remember two ways of doing the same thing but I can't rely on ifconfig being available in scripts anymore and I just waste too much time parsing ip's bad output when I'm messing with networking interactively.
# ip a a 192.168.1.32/24 dev eth0
Then put 192.168.1.1 into browser etc. Do job. Back to term. Up arrow to get last command, change the second a to d (for delete) and the extra address is gone.
The right way to do OS ABI stability is to require that system calls go through some user-space library before executing a privilege transition. This way, the kernel's interface can change as needed without breaking existing userland binaries. Windows gets this right: system calls go through ntdll.dll. Fuchsia gets this right as well: they don't have an ntdll.dll, but they have a huge vdso that amounts to the same thing.
If I had my way, Linux would take the Fuchsia approach: require every system call go through a vdso.
"But golang!" and "but I have multiple libcs!" and "but my static linking!" are not valid excuses. Windows also has Go and it also have multiple libcs and the NT kernel isn't forced to maintain decades of userland-facing crud.
As for static linking: you can statically link the world if you'd like, but you can do that and still call through a vdso or load the platform libc.
Are you saying that wrapper code implementing an old interface by wrapping around a new interface is easier to do correctly in userspace than in the kernel itself?
I think I need you to be more concrete in pointing to a specific performance penalty or avoidable maintenance burden.
I generally found the article to be light on technical accuracy and heavy on pointless "my OS is better than yours" prattle.
So it's userspace compatibility, not the linux kernel compatibility that lead to a new tool.
(and linux will drop old interfaces if it can be proven that no one uses them, or if they're insecure)
I'm also reminded of the "expert beginner" series of blog posts about jealously guarded fiefdoms and the folks that dominate them.