Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions dataplane/saiserver/acl.go
Original file line number Diff line number Diff line change
Expand Up @@ -731,6 +731,17 @@ func (a *acl) GetAclCounterAttribute(ctx context.Context, req *saipb.GetAclCount
if err != nil {
return nil, err
}
if len(count.GetCounters()) == 0 {
slog.WarnContext(ctx, "GetAclCounterAttribute: no counters returned", "oid", req.Oid)
resp := &saipb.GetAclCounterAttributeResponse{
Attr: &saipb.AclCounterAttribute{
Packets: proto.Uint64(0),
Bytes: proto.Uint64(0),
},
}
a.mgr.StoreAttributes(req.GetOid(), resp.GetAttr())
return resp, nil
}
resp := &saipb.GetAclCounterAttributeResponse{
Attr: &saipb.AclCounterAttribute{
Packets: &count.GetCounters()[0].Packets,
Expand Down
27 changes: 22 additions & 5 deletions dataplane/saiserver/acl_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -749,6 +749,7 @@ func TestGetAclCounterAttribute(t *testing.T) {
req *saipb.GetAclCounterAttributeRequest
wantErr string
want *saipb.GetAclCounterAttributeResponse
replies []*fwdpb.FlowCounterQueryReply
}{{
desc: "success",
req: &saipb.GetAclCounterAttributeRequest{
Expand All @@ -761,15 +762,31 @@ func TestGetAclCounterAttribute(t *testing.T) {
Bytes: proto.Uint64(0),
},
},
replies: []*fwdpb.FlowCounterQueryReply{{
Counters: []*fwdpb.FlowCounter{{
Packets: 1,
}},
}},
}, {
desc: "empty counters",
req: &saipb.GetAclCounterAttributeRequest{
Oid: 1,
AttrType: []saipb.AclCounterAttr{saipb.AclCounterAttr_ACL_COUNTER_ATTR_PACKETS},
},
want: &saipb.GetAclCounterAttributeResponse{
Attr: &saipb.AclCounterAttribute{
Packets: proto.Uint64(0),
Bytes: proto.Uint64(0),
},
},
replies: []*fwdpb.FlowCounterQueryReply{{
Counters: []*fwdpb.FlowCounter{},
}},
}}
for _, tt := range tests {
t.Run(tt.desc, func(t *testing.T) {
dplane := &fakeSwitchDataplane{
flowQueryReplies: []*fwdpb.FlowCounterQueryReply{{
Counters: []*fwdpb.FlowCounter{{
Packets: 1,
}},
}},
flowQueryReplies: tt.replies,
}
c, _, stopFn := newTestACL(t, dplane)
defer stopFn()
Expand Down
Loading