github.com/looshlee/beatles@v0.0.0-20220727174639-742810ab631c/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  	IPv4Address() addressing.CiliumIPv4
    51  	IPv6Address() addressing.CiliumIPv6
    52  	GetNodeMAC() mac.MAC
    53  
    54  	// TODO: Move this detail into the datapath
    55  	HasIpvlanDataPath() bool
    56  	ConntrackLocalLocked() bool
    57  
    58  	// RequireARPPassthrough returns true if the datapath must implement
    59  	// ARP passthrough for this endpoint
    60  	RequireARPPassthrough() bool
    61  
    62  	// RequireEgressProg returns true if the endpoint requires an egress
    63  	// program attached to the InterfaceName() invoking the section
    64  	// "to-container"
    65  	RequireEgressProg() bool
    66  
    67  	// RequireRouting returns true if the endpoint requires BPF routing to
    68  	// be enabled, when disabled, routing is delegated to Linux routing
    69  	RequireRouting() bool
    70  
    71  	// RequireEndpointRoute returns true if the endpoint wishes to have a
    72  	// per endpoint route installed in the host's routing table to point to
    73  	// the endpoint's interface
    74  	RequireEndpointRoute() bool
    75  }