istio
180 строк · 5.3 Кб
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
15package constants16
17import (18"time"19
20"istio.io/istio/pkg/env"21)
22
23// iptables tables
24const (25MANGLE = "mangle"26NAT = "nat"27FILTER = "filter"28RAW = "raw"29)
30
31// Built-in iptables chains
32const (33INPUT = "INPUT"34OUTPUT = "OUTPUT"35FORWARD = "FORWARD"36PREROUTING = "PREROUTING"37POSTROUTING = "POSTROUTING"38)
39
40var BuiltInChainsMap = map[string]struct{}{41INPUT: {},42OUTPUT: {},43FORWARD: {},44PREROUTING: {},45POSTROUTING: {},46}
47
48// Constants used for generating iptables commands
49const (50TCP = "tcp"51UDP = "udp"52
53TPROXY = "TPROXY"54RETURN = "RETURN"55ACCEPT = "ACCEPT"56REJECT = "REJECT"57REDIRECT = "REDIRECT"58MARK = "MARK"59CT = "CT"60DROP = "DROP"61)
62
63const (64// IPVersionSpecific is used as an input to rules that will be replaced with an ip version (v4/v6)65// specific value66IPVersionSpecific = "PLACEHOLDER_IP_VERSION_SPECIFIC"67)
68
69// iptables chains
70const (71ISTIOOUTPUT = "ISTIO_OUTPUT"72ISTIOINBOUND = "ISTIO_INBOUND"73ISTIODIVERT = "ISTIO_DIVERT"74ISTIOTPROXY = "ISTIO_TPROXY"75ISTIOREDIRECT = "ISTIO_REDIRECT"76ISTIOINREDIRECT = "ISTIO_IN_REDIRECT"77)
78
79// Constants used in cobra/viper CLI
80const (81InboundInterceptionMode = "istio-inbound-interception-mode"82InboundTProxyMark = "istio-inbound-tproxy-mark"83InboundTProxyRouteTable = "istio-inbound-tproxy-route-table"84InboundPorts = "istio-inbound-ports"85LocalExcludePorts = "istio-local-exclude-ports"86ExcludeInterfaces = "istio-exclude-interfaces"87ServiceCidr = "istio-service-cidr"88ServiceExcludeCidr = "istio-service-exclude-cidr"89OutboundPorts = "istio-outbound-ports"90LocalOutboundPortsExclude = "istio-local-outbound-ports-exclude"91EnvoyPort = "envoy-port"92InboundCapturePort = "inbound-capture-port"93InboundTunnelPort = "inbound-tunnel-port"94ProxyUID = "proxy-uid"95ProxyGID = "proxy-gid"96KubeVirtInterfaces = "kube-virt-interfaces"97DryRun = "dry-run"98TraceLogging = "iptables-trace-logging"99RestoreFormat = "restore-format"100SkipRuleApply = "skip-rule-apply"101RunValidation = "run-validation"102IptablesProbePort = "iptables-probe-port"103ProbeTimeout = "probe-timeout"104RedirectDNS = "redirect-dns"105DropInvalid = "drop-invalid"106DualStack = "dual-stack"107CaptureAllDNS = "capture-all-dns"108NetworkNamespace = "network-namespace"109CNIMode = "cni-mode"110IptablesVersion = "iptables-version"111)
112
113// Environment variables that deliberately have no equivalent command-line flags.
114//
115// The variables are defined as env.Var for documentation purposes.
116//
117// Use viper to resolve the value of the environment variable.
118var (119HostIPv4LoopbackCidr = env.Register("ISTIO_OUTBOUND_IPV4_LOOPBACK_CIDR", "127.0.0.1/32",120`IPv4 CIDR range used to identify outbound traffic on loopback interface intended for application container`)121
122OwnerGroupsInclude = env.Register("ISTIO_OUTBOUND_OWNER_GROUPS", "*",123`Comma separated list of groups whose outgoing traffic is to be redirected to Envoy.124A group can be specified either by name or by a numeric GID.
125The wildcard character "*" can be used to configure redirection of traffic from all groups.`)126
127OwnerGroupsExclude = env.Register("ISTIO_OUTBOUND_OWNER_GROUPS_EXCLUDE", "",128`Comma separated list of groups whose outgoing traffic is to be excluded from redirection to Envoy.129A group can be specified either by name or by a numeric GID.
130Only applies when traffic from all groups (i.e. "*") is being redirected to Envoy.`)131
132IstioInboundInterceptionMode = env.Register("INBOUND_INTERCEPTION_MODE", "",133`The mode used to redirect inbound connections to Envoy, either "REDIRECT" or "TPROXY"`)134
135IstioInboundTproxyMark = env.Register("INBOUND_TPROXY_MARK", "",136``)137)
138
139const (140DefaultProxyUID = "1337"141DefaultProxyUIDInt = int64(1337)142)
143
144// Constants used in environment variables
145const (146EnvoyUser = "ENVOY_USER"147)
148
149// Constants for syscall
150const (151// sys/socket.h152SoOriginalDst = 80153)
154
155const (156DefaultIptablesProbePort = "15002"157DefaultIptablesProbePortUint = 15002158DefaultProbeTimeout = 5 * time.Second159)
160
161const (162ValidationContainerName = "istio-validation"163ValidationErrorCode = 126164)
165
166// DNS ports
167const (168IstioAgentDNSListenerPort = "15053"169)
170
171// type of iptables operation/command to run, as an enum
172// the implementation will choose the correct underlying binary,
173// so callers should just use these enums to indicate what they want to do.
174type IptablesCmd int175
176const (177IPTables IptablesCmd = iota178IPTablesSave IptablesCmd = iota179IPTablesRestore IptablesCmd = iota180)
181