Skip to content

Commit

Permalink
Use a copy of ACLRules instead of the original (#773)
Browse files Browse the repository at this point in the history
Signed-off-by: Artem Glazychev <artem.glazychev@xored.com>
  • Loading branch information
glazychev-art authored Nov 21, 2023
1 parent 59cf35e commit 0b038c4
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
7 changes: 5 additions & 2 deletions pkg/networkservice/acl/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,11 +90,14 @@ func addACLToACLList(ctx context.Context, vppConn api.Connection, tag string, eg
}

func aclAdd(tag string, egress bool, aRules []acl_types.ACLRule) *acl.ACLAddReplace {
aRulesCopy := make([]acl_types.ACLRule, len(aRules))
copy(aRulesCopy, aRules)

aclAddReplace := &acl.ACLAddReplace{
ACLIndex: ^uint32(0),
Tag: tag,
Count: uint32(len(aRules)),
R: aRules,
Count: uint32(len(aRulesCopy)),
R: aRulesCopy,
}
if egress {
for i := range aclAddReplace.R {
Expand Down
3 changes: 2 additions & 1 deletion pkg/networkservice/acl/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ package acl

import (
"context"
"fmt"

"github.com/edwarnicke/genericsync"
"github.com/golang/protobuf/ptypes/empty"
Expand Down Expand Up @@ -61,7 +62,7 @@ func (a *aclServer) Request(ctx context.Context, request *networkservice.Network
_, loaded := a.aclIndices.Load(conn.GetId())
if !loaded && len(a.aclRules) > 0 {
var indices []uint32
if indices, err = create(ctx, a.vppConn, aclTag, metadata.IsClient(a), a.aclRules); err != nil {
if indices, err = create(ctx, a.vppConn, fmt.Sprintf("%s-%s", aclTag, conn.GetId()), metadata.IsClient(a), a.aclRules); err != nil {
closeCtx, cancelClose := postponeCtxFunc()
defer cancelClose()

Expand Down

0 comments on commit 0b038c4

Please sign in to comment.