Linux CRDA(Central Regulatory Domain Agent)简介

本文介绍了中央监管域代理(CRDA)的作用,包括消除主机驱动中的冗余监管域代码、提供更新‘监管规则’的方法、增强不同无线设备的互操作性以及实现无线软件对于不同地理位置(国家)不同规则的无线设备的兼容性。文中还讨论了无线网络软件的具体实现,以及如何通过用户空间与内核空间进行交互来实现这一目标。
这是一篇介绍CRDA的原文,来自于http://lwn.net/Articles/271037/,这里简单介绍一下。 
     通过下面的文章,我们可以获知如下信息:
     1、CRDA作用:
          消除host driver中的冗余regulatory domain code;
          提供更新“regulatory rules”的方法或途径;
          加强不同无线设备的互操作性;
          实现无线软件对于不同地理位置(国家)不同规则的无线设备的兼容性。
    2、无线网络软件实现
          用户空间通过nl80211与内核空间regulatory domain交互;
          80211设备可以通过cfg80211向内核注册自己的硬件设备(性能)。

    更具体的信息请参考下面文章:
     I'd like to request for review and advice for the central regulatory
domain agent (CRDA) we have been working towards in the Linux 802.11
subsystem. I'm including linux-kernel in hopes of a wider review.
Particularly I'd like advice on the best path we can take for the
userspace agent which *could* eventually be required upon userspace,
meaning *most* distributions will package it if they want decent
regulatory 802.11 support. But first let me begin with a brief
overview of the concept of a CRDA, the case for it, and patches
submitted and reviewed so far.

* Central regulatory domain agents - a case for it

    Contrary to all other drivers in the different subsystems in the
kernel, 802.11 drivers have local regulatory laws to take into
consideration for operation. To this day, due mainly to certification
requirements, vendors have taken it upon themselves to make their
hardware adhere to all regulatory regions their devices will be sold
in. These requirements are now implemented in software on the host
driver or firmware of the device. The reason for this is to enable the
design of one 802.11 chipset with capabilities to operate in different
geographical regions to reduce the cost of manufacturing, bring down
the price of the products sold, and allow users to make use of their
802.11 devices in different countries they may go to. Another shift in
market trends we are seeing is that of vendors moving away from a
FullMAC [1] design model to a SoftMAC [2] design model for most their
802.11 chipsets; development-wise this means the drivers receive raw
802.11 frames instead of Ethernet frames and hence the need for
mac80211, which provides a driver API to such type of devices and
implements a basic STA MLME [3] in-kernel. Some SoftMAC devices also
require complete regulatory control within the host driver. Some of
these drivers end up implementing their own regulatory domain control
and data structures. Except for the vendor-specific components of the
code, usually frequency, power values and sometimes regulatory domain
values, all of this code can instead be centralized as part of he
802.11 subsystem and shared amongst all the 802.11 drivers. This code
sharing would provide a centralized regulatory domain control for
devices which require regulatory domain control on the host, and
additionally provide *enhanced effort* on our part in the operating
system for compliance to local regulatory laws for devices which may
have *out-of-date rules* or *buggy* regulatory domain control code.

     The above just addresses the present. What lies ahead for wireless
seems to be making wireless devices smarter, more interoperable, but
always compliant to local regulatory laws. Software Defined Radios
(SDRs) [4] are a breed of wireless devices which are under the horizon
and depending on the definition of an SDR used, can be considered to
already be used and sold in the 802.11 market. Regulatory laws on SDR
are relatively new and are still under review and vary depending upon
geographical region. For example, the "The Software Freedom Law Center
(SFLC) has examined the Federal Communication Commission's (FCC)
rules", which when into into effect on July 6, 2007, "governing
Software Defined Radio (SDR) devices and concluded that the rules do
not restrict the activities of independent developers and distributors
of Free and Open Source Software (FOSS) designed for use with SDR
devices." [5] It also found that the "FCC's SDR rules create an
opportunity for wireless hardware manufacturers, the FOSS community,
and the FCC to communicate openly and productively about the ability
of public disclosure and open standards to strengthen the security and
robustness of wireless devices." With this in mind I think it is
important to try to help the vendors achieve compliance with local
regulatory laws and still remain compliant by supporting FOSS. Its
arguable if this is possible or not, but let us please not get into
this now; what I believe is more important is that we pave the way for
the best technology possible for regulatory rules for 802.11 and also
SDRs. A strong CRDA goes hand-in-hand with advancing SDRs as the
attributes can be expanded as the technology does -- more modulations
supported, different bands added, and so forth. Additionally a
Frequency Broker [6] (note: this link is old and needs some updating
but has the general idea) can later be added to register frequencies,
power level, modulations which each wireless device present on a host
is using to help with interoperability.

    A CRDA together with a Frequency Broker can therefore eliminate
