请教个在 OP 里链路聚合网速不升反降的问题

2022-09-06 09:51:04 +08:00
 flowdesign

原始参考贴 https://s.v2ex.com/t/822174

上海电信, 没有在局端开桥接, 自己买了华为的 HN8546Q, 刷回原版固件并补全了 shell, 改成 epon 模式, 光猫端没有做太多的额外设置, 开了 vlan51/85 来实现 IPTV 盒子的使用

光猫后面用软路由桥接拨号, PVE 宿主+OP 虚拟机, 直通三个网口给了 OP, 没有做 bond 之前单独用 wan1 或者 wan2 拨号测速都是在 900M 上下的速度浮动, 但 bond 之后测速就会掉落到 700-800 之间, 多次测速都是同样的结果, 如果拔掉一根 wan 口的网线在 bond 模式下单线单拨, 速度和普通的单线单拨是基本一致的, 来来回回折腾了很久都没发现问题到底出在哪里, 还望各路神仙给帮忙答疑解惑一下

PS.1 rc.local 我是这么写的

modprobe bonding mode=0 miimon=100

ip link delete bondwan

ip link add bondwan type bond mode 0

ip link set eth1 down

ip link set eth2 down

ip link set eth1 master bondwan

ip link set eth2 master bondwan

ip link set bondwan up

exit 0

PS.2 bonding 模式下拨号测速后用 ifconfig 看过 eth1 和 eth2 两个口的流量, 基本一致, 所以应该是按照正常的 bonding 模式在工作的

4504 次点击
所在节点    宽带症候群
37 条回复
yujincheng08
2022-09-07 15:46:20 +08:00
@flowdesign

> 光猫端没有做太多的额外设置

那你光猫设置聚合了吗?我没看你说设置了。
malash
2022-09-08 00:07:10 +08:00
着重看一下“二 /三层口配置”,我记得原厂固件默认没有勾选这几项,而运营商的固件都默认开启,是一个坑
flowdesign
2022-09-08 08:25:04 +08:00
@lcy630409 环路风暴没解决, 依然找不到原因, 逐渐陷入绝望中...
@malash 看了光猫设置, 二 /三层口配置都勾选了, 然后桥接 wan 口也没有绑定任何的 lan 口
@yujincheng08 光猫不需要对聚合做额外设置吧, 我也似乎没找到哪里有设置的

P.S V2 账号设置里的屏蔽搜索引擎并没有用嘛, 放狗搜 8546 聚合, 我的帖子都要上热搜了...
yujincheng08
2022-09-08 09:08:50 +08:00
@flowdesign 光猫需要设置聚合的,bond 0 聚合就是要求两端都配置 bond 不然会坏掉(看下面的 kernel 文档)。你的问题看起来就是光猫没设置 bond 。我估计是需要用 telnet 之类的设置 bond 。所谓网上说的支持 bond 我估计是自带的 kernel 支持,但是没有 web ui 。

https://www.kernel.org/doc/Documentation/networking/bonding.txt

The balance-rr, balance-xor and broadcast modes generally
require that the switch have the appropriate ports grouped together.
The nomenclature for such a group differs between switches, it may be
called an "etherchannel" (as in the Cisco example, above), a "trunk
group" or some other similar variation. For these modes, each switch
will also have its own configuration options for the switch's transmit
policy to the bond. Typical choices include XOR of either the MAC or
IP addresses. The transmit policy of the two peers does not need to
match. For these three modes, the bonding mode really selects a
transmit policy for an EtherChannel group; all three will interoperate
with another EtherChannel group.
flowdesign
2022-09-08 09:43:37 +08:00
@yujincheng08 刚刚又搜了一大圈, 看到一个帖子提到华为光猫固件没有对应的 bonding 内核的问题 <https://www.right.com.cn/forum/thread-4036246-1-1.html> , 今天回去继续研究一下看看, 如果真的是固件没有内核的话, 我要么放弃 bonding, 要么换光猫了
malash
2022-09-08 11:07:09 +08:00
Q 结尾的光猫内核里是不需要 bonding 支持的,这几款的交换芯片本身就支持链路聚合,因此无需额外配置就能直接使用,参见 https://www.v2ex.com/t/822174#r_11177803

相反,OpenWRT 需要内核开启 bonding 以支持链路聚合,原理上使用的是“软”聚合。

