From 88dd5556be4ad0a38e775bd8a86efd54f9e3087e Mon Sep 17 00:00:00 2001 From: Artem Glazychev Date: Tue, 21 Nov 2023 12:33:02 +0700 Subject: [PATCH] Use a copy of ACLRules instead of the original Signed-off-by: Artem Glazychev --- pkg/networkservice/acl/common.go | 7 +++++-- pkg/networkservice/acl/server.go | 3 ++- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/pkg/networkservice/acl/common.go b/pkg/networkservice/acl/common.go index 1ecd906e..27572bfc 100644 --- a/pkg/networkservice/acl/common.go +++ b/pkg/networkservice/acl/common.go @@ -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 { diff --git a/pkg/networkservice/acl/server.go b/pkg/networkservice/acl/server.go index 01c45a6b..647fcce0 100644 --- a/pkg/networkservice/acl/server.go +++ b/pkg/networkservice/acl/server.go @@ -21,6 +21,7 @@ package acl import ( "context" + "fmt" "github.com/edwarnicke/genericsync" "github.com/golang/protobuf/ptypes/empty" @@ -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()