2011年2月21日月曜日

obs600 で debian squeeze - その 2

uImage.initrd-cfboot の作成。src.tgz 展開して (bmake の?) Makefile を眺めると u-boot というパッケージの mkimage とゆーコマンドで三つのファイルを合わせている模様。最初がカーネル、次が ramdisk で最後が obs600.dtd。最初は先に make-kpkg したときにできた vmlinux を objcopy、最後はカーネルソースディレクトリで make のターゲットになってる。で真ん中の抽出。file コマンドの magic どこにあるか知らないので...
$ echo test | gzip > test.gz
$ hexdump test.gz
0000000 8b1f 0008 e2ea 4d5c 0300 492b 2e2d 02e1
0000010 c600 b935 053b 0000 0000
0000019
で uImage.initrd-cfboot 持ってきて眺めてみると
$ wget http://ftp.plathome.co.jp/pub/OBS600/LATEST/powerpc-obs600/installation/uImage.initrd-cfboot
$ mkimage -l uImage.initrd-cfboot
Image Name: 0.5-RELEASE-20101206-cfboot
Created: Sat Dec 11 23:23:08 2010
Image Type: PowerPC Linux Multi-File Image (gzip compressed)
Data Size: 2118162 Bytes = 2068.52 kB = 2.02 MB
Load Address: 00000000
Entry Point: 00000000
Contents:
Image 0: 1694842 Bytes = 1655.12 kB = 1.62 MB
Image 1: 415397 Bytes = 405.66 kB = 0.40 MB
Image 2: 7902 Bytes = 7.72 kB = 0.01 MB
$ hexdump uImage.initrd-cfboot | head -n8
0000000 0527 5619 57d2 dc0f 034d 4c89 2000 1252
0000010 0000 0000 0000 0000 8ea3 d3c5 0705 0104
0000020 2e30 2d35 4552 454c 5341 2d45 3032 3031
0000030 3231 3630 632d 6266 6f6f 0074 0000 0000
0000040 1900 7adc 0600 a556 0000 de1e 0000 0000
0000050 8b1f 0808 dfa9 4d01 0302 6d76 696c 756e
0000060 2e78 6962 2e6e 3432 3532 0033 5be4 707d
0000070 5554 3f96 bbaf 1d03 4388 0d03 0483 63a1
0x50 あたりからがカーネルの gz らしい。mkimage -l の出力に素直に従って
$ dd if=uImage.initrd-cfboot bs=1 skip=$((0x50)) count=1694842 of=Image.0
1694842+0 records in
1694842+0 records out
1694842 bytes (1.7 MB) copied, 7.09509 s, 239 kB/s
$ file Image.0
Image.0: gzip compressed data, was "vmlinux.bin.24253", from Unix, last modified: Fri Dec 10 17:07:05 2010, max compression
おぉ。調子にのって
$ dd if=uImage.initrd-cfboot bs=1 skip=$((0x50 + 1694842)) count=415397 of=Image.1
415397+0 records in
415397+0 records out
415397 bytes (415 kB) copied, 1.6545 s, 251 kB/s
$ file Image.1
Image.1: data
むーんと、再度 0x1f 0x8b 0x08 を探して
$ hexdump Image.1 | head -n 8
0000000 0000 8b1f 0808 8922 4d03 0302 6172 646d
0000010 7369 2e6b 6d69 6761 2d65 6663 6f62 746f
0000020 ec00 099d 1c7c 7d57 47c7 3abb b5ac 3893
0000030 0877 7924 e496 8e43 d0f7 964a 396d 2c72
0000040 72db c4ec 2257 39c7 271c 9d9e d59d b44e
0000050 b3bb 9999 91d5 25c4 b694 9694 dc33 8e10
0000060 29b4 a16d 69b4 e108 204a 82f4 d0b6 5a16
0000070 3d08 d028 b693 6850 bd0b f4db e6ff 4690
$ dd if=uImage.initrd-cfboot bs=1 skip=$((0x50 + 1694842 + 2)) count=415397 of=Image.1
415397+0 records in
415397+0 records out
415397 bytes (415 kB) copied, 1.71914 s, 242 kB/s
$ file Image.1
Image.1: gzip compressed data, was "ramdisk.image-cfboot", from Unix, last modified: Sat Dec 11 23:22:26 2010, max compression
何か力技っぽいけど、まぁ。試しに
$ gzip -cd < Image.1 > ramdisk.image-cfboot
$ file ramdisk.image-cfboot
ramdisk.image-cfboot: Linux rev 1.0 ext2 filesystem data, UUID=79b27492-4074-4633-a1e1-9094c7a4eccd
$ su
Password:
# mkdir tmp
# mount -o loop ramdisk.image-cfboot tmp
# ls tmp
bin dev etc home lib linuxrc lost+found mnt proc root sbin sys tmp usr var
あとは前後の二つ
$ cd linux-source-2.6.32
$ make ARCH=powerpc obs600.dtb
/home/chamaken/obs600/linux-source-2.6.32/scripts/dtc/dtc -O dtb -o arch/powerpc/boot/obs600.dtb -b 0 -p 1024 /home/chamaken/obs600/linux-s\
ource-2.6.32/arch/powerpc/boot/dts/obs600.dts
DTC: dts->dtb on file "/home/chamaken/obs600/linux-source-2.6.32/arch/powerpc/boot/dts/obs600.dts"
$ cp arch/powerpc/boot/obs600.dtb ..
正直よくわかってないけど先の通り Makefile 眺めたところの結果
$ powerpc-linux-gnu-objcopy -O binary vmlinux ../vmlinux.bin
$ cd ..
$ gzip vmlinux.bin
$ ls
Image.0 linux-image-2.6.32_0.9_powerpc.deb obs600.dtb src.tgz uImage.initrd-cfboot vmlinux.bin.gz
Image.1 linux-source-2.6.32 ramdisk.image-cfboot test.gz usr
$ mkimage -n "original.$(date +'%FT%T')" -A ppc -O linux -T multi -C gzip -d vmlinux.bin.gz:Image.1:obs600.dtb myImage.initrd-cfboot
Image Name: original.2011-02-20T18:18:09
Created: Sun Feb 20 18:18:09 2011
Image Type: PowerPC Linux Multi-File Image (gzip compressed)
Data Size: 2304477 Bytes = 2250.47 kB = 2.20 MB
Load Address: 00000000
Entry Point: 00000000
Contents:
Image 0: 1881007 Bytes = 1836.92 kB = 1.79 MB
Image 1: 415397 Bytes = 405.66 kB = 0.40 MB
Image 2: 8053 Bytes = 7.86 kB = 0.01 MB
えぇ、モチロン、コレはチラシのウラ、備忘録。

