github.com/looshlee/cilium@v1.6.12/pkg/option/runtime_options.go (about)

     1  // Copyright 2018-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 option
    16  
    17  import (
    18  	"errors"
    19  )
    20  
    21  const (
    22  	PolicyTracing       = "PolicyTracing"
    23  	ConntrackAccounting = "ConntrackAccounting"
    24  	ConntrackLocal      = "ConntrackLocal"
    25  	Conntrack           = "Conntrack"
    26  	Debug               = "Debug"
    27  	DebugLB             = "DebugLB"
    28  	DropNotify          = "DropNotification"
    29  	TraceNotify         = "TraceNotification"
    30  	MonitorAggregation  = "MonitorAggregationLevel"
    31  	NAT46               = "NAT46"
    32  	AlwaysEnforce       = "always"
    33  	NeverEnforce        = "never"
    34  	DefaultEnforcement  = "default"
    35  )
    36  
    37  var (
    38  	ErrNAT46ReqIPv4 = errors.New("NAT46 requires IPv4 to be enabled")
    39  	ErrNAT46ReqIPv6 = errors.New("NAT46 requires IPv6 to be enabled")
    40  	ErrNAT46ReqVeth = errors.New("NAT46 not supported in ipvlan datapath mode")
    41  )
    42  
    43  var (
    44  	specConntrackAccounting = Option{
    45  		Define:      "CONNTRACK_ACCOUNTING",
    46  		Description: "Enable per flow (conntrack) statistics",
    47  		Requires:    []string{Conntrack},
    48  	}
    49  
    50  	specConntrackLocal = Option{
    51  		Define:      "CONNTRACK_LOCAL",
    52  		Description: "Use endpoint dedicated tracking table instead of global one",
    53  		Requires:    []string{Conntrack},
    54  	}
    55  
    56  	specConntrack = Option{
    57  		Define:      "CONNTRACK",
    58  		Description: "Enable stateful connection tracking",
    59  	}
    60  
    61  	specDebug = Option{
    62  		Define:      "DEBUG",
    63  		Description: "Enable debugging trace statements",
    64  	}
    65  
    66  	specDebugLB = Option{
    67  		Define:      "LB_DEBUG",
    68  		Description: "Enable debugging trace statements for load balancer",
    69  	}
    70  
    71  	specDropNotify = Option{
    72  		Define:      "DROP_NOTIFY",
    73  		Description: "Enable drop notifications",
    74  	}
    75  
    76  	specTraceNotify = Option{
    77  		Define:      "TRACE_NOTIFY",
    78  		Description: "Enable trace notifications",
    79  	}
    80  
    81  	specMonitorAggregation = Option{
    82  		Define:      "MONITOR_AGGREGATION",
    83  		Description: "Set the level of aggregation for monitor events in the datapath",
    84  		Verify:      VerifyMonitorAggregationLevel,
    85  		Parse:       ParseMonitorAggregationLevel,
    86  		Format:      FormatMonitorAggregationLevel,
    87  	}
    88  
    89  	specNAT46 = Option{
    90  		Define:      "ENABLE_NAT46",
    91  		Description: "Enable automatic NAT46 translation",
    92  		Requires:    []string{Conntrack},
    93  		Verify: func(key string, val string) error {
    94  			opt, err := NormalizeBool(val)
    95  			if err != nil {
    96  				return err
    97  			}
    98  			if opt == OptionEnabled {
    99  				if !Config.EnableIPv4 {
   100  					return ErrNAT46ReqIPv4
   101  				}
   102  				if !Config.EnableIPv6 {
   103  					return ErrNAT46ReqIPv6
   104  				}
   105  				if Config.DatapathMode == DatapathModeIpvlan {
   106  					return ErrNAT46ReqVeth
   107  				}
   108  			}
   109  			return nil
   110  		},
   111  	}
   112  )