TC 安装
此安装针对于嵌入式设备,即交叉编译。
由于 tc 属于 iproute2, 所以安装 tc 就是在安装 iproute2。
设置工作空间
# WORKSPACE就是当前目录(docs)的上一级目录
export WORKSPACE=$(pwd)
源码下载
# 为当前最新的版本(2021.8.26)
wget https://mirrors.edge.kernel.org/pub/linux/utils/net/iproute2/iproute2-5.9.0.tar.gz
tar zxvf iproute2-5.9.0.tar.gz
rm iproute2-5.9.0.tar.gz
源码编译
修改 configure
# 为了保留最原始的一份 configure, 我将其备份为 configure_bak
cp "${WORKSPACE}"/iproute2-5.9.0/configure "${WORKSPACE}"/iproute2-5.9.0/configure_bak
此处保留备份是为了留下修改的证据,即修改的合理性,
通过观察 configure_bak 你就能发现 GNU 设置的
configure 是针对于你宿主机的配置,而非目标机
修改 mnl
修改 elf
修改 SELinux
修改 toolchain
可以观察以下修改的地方,都是合理的,不如说是 GNU 设计的
configure 设计得不合理(iproute2的源码由GNU内核团队维护)
编译
cd $WORKSPACE
cd iproute2-5.9.0/
mkdir install_dir
修改Makefiles
make
make install
检查
至此 tc 已经安装成功,或者说 iproute2 已经安装成功了。
我们使用一些简单的命令来检验一下。
使用 file
cd "${WORKSPACE}"
cd ./iproute2-5.9.0/install_dir/usr/sbin/
file ./tc
你应该看到了以下结果:
tc: ELF 32-bit LSB executable, ARM, EABI5 version 1 (SYSV), dynamically linked, interpreter /lib/ld-linux.so.3, for GNU/Linux 2.6.32, with debug_info, not stripped
使用 nfs
目标机运行
如果上面两个测试都能够运行成功,则代表 tc 已经安装成功。