github.com/noironetworks/cilium-net@v1.6.12/pkg/datapath/config.go (about)

     1  // Copyright 2019 Authors of Cilium
     2  //
     3  // Licensed under the Apache License, Version 2.0 (the "License");
     4  // you may not use this file except in compliance with the License.
     5  // You may obtain a copy of the License at
     6  //
     7  //     http://www.apache.org/licenses/LICENSE-2.0
     8  //
     9  // Unless required by applicable law or agreed to in writing, software
    10  // distributed under the License is distributed on an "AS IS" BASIS,
    11  // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    12  // See the License for the specific language governing permissions and
    13  // limitations under the License.
    14  
    15  package datapath
    16  
    17  import (
    18  	"github.com/cilium/cilium/common/addressing"
    19  	"github.com/cilium/cilium/pkg/identity"
    20  	"github.com/cilium/cilium/pkg/mac"
    21  	"github.com/cilium/cilium/pkg/option"
    22  )
    23  
    24  // DeviceConfiguration is an interface for injecting configuration of datapath
    25  // options that affect lookups and logic applied at a per-device level, whether
    26  // those are devices associated with the endpoint or associated with the host.
    27  type DeviceConfiguration interface {
    28  	// GetCIDRPrefixLengths fetches the lists of unique IPv6 and IPv4
    29  	// prefix lengths used for datapath lookups, each of which is sorted
    30  	// from longest prefix to shortest prefix. It must return more than
    31  	// one element in each returned array.
    32  	GetCIDRPrefixLengths() (s6, s4 []int)
    33  
    34  	// GetOptions fetches the configurable datapath options from the owner.
    35  	GetOptions() *option.IntOptions
    36  }
    37  
    38  // EndpointConfiguration provides datapath implementations a clean interface
    39  // to access endpoint-specific configuration when configuring the datapath.
    40  type EndpointConfiguration interface {
    41  	DeviceConfiguration
    42  
    43  	// GetID returns a locally-significant endpoint identification number.
    44  	GetID() uint64
    45  	// StringID returns the string-formatted version of the ID from GetID().
    46  	StringID() string
    47  	// GetIdentity returns a globally-significant numeric security identity.
    48  	GetIdentity() identity.NumericIdentity
    49  
    50  	// GetIdentityLocked returns a globally-significant numeric security
    51  	// identity while assuming that the backing data structure is locked.
    52  	// This function should be removed in favour of GetIdentity()
    53  	GetIdentityLocked() identity.NumericIdentity
    54  
    55  	IPv4Address() addressing.CiliumIPv4
    56  	IPv6Address() addressing.CiliumIPv6
    57  	GetNodeMAC() mac.MAC
    58  
    59  	// TODO: Move this detail into the datapath
    60  	HasIpvlanDataPath() bool
    61  	ConntrackLocalLocked() bool
    62  
    63  	// RequireARPPassthrough returns true if the datapath must implement
    64  	// ARP passthrough for this endpoint
    65  	RequireARPPassthrough() bool
    66  
    67  	// RequireEgressProg returns true if the endpoint requires an egress
    68  	// program attached to the InterfaceName() invoking the section
    69  	// "to-container"
    70  	RequireEgressProg() bool
    71  
    72  	// RequireRouting returns true if the endpoint requires BPF routing to
    73  	// be enabled, when disabled, routing is delegated to Linux routing
    74  	RequireRouting() bool
    75  
    76  	// RequireEndpointRoute returns true if the endpoint wishes to have a
    77  	// per endpoint route installed in the host's routing table to point to
    78  	// the endpoint's interface
    79  	RequireEndpointRoute() bool
    80  }