Excerpt from “Understanding Linux Network Internals”

Coding, Geekery, Linux — December 30, 2009 at 6:24 pm

I’m currently reading Christian Benvenuti’s excellently written Understanding Linux Network Internals from O’Reilly which is helping to shore up my knowledge about how the networking stack is implemented in Linux. It’s a fantastic read so far, on course to match Linux Kernel Development by Robert Love, one of my all-time favorite books.

The following paragraph from Benvenuti’s book really made me step back and take a look at the bigger picture:

A device driver can also disable the egress queue before a transmission (to prevent the kernel from generating another transmission request on the device), and re-enable it only if there is enough free memory on the NIC; if not, the device asks for an interrupt that allows it to resume transmission at a later time. Here is an example of this logic, taken from the el3_start_xmit routine, which the drivers/net/3c509.c driver installs as its hard_start_xmit function in its net_device structure…

That passage is just brilliant. Count the occurrences of jargon there!

I guess i should read more arXiv papers to better understand how much larger the world actually is.

XSLT for OPML to XHTML List

Coding, Geekery, Linux — December 28, 2009 at 8:45 pm

The following some XSLT sufficient to transform an OPML file into a list, ready for you to edit and post:

<?xml version="1.0" encoding="UTF-8"?>

<xsl:stylesheet version="1.0"
  xmlns:xhtml="http://www.w3.org/1999/xhtml"
  xmlns="http://www.w3.org/1999/xhtml"
  xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  xmlns:xs="http://www.w3.org/2001/XMLSchema"
  exclude-result-prefixes="xhtml xsl xs">

    <xsl:template match="body">
        <ol><xsl:text>
</xsl:text>
            <xsl:for-each select="outline">
                <li> <a href="{@htmlUrl}" ><strong><xsl:value-of select="@text" /></strong></a> - your text </li><xsl:text>
</xsl:text>
            </xsl:for-each>
        </ol>
    </xsl:template>
</xsl:stylesheet>

It isn’t 100% complete, but will get you a list of the form:

<ol>
    <li><a href="URL"><strong>Title</strong></a> - your text</li>
</ol>

In a sane interface to an operating system, you can run the following to produce transformed output, given the XSL above and an OPML file:

$ xsltproc extract.xsl google-reader-subscriptions.xml

Slashdot poll: Most Useful UNIX Tool

Geekery, Linux — September 19, 2009 at 11:09 pm

In response to the current /. poll, Most Useful UNIX Tool: I have the following from my ~/.zhistory at work:

$ for cmd in sed grep cat find telnet init exit ; do echo -n $cmd= ; grep -c “$cmd ” ~/.zhistory; done
sed=85
grep=875
cat=762
find=126
telnet=15
init=32
exit=33

