Skip to content

Commit

Permalink
datapath: Move NodeAddressing out from tables
Browse files Browse the repository at this point in the history
NodeAddressing doesn't make sense to live in the tables package as it
isn't about defining a common StateDB table. It also introduces dependency
on the datapath types package which makes it impossible to use the tables
package types in datapath types.

Eventually whole NodeAddressing will be removed as it is just a wrapper around
LocalNodeStore and Table[Device], and a harmful one at that as it hides the
fact that the underlying data may change over time.

Signed-off-by: Jussi Maki <jussi@isovalent.com>
  • Loading branch information
joamaki committed May 31, 2024
1 parent 0a02d60 commit a86ac24
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 6 deletions.
2 changes: 1 addition & 1 deletion pkg/datapath/cells.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ var Cell = cell.Module(
tables.NodeAddressCell,

// Provides the legacy accessor for the above, the NodeAddressing interface.
tables.NodeAddressingCell,
NodeAddressingCell,

// This cell periodically updates the agent liveness value in configmap.Map to inform
// the datapath of the liveness of the agent.
Expand Down
3 changes: 2 additions & 1 deletion pkg/datapath/fake/cells.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
"github.com/cilium/statedb"
"golang.org/x/sys/unix"

"github.com/cilium/cilium/pkg/datapath"
fakeTypes "github.com/cilium/cilium/pkg/datapath/fake/types"
"github.com/cilium/cilium/pkg/datapath/iptables"
"github.com/cilium/cilium/pkg/datapath/iptables/ipset"
Expand Down Expand Up @@ -64,7 +65,7 @@ var Cell = cell.Module(
),

tables.NodeAddressCell,
tables.NodeAddressingCell,
datapath.NodeAddressingCell,

cell.Invoke(
statedb.RegisterTable[*tables.Device],
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// SPDX-License-Identifier: Apache-2.0
// Copyright Authors of Cilium

package tables
package datapath

import (
"context"
Expand All @@ -11,6 +11,7 @@ import (
"github.com/cilium/statedb"

"github.com/cilium/cilium/pkg/cidr"
"github.com/cilium/cilium/pkg/datapath/tables"
"github.com/cilium/cilium/pkg/datapath/types"
"github.com/cilium/cilium/pkg/node"
"github.com/cilium/cilium/pkg/option"
Expand All @@ -26,7 +27,7 @@ var NodeAddressingCell = cell.Module(
cell.Provide(NewNodeAddressing),
)

func NewNodeAddressing(localNode *node.LocalNodeStore, db *statedb.DB, devices statedb.Table[*Device]) types.NodeAddressing {
func NewNodeAddressing(localNode *node.LocalNodeStore, db *statedb.DB, devices statedb.Table[*tables.Device]) types.NodeAddressing {
return &nodeAddressing{
localNode: localNode,
db: db,
Expand All @@ -37,7 +38,7 @@ func NewNodeAddressing(localNode *node.LocalNodeStore, db *statedb.DB, devices s
type nodeAddressing struct {
localNode *node.LocalNodeStore
db *statedb.DB
devices statedb.Table[*Device]
devices statedb.Table[*tables.Device]
}

func (n *nodeAddressing) IPv6() types.NodeAddressingFamily {
Expand Down Expand Up @@ -90,7 +91,7 @@ func (a addressFamily) getDirectRouting(flags getFlags) (int, net.IP, bool) {
return 0, nil, false
}

dev, _, ok := a.devices.Get(a.db.ReadTxn(), DeviceNameIndex.Query(option.Config.DirectRoutingDevice))
dev, _, ok := a.devices.Get(a.db.ReadTxn(), tables.DeviceNameIndex.Query(option.Config.DirectRoutingDevice))
if !ok {
return 0, nil, false
}
Expand Down

0 comments on commit a86ac24

Please sign in to comment.