你可以在 OpenWRT 上跑一下 dmesg | grep bond 和 cat /etc/config/network 然后贴一下结果看看吗?(后者注意隐藏 PPPOE 账号密码等信息)
yujincheng08
2022-09-08 11:09:03 +08:00
@flowdesign 真的想 bond 可以尝试用 mode6 ,这不需要对端支持。
swiftg
2022-09-08 14:57:17 +08:00
HN8546Q 聚合成功,登陆光猫看了的,没有 bonding.ko
flowdesign
2022-09-08 18:53:41 +08:00
@malash
dmesg | grep bond 的结果如下
[ 18.382320] 8021q: adding VLAN 0 to HW filter on device bondwan
[ 18.384502] br-IPTV51: port 4(bondwan.51) entered blocking state
[ 18.385421] br-IPTV51: port 4(bondwan.51) entered disabled state
[ 18.386689] device bondwan.51 entered promiscuous mode
[ 18.387423] device bondwan entered promiscuous mode
[ 18.438353] br-IPTV85: port 4(bondwan.85) entered blocking state
[ 18.439293] br-IPTV85: port 4(bondwan.85) entered disabled state
[ 18.440374] device bondwan.85 entered promiscuous mode
[ 18.572613] bondwan: (slave eth1): Enslaving as an active interface with an u p link
[ 18.573799] IPv6: ADDRCONF(NETDEV_CHANGE): bondwan: link becomes ready
[ 18.574914] br-IPTV51: port 4(bondwan.51) entered blocking state
[ 18.575883] br-IPTV51: port 4(bondwan.51) entered forwarding state
[ 18.579326] br-IPTV85: port 4(bondwan.85) entered blocking state
[ 18.580288] br-IPTV85: port 4(bondwan.85) entered forwarding state
[ 18.685858] bondwan: (slave eth2): Enslaving as an active interface with an u p link
[ 102.968787] device bondwan.51 left promiscuous mode
[ 102.969839] br-IPTV51: port 4(bondwan.51) entered disabled state
[ 103.020110] device bondwan.85 left promiscuous mode
[ 103.021104] device bondwan left promiscuous mode
[ 103.022287] br-IPTV85: port 4(bondwan.85) entered disabled state
[ 103.236200] 8021q: adding VLAN 0 to HW filter on device bondwan
[ 103.240105] br-IPTV51: port 4(bondwan.51) entered blocking state
[ 103.241799] br-IPTV51: port 4(bondwan.51) entered disabled state
[ 103.243575] device bondwan.51 entered promiscuous mode
[ 103.244972] device bondwan entered promiscuous mode
[ 103.246447] br-IPTV51: port 4(bondwan.51) entered blocking state

network config 是这样的

config interface 'loopback'
option ifname 'lo'
option proto 'static'
option ipaddr '127.0.0.1'
option netmask '255.0.0.0'

config globals 'globals'
option packet_steering '1'

config interface 'lan'
option type 'bridge'
option proto 'static'
option netmask '255.255.255.0'
option delegate '0'
option _orig_ifname 'eth0'
option _orig_bridge 'true'
option ifname 'eth0'
option ipaddr '192.168.1.111'

config interface 'vpn0'
option ifname 'tun0'
option proto 'none'

config interface 'docker'
option ifname 'docker0'
option proto 'none'
option auto '0'

config device
option type 'bridge'
option name 'docker0'

config interface 'ipsec_server'
option ifname 'ipsec0'
option device 'ipsec0'
option proto 'static'
option ipaddr '192.168.100.1'
option netmask '255.255.255.0'

config interface 'wan'
option proto 'pppoe'
option username '马赛克'
option password '马赛克'
option keepalive '5 5'
option mtu '1460'
option ipv6 '0'
option delegate '0'
option _orig_ifname 'bondwan'
option _orig_bridge 'false'
option metric '40'
option ifname 'bondwan'

config interface 'IPTV51'
option type 'bridge'
option proto 'none'
option ifname 'bondwan.51 eth0.51 eth1.51 eth2.51'
option auto '1'
option delegate '0'

config interface 'IPTV85'
option type 'bridge'
option proto 'none'
option ifname 'bondwan.85 eth0.85 eth1.85 eth2.85'
option auto '1'
option delegate '0'

有一些 OP 自己加的 IPSec, VPN 啥的接口, 我也懒得删就留着了, 主要用的就是 wan, lan, 外加为了 IPTV 加出来的一堆带 vlan tag 的接口, 反正我自己看 log 就是压根没看出什么不妥的地方... 我刚刚是重启了路由器以后重新加载 rc.local 增加的 bonding, 然后这个 bonding 拨号成功后我测速依然不出意料地只有 700 多 M, 再然后它就突然断线, 看了一眼 eth2 口不亮了, 我暂时没空研究, 拔掉网线现在暂时还有网络来回帖, 晚上不敢再折腾下去, 不然要被赶出家门


