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

相关推荐
尘似鹤14 小时前
linux驱动学习---有些节点不会生成platform_device,怎么访问它们
linux
iCxhust14 小时前
windows环境下在Bochs中运行Linux0.12系统
linux·运维·服务器·windows·minix
七七七七0718 小时前
【计算机网络】深入理解ARP协议:工作原理、报文格式与安全防护
linux·服务器·网络·计算机网络·安全
qq_54702617918 小时前
Flowable 工作流引擎
java·服务器·前端
奋斗的蛋黄19 小时前
网络卡顿运维排查方案:从客户端到服务器的全链路处理
运维·服务器·网络
wanhengidc20 小时前
云手机搬砖 尤弥尔传奇自动化操作
运维·服务器·arm开发·安全·智能手机·自动化
图图图图爱睡觉20 小时前
主机跟虚拟机ip一直Ping不通,并且虚拟机使用ifconfig命令时,ens33没有ipv4地址,只有ipv6地址
服务器·网络·tcp/ip
deephub21 小时前
FastMCP 入门:用 Python 快速搭建 MCP 服务器接入 LLM
服务器·人工智能·python·大语言模型·mcp
lhxcc_fly21 小时前
Linux网络--8、NAT,代理,网络穿透
linux·服务器·网络·nat
摇滚侠21 小时前
Spring Boot3零基础教程,Spring Boot 应用打包成 exe 可执行文件,笔记91 笔记92 笔记93
linux·spring boot·笔记