Reanimating a Zombie: CAPI4Linux

E-mail Print

CAPI4Linux Rescue

For more than 5 years I'm running my home gateway with an ancient FRITZ!Card DSL v2.0. That's a dual channel adapter acting both as an ISDN interface as well as an ADSL modem. It supports up to 6 MBit/s downstream. No longer amazingly fast but still sufficient here. The nice thing about it is that it's only a single PCI card in my gateway box, no external device with additional powering required. But while the hardware is fine, its software sucked from the very first day.

The DSLv2 is pasive card. Wide parts of its lower ISDN and DSL stack run on the host. Only the signal processing is executed on a DSP, basically the heart of this PCI adapter. So the vendor, AVM, kept a lot of its core know-how on the host PC, specifically in the driver binary. Well, you may already guess what this means for Linux: a huge binary blob and a smaller "license adapter" form a proprietary device driver called fcdsl2 - the nightmare of every Linux user and developer.

Yet this nightmare worked more or less reliable for me over the last years. A few hacks were required to get it working with recent kernels and a few more hacks to fix the most annoying bugs. As the locking scheme of this thing always looked suspicious and many people already added various bits to improve it, I cowardly ran my box in CONFIG_PREEMPT_NONE mode. All was fine as long as the DSL connection was up and running.

Unfortunately, DSL links get lost once in a while, cut at least once per day by my provider. pppd was not always able to recover from this. Sometimes a full reload of the driver was required, triggered by a watchdog script. And of those reloads, some ended up in an unresponsive gateway, usually a crashed one. That happened once per month down to once per week - probably depending on the weather or my current bad aura level. Mostly too infrequent to start acting, but still too frequent to ignore it.

So, after another crash cut my home link over Christmas, I finally started looking into this mess. The original plan was to review and fix the fcdsl2, which would likely mean rewriting some parts of it - that was clear. But if I had known in advance how much was broken, well, I don't think I would have started this hack. Not only the driver required a complete locking rework, also the Linux CAPI stack that connects pppd and ISDN tools with the fcdsl2 was part of the problem.

OK, the CAPI stacks has its roots in an AVM driver that was written in the past millennium. That were the days when SMP and kernel preemption were far away from from being common. Some attempts were made to evolve the code towards a proper locking scheme, but the efforts widely stalled many years ago (see history before 2.6.12 and 2.6.12..today: mostly drive-by changes for at least 6 years). So the stack was now in a zombie state: fairly broken inside, not much in use anymore (you can buy ready-to-use DSL+phone routers today), but not yet obsolete as at least a few CAPI-speaking adapters are still around (e.g. Gigaset equipment).

So I started digging my way through the CAPI code:

 Documentation/devices.txt      |    7 +-
drivers/isdn/capi/Kconfig | 3 +-
drivers/isdn/capi/capi.c | 937 ++++++++++++++++++----------------------
drivers/isdn/capi/capidrv.c | 48 +--
drivers/isdn/capi/capifs.c | 126 +++---
drivers/isdn/capi/capifs.h | 21 +-
drivers/isdn/capi/kcapi.c | 797 ++++++++++++++++++----------------
drivers/isdn/capi/kcapi.h | 12 +-
drivers/isdn/capi/kcapi_proc.c | 41 +-
include/linux/isdn/capilli.h | 2 +-
include/linux/kernelcapi.h | 17 +-
11 files changed, 1005 insertions(+), 1006 deletions(-)

The results are 31 kernel patches, mostly touching the user space interface (capi.c), the driver layer (kcapi.c), and the special CAPI filesystem (capifs.c). I did not look very long into capidrv.c, the adapter to the legacy ISDN stack of Linux. That adapter is broken like the rest was. But I'm afraid I would have to continue with digging into the almost obsolete ISDN code, and that is huge. Instead, I decided to replace the last local user of that part, isdnlog from the isdn4k-utils, with a CAPI version, but work on that hasn't started yet.

The series is currently parked in my git tree, waiting for submission after some final stress tests. That should be completed in a few days. Stay tuned for more news from the CAPI front. Next time I will report about my endeavor fixing the FRITZ!Card DSL v2.0 driver itself.

Last Updated on Tuesday, 19 January 2010 09:00
 

Migration Completed

E-mail Print

The last relevant bits are transfered, the last service is configured, everything runs even smoother than before. I'm now on Debian here, and except for some fights with the exim configuration and the fact that Lenny still delivers a vulnerable buildbot version there was nothing to complain about.

