Hostapd no IRで5GHzが使えないときの対処法(ドライバ改造)
環境
OS : Ubuntu Server 20.04
カーネル : 5.4.0-70-generic
WLANカード : Killer 1535 (Qualcomm QCA6174A)
athドライバ使うAtherosのカードならおそらくこの方法で解決できると思います。
intel製のカードの場合の対処法は探しても見つかりませんでした…
Hostapdで5GHzが使えない!
hostapdで5GHzなAPを建てようとしても、変なエラー出て失敗します。
hostapd[11500]: wlp3s0: IEEE 802.11 Configured channel (36) not found from the channel list of current mode (2) IEEE 802.11a
hostapd[11500]: wlp3s0: IEEE 802.11 Hardware does not support configured channel
systemd[1]: Failed to start Advanced IEEE 802.11 AP and IEEE 802.1X/WPA/WPA2/EAP Authenticator.
電波の地域制限らしいので、現在の状態を見てみます。
$ iw list
Band 2:
Frequencies:
* 5180 MHz [36] (20.0 dBm) (no IR)
* 5200 MHz [40] (20.0 dBm) (no IR)
* 5220 MHz [44] (20.0 dBm) (no IR)
* 5240 MHz [48] (20.0 dBm) (no IR)
* 5260 MHz [52] (20.0 dBm) (no IR, radar detection)
* 5280 MHz [56] (20.0 dBm) (no IR, radar detection)
* 5300 MHz [60] (20.0 dBm) (no IR, radar detection)
* 5320 MHz [64] (20.0 dBm) (no IR, radar detection)
* 5500 MHz [100] (20.0 dBm) (no IR, radar detection)
* 5520 MHz [104] (20.0 dBm) (no IR, radar detection)
* 5540 MHz [108] (20.0 dBm) (no IR, radar detection)
* 5560 MHz [112] (20.0 dBm) (no IR, radar detection)
* 5580 MHz [116] (20.0 dBm) (no IR, radar detection)
* 5600 MHz [120] (20.0 dBm) (no IR, radar detection)
* 5620 MHz [124] (20.0 dBm) (no IR, radar detection)
* 5640 MHz [128] (20.0 dBm) (no IR, radar detection)
* 5660 MHz [132] (20.0 dBm) (no IR, radar detection)
* 5680 MHz [136] (20.0 dBm) (no IR, radar detection)
* 5700 MHz [140] (20.0 dBm) (no IR, radar detection)
* 5720 MHz [144] (20.0 dBm) (no IR, radar detection)
* 5745 MHz [149] (20.0 dBm) (no IR)
* 5765 MHz [153] (20.0 dBm) (no IR)
* 5785 MHz [157] (20.0 dBm) (no IR)
* 5805 MHz [161] (20.0 dBm) (no IR)
* 5825 MHz [165] (20.0 dBm) (no IR)
* 5845 MHz [169] (disabled)
* 5845 MHz [173] (disabled)
no IR と出てるので、やっぱり地域制限が有効になっているようです。
地域を日本にセット
$ sudo iw reg set JP
しかし、相変わらずすべてのチャンネルにno IRが表示されて使えません。
そこで、こちらを参考にドライバを改造して地域制限を無効化してみることにしました。
ドライバ改造
まずカーネル全体をコンパイルし、athドライバの部分のソースを修正した後リコンパイルしてできたドライバ(ath.ko)を置き換えるといった手順です。
上の環境でコンパイルしたものを載せておきます。
こちらからどうぞ。
自分でやる方は以下の手順を参考にしてください。
カーネルをコンパイル
別のマシンでコンパイルするときは、’uname -r’を使うマシンのカーネルバージョンに変えて実行し、configファイルも使うマシンからコピーしてきてください。
コンパイルに必要なもの
$ sudo sed -i 's/# deb-src/deb-src/' /etc/apt/sources.list
$ sudo apt update
$ sudo apt build-dep -y linux
$ sudo apt install libncurses-dev gawk flex bison openssl libssl-dev dkms libelf-dev libudev-dev libpci-dev libiberty-dev autoconf git fakeroot
カーネルをダウンロード(結構でかい)
$ git clone git://kernel.ubuntu.com/ubuntu/ubuntu-focal.git
$ cd ubuntu-focal
configをコピー
$ cp /boot/config-`uname -r` .config
コンパイル
12の部分は平行処理数です。CPUのスレッド数を指定すればいいと思います。低スぺなので結構時間かかりました。
$ fakeroot debian/rules clean
$ make KERNELVERSION=`uname -r` -j 12 modules
カーネル修正
変数宣言の直後にreturn;を追加し、最後の関数にはreturn 0;を追加します。
__ath_reg_apply_beaconing_flags()のように似た名前の関数がありますが、こちらは編集してはいけないようです。
$ nano drivers/net/wireless/ath/regd.c
static void
ath_reg_apply_beaconing_flags(struct wiphy *wiphy,
struct ath_regulatory *reg,
enum nl80211_reg_initiator initiator)
{
enum nl80211_band band;
struct ieee80211_supported_band *sband;
struct ieee80211_channel *ch;
unsigned int i;
return; #追加
for (band = 0; band < NUM_NL80211_BANDS; band++) {
if (!wiphy->bands[band])
continue;
sband = wiphy->bands[band];
for (i = 0; i < sband->n_channels; i++) {
ch = &sband->channels[i];
__ath_reg_apply_beaconing_flags(wiphy, reg,
initiator, ch);
}
}
}
static void
ath_reg_apply_ir_flags(struct wiphy *wiphy,
struct ath_regulatory *reg,
enum nl80211_reg_initiator initiator)
{
struct ieee80211_supported_band *sband;
return; #追加
sband = wiphy->bands[NL80211_BAND_2GHZ];
if (!sband)
return;
static void ath_reg_apply_radar_flags(struct wiphy *wiphy)
{
struct ieee80211_supported_band *sband;
struct ieee80211_channel *ch;
unsigned int i;
return; #追加
if (!wiphy->bands[NL80211_BAND_5GHZ])
return;
sband = wiphy->bands[NL80211_BAND_5GHZ];
static int
ath_regd_init_wiphy(struct ath_regulatory *reg,
struct wiphy *wiphy,
void (*reg_notifier)(struct wiphy *wiphy,
struct regulatory_request *request))
{
const struct ieee80211_regdomain *regd;
wiphy->reg_notifier = reg_notifier;
return 0; #追加
wiphy->regulatory_flags |= REGULATORY_STRICT_REG |
REGULATORY_CUSTOM_REG;
if (ath_is_world_regd(reg)) {
リコンパイル
$ make KERNELVERSION=`uname -r` -j 12 modules
置き換え
出来上がったドライバを今使ってるものから置き換えたら終わりです。
$ sudo mv /lib/modules/`uname -r`/kernel/drivers/net/wireless/ath/ath.ko /lib/modules/`uname -r`/kernel/drivers/net/wireless/ath/ath.ko.old
$ sudo cp drivers/net/wireless/ath/ath.ko /lib/modules/`uname -r`/kernel/drivers/net/wireless/ath
コピーしたら再起動してください。
5GHz出せるか確認
USにセットしてみました。
$ sudo iw reg set US
$ iw list
Frequencies:
* 5180 MHz [36] (23.0 dBm)
* 5200 MHz [40] (23.0 dBm)
* 5220 MHz [44] (23.0 dBm)
* 5240 MHz [48] (23.0 dBm)
* 5260 MHz [52] (23.0 dBm) (radar detection)
* 5280 MHz [56] (23.0 dBm) (radar detection)
* 5300 MHz [60] (23.0 dBm) (radar detection)
* 5320 MHz [64] (23.0 dBm) (radar detection)
* 5500 MHz [100] (23.0 dBm) (radar detection)
* 5520 MHz [104] (23.0 dBm) (radar detection)
* 5540 MHz [108] (23.0 dBm) (radar detection)
* 5560 MHz [112] (23.0 dBm) (radar detection)
* 5580 MHz [116] (23.0 dBm) (radar detection)
* 5600 MHz [120] (23.0 dBm) (radar detection)
* 5620 MHz [124] (23.0 dBm) (radar detection)
* 5640 MHz [128] (23.0 dBm) (radar detection)
* 5660 MHz [132] (23.0 dBm) (radar detection)
* 5680 MHz [136] (23.0 dBm) (radar detection)
* 5700 MHz [140] (23.0 dBm) (radar detection)
* 5720 MHz [144] (23.0 dBm) (radar detection)
* 5745 MHz [149] (30.0 dBm)
* 5765 MHz [153] (30.0 dBm)
* 5785 MHz [157] (30.0 dBm)
* 5805 MHz [161] (30.0 dBm)
* 5825 MHz [165] (30.0 dBm)
* 5845 MHz [169] (disabled)
* 5865 MHz [173] (disabled)
しっかりno IRが消えて5GHz使えるようになってます!やったね!
最近のコメント