Linux: network: 拔插网线 interface down/up测试的痛点

文章目录

测试的痛点

外企做测试的一个痛点是,设备不在国内,如果想做破坏性的测试,就需要让外国同事帮着做这种拔插网线类的操作。很麻烦,万一碰到问题,就要麻烦他来来回回的去实验室。外国人休假还那么长时间,一休休一个月。

网线虚插

最近做的这个操作,发现下面这样的日志,看着就有理由,猜想这个同事做的拔插网线有点问题。

c 复制代码
Oct  9 11:51:24 p-b kernel: [ 2381.633072] mlx5_core 0000:00:08.0: Port module event: module 1, Cable unplugged
Oct  9 11:51:25 p-b kernel: [ 2381.666406] mlx5_core 0000:00:08.0 pr1: Link down
Oct  9 11:51:34 p-b kernel: [ 2390.838359] mlx5_core 0000:00:08.0: Port module event: module 1, Cable plugged
Oct  9 11:51:34 p-b kernel: [ 2391.434150] mlx5_core 0000:00:08.0: Port module event: module 1, Cable unplugged
Oct  9 11:51:39 p-b kernel: [ 2396.388908] mlx5_core 0000:00:08.0: Port module event: module 1, Cable plugged
Oct  9 11:51:44 p-b kernel: [ 2401.082159] mlx5_core 0000:00:08.0: Port module event: module 1, Cable unplugged
Oct  9 11:51:49 p-b kernel: [ 2405.739985] mlx5_core 0000:00:08.0: Port module event: module 1, Cable plugged
Oct  9 11:51:50 p-b kernel: [ 2406.998658] mlx5_core 0000:00:08.0: Port module event: module 1, Cable unplugged
Oct  9 11:52:06 p-b kernel: [ 2422.691875] mlx5_core 0000:00:08.0: Port module event: module 1, Cable plugged
Oct  9 11:52:06 p-b kernel: [ 2422.725911] mlx5_core 0000:00:08.0: Port module event: module 1, Cable unplugged
Oct  9 11:52:10 p-b kernel: [ 2427.292388] mlx5_core 0000:00:08.0: Port module event: module 1, Cable plugged
Oct  9 11:52:12 p-b kernel: [ 2429.572874] mlx5_core 0000:00:08.0: Port module event: module 1, Cable unplugged
Oct  9 11:52:17 p-b kernel: [ 2434.343169] mlx5_core 0000:00:08.0: Port module event: module 1, Cable plugged
Oct  9 11:52:29 p-b kernel: [ 2446.635359] mlx5_core 0000:00:08.0 pr1: Link up
Oct  9 11:52:30 p-b kernel: [ 2446.673528] mlx5_core 0000:00:08.0 pr1: Link down
Oct  9 11:52:35 p-b kernel: [ 2452.381350] mlx5_core 0000:00:08.0: Port module event: module 1, Cable unplugged
Oct  9 11:52:39 p-b kernel: [ 2455.945684] mlx5_core 0000:00:08.0: Port module event: module 1, Cable plugged
Oct  9 11:52:42 p-b kernel: [ 2459.294453] mlx5_core 0000:00:08.0: Port module event: module 1, Cable unplugged
Oct  9 11:54:24 p-b kernel: [ 2561.557582] mlx5_core 0000:00:08.0: Port module event: module 1, Cable plugged
Oct  9 11:54:30 p-b kernel: [ 2567.188845] mlx5_core 0000:00:08.0 pr1: Link up
Oct  9 11:57:05 p-b kernel: [ 2721.922978] mlx5_core 0000:00:08.0: Port module event: module 1, Cable unplugged
Oct  9 11:57:05 p-b kernel: [ 2721.954832] mlx5_core 0000:00:08.0 pr1: Link down
Oct  9 11:57:08 p-b kernel: [ 2724.976145] mlx5_core 0000:00:08.0: Port module event: module 1, Cable plugged
Oct  9 11:57:15 p-b kernel: [ 2731.956035] mlx5_core 0000:00:08.0 pr1: Link up

从这个日志可以发现

频繁的拔插日志

这个的原因猜测是没有真正拔下来,而是网口处在一个虚插的状态。才导致频繁的unplugged/plugged。

从插入网线到link变成up的状态,需要~7秒的时间

从这里也可以看懂从插入网线到link变成up的状态,需要~7秒的时间。

这种延迟是正常的,主要原因包括:

物理层协商 (Physical Layer Negotiation):

自协商 (Auto-negotiation): 网卡和交换机端口需要协商最佳的连接速度(如1Gbps、10Gbps等)和双工模式(全双工)。这个过程需要交换数据包并达成一致。

链路训练 (Link Training): 对于高速网络接口(如10Gbps及以上),物理层需要进行更复杂的"链路训练"过程,以调整信号强度、均衡和时钟恢复,确保建立稳定的物理连接。这可能需要几秒钟。

模块初始化 (Module Initialization): 如果使用的是可插拔的光模块(如SFP/QSFP),模块本身需要时间上电、初始化并稳定工作,然后才能开始链路协商。日志中的"Port module event"表明涉及到了模块。

驱动程序处理 (Driver Processing): 网卡驱动程序在检测到物理连接后,还需要进行一些内部配置和初始化,才能将链路状态报告为"up"。

这些步骤都需要一定的时间来完成,因此从物理插入到逻辑链路"up"之间存在几秒钟的延迟是预期行为。

相关推荐
dllmayday43 分钟前
Linux 上用终端连接 WiFi
linux·服务器·windows
ACP广源盛139246256731 小时前
IX8024与科学大模型的碰撞@ACP#筑牢科研 AI 算力高速枢纽分享
运维·服务器·网络·数据库·人工智能·嵌入式硬件·电脑
测试员周周2 小时前
【AI测试系统】第5篇:从 Archon 看 AI 工程化落地:为什么"确定性编排+AI 弹性智能"是终局?
人工智能·python·测试
峥无2 小时前
Linux系统编程基石:静态库·动态库·ELF文件·进程地址空间全景图
linux·运维·服务器
用户2367829801682 小时前
从 chmod 755 说起:Unix 文件权限到底是怎么算的?
linux
Strugglingler2 小时前
【systemctl 学习总结】
linux·systemd·systemctl·journalctl·unit file
嵌入式×边缘AI:打怪升级日志4 小时前
100ASK-T113 Pro 开发板 Bootloader 完全开发指南
linux·ubuntu·bootloader
lzhdim4 小时前
SQL 入门 12:SQL 视图:创建、修改与可更新视图
java·大数据·服务器·数据库·sql
2401_873479404 小时前
断网时如何实时判断IP归属?嵌入本地离线库,保障风控不中断
运维·服务器·网络
charlie1145141915 小时前
Linux 字符设备驱动:cdev、设备号与设备模型
linux·开发语言·驱动开发·c