Skip to content

Commit f858b05

Browse files
mhofstettertklauser
authored andcommitted
datapath: remove datapath abstraction
The datapath abstraction no longer provides access to datapath related components. Therefore, this commit removes the interface `types.Datapath` and struct `linuxDatapath` - including all the referencing methods. Signed-off-by: Marco Hofstetter <[email protected]>
1 parent 5e5138f commit f858b05

File tree

16 files changed

+8
-130
lines changed

16 files changed

+8
-130
lines changed

Diff for: daemon/cmd/daemon.go

-5
Original file line numberDiff line numberDiff line change
@@ -124,10 +124,6 @@ type Daemon struct {
124124

125125
mtuConfig mtu.MTU
126126

127-
// datapath is the underlying datapath implementation to use to
128-
// implement all aspects of an agent
129-
datapath datapath.Datapath
130-
131127
loader datapath.Loader
132128

133129
nodeAddressing datapath.NodeAddressing
@@ -368,7 +364,6 @@ func newDaemon(ctx context.Context, cleaner *daemonCleanup, params *daemonParams
368364
buildEndpointSem: semaphore.NewWeighted(int64(numWorkerThreads())),
369365
compilationLock: params.CompilationLock,
370366
mtuConfig: params.MTU,
371-
datapath: params.Datapath,
372367
directRoutingDev: params.DirectRoutingDevice,
373368
loader: params.Loader,
374369
nodeAddressing: params.NodeAddressing,

Diff for: daemon/cmd/daemon_main.go

-1
Original file line numberDiff line numberDiff line change
@@ -1651,7 +1651,6 @@ type daemonParams struct {
16511651
Lifecycle cell.Lifecycle
16521652
Health cell.Health
16531653
Clientset k8sClient.Clientset
1654-
Datapath datapath.Datapath
16551654
Loader datapath.Loader
16561655
WGAgent *wireguard.Agent
16571656
LocalNodeStore *node.LocalNodeStore

Diff for: daemon/cmd/daemon_test.go

-4
Original file line numberDiff line numberDiff line change
@@ -299,10 +299,6 @@ func (ds *DaemonSuite) GetCIDRPrefixLengths() ([]int, []int) {
299299
panic("GetCIDRPrefixLengths should not have been called")
300300
}
301301

302-
func (ds *DaemonSuite) Datapath() datapath.Datapath {
303-
return ds.d.datapath
304-
}
305-
306302
func (ds *DaemonSuite) Loader() datapath.Loader {
307303
return ds.d.loader
308304
}

Diff for: daemon/cmd/datapath.go

-5
Original file line numberDiff line numberDiff line change
@@ -402,11 +402,6 @@ func setupRouteToVtepCidr() error {
402402
return nil
403403
}
404404

405-
// Datapath returns a reference to the datapath implementation.
406-
func (d *Daemon) Datapath() datapath.Datapath {
407-
return d.datapath
408-
}
409-
410405
// Loader returns a reference to the loader implementation.
411406
func (d *Daemon) Loader() datapath.Loader {
412407
return d.loader

Diff for: pkg/datapath/cells.go

+6-19
Original file line numberDiff line numberDiff line change
@@ -75,10 +75,9 @@ var Cell = cell.Module(
7575
// Manages Cilium-specific iptables rules.
7676
iptables.Cell,
7777

78-
cell.Provide(
79-
newWireguardAgent,
80-
newDatapath,
81-
),
78+
cell.Invoke(initDatapath),
79+
80+
cell.Provide(newWireguardAgent),
8281

8382
cell.Provide(func(expConfig experimental.Config) types.LBMap {
8483
if expConfig.EnableExperimentalLB {
@@ -180,26 +179,14 @@ func newWireguardAgent(lc cell.Lifecycle, sysctl sysctl.Sysctl) *wg.Agent {
180179
return wgAgent
181180
}
182181

183-
func newDatapath(params datapathParams) types.Datapath {
184-
datapath := linuxdatapath.NewDatapath(linuxdatapath.DatapathParams{})
185-
186-
params.LC.Append(cell.Hook{
182+
func initDatapath(logger *slog.Logger, lifecycle cell.Lifecycle) {
183+
lifecycle.Append(cell.Hook{
187184
OnStart: func(cell.HookContext) error {
188-
if err := linuxdatapath.CheckRequirements(params.Log); err != nil {
185+
if err := linuxdatapath.CheckRequirements(logger); err != nil {
189186
return fmt.Errorf("requirements failed: %w", err)
190187
}
191188

192189
return nil
193190
},
194191
})
195-
196-
return datapath
197-
}
198-
199-
type datapathParams struct {
200-
cell.In
201-
202-
Log *slog.Logger
203-
204-
LC cell.Lifecycle
205192
}

Diff for: pkg/datapath/fake/cells.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,10 @@ var Cell = cell.Module(
4343
"Fake Datapath",
4444

4545
cell.Provide(
46-
func(lifecycle cell.Lifecycle, na types.NodeAddressing, nodeManager manager.NodeManager) (*fakeTypes.FakeDatapath, types.Datapath, types.NodeIDHandler, types.NodeHandler, types.NodeNeighbors, types.LBMap) {
46+
func(lifecycle cell.Lifecycle, na types.NodeAddressing, nodeManager manager.NodeManager) (*fakeTypes.FakeDatapath, types.NodeIDHandler, types.NodeHandler, types.NodeNeighbors, types.LBMap) {
4747
dp := fakeTypes.NewDatapathWithNodeAddressing(na)
4848
nodeManager.Subscribe(dp.Node())
49-
return dp, dp, dp.NodeIDs(), dp.Node(), dp.NodeNeighbors(), dp.LBMap()
49+
return dp, dp.NodeIDs(), dp.Node(), dp.NodeNeighbors(), dp.LBMap()
5050
},
5151
func() signalmap.Map { return fakesignalmap.NewFakeSignalMap([][]byte{}, time.Second) },
5252
func() authmap.Map { return fakeauthmap.NewFakeAuthMap() },

Diff for: pkg/datapath/fake/types/datapath.go

-2
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,6 @@ import (
1515
"github.com/cilium/cilium/pkg/testutils/mockmaps"
1616
)
1717

18-
var _ datapath.Datapath = (*FakeDatapath)(nil)
19-
2018
type FakeDatapath struct {
2119
node *FakeNodeHandler
2220
nodeAddressing datapath.NodeAddressing

Diff for: pkg/datapath/linux/datapath.go

-19
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,6 @@
33

44
package linux
55

6-
import (
7-
datapath "github.com/cilium/cilium/pkg/datapath/types"
8-
)
9-
106
// DatapathConfiguration is the static configuration of the datapath. The
117
// configuration cannot change throughout the lifetime of a datapath object.
128
type DatapathConfiguration struct {
@@ -16,18 +12,3 @@ type DatapathConfiguration struct {
1612
// TunnelDevice is the name of the tunnel device (if any).
1713
TunnelDevice string
1814
}
19-
20-
type linuxDatapath struct{}
21-
22-
type DatapathParams struct{}
23-
24-
// NewDatapath creates a new Linux datapath
25-
func NewDatapath(p DatapathParams) datapath.Datapath {
26-
dp := &linuxDatapath{}
27-
28-
return dp
29-
}
30-
31-
func (l *linuxDatapath) Name() string {
32-
return "linux-datapath"
33-
}

Diff for: pkg/datapath/linux/datapath_test.go

-15
This file was deleted.

Diff for: pkg/datapath/types/datapath.go

-9
This file was deleted.

Diff for: pkg/endpoint/endpoint_test.go

-13
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@ import (
3939
type EndpointSuite struct {
4040
orchestrator datapath.Orchestrator
4141
repo *policy.Repository
42-
datapath datapath.Datapath
4342
mgr *cache.CachingIdentityAllocator
4443

4544
// Owners interface mock
@@ -108,10 +107,6 @@ func (s *EndpointSuite) SendNotification(msg monitorAPI.AgentNotifyMessage) erro
108107
return nil
109108
}
110109

111-
func (s *EndpointSuite) Datapath() datapath.Datapath {
112-
return s.datapath
113-
}
114-
115110
func (s *EndpointSuite) GetDNSRules(epID uint16) restore.DNSRules {
116111
return nil
117112
}
@@ -692,14 +687,6 @@ func TestEndpointEventQueueDeadlockUponStop(t *testing.T) {
692687
option.Config.EndpointQueueSize = oldQueueSize
693688
}()
694689

695-
oldDatapath := s.datapath
696-
697-
s.datapath = fakeTypes.NewDatapath()
698-
699-
defer func() {
700-
s.datapath = oldDatapath
701-
}()
702-
703690
ep := NewTestEndpointWithState(t, s, s, testipcache.NewMockIPCache(), &FakeEndpointProxy{}, testidentity.NewMockIdentityAllocator(nil), 12345, StateReady)
704691

705692
ep.properties[PropertyFakeEndpoint] = true

Diff for: pkg/endpoint/redirect_test.go

-5
Original file line numberDiff line numberDiff line change
@@ -156,11 +156,6 @@ func (d *DummyOwner) SendNotification(msg monitorAPI.AgentNotifyMessage) error {
156156
return nil
157157
}
158158

159-
// Datapath returns a nil datapath.
160-
func (d *DummyOwner) Datapath() datapath.Datapath {
161-
return nil
162-
}
163-
164159
// Datapath returns a nil datapath.
165160
func (d *DummyOwner) Loader() datapath.Loader {
166161
return nil

Diff for: pkg/endpoint/regeneration/owner.go

-3
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,6 @@ type Owner interface {
2424
// SendNotification is called to emit an agent notification
2525
SendNotification(msg monitorAPI.AgentNotifyMessage) error
2626

27-
// Datapath returns a reference to the datapath implementation.
28-
Datapath() datapath.Datapath
29-
3027
// Loader returns a reference to the loader implementation.
3128
Loader() datapath.Loader
3229

Diff for: pkg/endpoint/restore_test.go

-20
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ import (
1515

1616
"github.com/stretchr/testify/require"
1717

18-
fake "github.com/cilium/cilium/pkg/datapath/fake/types"
1918
"github.com/cilium/cilium/pkg/identity"
2019
"github.com/cilium/cilium/pkg/labels"
2120
"github.com/cilium/cilium/pkg/mac"
@@ -78,12 +77,6 @@ func (s *EndpointSuite) endpointCreator(id uint16, secID identity.NumericIdentit
7877

7978
func TestReadEPsFromDirNames(t *testing.T) {
8079
s := setupEndpointSuite(t)
81-
oldDatapath := s.datapath
82-
defer func() {
83-
s.datapath = oldDatapath
84-
}()
85-
86-
s.datapath = fake.NewDatapath()
8780
epsWanted, _ := s.createEndpoints()
8881
tmpDir, err := os.MkdirTemp("", "cilium-tests")
8982
defer func() {
@@ -156,13 +149,6 @@ func TestReadEPsFromDirNames(t *testing.T) {
156149
func TestReadEPsFromDirNamesWithRestoreFailure(t *testing.T) {
157150
s := setupEndpointSuite(t)
158151

159-
oldDatapath := s.datapath
160-
defer func() {
161-
s.datapath = oldDatapath
162-
}()
163-
164-
s.datapath = fake.NewDatapath()
165-
166152
eps, _ := s.createEndpoints()
167153
ep := eps[0]
168154
require.NotNil(t, ep)
@@ -225,12 +211,6 @@ func BenchmarkReadEPsFromDirNames(b *testing.B) {
225211

226212
// For this benchmark, the real linux datapath is necessary to properly
227213
// serialize config files to disk and benchmark the restore.
228-
oldDatapath := s.datapath
229-
defer func() {
230-
s.datapath = oldDatapath
231-
}()
232-
233-
s.datapath = fake.NewDatapath()
234214

235215
epsWanted, _ := s.createEndpoints()
236216
tmpDir, err := os.MkdirTemp("", "cilium-tests")

Diff for: pkg/endpointmanager/manager_test.go

-4
Original file line numberDiff line numberDiff line change
@@ -84,10 +84,6 @@ func (s *EndpointManagerSuite) SendNotification(msg monitorAPI.AgentNotifyMessag
8484
return nil
8585
}
8686

87-
func (s *EndpointManagerSuite) Datapath() datapath.Datapath {
88-
return nil
89-
}
90-
9187
func (s *EndpointManagerSuite) Loader() datapath.Loader {
9288
return nil
9389
}

Diff for: pkg/fqdn/dnsproxy/proxy_test.go

-4
Original file line numberDiff line numberDiff line change
@@ -181,10 +181,6 @@ func (s *DNSProxyTestSuite) SendNotification(msg monitorAPI.AgentNotifyMessage)
181181
return nil
182182
}
183183

184-
func (s *DNSProxyTestSuite) Datapath() datapath.Datapath {
185-
return nil
186-
}
187-
188184
func (s *DNSProxyTestSuite) Loader() datapath.Loader {
189185
return nil
190186
}

0 commit comments

Comments
 (0)