istio.io/istio@v0.0.0-20240520182934-d79c90f27776/cni/pkg/iptables/nldeps.go (about)

     1  // Copyright Istio Authors
     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 iptables
    16  
    17  type NetlinkDependencies interface {
    18  	AddInpodMarkIPRule(cfg *Config) error
    19  	DelInpodMarkIPRule(cfg *Config) error
    20  	AddLoopbackRoutes(cfg *Config) error
    21  	DelLoopbackRoutes(cfg *Config) error
    22  }
    23  
    24  func RealNlDeps() NetlinkDependencies {
    25  	return &realDeps{}
    26  }
    27  
    28  type realDeps struct{}
    29  
    30  func (r *realDeps) AddInpodMarkIPRule(cfg *Config) error {
    31  	return AddInpodMarkIPRule(cfg)
    32  }
    33  
    34  func (r *realDeps) DelInpodMarkIPRule(cfg *Config) error {
    35  	return DelInpodMarkIPRule(cfg)
    36  }
    37  
    38  func (r *realDeps) AddLoopbackRoutes(cfg *Config) error {
    39  	return AddLoopbackRoutes(cfg)
    40  }
    41  
    42  func (r *realDeps) DelLoopbackRoutes(cfg *Config) error {
    43  	return DelLoopbackRoutes(cfg)
    44  }
    45  
    46  type emptyDeps struct{}
    47  
    48  func EmptyNlDeps() NetlinkDependencies {
    49  	return &emptyDeps{}
    50  }
    51  
    52  func (r *emptyDeps) AddInpodMarkIPRule(cfg *Config) error {
    53  	return nil
    54  }
    55  
    56  func (r *emptyDeps) DelInpodMarkIPRule(cfg *Config) error {
    57  	return nil
    58  }
    59  
    60  func (r *emptyDeps) AddLoopbackRoutes(cfg *Config) error {
    61  	return nil
    62  }
    63  
    64  func (r *emptyDeps) DelLoopbackRoutes(cfg *Config) error {
    65  	return nil
    66  }