diff --git a/dataplane/saiserver/acl.go b/dataplane/saiserver/acl.go index f6b343a6..318badeb 100644 --- a/dataplane/saiserver/acl.go +++ b/dataplane/saiserver/acl.go @@ -28,6 +28,7 @@ import ( "google.golang.org/grpc" "google.golang.org/grpc/codes" "google.golang.org/grpc/status" + "google.golang.org/protobuf/proto" saipb "github.com/openconfig/lemming/dataplane/proto/sai" fwdpb "github.com/openconfig/lemming/proto/forwarding" @@ -120,6 +121,12 @@ func (a *acl) CreateAclTableGroupMember(_ context.Context, req *saipb.CreateAclT // CreateAclTable is noop as the table is already created in the group. func (a *acl) CreateAclTable(context.Context, *saipb.CreateAclTableRequest) (*saipb.CreateAclTableResponse, error) { id := a.mgr.NextID() + + a.mgr.StoreAttributes(id, &saipb.AclTableAttribute{ + AvailableAclEntry: proto.Uint32(10000), + AvailableAclCounter: proto.Uint32(10000), + }) + return &saipb.CreateAclTableResponse{Oid: id}, nil } @@ -370,6 +377,17 @@ func (a *acl) CreateAclEntry(ctx context.Context, req *saipb.CreateAclEntryReque aReq.Actions = append(aReq.Actions, &fwdpb.ActionDesc{ActionType: fwdpb.ActionType_ACTION_TYPE_DROP}) case saipb.PacketAction_PACKET_ACTION_TRAP: // COPY and DROP aReq.Actions = append(aReq.Actions, fwdconfig.Action(fwdconfig.TransmitAction(fmt.Sprint(resp.GetAttr().GetCpuPort())).WithImmediate(true)).Build()) + case saipb.PacketAction_PACKET_ACTION_COPY: + aReq.Actions = append(aReq.Actions, &fwdpb.ActionDesc{ + ActionType: fwdpb.ActionType_ACTION_TYPE_MIRROR, + Action: &fwdpb.ActionDesc_Mirror{Mirror: &fwdpb.MirrorActionDesc{ + PortId: &fwdpb.PortId{ObjectId: &fwdpb.ObjectId{Id: fmt.Sprint(resp.GetAttr().GetCpuPort())}}, + FieldIds: []*fwdpb.PacketFieldId{{ + Field: &fwdpb.PacketField{FieldNum: fwdpb.PacketFieldNum_PACKET_FIELD_NUM_TRAP_ID}, + }}, + PortAction: fwdpb.PortAction_PORT_ACTION_OUTPUT, + }}, + }) case saipb.PacketAction_PACKET_ACTION_LOG: // COPY and FORWARD mirror := &fwdpb.ActionDesc{ ActionType: fwdpb.ActionType_ACTION_TYPE_MIRROR, diff --git a/dataplane/saiserver/switch.go b/dataplane/saiserver/switch.go index 280dde1c..1fdc97fd 100644 --- a/dataplane/saiserver/switch.go +++ b/dataplane/saiserver/switch.go @@ -767,10 +767,10 @@ func (sw *saiSwitch) CreateSwitch(ctx context.Context, _ *saipb.CreateSwitchRequ CpuPort: proto.Uint64(cpuPortID), NumberOfActivePorts: proto.Uint32(0), AclEntryMinimumPriority: proto.Uint32(1), - AclEntryMaximumPriority: proto.Uint32(100), + AclEntryMaximumPriority: proto.Uint32(10000), AclTableMinimumPriority: proto.Uint32(1), - AclTableMaximumPriority: proto.Uint32(100), - MaxAclActionCount: proto.Uint32(50), + AclTableMaximumPriority: proto.Uint32(10000), + MaxAclActionCount: proto.Uint32(1000), NumberOfEcmpGroups: proto.Uint32(1024), PortList: []uint64{cpuPortID}, SwitchHardwareInfo: []int32{}, diff --git a/dataplane/saiserver/switch_test.go b/dataplane/saiserver/switch_test.go index 44aa6e4a..acc0d2ee 100644 --- a/dataplane/saiserver/switch_test.go +++ b/dataplane/saiserver/switch_test.go @@ -53,10 +53,10 @@ func TestCreateSwitch(t *testing.T) { CpuPort: proto.Uint64(2), NumberOfActivePorts: proto.Uint32(0), AclEntryMinimumPriority: proto.Uint32(1), - AclEntryMaximumPriority: proto.Uint32(100), + AclEntryMaximumPriority: proto.Uint32(10000), AclTableMinimumPriority: proto.Uint32(1), - AclTableMaximumPriority: proto.Uint32(100), - MaxAclActionCount: proto.Uint32(50), + AclTableMaximumPriority: proto.Uint32(10000), + MaxAclActionCount: proto.Uint32(1000), NumberOfEcmpGroups: proto.Uint32(1024), PortList: []uint64{2}, SwitchHardwareInfo: []int32{}, diff --git a/dataplane/standalone/pkthandler/pktiohandler/pktiohandler_test.go b/dataplane/standalone/pkthandler/pktiohandler/pktiohandler_test.go index c1edc8bd..3470fa7d 100644 --- a/dataplane/standalone/pkthandler/pktiohandler/pktiohandler_test.go +++ b/dataplane/standalone/pkthandler/pktiohandler/pktiohandler_test.go @@ -90,7 +90,7 @@ func TestStreamPackets(t *testing.T) { mgr.sendQueue.Write(pkt) } mgr.StreamPackets(ps) - time.Sleep(time.Millisecond) // Sleep long enough to drain the send queue. + time.Sleep(5 * time.Millisecond) // Sleep long enough to drain the send queue. if d := cmp.Diff(ps.sendPackets, tt.wantSentPacket, protocmp.Transform()); d != "" { t.Errorf("StreamPackets() failed: sent packet diff(-got,+want)\n:%s", d) @@ -134,7 +134,7 @@ func TestManagePorts(t *testing.T) { t.Fatalf("unexpected error on New(): %v", err) } builder[pktiopb.PortType_PORT_TYPE_NETDEV] = func(hpcm *pktiopb.HostPortControlMessage) (PortIO, error) { - return nil, nil + return &fakePort{}, nil } linkByName = func(name string) (netlink.Link, error) { return &fakeLink{}, nil @@ -162,6 +162,10 @@ type fakePort struct { writtenData []*portWriteData } +func (p *fakePort) Read([]byte) (int, error) { + return 0, nil +} + func (p *fakePort) Write(frame []byte, md *kernel.PacketMetadata) (int, error) { p.writtenData = append(p.writtenData, &portWriteData{Frame: frame, MD: md}) return len(frame), nil