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