Skip to content

Commit 70d5364

Browse files
committed
update ipip manager
1 parent 5f808f9 commit 70d5364

File tree

10 files changed

+981
-316
lines changed

10 files changed

+981
-316
lines changed

felix/calc/calc_graph.go

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright (c) 2016-2021 Tigera, Inc. All rights reserved.
1+
// Copyright (c) 2016-2024 Tigera, Inc. All rights reserved.
22

33
// Licensed under the Apache License, Version 2.0 (the "License");
44
// you may not use this file except in compliance with the License.
@@ -378,7 +378,8 @@ func NewCalculationGraph(callbacks PipelineCallbacks, conf *config.Config, liveC
378378
hostIPPassthru.RegisterWith(allUpdDispatcher)
379379
cg.hostIPPassthru = hostIPPassthru
380380

381-
if conf.BPFEnabled || conf.Encapsulation.VXLANEnabled || conf.Encapsulation.VXLANEnabledV6 || conf.WireguardEnabled || conf.WireguardEnabledV6 {
381+
if conf.BPFEnabled || conf.Encapsulation.VXLANEnabled || conf.Encapsulation.VXLANEnabledV6 ||
382+
conf.WireguardEnabled || conf.WireguardEnabledV6 || conf.Encapsulation.IPIPEnabled {
382383
// Calculate simple node-ownership routes.
383384
// ...
384385
// Dispatcher (all updates)

felix/dataplane/linux/int_dataplane.go

+25-3
Original file line numberDiff line numberDiff line change
@@ -287,6 +287,7 @@ type InternalDataplane struct {
287287
ipSets []common.IPSetsDataplane
288288

289289
ipipManager *ipipManager
290+
ipipParentC chan string
290291

291292
vxlanManager *vxlanManager
292293
vxlanParentC chan string
@@ -806,10 +807,29 @@ func NewIntDataplaneDriver(config Config) *InternalDataplane {
806807
dp.RegisterManager(newFloatingIPManager(natTableV4, ruleRenderer, 4, config.FloatingIPsEnabled))
807808
dp.RegisterManager(newMasqManager(ipSetsV4, natTableV4, ruleRenderer, config.MaxIPSetSize, 4))
808809
if config.RulesConfig.IPIPEnabled {
810+
var routeTableIPIP routetable.RouteTableInterface
811+
if !config.RouteSyncDisabled {
812+
log.Debug("RouteSyncDisabled is false.")
813+
routeTableIPIP = routetable.New([]string{"^" + IPIPIfaceName + "$"}, 4, config.NetlinkTimeout,
814+
config.DeviceRouteSourceAddress, config.DeviceRouteProtocol, true, unix.RT_TABLE_MAIN,
815+
dp.loopSummarizer, featureDetector, routetable.WithLivenessCB(dp.reportHealth))
816+
} else {
817+
log.Info("RouteSyncDisabled is true, using DummyTable.")
818+
routeTableIPIP = &routetable.DummyTable{}
819+
}
809820
log.Info("IPIP enabled, starting thread to keep tunnel configuration in sync.")
810821
// Add a manager to keep the all-hosts IP set up to date.
811-
dp.ipipManager = newIPIPManager(ipSetsV4, config.MaxIPSetSize, config.ExternalNodesCidrs)
812-
go dp.ipipManager.KeepIPIPDeviceInSync(config.IPIPMTU, config.RulesConfig.IPIPTunnelAddress, dataplaneFeatures.ChecksumOffloadBroken)
822+
dp.ipipManager = newIPIPManager(
823+
ipSetsV4,
824+
routeTableIPIP,
825+
IPIPIfaceName,
826+
config,
827+
dp.loopSummarizer,
828+
4,
829+
featureDetector,
830+
)
831+
dp.ipipParentC = make(chan string, 1)
832+
go dp.ipipManager.KeepIPIPDeviceInSync(context.Background(), config.IPIPMTU, config.RulesConfig.IPIPTunnelAddress, dataplaneFeatures.ChecksumOffloadBroken, 10*time.Second, dp.ipipParentC)
813833
dp.RegisterManager(dp.ipipManager) // IPv4-only
814834
} else {
815835
// Only clean up IPIP addresses if IPIP is implicitly disabled (no IPIP pools and not explicitly set in FelixConfig)
@@ -1225,7 +1245,7 @@ func cleanUpVXLANDevice(deviceName string) {
12251245

12261246
type Manager interface {
12271247
// OnUpdate is called for each protobuf message from the datastore. May either directly
1228-
// send updates to the IPSets and iptables.Table objects (which will queue the updates
1248+
// send updates to the IPSets and iptables. Table objects (which will queue the updates
12291249
// until the main loop instructs them to act) or (for efficiency) may wait until
12301250
// a call to CompleteDeferredWork() to flush updates to the dataplane.
12311251
OnUpdate(protoBufMsg interface{})
@@ -1773,6 +1793,8 @@ func (d *InternalDataplane) loopUpdatingDataplane() {
17731793
d.vxlanManager.OnParentNameUpdate(name)
17741794
case name := <-d.vxlanParentCV6:
17751795
d.vxlanManagerV6.OnParentNameUpdate(name)
1796+
case name := <-d.ipipParentC:
1797+
d.ipipManager.OnParentNameUpdate(name)
17761798
case <-ipSetsRefreshC:
17771799
log.Debug("Refreshing IP sets state")
17781800
d.forceIPSetsRefresh = true

0 commit comments

Comments
 (0)