redundant regulatory domain code on host drivers, provide a convenient
mechanism to update regulatory rules, and enhance interoperability
between different type of wireless devices.

* Implementation of the CRDA

    I posted my first series on October of 2006 [7] however the first
series stuffed everything into the kernel, the data structures were
overly complex, and no solid integration with mac80211 (d80211 then)
was provided [8]. The second series, posted on September of 2007 [9],
still left everything in the kernel, was more simplified and had
integration with mac80211 and cfg80211, additionally zd1211rw was
ported to the new framework and tested. After some discussion one the
lists and IRC it was determined we should just move the database of
regulatory domains into userspace and have just one regulatory domain
defined in kernel space at a time. Userspace can then pass to kernel
space a regulatory domain via the new nl80211. 802.11 devices can then
register with cfg80211 its hardware capabilities and only allowed
"channels" will be enabled, all others will be disabled. We can keep
two standard regulatory domains in kernel space, however: a world
regulatory domain which is a common denominator of all regulatory law
-- its basically FCC with relaxed power requirements and no 5 GHz
communication -- and a debug regulatory domain which enables
everything.

    The regulatory domain used on the 802.11 subsystem will reflect the
user's latest selected preference if one is set (this will override
all settings), an 802.11 card's EEPROM reading, or country defined by
an 802.11d country information element broadcast by a local access
point (depending upon configuration and preferences).

* Request for advice:

     cfg80211 can take the "installed" regulatory domain and only enable
power settings / frequency settings dependent upon current defined
regulatory rules. But in order to install a regulatory domain into the
kernel we need userspace to upload it via nl80211. This is easily
accomplished once userspace has one defined via structures defined in
nl80211 for a regulatory domain. Regulatory domain rules vary,
however, and I expect users to contribute on expanding the rules to be
as accurate as possible. As such it *is* expected that as time goes by
userspace will have rules updated, attributes added (will go
hand-in-hand with nl80211 updates), or completely new regulatory
domains defined. We therefore need a way to keep a database of
regulatory domains, and a way to parse this database to finally hand
to the kernel the desired regulatory domain.

    My initial take on this was to use a berkely db or sqlite db for the
database and keep this local on hosts, however this would enforce
certain package requirements upon most installations and do not think
that's the best approach. Another approach is to keep the real
database only on some development machines and let people send updates
to it as well as view the database online. An output of the database
can then be dumped as a flat file to a host in some format. The
regulatory daemon would then parse this flat file and upon changes to
the file update its local database of regulatory domains. I'd like
feedback on suggestions for the file format used which would keep
distributions requirements at a minimal. If there is some extremely
light weight and acceptable database and database API most of us
wouldn't mind seeing on most installs please name them too (although I
don't think this is really a good idea).

    My preference is to keep the real database on a development box which
has some web interface which people can use to view. Ideally users can
then send updates to the database to provide updates to rules. The
database can then be dumped and an application used to generate some
flat file. Distributions can then pick this flat file up and propagate
it to users. A user's host would have the CRDA userspace daemon
running, and once a new file is downloaded the regulatory daemon is
informed about it. The reg daemon would then parse the flat file and
update its internal database and new regulatory rules would become
available to the kernel. What I am not sure on is the best format to
use for the flat file.