2011年2月20日日曜日

obs600 で debian squeeze - その 1

squeeze がリリースされたので「OBS600でlinux-2.6.35.4 + Debian squeeze」と同じようなコトしてみた。ただ ssdlinux を走らせるのが面倒だったので極力 amd64 からのクロス環境でダーティハック込み。まずは「ファームウェアアップデートを実行したら起動しなくなりました。どうすれば復旧できますか。」の準備
# apt-get install tftpd-hpa
....
# cd /srv/tftp
# wget http://ftp.plathome.co.jp/pub/OBS600/0.5-LATEST/powerpc-obs600/installation/uImage.initrd
....
# ip addr add 192.168.253.1/24 dev eth0
# /etc/init.d/tftpd-hpa restart
ディップスイッチ操作が必要になる --- であろうとフタは外しておく。
順序はどうでもよいけど「他OSのインストール方法 (OBS600)」見つつ obs600 側の CF フォーマット。
# fdisk /dev/sda
# mke2fs -j -b 4096 -L / /dev/sda1
# mount LABEL=/ /mnt# cd /mnt/
また 開発環境の構築の中「クロス開発 (VMware等のx86環境上での開発)」の 3. 必要なパッケージを追加します。までやっとく。

で amd64 側でのカーネルのコンパイルヘ。obs600 のパッチは ssdlinux のソースから
$ mkdir obs600
$ cd obs600
$ wget http://ftp.plathome.co.jp/pub/ssdlinux/0.5-LATEST/source/src.tgz
$ tar xzf src.tgz
$ ls usr/src/mkdist/kernel
2.4.20 2.4.26 2.4.37 2.6.16 2.6.26 2.6.29 2.6.32 2.6.33 2.6.35 2.6.36 Makefile
2.6.36 も動くけど、ここは squeeze ソース使って
$ sudo apt-get install linux-source-2.6.32
$ tar xjf /usr/src/linux-source-2.6.32.tar.bz2 -C .
$ ls
linux-source-2.6.32 src.tgz usr
2.6.32 のパッチあて
$ cd linux-source-2.6.32
$ for i in ../usr/src/mkdist/kernel/2.6.32/patches/*.patch; do patch -p1 < $i; done
....
patching file Makefile
Reversed (or previously applied) patch detected! Assume -R? [n]
Apply anyway? [n]
Skipping patch.
4 out of 4 hunks ignored -- saving rejects to file Makefile.rej
patching file scripts/Makefile.modinst
この Makefile の rej はムシしても OK な範囲。カーネルモジュールを gzip してくれなくてもよいので scripts.patch は除外。その他必要なファイルをコピーしておく
$ patch -p1 -R <  ../usr/src/mkdist/kernel/2.6.32/patches/scripts.patch
$ cp ../usr/src/mkdist/kernel/2.6.32/obs600.dts arch/powerpc/boot/dts/
$ cp ../usr/src/mkdist/kernel/2.6.32/dot.config.powerpc-obs600 .config
$ make ARCH=powerpc menuconfig
....

$ CONCURRENCY_LEVEL=4 fakeroot make-kpkg --arch=powerpc --revision 0.9 kernel_image
....
$ cd ..
$ ls
linux-image-2.6.32_0.9_powerpc.deb linux-source-2.6.32 src.tgz usr
と、その 1 はここまで。

2009年12月14日月曜日

lisp の quicksort

まぁ、まだ元気だよ。と言うことで、とっても久しぶり。

年に一度位。歳と共に頻度が少なくなる気がするけど SICP を中途半端なまま眺めたりすることがある。少し前くらいかな。関数型言語が流行ったらしくていくつか入門書らしきものも購入したり。その中に Haskell の quick ソートがあった。3.1 Quicksort in Haskell
qsort []     = []
qsort (x:xs) = qsort (filter (< x) xs) ++ [x] ++ qsort (filter (>= x) xs)
すんごいシンプル。
  • 遅延評価
  • 副作用はモナドが引き受ける
あたりが魅力的。同じようなものは...と探したところ、Lisp のものもあった。swisspig.net - The Beauty of a Lisp Quicksort
(defun quicksort (lis) (if (null lis) nil
(let* ((x (car lis)) (r (cdr lis)) (fn (lambda (a) (< a x))))
(append (quicksort (remove-if-not fn r)) (list x)
(quicksort (remove-if fn r))))))
で、拙い Scheme では....
(use srfi-1)

(define (qsort lst)
(if (null? lst) '()
(let* ((x (car lst))
(r (cdr lst)))
(append
(qsort (filter (lambda (a) (< a x)) r))
(list x)
(qsort (filter (lambda (a) (>= a x)) r))))))
さらに Shiro さん の続きを早く読みたい なんでも継続を眺めつつ.... こんな感じなのかなぁ。
(define (qsort/cps lst cont)
(if (null? lst) (cont '())
(let* ((x (car lst))
(r (cdr lst)))
(qsort/cps (filter (lambda (a) (< a x)) r)
(lambda (n)
(qsort/cps (filter (lambda (a) (>= a x)) r)
(lambda (m) (cont (append n (list x) m)))))))))
メジャーどころの Python でも同じようにするには、こんなん?
def qsort(lst):
if len(lst) < 1: return []

x = lst[0]
r = lst[1:]

return qsort([i for i in r if i < x]) \
+ [x] \
+ qsort([i for i in r if i >= x])

2009年6月30日火曜日

lxc の (今までの) ごめんなさい

いくつか嘘ついていました。
devpts
lxc.mount に指定する fstab にて devpts を
/dev/pts /opt/lxc/sshd/rootfs/dev/pts none bind,newinstance 0 0
なんて書いていましたが、意図した正しくは
lxcpts /opt/lxc/sshd/rootfs/dev/pts devpts newinstance,ptmxmode=0666 0 0
でした。

quagga のユーザ、グループ
ホスト側とコンテナ内の uid gid が一致しないと動きませんでした。修正しましたので、良ろしかったらお試し下さい。quagga はこちら。sshd はこちらです。debian/lenny の amd64 です。i386 の方は fstab から /lib64 削除すれば動くと思います。

/usr/local/lib の liblxc-*.so
やっぱ /usr/lib にコピーした方が良さげです。相変わらずの勉強不足で ld.so.cache のフォーマットが x86_64 と i386 が同じで良いかわからず、動かせませんでした
付き合ってくれた人、ごめんなさい。

2009年6月23日火曜日

veth に ping

lxc で使っている veth は OpenVZ 由来だそうだ。何かちょっと不思議に思って veth 作って ping 投げてみた。
# ip link add type veth
# ip link ls veth0
11: veth0: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN qlen 1000
link/ether 9a:87:c9:92:6b:91 brd ff:ff:ff:ff:ff:ff
# ip link ls veth1
12: veth1: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN qlen 1000
link/ether 42:01:93:00:97:d9 brd ff:ff:ff:ff:ff:ff
# ip link set veth0 up
# ip link set veth1 up
# ip addr add 192.168.1.10/24 dev veth0
# ip addr add 192.168.1.11/24 dev veth1
# ping -c 4 192.168.1.10
PING 192.168.1.10 (192.168.1.10) 56(84) bytes of data.
64 bytes from 192.168.1.10: icmp_seq=1 ttl=64 time=0.074 ms
64 bytes from 192.168.1.10: icmp_seq=2 ttl=64 time=0.073 ms
64 bytes from 192.168.1.10: icmp_seq=3 ttl=64 time=0.070 ms
64 bytes from 192.168.1.10: icmp_seq=4 ttl=64 time=0.072 ms

--- 192.168.1.10 ping statistics ---
4 packets transmitted, 4 received, 0% packet loss, time 2999ms
rtt min/avg/max/mdev = 0.070/0.072/0.074/0.006 ms
# ping -c 4 192.168.1.11
PING 192.168.1.11 (192.168.1.11) 56(84) bytes of data.
64 bytes from 192.168.1.11: icmp_seq=1 ttl=64 time=0.094 ms
64 bytes from 192.168.1.11: icmp_seq=2 ttl=64 time=0.026 ms
64 bytes from 192.168.1.11: icmp_seq=3 ttl=64 time=0.078 ms
64 bytes from 192.168.1.11: icmp_seq=4 ttl=64 time=0.069 ms

--- 192.168.1.11 ping statistics ---
4 packets transmitted, 4 received, 0% packet loss, time 2999ms
rtt min/avg/max/mdev = 0.026/0.066/0.094/0.027 ms
まぁ loopback みたいな感じ。で veth0 から veth1 - 192.168.1.11 に ping 投げてみると
# ping -I veth0 192.168.1.11
PING 192.168.1.11 (192.168.1.11) from 192.168.1.10 veth0: 56(84) bytes of data.
From 192.168.1.10 icmp_seq=2 Destination Host Unreachable
From 192.168.1.10 icmp_seq=3 Destination Host Unreachable
From 192.168.1.10 icmp_seq=4 Destination Host Unreachable
音沙汰なしっ。tcpdump で眺めてみると
# tcpdump -ntei veth0
tcpdump: verbose output suppressed, use -v or -vv for full protocol decode
listening on veth0, link-type EN10MB (Ethernet), capture size 96 bytes
9a:87:c9:92:6b:91 > ff:ff:ff:ff:ff:ff, ethertype ARP (0x0806), length 42: arp who-has 192.168.1.11 tell 192.168.1.10
9a:87:c9:92:6b:91 > ff:ff:ff:ff:ff:ff, ethertype ARP (0x0806), length 42: arp who-has 192.168.1.11 tell 192.168.1.10
9a:87:c9:92:6b:91 > ff:ff:ff:ff:ff:ff, ethertype ARP (0x0806), length 42: arp who-has 192.168.1.11 tell 192.168.1.10
^C
3 packets captured
3 packets received by filter
0 packets dropped by kernel
# tcpdump -ntei veth1
tcpdump: verbose output suppressed, use -v or -vv for full protocol decode
listening on veth1, link-type EN10MB (Ethernet), capture size 96 bytes
9a:87:c9:92:6b:91 > ff:ff:ff:ff:ff:ff, ethertype ARP (0x0806), length 42: arp who-has 192.168.1.11 tell 192.168.1.10
9a:87:c9:92:6b:91 > ff:ff:ff:ff:ff:ff, ethertype ARP (0x0806), length 42: arp who-has 192.168.1.11 tell 192.168.1.10
9a:87:c9:92:6b:91 > ff:ff:ff:ff:ff:ff, ethertype ARP (0x0806), length 42: arp who-has 192.168.1.11 tell 192.168.1.10
9a:87:c9:92:6b:91 > ff:ff:ff:ff:ff:ff, ethertype ARP (0x0806), length 42: arp who-has 192.168.1.11 tell 192.168.1.10
^C
4 packets captured
4 packets received by filter
0 packets dropped by kernel
lxc 追って調べてみるのは面倒だなぁ。と Google 先生に相談したところ lxc の前、ns_exec なるソースを見つけた。既に昔のものになっているらしく
  • ここから持ってきたけど無くなりそうなので
  • ちょっと変更して
    --- ns_exec.c.orig 2009-06-21 23:02:41.000000000 +0900
    +++ ns_exec.c 2009-06-21 23:03:08.000000000 +0900
    @@ -12,7 +12,7 @@
    #include <sys/wait.h>
    #include <sys/mount.h>

    -#include "clone.h"
    +#include <linux/sched.h>

    extern pid_t getpgid(pid_t pid);
    extern pid_t getsid(pid_t pid);
  • ローカルコピー
コンパイルして起動してみる
# cc -o ns_exec ns_exec.c
# echo $$
30530
# ./ns_exec -c -n /bin/bash
about to clone with 40000000
# echo $$
30549
# ip link ls
28: lo: <LOOPBACK> mtu 16436 qdisc noop state DOWN
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
29: gre0: <NOARP> mtu 1476 qdisc noop state DOWN
link/gre 0.0.0.0 brd 0.0.0.0

で PID 30549 に veth1 を渡してあげる
(って言い回しが正しいかわからないけど - 別ターミナルから)
# ip link set veth1 netns 30549
ns_exec したターミナルに戻ってみると
# ip link ls
28: lo: <LOOPBACK> mtu 16436 qdisc noop state DOWN
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
29: gre0: <NOARP> mtu 1476 qdisc noop state DOWN
link/gre 0.0.0.0 brd 0.0.0.0
31: veth1: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN qlen 1000
link/ether 1e:cf:fa:8f:a4:4b brd ff:ff:ff:ff:ff:ff
おぉ、わたってる。リンク上げたりアドレス設定すると期待通り
# ip link set veth1 up
# ip addr ls
28: lo: <LOOPBACK> mtu 16436 qdisc noop state DOWN
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
29: gre0: <NOARP> mtu 1476 qdisc noop state DOWN
link/gre 0.0.0.0 brd 0.0.0.0
31: veth1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
link/ether 1e:cf:fa:8f:a4:4b brd ff:ff:ff:ff:ff:ff
inet6 fe80::1ccf:faff:fe8f:a44b/64 scope link
valid_lft forever preferred_lft forever
# ip addr add 192.168.1.11/24 dev veth1
# ping -I veth1 192.168.1.10
PING 192.168.1.10 (192.168.1.10) from 192.168.1.11 veth1: 56(84) bytes of data.
64 bytes from 192.168.1.10: icmp_seq=1 ttl=64 time=3.72 ms
64 bytes from 192.168.1.10: icmp_seq=2 ttl=64 time=0.131 ms
64 bytes from 192.168.1.10: icmp_seq=3 ttl=64 time=0.108 ms
64 bytes from 192.168.1.10: icmp_seq=4 ttl=64 time=0.111 ms
^C
--- 192.168.1.10 ping statistics ---
4 packets transmitted, 4 received, 0% packet loss, time 2999ms
rtt min/avg/max/mdev = 0.108/1.019/3.727/1.563 ms

なぜ?

例のごとく深く追ってないけど....ARP については
veth_xmit()::driver/net/veth.c
netif_rx()::net/core/dev.c
net_rx_action()::net/core/dev.c - softirq
process_backlog()::net/core/dev.c - dev->poll()
netif_receive_skb()::net/core/dev.c
arp_rcv()::net/ipv4/arp.c
arp_process()::net/ipv4/arp.c
arp_ignore()::net/ipv4/arp.c
inet_confirm_addr()::net/ipv4/devinet.c
confirm_addr_indev()::net/ipv4/devinet.c
この内 inet_confir_addr() から引用
struct net *net;
....
net = dev_net(in_dev->dev);
....
for_each_netdev(net, dev) {
if ((in_dev = __in_dev_get_rcu(dev))) {
addr = confirm_addr_indev(in_dev, dst, local, scope);
struct net は include/net/net_namespace.h で定義されている。上記はネットワークの「名前空間毎に」 net_device / in dev を保持していて、これを加味した上で指定された IP アドレスがローカルか否か判断しているらしい。

ローカルだよ (って表現も上手くないと思うけど) って判断が下り通常は arp_process() にて ARP に応答しない。ns_exec で CLONE_NEWNET してあると、ローカルと判断しない... ``らしい'' ばかりでごめんなさい。

2009年6月15日月曜日

rt73usb rt2500usb で hostapd

相変わらずの TXDONE_UNKNOWN
2.6.30 がリリースされたけど /drivers/net/wireless/rt2x00/rt2x00usb の TXDONE_UNKNOWN については以前のまま。チェックしている辺を grep すると何となく....
$ fgrep -C 4 'test_bit(TXDONE' *.c
rt2x00dev.c- /*
rt2x00dev.c- * Update TX statistics.
rt2x00dev.c- */
rt2x00dev.c- rt2x00dev->link.qual.tx_success +=
rt2x00dev.c: test_bit(TXDONE_SUCCESS, &txdesc->flags);
rt2x00dev.c- rt2x00dev->link.qual.tx_failed +=
rt2x00dev.c: test_bit(TXDONE_FAILURE, &txdesc->flags);
rt2x00dev.c-
rt2x00dev.c- rate_idx = skbdesc->tx_rate_idx;
rt2x00dev.c- rate_flags = skbdesc->tx_rate_flags;
rt2x00dev.c-
--
rt2x00dev.c- tx_info->status.rates[0].count = txdesc->retry + 1;
rt2x00dev.c- tx_info->status.rates[1].idx = -1; /* terminate */
rt2x00dev.c-
rt2x00dev.c- if (!(tx_info->flags & IEEE80211_TX_CTL_NO_ACK)) {
rt2x00dev.c: if (test_bit(TXDONE_SUCCESS, &txdesc->flags))
rt2x00dev.c- tx_info->flags |= IEEE80211_TX_STAT_ACK;
rt2x00dev.c: else if (test_bit(TXDONE_FAILURE, &txdesc->flags))
rt2x00dev.c- rt2x00dev->low_level_stats.dot11ACKFailureCount++;
rt2x00dev.c- }
rt2x00dev.c-
rt2x00dev.c- if (rate_flags & IEEE80211_TX_RC_USE_RTS_CTS) {
rt2x00dev.c: if (test_bit(TXDONE_SUCCESS, &txdesc->flags))
rt2x00dev.c- rt2x00dev->low_level_stats.dot11RTSSuccessCount++;
rt2x00dev.c: else if (test_bit(TXDONE_FAILURE, &txdesc->flags))
rt2x00dev.c- rt2x00dev->low_level_stats.dot11RTSFailureCount++;
rt2x00dev.c- }
rt2x00dev.c-
rt2x00dev.c- /*
上の方はリンク品質、結果送信レートに。下の方が肝心の hostapd で送信可否の判断材料IEEE80211_RADIOTAP_F_TX_FAILになるらしい
$ cd net/mac80211/
$ fgrep -C 2 IEEE80211_RADIOTAP_F_TX_FAIL *.c
main.c- if (!(info->flags & IEEE80211_TX_STAT_ACK) &&
main.c- !is_multicast_ether_addr(hdr->addr1))
main.c: rthdr->tx_flags |= cpu_to_le16(IEEE80211_RADIOTAP_F_TX_FAIL);
main.c-
main.c- /*
で、仕方が無いと言うか無理矢理稼働させるがための二行パッチ
$ cd drivers/net/wireless/rt2x00/
$ diff -ubB rt2x00usb.c.orig rt2x00usb.c
--- rt2x00usb.c.orig 2009-06-15 20:14:27.000000000 +0900
+++ rt2x00usb.c 2009-06-15 20:14:53.000000000 +0900
@@ -200,7 +200,7 @@
*/
txdesc.flags = 0;
if (!urb->status)
- __set_bit(TXDONE_UNKNOWN, &txdesc.flags);
+ __set_bit(TXDONE_SUCCESS, &txdesc.flags);
else
__set_bit(TXDONE_FAILURE, &txdesc.flags);
txdesc.retry = 0;