Last Updated on Saturday, 05 December 2009 11:55
 

vServer Upgrade

E-mail Print

Under construction

The provider of this virtual server, Host Europe, is not longer supporting OpenSUSE. As the release this server is based on phased out recently, I'm now forced to upgrade. The upgrade is free, comes with a more powerful host, more RAM, a few gigs more disk space – but also with a new distro. So I'm going to set up a new server in the background over the next days. All this work should be widely invisible, but Murphy is everywhere and may still cause some downtime as well as several short nights...

 

 

Last Updated on Saturday, 05 December 2009 11:55
 

project-relay

E-mail Print

Musicpal

One of my favorite webradio stations is PROJECT RELOADED, successor of the legendary PROJECT 89.0 DIGITAL (you probably had to live in the Northern part of Germany in 2001-2003 to know this station). Unfortunately, it is not broadcasting proper metadata in its stream, while almost every webradio device would display this information nicely.

Requests to improve the situation were unsuccessful, although there are already playlists available: on the official website and on the homepage of another enthusiastic listener. They are backed by two XML files, the preview list which drives the flash-based playlist and the main list which is said to be used by the old Windows gadget player PROJECT offers for download.

So I sat down and wrote a tiny program to plug the floating pieces together: project-relay was born. On its input side, project-relay connects to the webradio stream server and also periodically reads one of the two XML playlists. It converts the data about the currently played song and injects it conforming to the shoutcase format into the stream that it provides on its output side. As the playlist server is a bit instable, quite a few magic dances are performed to avoid presenting no or invalid metadata.

The relay is written in C for Unix in order to run it directly on my Musicpal (pictured above) which is Linux-based and only has a few KB space left. Pre-built binaries of the latest version are available for both x86 and the Musicpal. They run as daemon in the background by default, but can also be re-configured:

Usage: project-relay [OPTIONS]

-d, --debug stay in foreground and issue debug messages
-p, --port PORT provide radio stream on given TCP port (default: 8010)
-v, --version print version and exit

To push the Musicpal version on the device, telnet acces has to be enabled first (go to http://<local-musicpal-ip>/admin/cgi-bin/debug.cgi). Recent revisions of that webradio come with a USB plug and support mass storage devices so that the binary can be transferred via an USB stick. Alternatively, a tftp server can provide the binary for download. The required steps are then:

# telnet 
# login as root
~ $ ./make_rw.sh
# if there is already an older version:
~ $ killall project-relay
# copy from USB
~ $ cp /tmp/mnt/Flash_Disk\#sda1/project-relay /bin/project-relay
# or download from tftp server
~ $ tftp -g -r project-relay -l /bin/project-relay <server-ip>
# Add project-relay to start script
~ $ vi /etc/init.d/mainapp

The script should gain a call to project-relay:

#! /bin/sh

case "$1" in

start)
echo "Starting Nashville."
/bin/logo 2 &
/bin/project-relay
/bin/nashville | logger &
;;
[...]

A short vi editor how-to: Press the Insert key, move the cursor and add the new line. Then press Esc and type ':x'. Finally press Enter.

Reboot the Musicpal to check if the installation succeeded:

~ $ reboot

The Musicpal will now provide a stream with proper metadata on <musicpal-ip>:8010 or 127.0.0.1:8010 (when addressing it locally). Note that only one client can connect in parallel. I was lazy and have no permant use for more so far. May change in the future, and I'm open for patches as well.

Last Updated on Saturday, 21 November 2009 14:55
 

Why Flash Sucks on the Best OS

E-mail Print

Yesterday I finally watched that great movie Home on my laptop. And I wondered if I already need a new one. But now I know for sure it wasn't a hardware problem:

why flash still sucks
(for more of these: www.xkcd.net)

Seriously, Adobe's Flash plugin for Linux is a nightmare. Right while hacking these lines it decides to go wild and took whole Firefox with unsaved version 1 of the article with it. And this happens regularly with Flash-overloaded pages here. Based on some gdb sessions with stalled Firefoxes my suspect is a lock-ordering bug. Well, hard to say for sure without the source code...

Too bad that half of the Web more or less depends on this closed-source extension. And we still have no real alternative.

Last Updated on Saturday, 30 June 2012 09:12
 
More Articles...
  • «
  •  Start 
  •  Prev 
  •  1 
  •  2 
  •  Next 
  •  End 
  • »


Page 1 of 2
© Copyright 2009 by Jan Kiszka (PGP Key)