{
“device”:”tap1”,
“name”:”eth1”,
“IPAddresses”:[{“address”:”172.17.1.10”,”mask”:”24”}],
“mtu”:1300,
“hwAddr”:”02:42:20:6f:a2:80”
“vhostUserSocket”:”/usr/local/var/run/openvswitch/vhost-user1”
}
root@ubuntu:# cat kata_add_tap.json
{
"device": "veth-test",
"name": "eth-test",
"IPAddresses": [
{
"address": "172.17.0.3",
"mask": "16"
}
],
"hwAddr":"02:42:20:6f:a3:69",
"mtu": 1500
}
root@ubuntu:# kata-runtime kata-network add-iface d5f9427e83fd374e12125fb442942931fdf08c949f68e9c027592d048526b0cb kata_add_tap.json
null
Unsupported network interface:
// tap interface/bridge if it is.
isPhysical, err := isPhysicalIface(netInfo.Iface.Name)
if err != nil {
return nil, err
}
if isPhysical {
networkLogger().WithField("interface", netInfo.Iface.Name).Info("Physical network interface found")
endpoint, err = createPhysicalEndpoint(netInfo)
} else {
var socketPath string
// Check if this is a dummy interface which has a vhost-user socket associated with it
socketPath, err = vhostUserSocketPath(netInfo)
if err != nil {
return nil, err
}
networkLogger().WithField("interface", netInfo.Iface.Name).WithField("Type", netInfo.Iface.Type).Info("network info")
networkLogger().WithField("addr", netInfo.Iface.HardwareAddr).Info("network info")
if socketPath != "" {
networkLogger().WithField("interface", netInfo.Iface.Name).Info("VhostUser network interface found")
endpoint, err = createVhostUserEndpoint(netInfo, socketPath)
} else if netInfo.Iface.Type == "macvlan" {
networkLogger().Infof("macvlan interface found")
endpoint, err = createBridgedMacvlanNetworkEndpoint(idx, netInfo.Iface.Name, model)
} else if netInfo.Iface.Type == "macvtap" {
networkLogger().Infof("macvtap interface found")
endpoint, err = createMacvtapNetworkEndpoint(netInfo)
} else if netInfo.Iface.Type == "tap" {
networkLogger().Info("tap interface found")
endpoint, err = createTapNetworkEndpoint(idx, netInfo.Iface.Name)
} else if netInfo.Iface.Type == "tuntap" {
if link != nil {
switch link.(*netlink.Tuntap).Mode {
case 0:
// mount /sys/class/net to get links
return nil, fmt.Errorf("Network device mode not determined correctly. Mount sysfs in caller")
case 1:
return nil, fmt.Errorf("tun networking device not yet supported")
case 2:
networkLogger().Info("tuntap tap interface found")
endpoint, err = createTuntapNetworkEndpoint(idx, netInfo.Iface.Name, netInfo.Iface.HardwareAddr, model)
default:
return nil, fmt.Errorf("tuntap network %v mode unsupported", link.(*netlink.Tuntap).Mode)
}
}
} else if netInfo.Iface.Type == "veth" {
endpoint, err = createVethNetworkEndpoint(idx, netInfo.Iface.Name, model)
} else if netInfo.Iface.Type == "ipvlan" {
endpoint, err = createIPVlanNetworkEndpoint(idx, netInfo.Iface.Name)
} else {
return nil, fmt.Errorf("Unsupported network interface: %s", netInfo.Iface.Type)
}
}
return endpoint, err
}