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"之间存在几秒钟的延迟是预期行为。

相关推荐
云飞云共享云桌面9 分钟前
钣金精密机械工厂:多工程师共享图形服务器,SolidWorks/UG 三维设计兼顾成本与数据安全
运维·服务器·人工智能·自动化·制造
有味道的男人23 分钟前
搜好货平台关键词商品搜索接口:分页容错与商品数据轻量化提取方案
服务器·前端·javascript
别动我齐刘海36 分钟前
实时控制学习2
linux·c++·人工智能·学习·算法
行者-全栈开发41 分钟前
【容器/虚拟化】CVE-2026-53359:Linux KVM Januscape 虚拟机逃逸漏洞修复指南(潜伏16年的云安全噩梦)
linux·运维·服务器·多租户隔离·cve-2026-53359·kvm虚拟机逃逸·shadow mmu
专注学习41 分钟前
《深入理解Linux进程与内存》第 3 章 · 进程与线程的对比 · 重点总结
linux
杂家1 小时前
ubuntu使用指南
linux
GIFT1681 小时前
进程优先级
linux
虎头金猫1 小时前
从上传PPT到观众远程打开互动页面:Claper在CentOS 7上的Docker部署、互动组件设置与固定访问地址实战
linux·运维·网络·人工智能·docker·centos·powerpoint
用户766743934541 小时前
云服务器上线前,我必做的 5 项安全检查
linux
AI备忘录2 小时前
(二十五)华为华三锐捷迈普思科 ERPS 环网保护配置命令(G.8032 五厂商对照)
运维·服务器·网络·网络协议·华为