diff --git a/pkg/hostman/hostinfo/hostbridge/linux_bridge.go b/pkg/hostman/hostinfo/hostbridge/linux_bridge.go index 1799c9bbb4..72c3e8bf3c 100644 --- a/pkg/hostman/hostinfo/hostbridge/linux_bridge.go +++ b/pkg/hostman/hostinfo/hostbridge/linux_bridge.go @@ -24,6 +24,7 @@ import ( "yunion.io/x/pkg/errors" "yunion.io/x/pkg/utils" + "yunion.io/x/onecloud/pkg/apis/compute" "yunion.io/x/onecloud/pkg/hostman/guestman/desc" "yunion.io/x/onecloud/pkg/hostman/options" "yunion.io/x/onecloud/pkg/util/iproute2" @@ -104,6 +105,11 @@ func (l *SLinuxBridgeDriver) getUpScripts(nic *desc.SGuestNetwork, isVolatileHos s += "ip address flush dev $1\n" s += "ip link set dev $1 up\n" s += "brctl addif ${switch} $1\n" + if nic.Driver != compute.NETWORK_DRIVER_VFIO { + if len(options.HostOptions.SRIOVNics) > 0 { + s += fmt.Sprintf("bridge fdb add %s dev %s\n", nic.Mac, l.inter.String()) + } + } return s, nil } @@ -117,6 +123,11 @@ func (l *SLinuxBridgeDriver) getDownScripts(nic *desc.SGuestNetwork, isVolatileH s += "ip addr flush dev $1\n" s += "ip link set dev $1 down\n" s += "brctl delif ${switch} $1\n" + if nic.Driver != compute.NETWORK_DRIVER_VFIO { + if len(options.HostOptions.SRIOVNics) > 0 { + s += fmt.Sprintf("bridge fdb del %s dev %s\n", nic.Mac, l.inter.String()) + } + } return s, nil } diff --git a/pkg/hostman/hostinfo/hostbridge/ovs.go b/pkg/hostman/hostinfo/hostbridge/ovs.go index 7be3ff8623..cbae731c93 100644 --- a/pkg/hostman/hostinfo/hostbridge/ovs.go +++ b/pkg/hostman/hostinfo/hostbridge/ovs.go @@ -196,6 +196,9 @@ func (o *SOVSBridgeDriver) getUpScripts(nic *desc.SGuestNetwork, isVolatileHost s += " ovs-vsctl set Interface $IF ingress_policing_rate=$LIMIT\n" s += " ovs-vsctl set Interface $IF ingress_policing_burst=$BURST\n" s += "fi\n" + if vpcProvider != compute.VPC_PROVIDER_OVN && len(options.HostOptions.SRIOVNics) > 0 { + s += fmt.Sprintf("bridge fdb add %s dev %s\n", nic.Mac, o.inter.String()) + } } s += "if [ $LIMIT_DOWNLOAD != \"0mbit\" ]; then\n" @@ -232,6 +235,11 @@ func (o *SOVSBridgeDriver) getDownScripts(nic *desc.SGuestNetwork, isVolatileHos s += "PORT=$(echo $PORT | awk 'BEGIN{FS=\"(\"}{print $1}')\n" s += "ip link set dev $IF down\n" s += "ovs-vsctl -- --if-exists del-port $SWITCH $IF\n" + if nic.Driver != compute.NETWORK_DRIVER_VFIO { + if nic.Vpc.Provider != compute.VPC_PROVIDER_OVN && len(options.HostOptions.SRIOVNics) > 0 { + s += fmt.Sprintf("bridge fdb del %s dev %s\n", nic.Mac, o.inter.String()) + } + } return s, nil }