From 3c966421aeae80594e32e3b0c4169ad6bfa8595a Mon Sep 17 00:00:00 2001 From: Guo-shiuan Wang Date: Wed, 17 Jul 2024 02:01:39 +0000 Subject: [PATCH 01/11] Implement L2MC via ACL redirect. --- dataplane/forwarding/protocol/attr.go | 3 + .../forwarding/protocol/metadata/metadata.go | 7 + dataplane/saiserver/acl.go | 5 + dataplane/saiserver/l2.go | 149 +++++++++++++- dataplane/saiserver/ports.go | 1 + dataplane/saiserver/switch.go | 21 ++ proto/forwarding/forwarding_common.pb.go | 187 +++++++++--------- proto/forwarding/forwarding_common.proto | 1 + 8 files changed, 275 insertions(+), 99 deletions(-) diff --git a/dataplane/forwarding/protocol/attr.go b/dataplane/forwarding/protocol/attr.go index 3b43fe4f..445a4e6b 100644 --- a/dataplane/forwarding/protocol/attr.go +++ b/dataplane/forwarding/protocol/attr.go @@ -191,6 +191,9 @@ var FieldAttr = map[fwdpb.PacketFieldNum]struct { fwdpb.PacketFieldNum_PACKET_FIELD_NUM_HOST_PORT_ID: { Sizes: []int{SizeUint64}, }, + fwdpb.PacketFieldNum_PACKET_FIELD_NUM_L2MC_GROUP_ID: { + Sizes: []int{SizeUint64}, + }, } // GroupAttr contains attributes for each packet header group. diff --git a/dataplane/forwarding/protocol/metadata/metadata.go b/dataplane/forwarding/protocol/metadata/metadata.go index 6a6ff735..c02e7b9e 100644 --- a/dataplane/forwarding/protocol/metadata/metadata.go +++ b/dataplane/forwarding/protocol/metadata/metadata.go @@ -46,6 +46,7 @@ type Metadata struct { outputIface []byte // L3 output interface id. tunnelID []byte // Tunnel ID hostPortID []byte // Host port id + l2mcgid []byte // L2MC Group ID desc *protocol.Desc // Protocol descriptor. } @@ -126,6 +127,8 @@ func (m *Metadata) Field(id fwdpacket.FieldID) ([]byte, error) { return m.tunnelID, nil case fwdpb.PacketFieldNum_PACKET_FIELD_NUM_HOST_PORT_ID: return m.hostPortID, nil + case fwdpb.PacketFieldNum_PACKET_FIELD_NUM_L2MC_GROUP_ID: + return m.l2mcgid, nil default: return nil, fmt.Errorf("metadata: Field %v failed, unsupported field", id) @@ -232,6 +235,9 @@ func (m *Metadata) updateSet(id fwdpacket.FieldID, arg []byte) (bool, error) { case fwdpb.PacketFieldNum_PACKET_FIELD_NUM_HOST_PORT_ID: m.hostPortID = arg return true, nil + case fwdpb.PacketFieldNum_PACKET_FIELD_NUM_L2MC_GROUP_ID: + m.l2mcgid = arg + return true, nil default: return false, fmt.Errorf("metadata: UpdateField failed, set unsupported for field %v", id) } @@ -287,6 +293,7 @@ func parse(frame *frame.Frame, desc *protocol.Desc) (protocol.Handler, fwdpb.Pac outputIface: make([]byte, protocol.FieldAttr[fwdpb.PacketFieldNum_PACKET_FIELD_NUM_OUTPUT_IFACE].DefaultSize), tunnelID: make([]byte, protocol.FieldAttr[fwdpb.PacketFieldNum_PACKET_FIELD_NUM_TUNNEL_ID].DefaultSize), hostPortID: make([]byte, protocol.FieldAttr[fwdpb.PacketFieldNum_PACKET_FIELD_NUM_HOST_PORT_ID].DefaultSize), + l2mcgid: make([]byte, protocol.FieldAttr[fwdpb.PacketFieldNum_PACKET_FIELD_NUM_L2MC_GROUP_ID].DefaultSize), attribute32: make(map[uint8][]byte), attribute24: make(map[uint8][]byte), attribute16: make(map[uint8][]byte), diff --git a/dataplane/saiserver/acl.go b/dataplane/saiserver/acl.go index 7f93ca2d..7de8b852 100644 --- a/dataplane/saiserver/acl.go +++ b/dataplane/saiserver/acl.go @@ -328,6 +328,11 @@ func (a *acl) CreateAclEntry(ctx context.Context, req *saipb.CreateAclEntryReque }, }) } + if req.ActionRedirect != nil { + aReq.Actions = append(aReq.Actions, + fwdconfig.Action(fwdconfig.UpdateAction(fwdpb.UpdateType_UPDATE_TYPE_SET, + fwdpb.PacketFieldNum_PACKET_FIELD_NUM_L2MC_GROUP_ID).WithUint64Value(req.GetActionRedirect().GetOid())).Build()) + } cpuPortReq := &saipb.GetSwitchAttributeRequest{Oid: switchID, AttrType: []saipb.SwitchAttr{saipb.SwitchAttr_SWITCH_ATTR_CPU_PORT}} resp := &saipb.GetSwitchAttributeResponse{} diff --git a/dataplane/saiserver/l2.go b/dataplane/saiserver/l2.go index 66cd9a73..c334005e 100644 --- a/dataplane/saiserver/l2.go +++ b/dataplane/saiserver/l2.go @@ -16,18 +16,29 @@ package saiserver import ( "context" + "fmt" "google.golang.org/grpc" + "google.golang.org/protobuf/proto" + "github.com/openconfig/lemming/dataplane/forwarding/fwdconfig" "github.com/openconfig/lemming/dataplane/saiserver/attrmgr" + fwdpb "github.com/openconfig/lemming/proto/forwarding" saipb "github.com/openconfig/lemming/dataplane/proto/sai" ) +type l2mcGroupMember struct { + oid uint64 + groupId uint64 + outputId uint64 +} + type l2mcGroup struct { saipb.UnimplementedL2McGroupServer mgr *attrmgr.AttrMgr dataplane switchDataplaneAPI + groups map[uint64]map[uint64]*l2mcGroupMember // OID -> map of Port } func newL2mcGroup(mgr *attrmgr.AttrMgr, dataplane switchDataplaneAPI, s *grpc.Server) *l2mcGroup { @@ -39,25 +50,147 @@ func newL2mcGroup(mgr *attrmgr.AttrMgr, dataplane switchDataplaneAPI, s *grpc.Se return mg } -// TODO: Implement this. -func (mg *l2mcGroup) CreateL2McGroup(context.Context, *saipb.CreateL2McGroupRequest) (*saipb.CreateL2McGroupResponse, error) { +func (mg *l2mcGroup) CreateL2McGroup(ctx context.Context, req *saipb.CreateL2McGroupRequest) (*saipb.CreateL2McGroupResponse, error) { id := mg.mgr.NextID() + // Update internal data + mg.groups[id] = map[uint64]*l2mcGroupMember{} + // Update attributes + l2mcAttrs := &saipb.L2McGroupAttribute{ + L2McOutputCount: proto.Uint32(0), + L2McMemberList: []uint64{}, + } + mg.mgr.StoreAttributes(id, l2mcAttrs) return &saipb.CreateL2McGroupResponse{Oid: id}, nil } -// TODO: Implement this. -func (mg *l2mcGroup) CreateL2McGroupMember(context.Context, *saipb.CreateL2McGroupMemberRequest) (*saipb.CreateL2McGroupMemberResponse, error) { +func (mg *l2mcGroup) CreateL2McGroupMember(ctx context.Context, req *saipb.CreateL2McGroupMemberRequest) (*saipb.CreateL2McGroupMemberResponse, error) { id := mg.mgr.NextID() + // Update table entry + r := fwdconfig.TableEntryAddRequest(mg.dataplane.ID(), L2MCGroupTable).AppendEntry( + fwdconfig.EntryDesc(fwdconfig.ExactEntry(fwdconfig.PacketFieldBytes(fwdpb.PacketFieldNum_PACKET_FIELD_NUM_L2MC_GROUP_ID).WithUint64(req.GetL2McGroupId())))).Build() + for _, p := range mg.groups { + r.Entries[0].Actions = append(r.Entries[0].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(p), + }, + }, + }, + }, + }) + } + if _, err := mg.dataplane.TableEntryAdd(ctx, r); err != nil { + return nil, err + } + // Update internal data + if mg.groups[req.GetL2McGroupId()] == nil { + return nil, fmt.Errorf("L2MC group id %q not found", req.GetL2McGroupId()) + } + if _, ok := mg.groups[req.GetL2McGroupId()][req.GetL2McOutputId()]; ok { + return nil, fmt.Errorf("found existing member %q", req.GetL2McOutputId()) + } + mg.groups[req.GetL2McGroupId()][req.GetL2McOutputId()] = &l2mcGroupMember{ + oid: id, + outputId: req.GetL2McOutputId(), + groupId: req.GetL2McGroupId(), + } + // Update L2MC Group member attributes + attr := &saipb.L2McGroupMemberAttribute{ + L2McGroupId: req.L2McGroupId, + L2McOutputId: req.L2McOutputId, + } + mg.mgr.StoreAttributes(id, attr) + // Update L2MC Group Attributes. + gReq := &saipb.GetL2McGroupAttributeRequest{Oid: req.GetL2McGroupId(), AttrType: []saipb.L2McGroupAttr{saipb.L2McGroupAttr_L2MC_GROUP_ATTR_L2MC_MEMBER_LIST, saipb.L2McGroupAttr_L2MC_GROUP_ATTR_L2MC_OUTPUT_COUNT}} + gResp := &saipb.GetL2McGroupAttributeResponse{} + if err := mg.mgr.PopulateAttributes(gReq, gResp); err != nil { + return nil, err + } + gAttrs := gResp.GetAttr() + gAttrs.L2McMemberList = append(gAttrs.GetL2McMemberList(), id) + *gAttrs.L2McOutputCount += 1 + mg.mgr.StoreAttributes(req.GetL2McGroupId(), gAttrs) + // Update Switch Attributes. + swReq := &saipb.GetSwitchAttributeRequest{Oid: req.GetSwitch(), AttrType: []saipb.SwitchAttr{saipb.SwitchAttr_SWITCH_ATTR_AVAILABLE_L2MC_ENTRY}} + swResp := &saipb.GetSwitchAttributeResponse{} + if err := mg.mgr.PopulateAttributes(swReq, swResp); err != nil { + return nil, err + } + attrs := swResp.GetAttr() + *attrs.AvailableL2McEntry = attrs.GetAvailableL2McEntry() - 1 + mg.mgr.StoreAttributes(req.GetSwitch(), attrs) return &saipb.CreateL2McGroupMemberResponse{Oid: id}, nil } -// TODO: Implement this. -func (mg *l2mcGroup) RemoveL2McGroup(context.Context, *saipb.RemoveL2McGroupRequest) (*saipb.RemoveL2McGroupResponse, error) { +func (mg *l2mcGroup) RemoveL2McGroup(ctx context.Context, req *saipb.RemoveL2McGroupRequest) (*saipb.RemoveL2McGroupResponse, error) { + if mg.groups[req.GetOid()] == nil { + return nil, fmt.Errorf("cannot find group %q", req.GetOid()) + } + // Remove all members in the group + for _, p := range mg.groups[req.GetOid()] { + _, err := attrmgr.InvokeAndSave(ctx, mg.mgr, mg.RemoveL2McGroupMember, &saipb.RemoveL2McGroupMemberRequest{ + Oid: p.oid, + }) + if err != nil { + return nil, err + } + } + // Update internal data + delete(mg.groups, req.GetOid()) return &saipb.RemoveL2McGroupResponse{}, nil } -// TODO: Implement this. -func (mg *l2mcGroup) RemoveL2McGroupMember(context.Context, *saipb.RemoveL2McGroupMemberRequest) (*saipb.RemoveL2McGroupMemberResponse, error) { +func (mg *l2mcGroup) RemoveL2McGroupMember(ctx context.Context, req *saipb.RemoveL2McGroupMemberRequest) (*saipb.RemoveL2McGroupMemberResponse, error) { + // Remove table entry. + r := fwdconfig.TableEntryRemoveRequest(mg.dataplane.ID(), L2MCGroupTable).AppendEntry( + fwdconfig.EntryDesc(fwdconfig.ExactEntry(fwdconfig.PacketFieldBytes(fwdpb.PacketFieldNum_PACKET_FIELD_NUM_L2MC_GROUP_ID).WithUint64(req.GetOid())))).Build() + if _, err := mg.dataplane.TableEntryRemove(ctx, r); err != nil { + return nil, err + } + // Update L2MC group attributes + locateMember := func(oid uint64) *l2mcGroupMember { + for _, members := range mg.groups { + for k, v := range members { + if k == oid { + return v + } + } + } + return nil + } + m := locateMember(req.GetOid()) + if m == nil { + return nil, fmt.Errorf("cannot find member with OID %d", req.GetOid()) + } + gReq := &saipb.GetL2McGroupAttributeRequest{Oid: m.groupId, AttrType: []saipb.L2McGroupAttr{saipb.L2McGroupAttr_L2MC_GROUP_ATTR_L2MC_MEMBER_LIST, saipb.L2McGroupAttr_L2MC_GROUP_ATTR_L2MC_OUTPUT_COUNT}} + gResp := &saipb.GetL2McGroupAttributeResponse{} + if err := mg.mgr.PopulateAttributes(gReq, gResp); err != nil { + return nil, err + } + gAttrs := gResp.GetAttr() + newMemList := []uint64{} + for _, i := range gAttrs.GetL2McMemberList() { + if i != req.GetOid() { + newMemList = append(newMemList, i) + } + } + gAttrs.L2McMemberList = newMemList + *gAttrs.L2McOutputCount -= 1 + mg.mgr.StoreAttributes(m.groupId, gAttrs) + // Update Switch Attributes. + swReq := &saipb.GetSwitchAttributeRequest{Oid: 1, AttrType: []saipb.SwitchAttr{saipb.SwitchAttr_SWITCH_ATTR_AVAILABLE_L2MC_ENTRY}} + swResp := &saipb.GetSwitchAttributeResponse{} + if err := mg.mgr.PopulateAttributes(swReq, swResp); err != nil { + return nil, err + } + attrs := swResp.GetAttr() + *attrs.AvailableL2McEntry = attrs.GetAvailableL2McEntry() + 1 + mg.mgr.StoreAttributes(1, attrs) + // Update internal data + delete(mg.groups[m.groupId], req.GetOid()) return &saipb.RemoveL2McGroupMemberResponse{}, nil } diff --git a/dataplane/saiserver/ports.go b/dataplane/saiserver/ports.go index c663fc5b..a2c98749 100644 --- a/dataplane/saiserver/ports.go +++ b/dataplane/saiserver/ports.go @@ -104,6 +104,7 @@ func getL3Pipeline() []*fwdpb.ActionDesc { func getL2Pipeline() []*fwdpb.ActionDesc { return []*fwdpb.ActionDesc{ fwdconfig.Action(fwdconfig.LookupAction(IngressActionTable)).Build(), // Run ingress action. + fwdconfig.Action(fwdconfig.LookupAction(L2MCGroupTable)).Build(), // Check L2MC group. fwdconfig.Action(fwdconfig.DropAction()).Build(), // DROP } } diff --git a/dataplane/saiserver/switch.go b/dataplane/saiserver/switch.go index fdd5cfdf..1e6fa928 100644 --- a/dataplane/saiserver/switch.go +++ b/dataplane/saiserver/switch.go @@ -109,6 +109,7 @@ const ( portToHostifTable = "cpu-output" tunTermTable = "tun-term" VlanTable = "vlan" + L2MCGroupTable = "l2mcg" DefaultVlanId = 1 ) @@ -269,6 +270,26 @@ func (sw *saiSwitch) CreateSwitch(ctx context.Context, _ *saipb.CreateSwitchRequ if _, err := sw.dataplane.TableCreate(ctx, vlanReq); err != nil { return nil, err } + l2mcGroupReq := &fwdpb.TableCreateRequest{ + ContextId: &fwdpb.ContextId{Id: sw.dataplane.ID()}, + Desc: &fwdpb.TableDesc{ + TableType: fwdpb.TableType_TABLE_TYPE_EXACT, + TableId: &fwdpb.TableId{ObjectId: &fwdpb.ObjectId{Id: L2MCGroupTable}}, + Actions: []*fwdpb.ActionDesc{{ActionType: fwdpb.ActionType_ACTION_TYPE_CONTINUE}}, + Table: &fwdpb.TableDesc_Exact{ + Exact: &fwdpb.ExactTableDesc{ + FieldIds: []*fwdpb.PacketFieldId{{ + Field: &fwdpb.PacketField{ + FieldNum: fwdpb.PacketFieldNum_PACKET_FIELD_NUM_L2MC_GROUP_ID, + }, + }}, + }, + }, + }, + } + if _, err := sw.dataplane.TableCreate(ctx, l2mcGroupReq); err != nil { + return nil, err + } action := &fwdpb.TableCreateRequest{ ContextId: &fwdpb.ContextId{Id: sw.dataplane.ID()}, Desc: &fwdpb.TableDesc{ diff --git a/proto/forwarding/forwarding_common.pb.go b/proto/forwarding/forwarding_common.pb.go index 8e5f1cac..f8a5645a 100644 --- a/proto/forwarding/forwarding_common.pb.go +++ b/proto/forwarding/forwarding_common.pb.go @@ -280,6 +280,7 @@ const ( PacketFieldNum_PACKET_FIELD_NUM_OUTPUT_IFACE PacketFieldNum = 61 PacketFieldNum_PACKET_FIELD_NUM_TUNNEL_ID PacketFieldNum = 62 PacketFieldNum_PACKET_FIELD_NUM_HOST_PORT_ID PacketFieldNum = 63 + PacketFieldNum_PACKET_FIELD_NUM_L2MC_GROUP_ID PacketFieldNum = 64 PacketFieldNum_PACKET_FIELD_NUM_COUNT PacketFieldNum = 1000 ) @@ -330,6 +331,7 @@ var ( 61: "PACKET_FIELD_NUM_OUTPUT_IFACE", 62: "PACKET_FIELD_NUM_TUNNEL_ID", 63: "PACKET_FIELD_NUM_HOST_PORT_ID", + 64: "PACKET_FIELD_NUM_L2MC_GROUP_ID", 1000: "PACKET_FIELD_NUM_COUNT", } PacketFieldNum_value = map[string]int32{ @@ -377,6 +379,7 @@ var ( "PACKET_FIELD_NUM_OUTPUT_IFACE": 61, "PACKET_FIELD_NUM_TUNNEL_ID": 62, "PACKET_FIELD_NUM_HOST_PORT_ID": 63, + "PACKET_FIELD_NUM_L2MC_GROUP_ID": 64, "PACKET_FIELD_NUM_COUNT": 1000, } ) @@ -2717,7 +2720,7 @@ var file_proto_forwarding_forwarding_common_proto_rawDesc = []byte{ 0x0a, 0x13, 0x50, 0x41, 0x43, 0x4b, 0x45, 0x54, 0x5f, 0x48, 0x45, 0x41, 0x44, 0x45, 0x52, 0x5f, 0x49, 0x44, 0x5f, 0x49, 0x50, 0x10, 0x13, 0x12, 0x1b, 0x0a, 0x16, 0x50, 0x41, 0x43, 0x4b, 0x45, 0x54, 0x5f, 0x48, 0x45, 0x41, 0x44, 0x45, 0x52, 0x5f, 0x49, 0x44, 0x5f, 0x43, 0x4f, 0x55, 0x4e, - 0x54, 0x10, 0xe8, 0x07, 0x2a, 0x8d, 0x0c, 0x0a, 0x0e, 0x50, 0x61, 0x63, 0x6b, 0x65, 0x74, 0x46, + 0x54, 0x10, 0xe8, 0x07, 0x2a, 0xb1, 0x0c, 0x0a, 0x0e, 0x50, 0x61, 0x63, 0x6b, 0x65, 0x74, 0x46, 0x69, 0x65, 0x6c, 0x64, 0x4e, 0x75, 0x6d, 0x12, 0x20, 0x0a, 0x1c, 0x50, 0x41, 0x43, 0x4b, 0x45, 0x54, 0x5f, 0x46, 0x49, 0x45, 0x4c, 0x44, 0x5f, 0x4e, 0x55, 0x4d, 0x5f, 0x55, 0x4e, 0x53, 0x50, 0x45, 0x43, 0x49, 0x46, 0x49, 0x45, 0x44, 0x10, 0x00, 0x12, 0x19, 0x0a, 0x15, 0x50, 0x41, 0x43, @@ -2812,98 +2815,100 @@ var file_proto_forwarding_forwarding_common_proto_rawDesc = []byte{ 0x49, 0x45, 0x4c, 0x44, 0x5f, 0x4e, 0x55, 0x4d, 0x5f, 0x54, 0x55, 0x4e, 0x4e, 0x45, 0x4c, 0x5f, 0x49, 0x44, 0x10, 0x3e, 0x12, 0x21, 0x0a, 0x1d, 0x50, 0x41, 0x43, 0x4b, 0x45, 0x54, 0x5f, 0x46, 0x49, 0x45, 0x4c, 0x44, 0x5f, 0x4e, 0x55, 0x4d, 0x5f, 0x48, 0x4f, 0x53, 0x54, 0x5f, 0x50, 0x4f, - 0x52, 0x54, 0x5f, 0x49, 0x44, 0x10, 0x3f, 0x12, 0x1b, 0x0a, 0x16, 0x50, 0x41, 0x43, 0x4b, 0x45, - 0x54, 0x5f, 0x46, 0x49, 0x45, 0x4c, 0x44, 0x5f, 0x4e, 0x55, 0x4d, 0x5f, 0x43, 0x4f, 0x55, 0x4e, - 0x54, 0x10, 0xe8, 0x07, 0x2a, 0xda, 0x0a, 0x0a, 0x09, 0x43, 0x6f, 0x75, 0x6e, 0x74, 0x65, 0x72, - 0x49, 0x64, 0x12, 0x1a, 0x0a, 0x16, 0x43, 0x4f, 0x55, 0x4e, 0x54, 0x45, 0x52, 0x5f, 0x49, 0x44, - 0x5f, 0x55, 0x4e, 0x53, 0x50, 0x45, 0x43, 0x49, 0x46, 0x49, 0x45, 0x44, 0x10, 0x00, 0x12, 0x19, - 0x0a, 0x15, 0x43, 0x4f, 0x55, 0x4e, 0x54, 0x45, 0x52, 0x5f, 0x49, 0x44, 0x5f, 0x52, 0x58, 0x5f, - 0x50, 0x41, 0x43, 0x4b, 0x45, 0x54, 0x53, 0x10, 0x01, 0x12, 0x18, 0x0a, 0x14, 0x43, 0x4f, 0x55, - 0x4e, 0x54, 0x45, 0x52, 0x5f, 0x49, 0x44, 0x5f, 0x52, 0x58, 0x5f, 0x4f, 0x43, 0x54, 0x45, 0x54, - 0x53, 0x10, 0x02, 0x12, 0x1e, 0x0a, 0x1a, 0x43, 0x4f, 0x55, 0x4e, 0x54, 0x45, 0x52, 0x5f, 0x49, - 0x44, 0x5f, 0x52, 0x58, 0x5f, 0x44, 0x52, 0x4f, 0x50, 0x5f, 0x50, 0x41, 0x43, 0x4b, 0x45, 0x54, - 0x53, 0x10, 0x03, 0x12, 0x1d, 0x0a, 0x19, 0x43, 0x4f, 0x55, 0x4e, 0x54, 0x45, 0x52, 0x5f, 0x49, - 0x44, 0x5f, 0x52, 0x58, 0x5f, 0x44, 0x52, 0x4f, 0x50, 0x5f, 0x4f, 0x43, 0x54, 0x45, 0x54, 0x53, - 0x10, 0x04, 0x12, 0x1f, 0x0a, 0x1b, 0x43, 0x4f, 0x55, 0x4e, 0x54, 0x45, 0x52, 0x5f, 0x49, 0x44, - 0x5f, 0x52, 0x58, 0x5f, 0x45, 0x52, 0x52, 0x4f, 0x52, 0x5f, 0x50, 0x41, 0x43, 0x4b, 0x45, 0x54, - 0x53, 0x10, 0x05, 0x12, 0x1e, 0x0a, 0x1a, 0x43, 0x4f, 0x55, 0x4e, 0x54, 0x45, 0x52, 0x5f, 0x49, - 0x44, 0x5f, 0x52, 0x58, 0x5f, 0x45, 0x52, 0x52, 0x4f, 0x52, 0x5f, 0x4f, 0x43, 0x54, 0x45, 0x54, - 0x53, 0x10, 0x06, 0x12, 0x19, 0x0a, 0x15, 0x43, 0x4f, 0x55, 0x4e, 0x54, 0x45, 0x52, 0x5f, 0x49, - 0x44, 0x5f, 0x54, 0x58, 0x5f, 0x50, 0x41, 0x43, 0x4b, 0x45, 0x54, 0x53, 0x10, 0x07, 0x12, 0x18, - 0x0a, 0x14, 0x43, 0x4f, 0x55, 0x4e, 0x54, 0x45, 0x52, 0x5f, 0x49, 0x44, 0x5f, 0x54, 0x58, 0x5f, - 0x4f, 0x43, 0x54, 0x45, 0x54, 0x53, 0x10, 0x08, 0x12, 0x1e, 0x0a, 0x1a, 0x43, 0x4f, 0x55, 0x4e, - 0x54, 0x45, 0x52, 0x5f, 0x49, 0x44, 0x5f, 0x54, 0x58, 0x5f, 0x44, 0x52, 0x4f, 0x50, 0x5f, 0x50, - 0x41, 0x43, 0x4b, 0x45, 0x54, 0x53, 0x10, 0x09, 0x12, 0x1d, 0x0a, 0x19, 0x43, 0x4f, 0x55, 0x4e, - 0x54, 0x45, 0x52, 0x5f, 0x49, 0x44, 0x5f, 0x54, 0x58, 0x5f, 0x44, 0x52, 0x4f, 0x50, 0x5f, 0x4f, - 0x43, 0x54, 0x45, 0x54, 0x53, 0x10, 0x0a, 0x12, 0x1f, 0x0a, 0x1b, 0x43, 0x4f, 0x55, 0x4e, 0x54, - 0x45, 0x52, 0x5f, 0x49, 0x44, 0x5f, 0x54, 0x58, 0x5f, 0x45, 0x52, 0x52, 0x4f, 0x52, 0x5f, 0x50, - 0x41, 0x43, 0x4b, 0x45, 0x54, 0x53, 0x10, 0x0b, 0x12, 0x1e, 0x0a, 0x1a, 0x43, 0x4f, 0x55, 0x4e, - 0x54, 0x45, 0x52, 0x5f, 0x49, 0x44, 0x5f, 0x54, 0x58, 0x5f, 0x45, 0x52, 0x52, 0x4f, 0x52, 0x5f, - 0x4f, 0x43, 0x54, 0x45, 0x54, 0x53, 0x10, 0x0c, 0x12, 0x20, 0x0a, 0x1c, 0x43, 0x4f, 0x55, 0x4e, - 0x54, 0x45, 0x52, 0x5f, 0x49, 0x44, 0x5f, 0x52, 0x41, 0x54, 0x45, 0x4c, 0x49, 0x4d, 0x49, 0x54, - 0x5f, 0x50, 0x41, 0x43, 0x4b, 0x45, 0x54, 0x53, 0x10, 0x0d, 0x12, 0x1f, 0x0a, 0x1b, 0x43, 0x4f, - 0x55, 0x4e, 0x54, 0x45, 0x52, 0x5f, 0x49, 0x44, 0x5f, 0x52, 0x41, 0x54, 0x45, 0x4c, 0x49, 0x4d, - 0x49, 0x54, 0x5f, 0x4f, 0x43, 0x54, 0x45, 0x54, 0x53, 0x10, 0x0e, 0x12, 0x1b, 0x0a, 0x17, 0x43, - 0x4f, 0x55, 0x4e, 0x54, 0x45, 0x52, 0x5f, 0x49, 0x44, 0x5f, 0x44, 0x52, 0x4f, 0x50, 0x5f, 0x50, - 0x41, 0x43, 0x4b, 0x45, 0x54, 0x53, 0x10, 0x0f, 0x12, 0x1a, 0x0a, 0x16, 0x43, 0x4f, 0x55, 0x4e, - 0x54, 0x45, 0x52, 0x5f, 0x49, 0x44, 0x5f, 0x44, 0x52, 0x4f, 0x50, 0x5f, 0x4f, 0x43, 0x54, 0x45, - 0x54, 0x53, 0x10, 0x10, 0x12, 0x1c, 0x0a, 0x18, 0x43, 0x4f, 0x55, 0x4e, 0x54, 0x45, 0x52, 0x5f, - 0x49, 0x44, 0x5f, 0x45, 0x52, 0x52, 0x4f, 0x52, 0x5f, 0x50, 0x41, 0x43, 0x4b, 0x45, 0x54, 0x53, - 0x10, 0x11, 0x12, 0x1b, 0x0a, 0x17, 0x43, 0x4f, 0x55, 0x4e, 0x54, 0x45, 0x52, 0x5f, 0x49, 0x44, - 0x5f, 0x45, 0x52, 0x52, 0x4f, 0x52, 0x5f, 0x4f, 0x43, 0x54, 0x45, 0x54, 0x53, 0x10, 0x12, 0x12, - 0x1d, 0x0a, 0x19, 0x43, 0x4f, 0x55, 0x4e, 0x54, 0x45, 0x52, 0x5f, 0x49, 0x44, 0x5f, 0x52, 0x58, - 0x5f, 0x42, 0x41, 0x44, 0x5f, 0x50, 0x41, 0x43, 0x4b, 0x45, 0x54, 0x53, 0x10, 0x13, 0x12, 0x1c, - 0x0a, 0x18, 0x43, 0x4f, 0x55, 0x4e, 0x54, 0x45, 0x52, 0x5f, 0x49, 0x44, 0x5f, 0x52, 0x58, 0x5f, - 0x42, 0x41, 0x44, 0x5f, 0x4f, 0x43, 0x54, 0x45, 0x54, 0x53, 0x10, 0x14, 0x12, 0x24, 0x0a, 0x20, - 0x43, 0x4f, 0x55, 0x4e, 0x54, 0x45, 0x52, 0x5f, 0x49, 0x44, 0x5f, 0x52, 0x58, 0x5f, 0x41, 0x44, - 0x4d, 0x49, 0x4e, 0x5f, 0x44, 0x52, 0x4f, 0x50, 0x5f, 0x50, 0x41, 0x43, 0x4b, 0x45, 0x54, 0x53, - 0x10, 0x15, 0x12, 0x23, 0x0a, 0x1f, 0x43, 0x4f, 0x55, 0x4e, 0x54, 0x45, 0x52, 0x5f, 0x49, 0x44, - 0x5f, 0x52, 0x58, 0x5f, 0x41, 0x44, 0x4d, 0x49, 0x4e, 0x5f, 0x44, 0x52, 0x4f, 0x50, 0x5f, 0x4f, - 0x43, 0x54, 0x45, 0x54, 0x53, 0x10, 0x16, 0x12, 0x24, 0x0a, 0x20, 0x43, 0x4f, 0x55, 0x4e, 0x54, - 0x45, 0x52, 0x5f, 0x49, 0x44, 0x5f, 0x54, 0x58, 0x5f, 0x41, 0x44, 0x4d, 0x49, 0x4e, 0x5f, 0x44, - 0x52, 0x4f, 0x50, 0x5f, 0x50, 0x41, 0x43, 0x4b, 0x45, 0x54, 0x53, 0x10, 0x17, 0x12, 0x23, 0x0a, - 0x1f, 0x43, 0x4f, 0x55, 0x4e, 0x54, 0x45, 0x52, 0x5f, 0x49, 0x44, 0x5f, 0x54, 0x58, 0x5f, 0x41, - 0x44, 0x4d, 0x49, 0x4e, 0x5f, 0x44, 0x52, 0x4f, 0x50, 0x5f, 0x4f, 0x43, 0x54, 0x45, 0x54, 0x53, - 0x10, 0x18, 0x12, 0x1d, 0x0a, 0x19, 0x43, 0x4f, 0x55, 0x4e, 0x54, 0x45, 0x52, 0x5f, 0x49, 0x44, - 0x5f, 0x4d, 0x49, 0x52, 0x52, 0x4f, 0x52, 0x5f, 0x50, 0x41, 0x43, 0x4b, 0x45, 0x54, 0x53, 0x10, - 0x19, 0x12, 0x1c, 0x0a, 0x18, 0x43, 0x4f, 0x55, 0x4e, 0x54, 0x45, 0x52, 0x5f, 0x49, 0x44, 0x5f, - 0x4d, 0x49, 0x52, 0x52, 0x4f, 0x52, 0x5f, 0x4f, 0x43, 0x54, 0x45, 0x54, 0x53, 0x10, 0x1a, 0x12, - 0x23, 0x0a, 0x1f, 0x43, 0x4f, 0x55, 0x4e, 0x54, 0x45, 0x52, 0x5f, 0x49, 0x44, 0x5f, 0x4d, 0x49, - 0x52, 0x52, 0x4f, 0x52, 0x5f, 0x45, 0x52, 0x52, 0x4f, 0x52, 0x5f, 0x50, 0x41, 0x43, 0x4b, 0x45, - 0x54, 0x53, 0x10, 0x1b, 0x12, 0x22, 0x0a, 0x1e, 0x43, 0x4f, 0x55, 0x4e, 0x54, 0x45, 0x52, 0x5f, - 0x49, 0x44, 0x5f, 0x4d, 0x49, 0x52, 0x52, 0x4f, 0x52, 0x5f, 0x45, 0x52, 0x52, 0x4f, 0x52, 0x5f, - 0x4f, 0x43, 0x54, 0x45, 0x54, 0x53, 0x10, 0x1c, 0x12, 0x22, 0x0a, 0x1e, 0x43, 0x4f, 0x55, 0x4e, - 0x54, 0x45, 0x52, 0x5f, 0x49, 0x44, 0x5f, 0x45, 0x4e, 0x43, 0x41, 0x50, 0x5f, 0x45, 0x52, 0x52, - 0x4f, 0x52, 0x5f, 0x50, 0x41, 0x43, 0x4b, 0x45, 0x54, 0x53, 0x10, 0x1d, 0x12, 0x21, 0x0a, 0x1d, + 0x52, 0x54, 0x5f, 0x49, 0x44, 0x10, 0x3f, 0x12, 0x22, 0x0a, 0x1e, 0x50, 0x41, 0x43, 0x4b, 0x45, + 0x54, 0x5f, 0x46, 0x49, 0x45, 0x4c, 0x44, 0x5f, 0x4e, 0x55, 0x4d, 0x5f, 0x4c, 0x32, 0x4d, 0x43, + 0x5f, 0x47, 0x52, 0x4f, 0x55, 0x50, 0x5f, 0x49, 0x44, 0x10, 0x40, 0x12, 0x1b, 0x0a, 0x16, 0x50, + 0x41, 0x43, 0x4b, 0x45, 0x54, 0x5f, 0x46, 0x49, 0x45, 0x4c, 0x44, 0x5f, 0x4e, 0x55, 0x4d, 0x5f, + 0x43, 0x4f, 0x55, 0x4e, 0x54, 0x10, 0xe8, 0x07, 0x2a, 0xda, 0x0a, 0x0a, 0x09, 0x43, 0x6f, 0x75, + 0x6e, 0x74, 0x65, 0x72, 0x49, 0x64, 0x12, 0x1a, 0x0a, 0x16, 0x43, 0x4f, 0x55, 0x4e, 0x54, 0x45, + 0x52, 0x5f, 0x49, 0x44, 0x5f, 0x55, 0x4e, 0x53, 0x50, 0x45, 0x43, 0x49, 0x46, 0x49, 0x45, 0x44, + 0x10, 0x00, 0x12, 0x19, 0x0a, 0x15, 0x43, 0x4f, 0x55, 0x4e, 0x54, 0x45, 0x52, 0x5f, 0x49, 0x44, + 0x5f, 0x52, 0x58, 0x5f, 0x50, 0x41, 0x43, 0x4b, 0x45, 0x54, 0x53, 0x10, 0x01, 0x12, 0x18, 0x0a, + 0x14, 0x43, 0x4f, 0x55, 0x4e, 0x54, 0x45, 0x52, 0x5f, 0x49, 0x44, 0x5f, 0x52, 0x58, 0x5f, 0x4f, + 0x43, 0x54, 0x45, 0x54, 0x53, 0x10, 0x02, 0x12, 0x1e, 0x0a, 0x1a, 0x43, 0x4f, 0x55, 0x4e, 0x54, + 0x45, 0x52, 0x5f, 0x49, 0x44, 0x5f, 0x52, 0x58, 0x5f, 0x44, 0x52, 0x4f, 0x50, 0x5f, 0x50, 0x41, + 0x43, 0x4b, 0x45, 0x54, 0x53, 0x10, 0x03, 0x12, 0x1d, 0x0a, 0x19, 0x43, 0x4f, 0x55, 0x4e, 0x54, + 0x45, 0x52, 0x5f, 0x49, 0x44, 0x5f, 0x52, 0x58, 0x5f, 0x44, 0x52, 0x4f, 0x50, 0x5f, 0x4f, 0x43, + 0x54, 0x45, 0x54, 0x53, 0x10, 0x04, 0x12, 0x1f, 0x0a, 0x1b, 0x43, 0x4f, 0x55, 0x4e, 0x54, 0x45, + 0x52, 0x5f, 0x49, 0x44, 0x5f, 0x52, 0x58, 0x5f, 0x45, 0x52, 0x52, 0x4f, 0x52, 0x5f, 0x50, 0x41, + 0x43, 0x4b, 0x45, 0x54, 0x53, 0x10, 0x05, 0x12, 0x1e, 0x0a, 0x1a, 0x43, 0x4f, 0x55, 0x4e, 0x54, + 0x45, 0x52, 0x5f, 0x49, 0x44, 0x5f, 0x52, 0x58, 0x5f, 0x45, 0x52, 0x52, 0x4f, 0x52, 0x5f, 0x4f, + 0x43, 0x54, 0x45, 0x54, 0x53, 0x10, 0x06, 0x12, 0x19, 0x0a, 0x15, 0x43, 0x4f, 0x55, 0x4e, 0x54, + 0x45, 0x52, 0x5f, 0x49, 0x44, 0x5f, 0x54, 0x58, 0x5f, 0x50, 0x41, 0x43, 0x4b, 0x45, 0x54, 0x53, + 0x10, 0x07, 0x12, 0x18, 0x0a, 0x14, 0x43, 0x4f, 0x55, 0x4e, 0x54, 0x45, 0x52, 0x5f, 0x49, 0x44, + 0x5f, 0x54, 0x58, 0x5f, 0x4f, 0x43, 0x54, 0x45, 0x54, 0x53, 0x10, 0x08, 0x12, 0x1e, 0x0a, 0x1a, + 0x43, 0x4f, 0x55, 0x4e, 0x54, 0x45, 0x52, 0x5f, 0x49, 0x44, 0x5f, 0x54, 0x58, 0x5f, 0x44, 0x52, + 0x4f, 0x50, 0x5f, 0x50, 0x41, 0x43, 0x4b, 0x45, 0x54, 0x53, 0x10, 0x09, 0x12, 0x1d, 0x0a, 0x19, + 0x43, 0x4f, 0x55, 0x4e, 0x54, 0x45, 0x52, 0x5f, 0x49, 0x44, 0x5f, 0x54, 0x58, 0x5f, 0x44, 0x52, + 0x4f, 0x50, 0x5f, 0x4f, 0x43, 0x54, 0x45, 0x54, 0x53, 0x10, 0x0a, 0x12, 0x1f, 0x0a, 0x1b, 0x43, + 0x4f, 0x55, 0x4e, 0x54, 0x45, 0x52, 0x5f, 0x49, 0x44, 0x5f, 0x54, 0x58, 0x5f, 0x45, 0x52, 0x52, + 0x4f, 0x52, 0x5f, 0x50, 0x41, 0x43, 0x4b, 0x45, 0x54, 0x53, 0x10, 0x0b, 0x12, 0x1e, 0x0a, 0x1a, + 0x43, 0x4f, 0x55, 0x4e, 0x54, 0x45, 0x52, 0x5f, 0x49, 0x44, 0x5f, 0x54, 0x58, 0x5f, 0x45, 0x52, + 0x52, 0x4f, 0x52, 0x5f, 0x4f, 0x43, 0x54, 0x45, 0x54, 0x53, 0x10, 0x0c, 0x12, 0x20, 0x0a, 0x1c, + 0x43, 0x4f, 0x55, 0x4e, 0x54, 0x45, 0x52, 0x5f, 0x49, 0x44, 0x5f, 0x52, 0x41, 0x54, 0x45, 0x4c, + 0x49, 0x4d, 0x49, 0x54, 0x5f, 0x50, 0x41, 0x43, 0x4b, 0x45, 0x54, 0x53, 0x10, 0x0d, 0x12, 0x1f, + 0x0a, 0x1b, 0x43, 0x4f, 0x55, 0x4e, 0x54, 0x45, 0x52, 0x5f, 0x49, 0x44, 0x5f, 0x52, 0x41, 0x54, + 0x45, 0x4c, 0x49, 0x4d, 0x49, 0x54, 0x5f, 0x4f, 0x43, 0x54, 0x45, 0x54, 0x53, 0x10, 0x0e, 0x12, + 0x1b, 0x0a, 0x17, 0x43, 0x4f, 0x55, 0x4e, 0x54, 0x45, 0x52, 0x5f, 0x49, 0x44, 0x5f, 0x44, 0x52, + 0x4f, 0x50, 0x5f, 0x50, 0x41, 0x43, 0x4b, 0x45, 0x54, 0x53, 0x10, 0x0f, 0x12, 0x1a, 0x0a, 0x16, + 0x43, 0x4f, 0x55, 0x4e, 0x54, 0x45, 0x52, 0x5f, 0x49, 0x44, 0x5f, 0x44, 0x52, 0x4f, 0x50, 0x5f, + 0x4f, 0x43, 0x54, 0x45, 0x54, 0x53, 0x10, 0x10, 0x12, 0x1c, 0x0a, 0x18, 0x43, 0x4f, 0x55, 0x4e, + 0x54, 0x45, 0x52, 0x5f, 0x49, 0x44, 0x5f, 0x45, 0x52, 0x52, 0x4f, 0x52, 0x5f, 0x50, 0x41, 0x43, + 0x4b, 0x45, 0x54, 0x53, 0x10, 0x11, 0x12, 0x1b, 0x0a, 0x17, 0x43, 0x4f, 0x55, 0x4e, 0x54, 0x45, + 0x52, 0x5f, 0x49, 0x44, 0x5f, 0x45, 0x52, 0x52, 0x4f, 0x52, 0x5f, 0x4f, 0x43, 0x54, 0x45, 0x54, + 0x53, 0x10, 0x12, 0x12, 0x1d, 0x0a, 0x19, 0x43, 0x4f, 0x55, 0x4e, 0x54, 0x45, 0x52, 0x5f, 0x49, + 0x44, 0x5f, 0x52, 0x58, 0x5f, 0x42, 0x41, 0x44, 0x5f, 0x50, 0x41, 0x43, 0x4b, 0x45, 0x54, 0x53, + 0x10, 0x13, 0x12, 0x1c, 0x0a, 0x18, 0x43, 0x4f, 0x55, 0x4e, 0x54, 0x45, 0x52, 0x5f, 0x49, 0x44, + 0x5f, 0x52, 0x58, 0x5f, 0x42, 0x41, 0x44, 0x5f, 0x4f, 0x43, 0x54, 0x45, 0x54, 0x53, 0x10, 0x14, + 0x12, 0x24, 0x0a, 0x20, 0x43, 0x4f, 0x55, 0x4e, 0x54, 0x45, 0x52, 0x5f, 0x49, 0x44, 0x5f, 0x52, + 0x58, 0x5f, 0x41, 0x44, 0x4d, 0x49, 0x4e, 0x5f, 0x44, 0x52, 0x4f, 0x50, 0x5f, 0x50, 0x41, 0x43, + 0x4b, 0x45, 0x54, 0x53, 0x10, 0x15, 0x12, 0x23, 0x0a, 0x1f, 0x43, 0x4f, 0x55, 0x4e, 0x54, 0x45, + 0x52, 0x5f, 0x49, 0x44, 0x5f, 0x52, 0x58, 0x5f, 0x41, 0x44, 0x4d, 0x49, 0x4e, 0x5f, 0x44, 0x52, + 0x4f, 0x50, 0x5f, 0x4f, 0x43, 0x54, 0x45, 0x54, 0x53, 0x10, 0x16, 0x12, 0x24, 0x0a, 0x20, 0x43, + 0x4f, 0x55, 0x4e, 0x54, 0x45, 0x52, 0x5f, 0x49, 0x44, 0x5f, 0x54, 0x58, 0x5f, 0x41, 0x44, 0x4d, + 0x49, 0x4e, 0x5f, 0x44, 0x52, 0x4f, 0x50, 0x5f, 0x50, 0x41, 0x43, 0x4b, 0x45, 0x54, 0x53, 0x10, + 0x17, 0x12, 0x23, 0x0a, 0x1f, 0x43, 0x4f, 0x55, 0x4e, 0x54, 0x45, 0x52, 0x5f, 0x49, 0x44, 0x5f, + 0x54, 0x58, 0x5f, 0x41, 0x44, 0x4d, 0x49, 0x4e, 0x5f, 0x44, 0x52, 0x4f, 0x50, 0x5f, 0x4f, 0x43, + 0x54, 0x45, 0x54, 0x53, 0x10, 0x18, 0x12, 0x1d, 0x0a, 0x19, 0x43, 0x4f, 0x55, 0x4e, 0x54, 0x45, + 0x52, 0x5f, 0x49, 0x44, 0x5f, 0x4d, 0x49, 0x52, 0x52, 0x4f, 0x52, 0x5f, 0x50, 0x41, 0x43, 0x4b, + 0x45, 0x54, 0x53, 0x10, 0x19, 0x12, 0x1c, 0x0a, 0x18, 0x43, 0x4f, 0x55, 0x4e, 0x54, 0x45, 0x52, + 0x5f, 0x49, 0x44, 0x5f, 0x4d, 0x49, 0x52, 0x52, 0x4f, 0x52, 0x5f, 0x4f, 0x43, 0x54, 0x45, 0x54, + 0x53, 0x10, 0x1a, 0x12, 0x23, 0x0a, 0x1f, 0x43, 0x4f, 0x55, 0x4e, 0x54, 0x45, 0x52, 0x5f, 0x49, + 0x44, 0x5f, 0x4d, 0x49, 0x52, 0x52, 0x4f, 0x52, 0x5f, 0x45, 0x52, 0x52, 0x4f, 0x52, 0x5f, 0x50, + 0x41, 0x43, 0x4b, 0x45, 0x54, 0x53, 0x10, 0x1b, 0x12, 0x22, 0x0a, 0x1e, 0x43, 0x4f, 0x55, 0x4e, + 0x54, 0x45, 0x52, 0x5f, 0x49, 0x44, 0x5f, 0x4d, 0x49, 0x52, 0x52, 0x4f, 0x52, 0x5f, 0x45, 0x52, + 0x52, 0x4f, 0x52, 0x5f, 0x4f, 0x43, 0x54, 0x45, 0x54, 0x53, 0x10, 0x1c, 0x12, 0x22, 0x0a, 0x1e, 0x43, 0x4f, 0x55, 0x4e, 0x54, 0x45, 0x52, 0x5f, 0x49, 0x44, 0x5f, 0x45, 0x4e, 0x43, 0x41, 0x50, - 0x5f, 0x45, 0x52, 0x52, 0x4f, 0x52, 0x5f, 0x4f, 0x43, 0x54, 0x45, 0x54, 0x53, 0x10, 0x1e, 0x12, - 0x22, 0x0a, 0x1e, 0x43, 0x4f, 0x55, 0x4e, 0x54, 0x45, 0x52, 0x5f, 0x49, 0x44, 0x5f, 0x44, 0x45, - 0x43, 0x41, 0x50, 0x5f, 0x45, 0x52, 0x52, 0x4f, 0x52, 0x5f, 0x50, 0x41, 0x43, 0x4b, 0x45, 0x54, - 0x53, 0x10, 0x1f, 0x12, 0x21, 0x0a, 0x1d, 0x43, 0x4f, 0x55, 0x4e, 0x54, 0x45, 0x52, 0x5f, 0x49, - 0x44, 0x5f, 0x44, 0x45, 0x43, 0x41, 0x50, 0x5f, 0x45, 0x52, 0x52, 0x4f, 0x52, 0x5f, 0x4f, 0x43, - 0x54, 0x45, 0x54, 0x53, 0x10, 0x20, 0x12, 0x22, 0x0a, 0x1e, 0x43, 0x4f, 0x55, 0x4e, 0x54, 0x45, - 0x52, 0x5f, 0x49, 0x44, 0x5f, 0x46, 0x4c, 0x4f, 0x57, 0x5f, 0x43, 0x4f, 0x55, 0x4e, 0x54, 0x45, - 0x52, 0x5f, 0x4f, 0x43, 0x54, 0x45, 0x54, 0x53, 0x10, 0x21, 0x12, 0x23, 0x0a, 0x1f, 0x43, 0x4f, + 0x5f, 0x45, 0x52, 0x52, 0x4f, 0x52, 0x5f, 0x50, 0x41, 0x43, 0x4b, 0x45, 0x54, 0x53, 0x10, 0x1d, + 0x12, 0x21, 0x0a, 0x1d, 0x43, 0x4f, 0x55, 0x4e, 0x54, 0x45, 0x52, 0x5f, 0x49, 0x44, 0x5f, 0x45, + 0x4e, 0x43, 0x41, 0x50, 0x5f, 0x45, 0x52, 0x52, 0x4f, 0x52, 0x5f, 0x4f, 0x43, 0x54, 0x45, 0x54, + 0x53, 0x10, 0x1e, 0x12, 0x22, 0x0a, 0x1e, 0x43, 0x4f, 0x55, 0x4e, 0x54, 0x45, 0x52, 0x5f, 0x49, + 0x44, 0x5f, 0x44, 0x45, 0x43, 0x41, 0x50, 0x5f, 0x45, 0x52, 0x52, 0x4f, 0x52, 0x5f, 0x50, 0x41, + 0x43, 0x4b, 0x45, 0x54, 0x53, 0x10, 0x1f, 0x12, 0x21, 0x0a, 0x1d, 0x43, 0x4f, 0x55, 0x4e, 0x54, + 0x45, 0x52, 0x5f, 0x49, 0x44, 0x5f, 0x44, 0x45, 0x43, 0x41, 0x50, 0x5f, 0x45, 0x52, 0x52, 0x4f, + 0x52, 0x5f, 0x4f, 0x43, 0x54, 0x45, 0x54, 0x53, 0x10, 0x20, 0x12, 0x22, 0x0a, 0x1e, 0x43, 0x4f, 0x55, 0x4e, 0x54, 0x45, 0x52, 0x5f, 0x49, 0x44, 0x5f, 0x46, 0x4c, 0x4f, 0x57, 0x5f, 0x43, 0x4f, - 0x55, 0x4e, 0x54, 0x45, 0x52, 0x5f, 0x50, 0x41, 0x43, 0x4b, 0x45, 0x54, 0x53, 0x10, 0x22, 0x12, - 0x1f, 0x0a, 0x1b, 0x43, 0x4f, 0x55, 0x4e, 0x54, 0x45, 0x52, 0x5f, 0x49, 0x44, 0x5f, 0x52, 0x58, - 0x5f, 0x44, 0x45, 0x42, 0x55, 0x47, 0x5f, 0x50, 0x41, 0x43, 0x4b, 0x45, 0x54, 0x53, 0x10, 0x23, - 0x12, 0x1e, 0x0a, 0x1a, 0x43, 0x4f, 0x55, 0x4e, 0x54, 0x45, 0x52, 0x5f, 0x49, 0x44, 0x5f, 0x52, - 0x58, 0x5f, 0x44, 0x45, 0x42, 0x55, 0x47, 0x5f, 0x4f, 0x43, 0x54, 0x45, 0x54, 0x53, 0x10, 0x24, - 0x12, 0x1f, 0x0a, 0x1b, 0x43, 0x4f, 0x55, 0x4e, 0x54, 0x45, 0x52, 0x5f, 0x49, 0x44, 0x5f, 0x52, - 0x58, 0x5f, 0x55, 0x43, 0x41, 0x53, 0x54, 0x5f, 0x50, 0x41, 0x43, 0x4b, 0x45, 0x54, 0x53, 0x10, - 0x25, 0x12, 0x23, 0x0a, 0x1f, 0x43, 0x4f, 0x55, 0x4e, 0x54, 0x45, 0x52, 0x5f, 0x49, 0x44, 0x5f, - 0x52, 0x58, 0x5f, 0x4e, 0x4f, 0x4e, 0x5f, 0x55, 0x43, 0x41, 0x53, 0x54, 0x5f, 0x50, 0x41, 0x43, - 0x4b, 0x45, 0x54, 0x53, 0x10, 0x26, 0x12, 0x1f, 0x0a, 0x1b, 0x43, 0x4f, 0x55, 0x4e, 0x54, 0x45, - 0x52, 0x5f, 0x49, 0x44, 0x5f, 0x54, 0x58, 0x5f, 0x55, 0x43, 0x41, 0x53, 0x54, 0x5f, 0x50, 0x41, - 0x43, 0x4b, 0x45, 0x54, 0x53, 0x10, 0x27, 0x12, 0x23, 0x0a, 0x1f, 0x43, 0x4f, 0x55, 0x4e, 0x54, - 0x45, 0x52, 0x5f, 0x49, 0x44, 0x5f, 0x54, 0x58, 0x5f, 0x4e, 0x4f, 0x4e, 0x5f, 0x55, 0x43, 0x41, - 0x53, 0x54, 0x5f, 0x50, 0x41, 0x43, 0x4b, 0x45, 0x54, 0x53, 0x10, 0x28, 0x12, 0x13, 0x0a, 0x0e, - 0x43, 0x4f, 0x55, 0x4e, 0x54, 0x45, 0x52, 0x5f, 0x49, 0x44, 0x5f, 0x4d, 0x41, 0x58, 0x10, 0xff, - 0x01, 0x42, 0x30, 0x5a, 0x2e, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, - 0x6f, 0x70, 0x65, 0x6e, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2f, 0x6c, 0x65, 0x6d, 0x6d, 0x69, - 0x6e, 0x67, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x66, 0x6f, 0x72, 0x77, 0x61, 0x72, 0x64, - 0x69, 0x6e, 0x67, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x55, 0x4e, 0x54, 0x45, 0x52, 0x5f, 0x4f, 0x43, 0x54, 0x45, 0x54, 0x53, 0x10, 0x21, 0x12, 0x23, + 0x0a, 0x1f, 0x43, 0x4f, 0x55, 0x4e, 0x54, 0x45, 0x52, 0x5f, 0x49, 0x44, 0x5f, 0x46, 0x4c, 0x4f, + 0x57, 0x5f, 0x43, 0x4f, 0x55, 0x4e, 0x54, 0x45, 0x52, 0x5f, 0x50, 0x41, 0x43, 0x4b, 0x45, 0x54, + 0x53, 0x10, 0x22, 0x12, 0x1f, 0x0a, 0x1b, 0x43, 0x4f, 0x55, 0x4e, 0x54, 0x45, 0x52, 0x5f, 0x49, + 0x44, 0x5f, 0x52, 0x58, 0x5f, 0x44, 0x45, 0x42, 0x55, 0x47, 0x5f, 0x50, 0x41, 0x43, 0x4b, 0x45, + 0x54, 0x53, 0x10, 0x23, 0x12, 0x1e, 0x0a, 0x1a, 0x43, 0x4f, 0x55, 0x4e, 0x54, 0x45, 0x52, 0x5f, + 0x49, 0x44, 0x5f, 0x52, 0x58, 0x5f, 0x44, 0x45, 0x42, 0x55, 0x47, 0x5f, 0x4f, 0x43, 0x54, 0x45, + 0x54, 0x53, 0x10, 0x24, 0x12, 0x1f, 0x0a, 0x1b, 0x43, 0x4f, 0x55, 0x4e, 0x54, 0x45, 0x52, 0x5f, + 0x49, 0x44, 0x5f, 0x52, 0x58, 0x5f, 0x55, 0x43, 0x41, 0x53, 0x54, 0x5f, 0x50, 0x41, 0x43, 0x4b, + 0x45, 0x54, 0x53, 0x10, 0x25, 0x12, 0x23, 0x0a, 0x1f, 0x43, 0x4f, 0x55, 0x4e, 0x54, 0x45, 0x52, + 0x5f, 0x49, 0x44, 0x5f, 0x52, 0x58, 0x5f, 0x4e, 0x4f, 0x4e, 0x5f, 0x55, 0x43, 0x41, 0x53, 0x54, + 0x5f, 0x50, 0x41, 0x43, 0x4b, 0x45, 0x54, 0x53, 0x10, 0x26, 0x12, 0x1f, 0x0a, 0x1b, 0x43, 0x4f, + 0x55, 0x4e, 0x54, 0x45, 0x52, 0x5f, 0x49, 0x44, 0x5f, 0x54, 0x58, 0x5f, 0x55, 0x43, 0x41, 0x53, + 0x54, 0x5f, 0x50, 0x41, 0x43, 0x4b, 0x45, 0x54, 0x53, 0x10, 0x27, 0x12, 0x23, 0x0a, 0x1f, 0x43, + 0x4f, 0x55, 0x4e, 0x54, 0x45, 0x52, 0x5f, 0x49, 0x44, 0x5f, 0x54, 0x58, 0x5f, 0x4e, 0x4f, 0x4e, + 0x5f, 0x55, 0x43, 0x41, 0x53, 0x54, 0x5f, 0x50, 0x41, 0x43, 0x4b, 0x45, 0x54, 0x53, 0x10, 0x28, + 0x12, 0x13, 0x0a, 0x0e, 0x43, 0x4f, 0x55, 0x4e, 0x54, 0x45, 0x52, 0x5f, 0x49, 0x44, 0x5f, 0x4d, + 0x41, 0x58, 0x10, 0xff, 0x01, 0x42, 0x30, 0x5a, 0x2e, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, + 0x63, 0x6f, 0x6d, 0x2f, 0x6f, 0x70, 0x65, 0x6e, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2f, 0x6c, + 0x65, 0x6d, 0x6d, 0x69, 0x6e, 0x67, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x66, 0x6f, 0x72, + 0x77, 0x61, 0x72, 0x64, 0x69, 0x6e, 0x67, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( diff --git a/proto/forwarding/forwarding_common.proto b/proto/forwarding/forwarding_common.proto index 67082d50..f03c40f6 100644 --- a/proto/forwarding/forwarding_common.proto +++ b/proto/forwarding/forwarding_common.proto @@ -176,6 +176,7 @@ enum PacketFieldNum { PACKET_FIELD_NUM_OUTPUT_IFACE = 61; // Output L3 interface (metadata). PACKET_FIELD_NUM_TUNNEL_ID = 62; // Tunnel ID (metadata). PACKET_FIELD_NUM_HOST_PORT_ID = 63; // Host port id (metadata). + PACKET_FIELD_NUM_L2MC_GROUP_ID = 64; // L2MC Group id (metadata). PACKET_FIELD_NUM_COUNT = 1000; } From 6a4e1553f09b94b435964e24c95adc350576f36d Mon Sep 17 00:00:00 2001 From: Guo-shiuan Wang Date: Wed, 17 Jul 2024 07:00:34 +0000 Subject: [PATCH 02/11] Modify the CPU port ingress pipeline. --- dataplane/saiserver/ports.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/dataplane/saiserver/ports.go b/dataplane/saiserver/ports.go index a2c98749..58aeecdf 100644 --- a/dataplane/saiserver/ports.go +++ b/dataplane/saiserver/ports.go @@ -104,7 +104,6 @@ func getL3Pipeline() []*fwdpb.ActionDesc { func getL2Pipeline() []*fwdpb.ActionDesc { return []*fwdpb.ActionDesc{ fwdconfig.Action(fwdconfig.LookupAction(IngressActionTable)).Build(), // Run ingress action. - fwdconfig.Action(fwdconfig.LookupAction(L2MCGroupTable)).Build(), // Check L2MC group. fwdconfig.Action(fwdconfig.DropAction()).Build(), // DROP } } @@ -449,6 +448,8 @@ func (port *port) createCPUPort(ctx context.Context) (uint64, error) { Port: &fwdpb.PortUpdateDesc_Cpu{ Cpu: &fwdpb.CPUPortUpdateDesc{ Inputs: []*fwdpb.ActionDesc{ + fwdconfig.Action(fwdconfig.LookupAction(IngressActionTable)).Build(), // Run ingress action. + fwdconfig.Action(fwdconfig.LookupAction(L2MCGroupTable)).Build(), // Check L2MC group. fwdconfig.Action(fwdconfig.LookupAction(hostifToPortTable)).Build(), }, Outputs: []*fwdpb.ActionDesc{ From 858b934dddd0f073680593e12523d5b64304bdb3 Mon Sep 17 00:00:00 2001 From: Guo-shiuan Wang Date: Wed, 17 Jul 2024 18:03:59 +0000 Subject: [PATCH 03/11] Fix. --- dataplane/forwarding/protocol/attr.go | 1 + 1 file changed, 1 insertion(+) diff --git a/dataplane/forwarding/protocol/attr.go b/dataplane/forwarding/protocol/attr.go index 445a4e6b..a23150b2 100644 --- a/dataplane/forwarding/protocol/attr.go +++ b/dataplane/forwarding/protocol/attr.go @@ -232,6 +232,7 @@ var GroupAttr = map[fwdpb.PacketHeaderGroup]struct { fwdpb.PacketFieldNum_PACKET_FIELD_NUM_OUTPUT_IFACE, fwdpb.PacketFieldNum_PACKET_FIELD_NUM_TUNNEL_ID, fwdpb.PacketFieldNum_PACKET_FIELD_NUM_HOST_PORT_ID, + fwdpb.PacketFieldNum_PACKET_FIELD_NUM_L2MC_GROUP_ID, }, }, fwdpb.PacketHeaderGroup_PACKET_HEADER_GROUP_L2: { From 65ce2ab6c2588126c92db62830e5678fa7d1028b Mon Sep 17 00:00:00 2001 From: Guo-shiuan Wang Date: Wed, 17 Jul 2024 21:55:31 +0000 Subject: [PATCH 04/11] Feedback. --- dataplane/saiserver/acl.go | 13 ++- dataplane/saiserver/l2.go | 166 +++++++++++++++++++---------------- dataplane/saiserver/ports.go | 3 +- 3 files changed, 99 insertions(+), 83 deletions(-) diff --git a/dataplane/saiserver/acl.go b/dataplane/saiserver/acl.go index 7de8b852..e195385d 100644 --- a/dataplane/saiserver/acl.go +++ b/dataplane/saiserver/acl.go @@ -329,9 +329,16 @@ func (a *acl) CreateAclEntry(ctx context.Context, req *saipb.CreateAclEntryReque }) } if req.ActionRedirect != nil { - aReq.Actions = append(aReq.Actions, - fwdconfig.Action(fwdconfig.UpdateAction(fwdpb.UpdateType_UPDATE_TYPE_SET, - fwdpb.PacketFieldNum_PACKET_FIELD_NUM_L2MC_GROUP_ID).WithUint64Value(req.GetActionRedirect().GetOid())).Build()) + switch typ := a.mgr.GetType(fmt.Sprint(req.GetActionRedirect().GetOid())); typ { + case saipb.ObjectType_OBJECT_TYPE_L2MC_GROUP: + aReq.Actions = append(aReq.Actions, []*fwdpb.ActionDesc{ + fwdconfig.Action(fwdconfig.UpdateAction(fwdpb.UpdateType_UPDATE_TYPE_SET, + fwdpb.PacketFieldNum_PACKET_FIELD_NUM_L2MC_GROUP_ID).WithUint64Value(req.GetActionRedirect().GetOid())).Build(), + fwdconfig.Action(fwdconfig.LookupAction(L2MCGroupTable)).Build(), // Check L2MC group. + }...) + default: + return nil, status.Errorf(codes.InvalidArgument, "type %q is not supported; only support L2MC Group for ACL Redirect for now", typ.String()) + } } cpuPortReq := &saipb.GetSwitchAttributeRequest{Oid: switchID, AttrType: []saipb.SwitchAttr{saipb.SwitchAttr_SWITCH_ATTR_CPU_PORT}} diff --git a/dataplane/saiserver/l2.go b/dataplane/saiserver/l2.go index c334005e..d08abd0c 100644 --- a/dataplane/saiserver/l2.go +++ b/dataplane/saiserver/l2.go @@ -16,12 +16,14 @@ package saiserver import ( "context" + "encoding/binary" "fmt" "google.golang.org/grpc" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/status" "google.golang.org/protobuf/proto" - "github.com/openconfig/lemming/dataplane/forwarding/fwdconfig" "github.com/openconfig/lemming/dataplane/saiserver/attrmgr" fwdpb "github.com/openconfig/lemming/proto/forwarding" @@ -38,7 +40,7 @@ type l2mcGroup struct { saipb.UnimplementedL2McGroupServer mgr *attrmgr.AttrMgr dataplane switchDataplaneAPI - groups map[uint64]map[uint64]*l2mcGroupMember // OID -> map of Port + groups map[uint64]map[uint64]*l2mcGroupMember // map[group id][member oid] } func newL2mcGroup(mgr *attrmgr.AttrMgr, dataplane switchDataplaneAPI, s *grpc.Server) *l2mcGroup { @@ -63,71 +65,111 @@ func (mg *l2mcGroup) CreateL2McGroup(ctx context.Context, req *saipb.CreateL2McG return &saipb.CreateL2McGroupResponse{Oid: id}, nil } -func (mg *l2mcGroup) CreateL2McGroupMember(ctx context.Context, req *saipb.CreateL2McGroupMemberRequest) (*saipb.CreateL2McGroupMemberResponse, error) { - id := mg.mgr.NextID() - // Update table entry - r := fwdconfig.TableEntryAddRequest(mg.dataplane.ID(), L2MCGroupTable).AppendEntry( - fwdconfig.EntryDesc(fwdconfig.ExactEntry(fwdconfig.PacketFieldBytes(fwdpb.PacketFieldNum_PACKET_FIELD_NUM_L2MC_GROUP_ID).WithUint64(req.GetL2McGroupId())))).Build() - for _, p := range mg.groups { - r.Entries[0].Actions = append(r.Entries[0].Actions, &fwdpb.ActionDesc{ +// updateGroupMember updates the member of a L2MC group. +// If m is nil, remove mid from the group(key: group id), otherwise add m to groups with mid as the key. +func (mg *l2mcGroup) updateGroupMember(ctx context.Context, gid, mid uint64, m *l2mcGroupMember) error { + if mg.groups[gid] == nil { + return status.Errorf(codes.FailedPrecondition, "L2MC group %d does not exist", gid) + } + if m == nil { + // Remove the member. + delete(mg.groups[gid], mid) + if len(mg.groups[gid]) == 0 { + delete(mg.groups, gid) + } + gReq := &saipb.GetL2McGroupAttributeRequest{Oid: gid, AttrType: []saipb.L2McGroupAttr{saipb.L2McGroupAttr_L2MC_GROUP_ATTR_L2MC_MEMBER_LIST, saipb.L2McGroupAttr_L2MC_GROUP_ATTR_L2MC_OUTPUT_COUNT}} + gResp := &saipb.GetL2McGroupAttributeResponse{} + if err := mg.mgr.PopulateAttributes(gReq, gResp); err != nil { + return err + } + gAttrs := gResp.GetAttr() + newMemList := []uint64{} + for _, i := range gAttrs.GetL2McMemberList() { + if i != mid { + newMemList = append(newMemList, i) + } + } + gAttrs.L2McMemberList = newMemList + *gAttrs.L2McOutputCount -= 1 + mg.mgr.StoreAttributes(gid, gAttrs) + } else { + // Add a member. + mg.groups[gid][mid] = m + attr := &saipb.L2McGroupMemberAttribute{ + L2McGroupId: &m.groupId, + L2McOutputId: &m.outputId, + } + mg.mgr.StoreAttributes(mid, attr) + // Update L2MC Group Attributes. + gReq := &saipb.GetL2McGroupAttributeRequest{Oid: gid, AttrType: []saipb.L2McGroupAttr{saipb.L2McGroupAttr_L2MC_GROUP_ATTR_L2MC_MEMBER_LIST, saipb.L2McGroupAttr_L2MC_GROUP_ATTR_L2MC_OUTPUT_COUNT}} + gResp := &saipb.GetL2McGroupAttributeResponse{} + if err := mg.mgr.PopulateAttributes(gReq, gResp); err != nil { + return err + } + gAttrs := gResp.GetAttr() + gAttrs.L2McMemberList = append(gAttrs.GetL2McMemberList(), mid) + *gAttrs.L2McOutputCount += 1 + mg.mgr.StoreAttributes(gid, gAttrs) + } + var actions []*fwdpb.ActionDesc + for _, member := range mg.groups[gid] { + actions = append(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(p), + Id: fmt.Sprint(member), }, }, }, }, }) } - if _, err := mg.dataplane.TableEntryAdd(ctx, r); err != nil { - return nil, err - } - // Update internal data - if mg.groups[req.GetL2McGroupId()] == nil { - return nil, fmt.Errorf("L2MC group id %q not found", req.GetL2McGroupId()) - } - if _, ok := mg.groups[req.GetL2McGroupId()][req.GetL2McOutputId()]; ok { - return nil, fmt.Errorf("found existing member %q", req.GetL2McOutputId()) + entries := &fwdpb.TableEntryAddRequest{ + ContextId: &fwdpb.ContextId{Id: mg.dataplane.ID()}, + TableId: &fwdpb.TableId{ + ObjectId: &fwdpb.ObjectId{ + Id: L2MCGroupTable, + }, + }, + Entries: []*fwdpb.TableEntryAddRequest_Entry{{ + EntryDesc: &fwdpb.EntryDesc{ + Entry: &fwdpb.EntryDesc_Exact{ + Exact: &fwdpb.ExactEntryDesc{ + Fields: []*fwdpb.PacketFieldBytes{{ + Bytes: binary.BigEndian.AppendUint64(nil, gid), + FieldId: &fwdpb.PacketFieldId{ + Field: &fwdpb.PacketField{ + FieldNum: fwdpb.PacketFieldNum_PACKET_FIELD_NUM_L2MC_GROUP_ID, + }, + }, + }}, + }, + }, + }, + Actions: actions, + }}, } - mg.groups[req.GetL2McGroupId()][req.GetL2McOutputId()] = &l2mcGroupMember{ + _, err := mg.dataplane.TableEntryAdd(ctx, entries) + return err +} + +func (mg *l2mcGroup) CreateL2McGroupMember(ctx context.Context, req *saipb.CreateL2McGroupMemberRequest) (*saipb.CreateL2McGroupMemberResponse, error) { + id := mg.mgr.NextID() + if err := mg.updateGroupMember(ctx, req.GetL2McGroupId(), id, &l2mcGroupMember{ oid: id, outputId: req.GetL2McOutputId(), groupId: req.GetL2McGroupId(), - } - // Update L2MC Group member attributes - attr := &saipb.L2McGroupMemberAttribute{ - L2McGroupId: req.L2McGroupId, - L2McOutputId: req.L2McOutputId, - } - mg.mgr.StoreAttributes(id, attr) - // Update L2MC Group Attributes. - gReq := &saipb.GetL2McGroupAttributeRequest{Oid: req.GetL2McGroupId(), AttrType: []saipb.L2McGroupAttr{saipb.L2McGroupAttr_L2MC_GROUP_ATTR_L2MC_MEMBER_LIST, saipb.L2McGroupAttr_L2MC_GROUP_ATTR_L2MC_OUTPUT_COUNT}} - gResp := &saipb.GetL2McGroupAttributeResponse{} - if err := mg.mgr.PopulateAttributes(gReq, gResp); err != nil { - return nil, err - } - gAttrs := gResp.GetAttr() - gAttrs.L2McMemberList = append(gAttrs.GetL2McMemberList(), id) - *gAttrs.L2McOutputCount += 1 - mg.mgr.StoreAttributes(req.GetL2McGroupId(), gAttrs) - // Update Switch Attributes. - swReq := &saipb.GetSwitchAttributeRequest{Oid: req.GetSwitch(), AttrType: []saipb.SwitchAttr{saipb.SwitchAttr_SWITCH_ATTR_AVAILABLE_L2MC_ENTRY}} - swResp := &saipb.GetSwitchAttributeResponse{} - if err := mg.mgr.PopulateAttributes(swReq, swResp); err != nil { + }); err != nil { return nil, err } - attrs := swResp.GetAttr() - *attrs.AvailableL2McEntry = attrs.GetAvailableL2McEntry() - 1 - mg.mgr.StoreAttributes(req.GetSwitch(), attrs) return &saipb.CreateL2McGroupMemberResponse{Oid: id}, nil } func (mg *l2mcGroup) RemoveL2McGroup(ctx context.Context, req *saipb.RemoveL2McGroupRequest) (*saipb.RemoveL2McGroupResponse, error) { if mg.groups[req.GetOid()] == nil { - return nil, fmt.Errorf("cannot find group %q", req.GetOid()) + return nil, fmt.Errorf("cannot find L2MC group %q", req.GetOid()) } // Remove all members in the group for _, p := range mg.groups[req.GetOid()] { @@ -138,19 +180,10 @@ func (mg *l2mcGroup) RemoveL2McGroup(ctx context.Context, req *saipb.RemoveL2McG return nil, err } } - // Update internal data - delete(mg.groups, req.GetOid()) return &saipb.RemoveL2McGroupResponse{}, nil } func (mg *l2mcGroup) RemoveL2McGroupMember(ctx context.Context, req *saipb.RemoveL2McGroupMemberRequest) (*saipb.RemoveL2McGroupMemberResponse, error) { - // Remove table entry. - r := fwdconfig.TableEntryRemoveRequest(mg.dataplane.ID(), L2MCGroupTable).AppendEntry( - fwdconfig.EntryDesc(fwdconfig.ExactEntry(fwdconfig.PacketFieldBytes(fwdpb.PacketFieldNum_PACKET_FIELD_NUM_L2MC_GROUP_ID).WithUint64(req.GetOid())))).Build() - if _, err := mg.dataplane.TableEntryRemove(ctx, r); err != nil { - return nil, err - } - // Update L2MC group attributes locateMember := func(oid uint64) *l2mcGroupMember { for _, members := range mg.groups { for k, v := range members { @@ -165,32 +198,9 @@ func (mg *l2mcGroup) RemoveL2McGroupMember(ctx context.Context, req *saipb.Remov if m == nil { return nil, fmt.Errorf("cannot find member with OID %d", req.GetOid()) } - gReq := &saipb.GetL2McGroupAttributeRequest{Oid: m.groupId, AttrType: []saipb.L2McGroupAttr{saipb.L2McGroupAttr_L2MC_GROUP_ATTR_L2MC_MEMBER_LIST, saipb.L2McGroupAttr_L2MC_GROUP_ATTR_L2MC_OUTPUT_COUNT}} - gResp := &saipb.GetL2McGroupAttributeResponse{} - if err := mg.mgr.PopulateAttributes(gReq, gResp); err != nil { - return nil, err - } - gAttrs := gResp.GetAttr() - newMemList := []uint64{} - for _, i := range gAttrs.GetL2McMemberList() { - if i != req.GetOid() { - newMemList = append(newMemList, i) - } - } - gAttrs.L2McMemberList = newMemList - *gAttrs.L2McOutputCount -= 1 - mg.mgr.StoreAttributes(m.groupId, gAttrs) - // Update Switch Attributes. - swReq := &saipb.GetSwitchAttributeRequest{Oid: 1, AttrType: []saipb.SwitchAttr{saipb.SwitchAttr_SWITCH_ATTR_AVAILABLE_L2MC_ENTRY}} - swResp := &saipb.GetSwitchAttributeResponse{} - if err := mg.mgr.PopulateAttributes(swReq, swResp); err != nil { + if err := mg.updateGroupMember(ctx, m.groupId, m.oid, nil); err != nil { return nil, err } - attrs := swResp.GetAttr() - *attrs.AvailableL2McEntry = attrs.GetAvailableL2McEntry() + 1 - mg.mgr.StoreAttributes(1, attrs) - // Update internal data - delete(mg.groups[m.groupId], req.GetOid()) return &saipb.RemoveL2McGroupMemberResponse{}, nil } diff --git a/dataplane/saiserver/ports.go b/dataplane/saiserver/ports.go index 58aeecdf..8f9dd4c5 100644 --- a/dataplane/saiserver/ports.go +++ b/dataplane/saiserver/ports.go @@ -448,12 +448,11 @@ func (port *port) createCPUPort(ctx context.Context) (uint64, error) { Port: &fwdpb.PortUpdateDesc_Cpu{ Cpu: &fwdpb.CPUPortUpdateDesc{ Inputs: []*fwdpb.ActionDesc{ - fwdconfig.Action(fwdconfig.LookupAction(IngressActionTable)).Build(), // Run ingress action. - fwdconfig.Action(fwdconfig.LookupAction(L2MCGroupTable)).Build(), // Check L2MC group. fwdconfig.Action(fwdconfig.LookupAction(hostifToPortTable)).Build(), }, Outputs: []*fwdpb.ActionDesc{ fwdconfig.Action(fwdconfig.LookupAction(trapIDToHostifTable)).Build(), + fwdconfig.Action(fwdconfig.LookupAction(L2MCGroupTable)).Build(), // Check L2MC group. fwdconfig.Action(fwdconfig.LookupAction(portToHostifTable)).Build(), }, }, From deb540072823efecacf517851fd669ca7dca7a51 Mon Sep 17 00:00:00 2001 From: Guo-shiuan Wang Date: Wed, 17 Jul 2024 22:01:02 +0000 Subject: [PATCH 05/11] Fix. --- dataplane/saiserver/l2.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dataplane/saiserver/l2.go b/dataplane/saiserver/l2.go index d08abd0c..26dedcaf 100644 --- a/dataplane/saiserver/l2.go +++ b/dataplane/saiserver/l2.go @@ -119,7 +119,7 @@ func (mg *l2mcGroup) updateGroupMember(ctx context.Context, gid, mid uint64, m * Mirror: &fwdpb.MirrorActionDesc{ PortId: &fwdpb.PortId{ ObjectId: &fwdpb.ObjectId{ - Id: fmt.Sprint(member), + Id: fmt.Sprint(member.outputId), }, }, }, From f89ab2d496540d378e2b98862d3c4c27c20d16be Mon Sep 17 00:00:00 2001 From: Guo-shiuan Wang Date: Fri, 19 Jul 2024 01:46:58 +0000 Subject: [PATCH 06/11] Add unit tests. --- dataplane/saiserver/BUILD | 1 + dataplane/saiserver/l2.go | 34 +++- dataplane/saiserver/l2mc_test.go | 303 +++++++++++++++++++++++++++++++ 3 files changed, 331 insertions(+), 7 deletions(-) create mode 100644 dataplane/saiserver/l2mc_test.go diff --git a/dataplane/saiserver/BUILD b/dataplane/saiserver/BUILD index cb2c917e..691f9d81 100644 --- a/dataplane/saiserver/BUILD +++ b/dataplane/saiserver/BUILD @@ -43,6 +43,7 @@ go_test( srcs = [ "acl_test.go", "hostif_test.go", + "l2mc_test.go", "ports_test.go", "routing_test.go", "switch_test.go", diff --git a/dataplane/saiserver/l2.go b/dataplane/saiserver/l2.go index 26dedcaf..b9a77bca 100644 --- a/dataplane/saiserver/l2.go +++ b/dataplane/saiserver/l2.go @@ -47,6 +47,7 @@ func newL2mcGroup(mgr *attrmgr.AttrMgr, dataplane switchDataplaneAPI, s *grpc.Se mg := &l2mcGroup{ mgr: mgr, dataplane: dataplane, + groups: map[uint64]map[uint64]*l2mcGroupMember{}, } saipb.RegisterL2McGroupServer(s, mg) return mg @@ -65,12 +66,21 @@ func (mg *l2mcGroup) CreateL2McGroup(ctx context.Context, req *saipb.CreateL2McG return &saipb.CreateL2McGroupResponse{Oid: id}, nil } +func (mg *l2mcGroup) portNidFromBrirdgeId(ctx context.Context, outputId uint64) (uint64, error) { + req := &saipb.GetBridgePortAttributeRequest{Oid: outputId, AttrType: []saipb.BridgePortAttr{saipb.BridgePortAttr_BRIDGE_PORT_ATTR_PORT_ID}} + resp := &saipb.GetBridgePortAttributeResponse{} + if err := mg.mgr.PopulateAttributes(req, resp); err != nil { + return 0, fmt.Errorf("failed to populate OutputId (oid=%d): %v", outputId, err) + } + if resp.GetAttr().PortId == nil { + return 0, fmt.Errorf("cannot find portId for bridge port %q", outputId) + } + return resp.GetAttr().GetPortId(), nil +} + // updateGroupMember updates the member of a L2MC group. // If m is nil, remove mid from the group(key: group id), otherwise add m to groups with mid as the key. func (mg *l2mcGroup) updateGroupMember(ctx context.Context, gid, mid uint64, m *l2mcGroupMember) error { - if mg.groups[gid] == nil { - return status.Errorf(codes.FailedPrecondition, "L2MC group %d does not exist", gid) - } if m == nil { // Remove the member. delete(mg.groups[gid], mid) @@ -113,13 +123,17 @@ func (mg *l2mcGroup) updateGroupMember(ctx context.Context, gid, mid uint64, m * } var actions []*fwdpb.ActionDesc for _, member := range mg.groups[gid] { + portId, err := mg.portNidFromBrirdgeId(ctx, member.outputId) + if err != nil { + return err + } actions = append(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(member.outputId), + Id: fmt.Sprint(portId), }, }, }, @@ -156,6 +170,12 @@ func (mg *l2mcGroup) updateGroupMember(ctx context.Context, gid, mid uint64, m * } func (mg *l2mcGroup) CreateL2McGroupMember(ctx context.Context, req *saipb.CreateL2McGroupMemberRequest) (*saipb.CreateL2McGroupMemberResponse, error) { + if mg.groups[req.GetL2McGroupId()] == nil { + return nil, status.Errorf(codes.FailedPrecondition, "cannot find L2MC group with group ID=%d", req.GetL2McGroupId()) + } + if _, err := mg.portNidFromBrirdgeId(ctx, req.GetL2McOutputId()); err != nil { + return nil, err + } id := mg.mgr.NextID() if err := mg.updateGroupMember(ctx, req.GetL2McGroupId(), id, &l2mcGroupMember{ oid: id, @@ -169,9 +189,9 @@ func (mg *l2mcGroup) CreateL2McGroupMember(ctx context.Context, req *saipb.Creat func (mg *l2mcGroup) RemoveL2McGroup(ctx context.Context, req *saipb.RemoveL2McGroupRequest) (*saipb.RemoveL2McGroupResponse, error) { if mg.groups[req.GetOid()] == nil { - return nil, fmt.Errorf("cannot find L2MC group %q", req.GetOid()) + return nil, status.Errorf(codes.FailedPrecondition, "cannot find L2MC group %q", req.GetOid()) } - // Remove all members in the group + // Remove all members in the group. for _, p := range mg.groups[req.GetOid()] { _, err := attrmgr.InvokeAndSave(ctx, mg.mgr, mg.RemoveL2McGroupMember, &saipb.RemoveL2McGroupMemberRequest{ Oid: p.oid, @@ -196,7 +216,7 @@ func (mg *l2mcGroup) RemoveL2McGroupMember(ctx context.Context, req *saipb.Remov } m := locateMember(req.GetOid()) if m == nil { - return nil, fmt.Errorf("cannot find member with OID %d", req.GetOid()) + return nil, status.Errorf(codes.FailedPrecondition, "cannot find L2MC group member with OID %d", req.GetOid()) } if err := mg.updateGroupMember(ctx, m.groupId, m.oid, nil); err != nil { return nil, err diff --git a/dataplane/saiserver/l2mc_test.go b/dataplane/saiserver/l2mc_test.go new file mode 100644 index 00000000..3281134e --- /dev/null +++ b/dataplane/saiserver/l2mc_test.go @@ -0,0 +1,303 @@ +// Copyright 2024 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package saiserver + +import ( + "context" + "fmt" + "testing" + + "github.com/google/go-cmp/cmp" + "github.com/openconfig/gnmi/errdiff" + "google.golang.org/grpc" + "google.golang.org/protobuf/proto" + "google.golang.org/protobuf/testing/protocmp" + + saipb "github.com/openconfig/lemming/dataplane/proto/sai" + "github.com/openconfig/lemming/dataplane/saiserver/attrmgr" + fwdpb "github.com/openconfig/lemming/proto/forwarding" +) + +func TestCreateL2McGroup(t *testing.T) { + tests := []struct { + desc string + req *saipb.CreateL2McGroupRequest + wantAttr *saipb.L2McGroupAttribute + wantErr string + }{ + { + desc: "success", + wantAttr: &saipb.L2McGroupAttribute{ + L2McOutputCount: proto.Uint32(0), + L2McMemberList: []uint64{}, + }, + }, + } + + for _, tt := range tests { + t.Run(tt.desc, func(t *testing.T) { + dplane := &fakeSwitchDataplane{} + c, mg, stopFn := newTestL2McGroup(t, dplane) + defer stopFn() + resp, gotErr := c.CreateL2McGroup(context.TODO(), tt.req) + if diff := errdiff.Check(gotErr, tt.wantErr); diff != "" { + t.Fatalf("CreateL2McGroup() unexpected err: %s", diff) + } + if gotErr != nil { + return + } + attr := &saipb.L2McGroupAttribute{} + if err := mg.mgr.PopulateAllAttributes(fmt.Sprint(resp.GetOid()), attr); err != nil { + t.Fatal(err) + } + if d := cmp.Diff(attr, tt.wantAttr, protocmp.Transform()); d != "" { + t.Errorf("CreateL2McGroup() failed: diff(-got,+want)\n:%s", d) + } + }) + } +} + +func TestCreateL2McGroupMember(t *testing.T) { + bridgePort1Id := uint64(101) + port1Id := uint64(1001) + + tests := []struct { + desc string + withBridgePort bool + req *saipb.CreateL2McGroupMemberRequest + want *fwdpb.TableEntryAddRequest + wantAttr *saipb.L2McGroupMemberAttribute + wantErr string + }{{ + desc: "no bridge port", + req: &saipb.CreateL2McGroupMemberRequest{ + Switch: 1, + L2McOutputId: proto.Uint64(111), + }, + wantErr: "failed to populate OutputId", + }, { + desc: "no group", + withBridgePort: true, + req: &saipb.CreateL2McGroupMemberRequest{ + Switch: 1, + L2McGroupId: proto.Uint64(999), + L2McOutputId: proto.Uint64(100), + }, + wantErr: "cannot find L2MC group with group ID", + }, { + desc: "success", + withBridgePort: true, + req: &saipb.CreateL2McGroupMemberRequest{ + Switch: 1, + L2McOutputId: proto.Uint64(bridgePort1Id), + }, + want: &fwdpb.TableEntryAddRequest{ + ContextId: &fwdpb.ContextId{Id: "foo"}, + TableId: &fwdpb.TableId{ObjectId: &fwdpb.ObjectId{Id: L2MCGroupTable}}, + Entries: []*fwdpb.TableEntryAddRequest_Entry{ + { + EntryDesc: &fwdpb.EntryDesc{ + Entry: &fwdpb.EntryDesc_Exact{ + Exact: &fwdpb.ExactEntryDesc{ + Fields: []*fwdpb.PacketFieldBytes{{ + FieldId: &fwdpb.PacketFieldId{Field: &fwdpb.PacketField{FieldNum: fwdpb.PacketFieldNum_PACKET_FIELD_NUM_L2MC_GROUP_ID}}, + Bytes: []byte{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01}, + }}, + }, + }, + }, + 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(port1Id)}}}, + }, + }, + }, + }, + }, + }, + wantAttr: &saipb.L2McGroupMemberAttribute{ + L2McGroupId: proto.Uint64(1), + L2McOutputId: proto.Uint64(bridgePort1Id), + }, + }} + + for _, tt := range tests { + t.Run(tt.desc, func(t *testing.T) { + dplane := &fakeSwitchDataplane{} + c, mg, stopFn := newTestL2McGroup(t, dplane) + if tt.withBridgePort { + mg.mgr.StoreAttributes(bridgePort1Id, &saipb.BridgePortAttribute{PortId: proto.Uint64(port1Id)}) + } + defer stopFn() + ctx := context.TODO() + resp, err := c.CreateL2McGroup(ctx, &saipb.CreateL2McGroupRequest{ + Switch: *proto.Uint64(1), + }) + if err != nil { + t.Fatalf("failed to create L2MC group: %v", err) + } + if tt.req.L2McGroupId == nil { + tt.req.L2McGroupId = &resp.Oid + } + mResp, gotErr := c.CreateL2McGroupMember(ctx, tt.req) + if diff := errdiff.Check(gotErr, tt.wantErr); diff != "" { + t.Fatalf("CreateL2McGroupMember() unexpected err: %s", diff) + } + if gotErr != nil { + return + } + if d := cmp.Diff(dplane.gotEntryAddReqs[0], tt.want, protocmp.Transform()); d != "" { + t.Errorf("CreateL2McGroupMember() request check failed: diff(-got,+want)\n:%s", d) + } + attr := &saipb.L2McGroupMemberAttribute{} + if err := mg.mgr.PopulateAllAttributes(fmt.Sprint(mResp.GetOid()), attr); err != nil { + t.Fatal(err) + } + if d := cmp.Diff(attr, tt.wantAttr, protocmp.Transform()); d != "" { + t.Errorf("CreateL2McGroupMember() group attribute check failed: diff(-got,+want)\n:%s", d) + } + }) + } +} + +func TestRemoveL2McGroupMember(t *testing.T) { + bridgePort1Id := uint64(101) + bridgePort2Id := uint64(102) + port1Id := uint64(1001) + port2Id := uint64(1002) + + tests := []struct { + desc string + req *saipb.RemoveL2McGroupMemberRequest + want *fwdpb.TableEntryAddRequest + wantAttr *saipb.L2McGroupMemberAttribute + wantGroupAttr *saipb.L2McGroupAttribute + wantErr string + }{{ + desc: "non-existing member", + req: &saipb.RemoveL2McGroupMemberRequest{ + Oid: 123, + }, + wantErr: "cannot find L2MC group member with OID", + }, { + desc: "success", + req: &saipb.RemoveL2McGroupMemberRequest{ + Oid: 2, // first member. + }, + want: &fwdpb.TableEntryAddRequest{ + ContextId: &fwdpb.ContextId{Id: "foo"}, + TableId: &fwdpb.TableId{ObjectId: &fwdpb.ObjectId{Id: L2MCGroupTable}}, + Entries: []*fwdpb.TableEntryAddRequest_Entry{ + { + EntryDesc: &fwdpb.EntryDesc{ + Entry: &fwdpb.EntryDesc_Exact{ + Exact: &fwdpb.ExactEntryDesc{ + Fields: []*fwdpb.PacketFieldBytes{{ + FieldId: &fwdpb.PacketFieldId{Field: &fwdpb.PacketField{FieldNum: fwdpb.PacketFieldNum_PACKET_FIELD_NUM_L2MC_GROUP_ID}}, + Bytes: []byte{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01}, + }}, + }, + }, + }, + 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(port1Id)}}}, + }, + }, + }, + }, + }, + }, + wantGroupAttr: &saipb.L2McGroupAttribute{ + L2McOutputCount: proto.Uint32(1), + L2McMemberList: []uint64{3}, + }, + wantAttr: &saipb.L2McGroupMemberAttribute{ + L2McGroupId: proto.Uint64(1), + L2McOutputId: proto.Uint64(bridgePort2Id), + }, + }} + + for _, tt := range tests { + t.Run(tt.desc, func(t *testing.T) { + dplane := &fakeSwitchDataplane{} + c, mg, stopFn := newTestL2McGroup(t, dplane) + mg.mgr.StoreAttributes(bridgePort1Id, &saipb.BridgePortAttribute{PortId: proto.Uint64(port1Id)}) + mg.mgr.StoreAttributes(bridgePort2Id, &saipb.BridgePortAttribute{PortId: proto.Uint64(port2Id)}) + defer stopFn() + ctx := context.TODO() + // Create one group with 2 members (OID 2 and 3 repectively). + resp, err := c.CreateL2McGroup(ctx, &saipb.CreateL2McGroupRequest{ + Switch: *proto.Uint64(1), + }) + if err != nil { + t.Fatalf("failed to create L2MC group: %v", err) + } + groupId := resp.GetOid() + _, err = c.CreateL2McGroupMember(ctx, &saipb.CreateL2McGroupMemberRequest{ + L2McGroupId: &groupId, + L2McOutputId: proto.Uint64(bridgePort1Id), + }) + if err != nil { + t.Fatal(err) + } + mResp2, err := c.CreateL2McGroupMember(ctx, &saipb.CreateL2McGroupMemberRequest{ + L2McGroupId: &groupId, + L2McOutputId: proto.Uint64(bridgePort2Id), + }) + if err != nil { + t.Fatal(err) + } + // Remove the 1st member if the test gets here. + _, gotErr := c.RemoveL2McGroupMember(ctx, tt.req) + if diff := errdiff.Check(gotErr, tt.wantErr); diff != "" { + t.Fatalf("RemoveL2McGroupMember() unexpected err: %s", diff) + } + if gotErr != nil { + return + } + + if d := cmp.Diff(dplane.gotEntryAddReqs[0], tt.want, protocmp.Transform()); d != "" { + t.Errorf("RemoveL2McGroupMember() request check failed: diff(-got,+want)\n:%s", d) + } + attr := &saipb.L2McGroupMemberAttribute{} + if err := mg.mgr.PopulateAllAttributes(fmt.Sprint(mResp2.GetOid()), attr); err != nil { + t.Fatal(err) + } + if d := cmp.Diff(attr, tt.wantAttr, protocmp.Transform()); d != "" { + t.Errorf("RemoveL2McGroupMember() member attribute check failed: diff(-got,+want)\n:%s", d) + } + gAttr := &saipb.L2McGroupAttribute{} + if err := mg.mgr.PopulateAllAttributes(fmt.Sprint(groupId), gAttr); err != nil { + t.Fatal(err) + } + if d := cmp.Diff(gAttr, tt.wantGroupAttr, protocmp.Transform()); d != "" { + t.Errorf("RemoveL2McGroupMember() group attribute check failed: diff(-got,+want)\n:%s", d) + } + }) + } +} + +func newTestL2McGroup(t testing.TB, api switchDataplaneAPI) (saipb.L2McGroupClient, *l2mcGroup, func()) { + var p *l2mcGroup + conn, _, stopFn := newTestServer(t, func(mgr *attrmgr.AttrMgr, srv *grpc.Server) { + p = newL2mcGroup(mgr, api, srv) + }) + return saipb.NewL2McGroupClient(conn), p, stopFn +} From 2812208793177299a2909fd5e7e188b8f823261b Mon Sep 17 00:00:00 2001 From: Guo-shiuan Wang Date: Fri, 19 Jul 2024 02:16:22 +0000 Subject: [PATCH 07/11] Refactor the code. --- dataplane/saiserver/l2.go | 37 ++++++++++++------------------------- 1 file changed, 12 insertions(+), 25 deletions(-) diff --git a/dataplane/saiserver/l2.go b/dataplane/saiserver/l2.go index b9a77bca..9f4f9b3e 100644 --- a/dataplane/saiserver/l2.go +++ b/dataplane/saiserver/l2.go @@ -87,21 +87,6 @@ func (mg *l2mcGroup) updateGroupMember(ctx context.Context, gid, mid uint64, m * if len(mg.groups[gid]) == 0 { delete(mg.groups, gid) } - gReq := &saipb.GetL2McGroupAttributeRequest{Oid: gid, AttrType: []saipb.L2McGroupAttr{saipb.L2McGroupAttr_L2MC_GROUP_ATTR_L2MC_MEMBER_LIST, saipb.L2McGroupAttr_L2MC_GROUP_ATTR_L2MC_OUTPUT_COUNT}} - gResp := &saipb.GetL2McGroupAttributeResponse{} - if err := mg.mgr.PopulateAttributes(gReq, gResp); err != nil { - return err - } - gAttrs := gResp.GetAttr() - newMemList := []uint64{} - for _, i := range gAttrs.GetL2McMemberList() { - if i != mid { - newMemList = append(newMemList, i) - } - } - gAttrs.L2McMemberList = newMemList - *gAttrs.L2McOutputCount -= 1 - mg.mgr.StoreAttributes(gid, gAttrs) } else { // Add a member. mg.groups[gid][mid] = m @@ -110,17 +95,19 @@ func (mg *l2mcGroup) updateGroupMember(ctx context.Context, gid, mid uint64, m * L2McOutputId: &m.outputId, } mg.mgr.StoreAttributes(mid, attr) - // Update L2MC Group Attributes. - gReq := &saipb.GetL2McGroupAttributeRequest{Oid: gid, AttrType: []saipb.L2McGroupAttr{saipb.L2McGroupAttr_L2MC_GROUP_ATTR_L2MC_MEMBER_LIST, saipb.L2McGroupAttr_L2MC_GROUP_ATTR_L2MC_OUTPUT_COUNT}} - gResp := &saipb.GetL2McGroupAttributeResponse{} - if err := mg.mgr.PopulateAttributes(gReq, gResp); err != nil { - return err - } - gAttrs := gResp.GetAttr() - gAttrs.L2McMemberList = append(gAttrs.GetL2McMemberList(), mid) - *gAttrs.L2McOutputCount += 1 - mg.mgr.StoreAttributes(gid, gAttrs) } + mList := []uint64{} + for _, m := range mg.groups[gid] { + mList = append(mList, m.oid) + } + gAttr := &saipb.L2McGroupAttribute{} + if err := mg.mgr.PopulateAllAttributes(fmt.Sprint(gid), gAttr); err != nil { + return err + } + gAttr.L2McMemberList = mList + *gAttr.L2McOutputCount = uint32(len(mList)) + mg.mgr.StoreAttributes(gid, gAttr) + var actions []*fwdpb.ActionDesc for _, member := range mg.groups[gid] { portId, err := mg.portNidFromBrirdgeId(ctx, member.outputId) From 6e9648627a3582d96557b6ec5b4cad1ea4f58054 Mon Sep 17 00:00:00 2001 From: Guo-shiuan Wang Date: Fri, 19 Jul 2024 05:27:13 +0000 Subject: [PATCH 08/11] Regen proto and fix build error. --- dataplane/saiserver/acl.go | 1 + proto/forwarding/forwarding_common.pb.go | 192 +++++++++++------------ 2 files changed, 97 insertions(+), 96 deletions(-) diff --git a/dataplane/saiserver/acl.go b/dataplane/saiserver/acl.go index 110375af..c83296f1 100644 --- a/dataplane/saiserver/acl.go +++ b/dataplane/saiserver/acl.go @@ -339,6 +339,7 @@ func (a *acl) CreateAclEntry(ctx context.Context, req *saipb.CreateAclEntryReque default: return nil, status.Errorf(codes.InvalidArgument, "type %q is not supported; only support L2MC Group for ACL Redirect for now", typ.String()) } + } if req.ActionSetPolicer != nil { aReq.Actions = append(aReq.Actions, fwdconfig.Action(fwdconfig.UpdateAction(fwdpb.UpdateType_UPDATE_TYPE_SET, fwdpb.PacketFieldNum_PACKET_FIELD_NUM_POLICER_ID). diff --git a/proto/forwarding/forwarding_common.pb.go b/proto/forwarding/forwarding_common.pb.go index f8f77c37..bfa78e1a 100644 --- a/proto/forwarding/forwarding_common.pb.go +++ b/proto/forwarding/forwarding_common.pb.go @@ -2723,8 +2723,7 @@ var file_proto_forwarding_forwarding_common_proto_rawDesc = []byte{ 0x0a, 0x13, 0x50, 0x41, 0x43, 0x4b, 0x45, 0x54, 0x5f, 0x48, 0x45, 0x41, 0x44, 0x45, 0x52, 0x5f, 0x49, 0x44, 0x5f, 0x49, 0x50, 0x10, 0x13, 0x12, 0x1b, 0x0a, 0x16, 0x50, 0x41, 0x43, 0x4b, 0x45, 0x54, 0x5f, 0x48, 0x45, 0x41, 0x44, 0x45, 0x52, 0x5f, 0x49, 0x44, 0x5f, 0x43, 0x4f, 0x55, 0x4e, - 0x54, 0x10, 0xe8, 0x07, 0x2a, 0xb1, 0x0c, 0x0a, 0x0e, 0x50, 0x61, 0x63, 0x6b, 0x65, 0x74, 0x46, - 0x54, 0x10, 0xe8, 0x07, 0x2a, 0xae, 0x0c, 0x0a, 0x0e, 0x50, 0x61, 0x63, 0x6b, 0x65, 0x74, 0x46, + 0x54, 0x10, 0xe8, 0x07, 0x2a, 0xd2, 0x0c, 0x0a, 0x0e, 0x50, 0x61, 0x63, 0x6b, 0x65, 0x74, 0x46, 0x69, 0x65, 0x6c, 0x64, 0x4e, 0x75, 0x6d, 0x12, 0x20, 0x0a, 0x1c, 0x50, 0x41, 0x43, 0x4b, 0x45, 0x54, 0x5f, 0x46, 0x49, 0x45, 0x4c, 0x44, 0x5f, 0x4e, 0x55, 0x4d, 0x5f, 0x55, 0x4e, 0x53, 0x50, 0x45, 0x43, 0x49, 0x46, 0x49, 0x45, 0x44, 0x10, 0x00, 0x12, 0x19, 0x0a, 0x15, 0x50, 0x41, 0x43, @@ -2819,101 +2818,102 @@ var file_proto_forwarding_forwarding_common_proto_rawDesc = []byte{ 0x49, 0x45, 0x4c, 0x44, 0x5f, 0x4e, 0x55, 0x4d, 0x5f, 0x54, 0x55, 0x4e, 0x4e, 0x45, 0x4c, 0x5f, 0x49, 0x44, 0x10, 0x3e, 0x12, 0x21, 0x0a, 0x1d, 0x50, 0x41, 0x43, 0x4b, 0x45, 0x54, 0x5f, 0x46, 0x49, 0x45, 0x4c, 0x44, 0x5f, 0x4e, 0x55, 0x4d, 0x5f, 0x48, 0x4f, 0x53, 0x54, 0x5f, 0x50, 0x4f, - - 0x52, 0x54, 0x5f, 0x49, 0x44, 0x10, 0x3f, 0x12, 0x1f, 0x0a, 0x1b, 0x50, 0x41, 0x43, 0x4b, 0x45, - 0x54, 0x5f, 0x46, 0x49, 0x45, 0x4c, 0x44, 0x5f, 0x4e, 0x55, 0x4d, 0x5f, 0x50, 0x4f, 0x4c, 0x49, - 0x43, 0x45, 0x52, 0x5f, 0x49, 0x44, 0x10, 0x41, 0x12, 0x1b, 0x0a, 0x16, 0x50, 0x41, 0x43, 0x4b, - 0x45, 0x54, 0x5f, 0x46, 0x49, 0x45, 0x4c, 0x44, 0x5f, 0x4e, 0x55, 0x4d, 0x5f, 0x43, 0x4f, 0x55, - 0x4e, 0x54, 0x10, 0xe8, 0x07, 0x2a, 0xda, 0x0a, 0x0a, 0x09, 0x43, 0x6f, 0x75, 0x6e, 0x74, 0x65, - 0x72, 0x49, 0x64, 0x12, 0x1a, 0x0a, 0x16, 0x43, 0x4f, 0x55, 0x4e, 0x54, 0x45, 0x52, 0x5f, 0x49, - 0x44, 0x5f, 0x55, 0x4e, 0x53, 0x50, 0x45, 0x43, 0x49, 0x46, 0x49, 0x45, 0x44, 0x10, 0x00, 0x12, - 0x19, 0x0a, 0x15, 0x43, 0x4f, 0x55, 0x4e, 0x54, 0x45, 0x52, 0x5f, 0x49, 0x44, 0x5f, 0x52, 0x58, - 0x5f, 0x50, 0x41, 0x43, 0x4b, 0x45, 0x54, 0x53, 0x10, 0x01, 0x12, 0x18, 0x0a, 0x14, 0x43, 0x4f, - 0x55, 0x4e, 0x54, 0x45, 0x52, 0x5f, 0x49, 0x44, 0x5f, 0x52, 0x58, 0x5f, 0x4f, 0x43, 0x54, 0x45, - 0x54, 0x53, 0x10, 0x02, 0x12, 0x1e, 0x0a, 0x1a, 0x43, 0x4f, 0x55, 0x4e, 0x54, 0x45, 0x52, 0x5f, - 0x49, 0x44, 0x5f, 0x52, 0x58, 0x5f, 0x44, 0x52, 0x4f, 0x50, 0x5f, 0x50, 0x41, 0x43, 0x4b, 0x45, - 0x54, 0x53, 0x10, 0x03, 0x12, 0x1d, 0x0a, 0x19, 0x43, 0x4f, 0x55, 0x4e, 0x54, 0x45, 0x52, 0x5f, - 0x49, 0x44, 0x5f, 0x52, 0x58, 0x5f, 0x44, 0x52, 0x4f, 0x50, 0x5f, 0x4f, 0x43, 0x54, 0x45, 0x54, - 0x53, 0x10, 0x04, 0x12, 0x1f, 0x0a, 0x1b, 0x43, 0x4f, 0x55, 0x4e, 0x54, 0x45, 0x52, 0x5f, 0x49, - 0x44, 0x5f, 0x52, 0x58, 0x5f, 0x45, 0x52, 0x52, 0x4f, 0x52, 0x5f, 0x50, 0x41, 0x43, 0x4b, 0x45, - 0x54, 0x53, 0x10, 0x05, 0x12, 0x1e, 0x0a, 0x1a, 0x43, 0x4f, 0x55, 0x4e, 0x54, 0x45, 0x52, 0x5f, - 0x49, 0x44, 0x5f, 0x52, 0x58, 0x5f, 0x45, 0x52, 0x52, 0x4f, 0x52, 0x5f, 0x4f, 0x43, 0x54, 0x45, - 0x54, 0x53, 0x10, 0x06, 0x12, 0x19, 0x0a, 0x15, 0x43, 0x4f, 0x55, 0x4e, 0x54, 0x45, 0x52, 0x5f, - 0x49, 0x44, 0x5f, 0x54, 0x58, 0x5f, 0x50, 0x41, 0x43, 0x4b, 0x45, 0x54, 0x53, 0x10, 0x07, 0x12, - 0x18, 0x0a, 0x14, 0x43, 0x4f, 0x55, 0x4e, 0x54, 0x45, 0x52, 0x5f, 0x49, 0x44, 0x5f, 0x54, 0x58, - 0x5f, 0x4f, 0x43, 0x54, 0x45, 0x54, 0x53, 0x10, 0x08, 0x12, 0x1e, 0x0a, 0x1a, 0x43, 0x4f, 0x55, - 0x4e, 0x54, 0x45, 0x52, 0x5f, 0x49, 0x44, 0x5f, 0x54, 0x58, 0x5f, 0x44, 0x52, 0x4f, 0x50, 0x5f, - 0x50, 0x41, 0x43, 0x4b, 0x45, 0x54, 0x53, 0x10, 0x09, 0x12, 0x1d, 0x0a, 0x19, 0x43, 0x4f, 0x55, - 0x4e, 0x54, 0x45, 0x52, 0x5f, 0x49, 0x44, 0x5f, 0x54, 0x58, 0x5f, 0x44, 0x52, 0x4f, 0x50, 0x5f, - 0x4f, 0x43, 0x54, 0x45, 0x54, 0x53, 0x10, 0x0a, 0x12, 0x1f, 0x0a, 0x1b, 0x43, 0x4f, 0x55, 0x4e, - 0x54, 0x45, 0x52, 0x5f, 0x49, 0x44, 0x5f, 0x54, 0x58, 0x5f, 0x45, 0x52, 0x52, 0x4f, 0x52, 0x5f, - 0x50, 0x41, 0x43, 0x4b, 0x45, 0x54, 0x53, 0x10, 0x0b, 0x12, 0x1e, 0x0a, 0x1a, 0x43, 0x4f, 0x55, - 0x4e, 0x54, 0x45, 0x52, 0x5f, 0x49, 0x44, 0x5f, 0x54, 0x58, 0x5f, 0x45, 0x52, 0x52, 0x4f, 0x52, - 0x5f, 0x4f, 0x43, 0x54, 0x45, 0x54, 0x53, 0x10, 0x0c, 0x12, 0x20, 0x0a, 0x1c, 0x43, 0x4f, 0x55, - 0x4e, 0x54, 0x45, 0x52, 0x5f, 0x49, 0x44, 0x5f, 0x52, 0x41, 0x54, 0x45, 0x4c, 0x49, 0x4d, 0x49, - 0x54, 0x5f, 0x50, 0x41, 0x43, 0x4b, 0x45, 0x54, 0x53, 0x10, 0x0d, 0x12, 0x1f, 0x0a, 0x1b, 0x43, - 0x4f, 0x55, 0x4e, 0x54, 0x45, 0x52, 0x5f, 0x49, 0x44, 0x5f, 0x52, 0x41, 0x54, 0x45, 0x4c, 0x49, - 0x4d, 0x49, 0x54, 0x5f, 0x4f, 0x43, 0x54, 0x45, 0x54, 0x53, 0x10, 0x0e, 0x12, 0x1b, 0x0a, 0x17, - 0x43, 0x4f, 0x55, 0x4e, 0x54, 0x45, 0x52, 0x5f, 0x49, 0x44, 0x5f, 0x44, 0x52, 0x4f, 0x50, 0x5f, - 0x50, 0x41, 0x43, 0x4b, 0x45, 0x54, 0x53, 0x10, 0x0f, 0x12, 0x1a, 0x0a, 0x16, 0x43, 0x4f, 0x55, - 0x4e, 0x54, 0x45, 0x52, 0x5f, 0x49, 0x44, 0x5f, 0x44, 0x52, 0x4f, 0x50, 0x5f, 0x4f, 0x43, 0x54, - 0x45, 0x54, 0x53, 0x10, 0x10, 0x12, 0x1c, 0x0a, 0x18, 0x43, 0x4f, 0x55, 0x4e, 0x54, 0x45, 0x52, - 0x5f, 0x49, 0x44, 0x5f, 0x45, 0x52, 0x52, 0x4f, 0x52, 0x5f, 0x50, 0x41, 0x43, 0x4b, 0x45, 0x54, - 0x53, 0x10, 0x11, 0x12, 0x1b, 0x0a, 0x17, 0x43, 0x4f, 0x55, 0x4e, 0x54, 0x45, 0x52, 0x5f, 0x49, - 0x44, 0x5f, 0x45, 0x52, 0x52, 0x4f, 0x52, 0x5f, 0x4f, 0x43, 0x54, 0x45, 0x54, 0x53, 0x10, 0x12, - 0x12, 0x1d, 0x0a, 0x19, 0x43, 0x4f, 0x55, 0x4e, 0x54, 0x45, 0x52, 0x5f, 0x49, 0x44, 0x5f, 0x52, - 0x58, 0x5f, 0x42, 0x41, 0x44, 0x5f, 0x50, 0x41, 0x43, 0x4b, 0x45, 0x54, 0x53, 0x10, 0x13, 0x12, - 0x1c, 0x0a, 0x18, 0x43, 0x4f, 0x55, 0x4e, 0x54, 0x45, 0x52, 0x5f, 0x49, 0x44, 0x5f, 0x52, 0x58, - 0x5f, 0x42, 0x41, 0x44, 0x5f, 0x4f, 0x43, 0x54, 0x45, 0x54, 0x53, 0x10, 0x14, 0x12, 0x24, 0x0a, - 0x20, 0x43, 0x4f, 0x55, 0x4e, 0x54, 0x45, 0x52, 0x5f, 0x49, 0x44, 0x5f, 0x52, 0x58, 0x5f, 0x41, - 0x44, 0x4d, 0x49, 0x4e, 0x5f, 0x44, 0x52, 0x4f, 0x50, 0x5f, 0x50, 0x41, 0x43, 0x4b, 0x45, 0x54, - 0x53, 0x10, 0x15, 0x12, 0x23, 0x0a, 0x1f, 0x43, 0x4f, 0x55, 0x4e, 0x54, 0x45, 0x52, 0x5f, 0x49, - 0x44, 0x5f, 0x52, 0x58, 0x5f, 0x41, 0x44, 0x4d, 0x49, 0x4e, 0x5f, 0x44, 0x52, 0x4f, 0x50, 0x5f, - 0x4f, 0x43, 0x54, 0x45, 0x54, 0x53, 0x10, 0x16, 0x12, 0x24, 0x0a, 0x20, 0x43, 0x4f, 0x55, 0x4e, - 0x54, 0x45, 0x52, 0x5f, 0x49, 0x44, 0x5f, 0x54, 0x58, 0x5f, 0x41, 0x44, 0x4d, 0x49, 0x4e, 0x5f, - 0x44, 0x52, 0x4f, 0x50, 0x5f, 0x50, 0x41, 0x43, 0x4b, 0x45, 0x54, 0x53, 0x10, 0x17, 0x12, 0x23, - 0x0a, 0x1f, 0x43, 0x4f, 0x55, 0x4e, 0x54, 0x45, 0x52, 0x5f, 0x49, 0x44, 0x5f, 0x54, 0x58, 0x5f, - 0x41, 0x44, 0x4d, 0x49, 0x4e, 0x5f, 0x44, 0x52, 0x4f, 0x50, 0x5f, 0x4f, 0x43, 0x54, 0x45, 0x54, - 0x53, 0x10, 0x18, 0x12, 0x1d, 0x0a, 0x19, 0x43, 0x4f, 0x55, 0x4e, 0x54, 0x45, 0x52, 0x5f, 0x49, - 0x44, 0x5f, 0x4d, 0x49, 0x52, 0x52, 0x4f, 0x52, 0x5f, 0x50, 0x41, 0x43, 0x4b, 0x45, 0x54, 0x53, - 0x10, 0x19, 0x12, 0x1c, 0x0a, 0x18, 0x43, 0x4f, 0x55, 0x4e, 0x54, 0x45, 0x52, 0x5f, 0x49, 0x44, - 0x5f, 0x4d, 0x49, 0x52, 0x52, 0x4f, 0x52, 0x5f, 0x4f, 0x43, 0x54, 0x45, 0x54, 0x53, 0x10, 0x1a, - 0x12, 0x23, 0x0a, 0x1f, 0x43, 0x4f, 0x55, 0x4e, 0x54, 0x45, 0x52, 0x5f, 0x49, 0x44, 0x5f, 0x4d, - 0x49, 0x52, 0x52, 0x4f, 0x52, 0x5f, 0x45, 0x52, 0x52, 0x4f, 0x52, 0x5f, 0x50, 0x41, 0x43, 0x4b, - 0x45, 0x54, 0x53, 0x10, 0x1b, 0x12, 0x22, 0x0a, 0x1e, 0x43, 0x4f, 0x55, 0x4e, 0x54, 0x45, 0x52, - 0x5f, 0x49, 0x44, 0x5f, 0x4d, 0x49, 0x52, 0x52, 0x4f, 0x52, 0x5f, 0x45, 0x52, 0x52, 0x4f, 0x52, - 0x5f, 0x4f, 0x43, 0x54, 0x45, 0x54, 0x53, 0x10, 0x1c, 0x12, 0x22, 0x0a, 0x1e, 0x43, 0x4f, 0x55, - 0x4e, 0x54, 0x45, 0x52, 0x5f, 0x49, 0x44, 0x5f, 0x45, 0x4e, 0x43, 0x41, 0x50, 0x5f, 0x45, 0x52, - 0x52, 0x4f, 0x52, 0x5f, 0x50, 0x41, 0x43, 0x4b, 0x45, 0x54, 0x53, 0x10, 0x1d, 0x12, 0x21, 0x0a, - 0x1d, 0x43, 0x4f, 0x55, 0x4e, 0x54, 0x45, 0x52, 0x5f, 0x49, 0x44, 0x5f, 0x45, 0x4e, 0x43, 0x41, - 0x50, 0x5f, 0x45, 0x52, 0x52, 0x4f, 0x52, 0x5f, 0x4f, 0x43, 0x54, 0x45, 0x54, 0x53, 0x10, 0x1e, - 0x12, 0x22, 0x0a, 0x1e, 0x43, 0x4f, 0x55, 0x4e, 0x54, 0x45, 0x52, 0x5f, 0x49, 0x44, 0x5f, 0x44, - 0x45, 0x43, 0x41, 0x50, 0x5f, 0x45, 0x52, 0x52, 0x4f, 0x52, 0x5f, 0x50, 0x41, 0x43, 0x4b, 0x45, - 0x54, 0x53, 0x10, 0x1f, 0x12, 0x21, 0x0a, 0x1d, 0x43, 0x4f, 0x55, 0x4e, 0x54, 0x45, 0x52, 0x5f, - 0x49, 0x44, 0x5f, 0x44, 0x45, 0x43, 0x41, 0x50, 0x5f, 0x45, 0x52, 0x52, 0x4f, 0x52, 0x5f, 0x4f, - 0x43, 0x54, 0x45, 0x54, 0x53, 0x10, 0x20, 0x12, 0x22, 0x0a, 0x1e, 0x43, 0x4f, 0x55, 0x4e, 0x54, - 0x45, 0x52, 0x5f, 0x49, 0x44, 0x5f, 0x46, 0x4c, 0x4f, 0x57, 0x5f, 0x43, 0x4f, 0x55, 0x4e, 0x54, - 0x45, 0x52, 0x5f, 0x4f, 0x43, 0x54, 0x45, 0x54, 0x53, 0x10, 0x21, 0x12, 0x23, 0x0a, 0x1f, 0x43, + 0x52, 0x54, 0x5f, 0x49, 0x44, 0x10, 0x3f, 0x12, 0x22, 0x0a, 0x1e, 0x50, 0x41, 0x43, 0x4b, 0x45, + 0x54, 0x5f, 0x46, 0x49, 0x45, 0x4c, 0x44, 0x5f, 0x4e, 0x55, 0x4d, 0x5f, 0x4c, 0x32, 0x4d, 0x43, + 0x5f, 0x47, 0x52, 0x4f, 0x55, 0x50, 0x5f, 0x49, 0x44, 0x10, 0x40, 0x12, 0x1f, 0x0a, 0x1b, 0x50, + 0x41, 0x43, 0x4b, 0x45, 0x54, 0x5f, 0x46, 0x49, 0x45, 0x4c, 0x44, 0x5f, 0x4e, 0x55, 0x4d, 0x5f, + 0x50, 0x4f, 0x4c, 0x49, 0x43, 0x45, 0x52, 0x5f, 0x49, 0x44, 0x10, 0x41, 0x12, 0x1b, 0x0a, 0x16, + 0x50, 0x41, 0x43, 0x4b, 0x45, 0x54, 0x5f, 0x46, 0x49, 0x45, 0x4c, 0x44, 0x5f, 0x4e, 0x55, 0x4d, + 0x5f, 0x43, 0x4f, 0x55, 0x4e, 0x54, 0x10, 0xe8, 0x07, 0x2a, 0xda, 0x0a, 0x0a, 0x09, 0x43, 0x6f, + 0x75, 0x6e, 0x74, 0x65, 0x72, 0x49, 0x64, 0x12, 0x1a, 0x0a, 0x16, 0x43, 0x4f, 0x55, 0x4e, 0x54, + 0x45, 0x52, 0x5f, 0x49, 0x44, 0x5f, 0x55, 0x4e, 0x53, 0x50, 0x45, 0x43, 0x49, 0x46, 0x49, 0x45, + 0x44, 0x10, 0x00, 0x12, 0x19, 0x0a, 0x15, 0x43, 0x4f, 0x55, 0x4e, 0x54, 0x45, 0x52, 0x5f, 0x49, + 0x44, 0x5f, 0x52, 0x58, 0x5f, 0x50, 0x41, 0x43, 0x4b, 0x45, 0x54, 0x53, 0x10, 0x01, 0x12, 0x18, + 0x0a, 0x14, 0x43, 0x4f, 0x55, 0x4e, 0x54, 0x45, 0x52, 0x5f, 0x49, 0x44, 0x5f, 0x52, 0x58, 0x5f, + 0x4f, 0x43, 0x54, 0x45, 0x54, 0x53, 0x10, 0x02, 0x12, 0x1e, 0x0a, 0x1a, 0x43, 0x4f, 0x55, 0x4e, + 0x54, 0x45, 0x52, 0x5f, 0x49, 0x44, 0x5f, 0x52, 0x58, 0x5f, 0x44, 0x52, 0x4f, 0x50, 0x5f, 0x50, + 0x41, 0x43, 0x4b, 0x45, 0x54, 0x53, 0x10, 0x03, 0x12, 0x1d, 0x0a, 0x19, 0x43, 0x4f, 0x55, 0x4e, + 0x54, 0x45, 0x52, 0x5f, 0x49, 0x44, 0x5f, 0x52, 0x58, 0x5f, 0x44, 0x52, 0x4f, 0x50, 0x5f, 0x4f, + 0x43, 0x54, 0x45, 0x54, 0x53, 0x10, 0x04, 0x12, 0x1f, 0x0a, 0x1b, 0x43, 0x4f, 0x55, 0x4e, 0x54, + 0x45, 0x52, 0x5f, 0x49, 0x44, 0x5f, 0x52, 0x58, 0x5f, 0x45, 0x52, 0x52, 0x4f, 0x52, 0x5f, 0x50, + 0x41, 0x43, 0x4b, 0x45, 0x54, 0x53, 0x10, 0x05, 0x12, 0x1e, 0x0a, 0x1a, 0x43, 0x4f, 0x55, 0x4e, + 0x54, 0x45, 0x52, 0x5f, 0x49, 0x44, 0x5f, 0x52, 0x58, 0x5f, 0x45, 0x52, 0x52, 0x4f, 0x52, 0x5f, + 0x4f, 0x43, 0x54, 0x45, 0x54, 0x53, 0x10, 0x06, 0x12, 0x19, 0x0a, 0x15, 0x43, 0x4f, 0x55, 0x4e, + 0x54, 0x45, 0x52, 0x5f, 0x49, 0x44, 0x5f, 0x54, 0x58, 0x5f, 0x50, 0x41, 0x43, 0x4b, 0x45, 0x54, + 0x53, 0x10, 0x07, 0x12, 0x18, 0x0a, 0x14, 0x43, 0x4f, 0x55, 0x4e, 0x54, 0x45, 0x52, 0x5f, 0x49, + 0x44, 0x5f, 0x54, 0x58, 0x5f, 0x4f, 0x43, 0x54, 0x45, 0x54, 0x53, 0x10, 0x08, 0x12, 0x1e, 0x0a, + 0x1a, 0x43, 0x4f, 0x55, 0x4e, 0x54, 0x45, 0x52, 0x5f, 0x49, 0x44, 0x5f, 0x54, 0x58, 0x5f, 0x44, + 0x52, 0x4f, 0x50, 0x5f, 0x50, 0x41, 0x43, 0x4b, 0x45, 0x54, 0x53, 0x10, 0x09, 0x12, 0x1d, 0x0a, + 0x19, 0x43, 0x4f, 0x55, 0x4e, 0x54, 0x45, 0x52, 0x5f, 0x49, 0x44, 0x5f, 0x54, 0x58, 0x5f, 0x44, + 0x52, 0x4f, 0x50, 0x5f, 0x4f, 0x43, 0x54, 0x45, 0x54, 0x53, 0x10, 0x0a, 0x12, 0x1f, 0x0a, 0x1b, + 0x43, 0x4f, 0x55, 0x4e, 0x54, 0x45, 0x52, 0x5f, 0x49, 0x44, 0x5f, 0x54, 0x58, 0x5f, 0x45, 0x52, + 0x52, 0x4f, 0x52, 0x5f, 0x50, 0x41, 0x43, 0x4b, 0x45, 0x54, 0x53, 0x10, 0x0b, 0x12, 0x1e, 0x0a, + 0x1a, 0x43, 0x4f, 0x55, 0x4e, 0x54, 0x45, 0x52, 0x5f, 0x49, 0x44, 0x5f, 0x54, 0x58, 0x5f, 0x45, + 0x52, 0x52, 0x4f, 0x52, 0x5f, 0x4f, 0x43, 0x54, 0x45, 0x54, 0x53, 0x10, 0x0c, 0x12, 0x20, 0x0a, + 0x1c, 0x43, 0x4f, 0x55, 0x4e, 0x54, 0x45, 0x52, 0x5f, 0x49, 0x44, 0x5f, 0x52, 0x41, 0x54, 0x45, + 0x4c, 0x49, 0x4d, 0x49, 0x54, 0x5f, 0x50, 0x41, 0x43, 0x4b, 0x45, 0x54, 0x53, 0x10, 0x0d, 0x12, + 0x1f, 0x0a, 0x1b, 0x43, 0x4f, 0x55, 0x4e, 0x54, 0x45, 0x52, 0x5f, 0x49, 0x44, 0x5f, 0x52, 0x41, + 0x54, 0x45, 0x4c, 0x49, 0x4d, 0x49, 0x54, 0x5f, 0x4f, 0x43, 0x54, 0x45, 0x54, 0x53, 0x10, 0x0e, + 0x12, 0x1b, 0x0a, 0x17, 0x43, 0x4f, 0x55, 0x4e, 0x54, 0x45, 0x52, 0x5f, 0x49, 0x44, 0x5f, 0x44, + 0x52, 0x4f, 0x50, 0x5f, 0x50, 0x41, 0x43, 0x4b, 0x45, 0x54, 0x53, 0x10, 0x0f, 0x12, 0x1a, 0x0a, + 0x16, 0x43, 0x4f, 0x55, 0x4e, 0x54, 0x45, 0x52, 0x5f, 0x49, 0x44, 0x5f, 0x44, 0x52, 0x4f, 0x50, + 0x5f, 0x4f, 0x43, 0x54, 0x45, 0x54, 0x53, 0x10, 0x10, 0x12, 0x1c, 0x0a, 0x18, 0x43, 0x4f, 0x55, + 0x4e, 0x54, 0x45, 0x52, 0x5f, 0x49, 0x44, 0x5f, 0x45, 0x52, 0x52, 0x4f, 0x52, 0x5f, 0x50, 0x41, + 0x43, 0x4b, 0x45, 0x54, 0x53, 0x10, 0x11, 0x12, 0x1b, 0x0a, 0x17, 0x43, 0x4f, 0x55, 0x4e, 0x54, + 0x45, 0x52, 0x5f, 0x49, 0x44, 0x5f, 0x45, 0x52, 0x52, 0x4f, 0x52, 0x5f, 0x4f, 0x43, 0x54, 0x45, + 0x54, 0x53, 0x10, 0x12, 0x12, 0x1d, 0x0a, 0x19, 0x43, 0x4f, 0x55, 0x4e, 0x54, 0x45, 0x52, 0x5f, + 0x49, 0x44, 0x5f, 0x52, 0x58, 0x5f, 0x42, 0x41, 0x44, 0x5f, 0x50, 0x41, 0x43, 0x4b, 0x45, 0x54, + 0x53, 0x10, 0x13, 0x12, 0x1c, 0x0a, 0x18, 0x43, 0x4f, 0x55, 0x4e, 0x54, 0x45, 0x52, 0x5f, 0x49, + 0x44, 0x5f, 0x52, 0x58, 0x5f, 0x42, 0x41, 0x44, 0x5f, 0x4f, 0x43, 0x54, 0x45, 0x54, 0x53, 0x10, + 0x14, 0x12, 0x24, 0x0a, 0x20, 0x43, 0x4f, 0x55, 0x4e, 0x54, 0x45, 0x52, 0x5f, 0x49, 0x44, 0x5f, + 0x52, 0x58, 0x5f, 0x41, 0x44, 0x4d, 0x49, 0x4e, 0x5f, 0x44, 0x52, 0x4f, 0x50, 0x5f, 0x50, 0x41, + 0x43, 0x4b, 0x45, 0x54, 0x53, 0x10, 0x15, 0x12, 0x23, 0x0a, 0x1f, 0x43, 0x4f, 0x55, 0x4e, 0x54, + 0x45, 0x52, 0x5f, 0x49, 0x44, 0x5f, 0x52, 0x58, 0x5f, 0x41, 0x44, 0x4d, 0x49, 0x4e, 0x5f, 0x44, + 0x52, 0x4f, 0x50, 0x5f, 0x4f, 0x43, 0x54, 0x45, 0x54, 0x53, 0x10, 0x16, 0x12, 0x24, 0x0a, 0x20, + 0x43, 0x4f, 0x55, 0x4e, 0x54, 0x45, 0x52, 0x5f, 0x49, 0x44, 0x5f, 0x54, 0x58, 0x5f, 0x41, 0x44, + 0x4d, 0x49, 0x4e, 0x5f, 0x44, 0x52, 0x4f, 0x50, 0x5f, 0x50, 0x41, 0x43, 0x4b, 0x45, 0x54, 0x53, + 0x10, 0x17, 0x12, 0x23, 0x0a, 0x1f, 0x43, 0x4f, 0x55, 0x4e, 0x54, 0x45, 0x52, 0x5f, 0x49, 0x44, + 0x5f, 0x54, 0x58, 0x5f, 0x41, 0x44, 0x4d, 0x49, 0x4e, 0x5f, 0x44, 0x52, 0x4f, 0x50, 0x5f, 0x4f, + 0x43, 0x54, 0x45, 0x54, 0x53, 0x10, 0x18, 0x12, 0x1d, 0x0a, 0x19, 0x43, 0x4f, 0x55, 0x4e, 0x54, + 0x45, 0x52, 0x5f, 0x49, 0x44, 0x5f, 0x4d, 0x49, 0x52, 0x52, 0x4f, 0x52, 0x5f, 0x50, 0x41, 0x43, + 0x4b, 0x45, 0x54, 0x53, 0x10, 0x19, 0x12, 0x1c, 0x0a, 0x18, 0x43, 0x4f, 0x55, 0x4e, 0x54, 0x45, + 0x52, 0x5f, 0x49, 0x44, 0x5f, 0x4d, 0x49, 0x52, 0x52, 0x4f, 0x52, 0x5f, 0x4f, 0x43, 0x54, 0x45, + 0x54, 0x53, 0x10, 0x1a, 0x12, 0x23, 0x0a, 0x1f, 0x43, 0x4f, 0x55, 0x4e, 0x54, 0x45, 0x52, 0x5f, + 0x49, 0x44, 0x5f, 0x4d, 0x49, 0x52, 0x52, 0x4f, 0x52, 0x5f, 0x45, 0x52, 0x52, 0x4f, 0x52, 0x5f, + 0x50, 0x41, 0x43, 0x4b, 0x45, 0x54, 0x53, 0x10, 0x1b, 0x12, 0x22, 0x0a, 0x1e, 0x43, 0x4f, 0x55, + 0x4e, 0x54, 0x45, 0x52, 0x5f, 0x49, 0x44, 0x5f, 0x4d, 0x49, 0x52, 0x52, 0x4f, 0x52, 0x5f, 0x45, + 0x52, 0x52, 0x4f, 0x52, 0x5f, 0x4f, 0x43, 0x54, 0x45, 0x54, 0x53, 0x10, 0x1c, 0x12, 0x22, 0x0a, + 0x1e, 0x43, 0x4f, 0x55, 0x4e, 0x54, 0x45, 0x52, 0x5f, 0x49, 0x44, 0x5f, 0x45, 0x4e, 0x43, 0x41, + 0x50, 0x5f, 0x45, 0x52, 0x52, 0x4f, 0x52, 0x5f, 0x50, 0x41, 0x43, 0x4b, 0x45, 0x54, 0x53, 0x10, + 0x1d, 0x12, 0x21, 0x0a, 0x1d, 0x43, 0x4f, 0x55, 0x4e, 0x54, 0x45, 0x52, 0x5f, 0x49, 0x44, 0x5f, + 0x45, 0x4e, 0x43, 0x41, 0x50, 0x5f, 0x45, 0x52, 0x52, 0x4f, 0x52, 0x5f, 0x4f, 0x43, 0x54, 0x45, + 0x54, 0x53, 0x10, 0x1e, 0x12, 0x22, 0x0a, 0x1e, 0x43, 0x4f, 0x55, 0x4e, 0x54, 0x45, 0x52, 0x5f, + 0x49, 0x44, 0x5f, 0x44, 0x45, 0x43, 0x41, 0x50, 0x5f, 0x45, 0x52, 0x52, 0x4f, 0x52, 0x5f, 0x50, + 0x41, 0x43, 0x4b, 0x45, 0x54, 0x53, 0x10, 0x1f, 0x12, 0x21, 0x0a, 0x1d, 0x43, 0x4f, 0x55, 0x4e, + 0x54, 0x45, 0x52, 0x5f, 0x49, 0x44, 0x5f, 0x44, 0x45, 0x43, 0x41, 0x50, 0x5f, 0x45, 0x52, 0x52, + 0x4f, 0x52, 0x5f, 0x4f, 0x43, 0x54, 0x45, 0x54, 0x53, 0x10, 0x20, 0x12, 0x22, 0x0a, 0x1e, 0x43, 0x4f, 0x55, 0x4e, 0x54, 0x45, 0x52, 0x5f, 0x49, 0x44, 0x5f, 0x46, 0x4c, 0x4f, 0x57, 0x5f, 0x43, - 0x4f, 0x55, 0x4e, 0x54, 0x45, 0x52, 0x5f, 0x50, 0x41, 0x43, 0x4b, 0x45, 0x54, 0x53, 0x10, 0x22, - 0x12, 0x1f, 0x0a, 0x1b, 0x43, 0x4f, 0x55, 0x4e, 0x54, 0x45, 0x52, 0x5f, 0x49, 0x44, 0x5f, 0x52, - 0x58, 0x5f, 0x44, 0x45, 0x42, 0x55, 0x47, 0x5f, 0x50, 0x41, 0x43, 0x4b, 0x45, 0x54, 0x53, 0x10, - 0x23, 0x12, 0x1e, 0x0a, 0x1a, 0x43, 0x4f, 0x55, 0x4e, 0x54, 0x45, 0x52, 0x5f, 0x49, 0x44, 0x5f, - 0x52, 0x58, 0x5f, 0x44, 0x45, 0x42, 0x55, 0x47, 0x5f, 0x4f, 0x43, 0x54, 0x45, 0x54, 0x53, 0x10, - 0x24, 0x12, 0x1f, 0x0a, 0x1b, 0x43, 0x4f, 0x55, 0x4e, 0x54, 0x45, 0x52, 0x5f, 0x49, 0x44, 0x5f, - 0x52, 0x58, 0x5f, 0x55, 0x43, 0x41, 0x53, 0x54, 0x5f, 0x50, 0x41, 0x43, 0x4b, 0x45, 0x54, 0x53, - 0x10, 0x25, 0x12, 0x23, 0x0a, 0x1f, 0x43, 0x4f, 0x55, 0x4e, 0x54, 0x45, 0x52, 0x5f, 0x49, 0x44, - 0x5f, 0x52, 0x58, 0x5f, 0x4e, 0x4f, 0x4e, 0x5f, 0x55, 0x43, 0x41, 0x53, 0x54, 0x5f, 0x50, 0x41, - 0x43, 0x4b, 0x45, 0x54, 0x53, 0x10, 0x26, 0x12, 0x1f, 0x0a, 0x1b, 0x43, 0x4f, 0x55, 0x4e, 0x54, - 0x45, 0x52, 0x5f, 0x49, 0x44, 0x5f, 0x54, 0x58, 0x5f, 0x55, 0x43, 0x41, 0x53, 0x54, 0x5f, 0x50, - 0x41, 0x43, 0x4b, 0x45, 0x54, 0x53, 0x10, 0x27, 0x12, 0x23, 0x0a, 0x1f, 0x43, 0x4f, 0x55, 0x4e, - 0x54, 0x45, 0x52, 0x5f, 0x49, 0x44, 0x5f, 0x54, 0x58, 0x5f, 0x4e, 0x4f, 0x4e, 0x5f, 0x55, 0x43, - 0x41, 0x53, 0x54, 0x5f, 0x50, 0x41, 0x43, 0x4b, 0x45, 0x54, 0x53, 0x10, 0x28, 0x12, 0x13, 0x0a, - 0x0e, 0x43, 0x4f, 0x55, 0x4e, 0x54, 0x45, 0x52, 0x5f, 0x49, 0x44, 0x5f, 0x4d, 0x41, 0x58, 0x10, - 0xff, 0x01, 0x42, 0x30, 0x5a, 0x2e, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, - 0x2f, 0x6f, 0x70, 0x65, 0x6e, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2f, 0x6c, 0x65, 0x6d, 0x6d, - 0x69, 0x6e, 0x67, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x66, 0x6f, 0x72, 0x77, 0x61, 0x72, - 0x64, 0x69, 0x6e, 0x67, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x4f, 0x55, 0x4e, 0x54, 0x45, 0x52, 0x5f, 0x4f, 0x43, 0x54, 0x45, 0x54, 0x53, 0x10, 0x21, 0x12, + 0x23, 0x0a, 0x1f, 0x43, 0x4f, 0x55, 0x4e, 0x54, 0x45, 0x52, 0x5f, 0x49, 0x44, 0x5f, 0x46, 0x4c, + 0x4f, 0x57, 0x5f, 0x43, 0x4f, 0x55, 0x4e, 0x54, 0x45, 0x52, 0x5f, 0x50, 0x41, 0x43, 0x4b, 0x45, + 0x54, 0x53, 0x10, 0x22, 0x12, 0x1f, 0x0a, 0x1b, 0x43, 0x4f, 0x55, 0x4e, 0x54, 0x45, 0x52, 0x5f, + 0x49, 0x44, 0x5f, 0x52, 0x58, 0x5f, 0x44, 0x45, 0x42, 0x55, 0x47, 0x5f, 0x50, 0x41, 0x43, 0x4b, + 0x45, 0x54, 0x53, 0x10, 0x23, 0x12, 0x1e, 0x0a, 0x1a, 0x43, 0x4f, 0x55, 0x4e, 0x54, 0x45, 0x52, + 0x5f, 0x49, 0x44, 0x5f, 0x52, 0x58, 0x5f, 0x44, 0x45, 0x42, 0x55, 0x47, 0x5f, 0x4f, 0x43, 0x54, + 0x45, 0x54, 0x53, 0x10, 0x24, 0x12, 0x1f, 0x0a, 0x1b, 0x43, 0x4f, 0x55, 0x4e, 0x54, 0x45, 0x52, + 0x5f, 0x49, 0x44, 0x5f, 0x52, 0x58, 0x5f, 0x55, 0x43, 0x41, 0x53, 0x54, 0x5f, 0x50, 0x41, 0x43, + 0x4b, 0x45, 0x54, 0x53, 0x10, 0x25, 0x12, 0x23, 0x0a, 0x1f, 0x43, 0x4f, 0x55, 0x4e, 0x54, 0x45, + 0x52, 0x5f, 0x49, 0x44, 0x5f, 0x52, 0x58, 0x5f, 0x4e, 0x4f, 0x4e, 0x5f, 0x55, 0x43, 0x41, 0x53, + 0x54, 0x5f, 0x50, 0x41, 0x43, 0x4b, 0x45, 0x54, 0x53, 0x10, 0x26, 0x12, 0x1f, 0x0a, 0x1b, 0x43, + 0x4f, 0x55, 0x4e, 0x54, 0x45, 0x52, 0x5f, 0x49, 0x44, 0x5f, 0x54, 0x58, 0x5f, 0x55, 0x43, 0x41, + 0x53, 0x54, 0x5f, 0x50, 0x41, 0x43, 0x4b, 0x45, 0x54, 0x53, 0x10, 0x27, 0x12, 0x23, 0x0a, 0x1f, + 0x43, 0x4f, 0x55, 0x4e, 0x54, 0x45, 0x52, 0x5f, 0x49, 0x44, 0x5f, 0x54, 0x58, 0x5f, 0x4e, 0x4f, + 0x4e, 0x5f, 0x55, 0x43, 0x41, 0x53, 0x54, 0x5f, 0x50, 0x41, 0x43, 0x4b, 0x45, 0x54, 0x53, 0x10, + 0x28, 0x12, 0x13, 0x0a, 0x0e, 0x43, 0x4f, 0x55, 0x4e, 0x54, 0x45, 0x52, 0x5f, 0x49, 0x44, 0x5f, + 0x4d, 0x41, 0x58, 0x10, 0xff, 0x01, 0x42, 0x30, 0x5a, 0x2e, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, + 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x6f, 0x70, 0x65, 0x6e, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2f, + 0x6c, 0x65, 0x6d, 0x6d, 0x69, 0x6e, 0x67, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x66, 0x6f, + 0x72, 0x77, 0x61, 0x72, 0x64, 0x69, 0x6e, 0x67, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( From 600d27dca010e6ca20203b30d46347d0969ce125 Mon Sep 17 00:00:00 2001 From: Guo-shiuan Wang Date: Fri, 19 Jul 2024 05:43:35 +0000 Subject: [PATCH 09/11] lint --- dataplane/forwarding/protocol/attr.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/dataplane/forwarding/protocol/attr.go b/dataplane/forwarding/protocol/attr.go index e924aa2d..ebc1caec 100644 --- a/dataplane/forwarding/protocol/attr.go +++ b/dataplane/forwarding/protocol/attr.go @@ -193,8 +193,8 @@ var FieldAttr = map[fwdpb.PacketFieldNum]struct { }, fwdpb.PacketFieldNum_PACKET_FIELD_NUM_L2MC_GROUP_ID: { Sizes: []int{SizeUint64}, - }, - fwdpb.PacketFieldNum_PACKET_FIELD_NUM_POLICER_ID: { + }, + fwdpb.PacketFieldNum_PACKET_FIELD_NUM_POLICER_ID: { Sizes: []int{SizeUint64}, }, } From 19c60e0029983acc5228add4c4070a3fa67c201b Mon Sep 17 00:00:00 2001 From: Guo-shiuan Wang Date: Fri, 19 Jul 2024 06:18:10 +0000 Subject: [PATCH 10/11] Lookup L2MC group table. --- dataplane/saiserver/ports.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dataplane/saiserver/ports.go b/dataplane/saiserver/ports.go index fedc3cdd..d7be2157 100644 --- a/dataplane/saiserver/ports.go +++ b/dataplane/saiserver/ports.go @@ -448,11 +448,11 @@ func (port *port) createCPUPort(ctx context.Context) (uint64, error) { Port: &fwdpb.PortUpdateDesc_Cpu{ Cpu: &fwdpb.CPUPortUpdateDesc{ Inputs: []*fwdpb.ActionDesc{ + fwdconfig.Action(fwdconfig.LookupAction(L2MCGroupTable)).Build(), fwdconfig.Action(fwdconfig.LookupAction(hostifToPortTable)).Build(), }, Outputs: []*fwdpb.ActionDesc{ fwdconfig.Action(fwdconfig.LookupAction(trapIDToHostifTable)).Build(), - fwdconfig.Action(fwdconfig.LookupAction(L2MCGroupTable)).Build(), // Check L2MC group. fwdconfig.Action(fwdconfig.LookupAction(portToHostifTable)).Build(), }, }, From 2670669f515004e97e09af85ba12a55b972ab70a Mon Sep 17 00:00:00 2001 From: Guo-shiuan Wang Date: Fri, 19 Jul 2024 19:05:39 +0000 Subject: [PATCH 11/11] Feedback. --- dataplane/saiserver/l2.go | 24 ++++-------- dataplane/saiserver/l2mc_test.go | 63 ++++++++++++++++++++++++++++++++ 2 files changed, 71 insertions(+), 16 deletions(-) diff --git a/dataplane/saiserver/l2.go b/dataplane/saiserver/l2.go index 9f4f9b3e..a32310ad 100644 --- a/dataplane/saiserver/l2.go +++ b/dataplane/saiserver/l2.go @@ -24,6 +24,7 @@ import ( "google.golang.org/grpc/status" "google.golang.org/protobuf/proto" + "github.com/openconfig/lemming/dataplane/forwarding/fwdconfig" "github.com/openconfig/lemming/dataplane/saiserver/attrmgr" fwdpb "github.com/openconfig/lemming/proto/forwarding" @@ -84,9 +85,6 @@ func (mg *l2mcGroup) updateGroupMember(ctx context.Context, gid, mid uint64, m * if m == nil { // Remove the member. delete(mg.groups[gid], mid) - if len(mg.groups[gid]) == 0 { - delete(mg.groups, gid) - } } else { // Add a member. mg.groups[gid][mid] = m @@ -101,11 +99,9 @@ func (mg *l2mcGroup) updateGroupMember(ctx context.Context, gid, mid uint64, m * mList = append(mList, m.oid) } gAttr := &saipb.L2McGroupAttribute{} - if err := mg.mgr.PopulateAllAttributes(fmt.Sprint(gid), gAttr); err != nil { - return err - } gAttr.L2McMemberList = mList - *gAttr.L2McOutputCount = uint32(len(mList)) + cnt := uint32(len(mList)) + gAttr.L2McOutputCount = &cnt mg.mgr.StoreAttributes(gid, gAttr) var actions []*fwdpb.ActionDesc @@ -176,16 +172,12 @@ func (mg *l2mcGroup) CreateL2McGroupMember(ctx context.Context, req *saipb.Creat func (mg *l2mcGroup) RemoveL2McGroup(ctx context.Context, req *saipb.RemoveL2McGroupRequest) (*saipb.RemoveL2McGroupResponse, error) { if mg.groups[req.GetOid()] == nil { - return nil, status.Errorf(codes.FailedPrecondition, "cannot find L2MC group %q", req.GetOid()) + return nil, status.Errorf(codes.FailedPrecondition, "cannot find L2MC group with group ID=%d", req.GetOid()) } - // Remove all members in the group. - for _, p := range mg.groups[req.GetOid()] { - _, err := attrmgr.InvokeAndSave(ctx, mg.mgr, mg.RemoveL2McGroupMember, &saipb.RemoveL2McGroupMemberRequest{ - Oid: p.oid, - }) - if err != nil { - return nil, err - } + delete(mg.groups, req.GetOid()) + if _, err := mg.dataplane.TableEntryRemove(ctx, fwdconfig.TableEntryRemoveRequest(mg.dataplane.ID(), L2MCGroupTable).AppendEntry( + fwdconfig.EntryDesc(fwdconfig.ExactEntry(fwdconfig.PacketFieldBytes(fwdpb.PacketFieldNum_PACKET_FIELD_NUM_L2MC_GROUP_ID).WithUint64(req.GetOid())))).Build()); err != nil { + return nil, err } return &saipb.RemoveL2McGroupResponse{}, nil } diff --git a/dataplane/saiserver/l2mc_test.go b/dataplane/saiserver/l2mc_test.go index 3281134e..02baffe2 100644 --- a/dataplane/saiserver/l2mc_test.go +++ b/dataplane/saiserver/l2mc_test.go @@ -294,6 +294,69 @@ func TestRemoveL2McGroupMember(t *testing.T) { } } +func TestRemoveL2McGroup(t *testing.T) { + tests := []struct { + desc string + req *saipb.RemoveL2McGroupRequest + want *fwdpb.TableEntryRemoveRequest + wantErr string + }{{ + desc: "non-existing group", + req: &saipb.RemoveL2McGroupRequest{ + Oid: 123, + }, + wantErr: "cannot find L2MC group with group ID", + }, { + desc: "success", + want: &fwdpb.TableEntryRemoveRequest{ + ContextId: &fwdpb.ContextId{Id: "foo"}, + TableId: &fwdpb.TableId{ObjectId: &fwdpb.ObjectId{Id: L2MCGroupTable}}, + Entries: []*fwdpb.EntryDesc{{ + Entry: &fwdpb.EntryDesc_Exact{ + Exact: &fwdpb.ExactEntryDesc{ + Fields: []*fwdpb.PacketFieldBytes{{ + FieldId: &fwdpb.PacketFieldId{Field: &fwdpb.PacketField{FieldNum: fwdpb.PacketFieldNum_PACKET_FIELD_NUM_L2MC_GROUP_ID}}, + Bytes: []byte{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01}, + }}, + }, + }, + }}, + }, + }} + + for _, tt := range tests { + t.Run(tt.desc, func(t *testing.T) { + dplane := &fakeSwitchDataplane{} + c, _, stopFn := newTestL2McGroup(t, dplane) + defer stopFn() + ctx := context.TODO() + rmReq := &saipb.RemoveL2McGroupRequest{} + if tt.req == nil { + resp, err := c.CreateL2McGroup(ctx, &saipb.CreateL2McGroupRequest{ + Switch: *proto.Uint64(1), + }) + if err != nil { + t.Fatalf("failed to create L2MC group: %v", err) + } + rmReq.Oid = resp.GetOid() + } else { + rmReq = tt.req + } + _, gotErr := c.RemoveL2McGroup(ctx, rmReq) + if diff := errdiff.Check(gotErr, tt.wantErr); diff != "" { + t.Fatalf("RemoveL2McGroup() unexpected err: %s", diff) + } + if gotErr != nil { + return + } + + if d := cmp.Diff(dplane.gotEntryRemoveReqs[0], tt.want, protocmp.Transform()); d != "" { + t.Errorf("RemoveL2McGroup() request check failed: diff(-got,+want)\n:%s", d) + } + }) + } +} + func newTestL2McGroup(t testing.TB, api switchDataplaneAPI) (saipb.L2McGroupClient, *l2mcGroup, func()) { var p *l2mcGroup conn, _, stopFn := newTestServer(t, func(mgr *attrmgr.AttrMgr, srv *grpc.Server) {