github.com/elfadel/cilium@v1.6.12/pkg/datapath/datapath.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 "io" 19 ) 20 21 // Datapath is the interface to abstract all datapath interactions. The 22 // abstraction allows to implement the datapath requirements with multiple 23 // implementations 24 type Datapath interface { 25 // Node must return the handler for node events 26 Node() NodeHandler 27 28 // LocalNodeAddressing must return the node addressing implementation 29 // of the local node 30 LocalNodeAddressing() NodeAddressing 31 32 // WriteNodeConfig writes the implementation-specific configuration of 33 // node-wide options into the specified writer. 34 WriteNodeConfig(io.Writer, *LocalNodeConfiguration) error 35 36 // WriteNetdevConfig writes the implementation-specific configuration 37 // of configurable options to the specified writer. Options specified 38 // here will apply to base programs and not to endpoints, though 39 // endpoints may have equivalent configurable options. 40 WriteNetdevConfig(io.Writer, DeviceConfiguration) error 41 42 // WriteTemplateConfig writes the implementation-specific configuration 43 // of configurable options for BPF templates to the specified writer. 44 WriteTemplateConfig(w io.Writer, cfg EndpointConfiguration) error 45 46 // WriteEndpointConfig writes the implementation-specific configuration 47 // of configurable options for the endpoint to the specified writer. 48 WriteEndpointConfig(w io.Writer, cfg EndpointConfiguration) error 49 50 // InstallProxyRules creates the necessary datapath config (e.g., iptables 51 // rules for redirecting host proxy traffic on a specific ProxyPort) 52 InstallProxyRules(proxyPort uint16, ingress bool, name string) error 53 54 // RemoveProxyRules creates the necessary datapath config (e.g., iptables 55 // rules for redirecting host proxy traffic on a specific ProxyPort) 56 RemoveProxyRules(proxyPort uint16, ingress bool, name string) error 57 58 // SupportsOriginalSourceAddr tells if the datapath supports 59 // use of original source addresses in proxy upstream 60 // connections. 61 SupportsOriginalSourceAddr() bool 62 }