2009年5月6日水曜日

ralink USB で hostapd

どこで何を調べていたか定かではないけど hostapd での nl80211 ドライバはつい最近、2.6.30 からだよ。といった ML のアーカイブを見かけた... はさて置き。

ralink 謹製のドライバが、この辺り にあるので ``RT2501USB(RT73:RT2571W/RT2573/RT2671)'' を持ってきて眺めてみた。が、送信については ACK のチェックは無いようで、USB - urb? のステータスがエラーで無ければ送信 OK というスタンス。一方 linux では SUCCESS は送信フレームの ACK が返ってきたときだけ。と厳しいためrt2x00usb.c にてエラーだったら FAILURE。それ以外はエラーじゃないけど ACK が確認できないので UNKNOWN。この UNKNOWN が enum mac80211_tx_control_flags::include/net/mac80211.h の IEEE80211_TX_STAT_ACK か否か。で否との結果送信できなかったぁ。で動かない。

ralink で OK。に従うならば TXDONE_UNKNOWN を TXDONE_SUCCESS にするのもアリかと。

tcpdump で wlan - 復習

にっ、二年前ですか。こんなことちょっと調べた後も進歩なし。もう一度 MAC フレームの先頭、フレームコントロールフィールドについて。tcpdump でフィルタする時には wlan[0] あるいは wlan[1] で指定。
wlan[0]
  • sub type: 4bit
  • type: 2bit
  • version: 2bit

  • wlan[1]: すべて 1bit
  • ToDS
  • FromDS
  • MoreFragment
  • Retry
  • PowerManagement
  • MoreData
  • WEP
  • Order
  • 先日の tcpdump-workers へのリンクが切れていたので、こちら参照しつつ、バージョンは 0。管理フレームの type は 0。subtype は
    • 0000 association request
    • 0001 association response
    • 0010 reassociation request
    • 0011 reassociation response
    • 0100 probe request
    • 0101 probe response
    • 1000 beacon
    • 1010 deassociation
    • 1011 authentication
    • 1100 deauthentication
    を踏まえるとビーコンフレームは
    # iw dev wlan0 interface add mon0 type monitor flags none
    # ip link set mon0 up
    # ip link ls
    5: mon0: mtu 1500 qdisc pfifo_fast state UNKNOWN qlen 1000
    link/ieee802.11/radiotap xx:xx:xx:xx:xx:xx brd ff:ff:ff:ff:ff:ff
    # tcpdump -ntvvi mon0 '(wlan[0] & 0xff) == 0x80'
    tcpdump: WARNING: mon0: no IPv4 address assigned
    tcpdump: listening on mon0, link-type IEEE802_11_RADIO (802.11 plus BSD radio information header), capture size 96 bytes
    157275684377us tsft 1.0 Mb/s 2472 MHz (0x00a0) -33dB signal antenna 1 [0x0000000e] 0us Beacon (foobar) [1.0* 2.0* 5.5* 11.0* 6.0 9.0 12.0 18.0 Mbit] ESS, PRIVACY
    157275945495us tsft 1.0 Mb/s 2472 MHz (0x00a0) -34dB signal antenna 1 [0x0000000e] 0us Beacon (foobar) [1.0* 2.0* 5.5* 11.0* 6.0 9.0 12.0 18.0 Mbit] ESS, PRIVACY
    ....
    radiotap でも wlan[] 指定は OK。も一つ良くリンク忘れるので備忘録
    IEEE 802.11-2007 IEEE Standard for Information technology-Telecommunications and information exchange between systems-Local and metropolitan area networks-Specific requirements - Part 11: Wireless LAN Medium Access Control (MAC) and Physical Layer (PHY) Specifications

    2009年4月20日月曜日

    USB デバイスで hostapd

    # 半年以上放置....

    2.6.29 から AP モードサポートっ! で試してみた。こちら参照すると ralink の USB デバイスが OK とのことで
    $ lsusb
    Bus 001 Device 002: ID 0411:00d8 MelCo., Inc. WLI-U2-SG54HP

    で挑戦するも今一つと言うか、中途ハンパな状態だけど、チラシのウラ。強い電波で ARP ごにょごにょだったら Linux。なんて言わせないぜっ。か定かではないけど、こちら
    • git://git.kernel.org/pub/scm/linux/kernel/git/mcgrof/crda.git
    • git://git.kernel.org/pub/scm/linux/kernel/git/linville/wireless-regdb.git
    持って来る。debian であれば 85-regulatory.rules は /etc/udev/rules.d の下。libnl や python-crypto もパッケージそのままで OK。hostapd も
    • git://w1.fi/srv/git/hostap.git
    で、長くなるけど設定はこんな感じ
    interface=wlan0
    driver=nl80211
    logger_syslog=-1
    logger_syslog_level=4
    logger_stdout=-1
    logger_stdout_level=0
    dump_file=/tmp/hostapd.dump
    ctrl_interface=/var/run/hostapd
    ctrl_interface_group=0
    ssid=foobar
    country_code=JP
    ieee80211d=1
    hw_mode=g
    channel=2
    beacon_int=256
    dtim_period=2
    max_num_sta=255
    macaddr_acl=0
    accept_mac_file=/etc/hostapd/mac.accept
    deny_mac_file=/etc/hostapd/mac.deny
    auth_algs=1
    ieee8021x=1
    eapol_version=2
    own_ip_addr=192.168.1.1
    wpa=3
    wpa_passphrase=tetest1234
    wpa_key_mgmt=WPA-PSK
    wpa_pairwise=CCMP TKIP
    wpa_group_rekey=600
    wpa_strict_rekey=1
    wpa_gmk_rekey=86400
    wpa_ptk_rekey=600
    # とてつもなく適当
    で動かん...こちら が未解決の模様。

    rt2x00usb_interrupt_txdone()::drivers/net/wireless/rt2x00/rt2x00usb.c のコメントそのままに、失敗した訳では無いが、成功 (ACK を受信した) 訳でも無いと。曰く hostapd の不備との話を踏まえて、hostapd 側で IEEE80211_RADIOTAP_F_TX_FAIL のチェックを無効にしたら、動くコトは動いたが、むーん。レートが 1M から上がらん。

    で、結局は先の未解決のすったもんだ、そのままに TXDONE_UNKNOWN を TXDONE_SUCCESS にして自宅内運用中。iPhone でひっかかるような感じになることあるけど、まぁ。ralink の USB デバイスは全て (と言っても別系は 2.6.29 では rt2500usb のみ) ブチ当ってしまう模様。

    2.6.30 以降の ar9170 か rt3070 に期待するしか無いのかなぁ....

    2008年11月11日火曜日

    LIBPCAP 1.0.0

    10月 27日リリース
    PACKET_MMAPにも対応。v2 確認未。
    ダーティハックで debian lenny パッケージ作るためのパッチ
    忙しすぎ。むーん....

    2008年9月3日水曜日

    PF_PACKET での vlan_tci - 気になるトコロ

    間違い。
    > skb->vlan_tci を設定する __vlan_hwaccel_rx() を呼んでいるのは
    じゃなくて、__vlan_hwaccel_rx() を呼び出す netif_rx() や netif_receive_skb() の wrapper (とコメントに書いてある) の vlan_hwaccel_rx() や vlan_hwaccel_receive_skb() はいろんなドライバから呼ばれてる。

    その他
    • (多分 NETIF_F_HW_VLAN_RX でないデバイスで使う)
      vlan_skb_recv()::net/8021q/vlan_dev.c で skb->vlan_tci をセットしてない

    • packet_sock.tp_reserve で確保する位置
      tpacket_rcv()::net/packet/af_packet.c の中
       } else {
      unsigned maclen = skb_network_offset(skb);
      netoff = TPACKET_ALIGN(po->tp_hdrlen +
      (maclen < 16 ? 16 : maclen)) +
      po->tp_reserve;
      macoff = netoff - maclen;
      }
      ....
      skb_copy_bits(skb, 0, h.raw + macoff, snaplen);
      ....
      case TPACKET_V2:
      h.h2->tp_len = skb->len;
      h.h2->tp_snaplen = snaplen;
      h.h2->tp_mac = macoff;
      h.h2->tp_net = netoff;
      mac より前に確保してる? できれば mac と net の間に VLAN オプションフィールド入れたいけど、すんごいツラいしそーゆー用途ではない? ユーザスペースで mac ヘッダ前にずらす?

    2008年9月1日月曜日

    Dell Studio で Linux

    8月上旬に Dell Studio 17 ノートパソコンなるものを購入。CPU が T9300 (2.5GHz) メモリが 4G という我が家一番の高スペックマシンとなった。お盆休みもあって Linux - debian/lenny 入れてみた。やっぱり? 無線 LAN と GPU で手間取ったので...この位なら切り貼りで良いや。とパッチなど。 CONFIG_DRM は組み込まないように。

    Dell Studio の Radeon HD3650

    ドライバはここ。カーネルモジュールはいらないかも。と思っていたが、スクロールが遅すぎ。で 2.6.27-rc でコンパイルするためのパッチは以下。GPL なモジュールしか呼び出せない __rcu_read_lock() などこちらを参照しつつ回避しているので注意。
    diff -ubBrN fglrx/Makefile fglrx-27/Makefile
    --- fglrx/Makefile 2008-08-24 08:47:58.000000000 +0900
    +++ fglrx-27/Makefile 2008-08-30 20:27:22.000000000 +0900
    @@ -2,6 +2,11 @@

    LIBIP_PREFIX ?= ..

    +RCU_READ_LOCK := $(shell grep "T __rcu_read_lock" $(SYSMAP) | colrm 9)
    +RCU_READ_UNLOCK := $(shell grep "T __rcu_read_unlock" $(SYSMAP) | colrm 9)
    +EXTRA_LDFLAGS := --defsym __rcu_read_lock=0x$(RCU_READ_LOCK) \
    + --defsym __rcu_read_unlock=0x$(RCU_READ_UNLOCK)
    +
    obj-m += fglrx.o
    fglrx-libs += libfglrx_ip.a.GCC$(GCC_VER_MAJ)
    fglrx-c-objs += firegl_public.o
    diff -ubBrN fglrx/firegl_public.c fglrx-27/firegl_public.c
    --- fglrx/firegl_public.c 2008-08-24 08:47:58.000000000 +0900
    +++ fglrx-27/firegl_public.c 2008-08-31 21:07:45.000000000 +0900
    @@ -3077,7 +3077,7 @@
    {
    #ifdef __SMP__
    /* write back invalidate all other CPUs (exported by kernel) */
    - if (smp_call_function(deferred_flush, NULL, 1, 0) != 0)
    + if (smp_call_function(deferred_flush, NULL, 0) != 0)
    panic("timed out waiting for the other CPUs!\n");

    /* invalidate this CPU */
    @@ -4796,7 +4796,7 @@
    void ATI_API_CALL KCL_CallFuncOnOtherCpus(firegl_void_routine_t func_to_call)
    {
    #ifdef CONFIG_SMP
    - smp_call_function( firegl_smp_func_parameter_wrap, (void*)func_to_call, 0, 1 );
    + smp_call_function( firegl_smp_func_parameter_wrap, (void*)func_to_call, 1 );
    #endif
    }

    @@ -4910,7 +4910,7 @@
    }

    #ifdef CONFIG_SMP
    - if (smp_call_function(KCL_setup_pat, NULL, 0, 1) != 0)
    + if (smp_call_function(KCL_setup_pat, NULL, 1) != 0)
    return 0;
    #endif
    KCL_setup_pat(NULL);
    @@ -4929,7 +4929,7 @@
    }

    #ifdef CONFIG_SMP
    - if (smp_call_function(KCL_restore_pat, NULL, 0, 1) != 0)
    + if (smp_call_function(KCL_restore_pat, NULL, 1) != 0)
    return;
    #endif
    KCL_restore_pat(NULL);
    コンパイルは
    make SYSMAP=/boot/System.map-2.6.27-rc5-git1 -C /usr/src/testing SUBDIRS=`pwd` clean
    make SYSMAP=/boot/System.map-2.6.27-rc5-git1 -C /usr/src/testing SUBDIRS=`pwd` modules
    で。SYSMAP に、そのまま... System.map を指定して。