@@ -7,11 +7,10 @@ import (
7
7
8
8
configv1alpha2 "github.com/openservicemesh/osm/pkg/apis/config/v1alpha2"
9
9
10
- "github.com/openservicemesh/osm/pkg/configurator"
11
10
"github.com/openservicemesh/osm/pkg/constants"
12
11
)
13
12
14
- func genIPTablesOutboundStaticRules (cfg configurator. Configurator ) []string {
13
+ func genIPTablesOutboundStaticRules (proxyMode configv1alpha2. LocalProxyMode ) []string {
15
14
// iptablesOutboundStaticRules is the list of iptables rules related to outbound traffic interception and redirection
16
15
iptablesOutboundStaticRules := []string {
17
16
// Redirects outbound TCP traffic hitting OSM_PROXY_OUT_REDIRECT chain to Envoy's outbound listener port
@@ -21,9 +20,7 @@ func genIPTablesOutboundStaticRules(cfg configurator.Configurator) []string {
21
20
fmt .Sprintf ("-A OSM_PROXY_OUT_REDIRECT -p tcp --dport %d -j ACCEPT" , constants .EnvoyAdminPort ),
22
21
}
23
22
24
- localProxyMode := cfg .GetMeshConfig ().Spec .Sidecar .LocalProxyMode
25
-
26
- if localProxyMode == configv1alpha2 .LocalProxyModePodIP {
23
+ if proxyMode == configv1alpha2 .LocalProxyModePodIP {
27
24
// For envoy -> local service container proxying, send traffic to pod IP instead of localhost
28
25
iptablesOutboundStaticRules = append (iptablesOutboundStaticRules , fmt .Sprintf ("-A OUTPUT -p tcp -o lo -d 127.0.0.1/32 -m owner --uid-owner %d -j DNAT --to-destination $POD_IP" , constants .EnvoyUID ))
29
26
}
@@ -76,7 +73,7 @@ var iptablesInboundStaticRules = []string{
76
73
}
77
74
78
75
// generateIptablesCommands generates a list of iptables commands to set up sidecar interception and redirection
79
- func generateIptablesCommands (cfg configurator. Configurator , outboundIPRangeExclusionList []string , outboundIPRangeInclusionList []string , outboundPortExclusionList []int , inboundPortExclusionList []int , networkInterfaceExclusionList []string ) string {
76
+ func generateIptablesCommands (proxyMode configv1alpha2. LocalProxyMode , outboundIPRangeExclusionList []string , outboundIPRangeInclusionList []string , outboundPortExclusionList []int , inboundPortExclusionList []int , networkInterfaceExclusionList []string ) string {
80
77
var rules strings.Builder
81
78
82
79
fmt .Fprintln (& rules , `# OSM sidecar interception rules
@@ -108,7 +105,7 @@ func generateIptablesCommands(cfg configurator.Configurator, outboundIPRangeExcl
108
105
cmds = append (cmds , rule )
109
106
}
110
107
111
- iptablesOutboundStaticRules := genIPTablesOutboundStaticRules (cfg )
108
+ iptablesOutboundStaticRules := genIPTablesOutboundStaticRules (proxyMode )
112
109
113
110
// 3. Create outbound rules
114
111
cmds = append (cmds , iptablesOutboundStaticRules ... )
0 commit comments