network: Rename VirtualEndpoint to VethEndpoint

As this really represents a veth pair rather than a generic
virtual interface, rename VirtualEndpoint to VethEndpoint.

Signed-off-by: Archana Shinde <archana.m.shinde@intel.com>
This commit is contained in:
Archana Shinde 2018-10-09 10:44:08 -07:00
parent df8f21d9fe
commit 3c590b0e2c
7 changed files with 50 additions and 50 deletions

View File

@ -32,8 +32,8 @@ const (
// PhysicalEndpointType is the physical network interface.
PhysicalEndpointType EndpointType = "physical"
// VirtualEndpointType is the virtual network interface.
VirtualEndpointType EndpointType = "virtual"
// VethEndpointType is the virtual network interface.
VethEndpointType EndpointType = "virtual"
// VhostUserEndpointType is the vhostuser network interface.
VhostUserEndpointType EndpointType = "vhost-user"
@ -52,7 +52,7 @@ func (endpointType *EndpointType) Set(value string) error {
*endpointType = PhysicalEndpointType
return nil
case "virtual":
*endpointType = VirtualEndpointType
*endpointType = VethEndpointType
return nil
case "vhost-user":
*endpointType = VhostUserEndpointType
@ -73,8 +73,8 @@ func (endpointType *EndpointType) String() string {
switch *endpointType {
case PhysicalEndpointType:
return string(PhysicalEndpointType)
case VirtualEndpointType:
return string(VirtualEndpointType)
case VethEndpointType:
return string(VethEndpointType)
case VhostUserEndpointType:
return string(VhostUserEndpointType)
case BridgedMacvlanEndpointType:

View File

@ -25,8 +25,8 @@ func TestPhysicalEndpointTypeSet(t *testing.T) {
testEndpointTypeSet(t, "physical", PhysicalEndpointType)
}
func TestVirtualEndpointTypeSet(t *testing.T) {
testEndpointTypeSet(t, "virtual", VirtualEndpointType)
func TestVethEndpointTypeSet(t *testing.T) {
testEndpointTypeSet(t, "virtual", VethEndpointType)
}
func TestVhostUserEndpointTypeSet(t *testing.T) {
@ -63,9 +63,9 @@ func TestPhysicalEndpointTypeString(t *testing.T) {
testEndpointTypeString(t, &endpointType, string(PhysicalEndpointType))
}
func TestVirtualEndpointTypeString(t *testing.T) {
endpointType := VirtualEndpointType
testEndpointTypeString(t, &endpointType, string(VirtualEndpointType))
func TestVethEndpointTypeString(t *testing.T) {
endpointType := VethEndpointType
testEndpointTypeString(t, &endpointType, string(VethEndpointType))
}
func TestVhostUserEndpointTypeString(t *testing.T) {

View File

@ -232,8 +232,8 @@ func (n *NetworkNamespace) UnmarshalJSON(b []byte) error {
"endpoint-type": "physical",
}).Info("endpoint unmarshalled")
case VirtualEndpointType:
var endpoint VirtualEndpoint
case VethEndpointType:
var endpoint VethEndpoint
err := json.Unmarshal(e.Data, &endpoint)
if err != nil {
return err
@ -394,7 +394,7 @@ func getLinkForEndpoint(endpoint Endpoint, netHandle *netlink.Handle) (netlink.L
var link netlink.Link
switch ep := endpoint.(type) {
case *VirtualEndpoint:
case *VethEndpoint:
link = &netlink.Veth{}
case *BridgedMacvlanEndpoint:
link = &netlink.Macvlan{}
@ -1117,7 +1117,7 @@ func createEndpoint(netInfo NetworkInfo, idx int, model NetInterworkingModel) (E
networkLogger().Infof("macvtap interface found")
endpoint, err = createMacvtapNetworkEndpoint(netInfo)
} else {
endpoint, err = createVirtualNetworkEndpoint(idx, netInfo.Iface.Name, model)
endpoint, err = createVethNetworkEndpoint(idx, netInfo.Iface.Name, model)
}
}

View File

@ -833,7 +833,7 @@ func (q *qemu) hotplugVFIODevice(device *config.VFIODev, op operation) error {
return nil
}
func (q *qemu) hotplugMacvtap(drive *VirtualEndpoint) error {
func (q *qemu) hotplugMacvtap(drive *VethEndpoint) error {
var (
VMFdNames []string
VhostFdNames []string
@ -857,7 +857,7 @@ func (q *qemu) hotplugMacvtap(drive *VirtualEndpoint) error {
return q.qmpMonitorCh.qmp.ExecuteNetdevAddByFds(q.qmpMonitorCh.ctx, "tap", drive.NetPair.Name, VMFdNames, VhostFdNames)
}
func (q *qemu) hotplugNetDevice(drive *VirtualEndpoint, op operation) error {
func (q *qemu) hotplugNetDevice(drive *VethEndpoint, op operation) error {
err := q.qmpSetup()
if err != nil {
return err
@ -914,7 +914,7 @@ func (q *qemu) hotplugDevice(devInfo interface{}, devType deviceType, op operati
memdev := devInfo.(*memoryDevice)
return q.hotplugMemory(memdev, op)
case netDev:
device := devInfo.(*VirtualEndpoint)
device := devInfo.(*VethEndpoint)
return nil, q.hotplugNetDevice(device, op)
default:
return nil, fmt.Errorf("cannot hotplug device: unsupported device type '%v'", devType)

View File

@ -441,7 +441,7 @@ func networkModelToQemuType(model NetInterworkingModel) govmmQemu.NetDeviceType
func (q *qemuArchBase) appendNetwork(devices []govmmQemu.Device, endpoint Endpoint) []govmmQemu.Device {
switch ep := endpoint.(type) {
case *VirtualEndpoint, *BridgedMacvlanEndpoint:
case *VethEndpoint, *BridgedMacvlanEndpoint:
netPair := ep.NetworkPair()
devices = append(devices,
govmmQemu.NetDevice{

View File

@ -11,8 +11,8 @@ import (
"github.com/containernetworking/plugins/pkg/ns"
)
// VirtualEndpoint gathers a network pair and its properties.
type VirtualEndpoint struct {
// VethEndpoint gathers a network pair and its properties.
type VethEndpoint struct {
NetPair NetworkInterfacePair
EndpointProperties NetworkInfo
Physical bool
@ -20,9 +20,9 @@ type VirtualEndpoint struct {
PCIAddr string
}
func createVirtualNetworkEndpoint(idx int, ifName string, interworkingModel NetInterworkingModel) (*VirtualEndpoint, error) {
func createVethNetworkEndpoint(idx int, ifName string, interworkingModel NetInterworkingModel) (*VethEndpoint, error) {
if idx < 0 {
return &VirtualEndpoint{}, fmt.Errorf("invalid network endpoint index: %d", idx)
return &VethEndpoint{}, fmt.Errorf("invalid network endpoint index: %d", idx)
}
netPair, err := createNetworkInterfacePair(idx, ifName, interworkingModel)
@ -30,12 +30,12 @@ func createVirtualNetworkEndpoint(idx int, ifName string, interworkingModel NetI
return nil, err
}
endpoint := &VirtualEndpoint{
endpoint := &VethEndpoint{
// TODO This is too specific. We may need to create multiple
// end point types here and then decide how to connect them
// at the time of hypervisor attach and not here
NetPair: netPair,
EndpointType: VirtualEndpointType,
EndpointType: VethEndpointType,
}
if ifName != "" {
endpoint.NetPair.VirtIface.Name = ifName
@ -45,44 +45,44 @@ func createVirtualNetworkEndpoint(idx int, ifName string, interworkingModel NetI
}
// Properties returns properties for the veth interface in the network pair.
func (endpoint *VirtualEndpoint) Properties() NetworkInfo {
func (endpoint *VethEndpoint) Properties() NetworkInfo {
return endpoint.EndpointProperties
}
// Name returns name of the veth interface in the network pair.
func (endpoint *VirtualEndpoint) Name() string {
func (endpoint *VethEndpoint) Name() string {
return endpoint.NetPair.VirtIface.Name
}
// HardwareAddr returns the mac address that is assigned to the tap interface
// in th network pair.
func (endpoint *VirtualEndpoint) HardwareAddr() string {
func (endpoint *VethEndpoint) HardwareAddr() string {
return endpoint.NetPair.TAPIface.HardAddr
}
// Type identifies the endpoint as a virtual endpoint.
func (endpoint *VirtualEndpoint) Type() EndpointType {
// Type identifies the endpoint as a veth endpoint.
func (endpoint *VethEndpoint) Type() EndpointType {
return endpoint.EndpointType
}
// PciAddr returns the PCI address of the endpoint.
func (endpoint *VirtualEndpoint) PciAddr() string {
func (endpoint *VethEndpoint) PciAddr() string {
return endpoint.PCIAddr
}
// NetworkPair returns the network pair of the endpoint.
func (endpoint *VirtualEndpoint) NetworkPair() *NetworkInterfacePair {
func (endpoint *VethEndpoint) NetworkPair() *NetworkInterfacePair {
return &endpoint.NetPair
}
// SetProperties sets the properties for the endpoint.
func (endpoint *VirtualEndpoint) SetProperties(properties NetworkInfo) {
func (endpoint *VethEndpoint) SetProperties(properties NetworkInfo) {
endpoint.EndpointProperties = properties
}
// Attach for virtual endpoint bridges the network pair and adds the
// Attach for veth endpoint bridges the network pair and adds the
// tap interface of the network pair to the hypervisor.
func (endpoint *VirtualEndpoint) Attach(h hypervisor) error {
func (endpoint *VethEndpoint) Attach(h hypervisor) error {
networkLogger().WithField("endpoint-type", "virtual").Info("Attaching endpoint")
if err := xconnectVMNetwork(endpoint, true, h.hypervisorConfig().NumVCPUs, h.hypervisorConfig().DisableVhostNet); err != nil {
@ -93,9 +93,9 @@ func (endpoint *VirtualEndpoint) Attach(h hypervisor) error {
return h.addDevice(endpoint, netDev)
}
// Detach for the virtual endpoint tears down the tap and bridge
// Detach for the veth endpoint tears down the tap and bridge
// created for the veth interface.
func (endpoint *VirtualEndpoint) Detach(netNsCreated bool, netNsPath string) error {
func (endpoint *VethEndpoint) Detach(netNsCreated bool, netNsPath string) error {
// The network namespace would have been deleted at this point
// if it has not been created by virtcontainers.
if !netNsCreated {
@ -109,8 +109,8 @@ func (endpoint *VirtualEndpoint) Detach(netNsCreated bool, netNsPath string) err
})
}
// HotAttach for the virtual endpoint uses hot plug device
func (endpoint *VirtualEndpoint) HotAttach(h hypervisor) error {
// HotAttach for the veth endpoint uses hot plug device
func (endpoint *VethEndpoint) HotAttach(h hypervisor) error {
networkLogger().Info("Hot attaching virtual endpoint")
if err := xconnectVMNetwork(endpoint, true, h.hypervisorConfig().NumVCPUs, h.hypervisorConfig().DisableVhostNet); err != nil {
networkLogger().WithError(err).Error("Error bridging virtual ep")
@ -124,8 +124,8 @@ func (endpoint *VirtualEndpoint) HotAttach(h hypervisor) error {
return nil
}
// HotDetach for the virtual endpoint uses hot pull device
func (endpoint *VirtualEndpoint) HotDetach(h hypervisor, netNsCreated bool, netNsPath string) error {
// HotDetach for the veth endpoint uses hot pull device
func (endpoint *VethEndpoint) HotDetach(h hypervisor, netNsCreated bool, netNsPath string) error {
if !netNsCreated {
return nil
}

View File

@ -11,10 +11,10 @@ import (
"testing"
)
func TestCreateVirtualNetworkEndpoint(t *testing.T) {
func TestCreateVethNetworkEndpoint(t *testing.T) {
macAddr := net.HardwareAddr{0x02, 0x00, 0xCA, 0xFE, 0x00, 0x04}
expected := &VirtualEndpoint{
expected := &VethEndpoint{
NetPair: NetworkInterfacePair{
ID: "uniqueTestID-4",
Name: "br4_kata",
@ -27,10 +27,10 @@ func TestCreateVirtualNetworkEndpoint(t *testing.T) {
},
NetInterworkingModel: DefaultNetInterworkingModel,
},
EndpointType: VirtualEndpointType,
EndpointType: VethEndpointType,
}
result, err := createVirtualNetworkEndpoint(4, "", DefaultNetInterworkingModel)
result, err := createVethNetworkEndpoint(4, "", DefaultNetInterworkingModel)
if err != nil {
t.Fatal(err)
}
@ -46,10 +46,10 @@ func TestCreateVirtualNetworkEndpoint(t *testing.T) {
}
}
func TestCreateVirtualNetworkEndpointChooseIfaceName(t *testing.T) {
func TestCreateVethNetworkEndpointChooseIfaceName(t *testing.T) {
macAddr := net.HardwareAddr{0x02, 0x00, 0xCA, 0xFE, 0x00, 0x04}
expected := &VirtualEndpoint{
expected := &VethEndpoint{
NetPair: NetworkInterfacePair{
ID: "uniqueTestID-4",
Name: "br4_kata",
@ -62,10 +62,10 @@ func TestCreateVirtualNetworkEndpointChooseIfaceName(t *testing.T) {
},
NetInterworkingModel: DefaultNetInterworkingModel,
},
EndpointType: VirtualEndpointType,
EndpointType: VethEndpointType,
}
result, err := createVirtualNetworkEndpoint(4, "eth1", DefaultNetInterworkingModel)
result, err := createVethNetworkEndpoint(4, "eth1", DefaultNetInterworkingModel)
if err != nil {
t.Fatal(err)
}
@ -81,7 +81,7 @@ func TestCreateVirtualNetworkEndpointChooseIfaceName(t *testing.T) {
}
}
func TestCreateVirtualNetworkEndpointInvalidArgs(t *testing.T) {
func TestCreateVethNetworkEndpointInvalidArgs(t *testing.T) {
type endpointValues struct {
idx int
ifName string
@ -94,7 +94,7 @@ func TestCreateVirtualNetworkEndpointInvalidArgs(t *testing.T) {
}
for _, d := range failingValues {
result, err := createVirtualNetworkEndpoint(d.idx, d.ifName, DefaultNetInterworkingModel)
result, err := createVethNetworkEndpoint(d.idx, d.ifName, DefaultNetInterworkingModel)
if err == nil {
t.Fatalf("expected invalid endpoint for %v, got %v", d, result)
}