@swiftg 你这句话让我很伤心啊
swiftg
2022-09-08 20:01:48 +08:00
有可能是 mtu 的问题?我看你 pppoe 的 mtu 设置为 1460 ,我的是 1500 ,试着改下不同的值?

另外试试这个命令
iptables -t mangle -A FORWARD -p tcp --tcp-flags SYN,RST SYN -j TCPMSS --clamp-mss-to-pmtu

我以前有些 https 网站有问题,用这个命令解决的
malash
2022-09-08 23:43:30 +08:00
@flowdesign 我看了一下,感觉是有些问题。

首先 bonding 的配置你按照 3 楼说的来,不需要任何开机脚本,直接网页操作最简单。最终效果如下:

https://user-images.githubusercontent.com/1812118/189165482-057ef731-9b70-4c90-8ec2-bbaa375fc812.png
https://user-images.githubusercontent.com/1812118/189165611-6b3d57d8-6364-44e0-aa8f-b114acb13b96.png
https://user-images.githubusercontent.com/1812118/189165934-1e06d221-4e47-4f16-a6a2-79b3be11c417.png

然后你几个 IPTV 接口建议先删掉或者禁用,再或者只绑定一个 eth0.*。我也遇到了类似的的问题——链路聚合和 VLAN 不太兼容,因此对于需要 VLAN 的情况只能绑定原始的接口,用 bondwan.*大概是不生效的。

你配置里 option ifname 'bondwan.51 eth0.51 eth1.51 eth2.51' 显然是不对的,这样会把聚合和未聚合的给桥接在一起了,有可能是造成网络风暴的原因。
malash
2022-09-08 23:45:43 +08:00
这是我的 dmesg 输出,应该非常简洁的:

root@OpenWrt:~# dmesg | grep bond
[ 10.166536] bonding: bonding-bond is being created...
[ 10.199854] 8021q: adding VLAN 0 to HW filter on device bonding-bond
[ 11.296123] bonding-bond: (slave eth1): Enslaving as an active interface with an up link
[ 11.297601] IPv6: ADDRCONF(NETDEV_CHANGE): bonding-bond: link becomes ready
[ 12.386727] bonding-bond: (slave eth2): Enslaving as an active interface with an up link
malash
2022-09-08 23:51:35 +08:00
“HN8546Q 聚合成功,登陆光猫看了的,没有 bonding.ko”

不至于伤心啦,其实本质原因就是光猫走了硬交换,好处是性能比较好,坏处是支持的模式比较少,而且(猜测) VLAN 支持有问题。相反软路由这边走的都是软交换,对 CPU 占用会大一些。

忘了问你用的什么路由器了,是 x86 还是硬路由刷的?硬路由可能会有 CPU 性能不够的问题,建议用 x86
ttvast
2022-09-09 18:17:46 +08:00
根据我多次测试下来的,找到了一个最稳妥的多端口方式就是 iptables 的-m statistic --mode nth
用光猫拨号,路由器多个 wan 口接光猫,然后每个 lan 口分配一个地址做 nat 的负载均衡。完全不需要光猫的支持。
flowdesign
2022-09-12 18:10:23 +08:00
@malash
dmesg | grep bond 的结果因为混杂了很多 vlan tag 的软件接口,去掉那些以后跟 wan 口有关的看起来正常
root@OpenWrt:~# dmesg | grep bond
[ 18.209568] 8021q: adding VLAN 0 to HW filter on device bondwan
[ 18.336374] bondwan: (slave eth1): Enslaving as an active interface with an up link
[ 18.340263] device bondwan entered promiscuous mode
[ 18.422994] bondwan: (slave eth2): Enslaving as an active interface with an up link
我的路由是 J4125 安装了 PVE 宿主,OP 是 PVE 里面的一个虚拟机,给分配了 2G 内存,日常负载我看过很低,测速的时候也就是不到 50%的 cpu 占用

回头再按你的建议把 vlan tag 去掉再看看,但是为了实现 IPTV 任意网口使用,还是要想个办法把 vlan51 、85 都加上的...
malash
2022-09-12 23:56:24 +08:00
@ttvast 有点意思,这样的话能实现单线程突破千兆吗?
ttvast
2022-09-14 13:00:58 +08:00
@malash 单线程肯定不行,不过有这必要吗?服务器端一般也不会让你单线程跑到千兆吧。

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/877986

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX