mirror of
https://github.com/kata-containers/kata-containers.git
synced 2025-05-01 05:04:26 +00:00
macvlan: drop bridged part of name
The fact that we need to "bridge" the endpoint is a bit irrelevant. To be consistent with the rest of the endpoints, let's just call this "macvlan" Fixes: #3050 Signed-off-by: Eric Ernst <eric_ernst@apple.com>
This commit is contained in:
parent
15b5d22e81
commit
1e7cb4bc3a
@ -51,8 +51,8 @@ const (
|
|||||||
// VhostUserEndpointType is the vhostuser network interface.
|
// VhostUserEndpointType is the vhostuser network interface.
|
||||||
VhostUserEndpointType EndpointType = "vhost-user"
|
VhostUserEndpointType EndpointType = "vhost-user"
|
||||||
|
|
||||||
// BridgedMacvlanEndpointType is macvlan network interface.
|
// MacvlanEndpointType is macvlan network interface.
|
||||||
BridgedMacvlanEndpointType EndpointType = "macvlan"
|
MacvlanEndpointType EndpointType = "macvlan"
|
||||||
|
|
||||||
// MacvtapEndpointType is macvtap network interface.
|
// MacvtapEndpointType is macvtap network interface.
|
||||||
MacvtapEndpointType EndpointType = "macvtap"
|
MacvtapEndpointType EndpointType = "macvtap"
|
||||||
@ -80,7 +80,7 @@ func (endpointType *EndpointType) Set(value string) error {
|
|||||||
*endpointType = VhostUserEndpointType
|
*endpointType = VhostUserEndpointType
|
||||||
return nil
|
return nil
|
||||||
case "macvlan":
|
case "macvlan":
|
||||||
*endpointType = BridgedMacvlanEndpointType
|
*endpointType = MacvlanEndpointType
|
||||||
return nil
|
return nil
|
||||||
case "macvtap":
|
case "macvtap":
|
||||||
*endpointType = MacvtapEndpointType
|
*endpointType = MacvtapEndpointType
|
||||||
@ -108,8 +108,8 @@ func (endpointType *EndpointType) String() string {
|
|||||||
return string(VethEndpointType)
|
return string(VethEndpointType)
|
||||||
case VhostUserEndpointType:
|
case VhostUserEndpointType:
|
||||||
return string(VhostUserEndpointType)
|
return string(VhostUserEndpointType)
|
||||||
case BridgedMacvlanEndpointType:
|
case MacvlanEndpointType:
|
||||||
return string(BridgedMacvlanEndpointType)
|
return string(MacvlanEndpointType)
|
||||||
case MacvtapEndpointType:
|
case MacvtapEndpointType:
|
||||||
return string(MacvtapEndpointType)
|
return string(MacvtapEndpointType)
|
||||||
case TapEndpointType:
|
case TapEndpointType:
|
||||||
|
@ -35,8 +35,8 @@ func TestVhostUserEndpointTypeSet(t *testing.T) {
|
|||||||
testEndpointTypeSet(t, "vhost-user", VhostUserEndpointType)
|
testEndpointTypeSet(t, "vhost-user", VhostUserEndpointType)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestBridgedMacvlanEndpointTypeSet(t *testing.T) {
|
func TestMacvlanEndpointTypeSet(t *testing.T) {
|
||||||
testEndpointTypeSet(t, "macvlan", BridgedMacvlanEndpointType)
|
testEndpointTypeSet(t, "macvlan", MacvlanEndpointType)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestMacvtapEndpointTypeSet(t *testing.T) {
|
func TestMacvtapEndpointTypeSet(t *testing.T) {
|
||||||
@ -69,9 +69,9 @@ func TestVhostUserEndpointTypeString(t *testing.T) {
|
|||||||
testEndpointTypeString(t, &endpointType, string(VhostUserEndpointType))
|
testEndpointTypeString(t, &endpointType, string(VhostUserEndpointType))
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestBridgedMacvlanEndpointTypeString(t *testing.T) {
|
func TestMacvlanEndpointTypeString(t *testing.T) {
|
||||||
endpointType := BridgedMacvlanEndpointType
|
endpointType := MacvlanEndpointType
|
||||||
testEndpointTypeString(t, &endpointType, string(BridgedMacvlanEndpointType))
|
testEndpointTypeString(t, &endpointType, string(MacvlanEndpointType))
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestMacvtapEndpointTypeString(t *testing.T) {
|
func TestMacvtapEndpointTypeString(t *testing.T) {
|
||||||
|
@ -14,10 +14,10 @@ import (
|
|||||||
vcTypes "github.com/kata-containers/kata-containers/src/runtime/virtcontainers/types"
|
vcTypes "github.com/kata-containers/kata-containers/src/runtime/virtcontainers/types"
|
||||||
)
|
)
|
||||||
|
|
||||||
var macvlanTrace = getNetworkTrace(BridgedMacvlanEndpointType)
|
var macvlanTrace = getNetworkTrace(MacvlanEndpointType)
|
||||||
|
|
||||||
// BridgedMacvlanEndpoint represents a macvlan endpoint that is bridged to the VM
|
// MacvlanEndpoint represents a macvlan endpoint that is bridged to the VM
|
||||||
type BridgedMacvlanEndpoint struct {
|
type MacvlanEndpoint struct {
|
||||||
EndpointType EndpointType
|
EndpointType EndpointType
|
||||||
PCIPath vcTypes.PciPath
|
PCIPath vcTypes.PciPath
|
||||||
EndpointProperties NetworkInfo
|
EndpointProperties NetworkInfo
|
||||||
@ -26,9 +26,9 @@ type BridgedMacvlanEndpoint struct {
|
|||||||
TxRateLimiter bool
|
TxRateLimiter bool
|
||||||
}
|
}
|
||||||
|
|
||||||
func createBridgedMacvlanNetworkEndpoint(idx int, ifName string, interworkingModel NetInterworkingModel) (*BridgedMacvlanEndpoint, error) {
|
func createMacvlanNetworkEndpoint(idx int, ifName string, interworkingModel NetInterworkingModel) (*MacvlanEndpoint, error) {
|
||||||
if idx < 0 {
|
if idx < 0 {
|
||||||
return &BridgedMacvlanEndpoint{}, fmt.Errorf("invalid network endpoint index: %d", idx)
|
return &MacvlanEndpoint{}, fmt.Errorf("invalid network endpoint index: %d", idx)
|
||||||
}
|
}
|
||||||
|
|
||||||
netPair, err := createNetworkInterfacePair(idx, ifName, interworkingModel)
|
netPair, err := createNetworkInterfacePair(idx, ifName, interworkingModel)
|
||||||
@ -36,9 +36,9 @@ func createBridgedMacvlanNetworkEndpoint(idx int, ifName string, interworkingMod
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
endpoint := &BridgedMacvlanEndpoint{
|
endpoint := &MacvlanEndpoint{
|
||||||
NetPair: netPair,
|
NetPair: netPair,
|
||||||
EndpointType: BridgedMacvlanEndpointType,
|
EndpointType: MacvlanEndpointType,
|
||||||
}
|
}
|
||||||
if ifName != "" {
|
if ifName != "" {
|
||||||
endpoint.NetPair.VirtIface.Name = ifName
|
endpoint.NetPair.VirtIface.Name = ifName
|
||||||
@ -48,49 +48,49 @@ func createBridgedMacvlanNetworkEndpoint(idx int, ifName string, interworkingMod
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Properties returns properties of the interface.
|
// Properties returns properties of the interface.
|
||||||
func (endpoint *BridgedMacvlanEndpoint) Properties() NetworkInfo {
|
func (endpoint *MacvlanEndpoint) Properties() NetworkInfo {
|
||||||
return endpoint.EndpointProperties
|
return endpoint.EndpointProperties
|
||||||
}
|
}
|
||||||
|
|
||||||
// Name returns name of the veth interface in the network pair.
|
// Name returns name of the veth interface in the network pair.
|
||||||
func (endpoint *BridgedMacvlanEndpoint) Name() string {
|
func (endpoint *MacvlanEndpoint) Name() string {
|
||||||
return endpoint.NetPair.VirtIface.Name
|
return endpoint.NetPair.VirtIface.Name
|
||||||
}
|
}
|
||||||
|
|
||||||
// HardwareAddr returns the mac address that is assigned to the tap interface
|
// HardwareAddr returns the mac address that is assigned to the tap interface
|
||||||
// in th network pair.
|
// in th network pair.
|
||||||
func (endpoint *BridgedMacvlanEndpoint) HardwareAddr() string {
|
func (endpoint *MacvlanEndpoint) HardwareAddr() string {
|
||||||
return endpoint.NetPair.TAPIface.HardAddr
|
return endpoint.NetPair.TAPIface.HardAddr
|
||||||
}
|
}
|
||||||
|
|
||||||
// Type identifies the endpoint as a bridged macvlan endpoint.
|
// Type identifies the endpoint as a bridged macvlan endpoint.
|
||||||
func (endpoint *BridgedMacvlanEndpoint) Type() EndpointType {
|
func (endpoint *MacvlanEndpoint) Type() EndpointType {
|
||||||
return endpoint.EndpointType
|
return endpoint.EndpointType
|
||||||
}
|
}
|
||||||
|
|
||||||
// SetProperties sets the properties for the endpoint.
|
// SetProperties sets the properties for the endpoint.
|
||||||
func (endpoint *BridgedMacvlanEndpoint) SetProperties(properties NetworkInfo) {
|
func (endpoint *MacvlanEndpoint) SetProperties(properties NetworkInfo) {
|
||||||
endpoint.EndpointProperties = properties
|
endpoint.EndpointProperties = properties
|
||||||
}
|
}
|
||||||
|
|
||||||
// PciPath returns the PCI path of the endpoint.
|
// PciPath returns the PCI path of the endpoint.
|
||||||
func (endpoint *BridgedMacvlanEndpoint) PciPath() vcTypes.PciPath {
|
func (endpoint *MacvlanEndpoint) PciPath() vcTypes.PciPath {
|
||||||
return endpoint.PCIPath
|
return endpoint.PCIPath
|
||||||
}
|
}
|
||||||
|
|
||||||
// SetPciPath sets the PCI path of the endpoint.
|
// SetPciPath sets the PCI path of the endpoint.
|
||||||
func (endpoint *BridgedMacvlanEndpoint) SetPciPath(pciPath vcTypes.PciPath) {
|
func (endpoint *MacvlanEndpoint) SetPciPath(pciPath vcTypes.PciPath) {
|
||||||
endpoint.PCIPath = pciPath
|
endpoint.PCIPath = pciPath
|
||||||
}
|
}
|
||||||
|
|
||||||
// NetworkPair returns the network pair of the endpoint.
|
// NetworkPair returns the network pair of the endpoint.
|
||||||
func (endpoint *BridgedMacvlanEndpoint) NetworkPair() *NetworkInterfacePair {
|
func (endpoint *MacvlanEndpoint) NetworkPair() *NetworkInterfacePair {
|
||||||
return &endpoint.NetPair
|
return &endpoint.NetPair
|
||||||
}
|
}
|
||||||
|
|
||||||
// Attach for virtual endpoint bridges the network pair and adds the
|
// Attach for virtual endpoint bridges the network pair and adds the
|
||||||
// tap interface of the network pair to the hypervisor.
|
// tap interface of the network pair to the hypervisor.
|
||||||
func (endpoint *BridgedMacvlanEndpoint) Attach(ctx context.Context, s *Sandbox) error {
|
func (endpoint *MacvlanEndpoint) Attach(ctx context.Context, s *Sandbox) error {
|
||||||
span, ctx := macvlanTrace(ctx, "Attach", endpoint)
|
span, ctx := macvlanTrace(ctx, "Attach", endpoint)
|
||||||
defer span.End()
|
defer span.End()
|
||||||
|
|
||||||
@ -105,7 +105,7 @@ func (endpoint *BridgedMacvlanEndpoint) Attach(ctx context.Context, s *Sandbox)
|
|||||||
|
|
||||||
// Detach for the virtual endpoint tears down the tap and bridge
|
// Detach for the virtual endpoint tears down the tap and bridge
|
||||||
// created for the veth interface.
|
// created for the veth interface.
|
||||||
func (endpoint *BridgedMacvlanEndpoint) Detach(ctx context.Context, netNsCreated bool, netNsPath string) error {
|
func (endpoint *MacvlanEndpoint) Detach(ctx context.Context, netNsCreated bool, netNsPath string) error {
|
||||||
// The network namespace would have been deleted at this point
|
// The network namespace would have been deleted at this point
|
||||||
// if it has not been created by virtcontainers.
|
// if it has not been created by virtcontainers.
|
||||||
if !netNsCreated {
|
if !netNsCreated {
|
||||||
@ -121,49 +121,49 @@ func (endpoint *BridgedMacvlanEndpoint) Detach(ctx context.Context, netNsCreated
|
|||||||
}
|
}
|
||||||
|
|
||||||
// HotAttach for bridged macvlan endpoint not supported yet
|
// HotAttach for bridged macvlan endpoint not supported yet
|
||||||
func (endpoint *BridgedMacvlanEndpoint) HotAttach(ctx context.Context, h Hypervisor) error {
|
func (endpoint *MacvlanEndpoint) HotAttach(ctx context.Context, h Hypervisor) error {
|
||||||
return fmt.Errorf("BridgedMacvlanEndpoint does not support Hot attach")
|
return fmt.Errorf("MacvlanEndpoint does not support Hot attach")
|
||||||
}
|
}
|
||||||
|
|
||||||
// HotDetach for bridged macvlan endpoint not supported yet
|
// HotDetach for bridged macvlan endpoint not supported yet
|
||||||
func (endpoint *BridgedMacvlanEndpoint) HotDetach(ctx context.Context, h Hypervisor, netNsCreated bool, netNsPath string) error {
|
func (endpoint *MacvlanEndpoint) HotDetach(ctx context.Context, h Hypervisor, netNsCreated bool, netNsPath string) error {
|
||||||
return fmt.Errorf("BridgedMacvlanEndpoint does not support Hot detach")
|
return fmt.Errorf("MacvlanEndpoint does not support Hot detach")
|
||||||
}
|
}
|
||||||
|
|
||||||
func (endpoint *BridgedMacvlanEndpoint) save() persistapi.NetworkEndpoint {
|
func (endpoint *MacvlanEndpoint) save() persistapi.NetworkEndpoint {
|
||||||
netpair := saveNetIfPair(&endpoint.NetPair)
|
netpair := saveNetIfPair(&endpoint.NetPair)
|
||||||
|
|
||||||
return persistapi.NetworkEndpoint{
|
return persistapi.NetworkEndpoint{
|
||||||
Type: string(endpoint.Type()),
|
Type: string(endpoint.Type()),
|
||||||
BridgedMacvlan: &persistapi.BridgedMacvlanEndpoint{
|
Macvlan: &persistapi.MacvlanEndpoint{
|
||||||
NetPair: *netpair,
|
NetPair: *netpair,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (endpoint *BridgedMacvlanEndpoint) load(s persistapi.NetworkEndpoint) {
|
func (endpoint *MacvlanEndpoint) load(s persistapi.NetworkEndpoint) {
|
||||||
endpoint.EndpointType = BridgedMacvlanEndpointType
|
endpoint.EndpointType = MacvlanEndpointType
|
||||||
|
|
||||||
if s.BridgedMacvlan != nil {
|
if s.Macvlan != nil {
|
||||||
netpair := loadNetIfPair(&s.BridgedMacvlan.NetPair)
|
netpair := loadNetIfPair(&s.Macvlan.NetPair)
|
||||||
endpoint.NetPair = *netpair
|
endpoint.NetPair = *netpair
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (endpoint *BridgedMacvlanEndpoint) GetRxRateLimiter() bool {
|
func (endpoint *MacvlanEndpoint) GetRxRateLimiter() bool {
|
||||||
return endpoint.RxRateLimiter
|
return endpoint.RxRateLimiter
|
||||||
}
|
}
|
||||||
|
|
||||||
func (endpoint *BridgedMacvlanEndpoint) SetRxRateLimiter() error {
|
func (endpoint *MacvlanEndpoint) SetRxRateLimiter() error {
|
||||||
endpoint.RxRateLimiter = true
|
endpoint.RxRateLimiter = true
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (endpoint *BridgedMacvlanEndpoint) GetTxRateLimiter() bool {
|
func (endpoint *MacvlanEndpoint) GetTxRateLimiter() bool {
|
||||||
return endpoint.TxRateLimiter
|
return endpoint.TxRateLimiter
|
||||||
}
|
}
|
||||||
|
|
||||||
func (endpoint *BridgedMacvlanEndpoint) SetTxRateLimiter() error {
|
func (endpoint *MacvlanEndpoint) SetTxRateLimiter() error {
|
||||||
endpoint.TxRateLimiter = true
|
endpoint.TxRateLimiter = true
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
@ -12,10 +12,10 @@ import (
|
|||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestCreateBridgedMacvlanEndpoint(t *testing.T) {
|
func TestCreateMacvlanEndpoint(t *testing.T) {
|
||||||
macAddr := net.HardwareAddr{0x02, 0x00, 0xCA, 0xFE, 0x00, 0x04}
|
macAddr := net.HardwareAddr{0x02, 0x00, 0xCA, 0xFE, 0x00, 0x04}
|
||||||
|
|
||||||
expected := &BridgedMacvlanEndpoint{
|
expected := &MacvlanEndpoint{
|
||||||
NetPair: NetworkInterfacePair{
|
NetPair: NetworkInterfacePair{
|
||||||
TapInterface: TapInterface{
|
TapInterface: TapInterface{
|
||||||
ID: "uniqueTestID-4",
|
ID: "uniqueTestID-4",
|
||||||
@ -30,10 +30,10 @@ func TestCreateBridgedMacvlanEndpoint(t *testing.T) {
|
|||||||
},
|
},
|
||||||
NetInterworkingModel: DefaultNetInterworkingModel,
|
NetInterworkingModel: DefaultNetInterworkingModel,
|
||||||
},
|
},
|
||||||
EndpointType: BridgedMacvlanEndpointType,
|
EndpointType: MacvlanEndpointType,
|
||||||
}
|
}
|
||||||
|
|
||||||
result, err := createBridgedMacvlanNetworkEndpoint(4, "", DefaultNetInterworkingModel)
|
result, err := createMacvlanNetworkEndpoint(4, "", DefaultNetInterworkingModel)
|
||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
|
|
||||||
// the resulting ID will be random - so let's overwrite to test the rest of the flow
|
// the resulting ID will be random - so let's overwrite to test the rest of the flow
|
@ -256,8 +256,8 @@ func generateEndpoints(typedEndpoints []TypedJSONEndpoint) ([]Endpoint, error) {
|
|||||||
var endpoint VhostUserEndpoint
|
var endpoint VhostUserEndpoint
|
||||||
endpointInf = &endpoint
|
endpointInf = &endpoint
|
||||||
|
|
||||||
case BridgedMacvlanEndpointType:
|
case MacvlanEndpointType:
|
||||||
var endpoint BridgedMacvlanEndpoint
|
var endpoint MacvlanEndpoint
|
||||||
endpointInf = &endpoint
|
endpointInf = &endpoint
|
||||||
|
|
||||||
case MacvtapEndpointType:
|
case MacvtapEndpointType:
|
||||||
@ -378,7 +378,7 @@ func getLinkForEndpoint(endpoint Endpoint, netHandle *netlink.Handle) (netlink.L
|
|||||||
switch ep := endpoint.(type) {
|
switch ep := endpoint.(type) {
|
||||||
case *VethEndpoint:
|
case *VethEndpoint:
|
||||||
link = &netlink.Veth{}
|
link = &netlink.Veth{}
|
||||||
case *BridgedMacvlanEndpoint:
|
case *MacvlanEndpoint:
|
||||||
link = &netlink.Macvlan{}
|
link = &netlink.Macvlan{}
|
||||||
case *IPVlanEndpoint:
|
case *IPVlanEndpoint:
|
||||||
link = &netlink.IPVlan{}
|
link = &netlink.IPVlan{}
|
||||||
@ -1254,7 +1254,7 @@ func createEndpoint(netInfo NetworkInfo, idx int, model NetInterworkingModel, li
|
|||||||
endpoint, err = createVhostUserEndpoint(netInfo, socketPath)
|
endpoint, err = createVhostUserEndpoint(netInfo, socketPath)
|
||||||
} else if netInfo.Iface.Type == "macvlan" {
|
} else if netInfo.Iface.Type == "macvlan" {
|
||||||
networkLogger().Infof("macvlan interface found")
|
networkLogger().Infof("macvlan interface found")
|
||||||
endpoint, err = createBridgedMacvlanNetworkEndpoint(idx, netInfo.Iface.Name, model)
|
endpoint, err = createMacvlanNetworkEndpoint(idx, netInfo.Iface.Name, model)
|
||||||
} else if netInfo.Iface.Type == "macvtap" {
|
} else if netInfo.Iface.Type == "macvtap" {
|
||||||
networkLogger().Infof("macvtap interface found")
|
networkLogger().Infof("macvtap interface found")
|
||||||
endpoint, err = createMacvtapNetworkEndpoint(netInfo)
|
endpoint, err = createMacvtapNetworkEndpoint(netInfo)
|
||||||
@ -1456,7 +1456,7 @@ func (n *Network) Remove(ctx context.Context, ns *NetworkNamespace, hypervisor H
|
|||||||
func addRxRateLimiter(endpoint Endpoint, maxRate uint64) error {
|
func addRxRateLimiter(endpoint Endpoint, maxRate uint64) error {
|
||||||
var linkName string
|
var linkName string
|
||||||
switch ep := endpoint.(type) {
|
switch ep := endpoint.(type) {
|
||||||
case *VethEndpoint, *IPVlanEndpoint, *TuntapEndpoint, *BridgedMacvlanEndpoint:
|
case *VethEndpoint, *IPVlanEndpoint, *TuntapEndpoint, *MacvlanEndpoint:
|
||||||
netPair := endpoint.NetworkPair()
|
netPair := endpoint.NetworkPair()
|
||||||
linkName = netPair.TapInterface.TAPIface.Name
|
linkName = netPair.TapInterface.TAPIface.Name
|
||||||
case *MacvtapEndpoint, *TapEndpoint:
|
case *MacvtapEndpoint, *TapEndpoint:
|
||||||
@ -1612,7 +1612,7 @@ func addTxRateLimiter(endpoint Endpoint, maxRate uint64) error {
|
|||||||
var netPair *NetworkInterfacePair
|
var netPair *NetworkInterfacePair
|
||||||
var linkName string
|
var linkName string
|
||||||
switch ep := endpoint.(type) {
|
switch ep := endpoint.(type) {
|
||||||
case *VethEndpoint, *IPVlanEndpoint, *TuntapEndpoint, *BridgedMacvlanEndpoint:
|
case *VethEndpoint, *IPVlanEndpoint, *TuntapEndpoint, *MacvlanEndpoint:
|
||||||
netPair = endpoint.NetworkPair()
|
netPair = endpoint.NetworkPair()
|
||||||
switch netPair.NetInterworkingModel {
|
switch netPair.NetInterworkingModel {
|
||||||
// For those endpoints we've already used tcfilter as their inter-networking model,
|
// For those endpoints we've already used tcfilter as their inter-networking model,
|
||||||
@ -1685,7 +1685,7 @@ func removeHTBQdisc(linkName string) error {
|
|||||||
func removeRxRateLimiter(endpoint Endpoint, networkNSPath string) error {
|
func removeRxRateLimiter(endpoint Endpoint, networkNSPath string) error {
|
||||||
var linkName string
|
var linkName string
|
||||||
switch ep := endpoint.(type) {
|
switch ep := endpoint.(type) {
|
||||||
case *VethEndpoint, *IPVlanEndpoint, *TuntapEndpoint, *BridgedMacvlanEndpoint:
|
case *VethEndpoint, *IPVlanEndpoint, *TuntapEndpoint, *MacvlanEndpoint:
|
||||||
netPair := endpoint.NetworkPair()
|
netPair := endpoint.NetworkPair()
|
||||||
linkName = netPair.TapInterface.TAPIface.Name
|
linkName = netPair.TapInterface.TAPIface.Name
|
||||||
case *MacvtapEndpoint, *TapEndpoint:
|
case *MacvtapEndpoint, *TapEndpoint:
|
||||||
@ -1706,7 +1706,7 @@ func removeRxRateLimiter(endpoint Endpoint, networkNSPath string) error {
|
|||||||
func removeTxRateLimiter(endpoint Endpoint, networkNSPath string) error {
|
func removeTxRateLimiter(endpoint Endpoint, networkNSPath string) error {
|
||||||
var linkName string
|
var linkName string
|
||||||
switch ep := endpoint.(type) {
|
switch ep := endpoint.(type) {
|
||||||
case *VethEndpoint, *IPVlanEndpoint, *TuntapEndpoint, *BridgedMacvlanEndpoint:
|
case *VethEndpoint, *IPVlanEndpoint, *TuntapEndpoint, *MacvlanEndpoint:
|
||||||
netPair := endpoint.NetworkPair()
|
netPair := endpoint.NetworkPair()
|
||||||
switch netPair.NetInterworkingModel {
|
switch netPair.NetInterworkingModel {
|
||||||
case NetXConnectTCFilterModel:
|
case NetXConnectTCFilterModel:
|
||||||
|
@ -380,8 +380,8 @@ func (s *Sandbox) loadNetwork(netInfo persistapi.NetworkInfo) {
|
|||||||
ep = &VethEndpoint{}
|
ep = &VethEndpoint{}
|
||||||
case VhostUserEndpointType:
|
case VhostUserEndpointType:
|
||||||
ep = &VhostUserEndpoint{}
|
ep = &VhostUserEndpoint{}
|
||||||
case BridgedMacvlanEndpointType:
|
case MacvlanEndpointType:
|
||||||
ep = &BridgedMacvlanEndpoint{}
|
ep = &MacvlanEndpoint{}
|
||||||
case MacvtapEndpointType:
|
case MacvtapEndpointType:
|
||||||
ep = &MacvtapEndpoint{}
|
ep = &MacvtapEndpoint{}
|
||||||
case TapEndpointType:
|
case TapEndpointType:
|
||||||
|
@ -60,7 +60,7 @@ type TuntapEndpoint struct {
|
|||||||
TuntapInterface TuntapInterface
|
TuntapInterface TuntapInterface
|
||||||
}
|
}
|
||||||
|
|
||||||
type BridgedMacvlanEndpoint struct {
|
type MacvlanEndpoint struct {
|
||||||
NetPair NetworkInterfacePair
|
NetPair NetworkInterfacePair
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -82,14 +82,14 @@ type VhostUserEndpoint struct {
|
|||||||
// NetworkEndpoint contains network interface information
|
// NetworkEndpoint contains network interface information
|
||||||
type NetworkEndpoint struct {
|
type NetworkEndpoint struct {
|
||||||
// One and only one of these below are not nil according to Type.
|
// One and only one of these below are not nil according to Type.
|
||||||
Physical *PhysicalEndpoint `json:",omitempty"`
|
Physical *PhysicalEndpoint `json:",omitempty"`
|
||||||
Veth *VethEndpoint `json:",omitempty"`
|
Veth *VethEndpoint `json:",omitempty"`
|
||||||
VhostUser *VhostUserEndpoint `json:",omitempty"`
|
VhostUser *VhostUserEndpoint `json:",omitempty"`
|
||||||
BridgedMacvlan *BridgedMacvlanEndpoint `json:",omitempty"`
|
Macvlan *MacvlanEndpoint `json:",omitempty"`
|
||||||
Macvtap *MacvtapEndpoint `json:",omitempty"`
|
Macvtap *MacvtapEndpoint `json:",omitempty"`
|
||||||
Tap *TapEndpoint `json:",omitempty"`
|
Tap *TapEndpoint `json:",omitempty"`
|
||||||
IPVlan *IPVlanEndpoint `json:",omitempty"`
|
IPVlan *IPVlanEndpoint `json:",omitempty"`
|
||||||
Tuntap *TuntapEndpoint `json:",omitempty"`
|
Tuntap *TuntapEndpoint `json:",omitempty"`
|
||||||
|
|
||||||
Type string
|
Type string
|
||||||
}
|
}
|
||||||
|
@ -571,7 +571,7 @@ func networkModelToQemuType(model NetInterworkingModel) govmmQemu.NetDeviceType
|
|||||||
func genericNetwork(endpoint Endpoint, vhost, nestedRun bool, index int) (govmmQemu.NetDevice, error) {
|
func genericNetwork(endpoint Endpoint, vhost, nestedRun bool, index int) (govmmQemu.NetDevice, error) {
|
||||||
var d govmmQemu.NetDevice
|
var d govmmQemu.NetDevice
|
||||||
switch ep := endpoint.(type) {
|
switch ep := endpoint.(type) {
|
||||||
case *VethEndpoint, *BridgedMacvlanEndpoint, *IPVlanEndpoint:
|
case *VethEndpoint, *MacvlanEndpoint, *IPVlanEndpoint:
|
||||||
netPair := ep.NetworkPair()
|
netPair := ep.NetworkPair()
|
||||||
d = govmmQemu.NetDevice{
|
d = govmmQemu.NetDevice{
|
||||||
Type: networkModelToQemuType(netPair.NetInterworkingModel),
|
Type: networkModelToQemuType(netPair.NetInterworkingModel),
|
||||||
|
@ -490,7 +490,7 @@ func TestQemuArchBaseAppendNetwork(t *testing.T) {
|
|||||||
|
|
||||||
macAddr := net.HardwareAddr{0x02, 0x00, 0xCA, 0xFE, 0x00, 0x04}
|
macAddr := net.HardwareAddr{0x02, 0x00, 0xCA, 0xFE, 0x00, 0x04}
|
||||||
|
|
||||||
macvlanEp := &BridgedMacvlanEndpoint{
|
macvlanEp := &MacvlanEndpoint{
|
||||||
NetPair: NetworkInterfacePair{
|
NetPair: NetworkInterfacePair{
|
||||||
TapInterface: TapInterface{
|
TapInterface: TapInterface{
|
||||||
ID: "uniqueTestID-4",
|
ID: "uniqueTestID-4",
|
||||||
@ -505,7 +505,7 @@ func TestQemuArchBaseAppendNetwork(t *testing.T) {
|
|||||||
},
|
},
|
||||||
NetInterworkingModel: DefaultNetInterworkingModel,
|
NetInterworkingModel: DefaultNetInterworkingModel,
|
||||||
},
|
},
|
||||||
EndpointType: BridgedMacvlanEndpointType,
|
EndpointType: MacvlanEndpointType,
|
||||||
}
|
}
|
||||||
|
|
||||||
macvtapEp := &MacvtapEndpoint{
|
macvtapEp := &MacvtapEndpoint{
|
||||||
|
Loading…
Reference in New Issue
Block a user