github.com/adityamillind98/moby@v23.0.0-rc.4+incompatible/libnetwork/drivers/ipvlan/ipvlan.go (about)

     1  //go:build linux
     2  // +build linux
     3  
     4  package ipvlan
     5  
     6  import (
     7  	"net"
     8  	"sync"
     9  
    10  	"github.com/docker/docker/libnetwork/datastore"
    11  	"github.com/docker/docker/libnetwork/discoverapi"
    12  	"github.com/docker/docker/libnetwork/driverapi"
    13  	"github.com/docker/docker/libnetwork/types"
    14  )
    15  
    16  const (
    17  	vethLen             = 7
    18  	containerVethPrefix = "eth"
    19  	vethPrefix          = "veth"
    20  
    21  	ipvlanType    = "ipvlan"             // driver type name
    22  	parentOpt     = "parent"             // parent interface -o parent
    23  	driverModeOpt = ipvlanType + "_mode" // mode -o ipvlan_mode
    24  	driverFlagOpt = ipvlanType + "_flag" // flag -o ipvlan_flag
    25  
    26  	modeL2  = "l2"  // ipvlan L2 mode (default)
    27  	modeL3  = "l3"  // ipvlan L3 mode
    28  	modeL3S = "l3s" // ipvlan L3S mode
    29  
    30  	flagBridge  = "bridge"  // ipvlan flag bridge (default)
    31  	flagPrivate = "private" // ipvlan flag private
    32  	flagVepa    = "vepa"    // ipvlan flag vepa
    33  )
    34  
    35  type endpointTable map[string]*endpoint
    36  
    37  type networkTable map[string]*network
    38  
    39  type driver struct {
    40  	networks networkTable
    41  	sync.Once
    42  	sync.Mutex
    43  	store datastore.DataStore
    44  }
    45  
    46  type endpoint struct {
    47  	id       string
    48  	nid      string
    49  	mac      net.HardwareAddr
    50  	addr     *net.IPNet
    51  	addrv6   *net.IPNet
    52  	srcName  string
    53  	dbIndex  uint64
    54  	dbExists bool
    55  }
    56  
    57  type network struct {
    58  	id        string
    59  	endpoints endpointTable
    60  	driver    *driver
    61  	config    *configuration
    62  	sync.Mutex
    63  }
    64  
    65  // Init initializes and registers the libnetwork ipvlan driver
    66  func Init(dc driverapi.DriverCallback, config map[string]interface{}) error {
    67  	c := driverapi.Capability{
    68  		DataScope:         datastore.LocalScope,
    69  		ConnectivityScope: datastore.GlobalScope,
    70  	}
    71  	d := &driver{
    72  		networks: networkTable{},
    73  	}
    74  	if err := d.initStore(config); err != nil {
    75  		return err
    76  	}
    77  
    78  	return dc.RegisterDriver(ipvlanType, d, c)
    79  }
    80  
    81  func (d *driver) NetworkAllocate(id string, option map[string]string, ipV4Data, ipV6Data []driverapi.IPAMData) (map[string]string, error) {
    82  	return nil, types.NotImplementedErrorf("not implemented")
    83  }
    84  
    85  func (d *driver) NetworkFree(id string) error {
    86  	return types.NotImplementedErrorf("not implemented")
    87  }
    88  
    89  func (d *driver) EndpointOperInfo(nid, eid string) (map[string]interface{}, error) {
    90  	return make(map[string]interface{}), nil
    91  }
    92  
    93  func (d *driver) Type() string {
    94  	return ipvlanType
    95  }
    96  
    97  func (d *driver) IsBuiltIn() bool {
    98  	return true
    99  }
   100  
   101  func (d *driver) ProgramExternalConnectivity(nid, eid string, options map[string]interface{}) error {
   102  	return nil
   103  }
   104  
   105  func (d *driver) RevokeExternalConnectivity(nid, eid string) error {
   106  	return nil
   107  }
   108  
   109  // DiscoverNew is a notification for a new discovery event.
   110  func (d *driver) DiscoverNew(dType discoverapi.DiscoveryType, data interface{}) error {
   111  	return nil
   112  }
   113  
   114  // DiscoverDelete is a notification for a discovery delete event.
   115  func (d *driver) DiscoverDelete(dType discoverapi.DiscoveryType, data interface{}) error {
   116  	return nil
   117  }
   118  
   119  func (d *driver) EventNotify(etype driverapi.EventType, nid, tableName, key string, value []byte) {
   120  }
   121  
   122  func (d *driver) DecodeTableEntry(tablename string, key string, value []byte) (string, map[string]string) {
   123  	return "", nil
   124  }