企业🤖AI智能体构建引擎,智能编排和调试,一键部署,支持知识库和私有化部署方案 广告
# :-: Bond模式4协商不通排查过程 | 适用范围 | 适用版本 | 人员 | 发布时间 | 文档版本 |备注 | | --- | --- | --- | --- | --- |--- | | 服务器操作系统 | V10-SP1、V10-SP2 | 王国武 |2022.3.22| V1.0|发布| | 服务器操作系统 | V10-SP1、V10-SP2 | 张志勇 |2022.3.22| V1.1|模板调整| ### 经测试,该方案有效可行 ***** ## :-: 目录 1. 问题现象 2. 问题分析 3. 问题结论及解决方案 ***** ## 问题现象 Bond4模式协商不起来,配置好后网络不通 ## 问题分析 查看/proc/net/bonding/bond0 状态,发现协商不起来,抓包看发现只有交换机在发包,而我们的设备未发送LACPDU报文。 结合内核开源代码分析,ad_tx_machine函数无法工作,打印日志发现port->sm_tx_timer_counter=0; ![](https://img.kancloud.cn/65/4a/654a51de63678498e7aa60ed7e46f87b_553x425.png) 这个函数由于那个if条件不满足,进而导致一些变量无法初始化,从而无法正常工作。 分析sys_mac_addr赋值的地方,在配置bond params<ad_actor_sys_prio>时,会调用bond_3ad_update_ad_actor_settings函数更新该值。 接下来分析添加从接口的函数bond_enslave, ![](https://img.kancloud.cn/1d/4e/1d4e5da8c0c83cddb598fcfde97b326e_554x133.png) 首次添加从接口若MAC类型是RANDOM时,会更新成从接口的MAC地址。也就是说,如果这里更新了MAC地址,之前那个初始化函数(bond_3ad_initialize)就可以正常执行了。 那继续分析接口MAC地址的类型, ![](https://img.kancloud.cn/a7/d9/a7d91d9fcf3dc87d05c1d7a7d6a87bf9_554x87.png) 有如上四种,0是物理口的,这里不讨论。1是创建虚拟口时,若未指定mac则内核随机分配一个6Byte的MAC。2是bond口设置为从接口的MAC地址时,此时对于bond而言就是该类型。3是应用层调用了ioctl/netlink等API接口修改了接口MAC。而目前麒麟系统看cat /sys/class/net/bond0/addr_assign_type是3,说明有应用层修改了该MAC,后续分析是systemd-udev修改的,udev根据/etc/systemd/network,/usr/lib/systemd/network的link文件去配置mac的, ![](https://img.kancloud.cn/5b/6e/5b6efcecb1d820343adfb9846930adb8_553x235.png) MACAddressPolicy那个策略起了作用。 ## 问题结论及解决方案 基于上述分析,阻止udev去修改bond口的MAC就可以了,对应的team口也需要考虑到,现有方案如下 方案1:修改MACAddressPolicy = none ;华为openEuler用的该策略 方案2:添加优先级更高的link配置,针对bond、team特殊配置,如下 ### 01-bonding.link ``` # SPDX-License-Identifier: LGPL-2.1+ # # This file is part of systemd. # # systemd is free software; you can redistribute it and/or modify it # under the terms of the GNU Lesser General Public License as published by # the Free Software Foundation; either version 2.1 of the License, or # (at your option) any later version. [Link] NamePolicy=kernel database onboard slot path MACAddressPolicy=random [Match] Driver=bonding Type=bond ``` ### 02-team.link ``` # SPDX-License-Identifier: LGPL-2.1+ # # This file is part of systemd. # # systemd is free software; you can redistribute it and/or modify it # under the terms of the GNU Lesser General Public License as published by # the Free Software Foundation; either version 2.1 of the License, or # (at your option) any later version. [Link] NamePolicy=kernel database onboard slot path MACAddressPolicy=random [Match] Driver=team ```