Skip to content

Commit f4603d9

Browse files
committed
add felixConfiguration attr: DisableHostSubnetNATExclusion
1 parent 8b49cb1 commit f4603d9

19 files changed

+96
-7
lines changed

api/pkg/apis/projectcalico/v3/felixconfig.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -396,6 +396,10 @@ type FelixConfigurationSpec struct {
396396
// (ie it uses the iptables MASQUERADE target)
397397
NATOutgoingAddress string `json:"natOutgoingAddress,omitempty"`
398398

399+
// When set to true and ip pool setting `natOutgoing` is true, packets sent from Calico networked containers in this pool
400+
// to cluster host subnet will not be excluded from being masqueraded. [Default: false]
401+
DisableHostSubnetNATExclusion bool `json:"disableHostSubnetNATExclusion,omitempty"`
402+
399403
// This is the IPv4 source address to use on programmed device routes. By default the source address is left blank,
400404
// leaving the kernel to choose the source address used.
401405
DeviceRouteSourceAddress string `json:"deviceRouteSourceAddress,omitempty"`

api/pkg/openapi/openapi_generated.go

Lines changed: 7 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

calicoctl/calicoctl/commands/crds/crds.go

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

felix/config/config_params.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -358,9 +358,10 @@ type Config struct {
358358
FailsafeInboundHostPorts []ProtoPort `config:"port-list;tcp:22,udp:68,tcp:179,tcp:2379,tcp:2380,tcp:5473,tcp:6443,tcp:6666,tcp:6667;die-on-fail"`
359359
FailsafeOutboundHostPorts []ProtoPort `config:"port-list;udp:53,udp:67,tcp:179,tcp:2379,tcp:2380,tcp:5473,tcp:6443,tcp:6666,tcp:6667;die-on-fail"`
360360

361-
KubeNodePortRanges []numorstring.Port `config:"portrange-list;30000:32767"`
362-
NATPortRange numorstring.Port `config:"portrange;"`
363-
NATOutgoingAddress net.IP `config:"ipv4;"`
361+
KubeNodePortRanges []numorstring.Port `config:"portrange-list;30000:32767"`
362+
NATPortRange numorstring.Port `config:"portrange;"`
363+
NATOutgoingAddress net.IP `config:"ipv4;"`
364+
DisableHostSubnetNATExclusion bool `config:"bool;false"`
364365

365366
UsageReportingEnabled bool `config:"bool;true"`
366367
UsageReportingInitialDelaySecs time.Duration `config:"seconds;300"`

felix/dataplane/driver.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -277,6 +277,7 @@ func StartDataplaneDriver(configParams *config.Config,
277277
NATPortRange: configParams.NATPortRange,
278278
IptablesNATOutgoingInterfaceFilter: configParams.IptablesNATOutgoingInterfaceFilter,
279279
NATOutgoingAddress: configParams.NATOutgoingAddress,
280+
DisableHostSubnetNATExclusion: configParams.DisableHostSubnetNATExclusion,
280281
BPFEnabled: configParams.BPFEnabled,
281282
BPFForceTrackPacketsFromIfaces: replaceWildcards(configParams.NFTablesMode == "Enabled", configParams.BPFForceTrackPacketsFromIfaces),
282283
ServiceLoopPrevention: configParams.ServiceLoopPrevention,

felix/rules/nat.go

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,13 +52,16 @@ func (r *DefaultRuleRenderer) makeNATOutgoingRuleBPF(version uint8, protocol str
5252
func (r *DefaultRuleRenderer) makeNATOutgoingRuleIPTables(ipVersion uint8, protocol string, action Action) Rule {
5353
ipConf := r.ipSetConfig(ipVersion)
5454
allIPsSetName := ipConf.NameForMainIPSet(IPSetIDNATOutgoingAllPools)
55-
allHostsIPsSetName := ipConf.NameForMainIPSet(IPSetIDAllHostNets)
5655
masqIPsSetName := ipConf.NameForMainIPSet(IPSetIDNATOutgoingMasqPools)
5756

5857
match := r.NewMatch().
5958
SourceIPSet(masqIPsSetName).
60-
NotDestIPSet(allIPsSetName).
61-
NotDestIPSet(allHostsIPsSetName)
59+
NotDestIPSet(allIPsSetName)
60+
61+
if !r.Config.DisableHostSubnetNATExclusion {
62+
allHostsIPsSetName := ipConf.NameForMainIPSet(IPSetIDAllHostNets)
63+
match = match.NotDestIPSet(allHostsIPsSetName)
64+
}
6265

6366
if protocol != "" {
6467
match = match.Protocol(protocol)

felix/rules/rule_defs.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -355,6 +355,7 @@ type Config struct {
355355
IptablesNATOutgoingInterfaceFilter string
356356

357357
NATOutgoingAddress net.IP
358+
DisableHostSubnetNATExclusion bool
358359
BPFEnabled bool
359360
BPFForceTrackPacketsFromIfaces []string
360361
ServiceLoopPrevention string

libcalico-go/config/crd/crd.projectcalico.org_felixconfigurations.yaml

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

manifests/calico-bpf.yaml

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

manifests/calico-policy-only.yaml

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

manifests/calico-typha.yaml

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

manifests/calico-vxlan.yaml

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

manifests/calico.yaml

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

manifests/canal.yaml

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

manifests/crds.yaml

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

manifests/flannel-migration/calico.yaml

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

manifests/ocp/crd.projectcalico.org_felixconfigurations.yaml

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

manifests/operator-crds.yaml

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

manifests/tigera-operator.yaml

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)