github.com/kata-containers/runtime@v0.0.0-20210505125100-04f29832a923/virtcontainers/persist/api/network.go (about) 1 // Copyright (c) 2016 Intel Corporation 2 // Copyright (c) 2019 Huawei Corporation 3 // 4 // SPDX-License-Identifier: Apache-2.0 5 // 6 7 package persistapi 8 9 import ( 10 vcTypes "github.com/kata-containers/runtime/virtcontainers/pkg/types" 11 "github.com/vishvananda/netlink" 12 ) 13 14 // ============= sandbox level resources ============= 15 16 type NetworkInterface struct { 17 Name string 18 HardAddr string 19 Addrs []netlink.Addr 20 } 21 22 // TapInterface defines a tap interface 23 type TapInterface struct { 24 ID string 25 Name string 26 TAPIface NetworkInterface 27 // remove VMFds and VhostFds 28 } 29 30 // TuntapInterface defines a tap interface 31 type TuntapInterface struct { 32 Name string 33 TAPIface NetworkInterface 34 } 35 36 // NetworkInterfacePair defines a pair between VM and virtual network interfaces. 37 type NetworkInterfacePair struct { 38 TapInterface 39 VirtIface NetworkInterface 40 NetInterworkingModel int 41 } 42 43 type PhysicalEndpoint struct { 44 BDF string 45 Driver string 46 VendorDeviceID string 47 } 48 49 type MacvtapEndpoint struct { 50 // This is for showing information. 51 // Remove this field won't impact anything. 52 PCIPath vcTypes.PciPath 53 } 54 55 type TapEndpoint struct { 56 TapInterface TapInterface 57 } 58 59 type TuntapEndpoint struct { 60 TuntapInterface TuntapInterface 61 } 62 63 type BridgedMacvlanEndpoint struct { 64 NetPair NetworkInterfacePair 65 } 66 67 type VethEndpoint struct { 68 NetPair NetworkInterfacePair 69 } 70 71 type IPVlanEndpoint struct { 72 NetPair NetworkInterfacePair 73 } 74 75 type VhostUserEndpoint struct { 76 // This is for showing information. 77 // Remove these fields won't impact anything. 78 IfaceName string 79 PCIPath vcTypes.PciPath 80 } 81 82 // NetworkEndpoint contains network interface information 83 type NetworkEndpoint struct { 84 Type string 85 86 // One and only one of these below are not nil according to Type. 87 Physical *PhysicalEndpoint `json:",omitempty"` 88 Veth *VethEndpoint `json:",omitempty"` 89 VhostUser *VhostUserEndpoint `json:",omitempty"` 90 BridgedMacvlan *BridgedMacvlanEndpoint `json:",omitempty"` 91 Macvtap *MacvtapEndpoint `json:",omitempty"` 92 Tap *TapEndpoint `json:",omitempty"` 93 IPVlan *IPVlanEndpoint `json:",omitempty"` 94 Tuntap *TuntapEndpoint `json:",omitempty"` 95 } 96 97 // NetworkInfo contains network information of sandbox 98 type NetworkInfo struct { 99 NetNsPath string 100 NetmonPID int 101 NetNsCreated bool 102 Endpoints []NetworkEndpoint 103 }