New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
maps: switch maglev to cilium/ebpf package #15546
Conversation
311393d
to
084f15d
Compare
Nice! Fyi - you can drop the first commit - #15386 (comment). |
cc @christarazi (Chris has a WIP to make inner maps of a different size). |
Thanks for the headsup @aditighag 🙌 |
332e25a
to
eafd50c
Compare
56216e3
to
af21d5c
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, just a couple of nits, feel free to ignore them.
af21d5c
to
ac2b326
Compare
c32b28e
to
b90d982
Compare
@brb @christarazi while doing another round of tests I realized that whenever we need to access an existing maglev map from the Therefore I added a new function to the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM re: the new changes. It should be compatible with #15019, which I'll rebase on top of this PR soon.
8ae21dd
to
96f95f5
Compare
test-me-please |
@jibi I finally got around to rebasing my PR (#15019) on top of this and I ran into an issue. The summary is that when you specify an I've worked around this manually by changing the Here's the diff: diff --git a/pkg/maps/lbmap/maglev.go b/pkg/maps/lbmap/maglev.go
index 286aa078c..8760b94bb 100644
--- a/pkg/maps/lbmap/maglev.go
+++ b/pkg/maps/lbmap/maglev.go
@@ -42,12 +42,9 @@ var (
// InitMaglevMaps inits the ipv4 and/or ipv6 maglev outer and inner maps.
func InitMaglevMaps(ipv4, ipv6 bool, tableSize uint32) error {
- dummyInnerMap, dummyInnerMapSpec, err := NewMaglevInnerMap("cilium_lb_maglev_dummy", tableSize)
- if err != nil {
- return err
- }
- defer dummyInnerMap.Close()
+ dummyInnerMapSpec := NewMaglevInnerMap("cilium_lb_maglev_dummy", tableSize)
+ var err error
// Always try to delete old maps with the wrong M parameter, otherwise
// we may end up in a case where there are 2 maps (one for IPv4 and
// one for IPv6), one of which is not used, with 2 different table
@@ -173,12 +170,18 @@ func updateMaglevTable(ipv6 bool, revNATID uint16, backendIDs []uint16, tableSiz
innerMapName = MaglevInner6MapName
}
- innerMap, _, err := NewMaglevInnerMap(innerMapName, uint32(tableSize))
+ innerMapSpec := NewMaglevInnerMap(innerMapName, uint32(tableSize))
+ m := ebpf.NewMap(innerMapSpec)
+ err := m.OpenOrCreate()
if err != nil {
return err
}
- defer innerMap.Close()
+ defer m.Close()
+ innerMap := &maglevInnerMap{
+ Map: m,
+ tableSize: uint32(tableSize),
+ }
if err := updateMaglevInnerMap(innerMap, backendIDs); err != nil {
return err
}
diff --git a/pkg/maps/lbmap/maglev_inner_map.go b/pkg/maps/lbmap/maglev_inner_map.go
index 5a9680a72..a497507ce 100644
--- a/pkg/maps/lbmap/maglev_inner_map.go
+++ b/pkg/maps/lbmap/maglev_inner_map.go
@@ -79,8 +79,8 @@ func (m maglevInnerVals) MarshalBinary() ([]byte, error) {
}
// NewMaglevInnerMap returns a new object representing a maglev inner map.
-func NewMaglevInnerMap(name string, tableSize uint32) (*maglevInnerMap, *ebpf.MapSpec, error) {
- spec := &ebpf.MapSpec{
+func NewMaglevInnerMap(name string, tableSize uint32) *ebpf.MapSpec {
+ return &ebpf.MapSpec{
Name: name,
Type: ebpf.Array,
KeySize: uint32(unsafe.Sizeof(MaglevInnerKey{})),
@@ -88,16 +88,6 @@ func NewMaglevInnerMap(name string, tableSize uint32) (*maglevInnerMap, *ebpf.Ma
MaxEntries: tableSizeToMaxEntries(tableSize),
Flags: unix.BPF_F_INNER_MAP,
}
-
- m := ebpf.NewMap(spec)
- if err := m.OpenOrCreate(); err != nil {
- return nil, nil, err
- }
-
- return &maglevInnerMap{
- Map: m,
- tableSize: tableSize,
- }, spec, nil
}
// MaglevInnerMapFromID returns a new object representing the maglev inner map |
As mentioned offline, it seems that my code is working without the patch provided above for some reason. My best guess is that my local kernel must have gotten into some bad / weird state with regards to the inner map, as that's what I was developing on 🤷. |
Signed-off-by: Gilberto Bertin <gilberto@isovalent.com>
96f95f5
to
2a1fc5b
Compare
test-me-please |
retest-netnext |
Last week I saw |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🚀
Introduced in torvalds/linux@4a8f87e. In Cilium, following the merge of cilium/cilium#15546, we need to add this feature test as Maglev mode uses inner maps (map-in-map). Signed-off-by: Chris Tarazi <chris@isovalent.com>
Introduced in torvalds/linux@4a8f87e. In Cilium, following the merge of cilium/cilium#15546, we need to add this feature test as Maglev mode uses inner maps (map-in-map). Signed-off-by: Chris Tarazi <chris@isovalent.com>
Introduced in torvalds/linux@4a8f87e. In Cilium, following the merge of cilium/cilium#15546, we need to add this feature test as Maglev mode uses inner maps (map-in-map). Signed-off-by: Chris Tarazi <chris@isovalent.com>
Introduced in torvalds/linux@4a8f87e. In Cilium, following the merge of cilium/cilium#15546, we need to add this feature test as Maglev mode uses inner maps (map-in-map). Signed-off-by: Chris Tarazi <chris@isovalent.com>
No description provided.