Which is interesting to me. I can explain some of the counts:

  • I run ‘cat $file | (grep|sed|awk) | …’ too often out of a good/bad habit.
  • ‘exit’ is small because I’ve bound ”x’ to exit (which itself is a bad habit; I should have just started using ‘Control-D’.
  • ’ssh’ > ‘telnet’
  • I don’t have root, so ‘init’ isn’t really used, and my regex isn’t careful enough to eliminate ‘disk_init’.
  • ’sed’ is mega-useful, but is usually the second command in a pipeline. I want to start using ‘perl -pe’ more.

how to: resume from suspend by keystroke in Linux

Geekery, Linux — July 8, 2009 at 8:22 pm

I’ve always wondered why Macs could wakeup from sleep by a mere keystroke, but my Linux boxes required me to press the power button. It turns out you can enable wake from suspend/hibernate in Linux by adding the following to /etc/rc.local, which is run at startup:

for i in `/bin/grep USB /proc/acpi/wakeup | /usr/bin/awk '{print $1}'`;
do
    echo $i > /proc/acpi/wakeup;
done

/proc/acpi/wakeup will then look something like:

$ cat /proc/acpi/wakeup
Device  S-state   Status   Sysfs node
PCI0      S5     disabled  no-bus:pci0000:00
PEX0      S5     disabled  pci:0000:00:1c.0
PEX1      S5     disabled  pci:0000:00:1c.1
PEX2      S5     disabled
PEX3      S5     disabled
PEX4      S5     disabled
PEX5      S5     disabled
HUB0      S5     disabled  pci:0000:00:1e.0
IGBE      S5     disabled
USB0      S3     enabled   pci:0000:00:1d.0
USB1      S3     enabled   pci:0000:00:1d.1
USB2      S3     enabled   pci:0000:00:1d.2
USB3      S3     enabled   pci:0000:00:1a.0
USB4      S3     enabled   pci:0000:00:1a.1
USB5      S3     enabled   pci:0000:00:1a.2
EHC1      S3     disabled  pci:0000:00:1d.7
EHC2      S3     disabled  pci:0000:00:1a.7
AZAL      S5     disabled  pci:0000:00:1b.0

and voila: when your Linux box suspends, you can wake it up by pressing any key on your USB keyboard.

ratpower.sh: a power menu for ratpoison

Coding, Geekery, Linux, My Projects — April 19, 2009 at 7:02 pm

I’ve started to use ratpoison on my netbook. I’ve made a script that displays a menu of power-related actions and the current state of the battery. Here is a screenshot:

[discharging 58%]
SLEEP
HIBERNATE
REBOOT
SHUTDOWN
LOCK

The script uses ratmenu to actually display the menu and uses dbus to send signals.

download ratpower.sh

why would you say that?

Geekery, Linux — November 16, 2008 at 1:26 am

Saw this on Freshmeat today:

About: [some open source project] is a real-time collaboration (RTC) server. It uses the only widely adopted open protocol for instant messaging, XMPP (also called Jabber). [some open source project] is incredibly easy to setup and administer, but offers rock-solid security and performance.

Changes [in the new version]: A security flaw allowed authentication to be bypassed, allowing arbitrary code execution. This was fixed. JDBC and JID optimizations were done.

(Emphasis mine).

Wait, really? rock-solid security != arbitrary code execution, last time I checked.

New Computer!!!!111

Geekery, Linux — November 9, 2008 at 1:36 pm

This week, I purchased a new computer:

Shuttle SG33
Intel Core 2 Quad Q6600 2.4GHz
2 x 1GB DDR2 DIMMs
Cheapo ATI Radeon X1650 ( 2 x DVI-D)
2 x Acer x243w 24″ LCDs (yes, that’s 2!)

(I already had cheap hard disks, a gorgeous mouse, and a nice keyboard; though, I envision I’ll be bringing the love of my life home from work more often).

I purchased all of the parts from newegg, as they were offering some good specials for pretty much all the components, including free shipping for the monitors, which arrived the next day.

Assembling and getting the machine running was mostly without issue. The only complaint I have about the hardware is that the graphics card fan is extremely loud, something I will have to remedy in the coming weeks. Since I’m not a hardcore gamer anyway, I tried just unplugging the fan, but the card temporarily died a few minutes later. It does run extremely hot. That’s what you get when you skimp on an important component and don’t consult slientpcreview.com beforehand.

I’ve found UNetbootin to be an invaluable tool despite the horrible name. I ran out of CD-Rs a long time ago and don’t care to buy any more. UNetbootin has saved a considerable amount of time by transferring an iso+bootloader onto a hard drive. Highly recommended.

Getting X to deal with spanning across two monitors was a bit of a pain: the ATI Catalyst Control Center is broken and segfaults before the configuration is written out to disk but after the settings are applied to the driver. It took some poking around to realize that after setting the monitors up properly in Catalyst, then running the vanilla screen resolution manager, then blindly clicking “Apply”, the settings become static.

I also had an issue where the max_cpu_freq for all four cores was static at 1.6 GHz and Intel Speed Step (EIST) did not work. This was resolved by upgrading the bios to the latest version, which is annoying when not running Windows and not owning a floppy drive. I got around this by following these instructions on creating a bootable USB disk with FreeDOS. Admittedly, that is kind of a roundabout way of installing DOS to a disk (requiring installing a DOS emulator), but it works, where the other methods were far more complicated and had mixed results.

Now that I have a sweet rig and some more time (the latter due to life events), I hope to hammer out code more often. I have an idea to write a version of rup that has the same features as fping, or at least times out in a reasonable period.

And, now that Ubuntu Ibex is out, I need to try getting my PS3 running Linux again. Sadly, it still doesn’t support WPA at the moment, meaning I need to get/fetch from home a really long ethernet cable.

Update: Despite this new rig, I’m still kind of jealous of NYCR.

bzip’d tar file returns error

Geekery, Linux — January 29, 2008 at 8:26 pm

right. so I got this today when trying to untar all of my academic work from an archive:

ericgar@babbage extusb$ tar -xjf columbia-2007-10-31.tar.bzip2
You can use the `bzip2recover' program to attempt to recover
data from undamaged sections of corrupted files.
tar: Child returned status 2
tar: Error exit delayed from previous errors

ericgar@babbage extusb$ bzip2recover columbia-2007-10-31.tar.bzip2
bzip2recover 1.0.4: extracts blocks from damaged .bz2 files.
bzip2recover: searching for block boundaries ...
bzip2recover: I/O error reading `columbia-2007-10-31.tar.bzip2', possible reason follows.
bzip2recover: Input/output error
bzip2recover: warning: output file(s) may be incomplete.

I was thinking, “Well, data loss sucks.”

But it turns out the underlying filesystem was mounted read-write on a read-only mount point. D’oh. I feel like tar and bzip2recover could have told me that off the bat.

Sendmail SMTP AUTH Config Explanation

Geekery, Linux — April 10, 2007 at 7:34 pm

Both for my own knowledge and that of the internet, I took the time to finely document my sendmail.mc configuration file for use with SMTP AUTH to an external SMTP server. In this configuration, my local users can send mail to the rest of the internet by authenticating with my ISP’s SMTP server and send mail through it.

The following sites were extremely helpful when initially trying to configure this:

You can download my configuration file as it is printed below.
(more…)

IMAPProxy: MD5_DIGEST_LENGTH undeclared

Geekery, Linux — February 24, 2007 at 9:26 am

When I attempted to compile IMAPProxy on Linux 2.6.18 with GCC 4.1.1, I received this error:

src/imapcommon.c: In function 'Get_Server_conn':
src/imapcommon.c:380: error: 'MD5_DIGEST_LENGTH' undeclared (first use in this function)

The post by Jakob Hirsch on the IMAPProxy mailing list provided the answer:

Problem is that md5.h is not longer included by evp.h (which is included
by src/imapcommon.c), so MD5_DIGEST_LENGTH is not defined.
“#include ” in src/imapcommon.c fixed it for me.

Older Posts »
This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 2.5 License. | Eric Garrido