http://blog.youkuaiyun.com/hengkong_horse/article/details/8936566
### **问题分析:`regulatory.0: Process '/sbin/crda' failed with exit code 234`** 该错误通常出现在 Linux 系统中,当无线网卡(Wi-Fi)尝试加载 **无线监管域数据库(CRDA, Central Regulatory Domain Agent)** 时失败。`exit code 234` 表示 `crda` 进程因以下原因之一崩溃: 1. **监管域数据库缺失或损坏**:`/lib/crda/regulatory.db` 文件不存在或格式错误。 2. **权限问题**:`crda` 进程无权读取数据库文件。 3. **内核与 CRDA 版本不兼容**:内核模块(如 `cfg80211`)与 `crda` 版本不匹配。 4. **系统架构不匹配**:数据库文件可能针对错误架构(如 x86_64 vs ARM)。 --- ### **解决方案** #### **1. 检查并修复监管域数据库** - **确认数据库文件是否存在**: ```bash ls -l /lib/crda/regulatory.db ``` - 如果文件缺失,从同版本系统的 `/lib/crda/` 复制,或通过包管理器重新安装: ```bash sudo apt install --reinstall crda wireless-regdb # Debian/Ubuntu sudo dnf reinstall crda wireless-regdb # Fedora/RHEL ``` - **验证数据库完整性**: ```bash file /lib/crda/regulatory.db # 应显示 "SQLite 3.x database" ``` - 如果文件损坏,删除后重新安装: ```bash sudo rm /lib/crda/regulatory.db sudo apt install --reinstall wireless-regdb ``` #### **2. 检查权限问题** - **确保 `crda` 有权访问数据库**: ```bash sudo chmod 644 /lib/crda/regulatory.db sudo chown root:root /lib/crda/regulatory.db ``` - **检查 `crda` 的权限**: ```bash ls -l /sbin/crda # 应为 -rwxr-xr-x 1 root root ``` #### **3. 更新内核和 CRDA** - **升级内核和无线工具**: ```bash sudo apt update && sudo apt upgrade linux-image-generic crda wireless-regdb # Debian/Ubuntu sudo dnf update kernel crda wireless-regdb # Fedora/RHEL ``` - **重启系统**以加载新内核和模块。 #### **4. 手动指定监管域(临时解决)** - 如果问题仅影响特定区域,可通过 `iw` 命令手动设置: ```bash sudo iw reg set US # 例如设置为美国监管域 ``` - 永久生效需在 `/etc/default/crda` 中设置: ```bash echo "REGDOMAIN=US" | sudo tee /etc/default/crda ``` #### **5. 调试 CRDA 进程** - **手动运行 `crda` 测试**: ```bash sudo /sbin/crda # 应输出当前监管域信息 ``` - 如果报错,检查系统日志: ```bash journalctl -xe | grep crda ``` - **使用 `strace` 跟踪调用**: ```bash sudo strace -f /sbin/crda 2>&1 | grep -i "error\|fail" ``` --- ### **常见问题扩展** #### **1. 为什么 `crda` 需要监管域数据库?** - Linux 内核的无线驱动(如 `cfg80211`)依赖 `crda` 动态加载本地无线法规(如信道、功率限制),以避免违反当地法律。 #### **2. 如何确认当前监管域?** - 通过 `iw` 命令查看: ```bash iw reg get ``` - 输出示例: ```plaintext global country US: DFS-UNSET (2402 - 2472 @ 40), (N/A, 20), (N/A) ``` #### **3. 数据库文件路径可能有哪些?** - 常见路径: ```plaintext /lib/crda/regulatory.db # 主流发行版 /usr/lib/crda/regulatory.db # 旧版本 /usr/share/crda/regulatory.db # 某些定制系统 ``` #### **4. 如何重建监管域数据库?** - 从源码重建(需安装 `wireless-regdb` 源码包): ```bash git clone https://git.kernel.org/pub/scm/linux/kernel/git/sforshee/wireless-regdb.git cd wireless-regdb make sudo cp regulatory.db /lib/crda/ ``` #### **5. 虚拟化/容器环境中的问题** - 如果系统运行在虚拟机或容器中,可能缺少主机监管域信息: - 在宿主机上运行: ```bash sudo cp /lib/crda/regulatory.db /path/to/container/lib/crda/ ``` - 或为容器配置 `REGDOMAIN` 环境变量。 --- ### **最终建议** 1. **优先重新安装 `crda` 和 `wireless-regdb`**,覆盖可能损坏的文件。 2. **检查 `/etc/default/crda`** 是否配置了正确的 `REGDOMAIN`。 3. **升级内核和无线工具**,确保版本兼容性。 4. **手动设置监管域**(如 `iw reg set US`)作为临时解决方案。 如果问题仍未解决,建议: - 在 [Linux Wireless 邮件列表](https://linuxwireless.org/en/users/Documentation/MailingLists) 提交问题,附上: - `dmesg | grep -i wifi` 输出。 - `crda -v` 和 `iw --version` 版本信息。 - `strace /sbin/crda` 的完整错误日志。 ---
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值