コンパイル
hostapd を git やら CVS やらで持って来てl.... 後出しじゃんけんだけど
$ ldd /usr/local/sbin/hostapd
linux-vdso.so.1 => (0x00007fff06b95000)
libnl.so.1 => /usr/lib/libnl.so.1 (0x00007f8916e67000)
libssl.so.0.9.8 => /usr/lib/libssl.so.0.9.8 (0x00007f8916c16000)
libcrypto.so.0.9.8 => /usr/lib/libcrypto.so.0.9.8 (0x00007f891687b000)
libc.so.6 => /lib/libc.so.6 (0x00007f8916528000)
libm.so.6 => /lib/libm.so.6 (0x00007f89162a5000)
libdl.so.2 => /lib/libdl.so.2 (0x00007f89160a1000)
libz.so.1 => /usr/lib/libz.so.1 (0x00007f8915e8a000)
/lib64/ld-linux-x86-64.so.2 (0x00007f89170b6000)
openssl と libz ほか libnl が必要。debian/lenny では libnl1 libnl-dev でバージョンが 1。どうも新しい方が良さそうなので git で持って来た方が吉。以前の $HOSTAPD/defconfig には CONFIG_LIBNL20 なんてあったけど、今は無し。まとめて
  • git などで hostapd と libnl 持ってくる
  • lib〜-dev は libc6-dev zlib1g-dev libssl-dev
  • libnl を ./configure --prefix=/usr/local でコンパイル & ld.so.conf 周りに /usr/local/lib が含まれていること確認して ldconfig
  • hostap/hostapd に移って defconfig を .config に変更。適当に変更するも CONFIG_DRIVER_NL80211=y は忘れずに

