Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions cni/network/network.go
Original file line number Diff line number Diff line change
Expand Up @@ -1101,7 +1101,6 @@ func determineSnat() (bool, bool, error) {
log.Errorf("[cni-net] failed to unmarshal to snatConfig with error %v",
retrieveSnatConfigErr)
}

}

// If we weren't able to retrieve snatConfiguration, query NMAgent
Expand All @@ -1127,7 +1126,7 @@ func determineSnat() (bool, bool, error) {
fp.Write(jsonStr)
fp.Close()
} else {
log.Printf("[cni-net] failed to save snatConfig")
log.Errorf("[cni-net] failed to save snat settings to %s with error: %+v", snatConfigFile, err)
}
}
} else {
Expand All @@ -1143,7 +1142,14 @@ func determineSnat() (bool, bool, error) {
return snatConfig.EnableSnatForDns, snatConfig.EnableSnatOnHost, retrieveSnatConfigErr
}

log.Printf("[cni-net] EnableSnatOnHost set to %t; EnableSnatForDns set to %t", snatConfig.EnableSnatOnHost, snatConfig.EnableSnatForDns)
log.Printf("[cni-net] saved snat settings %+v to %s", snatConfig, snatConfigFile)
if snatConfig.EnableSnatOnHost {
log.Printf("[cni-net] enabling SNAT on container host for outbound connectivity")
} else if snatConfig.EnableSnatForDns {
log.Printf("[cni-net] enabling SNAT on container host for DNS traffic")
} else {
log.Printf("[cni-net] disabling SNAT on container host")
}

return snatConfig.EnableSnatForDns, snatConfig.EnableSnatOnHost, nil
}
8 changes: 6 additions & 2 deletions network/policy/policy_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -353,10 +353,12 @@ func GetHcnEndpointPolicies(policyType CNIPolicyType, policies []Policy, epInfoD
if policy.Type == policyType {
var err error
var endpointPolicy hcn.EndpointPolicy
var isOutboundNatPolicy bool

switch GetPolicyType(policy) {
case OutBoundNatPolicy:
endpointPolicy, err = GetHcnOutBoundNATPolicy(policy, epInfoData)
isOutboundNatPolicy = true
case RoutePolicy:
endpointPolicy, err = GetHcnRoutePolicy(policy)
case PortMappingPolicy:
Expand All @@ -371,8 +373,10 @@ func GetHcnEndpointPolicies(policyType CNIPolicyType, policies []Policy, epInfoD
return hcnEndPointPolicies, err
}

hcnEndPointPolicies = append(hcnEndPointPolicies, endpointPolicy)
log.Printf("Successfully set the policy: %+v", endpointPolicy)
if !(isOutboundNatPolicy && enableMultiTenancy && !enableSnatForDns) {
hcnEndPointPolicies = append(hcnEndPointPolicies, endpointPolicy)
log.Printf("Successfully set the policy: %+v", endpointPolicy)
}
}
}

Expand Down