[root@server ~]# cat /etc/redhat-release
CentOS Linux release 7.5.1804 (Core)
[root@server ~]# uname -r
3.10.0-862.3.2.el7.x86_64
目次
1. ひとまずmakeしてみる
Realtekのダウンロードセンターから、『LINUX driver for kernel up to 4.7』ドライバをダウンロードし、/rootに配置する。[root@server ~]# tar vjxf 0010-r8168-8.045.08.tar.bz2 [root@server ~]# cd r8168-8.045.08/ [root@server r8168-8.045.08]# make (略) make[2]: ディレクトリ `/usr/src/kernels/3.10.0-862.3.2.el7.x86_64' に入ります CC [M] /root/r8168-8.045.08/src/r8168_n.o In file included from /root/r8168-8.045.08/src/r8168_n.c:80:0: /root/r8168-8.045.08/src/r8168.h:47:20: エラー: ‘ether_addr_copy’ が再定義されました static inline void ether_addr_copy(u8 *dst, const u8 *src) ^ In file included from /root/r8168-8.045.08/src/r8168_n.c:42:0: include/linux/etherdevice.h:241:20: 備考: 前の ‘ether_addr_copy’ の宣言はここです static inline void ether_addr_copy(u8 *dst, const u8 *src) ^ /root/r8168-8.045.08/src/r8168_n.c:24919:9: エラー: 初期化子内で不明なフィールド ‘ndo_change_mtu’ が指定されています .ndo_change_mtu = rtl8168_change_mtu, ^ /root/r8168-8.045.08/src/r8168_n.c:24919:9: 警告: 初期化子の周りに中括弧がありません [-Wmissing-braces] /root/r8168-8.045.08/src/r8168_n.c:24919:9: 警告: (‘rtl8168_netdev_ops.<無名>’ 用の初期化付近) [-Wmissing-braces] /root/r8168-8.045.08/src/r8168_n.c:24919:9: 警告: 互換性のないポインタ型からの初期化です [デフォルトで有効] /root/r8168-8.045.08/src/r8168_n.c:24919:9: 警告: (‘rtl8168_netdev_ops.<無名>.ndo_get_stats64’ 用の初期化付近) [デフォルトで有効] /root/r8168-8.045.08/src/r8168_n.c: 関数 ‘rtl8168_rx_interrupt’ 内: /root/r8168-8.045.08/src/r8168_n.c:27611:28: エラー: ‘struct net_device’ は ‘last_rx’ という名前のメンバを持っていません dev->last_rx = jiffies; ^ (略)
2. ソースを編集してコンパイル
[root@server r8168-8.045.08]# vi src/r8168.h 46行目 #if LINUX_VERSION_CODE < KERNEL_VERSION(3,14,0) ↓ #if LINUX_VERSION_CODE < KERNEL_VERSION(3,10,0) [root@server r8168-8.045.08]# vi src/r8168_n.c 27610~27612行目をコメントアウト #if LINUX_VERSION_CODE < KERNEL_VERSION(4,11,0) dev->last_rx = jiffies; #endif //LINUX_VERSION_CODE < KERNEL_VERSION(4,11,0) ↓ //#if LINUX_VERSION_CODE < KERNEL_VERSION(4,11,0) // dev->last_rx = jiffies; //#endif //LINUX_VERSION_CODE < KERNEL_VERSION(4,11,0) 24919行目 .ndo_change_mtu = rtl8168_change_mtu, ↓ .ndo_change_mtu_rh74 = rtl8168_change_mtu, [root@server r8168-8.045.08]# make (略) make[2]: ディレクトリ `/usr/src/kernels/3.10.0-862.3.2.el7.x86_64' に入ります CC [M] /root/r8168-8.045.08/src/r8168_n.o CC [M] /root/r8168-8.045.08/src/r8168_asf.o CC [M] /root/r8168-8.045.08/src/rtl_eeprom.o CC [M] /root/r8168-8.045.08/src/rtltool.o LD [M] /root/r8168-8.045.08/src/r8168.o Building modules, stage 2. MODPOST 1 modules CC /root/r8168-8.045.08/src/r8168.mod.o LD [M] /root/r8168-8.045.08/src/r8168.ko (略) [root@server r8168-8.045.08]# ethtool -i enp2s0 driver: r8169 version: 2.3LK-NAPI firmware-version: rtl8168h-2_0.0.2 02/26/15 expansion-rom-version: bus-info: 0000:02:00.0 supports-statistics: yes supports-test: no supports-eeprom-access: no supports-register-dump: yes supports-priv-flags: no [root@server r8168-8.045.08]# ./autorun.sh (SSHが切れるが、しばらくしたら再接続する) [root@server r8168-8.045.08]# ethtool -i enp2s0 driver: r8168 version: 8.045.08-NAPI firmware-version: expansion-rom-version: bus-info: 0000:02:00.0 supports-statistics: yes supports-test: no supports-eeprom-access: no supports-register-dump: yes supports-priv-flags: no
3. 初期RAMDISKの再作成
初期RAMDISKを新しくしておく。[root@server ~]# cd /boot/ [root@server boot]# mv initramfs-$(uname -r).img initramfs-$(uname -r).img.bak [root@server boot]# dracut /boot/initramfs-$(uname -r).img
4. 2018/8/29追記
Realtekに新しいバージョンが上がっていました。そのバージョンでも同じ手順でコンパイル出来ています。
[root@server ~]# ethtool -i enp2s0 driver: r8168 version: 8.046.00-NAPI firmware-version: expansion-rom-version: bus-info: 0000:02:00.0 supports-statistics: yes supports-test: no supports-eeprom-access: no supports-register-dump: yes supports-priv-flags: no [root@server ~]# cat /etc/redhat-release CentOS Linux release 7.5.1804 (Core) [root@server ~]# uname -r 3.10.0-862.11.6.el7.x86_64