その他
やべ、面倒になってきた....国によって異なる利用可能な無線スペクトラム? に従うために、この辺りも、多分最近のものは必須。これらコンパイルに必要な追加パッケージは crda の README に書かれている通り python-m2crypto。
同じく crda の方で make install すると udev の rule が /usr/lib/udev/rules.d/85-regulatory.rules にコピーされてしまうので /etc/udev/rules.d/ に移してあげるコト。

おまけ
  • It's All Text なるもの試してみました。ラクチンだけど考えまとめてないと、こんな風にとりとめなくウダウダは相変わらず。
  • Wikipedia の 802.11 カテゴリがまとまっている。
  • Adobe labs からの 64bit 版 Adobe Flash Player 10 でも Googlel/検察ツール/ワンダーホイールで落ちる....

# チラシの裏

2009年6月9日火曜日

quagga on lxc

T/O debian/lenny amd64 でやってみました。こちらにイメージ? 置いときます。/opt/lxc 配下に展開仮定なので fstab を適宜直して使ってやって下さい。# レイノゴトクルートデ....
# seq とゆーもの覚えた。
# for i in `seq 0 7`; do
> br=br${i}
> brctl addbr $br
> brctl setfd $br 0
> brctl stp $br off
> ip link set $br up
> done

# ip link ls | grep "br[0-7]"
630: br0: mtu 1500 qdisc noqueue state UNKNOWN
631: br1: mtu 1500 qdisc noqueue state UNKNOWN
632: br2: mtu 1500 qdisc noqueue state UNKNOWN
633: br3: mtu 1500 qdisc noqueue state UNKNOWN
634: br4: mtu 1500 qdisc noqueue state UNKNOWN
635: br5: mtu 1500 qdisc noqueue state UNKNOWN
636: br6: mtu 1500 qdisc noqueue state UNKNOWN
637: br7: mtu 1500 qdisc noqueue state UNKNOWN
# ip addr add 192.168.200.1/24 dev br0
# pwd
/opt/lxc/quagga
# lxc-execute -n quagga -f lxc-quagga.conf -- /etc/init.d/quagga start &
[1] 5417
# Loading capability module if not yet done.
Starting Quagga daemons (prio:10): zebra ospfd ospf6d.

