Skip to content

Commit

Permalink
pkg/maps/eppolicymap: Fix inner map name
Browse files Browse the repository at this point in the history
Previously, the endpoint policy inner map name was
"ep-policy-inner-map", which is illegal and if passed to bpf() while
creating map, will result in "invalid argument" being returned.

Fix this by converting the dashes to underscores, which are allowed.

The subsequent commit will add names to the BPF maps.

Signed-off-by: Chris Tarazi <chris@isovalent.com>
  • Loading branch information
christarazi authored and nebril committed Jun 10, 2022
1 parent 5feb34e commit 56375af
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion pkg/maps/eppolicymap/eppolicymap.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import (
var (
log = logging.DefaultLogger.WithField(logfields.LogSubsys, "map-ep-policy")
MapName = "cilium_ep_to_policy"
innerMapName = "ep-policy-inner-map"
innerMapName = "ep_policy_inner_map"
)

const (
Expand Down
6 changes: 3 additions & 3 deletions pkg/maps/eppolicymap/eppolicymap_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ func (e *EPPolicyMapTestSuite) TestWriteEndpoint(c *C) {
fd, err := bpf.CreateMap(bpf.MapTypeHash,
uint32(unsafe.Sizeof(policymap.PolicyKey{})),
uint32(unsafe.Sizeof(policymap.PolicyEntry{})), 1024, 0, 0,
"ep-policy-inner-map")
innerMapName)
c.Assert(err, IsNil)

keys[0] = lxcmap.NewEndpointKey(net.ParseIP("1.2.3.4"))
Expand All @@ -82,7 +82,7 @@ func (e *EPPolicyMapTestSuite) TestWriteEndpointFails(c *C) {
_, err := bpf.CreateMap(bpf.MapTypeHash,
uint32(unsafe.Sizeof(policymap.PolicyKey{})),
uint32(unsafe.Sizeof(policymap.PolicyEntry{})), 1024, 0, 0,
"ep-policy-inner-map")
innerMapName)
c.Assert(err, IsNil)

keys[0] = lxcmap.NewEndpointKey(net.ParseIP("1.2.3.4"))
Expand All @@ -98,7 +98,7 @@ func (e *EPPolicyMapTestSuite) TestWriteEndpointDisabled(c *C) {
fd, err := bpf.CreateMap(bpf.MapTypeHash,
uint32(unsafe.Sizeof(policymap.PolicyKey{})),
uint32(unsafe.Sizeof(policymap.PolicyEntry{})), 1024, 0, 0,
"ep-policy-inner-map")
innerMapName)
c.Assert(err, IsNil)

keys[0] = lxcmap.NewEndpointKey(net.ParseIP("1.2.3.4"))
Expand Down

0 comments on commit 56375af

Please sign in to comment.