我正在尝试为KVM来宾和主机系统之间的存储通信实现9000字节MTU.主机有一个桥接器(br1),其MTU为9000字节:
host# ip link show br1 8: br1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 9000 qdisc noqueue state UP link/ether fe:54:00:50:f3:55 brd ff:ff:ff:ff:ff:ff inet 172.16.64.1/24 brd 172.16.64.255 scope global br1 inet6 fe80::21b:21ff:fe0e:ee39/64 scope link valid_lft forever preferred_lft forever
客人有一个连接到此桥接器的接口,该接口还具有9000字节MTU:
guest# ip addr show eth2 4: eth2: <BROADCAST,LOWER_UP> mtu 9000 qdisc pfifo_fast state UP qlen 1000 link/ether 52:54:00:50:f3:55 brd ff:ff:ff:ff:ff:ff inet 172.16.64.10/24 brd 172.16.64.255 scope global eth2 inet6 fe80::5054:ff:fe50:f355/64 scope link valid_lft forever preferred_lft forever
我可以从主机ping到访客:
host# ping -c4 172.16.64.10 PING 172.16.64.10 (172.16.64.10) 56(84) bytes of data. 64 bytes from 172.16.64.10: icmp_seq=1 ttl=64 time=1.15 ms 64 bytes from 172.16.64.10: icmp_seq=2 ttl=64 time=0.558 ms 64 bytes from 172.16.64.10: icmp_seq=3 ttl=64 time=0.566 ms 64 bytes from 172.16.64.10: icmp_seq=4 ttl=64 time=0.631 ms --- 172.16.64.10 ping statistics --- 4 packets transmitted,4 received,0% packet loss,time 3000ms rtt min/avg/max/mdev = 0.558/0.727/1.153/0.247 ms
但是,如果我将ping数据包大小增加到超过1490字节,我就不再具有连接性:
host# ping -c4 -s 1491 172.16.64.10 PING 172.16.64.10 (172.16.64.10) 1491(1519) bytes of data. --- 172.16.64.10 ping statistics --- 4 packets transmitted,0 received,100% packet loss,time 3000ms
数据包跟踪显示这些数据包永远不会到达来宾.我读过的所有内容都表明Linux桥接接口和virtio网络驱动器都支持巨型帧,但这对我来说肯定是一个MTU问题.
我错过了一些非常明显的东西吗
更新
显示访客接口的主机端:
host# brctl show bridge name bridge id STP enabled interfaces br1 8000.fe540050f355 no vnet2 host# ip addr show vnet2 11: vnet2: <BROADCAST,LOWER_UP> mtu 9000 qdisc pfifo_fast master br1 state UNKNOWN qlen 500 link/ether fe:54:00:50:f3:55 brd ff:ff:ff:ff:ff:ff inet6 fe80::fc54:ff:fe50:f355/64 scope link valid_lft forever preferred_lft forever
解决方法
虽然这是一个MTU问题,但事实证明它与任何组件设备上的MTU设置无关.正如我在原始问题中所示,主机桥,主机tun接口和guest虚拟机接口都具有相同的MTU设置(9000字节).
实际问题是libvirt / kvm配置问题.默认情况下,libvirt不使用virtio设备.如果没有显式配置,您最终会使用RealTek RTL-8139 NIC.此虚拟NIC不支持巨型帧.
要使用virtio设备,您需要指定显式模型.使用virt-install时:
virt-install ... -w bridge=br1,model=virtio
或者在事实之后添加< model>标记到适当的< interface>域XML中的元素:
<interface type="bridge"> <model type="virtio"/> <source bridge="br1"/> <target dev="vnet2"/> </interface>
随着这种变化,一切都按预期工作.