#
で稼働。起動の仕方がイマイチの気もするけど、まぁ。zebra と ospfd、 ospf6d が起動しているハズです。ホスト側のアドレスはこんな感じ。
# ip addr ls | egrep "(^[0-9]|inet )"
1: lo: mtu 16436 qdisc noqueue state UNKNOWN
inet 127.0.0.1/8 scope host lo
2: eth0: mtu 1500 qdisc pfifo_fast state UP qlen 1000
3: sit0: mtu 1480 qdisc noop state DOWN
4: ip6tnl0: mtu 1460 qdisc noop state DOWN
5: wmaster0: <> mtu 0 qdisc noop state DOWN qlen 1000
6: wlan0: mtu 1500 qdisc noop state DOWN qlen 1000
7: vlan10@eth0: mtu 1500 qdisc noqueue state UP
inet 172.27.129.2/24 brd 172.27.129.255 scope global vlan10
8: vlan11@eth0: mtu 1500 qdisc noqueue state UP
inet 192.168.1.3/24 brd 192.168.1.255 scope global vlan11
630: br0: mtu 1500 qdisc noqueue state UNKNOWN
inet 192.168.200.1/24 scope global br0
631: br1: mtu 1500 qdisc noqueue state UNKNOWN
632: br2: mtu 1500 qdisc noqueue state UNKNOWN
....
やっぱりホスト側でも ospfd 動いているので、寂しい経路数ですが....
# telnet 192.168.200.10 zebra
Trying 192.168.200.10...
Connected to 192.168.200.10.
Escape character is '^]'.

Hello, this is Quagga (version 0.99.10).
Copyright 1996-2005 Kunihiro Ishiguro, et al.


User Access Verification

Password:
zebra@quagga> en
Password:
zebra@quagga# show ip route
Codes: K - kernel route, C - connected, S - static, R - RIP, O - OSPF,
I - ISIS, B - BGP, > - selected route, * - FIB route

C>* 127.0.0.0/8 is directly connected, lo
C>* 192.168.200.0/24 is directly connected, eth0
C>* 192.168.201.0/24 is directly connected, eth1
C>* 192.168.202.0/24 is directly connected, eth2
C>* 192.168.203.0/24 is directly connected, eth3
C>* 192.168.204.0/24 is directly connected, eth4
C>* 192.168.205.0/24 is directly connected, eth5
C>* 192.168.206.0/24 is directly connected, eth6
C>* 192.168.207.0/24 is directly connected, eth7
zebra@quagga#
申し遅れましたが、パスワードは共に zebra です。
# telnet 192.168.200.10 ospfd
Trying 192.168.200.10...
Connected to 192.168.200.10.
Escape character is '^]'.

Hello, this is Quagga (version 0.99.10).
Copyright 1996-2005 Kunihiro Ishiguro, et al.


User Access Verification

Password:
ospfd@quagga> en
Password:
ospfd@quagga# conf t
ospfd@quagga(config)# router ospf
ospfd@quagga(config-router)# network 192.168.200.0/24 area 0.0.0.128
ospfd@quagga(config-router)#
で再度 zebra に
# telnet 192.168.200.10 zebra
Trying 192.168.200.10...
Connected to 192.168.200.10.
Escape character is '^]'.

Hello, this is Quagga (version 0.99.10).
Copyright 1996-2005 Kunihiro Ishiguro, et al.


User Access Verification

Password:
zebra@quagga> en
Password:
zebra@quagga# show ip route
Codes: K - kernel route, C - connected, S - static, R - RIP, O - OSPF,
I - ISIS, B - BGP, > - selected route, * - FIB route

C>* 127.0.0.0/8 is directly connected, lo
O>* 172.27.1.0/24 [110/40] via 192.168.200.1, eth0, 00:00:58
O>* 172.27.68.0/24 [110/40] via 192.168.200.1, eth0, 00:00:58
O>* 172.27.129.0/24 [110/20] via 192.168.200.1, eth0, 00:00:59
O>* 172.27.193.0/24 [110/30] via 192.168.200.1, eth0, 00:00:59
O 192.168.200.0/24 [110/10] is directly connected, eth0, 00:00:59
C>* 192.168.200.0/24 is directly connected, eth0
C>* 192.168.201.0/24 is directly connected, eth1
C>* 192.168.202.0/24 is directly connected, eth2
C>* 192.168.203.0/24 is directly connected, eth3
C>* 192.168.204.0/24 is directly connected, eth4
C>* 192.168.205.0/24 is directly connected, eth5
C>* 192.168.206.0/24 is directly connected, eth6
C>* 192.168.207.0/24 is directly connected, eth7
をぉ....後片付けは
# lxc-stop -n quagga
#
[1]+ Exit 137 lxc-execute -n quagga -f lxc-quagga.conf -- /etc/init.d/quagga start
# lxc-destroy -n quagga
最近のものを git で持ってこないと、後が何かおかしくなるコトあり。

# 沢山稼働させる場合は、きちんと絵を描いてから。って自分に言いきかせる。